gnome-shell r59 - trunk/src



Author: otaylor
Date: Wed Nov 19 19:54:17 2008
New Revision: 59
URL: http://svn.gnome.org/viewvc/gnome-shell?rev=59&view=rev

Log:
Add shell_global_focus_stage()

Add a a method shell_global_focus_stage() to set the
input focus to the stage window, so that Clutter gets
keyboard events.

Adapted from patch in Bug 561299 from Colin Walters


Modified:
   trunk/src/shell-global.c
   trunk/src/shell-global.h

Modified: trunk/src/shell-global.c
==============================================================================
--- trunk/src/shell-global.c	(original)
+++ trunk/src/shell-global.c	Wed Nov 19 19:54:17 2008
@@ -2,6 +2,9 @@
 
 #include "shell-global.h"
 
+#include "display.h"
+#include <clutter/x11/clutter-x11.h>
+
 struct _ShellGlobal {
   GObject parent;
 
@@ -217,3 +220,21 @@
 
   global->plugin = plugin;
 }
+
+/**
+ * shell_global_focus_stage:
+ *
+ * Set the keyboard focus to the Clutter stage window.  This function
+ * is best used in combination with some sort of visual notification
+ * that the shell has taken over input.
+ */
+void
+shell_global_focus_stage (ShellGlobal *global)
+{
+  MetaScreen *screen = mutter_plugin_get_screen (global->plugin);
+  MetaDisplay *display = meta_screen_get_display (screen);
+  Display *xdisplay = meta_display_get_xdisplay (display);
+  ClutterStage *stage = CLUTTER_STAGE (mutter_plugin_get_stage (global->plugin));
+  Window stagewin = clutter_x11_get_stage_window (stage);
+  XSetInputFocus (xdisplay, stagewin, RevertToParent, CurrentTime);
+}

Modified: trunk/src/shell-global.h
==============================================================================
--- trunk/src/shell-global.h	(original)
+++ trunk/src/shell-global.h	Wed Nov 19 19:54:17 2008
@@ -42,6 +42,10 @@
 void _shell_global_set_plugin (ShellGlobal  *global,
 			       MutterPlugin *plugin);
 
+MetaScreen * shell_global_get_screen (ShellGlobal *global);
+
+void shell_global_focus_stage (ShellGlobal *global);
+
 G_END_DECLS
 
 #endif /* __SHELL_GLOBAL_H__ */



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