From dd4c8aa45e7edba468d4ff2dee6fd6f8ce42810b Mon Sep 17 00:00:00 2001 From: Tudor Brindus Date: Sun, 31 Jan 2021 12:27:54 -0500 Subject: xwayland/selection: make xwm_selection_init take a wlr_xwm_selection * This makes it consistent with xwm_selection_finish. --- xwayland/selection/selection.c | 57 ++---------------------------------------- xwayland/xwm.c | 52 +++++++++++++++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 56 deletions(-) (limited to 'xwayland') diff --git a/xwayland/selection/selection.c b/xwayland/selection/selection.c index 08d04178..c526fd2a 100644 --- a/xwayland/selection/selection.c +++ b/xwayland/selection/selection.c @@ -179,8 +179,8 @@ int xwm_handle_selection_event(struct wlr_xwm *xwm, return 0; } -static void selection_init(struct wlr_xwm *xwm, - struct wlr_xwm_selection *selection, xcb_atom_t atom) { +void xwm_selection_init(struct wlr_xwm_selection *selection, + struct wlr_xwm *xwm, xcb_atom_t atom) { selection->xwm = xwm; selection->atom = atom; selection->window = xwm->selection_window; @@ -196,59 +196,6 @@ static void selection_init(struct wlr_xwm *xwm, selection->atom, mask); } -void xwm_selection_init(struct wlr_xwm *xwm) { - // Clipboard and primary selection - uint32_t selection_values[] = { - XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_PROPERTY_CHANGE - }; - xwm->selection_window = xcb_generate_id(xwm->xcb_conn); - xcb_create_window(xwm->xcb_conn, - XCB_COPY_FROM_PARENT, - xwm->selection_window, - xwm->screen->root, - 0, 0, - 10, 10, - 0, - XCB_WINDOW_CLASS_INPUT_OUTPUT, - xwm->screen->root_visual, - XCB_CW_EVENT_MASK, selection_values); - - xcb_set_selection_owner(xwm->xcb_conn, - xwm->selection_window, - xwm->atoms[CLIPBOARD_MANAGER], - XCB_TIME_CURRENT_TIME); - - selection_init(xwm, &xwm->clipboard_selection, xwm->atoms[CLIPBOARD]); - selection_init(xwm, &xwm->primary_selection, xwm->atoms[PRIMARY]); - - // Drag'n'drop - uint32_t dnd_values[] = { - XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_PROPERTY_CHANGE - }; - xwm->dnd_window = xcb_generate_id(xwm->xcb_conn); - xcb_create_window(xwm->xcb_conn, - XCB_COPY_FROM_PARENT, - xwm->dnd_window, - xwm->screen->root, - 0, 0, - 8192, 8192, - 0, - XCB_WINDOW_CLASS_INPUT_ONLY, - xwm->screen->root_visual, - XCB_CW_EVENT_MASK, dnd_values); - - uint32_t version = XDND_VERSION; - xcb_change_property(xwm->xcb_conn, - XCB_PROP_MODE_REPLACE, - xwm->dnd_window, - xwm->atoms[DND_AWARE], - XCB_ATOM_ATOM, - 32, // format - 1, &version); - - selection_init(xwm, &xwm->dnd_selection, xwm->atoms[DND_SELECTION]); -} - void xwm_selection_finish(struct wlr_xwm_selection *selection) { if (!selection) { return; diff --git a/xwayland/xwm.c b/xwayland/xwm.c index 99417d16..be1436a5 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -1927,7 +1927,57 @@ struct wlr_xwm *xwm_create(struct wlr_xwayland *xwayland, int wm_fd) { xwm_set_net_active_window(xwm, XCB_WINDOW_NONE); - xwm_selection_init(xwm); + // Clipboard and primary selection + xwm->selection_window = xcb_generate_id(xwm->xcb_conn); + xcb_create_window( + xwm->xcb_conn, + XCB_COPY_FROM_PARENT, + xwm->selection_window, + xwm->screen->root, + 0, 0, + 10, 10, + 0, + XCB_WINDOW_CLASS_INPUT_OUTPUT, + xwm->screen->root_visual, + XCB_CW_EVENT_MASK, (uint32_t[]){ + XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_PROPERTY_CHANGE + } + ); + + xcb_set_selection_owner(xwm->xcb_conn, xwm->selection_window, + xwm->atoms[CLIPBOARD_MANAGER], XCB_TIME_CURRENT_TIME); + + xwm_selection_init(&xwm->clipboard_selection, xwm, xwm->atoms[CLIPBOARD]); + xwm_selection_init(&xwm->primary_selection, xwm, xwm->atoms[PRIMARY]); + + // Drag'n'drop + xwm->dnd_window = xcb_generate_id(xwm->xcb_conn); + xcb_create_window( + xwm->xcb_conn, + XCB_COPY_FROM_PARENT, + xwm->dnd_window, + xwm->screen->root, + 0, 0, + 8192, 8192, + 0, + XCB_WINDOW_CLASS_INPUT_ONLY, + xwm->screen->root_visual, + XCB_CW_EVENT_MASK, (uint32_t[]){ + XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_PROPERTY_CHANGE + } + ); + + xcb_change_property( + xwm->xcb_conn, + XCB_PROP_MODE_REPLACE, + xwm->dnd_window, + xwm->atoms[DND_AWARE], + XCB_ATOM_ATOM, + 32, // format + 1, &(uint32_t){XDND_VERSION} + ); + + xwm_selection_init(&xwm->dnd_selection, xwm, xwm->atoms[DND_SELECTION]); xwm->compositor_new_surface.notify = handle_compositor_new_surface; wl_signal_add(&xwayland->compositor->events.new_surface, -- cgit v1.2.3