[gnome-shell] xdnd: Remove XDnD handling code and receive DnD signals from mutter



commit 4b80cbe1cd9e5e3189240b79f71ad45053802b37
Author: Hyungwon Hwang <hyungwon hwang7 gmail com>
Date:   Sat Dec 24 17:56:52 2016 +0900

    xdnd: Remove XDnD handling code and receive DnD signals from mutter
    
    Move the XDnD handling code to mutter, and receive DnD handling signals from
    mutter directly.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=765003

 js/ui/xdndHandler.js     |    7 ++-
 src/gnome-shell-plugin.c |   11 +-----
 src/shell-global.c       |   94 ----------------------------------------------
 3 files changed, 5 insertions(+), 107 deletions(-)
---
diff --git a/js/ui/xdndHandler.js b/js/ui/xdndHandler.js
index 18ae23c..1557396 100644
--- a/js/ui/xdndHandler.js
+++ b/js/ui/xdndHandler.js
@@ -24,9 +24,10 @@ const XdndHandler = new Lang.Class({
         if (!Meta.is_wayland_compositor())
             global.init_xdnd();
 
-        global.connect('dnd-enter', Lang.bind(this, this._onEnter));
-        global.connect('dnd-position-change', Lang.bind(this, this._onPositionChanged));
-        global.connect('dnd-leave', Lang.bind(this, this._onLeave));
+        var dnd = Meta.get_backend().get_dnd();
+        dnd.connect('dnd-enter', Lang.bind(this, this._onEnter));
+        dnd.connect('dnd-position-change', Lang.bind(this, this._onPositionChanged));
+        dnd.connect('dnd-leave', Lang.bind(this, this._onLeave));
 
         this._windowGroupVisibilityHandlerId = 0;
     },
diff --git a/src/gnome-shell-plugin.c b/src/gnome-shell-plugin.c
index 35b9995..c9a8917 100644
--- a/src/gnome-shell-plugin.c
+++ b/src/gnome-shell-plugin.c
@@ -369,9 +369,9 @@ static gboolean
 gnome_shell_plugin_xevent_filter (MetaPlugin *plugin,
                                   XEvent     *xev)
 {
+#ifdef GLX_INTEL_swap_event
   GnomeShellPlugin *shell_plugin = GNOME_SHELL_PLUGIN (plugin);
 
-#ifdef GLX_INTEL_swap_event
   if (shell_plugin->have_swap_event &&
       xev->type == (shell_plugin->glx_event_base + GLX_BufferSwapComplete))
     {
@@ -396,15 +396,6 @@ gnome_shell_plugin_xevent_filter (MetaPlugin *plugin,
     }
 #endif
 
-  if (meta_is_wayland_compositor ())
-    return FALSE;
-
-  /*
-   * Pass the event to shell-global for XDND
-   */
-  if (_shell_global_check_xdnd_event (shell_plugin->global, xev))
-    return TRUE;
-
   return FALSE;
 }
 
diff --git a/src/shell-global.c b/src/shell-global.c
index 893cf83..3bfaba4 100644
--- a/src/shell-global.c
+++ b/src/shell-global.c
@@ -87,8 +87,6 @@ struct _ShellGlobal {
   /* For sound notifications */
   ca_context *sound_context;
 
-  guint32 xdnd_timestamp;
-
   gboolean has_modal;
   gboolean frame_timestamps;
   gboolean frame_finish_timestamp;
@@ -119,9 +117,6 @@ enum {
 /* Signals */
 enum
 {
- XDND_POSITION_CHANGED,
- XDND_LEAVE,
- XDND_ENTER,
  NOTIFY_ERROR,
  LAST_SIGNAL
 };
@@ -358,33 +353,6 @@ shell_global_class_init (ShellGlobalClass *klass)
   gobject_class->set_property = shell_global_set_property;
   gobject_class->finalize = shell_global_finalize;
 
-  /* Emitted from gnome-shell-plugin.c during event handling */
-  shell_global_signals[XDND_POSITION_CHANGED] =
-      g_signal_new ("dnd-position-change",
-                    G_TYPE_FROM_CLASS (klass),
-                    G_SIGNAL_RUN_LAST,
-                    0,
-                    NULL, NULL, NULL,
-                    G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
-
-  /* Emitted from gnome-shell-plugin.c during event handling */
-  shell_global_signals[XDND_LEAVE] =
-      g_signal_new ("dnd-leave",
-                    G_TYPE_FROM_CLASS (klass),
-                    G_SIGNAL_RUN_LAST,
-                    0,
-                    NULL, NULL, NULL,
-                    G_TYPE_NONE, 0);
-
-  /* Emitted from gnome-shell-plugin.c during event handling */
-  shell_global_signals[XDND_ENTER] =
-      g_signal_new ("dnd-enter",
-                    G_TYPE_FROM_CLASS (klass),
-                    G_SIGNAL_RUN_LAST,
-                    0,
-                    NULL, NULL, NULL,
-                    G_TYPE_NONE, 0);
-
   shell_global_signals[NOTIFY_ERROR] =
       g_signal_new ("notify-error",
                     G_TYPE_FROM_CLASS (klass),
@@ -1561,10 +1529,6 @@ shell_global_get_current_time (ShellGlobal *global)
 {
   guint32 time;
 
-  /* In case we have a xdnd timestamp use it */
-  if (global->xdnd_timestamp != 0)
-    return global->xdnd_timestamp;
-
   /* meta_display_get_current_time() will return the correct time
      when handling an X or Gdk event, but will return CurrentTime
      from some Clutter event callbacks.
@@ -1926,64 +1890,6 @@ shell_global_cancel_theme_sound (ShellGlobal *global,
   ca_context_cancel (global->sound_context, id);
 }
 
-/*
- * Process Xdnd events
- *
- * We pass the position and leave events to JS via a signal
- * where the actual drag & drop handling happens.
- *
- * http://www.freedesktop.org/wiki/Specifications/XDND
- */
-gboolean _shell_global_check_xdnd_event (ShellGlobal  *global,
-                                         XEvent       *xev)
-{
-  Window output_window = meta_get_overlay_window (global->meta_screen);
-
-  if (xev->xany.window != output_window && xev->xany.window != global->stage_xwindow)
-    return FALSE;
-
-  if (xev->xany.type == ClientMessage && xev->xclient.message_type == gdk_x11_get_xatom_by_name 
("XdndPosition"))
-    {
-      XEvent xevent;
-      Window src = xev->xclient.data.l[0];
-
-      memset (&xevent, 0, sizeof(xevent));
-      xevent.xany.type = ClientMessage;
-      xevent.xany.display = global->xdisplay;
-      xevent.xclient.window = src;
-      xevent.xclient.message_type = gdk_x11_get_xatom_by_name ("XdndStatus");
-      xevent.xclient.format = 32;
-      xevent.xclient.data.l[0] = output_window;
-      /* flags: bit 0: will we accept the drop? bit 1: do we want more position messages */
-      xevent.xclient.data.l[1] = 2;
-      xevent.xclient.data.l[4] = None;
-
-      XSendEvent (global->xdisplay, src, False, 0, &xevent);
-
-      /* Store the timestamp of the xdnd position event */
-      global->xdnd_timestamp = xev->xclient.data.l[3];
-      g_signal_emit_by_name (G_OBJECT (global), "dnd-position-change",
-                            (int)(xev->xclient.data.l[2] >> 16), (int)(xev->xclient.data.l[2] & 0xFFFF));
-      global->xdnd_timestamp = 0;
-
-      return TRUE;
-    }
-   else if (xev->xany.type == ClientMessage && xev->xclient.message_type == gdk_x11_get_xatom_by_name 
("XdndLeave"))
-    {
-      g_signal_emit_by_name (G_OBJECT (global), "dnd-leave");
-
-      return TRUE;
-    }
-   else if (xev->xany.type == ClientMessage && xev->xclient.message_type == gdk_x11_get_xatom_by_name 
("XdndEnter"))
-    {
-      g_signal_emit_by_name (G_OBJECT (global), "dnd-enter");
-
-      return TRUE;
-    }
-
-    return FALSE;
-}
-
 const char *
 shell_global_get_session_mode (ShellGlobal *global)
 {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]