diff --git a/WINGs/selection.c b/WINGs/selection.c index 5d5221b..81cadfe 100644 --- a/WINGs/selection.c +++ b/WINGs/selection.c @@ -333,10 +333,9 @@ void W_HandleSelectionEvent(XEvent * event) Bool WMCreateSelectionHandler(WMView * view, Atom selection, Time timestamp, WMSelectionProcs * procs, void *cdata) { SelectionHandler *handler; - Display *dpy = W_VIEW_SCREEN(view)->display; + const W_ViewBackend *vb = view->screen->viewBackend; - XSetSelectionOwner(dpy, selection, W_VIEW_DRAWABLE(view), timestamp); - if (XGetSelectionOwner(dpy, selection) != W_VIEW_DRAWABLE(view)) { + if (!vb->selection_acquire(view->screen->viewBackendCtx, view, selection, timestamp)) { return False; } diff --git a/WINGs/wview_wl.c b/WINGs/wview_wl.c index 0b0b36e..c8b08d1 100644 --- a/WINGs/wview_wl.c +++ b/WINGs/wview_wl.c @@ -283,6 +283,18 @@ static WMPoint wl_get_screen_position(void *vctx, W_View *view) return wmkpoint(x, y); } +static Bool wl_selection_acquire(void *vctx, W_View *view, Atom selection, Time timestamp) +{ + (void)vctx; (void)view; (void)selection; (void)timestamp; + /* TODO: implement via wl_data_device */ + return True; +} + +static void wl_selection_release(void *vctx, W_View *view, Atom selection) +{ + (void)vctx; (void)view; (void)selection; +} + const W_ViewBackend W_ViewBackendWL = { .screen_init = wl_screen_init, .screen_fini = wl_screen_fini, @@ -302,4 +314,6 @@ const W_ViewBackend W_ViewBackendWL = { .set_cursor = wl_set_cursor, .redisplay = wl_redisplay, .get_screen_position = wl_get_screen_position, + .selection_acquire = wl_selection_acquire, + .selection_release = wl_selection_release, }; diff --git a/WINGs/wview_x11.c b/WINGs/wview_x11.c index c3a39fb..d3abf1e 100644 --- a/WINGs/wview_x11.c +++ b/WINGs/wview_x11.c @@ -190,6 +190,19 @@ W_View *W_GetViewForXWindow(Display *display, Window window) return NULL; } +static Bool x11_selection_acquire(void *vctx, W_View *view, Atom selection, Time timestamp) +{ + (void)vctx; + Display *dpy = view->screen->display; + XSetSelectionOwner(dpy, selection, W_VIEW_DRAWABLE(view), timestamp); + return (XGetSelectionOwner(dpy, selection) == W_VIEW_DRAWABLE(view)); +} + +static void x11_selection_release(void *vctx, W_View *view, Atom selection) +{ + (void)vctx; (void)view; (void)selection; +} + const W_ViewBackend W_ViewBackendX11 = { .screen_init = x11_screen_init, .screen_fini = x11_screen_fini, @@ -209,4 +222,6 @@ const W_ViewBackend W_ViewBackendX11 = { .set_cursor = x11_set_cursor, .redisplay = x11_redisplay, .get_screen_position = x11_get_screen_position, + .selection_acquire = x11_selection_acquire, + .selection_release = x11_selection_release, };