[gnome-shell/wip/wayland: 47/53] ShellGlobal: remove cursor manipulation functions



commit f0b0ff17a039299a1e73750a27dd78f61162773f
Author: Giovanni Campagna <gcampagn redhat com>
Date:   Wed Sep 11 17:35:58 2013 +0200

    ShellGlobal: remove cursor manipulation functions
    
    Use the new API in MetaScreen instead, which is automatically
    routed to MetaCursorTracker as appropriate.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=707467

 js/ui/dnd.js         |   21 ++++++------
 js/ui/messageTray.js |    6 ++--
 js/ui/screenshot.js  |    5 ++-
 src/shell-global.c   |   86 +-------------------------------------------------
 src/shell-global.h   |   14 --------
 5 files changed, 18 insertions(+), 114 deletions(-)
---
diff --git a/js/ui/dnd.js b/js/ui/dnd.js
index 411a1d6..96401b7 100644
--- a/js/ui/dnd.js
+++ b/js/ui/dnd.js
@@ -5,6 +5,7 @@ const GLib = imports.gi.GLib;
 const Gtk = imports.gi.Gtk;
 const St = imports.gi.St;
 const Lang = imports.lang;
+const Meta = imports.gi.Meta;
 const Shell = imports.gi.Shell;
 const Signals = imports.signals;
 const Tweener = imports.ui.tweener;
