diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-12-02 13:16:50 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-02 13:16:50 -0500 |
commit | 8887508fed89d59486a4abcff7a2071326ca8207 (patch) | |
tree | 169bfbf09bf0d533da13f4965b896cb1a97dc86b /include/wlr | |
parent | 3f5f4cec88868818105bdc297f89d51fa378d99d (diff) | |
parent | 9f0720c03abcc600b6156b52e367d7cafcf57644 (diff) |
Merge pull request #1397 from emersion/refactor-primary-selection
gtk-primary-selection: refactor everything, untie from seat
Diffstat (limited to 'include/wlr')
-rw-r--r-- | include/wlr/types/meson.build | 1 | ||||
-rw-r--r-- | include/wlr/types/wlr_gtk_primary_selection.h | 46 | ||||
-rw-r--r-- | include/wlr/types/wlr_primary_selection.h | 54 | ||||
-rw-r--r-- | include/wlr/types/wlr_seat.h | 15 | ||||
-rw-r--r-- | include/wlr/xwayland.h | 4 |
5 files changed, 84 insertions, 36 deletions
diff --git a/include/wlr/types/meson.build b/include/wlr/types/meson.build index df611970..491d4a50 100644 --- a/include/wlr/types/meson.build +++ b/include/wlr/types/meson.build @@ -23,6 +23,7 @@ install_headers( 'wlr_output.h', 'wlr_pointer.h', 'wlr_presentation_time.h', + 'wlr_primary_selection.h', 'wlr_region.h', 'wlr_screencopy_v1.h', 'wlr_screenshooter.h', diff --git a/include/wlr/types/wlr_gtk_primary_selection.h b/include/wlr/types/wlr_gtk_primary_selection.h index f3410f69..7cf34201 100644 --- a/include/wlr/types/wlr_gtk_primary_selection.h +++ b/include/wlr/types/wlr_gtk_primary_selection.h @@ -14,7 +14,8 @@ struct wlr_gtk_primary_selection_device_manager { struct wl_global *global; - struct wl_list resources; + struct wl_list resources; // wl_resource_get_link + struct wl_list devices; // wlr_gtk_primary_selection_device::link struct wl_listener display_destroy; @@ -25,30 +26,20 @@ struct wlr_gtk_primary_selection_device_manager { void *data; }; -struct wlr_gtk_primary_selection_source { - // source metadata - struct wl_array mime_types; - - // source implementation - void (*send)(struct wlr_gtk_primary_selection_source *source, - const char *mime_type, int32_t fd); - void (*cancel)(struct wlr_gtk_primary_selection_source *source); - - // source status - struct wlr_seat_client *seat_client; - - struct { - struct wl_signal destroy; - } events; - - void *data; -}; +/** + * A device is a per-seat object used to set and get the current selection. + */ +struct wlr_gtk_primary_selection_device { + struct wlr_gtk_primary_selection_device_manager *manager; + struct wlr_seat *seat; + struct wl_list link; // wlr_gtk_primary_selection_device_manager::devices + struct wl_list resources; // wl_resource_get_link -struct wlr_gtk_primary_selection_offer { - struct wl_resource *resource; - struct wlr_gtk_primary_selection_source *source; + struct wl_list offers; // wl_resource_get_link - struct wl_listener source_destroy; + struct wl_listener seat_destroy; + struct wl_listener seat_focus_change; + struct wl_listener seat_primary_selection; void *data; }; @@ -58,13 +49,4 @@ struct wlr_gtk_primary_selection_device_manager * void wlr_gtk_primary_selection_device_manager_destroy( struct wlr_gtk_primary_selection_device_manager *manager); -void wlr_seat_client_send_gtk_primary_selection(struct wlr_seat_client *seat_client); -void wlr_seat_set_gtk_primary_selection(struct wlr_seat *seat, - struct wlr_gtk_primary_selection_source *source, uint32_t serial); - -void wlr_gtk_primary_selection_source_init( - struct wlr_gtk_primary_selection_source *source); -void wlr_gtk_primary_selection_source_finish( - struct wlr_gtk_primary_selection_source *source); - #endif diff --git a/include/wlr/types/wlr_primary_selection.h b/include/wlr/types/wlr_primary_selection.h new file mode 100644 index 00000000..9be61acc --- /dev/null +++ b/include/wlr/types/wlr_primary_selection.h @@ -0,0 +1,54 @@ +/* + * This an unstable interface of wlroots. No guarantees are made regarding the + * future consistency of this API. + */ +#ifndef WLR_USE_UNSTABLE +#error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" +#endif + +#ifndef WLR_TYPES_WLR_PRIMARY_SELECTION_H +#define WLR_TYPES_WLR_PRIMARY_SELECTION_H + +#include <wayland-server.h> +#include <wlr/types/wlr_seat.h> + +struct wlr_primary_selection_source; + +/** + * A data source implementation. Only the `send` function is mandatory. + */ +struct wlr_primary_selection_source_impl { + void (*send)(struct wlr_primary_selection_source *source, + const char *mime_type, int fd); + void (*destroy)(struct wlr_primary_selection_source *source); +}; + +/** + * A source is the sending side of a selection. + */ +struct wlr_primary_selection_source { + const struct wlr_primary_selection_source_impl *impl; + + // source metadata + struct wl_array mime_types; + + struct { + struct wl_signal destroy; + } events; + + void *data; +}; + +void wlr_primary_selection_source_init( + struct wlr_primary_selection_source *source, + const struct wlr_primary_selection_source_impl *impl); +void wlr_primary_selection_source_destroy( + struct wlr_primary_selection_source *source); +void wlr_primary_selection_source_send( + struct wlr_primary_selection_source *source, const char *mime_type, + int fd); + +void wlr_seat_set_primary_selection(struct wlr_seat *seat, + struct wlr_primary_selection_source *source); + +#endif diff --git a/include/wlr/types/wlr_seat.h b/include/wlr/types/wlr_seat.h index 9670e6a5..942a3420 100644 --- a/include/wlr/types/wlr_seat.h +++ b/include/wlr/types/wlr_seat.h @@ -30,7 +30,6 @@ struct wlr_seat_client { struct wl_list keyboards; struct wl_list touches; struct wl_list data_devices; - struct wl_list primary_selection_devices; struct { struct wl_signal destroy; @@ -168,6 +167,10 @@ struct wlr_seat_keyboard_state { struct wlr_seat_keyboard_grab *grab; struct wlr_seat_keyboard_grab *default_grab; + + struct { + struct wl_signal focus_change; // wlr_seat_keyboard_focus_change_event + } events; }; struct wlr_seat_touch_state { @@ -181,6 +184,8 @@ struct wlr_seat_touch_state { struct wlr_seat_touch_grab *default_grab; }; +struct wlr_primary_selection_source; + struct wlr_seat { struct wl_global *global; struct wl_display *display; @@ -194,8 +199,7 @@ struct wlr_seat { struct wlr_data_source *selection_source; uint32_t selection_serial; - struct wlr_gtk_primary_selection_source *primary_selection_source; - uint32_t primary_selection_serial; + struct wlr_primary_selection_source *primary_selection_source; // `drag` goes away before `drag_source`, when the implicit grab ends struct wlr_drag *drag; @@ -248,6 +252,11 @@ struct wlr_seat_pointer_focus_change_event { double sx, sy; }; +struct wlr_seat_keyboard_focus_change_event { + struct wlr_seat *seat; + struct wlr_surface *old_surface, *new_surface; +}; + /** * Allocates a new wlr_seat and adds a wl_seat global to the display. */ diff --git a/include/wlr/xwayland.h b/include/wlr/xwayland.h index 8247aa15..40cc8848 100644 --- a/include/wlr/xwayland.h +++ b/include/wlr/xwayland.h @@ -18,6 +18,7 @@ struct wlr_xwm; struct wlr_xwayland_cursor; +struct wlr_gtk_primary_selection_device_manager; struct wlr_xwayland { pid_t pid; @@ -42,13 +43,14 @@ struct wlr_xwayland { struct wl_display *wl_display; struct wlr_compositor *compositor; struct wlr_seat *seat; - struct wl_listener seat_destroy; struct { struct wl_signal ready; struct wl_signal new_surface; } events; + struct wl_listener seat_destroy; + /** * Add a custom event handler to xwayland. Return 1 if the event was * handled or 0 to use the default wlr-xwayland handler. wlr-xwayland will |