compositor: Add MetaDnD private function to initialize XDND

We need to set XdndAware and XdndProxy on the stage window if running
a X11 compositor, this is not necessary on wayland.

Takes over gnome-shell code doing this initialization.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/667
This commit is contained in:
Carlos Garnacho 2019-07-03 16:23:45 +02:00 committed by Carlos Garnacho
parent 84616bef27
commit 1f133b3ed2
3 changed files with 36 additions and 0 deletions

View File

@ -30,6 +30,8 @@ gboolean meta_dnd_handle_xdnd_event (MetaBackend *backend,
Display *xdisplay,
XEvent *xev);
void meta_dnd_init_xdnd (MetaX11Display *x11_display);
#ifdef HAVE_WAYLAND
void meta_dnd_wayland_handle_begin_modal (MetaCompositor *compositor);
void meta_dnd_wayland_handle_end_modal (MetaCompositor *compositor);

View File

@ -26,6 +26,7 @@
#include "compositor/compositor-private.h"
#include "core/display-private.h"
#include "backends/meta-dnd-private.h"
#include "backends/x11/meta-backend-x11.h"
#include "meta/meta-dnd.h"
#include "x11/meta-x11-display-private.h"
@ -109,6 +110,35 @@ meta_dnd_init (MetaDnd *dnd)
{
}
void
meta_dnd_init_xdnd (MetaX11Display *x11_display)
{
MetaBackend *backend = meta_get_backend ();
Display *xdisplay = x11_display->xdisplay;
Window xwindow, overlay_xwindow;
long xdnd_version = 5;
overlay_xwindow = meta_get_overlay_window (x11_display->display);
xwindow = meta_backend_x11_get_xwindow (META_BACKEND_X11 (backend));
XChangeProperty (xdisplay, xwindow,
XInternAtom (xdisplay, "XdndAware", TRUE), XA_ATOM,
32, PropModeReplace,
(const unsigned char *) &xdnd_version, 1);
XChangeProperty (xdisplay, overlay_xwindow,
XInternAtom (xdisplay, "XdndProxy", TRUE), XA_WINDOW,
32, PropModeReplace, (const unsigned char *) &xwindow, 1);
/*
* XdndProxy is additionally set on the proxy window as verification that the
* XdndProxy property on the target window isn't a left-over
*/
XChangeProperty (xdisplay, xwindow,
XInternAtom (xdisplay, "XdndProxy", TRUE), XA_WINDOW,
32, PropModeReplace, (const unsigned char *) &xwindow, 1);
}
static void
meta_dnd_notify_dnd_enter (MetaDnd *dnd)
{

View File

@ -48,6 +48,7 @@
#include <X11/extensions/Xrandr.h>
#include "backends/meta-backend-private.h"
#include "backends/meta-dnd-private.h"
#include "backends/meta-cursor-sprite-xcursor.h"
#include "backends/meta-logical-monitor.h"
#include "backends/meta-settings-private.h"
@ -1342,6 +1343,9 @@ meta_x11_display_new (MetaDisplay *display, GError **error)
meta_x11_startup_notification_init (x11_display);
meta_x11_selection_init (x11_display);
if (!meta_is_wayland_compositor ())
meta_dnd_init_xdnd (x11_display);
return x11_display;
}