From 1fcaafdb58902f85808d4771cc1f7f590001d6f9 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Thu, 12 Mar 2009 17:13:08 -0400 Subject: [PATCH] Fix panel stacking with respect to fullscreen windows and screensaver. #571827 Because we can't set the stage input area to a non-rectangular shape, we don't allow the panel to be partially overlapped; it is always either on top, or else completely hidden. --- js/ui/main.js | 3 +-- js/ui/panel.js | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/js/ui/main.js b/js/ui/main.js index 449553c04..3eaa6918d 100644 --- a/js/ui/main.js +++ b/js/ui/main.js @@ -59,7 +59,6 @@ function start() { }); panel = new Panel.Panel(); - global.set_stage_input_area(0, 0, global.screen_width, Panel.PANEL_HEIGHT); overlay = new Overlay.Overlay(); wm = new WindowManager.WindowManager(); @@ -144,7 +143,7 @@ function endModal() { let global = Shell.Global.get(); global.ungrab_keyboard(); - global.set_stage_input_area(0, 0, global.screen_width, Panel.PANEL_HEIGHT); + panel.set_stage_input_area(); } function show_overlay() { diff --git a/js/ui/panel.js b/js/ui/panel.js index e8ac5ce9e..273759570 100644 --- a/js/ui/panel.js +++ b/js/ui/panel.js @@ -103,11 +103,26 @@ Panel.prototype = { }); global.stage.add_actor(this._box); + global.screen.connect('restacked', + function() { + me._restacked(); + }); + this._restacked(); // Start the clock this._updateClock(); }, + set_stage_input_area: function() { + let global = Shell.Global.get(); + + if (this._box.visible) { + global.set_stage_input_area(this._box.x, this._box.y, + this._box.width, this._box.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() { @@ -132,6 +147,42 @@ Panel.prototype = { } }, + _restacked: function() { + let global = Shell.Global.get(); + let windows = global.get_windows(); + let i; + + // We want to be visible unless there is a window with layer + // FULLSCREEN, or a window with layer OVERRIDE_REDIRECT that + // completely covers us. (We can't set a non-rectangular + // stage_input_area, so we don't let windows overlap us + // partially.). "override_redirect" is not actually a layer + // above all other windows, but this seems to be how mutter + // treats it currently... + // + // @windows is sorted bottom to top. + this._box.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._box.x && + windows[i].x + windows[i].width >= this._box.x + this._box.width && + windows[i].y <= this._box.y && + windows[i].y + windows[i].height >= this._box.y + this._box.height) { + this._box.hide(); + break; + } + } else if (layer == Meta.StackLayer.FULLSCREEN) { + this._box.hide(); + break; + } else + break; + } + + this.set_stage_input_area(); + }, + _updateClock: function() { let me = this; let display_date = new Date();