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
This commit is contained in:
Dan Winship 2009-03-26 18:01:07 -04:00 committed by Owen W. Taylor
parent 7995f75cfb
commit 670532e5c9
2 changed files with 29 additions and 24 deletions

View File

@ -21,6 +21,7 @@ let overlayActive = false;
let runDialog = null; let runDialog = null;
let wm = null; let wm = null;
let recorder = null; let recorder = null;
let inModal = false;
function start() { function start() {
let global = Shell.Global.get(); let global = Shell.Global.get();
@ -59,6 +60,8 @@ function start() {
}); });
panel = new Panel.Panel(); panel = new Panel.Panel();
panel.actor.connect('notify::visible', _panelVisibilityChanged);
_panelVisibilityChanged();
overlay = new Overlay.Overlay(); overlay = new Overlay.Overlay();
wm = new WindowManager.WindowManager(); wm = new WindowManager.WindowManager();
@ -125,6 +128,18 @@ function _removeUnusedWorkspaces() {
return false; 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 // 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 // the stage. Returns true if we successfully grabbed the keyboard and
// went modal, false otherwise // went modal, false otherwise
@ -134,6 +149,7 @@ function startModal() {
if (!global.grab_keyboard()) if (!global.grab_keyboard())
return false; return false;
inModal = true;
global.set_stage_input_area(0, 0, global.screen_width, global.screen_height); global.set_stage_input_area(0, 0, global.screen_width, global.screen_height);
return true; return true;
@ -143,7 +159,8 @@ function endModal() {
let global = Shell.Global.get(); let global = Shell.Global.get();
global.ungrab_keyboard(); global.ungrab_keyboard();
panel.set_stage_input_area(); inModal = false;
_panelVisibilityChanged();
} }
function show_overlay() { function show_overlay() {

View File

@ -51,7 +51,7 @@ Panel.prototype = {
let global = Shell.Global.get(); let global = Shell.Global.get();
// Put the background under the panel within a group. // 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, // Create backBox, which contains two boxes, backUpper and backLower,
// for the background gradients and one for the shadow. The shadow at // 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(backUpper, Big.BoxPackFlags.EXPAND);
backBox.append(backLower, Big.BoxPackFlags.EXPAND); backBox.append(backLower, Big.BoxPackFlags.EXPAND);
backBox.append(shadow, Big.BoxPackFlags.NONE); backBox.append(shadow, Big.BoxPackFlags.NONE);
this._group.add_actor(backBox); this.actor.add_actor(backBox);
let box = new Big.Box({ x: 0, let box = new Big.Box({ x: 0,
y: 0, y: 0,
@ -165,9 +165,9 @@ Panel.prototype = {
me._setStruts(); 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', global.screen.connect('restacked',
function() { function() {
@ -179,16 +179,6 @@ Panel.prototype = {
this._updateClock(); 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 // Struts determine the area along each side of the screen that is reserved
// and not available to applications // and not available to applications
_setStruts: function() { _setStruts: function() {
@ -227,26 +217,24 @@ Panel.prototype = {
// treats it currently... // treats it currently...
// //
// @windows is sorted bottom to top. // @windows is sorted bottom to top.
this._group.show(); this.actor.show();
for (i = windows.length - 1; i > -1; i--) { for (i = windows.length - 1; i > -1; i--) {
let layer = windows[i].get_meta_window().get_layer(); let layer = windows[i].get_meta_window().get_layer();
if (layer == Meta.StackLayer.OVERRIDE_REDIRECT) { if (layer == Meta.StackLayer.OVERRIDE_REDIRECT) {
if (windows[i].x <= this._group.x && if (windows[i].x <= this.actor.x &&
windows[i].x + windows[i].width >= this._group.x + this._group.width && windows[i].x + windows[i].width >= this.actor.x + this.actor.width &&
windows[i].y <= this._group.y && windows[i].y <= this.actor.y &&
windows[i].y + windows[i].height >= this._group.y + PANEL_HEIGHT) { windows[i].y + windows[i].height >= this.actor.y + PANEL_HEIGHT) {
this._group.hide(); this.actor.hide();
break; break;
} }
} else if (layer == Meta.StackLayer.FULLSCREEN) { } else if (layer == Meta.StackLayer.FULLSCREEN) {
this._group.hide(); this.actor.hide();
break; break;
} else } else
break; break;
} }
this.set_stage_input_area();
}, },
_updateClock: function() { _updateClock: function() {