[gnome-shell] add shell_global_[un]set_cursor
- From: Maxim Ermilov <mermilov src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] add shell_global_[un]set_cursor
- Date: Fri, 10 Sep 2010 02:05:05 +0000 (UTC)
commit 0e2ed0fb0b5c8f78136de89d39a84fdf28280aab
Author: Maxim Ermilov <zaspire rambler ru>
Date: Fri Sep 10 05:46:13 2010 +0400
add shell_global_[un]set_cursor
This functions set/unset the cursor on the stage window.
https://bugzilla.gnome.org/show_bug.cgi?id=607821
src/shell-global.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++
src/shell-global.h | 12 +++++++
2 files changed, 96 insertions(+), 0 deletions(-)
---
diff --git a/src/shell-global.c b/src/shell-global.c
index 0a1e232..59e4dbb 100644
--- a/src/shell-global.c
+++ b/src/shell-global.c
@@ -59,6 +59,7 @@ struct _ShellGlobal {
/* Displays the root window; see shell_global_create_root_pixmap_actor() */
ClutterActor *root_pixmap;
+ GdkWindow *stage_window;
gint last_change_screen_width, last_change_screen_height;
@@ -206,6 +207,7 @@ shell_global_init (ShellGlobal *global)
global->gtk_grab_active = FALSE;
global->root_pixmap = NULL;
+ global->stage_window = NULL;
global->input_mode = SHELL_STAGE_INPUT_MODE_NORMAL;
@@ -436,6 +438,88 @@ shell_global_set_stage_input_mode (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;
+ default:
+ g_return_if_reached ();
+ }
+
+ cursor = gdk_cursor_new_from_name (gdk_display_get_default (), 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_DND_UNSUPPORTED_TARGET:
+ cursor_type = GDK_X_CURSOR;
+ break;
+ default:
+ g_return_if_reached ();
+ }
+ cursor = gdk_cursor_new (cursor_type);
+ }
+ if (!global->stage_window)
+ {
+ ClutterStage *stage = CLUTTER_STAGE (mutter_plugin_get_stage (global->plugin));
+
+ global->stage_window = gdk_window_foreign_new (clutter_x11_get_stage_window (stage));
+ }
+
+ gdk_window_set_cursor (global->stage_window, cursor);
+
+ gdk_cursor_unref (cursor);
+}
+
+/**
+ * shell_global_unset_cursor:
+ * @global: A #ShellGlobal
+ *
+ * Unset the cursor on the stage window.
+ */
+void
+shell_global_unset_cursor (ShellGlobal *global)
+{
+ if (!global->stage_window) /* cursor has never been set */
+ return;
+
+ gdk_window_set_cursor (global->stage_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 76a4ff6..a482c1f 100644
--- a/src/shell-global.h
+++ b/src/shell-global.h
@@ -34,6 +34,18 @@ gboolean shell_clutter_texture_set_from_pixbuf (ClutterTexture *texture,
ShellGlobal *shell_global_get (void);
+typedef enum {
+ SHELL_CURSOR_DND_IN_DRAG,
+ SHELL_CURSOR_DND_UNSUPPORTED_TARGET,
+ SHELL_CURSOR_DND_MOVE,
+ SHELL_CURSOR_DND_COPY
+} ShellCursor;
+
+void shell_global_set_cursor (ShellGlobal *global,
+ ShellCursor type);
+
+void shell_global_unset_cursor (ShellGlobal *global);
+
MetaScreen *shell_global_get_screen (ShellGlobal *global);
GdkScreen *shell_global_get_gdk_screen (ShellGlobal *global);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]