From 670532e5c97da061dfaa725a660a1a4f21a87354 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Thu, 26 Mar 2009 18:01:07 -0400 Subject: [PATCH] Fix the stage_input_area handling The panel show/hide changes broke things if window restacking occurred while the overlay was active. Now instead of having the panel set the input area itself, main.js just watches whether or not the panel is visible, and updates things itself (taking the modal state into account as well). http://bugzilla.gnome.org/show_bug.cgi?id=576903 --- js/ui/main.js | 19 ++++++++++++++++++- js/ui/panel.js | 34 +++++++++++----------------------- 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/js/ui/main.js b/js/ui/main.js index 3eaa6918d..d4b3f9ca9 100644 --- a/js/ui/main.js +++ b/js/ui/main.js @@ -21,6 +21,7 @@ let overlayActive = false; let runDialog = null; let wm = null; let recorder = null; +let inModal = false; function start() { let global = Shell.Global.get(); @@ -59,6 +60,8 @@ function start() { }); panel = new Panel.Panel(); + panel.actor.connect('notify::visible', _panelVisibilityChanged); + _panelVisibilityChanged(); overlay = new Overlay.Overlay(); wm = new WindowManager.WindowManager(); @@ -125,6 +128,18 @@ function _removeUnusedWorkspaces() { return false; } +function _panelVisibilityChanged() { + if (!inModal) { + let global = Shell.Global.get(); + + if (panel.actor.visible) { + global.set_stage_input_area(0, 0, + global.screen_width, Panel.PANEL_HEIGHT); + } else + global.set_stage_input_area(0, 0, 0, 0); + } +} + // Used to go into a mode where all keyboard and mouse input goes to // the stage. Returns true if we successfully grabbed the keyboard and // went modal, false otherwise @@ -134,6 +149,7 @@ function startModal() { if (!global.grab_keyboard()) return false; + inModal = true; global.set_stage_input_area(0, 0, global.screen_width, global.screen_height); return true; @@ -143,7 +159,8 @@ function endModal() { let global = Shell.Global.get(); global.ungrab_keyboard(); - panel.set_stage_input_area(); + inModal = false; + _panelVisibilityChanged(); } function show_overlay() { diff --git a/js/ui/panel.js b/js/ui/panel.js index 9976d8252..ccb67f7e9 100644 --- a/js/ui/panel.js +++ b/js/ui/panel.js @@ -51,7 +51,7 @@ Panel.prototype = { let global = Shell.Global.get(); // Put the background under the panel within a group. - this._group = new Clutter.Group(); + this.actor = new Clutter.Group(); // Create backBox, which contains two boxes, backUpper and backLower, // for the background gradients and one for the shadow. The shadow at @@ -73,7 +73,7 @@ Panel.prototype = { backBox.append(backUpper, Big.BoxPackFlags.EXPAND); backBox.append(backLower, Big.BoxPackFlags.EXPAND); backBox.append(shadow, Big.BoxPackFlags.NONE); - this._group.add_actor(backBox); + this.actor.add_actor(backBox); let box = new Big.Box({ x: 0, y: 0, @@ -165,9 +165,9 @@ Panel.prototype = { me._setStruts(); }); - this._group.add_actor(box); + this.actor.add_actor(box); - global.stage.add_actor(this._group); + global.stage.add_actor(this.actor); global.screen.connect('restacked', function() { @@ -179,16 +179,6 @@ Panel.prototype = { this._updateClock(); }, - set_stage_input_area: function() { - let global = Shell.Global.get(); - - if (this._group.visible) { - global.set_stage_input_area(this._group.x, this._group.y, - this._group.width, PANEL_HEIGHT); - } else - global.set_stage_input_area(0, 0, 0, 0); - }, - // Struts determine the area along each side of the screen that is reserved // and not available to applications _setStruts: function() { @@ -227,26 +217,24 @@ Panel.prototype = { // treats it currently... // // @windows is sorted bottom to top. - this._group.show(); + this.actor.show(); for (i = windows.length - 1; i > -1; i--) { let layer = windows[i].get_meta_window().get_layer(); if (layer == Meta.StackLayer.OVERRIDE_REDIRECT) { - if (windows[i].x <= this._group.x && - windows[i].x + windows[i].width >= this._group.x + this._group.width && - windows[i].y <= this._group.y && - windows[i].y + windows[i].height >= this._group.y + PANEL_HEIGHT) { - this._group.hide(); + if (windows[i].x <= this.actor.x && + windows[i].x + windows[i].width >= this.actor.x + this.actor.width && + windows[i].y <= this.actor.y && + windows[i].y + windows[i].height >= this.actor.y + PANEL_HEIGHT) { + this.actor.hide(); break; } } else if (layer == Meta.StackLayer.FULLSCREEN) { - this._group.hide(); + this.actor.hide(); break; } else break; } - - this.set_stage_input_area(); }, _updateClock: function() {