gnome-shell r63 - trunk/js/ui



Author: otaylor
Date: Wed Nov 19 23:04:53 2008
New Revision: 63
URL: http://svn.gnome.org/viewvc/gnome-shell?rev=63&view=rev

Log:
Set a strut to prevent windows under the panel

Set a strut (a reserved region) at the top of the screen so that
windows don't get positioned under the panel. Do this on all
workspaces and redo it when the number of workspaces changes.
http://bugzilla.gnome.org/show_bug.cgi?id=561297

Modified:
   trunk/js/ui/panel.js

Modified: trunk/js/ui/panel.js
==============================================================================
--- trunk/js/ui/panel.js	(original)
+++ trunk/js/ui/panel.js	Wed Nov 19 23:04:53 2008
@@ -2,11 +2,12 @@
 
 const Mainloop = imports.mainloop;
 
-const Shell = imports.gi.Shell;
 const Clutter = imports.gi.Clutter;
+const Meta = imports.gi.Meta;
+const Shell = imports.gi.Shell;
 const Tidy = imports.gi.Tidy;
-const Button = imports.ui.button;
 
+const Button = imports.ui.button;
 const Main = imports.ui.main;
 
 const PANEL_HEIGHT = 32;
@@ -86,12 +87,42 @@
 		return true;
             });
 
+	this._setStruts();
+	global.screen.connect('notify::n-workspaces',
+	    function() {
+		me._setStruts();
+	    });
+
 	global.stage.add_actor(this._group);
 
 	this._updateClock();
 	this._startClock();
     },
 
+    // Struts determine the area along each side of the screen that is reserved
+    // and not available to applications
+    _setStruts: function() {
+	let global = Shell.global_get();
+
+	let struts = [
+            new Meta.Strut({
+		rect: {
+		    x: 0,
+		    y: 0,
+		    width: global.screen_width,
+		    height: PANEL_HEIGHT
+		},
+		side: Meta.Direction.TOP
+	    })
+	];
+
+	let screen = global.screen;
+	for (let i = 0; i < screen.n_workspaces; i++) {
+	    let workspace = screen.get_workspace_by_index(i);
+	    workspace.set_builtin_struts(struts);
+	}
+    },
+
     _startClock: function() {
 	let me = this;
         // TODO: this makes the clock updated every 60 seconds, but not necessarily on the minute, so it is inaccurate



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