@@ -27,9 +28,9 @@ const DragMotionResult = {
 };
 
 const DRAG_CURSOR_MAP = {
-    0: Shell.Cursor.DND_UNSUPPORTED_TARGET,
-    1: Shell.Cursor.DND_COPY,
-    2: Shell.Cursor.DND_MOVE
+    0: Meta.Cursor.DND_UNSUPPORTED_TARGET,
+    1: Meta.Cursor.DND_COPY,
+    2: Meta.Cursor.DND_MOVE
 };
 
 const DragDropResult = {
@@ -244,7 +245,7 @@ const _Draggable = new Lang.Class({
         if (this._onEventId)
             this._ungrabActor();
         this._grabEvents();
-        global.set_cursor(Shell.Cursor.DND_IN_DRAG);
+        global.screen.set_cursor(Meta.Cursor.DND_IN_DRAG);
 
         this._dragX = this._dragStartX = stageX;
         this._dragY = this._dragStartY = stageY;
@@ -374,7 +375,7 @@ const _Draggable = new Lang.Class({
             if (motionFunc) {
                 let result = motionFunc(dragEvent);
                 if (result != DragMotionResult.CONTINUE) {
-                    global.set_cursor(DRAG_CURSOR_MAP[result]);
+                    global.screen.set_cursor(DRAG_CURSOR_MAP[result]);
                     return false;
                 }
             }
@@ -392,13 +393,13 @@ const _Draggable = new Lang.Class({
                                                              targY,
                                                              0);
                 if (result != DragMotionResult.CONTINUE) {
-                    global.set_cursor(DRAG_CURSOR_MAP[result]);
+                    global.screen.set_cursor(DRAG_CURSOR_MAP[result]);
                     return false;
                 }
             }
             target = target.get_parent();
         }
-        global.set_cursor(Shell.Cursor.DND_IN_DRAG);
+        global.screen.set_cursor(Shell.Cursor.DND_IN_DRAG);
         return false;
     },
 
@@ -470,7 +471,7 @@ const _Draggable = new Lang.Class({
                     }
 
                     this._dragInProgress = false;
-                    global.unset_cursor();
+                    global.screen.set_cursor(Meta.Cursor.DEFAULT);
                     this.emit('drag-end', event.get_time(), true);
                     this._dragComplete();
                     return true;
@@ -527,7 +528,7 @@ const _Draggable = new Lang.Class({
         let [snapBackX, snapBackY, snapBackScale] = this._getRestoreLocation();
 
         if (this._actorDestroyed) {
-            global.unset_cursor();
+            global.screen.set_cursor(Meta.Cursor.DEFAULT);
             if (!this._buttonDown)
                 this._dragComplete();
             this.emit('drag-end', eventTime, false);
@@ -581,7 +582,7 @@ const _Draggable = new Lang.Class({
         } else {
             dragActor.destroy();
         }
-        global.unset_cursor();
+        global.screen.set_cursor(Meta.Cursor.DEFAULT);
         this.emit('drag-end', eventTime, false);
 
         this._animationInProgress = false;
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index 69a822d..bc9136e 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -215,10 +215,10 @@ const URLHighlighter = new Lang.Class({
 
             let urlId = this._findUrlAtPos(event);
             if (urlId != -1 && !this._cursorChanged) {
-                global.set_cursor(Shell.Cursor.POINTING_HAND);
+                global.screen.set_cursor(Meta.Cursor.POINTING_HAND);
                 this._cursorChanged = true;
             } else if (urlId == -1) {
-                global.unset_cursor();
+                global.screen.set_cursor(Meta.Cursor.DEFAULT);
                 this._cursorChanged = false;
             }
             return false;
@@ -229,7 +229,7 @@ const URLHighlighter = new Lang.Class({
 
             if (this._cursorChanged) {
                 this._cursorChanged = false;
-                global.unset_cursor();
+                global.screen.set_cursor(Meta.Cursor.DEFAULT);
             }
         }));
     },
diff --git a/js/ui/screenshot.js b/js/ui/screenshot.js
index 2219a89..92efd03 100644
--- a/js/ui/screenshot.js
+++ b/js/ui/screenshot.js
@@ -6,6 +6,7 @@ const Gio = imports.gi.Gio;
 const GLib = imports.gi.GLib;
 const Gtk = imports.gi.Gtk;
 const Lang = imports.lang;
+const Meta = imports.gi.Meta;
 const Shell = imports.gi.Shell;
 const Signals = imports.signals;
 const St = imports.gi.St;
@@ -167,7 +168,7 @@ const SelectArea = new Lang.Class({
         if (!Main.pushModal(this._group) || this._group.visible)
             return;
 
-        global.set_cursor(Shell.Cursor.CROSSHAIR);
+        global.screen.set_cursor(Meta.Cursor.CROSSHAIR);
         this._group.visible = true;
     },
 
@@ -238,7 +239,7 @@ const SelectArea = new Lang.Class({
                                function() {
                                    Main.popModal(this._group);
                                    this._group.destroy();
-                                   global.unset_cursor();
+                                   global.screen.set_cursor(Meta.Cursor.DEFAULT);
 
                                    this.emit('finished', geometry);
                                })
diff --git a/src/shell-global.c b/src/shell-global.c
index 0ea3287..1d0dadc 100644
--- a/src/shell-global.c
+++ b/src/shell-global.c
@@ -27,6 +27,7 @@
 #include <meta/display.h>
 #include <meta/util.h>
 #include <meta/meta-shaped-texture.h>
+#include <meta/meta-cursor-tracker.h>
 
 /* Memory report bits */
 #ifdef HAVE_MALLINFO
@@ -600,91 +601,6 @@ sync_input_region (ShellGlobal *global)
 }
 
 /**
- * shell_global_set_cursor:
- * @global: A #ShellGlobal
- * @type: the type of the cursor
- *
- * Set the cursor on the stage window.
- */
-void
-shell_global_set_cursor (ShellGlobal *global,
-                         ShellCursor type)
-{
-  const char *name;
-  GdkCursor *cursor;
-
-  switch (type)
-    {
-    case SHELL_CURSOR_DND_IN_DRAG:
-      name = "dnd-none";
-      break;
-    case SHELL_CURSOR_DND_MOVE:
-      name = "dnd-move";
-      break;
-    case SHELL_CURSOR_DND_COPY:
-      name = "dnd-copy";
-      break;
-    case SHELL_CURSOR_DND_UNSUPPORTED_TARGET:
-      name = "dnd-none";
-      break;
-    case SHELL_CURSOR_POINTING_HAND:
-      name = "hand";
-      break;
-    case SHELL_CURSOR_CROSSHAIR:
-      name = "crosshair";
-      break;
-    default:
-      g_return_if_reached ();
-    }
-
-  cursor = gdk_cursor_new_from_name (global->gdk_display, name);
-  if (!cursor)
-    {
-      GdkCursorType cursor_type;
-      switch (type)
-        {
-        case SHELL_CURSOR_DND_IN_DRAG:
-          cursor_type = GDK_FLEUR;
-          break;
-        case SHELL_CURSOR_DND_MOVE:
-          cursor_type = GDK_TARGET;
-          break;
-        case SHELL_CURSOR_DND_COPY:
-          cursor_type = GDK_PLUS;
-          break;
-        case SHELL_CURSOR_POINTING_HAND:
-          cursor_type = GDK_HAND2;
-          break;
-        case SHELL_CURSOR_CROSSHAIR:
-          cursor_type = GDK_CROSSHAIR;
-          break;
-        case SHELL_CURSOR_DND_UNSUPPORTED_TARGET:
-          cursor_type = GDK_X_CURSOR;
-          break;
-        default:
-          g_return_if_reached ();
-        }
-      cursor = gdk_cursor_new (cursor_type);
-    }
-
-  gdk_window_set_cursor (global->stage_gdk_window, cursor);
-
-  g_object_unref (cursor);
-}
-
-/**
- * shell_global_unset_cursor:
- * @global: A #ShellGlobal
- *
- * Unset the cursor on the stage window.
- */
-void
-shell_global_unset_cursor (ShellGlobal  *global)
-{
-  gdk_window_set_cursor (global->stage_gdk_window, NULL);
-}
-
-/**
  * shell_global_set_stage_input_region:
  * @global: the #ShellGlobal
  * @rectangles: (element-type Meta.Rectangle): a list of #MetaRectangle
diff --git a/src/shell-global.h b/src/shell-global.h
index 0e11cc7..037b55f 100644
--- a/src/shell-global.h
+++ b/src/shell-global.h
@@ -50,20 +50,6 @@ void     shell_global_freeze_keyboard        (ShellGlobal         *global,
 void     shell_global_set_stage_input_region (ShellGlobal         *global,
                                               GSList              *rectangles);
 
-/* X utilities */
-typedef enum {
-  SHELL_CURSOR_DND_IN_DRAG,
-  SHELL_CURSOR_DND_UNSUPPORTED_TARGET,
-  SHELL_CURSOR_DND_MOVE,
-  SHELL_CURSOR_DND_COPY,
-  SHELL_CURSOR_POINTING_HAND,
-  SHELL_CURSOR_CROSSHAIR
-} ShellCursor;
-
-void    shell_global_set_cursor              (ShellGlobal         *global,
-                                              ShellCursor          type);
-void    shell_global_unset_cursor            (ShellGlobal         *global);
-
 void    shell_global_get_pointer             (ShellGlobal         *global,
                                               int                 *x,
                                               int                 *y,


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