messageTray: fix dwelling during mouse-down
If the user has the mouse down - for example when they are selecting text and dragging - then the attempt to get a modal grab will fail. grabHelper: allow the .grab() function to fail and do nothing in this modal case if the grab fails. messageTray: handle grab failure and don't pop up the tray. Change the logic for tray dwelling so that we only try to pop up the tray once while the pointer is in the dwell area - this avoids the possiility that the tray will pop up once the user releases the mouse. https://bugzilla.gnome.org/show_bug.cgi?id=682385
This commit is contained in:
parent
5d6f37017b
commit
3902e8bff0
@ -128,7 +128,9 @@ const GrabHelper = new Lang.Class({
|
|||||||
// on the owner of the GrabHelper. As long as there is at least one
|
// on the owner of the GrabHelper. As long as there is at least one
|
||||||
// { modal: true } actor on the grab stack, the grab will be kept.
|
// { modal: true } actor on the grab stack, the grab will be kept.
|
||||||
// When the last { modal: true } actor is ungrabbed, then the modal
|
// When the last { modal: true } actor is ungrabbed, then the modal
|
||||||
// will be dropped.
|
// will be dropped. A modal grab can fail if there is already a grab
|
||||||
|
// in effect from aother application; in this case the function returns
|
||||||
|
// false and nothing happens. Non-modal grabs can never fail.
|
||||||
//
|
//
|
||||||
// If @params contains { grabFocus: true }, then if you call grab()
|
// If @params contains { grabFocus: true }, then if you call grab()
|
||||||
// while the shell is outside the overview, it will set the stage
|
// while the shell is outside the overview, it will set the stage
|
||||||
@ -151,10 +153,12 @@ const GrabHelper = new Lang.Class({
|
|||||||
let newFocus = params.actor;
|
let newFocus = params.actor;
|
||||||
|
|
||||||
if (this.isActorGrabbed(params.actor))
|
if (this.isActorGrabbed(params.actor))
|
||||||
return;
|
return true;
|
||||||
|
|
||||||
if (this._grabFocusCount == 0 && this._modalCount == 0)
|
if (this._grabFocusCount == 0 && this._modalCount == 0) {
|
||||||
this._fullGrab(hadFocus, params.modal, params.grabFocus);
|
if (!this._fullGrab(hadFocus, params.modal, params.grabFocus))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
params.savedFocus = focus;
|
params.savedFocus = focus;
|
||||||
this._grabStack.push(params);
|
this._grabStack.push(params);
|
||||||
@ -166,19 +170,22 @@ const GrabHelper = new Lang.Class({
|
|||||||
this._grabFocusCount++;
|
this._grabFocusCount++;
|
||||||
|
|
||||||
_navigateActor(newFocus, hadFocus);
|
_navigateActor(newFocus, hadFocus);
|
||||||
|
|
||||||
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
_fullGrab: function(hadFocus, modal, grabFocus) {
|
_fullGrab: function(hadFocus, modal, grabFocus) {
|
||||||
let metaDisplay = global.screen.get_display();
|
let metaDisplay = global.screen.get_display();
|
||||||
|
|
||||||
|
if (modal) {
|
||||||
|
if (!Main.pushModal(this._owner))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
this._grabbedFromKeynav = hadFocus;
|
this._grabbedFromKeynav = hadFocus;
|
||||||
this._preGrabInputMode = global.stage_input_mode;
|
this._preGrabInputMode = global.stage_input_mode;
|
||||||
this._prevFocusedWindow = null;
|
this._prevFocusedWindow = null;
|
||||||
|
|
||||||
if (modal) {
|
|
||||||
Main.pushModal(this._owner);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (grabFocus) {
|
if (grabFocus) {
|
||||||
this._prevFocusedWindow = metaDisplay.focus_window;
|
this._prevFocusedWindow = metaDisplay.focus_window;
|
||||||
if (this._preGrabInputMode == Shell.StageInputMode.NONREACTIVE ||
|
if (this._preGrabInputMode == Shell.StageInputMode.NONREACTIVE ||
|
||||||
@ -193,6 +200,8 @@ const GrabHelper = new Lang.Class({
|
|||||||
this._keyFocusNotifyId = global.stage.connect('notify::key-focus', Lang.bind(this, this._onKeyFocusChanged));
|
this._keyFocusNotifyId = global.stage.connect('notify::key-focus', Lang.bind(this, this._onKeyFocusChanged));
|
||||||
this._focusWindowChangedId = metaDisplay.connect('notify::focus-window', Lang.bind(this, this._focusWindowChanged));
|
this._focusWindowChangedId = metaDisplay.connect('notify::focus-window', Lang.bind(this, this._focusWindowChanged));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
// ignoreRelease:
|
// ignoreRelease:
|
||||||
|
@ -1489,19 +1489,24 @@ const MessageTray = new Lang.Class({
|
|||||||
let pointerWatcher = PointerWatcher.getPointerWatcher();
|
let pointerWatcher = PointerWatcher.getPointerWatcher();
|
||||||
pointerWatcher.addWatch(TRAY_DWELL_CHECK_INTERVAL, Lang.bind(this, this._checkTrayDwell));
|
pointerWatcher.addWatch(TRAY_DWELL_CHECK_INTERVAL, Lang.bind(this, this._checkTrayDwell));
|
||||||
this._trayDwellTimeoutId = 0;
|
this._trayDwellTimeoutId = 0;
|
||||||
|
this._trayDwelling = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
_checkTrayDwell: function(x, y) {
|
_checkTrayDwell: function(x, y) {
|
||||||
// We only set up dwell timeout when the user is not hovering over the tray
|
if (y == global.screen_height - 1) {
|
||||||
// (!this.actor.hover). This avoids bringing up the message tray after the
|
// We only set up dwell timeout when the user is not hovering over the tray
|
||||||
// user clicks on a notification with the pointer on the bottom pixel
|
// (!this.actor.hover). This avoids bringing up the message tray after the
|
||||||
// of the monitor.
|
// user clicks on a notification with the pointer on the bottom pixel
|
||||||
if (y == global.screen_height - 1 && !this.actor.hover) {
|
// of the monitor. The _trayDwelling variable is used so that we only try to
|
||||||
if (this._trayDwellTimeoutId == 0)
|
// fire off one tray dwell - if it fails (because, say, the user has the mouse down),
|
||||||
|
// we don't try again until the user moves the mouse up and down again.
|
||||||
|
if (!this._trayDwelling && !this.actor.hover && this._trayDwellTimeoutId == 0)
|
||||||
this._trayDwellTimeoutId = Mainloop.timeout_add(TRAY_DWELL_TIME,
|
this._trayDwellTimeoutId = Mainloop.timeout_add(TRAY_DWELL_TIME,
|
||||||
Lang.bind(this, this._trayDwellTimeout));
|
Lang.bind(this, this._trayDwellTimeout));
|
||||||
|
this._trayDwelling = true;
|
||||||
} else {
|
} else {
|
||||||
this._cancelTrayDwell();
|
this._cancelTrayDwell();
|
||||||
|
this._trayDwelling = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1993,19 +1998,22 @@ const MessageTray = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_showTray: function() {
|
_showTray: function() {
|
||||||
|
// Don't actually take a modal grab in the overview.
|
||||||
|
// Just add something to the grab stack that we can
|
||||||
|
// pop later.
|
||||||
|
if (!this._grabHelper.grab({ actor: this.actor,
|
||||||
|
modal: !this._overviewVisible,
|
||||||
|
onUngrab: Lang.bind(this, this._escapeTray) })) {
|
||||||
|
this._traySummoned = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this._tween(this.actor, '_trayState', State.SHOWN,
|
this._tween(this.actor, '_trayState', State.SHOWN,
|
||||||
{ y: -this.actor.height,
|
{ y: -this.actor.height,
|
||||||
time: ANIMATION_TIME,
|
time: ANIMATION_TIME,
|
||||||
transition: 'easeOutQuad'
|
transition: 'easeOutQuad'
|
||||||
});
|
});
|
||||||
|
|
||||||
// Don't actually take a modal grab in the overview.
|
|
||||||
// Just add something to the grab stack that we can
|
|
||||||
// pop later.
|
|
||||||
this._grabHelper.grab({ actor: this.actor,
|
|
||||||
modal: !this._overviewVisible,
|
|
||||||
onUngrab: Lang.bind(this, this._escapeTray) });
|
|
||||||
|
|
||||||
// Don't move the windows up if we are in the overview,
|
// Don't move the windows up if we are in the overview,
|
||||||
// but show the tray in the ctrl+alt+tab list.
|
// but show the tray in the ctrl+alt+tab list.
|
||||||
if (this._overviewVisible) {
|
if (this._overviewVisible) {
|
||||||
|
Loading…
Reference in New Issue
Block a user