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
This commit is contained in:
parent
01696f19e8
commit
f4b58f35ba
@ -6,6 +6,7 @@ const Gio = imports.gi.Gio;
|
|||||||
const GLib = imports.gi.GLib;
|
const GLib = imports.gi.GLib;
|
||||||
const Lang = imports.lang;
|
const Lang = imports.lang;
|
||||||
const Mainloop = imports.mainloop;
|
const Mainloop = imports.mainloop;
|
||||||
|
const Meta = imports.gi.Meta;
|
||||||
const Pango = imports.gi.Pango;
|
const Pango = imports.gi.Pango;
|
||||||
const Shell = imports.gi.Shell;
|
const Shell = imports.gi.Shell;
|
||||||
const St = imports.gi.St;
|
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-width', Lang.bind(this, this._getPreferredWidth));
|
||||||
this.actor.connect('get-preferred-height', Lang.bind(this, this._getPreferredHeight));
|
this.actor.connect('get-preferred-height', Lang.bind(this, this._getPreferredHeight));
|
||||||
this.actor.connect('allocate', Lang.bind(this, this._allocate));
|
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. */
|
/* Button on the left side of the panel. */
|
||||||
if (global.session_type == Shell.SessionType.USER) {
|
if (global.session_type == Shell.SessionType.USER) {
|
||||||
@ -1058,6 +1060,45 @@ const Panel = new Lang.Class({
|
|||||||
this._rightCorner.actor.allocate(childBox, flags);
|
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() {
|
startStatusArea: function() {
|
||||||
for (let i = 0; i < this._status_area_order.length; i++) {
|
for (let i = 0; i < this._status_area_order.length; i++) {
|
||||||
let role = this._status_area_order[i];
|
let role = this._status_area_order[i];
|
||||||
|
Loading…
Reference in New Issue
Block a user