layout: Port the hot corner to pressure barriers
If the X server supports the new barrier features, we should trigger the overview hot corner with a pressure barrier as well. https://bugzilla.gnome.org/show_bug.cgi?id=663661
This commit is contained in:
parent
36a7429aa0
commit
26966b2bf3
101
js/ui/layout.js
101
js/ui/layout.js
@ -28,6 +28,9 @@ const DEFAULT_BACKGROUND_COLOR = Clutter.Color.from_pixel(0x2e3436ff);
|
|||||||
const MESSAGE_TRAY_PRESSURE_THRESHOLD = 250; // pixels
|
const MESSAGE_TRAY_PRESSURE_THRESHOLD = 250; // pixels
|
||||||
const MESSAGE_TRAY_PRESSURE_TIMEOUT = 1000; // ms
|
const MESSAGE_TRAY_PRESSURE_TIMEOUT = 1000; // ms
|
||||||
|
|
||||||
|
const HOT_CORNER_PRESSURE_THRESHOLD = 100; // pixels
|
||||||
|
const HOT_CORNER_PRESSURE_TIMEOUT = 1000; // ms
|
||||||
|
|
||||||
function isPopupMetaWindow(actor) {
|
function isPopupMetaWindow(actor) {
|
||||||
switch(actor.meta_window.get_window_type()) {
|
switch(actor.meta_window.get_window_type()) {
|
||||||
case Meta.WindowType.DROPDOWN_MENU:
|
case Meta.WindowType.DROPDOWN_MENU:
|
||||||
@ -1109,6 +1112,52 @@ const HotCorner = new Lang.Class({
|
|||||||
this._x = x;
|
this._x = x;
|
||||||
this._y = y;
|
this._y = y;
|
||||||
|
|
||||||
|
this._setupFallbackCornerIfNeeded();
|
||||||
|
|
||||||
|
this._pressureBarrier = new PressureBarrier(HOT_CORNER_PRESSURE_THRESHOLD,
|
||||||
|
HOT_CORNER_PRESSURE_TIMEOUT,
|
||||||
|
Shell.KeyBindingMode.NORMAL |
|
||||||
|
Shell.KeyBindingMode.OVERVIEW);
|
||||||
|
this._pressureBarrier.connect('trigger', Lang.bind(this, this._toggleOverview));
|
||||||
|
|
||||||
|
// Cache the three ripples instead of dynamically creating and destroying them.
|
||||||
|
this._ripple1 = new St.BoxLayout({ style_class: 'ripple-box', opacity: 0, visible: false });
|
||||||
|
this._ripple2 = new St.BoxLayout({ style_class: 'ripple-box', opacity: 0, visible: false });
|
||||||
|
this._ripple3 = new St.BoxLayout({ style_class: 'ripple-box', opacity: 0, visible: false });
|
||||||
|
|
||||||
|
layoutManager.uiGroup.add_actor(this._ripple1);
|
||||||
|
layoutManager.uiGroup.add_actor(this._ripple2);
|
||||||
|
layoutManager.uiGroup.add_actor(this._ripple3);
|
||||||
|
},
|
||||||
|
|
||||||
|
setBarrierSize: function(size) {
|
||||||
|
if (this._verticalBarrier) {
|
||||||
|
this._pressureBarrier.removeBarrier(this._verticalBarrier);
|
||||||
|
this._verticalBarrier.destroy();
|
||||||
|
this._verticalBarrier = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this._horizontalBarrier) {
|
||||||
|
this._pressureBarrier.removeBarrier(this._horizontalBarrier);
|
||||||
|
this._horizontalBarrier.destroy();
|
||||||
|
this._horizontalBarrier = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (size > 0) {
|
||||||
|
this._verticalBarrier = new Meta.Barrier({ display: global.display,
|
||||||
|
x1: this._x, x2: this._x, y1: this._y, y2: this._y + size,
|
||||||
|
directions: Meta.BarrierDirection.POSITIVE_X });
|
||||||
|
this._horizontalBarrier = new Meta.Barrier({ display: global.display,
|
||||||
|
x1: this._x, x2: this._x + size, y1: this._y, y2: this._y,
|
||||||
|
directions: Meta.BarrierDirection.POSITIVE_Y });
|
||||||
|
|
||||||
|
this._pressureBarrier.addBarrier(this._verticalBarrier);
|
||||||
|
this._pressureBarrier.addBarrier(this._horizontalBarrier);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_setupFallbackCornerIfNeeded: function() {
|
||||||
|
if (!global.display.supports_extended_barriers()) {
|
||||||
this.actor = new Clutter.Actor({ name: 'hot-corner-environs',
|
this.actor = new Clutter.Actor({ name: 'hot-corner-environs',
|
||||||
x: x, y: y,
|
x: x, y: y,
|
||||||
width: 3,
|
width: 3,
|
||||||
@ -1139,40 +1188,15 @@ const HotCorner = new Lang.Class({
|
|||||||
Lang.bind(this, this._onCornerEntered));
|
Lang.bind(this, this._onCornerEntered));
|
||||||
this._corner.connect('leave-event',
|
this._corner.connect('leave-event',
|
||||||
Lang.bind(this, this._onCornerLeft));
|
Lang.bind(this, this._onCornerLeft));
|
||||||
|
|
||||||
// Cache the three ripples instead of dynamically creating and destroying them.
|
|
||||||
this._ripple1 = new St.BoxLayout({ style_class: 'ripple-box', opacity: 0, visible: false });
|
|
||||||
this._ripple2 = new St.BoxLayout({ style_class: 'ripple-box', opacity: 0, visible: false });
|
|
||||||
this._ripple3 = new St.BoxLayout({ style_class: 'ripple-box', opacity: 0, visible: false });
|
|
||||||
|
|
||||||
layoutManager.uiGroup.add_actor(this._ripple1);
|
|
||||||
layoutManager.uiGroup.add_actor(this._ripple2);
|
|
||||||
layoutManager.uiGroup.add_actor(this._ripple3);
|
|
||||||
},
|
|
||||||
|
|
||||||
setBarrierSize: function(size) {
|
|
||||||
if (this._verticalBarrier) {
|
|
||||||
this._verticalBarrier.destroy();
|
|
||||||
this._verticalBarrier = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this._horizontalBarrier) {
|
|
||||||
this._horizontalBarrier.destroy();
|
|
||||||
this._horizontalBarrier = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (size > 0) {
|
|
||||||
this._verticalBarrier = new Meta.Barrier({ display: global.display,
|
|
||||||
x1: this._x, x2: this._x, y1: this._y, y2: this._y + size,
|
|
||||||
directions: Meta.BarrierDirection.POSITIVE_X });
|
|
||||||
this._horizontalBarrier = new Meta.Barrier({ display: global.display,
|
|
||||||
x1: this._x, x2: this._x + size, y1: this._y, y2: this._y,
|
|
||||||
directions: Meta.BarrierDirection.POSITIVE_Y });
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
destroy: function() {
|
destroy: function() {
|
||||||
this.setBarrierSize(0);
|
this.setBarrierSize(0);
|
||||||
|
this._pressureBarrier.destroy();
|
||||||
|
this._pressureBarrier = null;
|
||||||
|
|
||||||
|
if (this.actor)
|
||||||
this.actor.destroy();
|
this.actor.destroy();
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1206,7 +1230,7 @@ const HotCorner = new Lang.Class({
|
|||||||
onComplete: function() { ripple.visible = false; } });
|
onComplete: function() { ripple.visible = false; } });
|
||||||
},
|
},
|
||||||
|
|
||||||
rippleAnimation: function() {
|
_rippleAnimation: function() {
|
||||||
// Show three concentric ripples expanding outwards; the exact
|
// Show three concentric ripples expanding outwards; the exact
|
||||||
// parameters were found by trial and error, so don't look
|
// parameters were found by trial and error, so don't look
|
||||||
// for them to make perfect sense mathematically
|
// for them to make perfect sense mathematically
|
||||||
@ -1217,25 +1241,24 @@ const HotCorner = new Lang.Class({
|
|||||||
this._animRipple(this._ripple3, 0.35, 1.0, 0.0, 0.3, 1);
|
this._animRipple(this._ripple3, 0.35, 1.0, 0.0, 0.3, 1);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_toggleOverview: function() {
|
||||||
|
if (Main.overview.shouldToggleByCornerOrButton()) {
|
||||||
|
this._rippleAnimation();
|
||||||
|
Main.overview.toggle();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
handleDragOver: function(source, actor, x, y, time) {
|
handleDragOver: function(source, actor, x, y, time) {
|
||||||
if (source != Main.xdndHandler)
|
if (source != Main.xdndHandler)
|
||||||
return DND.DragMotionResult.CONTINUE;
|
return DND.DragMotionResult.CONTINUE;
|
||||||
|
|
||||||
if (Main.overview.shouldToggleByCornerOrButton()) {
|
|
||||||
this.rippleAnimation();
|
|
||||||
Main.overview.toggle();
|
|
||||||
}
|
|
||||||
|
|
||||||
return DND.DragMotionResult.CONTINUE;
|
return DND.DragMotionResult.CONTINUE;
|
||||||
},
|
},
|
||||||
|
|
||||||
_onCornerEntered : function() {
|
_onCornerEntered : function() {
|
||||||
if (!this._entered) {
|
if (!this._entered) {
|
||||||
this._entered = true;
|
this._entered = true;
|
||||||
if (Main.overview.shouldToggleByCornerOrButton()) {
|
this._toggleOverview();
|
||||||
this.rippleAnimation();
|
|
||||||
Main.overview.toggle();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user