[gnome-shell] Add pointer barriers to panel and message tray
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] Add pointer barriers to panel and message tray
- Date: Mon, 21 Mar 2011 21:07:51 +0000 (UTC)
commit 1518dc9b604c69597a42058551e34d36d22c5bc4
Author: Alexander Larsson <alexl redhat com>
Date: Fri Mar 18 13:27:06 2011 +0100
Add pointer barriers to panel and message tray
If you have XFixes 5 (and corresponding xserver support) then we
add barriers on the panel and in the message tray corner so that
its easy to reach the corners even when there are monitors to the
sides of the primary monitor.
https://bugzilla.gnome.org/show_bug.cgi?id=622655
js/ui/messageTray.js | 10 +++++++++
js/ui/panel.js | 16 ++++++++++++++
src/shell-global.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++
src/shell-global.h | 6 +++++
4 files changed, 87 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index e34d693..ea21d49 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -1030,6 +1030,7 @@ MessageTray.prototype = {
this._clickedSummaryItemAllocationChangedId = 0;
this._expandedSummaryItem = null;
this._summaryItemTitleWidth = 0;
+ this._pointerBarrier = 0;
// To simplify the summary item animation code, we pretend
// that there's an invisible SummaryItem to the left of the
@@ -1119,6 +1120,15 @@ MessageTray.prototype = {
this._notificationBin.width = primary.width;
this._summaryBin.x = 0;
this._summaryBin.width = primary.width;
+
+ if (this._pointerBarrier)
+ global.destroy_pointer_barrier(this._pointerBarrier);
+ this._pointerBarrier =
+ global.create_pointer_barrier(primary.x + primary.width, primary.y + primary.height - this.actor.height,
+ primary.x + primary.width, primary.y + primary.height,
+ 4 /* BarrierNegativeX */);
+
+
},
contains: function(source) {
diff --git a/js/ui/panel.js b/js/ui/panel.js
index c064245..a75cf3d 100644
--- a/js/ui/panel.js
+++ b/js/ui/panel.js
@@ -789,6 +789,8 @@ Panel.prototype = {
this.actor.remove_style_class_name('in-overview');
}));
+ this._leftPointerBarrier = 0;
+ this._rightPointerBarrier = 0;
this._menus = new PopupMenu.PopupMenuManager(this);
this._leftBox = new St.BoxLayout({ name: 'panelLeft' });
@@ -1051,6 +1053,20 @@ Panel.prototype = {
this.actor.set_position(primary.x, primary.y);
this.actor.set_size(primary.width, -1);
+ if (this._leftPointerBarrier)
+ global.destroy_pointer_barrier(this._leftPointerBarrier);
+ if (this._rightPointerBarrier)
+ global.destroy_pointer_barrier(this._rightPointerBarrier);
+
+ this._leftPointerBarrier =
+ global.create_pointer_barrier(primary.x, primary.y,
+ primary.x, primary.y + this.actor.height,
+ 1 /* BarrierPositiveX */);
+ this._rightPointerBarrier =
+ global.create_pointer_barrier(primary.x + primary.width, primary.y,
+ primary.x + primary.width, primary.y + this.actor.height,
+ 4 /* BarrierNegativeX */);
+
this._leftCorner.relayout();
this._rightCorner.relayout();
},
diff --git a/src/shell-global.c b/src/shell-global.c
index 44f4aff..dcedf43 100644
--- a/src/shell-global.c
+++ b/src/shell-global.c
@@ -885,6 +885,61 @@ shell_global_display_is_grabbed (ShellGlobal *global)
}
/**
+ * shell_global_create_pointer_barrier
+ * @global: a #ShellGlobal
+ * @x1: left X coordinate
+ * @y1: top Y coordinate
+ * @x2: right X coordinate
+ * @y2: bottom Y coordinate
+ * @directions: The directions we're allowed to pass through
+ *
+ * If supported by X creates a pointer barrier.
+ *
+ * Return value: value you can pass to shell_global_destroy_pointer_barrier()
+ */
+guint32
+shell_global_create_pointer_barrier (ShellGlobal *global,
+ int x1, int y1, int x2, int y2,
+ int directions)
+{
+#if XFIXES_MAJOR >= 5
+ Display *xdpy;
+
+ xdpy = meta_plugin_get_xdisplay (global->plugin);
+
+ return (guint32)
+ XFixesCreatePointerBarrier (xdpy, DefaultRootWindow(xdpy),
+ x1, y1,
+ x2, y2,
+ directions,
+ 0, NULL);
+#else
+ return 0;
+#endif
+}
+
+/**
+ * shell_global_destroy_pointer_barrier
+ * @global: a #ShellGlobal
+ * @barrier: a pointer barrier
+ *
+ * Destroys the @barrier created by shell_global_create_pointer_barrier().
+ */
+void
+shell_global_destroy_pointer_barrier (ShellGlobal *global, guint32 barrier)
+{
+#if XFIXES_MAJOR >= 5
+ Display *xdpy;
+
+ g_return_if_fail (barrier > 0);
+
+ xdpy = meta_plugin_get_xdisplay (global->plugin);
+ XFixesDestroyPointerBarrier (xdpy, (PointerBarrier)barrier);
+#endif
+}
+
+
+/**
* shell_global_add_extension_importer:
* @target_object_script: JavaScript code evaluating to a target object
* @target_property: Name of property to use for importer
diff --git a/src/shell-global.h b/src/shell-global.h
index cda10e4..6e16abe 100644
--- a/src/shell-global.h
+++ b/src/shell-global.h
@@ -103,6 +103,12 @@ MetaRectangle *shell_global_get_primary_monitor (ShellGlobal *global);
int shell_global_get_primary_monitor_index (ShellGlobal *global);
MetaRectangle *shell_global_get_focus_monitor (ShellGlobal *global);
+guint32 shell_global_create_pointer_barrier (ShellGlobal *global,
+ int x1, int y1, int x2, int y2,
+ int directions);
+void shell_global_destroy_pointer_barrier (ShellGlobal *global,
+ guint32 barrier);
+
void shell_global_get_pointer (ShellGlobal *global,
int *x,
int *y,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]