diff options
author | Tony Crisci <tony@dubstepdish.com> | 2017-11-20 08:51:40 -0500 |
---|---|---|
committer | Tony Crisci <tony@dubstepdish.com> | 2017-11-20 08:51:40 -0500 |
commit | 444257b6b17935be5dff11791e9ac9d52cf811b7 (patch) | |
tree | 53a44251b94141f11c3c6874f3679440cc0b2287 | |
parent | 3880fb0a532d50d8efe1e080fc3e047d5d00bbfe (diff) |
xwm: selection init
-rw-r--r-- | xwayland/selection.c | 58 | ||||
-rw-r--r-- | xwayland/xwm.c | 5 | ||||
-rw-r--r-- | xwayland/xwm.h | 10 |
3 files changed, 68 insertions, 5 deletions
diff --git a/xwayland/selection.c b/xwayland/selection.c index a83e206c..c80e1db2 100644 --- a/xwayland/selection.c +++ b/xwayland/selection.c @@ -9,12 +9,28 @@ static void xwm_handle_selection_notify(struct wlr_xwm *xwm, xcb_generic_event_t static int xwm_handle_selection_property_notify(struct wlr_xwm *xwm, xcb_generic_event_t *event) { - wlr_log(L_DEBUG, "TODO: SELECTION PROPERTY NOTIFY"); - return 1; + xcb_property_notify_event_t *property_notify = + (xcb_property_notify_event_t *) event; + + if (property_notify->window == xwm->selection_window) { + if (property_notify->state == XCB_PROPERTY_NEW_VALUE && + property_notify->atom == xwm->atoms[WL_SELECTION] && + xwm->incr) + wlr_log(L_DEBUG, "TODO: get selection"); + return 1; + } else if (property_notify->window == xwm->selection_request.requestor) { + if (property_notify->state == XCB_PROPERTY_DELETE && + property_notify->atom == xwm->selection_request.property && + xwm->incr) + wlr_log(L_DEBUG, "TODO: send selection"); + return 1; + } + + return 0; } -static void xwm_handle_selection_request(struct wlr_xwm *xwm, xcb_generic_event_t - *event) { +static void xwm_handle_selection_request(struct wlr_xwm *xwm, + xcb_generic_event_t *event) { wlr_log(L_DEBUG, "TODO: SELECTION REQUEST"); return; } @@ -26,7 +42,8 @@ static int weston_wm_handle_xfixes_selection_notify(struct wlr_xwm *xwm, } -int xwm_handle_selection_event(struct wlr_xwm *xwm, xcb_generic_event_t *event) { +int xwm_handle_selection_event(struct wlr_xwm *xwm, + xcb_generic_event_t *event) { switch (event->response_type & ~0x80) { case XCB_SELECTION_NOTIFY: xwm_handle_selection_notify(xwm, event); @@ -45,3 +62,34 @@ int xwm_handle_selection_event(struct wlr_xwm *xwm, xcb_generic_event_t *event) return 0; } + +void xwm_selection_init(struct wlr_xwm *xwm) { + uint32_t values[1], mask; + + xwm->selection_request.requestor = XCB_NONE; + + values[0] = 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, values); + + xcb_set_selection_owner(xwm->xcb_conn, + xwm->selection_window, + xwm->atoms[CLIPBOARD_MANAGER], + XCB_TIME_CURRENT_TIME); + + mask = + XCB_XFIXES_SELECTION_EVENT_MASK_SET_SELECTION_OWNER | + XCB_XFIXES_SELECTION_EVENT_MASK_SELECTION_WINDOW_DESTROY | + XCB_XFIXES_SELECTION_EVENT_MASK_SELECTION_CLIENT_CLOSE; + xcb_xfixes_select_selection_input(xwm->xcb_conn, xwm->selection_window, + xwm->atoms[CLIPBOARD], mask); +} diff --git a/xwayland/xwm.c b/xwayland/xwm.c index c10aab47..febe1ea2 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -43,6 +43,9 @@ const char *atom_map[ATOM_LAST] = { "_NET_WM_STATE_MAXIMIZED_VERT", "_NET_WM_STATE_MAXIMIZED_HORZ", "WM_STATE", + "CLIPBOARD", + "_WL_SELECTION", + "CLIPBOARD_MANAGER", }; /* General helpers */ @@ -1339,6 +1342,8 @@ struct wlr_xwm *xwm_create(struct wlr_xwayland *wlr_xwayland) { xwm_set_net_active_window(xwm, XCB_WINDOW_NONE); + xwm_selection_init(xwm); + xwm->compositor_surface_create.notify = handle_compositor_surface_create; wl_signal_add(&wlr_xwayland->compositor->events.create_surface, &xwm->compositor_surface_create); diff --git a/xwayland/xwm.h b/xwayland/xwm.h index f6bec6c5..2daa4eeb 100644 --- a/xwayland/xwm.h +++ b/xwayland/xwm.h @@ -31,6 +31,9 @@ enum atom_name { _NET_WM_STATE_MAXIMIZED_VERT, _NET_WM_STATE_MAXIMIZED_HORZ, WM_STATE, + CLIPBOARD, + CLIPBOARD_MANAGER, + WL_SELECTION, ATOM_LAST, }; @@ -55,6 +58,11 @@ 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; + int incr; + struct wlr_xwayland_surface *focus_surface; struct wl_list surfaces; // wlr_xwayland_surface::link @@ -74,4 +82,6 @@ void xwm_set_cursor(struct wlr_xwm *xwm, const uint8_t *pixels, uint32_t stride, int xwm_handle_selection_event(struct wlr_xwm *xwm, xcb_generic_event_t *event); +void xwm_selection_init(struct wlr_xwm *xwm); + #endif |