mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 12:55:58 +01:00
Merge pull request #519 from emersion/xwayland-primary-selection
Implement xwayland primary selection sync
This commit is contained in:
commit
e809250171
7 changed files with 527 additions and 307 deletions
|
@ -34,6 +34,7 @@ struct wlr_data_source {
|
|||
struct wl_resource *resource;
|
||||
struct wlr_data_offer *offer;
|
||||
struct wlr_seat_client *seat_client;
|
||||
|
||||
struct wl_array mime_types;
|
||||
|
||||
bool accepted;
|
||||
|
@ -123,4 +124,8 @@ void wlr_seat_client_send_selection(struct wlr_seat_client *seat_client);
|
|||
void wlr_seat_set_selection(struct wlr_seat *seat,
|
||||
struct wlr_data_source *source, uint32_t serial);
|
||||
|
||||
void wlr_data_source_init(struct wlr_data_source *source);
|
||||
|
||||
void wlr_data_source_finish(struct wlr_data_source *source);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -48,6 +48,11 @@ void wlr_primary_selection_device_manager_destroy(
|
|||
|
||||
void wlr_seat_client_send_primary_selection(struct wlr_seat_client *seat_client);
|
||||
void wlr_seat_set_primary_selection(struct wlr_seat *seat,
|
||||
struct wlr_primary_selection_source *source, uint32_t serial);
|
||||
struct wlr_primary_selection_source *source, uint32_t serial);
|
||||
|
||||
void wlr_primary_selection_source_init(
|
||||
struct wlr_primary_selection_source *source);
|
||||
void wlr_primary_selection_source_finish(
|
||||
struct wlr_primary_selection_source *source);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -32,6 +32,7 @@ enum atom_name {
|
|||
_NET_WM_STATE_MAXIMIZED_HORZ,
|
||||
WM_STATE,
|
||||
CLIPBOARD,
|
||||
PRIMARY,
|
||||
WL_SELECTION,
|
||||
TARGETS,
|
||||
CLIPBOARD_MANAGER,
|
||||
|
@ -49,6 +50,24 @@ enum net_wm_state_action {
|
|||
NET_WM_STATE_TOGGLE = 2,
|
||||
};
|
||||
|
||||
struct wlr_xwm_selection {
|
||||
struct wlr_xwm *xwm;
|
||||
xcb_atom_t atom;
|
||||
xcb_window_t window;
|
||||
xcb_selection_request_event_t request;
|
||||
xcb_window_t owner;
|
||||
xcb_timestamp_t timestamp;
|
||||
int incr;
|
||||
int source_fd;
|
||||
int property_start;
|
||||
xcb_get_property_reply_t *property_reply;
|
||||
struct wl_event_source *property_source;
|
||||
int flush_property_on_delete;
|
||||
struct wl_array source_data;
|
||||
xcb_atom_t target;
|
||||
bool property_set;
|
||||
};
|
||||
|
||||
struct wlr_xwm {
|
||||
struct wlr_xwayland *xwayland;
|
||||
struct wl_event_source *event_source;
|
||||
|
@ -63,20 +82,9 @@ struct wlr_xwm {
|
|||
xcb_render_pictformat_t render_format_id;
|
||||
xcb_cursor_t cursor;
|
||||
|
||||
// selection properties
|
||||
xcb_window_t selection_window;
|
||||
xcb_selection_request_event_t selection_request;
|
||||
xcb_window_t selection_owner;
|
||||
xcb_timestamp_t selection_timestamp;
|
||||
int incr;
|
||||
int data_source_fd;
|
||||
int property_start;
|
||||
xcb_get_property_reply_t *property_reply;
|
||||
struct wl_event_source *property_source;
|
||||
int flush_property_on_delete;
|
||||
struct wl_array source_data;
|
||||
xcb_atom_t selection_target;
|
||||
bool selection_property_set;
|
||||
struct wlr_xwm_selection clipboard_selection;
|
||||
struct wlr_xwm_selection primary_selection;
|
||||
|
||||
struct wlr_xwayland_surface *focus_surface;
|
||||
|
||||
|
@ -86,7 +94,8 @@ struct wlr_xwm {
|
|||
const xcb_query_extension_reply_t *xfixes;
|
||||
|
||||
struct wl_listener compositor_surface_create;
|
||||
struct wl_listener seat_selection_change;
|
||||
struct wl_listener seat_selection;
|
||||
struct wl_listener seat_primary_selection;
|
||||
};
|
||||
|
||||
struct wlr_xwm *xwm_create(struct wlr_xwayland *wlr_xwayland);
|
||||
|
|
|
@ -856,16 +856,7 @@ void data_device_manager_get_data_device(struct wl_client *client,
|
|||
static void data_source_resource_destroy(struct wl_resource *resource) {
|
||||
struct wlr_data_source *source =
|
||||
wl_resource_get_user_data(resource);
|
||||
char **p;
|
||||
|
||||
wl_signal_emit(&source->events.destroy, source);
|
||||
|
||||
wl_array_for_each(p, &source->mime_types) {
|
||||
free(*p);
|
||||
}
|
||||
|
||||
wl_array_release(&source->mime_types);
|
||||
|
||||
wlr_data_source_finish(source);
|
||||
free(source);
|
||||
}
|
||||
|
||||
|
@ -927,6 +918,25 @@ static struct wl_data_source_interface data_source_impl = {
|
|||
.set_actions = data_source_set_actions,
|
||||
};
|
||||
|
||||
void wlr_data_source_init(struct wlr_data_source *source) {
|
||||
wl_array_init(&source->mime_types);
|
||||
wl_signal_init(&source->events.destroy);
|
||||
}
|
||||
|
||||
void wlr_data_source_finish(struct wlr_data_source *source) {
|
||||
if (source == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
wl_signal_emit(&source->events.destroy, source);
|
||||
|
||||
char **p;
|
||||
wl_array_for_each(p, &source->mime_types) {
|
||||
free(*p);
|
||||
}
|
||||
wl_array_release(&source->mime_types);
|
||||
}
|
||||
|
||||
static void data_device_manager_create_data_source(struct wl_client *client,
|
||||
struct wl_resource *resource, uint32_t id) {
|
||||
struct wlr_data_source *source = calloc(1, sizeof(struct wlr_data_source));
|
||||
|
@ -934,25 +944,21 @@ static void data_device_manager_create_data_source(struct wl_client *client,
|
|||
wl_resource_post_no_memory(resource);
|
||||
return;
|
||||
}
|
||||
wlr_data_source_init(source);
|
||||
|
||||
source->resource =
|
||||
wl_resource_create(client, &wl_data_source_interface,
|
||||
wl_resource_get_version(resource), id);
|
||||
source->resource = wl_resource_create(client, &wl_data_source_interface,
|
||||
wl_resource_get_version(resource), id);
|
||||
if (source->resource == NULL) {
|
||||
free(source);
|
||||
wl_resource_post_no_memory(resource);
|
||||
return;
|
||||
}
|
||||
wl_resource_set_implementation(source->resource, &data_source_impl,
|
||||
source, data_source_resource_destroy);
|
||||
|
||||
source->accept = client_data_source_accept;
|
||||
source->send = client_data_source_send;
|
||||
source->cancel = client_data_source_cancel;
|
||||
|
||||
wl_array_init(&source->mime_types);
|
||||
wl_signal_init(&source->events.destroy);
|
||||
|
||||
wl_resource_set_implementation(source->resource, &data_source_impl,
|
||||
source, data_source_resource_destroy);
|
||||
}
|
||||
|
||||
static const struct wl_data_device_manager_interface
|
||||
|
|
|
@ -144,15 +144,7 @@ static const struct gtk_primary_selection_source_interface source_impl = {
|
|||
static void source_resource_handle_destroy(struct wl_resource *resource) {
|
||||
struct wlr_primary_selection_source *source =
|
||||
wl_resource_get_user_data(resource);
|
||||
|
||||
wl_signal_emit(&source->events.destroy, source);
|
||||
|
||||
char **p;
|
||||
wl_array_for_each(p, &source->mime_types) {
|
||||
free(*p);
|
||||
}
|
||||
wl_array_release(&source->mime_types);
|
||||
|
||||
wlr_primary_selection_source_finish(source);
|
||||
free(source);
|
||||
}
|
||||
|
||||
|
@ -262,6 +254,27 @@ static void device_resource_handle_destroy(struct wl_resource *resource) {
|
|||
}
|
||||
|
||||
|
||||
void wlr_primary_selection_source_init(
|
||||
struct wlr_primary_selection_source *source) {
|
||||
wl_array_init(&source->mime_types);
|
||||
wl_signal_init(&source->events.destroy);
|
||||
}
|
||||
|
||||
void wlr_primary_selection_source_finish(
|
||||
struct wlr_primary_selection_source *source) {
|
||||
if (source == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
wl_signal_emit(&source->events.destroy, source);
|
||||
|
||||
char **p;
|
||||
wl_array_for_each(p, &source->mime_types) {
|
||||
free(*p);
|
||||
}
|
||||
wl_array_release(&source->mime_types);
|
||||
}
|
||||
|
||||
static void device_manager_handle_create_source(struct wl_client *client,
|
||||
struct wl_resource *manager_resource, uint32_t id) {
|
||||
struct wlr_primary_selection_source *source =
|
||||
|
@ -270,6 +283,7 @@ static void device_manager_handle_create_source(struct wl_client *client,
|
|||
wl_client_post_no_memory(client);
|
||||
return;
|
||||
}
|
||||
wlr_primary_selection_source_init(source);
|
||||
|
||||
int version = wl_resource_get_version(manager_resource);
|
||||
source->resource = wl_resource_create(client,
|
||||
|
@ -284,9 +298,6 @@ static void device_manager_handle_create_source(struct wl_client *client,
|
|||
|
||||
source->send = client_source_send;
|
||||
source->cancel = client_source_cancel;
|
||||
|
||||
wl_array_init(&source->mime_types);
|
||||
wl_signal_init(&source->events.destroy);
|
||||
}
|
||||
|
||||
void device_manager_handle_get_device(struct wl_client *client,
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -46,6 +46,7 @@ const char *atom_map[ATOM_LAST] = {
|
|||
"_NET_WM_STATE_MAXIMIZED_HORZ",
|
||||
"WM_STATE",
|
||||
"CLIPBOARD",
|
||||
"PRIMARY",
|
||||
"_WL_SELECTION",
|
||||
"TARGETS",
|
||||
"CLIPBOARD_MANAGER",
|
||||
|
|
Loading…
Reference in a new issue