ScreenShield: Allow lifting up the curtain with the mouse wheel

On a traditional mouse, or with edge-scrolling on a touchpad, it just
feels natural to unlock by scrolling up.

https://bugzilla.gnome.org/show_bug.cgi?id=683164
This commit is contained in:
Giovanni Campagna 2012-09-02 14:48:08 +02:00
parent 11086e8ef8
commit f177bd0b51

View File

@ -355,6 +355,8 @@ const ScreenShield = new Lang.Class({
}); });
this._lockScreenGroup.connect('key-release-event', this._lockScreenGroup.connect('key-release-event',
Lang.bind(this, this._onLockScreenKeyRelease)); Lang.bind(this, this._onLockScreenKeyRelease));
this._lockScreenGroup.connect('scroll-event',
Lang.bind(this, this._onLockScreenScroll));
this._lockScreenContents = new St.Widget({ layout_manager: new Clutter.BinLayout(), this._lockScreenContents = new St.Widget({ layout_manager: new Clutter.BinLayout(),
name: 'lockScreenContents' }); name: 'lockScreenContents' });
@ -439,6 +441,27 @@ const ScreenShield = new Lang.Class({
return true; return true;
}, },
_onLockScreenScroll: function(actor, event) {
if (this._lockScreenState != MessageTray.State.SHOWN)
return false;
let delta = 0;
if (event.get_scroll_direction() == Clutter.ScrollDirection.UP)
delta = 5;
else if (event.get_scroll_direction() == Clutter.ScrollDirection.SMOOTH)
delta = Math.max(0, event.get_scroll_delta()[0]);
this._lockScreenScrollCounter += delta;
// 7 standard scrolls to lift up
if (this._lockScreenScrollCounter > 35) {
this._ensureUnlockDialog();
this._hideLockScreen(0);
}
return true;
},
_animateArrows: function() { _animateArrows: function() {
let arrows = this._arrowContainer.get_children(); let arrows = this._arrowContainer.get_children();
let unitaryDelay = ARROW_ANIMATION_TIME / (arrows.length + 1); let unitaryDelay = ARROW_ANIMATION_TIME / (arrows.length + 1);
@ -656,6 +679,7 @@ const ScreenShield = new Lang.Class({
this._lockScreenState = MessageTray.State.SHOWN; this._lockScreenState = MessageTray.State.SHOWN;
this._lockScreenGroup.fixed_position_set = false; this._lockScreenGroup.fixed_position_set = false;
this._lockScreenScrollCounter = 0;
this.emit('lock-screen-shown'); this.emit('lock-screen-shown');
}, },