[gnome-shell] shell-global: add a "display" property



commit aed50e2a391f90eb50f39839b2d264be42a74034
Author: Dan Winship <danw gnome org>
Date:   Wed Jul 13 12:34:31 2011 -0400

    shell-global: add a "display" property
    
    and update callers to fetch that rather than doing
    "global.screen.get_display()"
    
    https://bugzilla.gnome.org/show_bug.cgi?id=654639

 js/ui/altTab.js                 |    2 +-
 js/ui/layout.js                 |    4 +---
 js/ui/lookingGlass.js           |    3 +--
 js/ui/main.js                   |    6 ++----
 js/ui/messageTray.js            |   10 +++-------
 js/ui/panel.js                  |    1 -
 js/ui/windowAttentionHandler.js |    3 +--
 js/ui/workspace.js              |    2 +-
 src/shell-global.c              |   23 +++++++++++++++++++++++
 src/shell-global.h              |    1 +
 src/shell-window-tracker.c      |    2 +-
 11 files changed, 35 insertions(+), 22 deletions(-)
---
diff --git a/js/ui/altTab.js b/js/ui/altTab.js
index ad655d9..8175c61 100644
--- a/js/ui/altTab.js
+++ b/js/ui/altTab.js
@@ -223,7 +223,7 @@ AltTabPopup.prototype = {
         let keysym = event.get_key_symbol();
         let event_state = Shell.get_event_state(event);
         let backwards = event_state & Clutter.ModifierType.SHIFT_MASK;
-        let action = global.screen.get_display().get_keybinding_action(event.get_key_code(), event_state);
+        let action = global.display.get_keybinding_action(event.get_key_code(), event_state);
 
         this._disableHover();
 
diff --git a/js/ui/layout.js b/js/ui/layout.js
index e884507..a4f4996 100644
--- a/js/ui/layout.js
+++ b/js/ui/layout.js
@@ -135,9 +135,7 @@ LayoutManager.prototype = {
     },
 
     get focusIndex() {
-        let screen = global.screen;
-        let display = screen.get_display();
-        let focusWindow = display.focus_window;
+        let focusWindow = global.display.focus_window;
 
         if (focusWindow) {
             let wrect = focusWindow.get_outer_rect();
diff --git a/js/ui/lookingGlass.js b/js/ui/lookingGlass.js
index e40d86c..9a9488e 100644
--- a/js/ui/lookingGlass.js
+++ b/js/ui/lookingGlass.js
@@ -222,10 +222,9 @@ function WindowList() {
 WindowList.prototype = {
     _init : function () {
         this.actor = new St.BoxLayout({ name: 'Windows', vertical: true, style: 'spacing: 8px' });
-        let display = global.screen.get_display();
         let tracker = Shell.WindowTracker.get_default();
         this._updateId = Main.initializeDeferredWork(this.actor, Lang.bind(this, this._updateWindowList));
-        display.connect('window-created', Lang.bind(this, this._updateWindowList));
+        global.display.connect('window-created', Lang.bind(this, this._updateWindowList));
         tracker.connect('tracked-windows-changed', Lang.bind(this, this._updateWindowList));
     },
 
diff --git a/js/ui/main.js b/js/ui/main.js
index 47f6af2..efda3b2 100644
--- a/js/ui/main.js
+++ b/js/ui/main.js
@@ -194,8 +194,7 @@ function start() {
     panel.startStatusArea();
     panel.startupAnimation();
 
-    let display = global.screen.get_display();
-    display.connect('overlay-key', Lang.bind(overview, overview.toggle));
+    global.display.connect('overlay-key', Lang.bind(overview, overview.toggle));
 
     global.stage.connect('captured-event', _globalKeyPressHandler);
 
@@ -524,9 +523,8 @@ function _globalKeyPressHandler(actor, event) {
     let keyCode = event.get_key_code();
     let modifierState = Shell.get_event_state(event);
 
-    let display = global.screen.get_display();
     // This relies on the fact that Clutter.ModifierType is the same as Gdk.ModifierType
-    let action = display.get_keybinding_action(keyCode, modifierState);
+    let action = global.display.get_keybinding_action(keyCode, modifierState);
 
     // The screenshot action should always be available (even if a
     // modal dialog is present)
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index 4dc949e..3dea6ff 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -234,9 +234,7 @@ FocusGrabber.prototype = {
 
         this.actor = actor;
 
-        let metaDisplay = global.screen.get_display();
-
-        this._prevFocusedWindow = metaDisplay.focus_window;
+        this._prevFocusedWindow = global.display.focus_window;
         this._prevKeyFocusActor = global.stage.get_key_focus();
 
         if (!Main.overview.visible)
@@ -290,8 +288,6 @@ FocusGrabber.prototype = {
         if (!this._hasFocus)
             return;
 
-        let metaDisplay = global.screen.get_display();
-
         if (this._focusActorChangedId > 0) {
             global.stage.disconnect(this._focusActorChangedId);
             this._focusActorChangedId = 0;
@@ -310,8 +306,8 @@ FocusGrabber.prototype = {
         this._hasFocus = false;
         this.emit('focus-ungrabbed');
 
-        if (this._prevFocusedWindow && !metaDisplay.focus_window) {
-            metaDisplay.set_input_focus_window(this._prevFocusedWindow, false, global.get_current_time());
+        if (this._prevFocusedWindow && !global.display.focus_window) {
+            global.display.set_input_focus_window(this._prevFocusedWindow, false, global.get_current_time());
             this._prevFocusedWindow = null;
         }
         if (this._prevKeyFocusActor) {
diff --git a/js/ui/panel.js b/js/ui/panel.js
index 3fc8bd0..a830a1c 100644
--- a/js/ui/panel.js
+++ b/js/ui/panel.js
@@ -237,7 +237,6 @@ AppMenuButton.prototype = {
 
     _init: function() {
         PanelMenu.Button.prototype._init.call(this, 0.0);
-        this._metaDisplay = global.screen.get_display();
         this._startingApps = [];
 
         this._targetApp = null;
diff --git a/js/ui/windowAttentionHandler.js b/js/ui/windowAttentionHandler.js
index 0d4b988..5ce1671 100644
--- a/js/ui/windowAttentionHandler.js
+++ b/js/ui/windowAttentionHandler.js
@@ -16,8 +16,7 @@ WindowAttentionHandler.prototype = {
         this._tracker = Shell.WindowTracker.get_default();
         this._tracker.connect('startup-sequence-changed', Lang.bind(this, this._onStartupSequenceChanged));
 
-        let display = global.screen.get_display();
-        display.connect('window-demands-attention', Lang.bind(this, this._onWindowDemandsAttention));
+        global.display.connect('window-demands-attention', Lang.bind(this, this._onWindowDemandsAttention));
     },
 
     _onStartupSequenceChanged : function(tracker) {
diff --git a/js/ui/workspace.js b/js/ui/workspace.js
index e6c65b9..acb8904 100644
--- a/js/ui/workspace.js
+++ b/js/ui/workspace.js
@@ -161,7 +161,7 @@ WindowClone.prototype = {
             // will look funny.
 
             if (!this._selected &&
-                this.metaWindow != global.screen.get_display().focus_window)
+                this.metaWindow != global.display.focus_window)
                 this._zoomEnd();
         }
     },
diff --git a/src/shell-global.c b/src/shell-global.c
index 8c30ae7..3370b42 100644
--- a/src/shell-global.c
+++ b/src/shell-global.c
@@ -93,6 +93,7 @@ enum {
   PROP_OVERLAY_GROUP,
   PROP_SCREEN,
   PROP_GDK_SCREEN,
+  PROP_DISPLAY,
   PROP_SCREEN_WIDTH,
   PROP_SCREEN_HEIGHT,
   PROP_STAGE,
@@ -160,6 +161,9 @@ shell_global_get_property(GObject         *object,
     case PROP_GDK_SCREEN:
       g_value_set_object (value, global->gdk_screen);
       break;
+    case PROP_DISPLAY:
+      g_value_set_object (value, global->meta_display);
+      break;
     case PROP_SCREEN_WIDTH:
       {
         int width, height;
@@ -365,6 +369,14 @@ shell_global_class_init (ShellGlobalClass *klass)
                                                      0, G_MAXINT, 1,
                                                      G_PARAM_READABLE));
   g_object_class_install_property (gobject_class,
+                                   PROP_DISPLAY,
+                                   g_param_spec_object ("display",
+                                                        "Display",
+                                                        "Metacity display object for the shell",
+                                                        META_TYPE_DISPLAY,
+                                                        G_PARAM_READABLE));
+
+  g_object_class_install_property (gobject_class,
                                    PROP_STAGE,
                                    g_param_spec_object ("stage",
                                                         "Stage",
@@ -668,6 +680,17 @@ shell_global_get_gdk_screen (ShellGlobal *global)
 }
 
 /**
+ * shell_global_get_display:
+ *
+ * Return value: (transfer none): The default #MetaDisplay
+ */
+MetaDisplay *
+shell_global_get_display (ShellGlobal  *global)
+{
+  return global->meta_display;
+}
+
+/**
  * shell_global_get_window_actors:
  *
  * Gets the list of #MetaWindowActor for the plugin's screen
diff --git a/src/shell-global.h b/src/shell-global.h
index 1f79cf5..d5bca83 100644
--- a/src/shell-global.h
+++ b/src/shell-global.h
@@ -31,6 +31,7 @@ ShellGlobal   *shell_global_get                       (void);
 
 MetaScreen    *shell_global_get_screen                (ShellGlobal *global);
 GdkScreen     *shell_global_get_gdk_screen            (ShellGlobal *global);
+MetaDisplay   *shell_global_get_display               (ShellGlobal *global);
 GList         *shell_global_get_window_actors         (ShellGlobal *global);
 GSettings     *shell_global_get_settings              (ShellGlobal *global);
 guint32        shell_global_get_current_time          (ShellGlobal *global);
diff --git a/src/shell-window-tracker.c b/src/shell-window-tracker.c
index 4b7b2d4..31d3e00 100644
--- a/src/shell-window-tracker.c
+++ b/src/shell-window-tracker.c
@@ -418,7 +418,7 @@ update_focus_app (ShellWindowTracker *self)
   MetaWindow *new_focus_win;
   ShellApp *new_focus_app;
 
-  new_focus_win = meta_display_get_focus_window (meta_screen_get_display (shell_global_get_screen (shell_global_get ())));
+  new_focus_win = meta_display_get_focus_window (shell_global_get_display (shell_global_get ()));
   new_focus_app = new_focus_win ? shell_window_tracker_get_window_app (self, new_focus_win) : NULL;
 
   set_focus_app (self, new_focus_app);



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