[gnome-shell] panel: Allow to start a drag to restore a window from the panel
- From: Florian MÃllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] panel: Allow to start a drag to restore a window from the panel
- Date: Wed, 29 Feb 2012 12:51:37 +0000 (UTC)
commit f4b58f35babcb8498cb80cdd9720f7d9d1c4c266
Author: Florian MÃllner <fmuellner gnome org>
Date: Tue Oct 4 17:14:29 2011 +0200
panel: Allow to start a drag to restore a window from the panel
The preferred way to unmaximize/untile a window is by using a drag
gesture. Extend the available area to start this gesture into
non-reactive parts of the top bar above the window - with that we
take advantage of the "infinite height" of the screen edge, and the
extra space is particularly useful when the window has its titlebar
hidden.
https://bugzilla.gnome.org/show_bug.cgi?id=666359
js/ui/panel.js | 41 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 41 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/panel.js b/js/ui/panel.js
index 97cbf7d..9311f66 100644
--- a/js/ui/panel.js
+++ b/js/ui/panel.js
@@ -6,6 +6,7 @@ const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const Lang = imports.lang;
const Mainloop = imports.mainloop;
+const Meta = imports.gi.Meta;
const Pango = imports.gi.Pango;
const Shell = imports.gi.Shell;
const St = imports.gi.St;
@@ -944,6 +945,7 @@ const Panel = new Lang.Class({
this.actor.connect('get-preferred-width', Lang.bind(this, this._getPreferredWidth));
this.actor.connect('get-preferred-height', Lang.bind(this, this._getPreferredHeight));
this.actor.connect('allocate', Lang.bind(this, this._allocate));
+ this.actor.connect('button-press-event', Lang.bind(this, this._onButtonPress));
/* Button on the left side of the panel. */
if (global.session_type == Shell.SessionType.USER) {
@@ -1058,6 +1060,45 @@ const Panel = new Lang.Class({
this._rightCorner.actor.allocate(childBox, flags);
},
+ _onButtonPress: function(actor, event) {
+ if (event.get_source() != actor)
+ return false;
+
+ let button = event.get_button();
+ if (button != 1)
+ return false;
+
+ let focusWindow = global.display.focus_window;
+ if (!focusWindow)
+ return false;
+
+ let dragWindow = focusWindow.is_attached_dialog() ? focusWindow.get_transient_for()
+ : focusWindow;
+ if (!dragWindow)
+ return false;
+
+ let rect = dragWindow.get_outer_rect();
+ let [stageX, stageY] = event.get_coords();
+
+ let allowDrag = dragWindow.maximized_vertically &&
+ stageX > rect.x && stageX < rect.x + rect.width;
+
+ if (!allowDrag)
+ return false;
+
+ global.display.begin_grab_op(global.screen,
+ dragWindow,
+ Meta.GrabOp.MOVING,
+ false, /* pointer grab */
+ true, /* frame action */
+ button,
+ event.get_state(),
+ event.get_time(),
+ stageX, stageY);
+
+ return true;
+ },
+
startStatusArea: function() {
for (let i = 0; i < this._status_area_order.length; i++) {
let role = this._status_area_order[i];
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]