#ifndef DULCEPAN_H #define DULCEPAN_H #include #include #include #include // Per-output #define DP_SWAPCHAIN_LEN 2 enum dp_status { DP_STATUS_RUNNING, DP_STATUS_SAVED, DP_STATUS_QUIT, }; struct dp_buffer { struct wl_buffer *wl_buffer; pixman_image_t *image; void *data; size_t size; bool used; }; struct dp_output { struct dp_state *state; uint32_t name; struct wl_output *wl_output; struct wl_surface *main_surface; struct zwlr_layer_surface_v1 *main_layer_surface; struct wp_viewport *main_viewport; struct wl_surface *select_surface; struct wl_subsurface *select_subsurface; struct wp_viewport *select_viewport; int width, height; int32_t transform; bool has_geom; int transformed_width, transformed_height; int effective_width, effective_height; bool initialized; struct wl_callback *redraw_callback; bool needs_redraw; struct zwlr_screencopy_frame_v1 *frame; // XXX: this is completely untested bool y_invert; struct wl_buffer *frame_buffer; int32_t frame_stride; uint32_t frame_format; void *frame_data; size_t frame_size; struct dp_buffer swapchain[DP_SWAPCHAIN_LEN]; struct wl_list link; }; struct dp_seat { struct dp_state *state; uint32_t name; struct wl_seat *wl_seat; struct wl_keyboard *keyboard; struct wl_pointer *pointer; struct xkb_keymap *xkb_keymap; struct xkb_state *xkb_state; // The output the pointer is on struct dp_output *ptr_output; // In buffer space int ptr_x, ptr_y; struct wl_list link; }; struct dp_selection { struct dp_output *output; // May be NULL int x, y, width, height; struct dp_output *interactive_output; // NULL if not interactively selecting int interactive_x, interactive_y; bool interactive_moved; }; enum dp_file_format { DP_FILE_UNKNOWN = 0, DP_FILE_PNG, DP_FILE_PPM, }; struct dp_config { pixman_color_t unselected_color; pixman_color_t selected_color; pixman_color_t border_color; int border_size; // 0 if disabled bool quick_select; }; struct dp_state { enum dp_status status; struct wl_display *display; struct wl_registry *registry; struct wl_compositor *compositor; struct wl_subcompositor *subcompositor; struct wp_viewporter *viewporter; struct wl_shm *shm; struct zwlr_layer_shell_v1 *layer_shell; struct zwlr_screencopy_manager_v1 *screencopy_manager; bool initialized; struct xkb_context *xkb_context; struct wl_list outputs; struct wl_list seats; struct dp_selection selection; struct dp_config config; const char *output_path; // May be NULL enum dp_file_format output_format; pixman_image_t *unselected_fill_image; pixman_image_t *selected_fill_image; pixman_image_t *border_fill_image; }; void dp_config_load(struct dp_config *config, const char *user_path); // When done, data must be unmapped struct wl_buffer *dp_buffer_create(struct dp_state *state, int32_t width, int32_t height, int32_t stride, uint32_t format, void **data, size_t *size); void dp_output_create(struct dp_state *state, uint32_t name, struct wl_output *wl_output); void dp_output_destroy(struct dp_output *output); void dp_output_redraw(struct dp_output *output); void dp_output_hide_surface(struct dp_output *output); void dp_seat_create(struct dp_state *state, uint32_t name, struct wl_seat *wl_seat); void dp_seat_destroy(struct dp_seat *seat); void dp_select_interactive_start( struct dp_selection *selection, struct dp_output *output, int x, int y); void dp_select_interactive_move(struct dp_selection *selection, int x, int y); void dp_select_interactive_stop(struct dp_selection *selection); void dp_select_whole(struct dp_selection *selection, struct dp_output *output); void dp_save(struct dp_state *state); void dp_log_error(const char *fmt, ...); void dp_log_fatal(const char *fmt, ...); void *dp_zalloc(size_t size); const char *dp_ext_from_path(const char *path); enum dp_file_format dp_ext_to_format(const char *ext); #endif