[mutter/wip/wayland-work: 8/22] display: add support for more cursor types



commit b70b033a0d2076c2fcaf4a192ae4846c28a0337b
Author: Giovanni Campagna <gcampagn redhat com>
Date:   Wed Sep 11 17:22:14 2013 +0200

    display: add support for more cursor types
    
    These cursors are used by gnome-shell, supporting them allows
    to reduce GDK usage in the shell.
    
    Also, make meta_screen_set_cursor() public.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=707919

 src/core/display.c        |   33 +++++++++++++++++++++++++++++----
 src/core/screen-private.h |    2 --
 src/meta/common.h         |   18 ++++++++++++++++--
 src/meta/screen.h         |    4 ++++
 4 files changed, 49 insertions(+), 8 deletions(-)
---
diff --git a/src/core/display.c b/src/core/display.c
index c723b76..ffd5f6f 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -3942,7 +3942,8 @@ meta_display_create_x_cursor (MetaDisplay *display,
                               MetaCursor cursor)
 {
   Cursor xcursor;
-  guint glyph;
+  guint glyph = XC_num_glyphs;
+  const char *name = NULL;
 
   switch (cursor)
     {
@@ -3979,14 +3980,38 @@ meta_display_create_x_cursor (MetaDisplay *display,
     case META_CURSOR_BUSY:
       glyph = XC_watch;
       break;
-      
+    case META_CURSOR_DND_IN_DRAG:
+      name = "dnd-in-drag";
+      break;
+    case META_CURSOR_DND_MOVE:
+      name = "dnd-move";
+      break;
+    case META_CURSOR_DND_COPY:
+      name = "dnd-copy";
+      break;
+    case META_CURSOR_DND_UNSUPPORTED_TARGET:
+      name = "dnd-none";
+      break;
+    case META_CURSOR_POINTING_HAND:
+      glyph = XC_hand2;
+      break;
+    case META_CURSOR_CROSSHAIR:
+      glyph = XC_crosshair;
+      break;
+    case META_CURSOR_IBEAM:
+      glyph = XC_xterm;
+      break;
+
     default:
       g_assert_not_reached ();
       glyph = 0; /* silence compiler */
       break;
     }
-  
-  xcursor = XCreateFontCursor (display->xdisplay, glyph);
+
+  if (glyph < XC_num_glyphs)
+    xcursor = XCreateFontCursor (display->xdisplay, glyph);
+  else
+    xcursor = XcursorLibraryLoadCursor (display->xdisplay, name);
 
   return xcursor;
 }
diff --git a/src/core/screen-private.h b/src/core/screen-private.h
index 8ddf049..36c7a38 100644
--- a/src/core/screen-private.h
+++ b/src/core/screen-private.h
@@ -151,8 +151,6 @@ void          meta_screen_foreach_window      (MetaScreen                 *scree
                                                MetaScreenWindowFunc        func,
                                                gpointer                    data);
 
-void          meta_screen_set_cursor          (MetaScreen                 *screen,
-                                               MetaCursor                  cursor);
 void          meta_screen_update_cursor       (MetaScreen                 *screen);
 
 void          meta_screen_tab_popup_create       (MetaScreen              *screen,
diff --git a/src/meta/common.h b/src/meta/common.h
index 98f2ad7..01c2597 100644
--- a/src/meta/common.h
+++ b/src/meta/common.h
@@ -260,6 +260,13 @@ typedef enum
  * @META_CURSOR_NW_RESIZE: Resize north-western corner cursor
  * @META_CURSOR_MOVE_OR_RESIZE_WINDOW: Move or resize cursor
  * @META_CURSOR_BUSY: Busy cursor
+ * @META_CURSOR_DND_IN_DRAG: DND in drag cursor
+ * @META_CURSOR_DND_MOVE: DND move cursor
+ * @META_CURSOR_DND_COPY: DND copy cursor
+ * @META_CURSOR_DND_UNSUPPORTED_TARGET: DND unsupported target
+ * @META_CURSOR_POINTING_HAND: pointing hand
+ * @META_CURSOR_CROSSHAIR: crosshair (action forbidden)
+ * @META_CURSOR_IBEAM: I-beam (text input)
  */
 typedef enum
 {
@@ -273,8 +280,15 @@ typedef enum
   META_CURSOR_NE_RESIZE,
   META_CURSOR_NW_RESIZE,
   META_CURSOR_MOVE_OR_RESIZE_WINDOW,
-  META_CURSOR_BUSY
-
+  META_CURSOR_BUSY,
+  META_CURSOR_DND_IN_DRAG,
+  META_CURSOR_DND_MOVE,
+  META_CURSOR_DND_COPY,
+  META_CURSOR_DND_UNSUPPORTED_TARGET,
+  META_CURSOR_POINTING_HAND,
+  META_CURSOR_CROSSHAIR,
+  META_CURSOR_IBEAM,
+  META_CURSOR_LAST
 } MetaCursor;
 
 /**
diff --git a/src/meta/screen.h b/src/meta/screen.h
index aec9afa..88a3481 100644
--- a/src/meta/screen.h
+++ b/src/meta/screen.h
@@ -114,4 +114,8 @@ void meta_screen_override_workspace_layout (MetaScreen      *screen,
                                             gboolean         vertical_layout,
                                             int              n_rows,
                                             int              n_columns);
+
+void          meta_screen_set_cursor          (MetaScreen                 *screen,
+                                               MetaCursor                  cursor);
+
 #endif


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