[PATCH weston] xwayland: Create the drag-and-drop window in weston_wm_dnd_init
Derek Foreman
derekf at osg.samsung.com
Tue May 24 18:34:32 UTC 2016
On 22/02/16 12:42 PM, Carlos Garnacho wrote:
> Just to keep it hidden so far... A lot of the plumbing necessary to
> handle x11->wayland drag and drop is missing, and the current
> partial handling gets in the middle for X11 drag-and-drop itself
> to work.
>
> The approach is well directed, but needs some further work, till
> then, just keep our fake drag-and-drop target hidden. This allows
> drag-and-drop to work between X11 clients in Xwayland, and avoids
> a crash with (currently unhandled) wl_resource-less data sources.
>
> Fixes https://bugs.freedesktop.org/show_bug.cgi?id=94218
This seems to be a pretty important stop-gap patch neglected for quite
some time. :(
It looks superficially ok to me, but I'm really not equipped to provide
proper review, I'll happily:
Acked-by: Derek Foreman <derekf at osg.samsung.com>
because I trust Carlos to follow up :)
And maybe if we can get linkmauve to test, as he was the author of the
bug ticket, we can land it?
Thanks,
Derek
> Signed-off-by: Carlos Garnacho <carlosg at gnome.org>
> ---
>
> I'm sending this patch with the promise to look into improving the
> drag-and-drop interoperation situation at some point before 1.11.
>
> My intention is copying what mutter is doing currently, and works
> nicely there:
> * Set up an special pointer grab that still relays pointer and
> keyboard events to the DnD X11 source client, needed as it's
> still driving DnD as X11 expects of it.
> * Hook to motion events in that grab so we resize/move/map the
> fake DnD target window to have the same position than the
> wayland app the pointer is above. That'll make the X11 source
> side see something consistent. This is why keeping
> wm->dnd_window around makes sense IMO.
> * Reply appropriately to XdndPosition/XdndLeave/XdndDrop
> and translate those to the wayland side.
>
> But at the moment, I'm doing just the minimals to avoid the crash,
> and allow X11<->X11 drag-and-drop to work.
>
> xwayland/dnd.c | 70 ++++++++++++++++++++--------------------------------------
> 1 file changed, 24 insertions(+), 46 deletions(-)
>
> diff --git a/xwayland/dnd.c b/xwayland/dnd.c
> index f17e4cd..1130f56 100644
> --- a/xwayland/dnd.c
> +++ b/xwayland/dnd.c
> @@ -42,45 +42,6 @@
> #include "compositor.h"
> #include "hash.h"
>
> -static void
> -weston_dnd_start(struct weston_wm *wm, xcb_window_t owner)
> -{
> - uint32_t values[1], version = 4;
> -
> - wm->dnd_window = xcb_generate_id(wm->conn);
> - values[0] =
> - XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY |
> - XCB_EVENT_MASK_PROPERTY_CHANGE;
> -
> - xcb_create_window(wm->conn,
> - XCB_COPY_FROM_PARENT,
> - wm->dnd_window,
> - wm->screen->root,
> - 0, 0,
> - 8192, 8192,
> - 0,
> - XCB_WINDOW_CLASS_INPUT_ONLY,
> - wm->screen->root_visual,
> - XCB_CW_EVENT_MASK, values);
> - xcb_change_property(wm->conn,
> - XCB_PROP_MODE_REPLACE,
> - wm->dnd_window,
> - wm->atom.xdnd_aware,
> - XCB_ATOM_ATOM,
> - 32, /* format */
> - 1, &version);
> -
> - xcb_map_window(wm->conn, wm->dnd_window);
> - wm->dnd_owner = owner;
> -}
> -
> -static void
> -weston_dnd_stop(struct weston_wm *wm)
> -{
> - xcb_destroy_window(wm->conn, wm->dnd_window);
> - wm->dnd_window = XCB_WINDOW_NONE;
> -}
> -
> struct dnd_data_source {
> struct weston_data_source base;
> struct weston_wm *wm;
> @@ -233,12 +194,6 @@ weston_wm_handle_dnd_event(struct weston_wm *wm,
>
> weston_log("XdndSelection owner: %d!\n",
> xfixes_selection_notify->owner);
> -
> - if (xfixes_selection_notify->owner != XCB_WINDOW_NONE)
> - weston_dnd_start(wm, xfixes_selection_notify->owner);
> - else
> - weston_dnd_stop(wm);
> -
> return 1;
> }
>
> @@ -266,7 +221,7 @@ weston_wm_handle_dnd_event(struct weston_wm *wm,
> void
> weston_wm_dnd_init(struct weston_wm *wm)
> {
> - uint32_t mask;
> + uint32_t values[1], version = 4, mask;
>
> mask =
> XCB_XFIXES_SELECTION_EVENT_MASK_SET_SELECTION_OWNER |
> @@ -274,4 +229,27 @@ weston_wm_dnd_init(struct weston_wm *wm)
> XCB_XFIXES_SELECTION_EVENT_MASK_SELECTION_CLIENT_CLOSE;
> xcb_xfixes_select_selection_input(wm->conn, wm->selection_window,
> wm->atom.xdnd_selection, mask);
> +
> + wm->dnd_window = xcb_generate_id(wm->conn);
> + values[0] =
> + XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY |
> + XCB_EVENT_MASK_PROPERTY_CHANGE;
> +
> + xcb_create_window(wm->conn,
> + XCB_COPY_FROM_PARENT,
> + wm->dnd_window,
> + wm->screen->root,
> + 0, 0,
> + 8192, 8192,
> + 0,
> + XCB_WINDOW_CLASS_INPUT_ONLY,
> + wm->screen->root_visual,
> + XCB_CW_EVENT_MASK, values);
> + xcb_change_property(wm->conn,
> + XCB_PROP_MODE_REPLACE,
> + wm->dnd_window,
> + wm->atom.xdnd_aware,
> + XCB_ATOM_ATOM,
> + 32, /* format */
> + 1, &version);
> }
>
More information about the wayland-devel
mailing list