mirror of
https://github.com/elementary/gala.git
synced 2024-09-11 15:15:39 +03:00
Fix barriers (#1908)
This commit is contained in:
parent
fe650bfa80
commit
29da53aedc
@ -6,7 +6,7 @@
|
|||||||
/**
|
/**
|
||||||
* A pointer barrier supporting pressured activation.
|
* A pointer barrier supporting pressured activation.
|
||||||
*/
|
*/
|
||||||
public class Gala.Barrier : Meta.Barrier {
|
public class Gala.Barrier : Object {
|
||||||
public signal void trigger ();
|
public signal void trigger ();
|
||||||
|
|
||||||
public bool triggered { get; set; default = false; }
|
public bool triggered { get; set; default = false; }
|
||||||
@ -16,6 +16,8 @@ public class Gala.Barrier : Meta.Barrier {
|
|||||||
public int retrigger_pressure_threshold { get; construct; }
|
public int retrigger_pressure_threshold { get; construct; }
|
||||||
public int retrigger_delay { get; construct; }
|
public int retrigger_delay { get; construct; }
|
||||||
|
|
||||||
|
private Meta.Barrier barrier;
|
||||||
|
|
||||||
private uint32 triggered_time;
|
private uint32 triggered_time;
|
||||||
private double pressure;
|
private double pressure;
|
||||||
|
|
||||||
@ -26,6 +28,7 @@ public class Gala.Barrier : Meta.Barrier {
|
|||||||
* the barrier to trigger again. Set to int.MAX to disallow retrigger.
|
* the barrier to trigger again. Set to int.MAX to disallow retrigger.
|
||||||
*/
|
*/
|
||||||
public Barrier (
|
public Barrier (
|
||||||
|
Meta.Backend backend,
|
||||||
int x1,
|
int x1,
|
||||||
int y1,
|
int y1,
|
||||||
int x2,
|
int x2,
|
||||||
@ -37,25 +40,27 @@ public class Gala.Barrier : Meta.Barrier {
|
|||||||
int retrigger_delay
|
int retrigger_delay
|
||||||
) {
|
) {
|
||||||
Object (
|
Object (
|
||||||
x1: x1,
|
|
||||||
y1: y1,
|
|
||||||
x2: x2,
|
|
||||||
y2: y2,
|
|
||||||
directions: directions,
|
|
||||||
trigger_pressure_threshold: trigger_pressure_threshold,
|
trigger_pressure_threshold: trigger_pressure_threshold,
|
||||||
release_pressure_threshold: release_pressure_threshold,
|
release_pressure_threshold: release_pressure_threshold,
|
||||||
retrigger_pressure_threshold: retrigger_pressure_threshold,
|
retrigger_pressure_threshold: retrigger_pressure_threshold,
|
||||||
retrigger_delay: retrigger_delay
|
retrigger_delay: retrigger_delay
|
||||||
);
|
);
|
||||||
|
|
||||||
|
try {
|
||||||
|
barrier = new Meta.Barrier (backend, x1, y1, x2, y2, directions, Meta.BarrierFlags.NONE);
|
||||||
|
barrier.hit.connect (on_hit);
|
||||||
|
barrier.left.connect (on_left);
|
||||||
|
} catch (Error e) {
|
||||||
|
warning ("Failed to create Meta Barrier");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
construct {
|
~Barrier () {
|
||||||
hit.connect (on_hit);
|
barrier.destroy ();
|
||||||
left.connect (on_left);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void on_hit (Meta.BarrierEvent event) {
|
private void on_hit (Meta.BarrierEvent event) {
|
||||||
if (POSITIVE_X in directions || NEGATIVE_X in directions) {
|
if (POSITIVE_X in barrier.directions || NEGATIVE_X in barrier.directions) {
|
||||||
pressure += event.dx.abs ();
|
pressure += event.dx.abs ();
|
||||||
} else {
|
} else {
|
||||||
pressure += event.dy.abs ();
|
pressure += event.dy.abs ();
|
||||||
@ -66,7 +71,7 @@ public class Gala.Barrier : Meta.Barrier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!triggered && pressure > release_pressure_threshold) {
|
if (!triggered && pressure > release_pressure_threshold) {
|
||||||
release (event);
|
barrier.release (event);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (triggered && pressure.abs () > retrigger_pressure_threshold && event.time > retrigger_delay + triggered_time) {
|
if (triggered && pressure.abs () > retrigger_pressure_threshold && event.time > retrigger_delay + triggered_time) {
|
||||||
|
@ -48,27 +48,23 @@ public class Gala.HotCorner : Object {
|
|||||||
private Gala.Barrier? vertical_barrier = null;
|
private Gala.Barrier? vertical_barrier = null;
|
||||||
private Gala.Barrier? horizontal_barrier = null;
|
private Gala.Barrier? horizontal_barrier = null;
|
||||||
|
|
||||||
public HotCorner (Meta.Display display, float x, float y, float scale, string hot_corner_position) {
|
public HotCorner (Meta.Backend backend, float x, float y, float scale, string hot_corner_position) {
|
||||||
add_barriers (display, x, y, scale, hot_corner_position);
|
add_barriers (backend, x, y, scale, hot_corner_position);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void destroy_barriers () {
|
public void destroy_barriers () {
|
||||||
if (vertical_barrier != null) {
|
vertical_barrier = null;
|
||||||
vertical_barrier.destroy ();
|
horizontal_barrier = null;
|
||||||
}
|
|
||||||
|
|
||||||
if (horizontal_barrier != null) {
|
|
||||||
horizontal_barrier.destroy ();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void add_barriers (Meta.Display display, float x, float y, float scale, string hot_corner_position) {
|
private void add_barriers (Meta.Backend backend, float x, float y, float scale, string hot_corner_position) {
|
||||||
var vrect = get_barrier_rect (x, y, scale, hot_corner_position, Clutter.Orientation.VERTICAL);
|
var vrect = get_barrier_rect (x, y, scale, hot_corner_position, Clutter.Orientation.VERTICAL);
|
||||||
var hrect = get_barrier_rect (x, y, scale, hot_corner_position, Clutter.Orientation.HORIZONTAL);
|
var hrect = get_barrier_rect (x, y, scale, hot_corner_position, Clutter.Orientation.HORIZONTAL);
|
||||||
var vdir = get_barrier_direction (hot_corner_position, Clutter.Orientation.VERTICAL);
|
var vdir = get_barrier_direction (hot_corner_position, Clutter.Orientation.VERTICAL);
|
||||||
var hdir = get_barrier_direction (hot_corner_position, Clutter.Orientation.HORIZONTAL);
|
var hdir = get_barrier_direction (hot_corner_position, Clutter.Orientation.HORIZONTAL);
|
||||||
|
|
||||||
vertical_barrier = new Gala.Barrier (
|
vertical_barrier = new Gala.Barrier (
|
||||||
|
backend,
|
||||||
vrect.x, vrect.y, vrect.x + vrect.width, vrect.y + vrect.height, vdir,
|
vrect.x, vrect.y, vrect.x + vrect.width, vrect.y + vrect.height, vdir,
|
||||||
TRIGGER_PRESSURE_THRESHOLD,
|
TRIGGER_PRESSURE_THRESHOLD,
|
||||||
RELEASE_PRESSURE_THRESHOLD,
|
RELEASE_PRESSURE_THRESHOLD,
|
||||||
@ -77,6 +73,7 @@ public class Gala.HotCorner : Object {
|
|||||||
);
|
);
|
||||||
|
|
||||||
horizontal_barrier = new Gala.Barrier (
|
horizontal_barrier = new Gala.Barrier (
|
||||||
|
backend,
|
||||||
hrect.x, hrect.y, hrect.x + hrect.width, hrect.y + hrect.height, hdir,
|
hrect.x, hrect.y, hrect.x + hrect.width, hrect.y + hrect.height, hdir,
|
||||||
TRIGGER_PRESSURE_THRESHOLD,
|
TRIGGER_PRESSURE_THRESHOLD,
|
||||||
RELEASE_PRESSURE_THRESHOLD,
|
RELEASE_PRESSURE_THRESHOLD,
|
||||||
|
@ -69,7 +69,7 @@ public class Gala.HotCornerManager : Object {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unowned Meta.Display display = wm.get_display ();
|
unowned Meta.Display display = wm.get_display ();
|
||||||
var hot_corner = new HotCorner (display, (int) x, (int) y, scale, hot_corner_position);
|
var hot_corner = new HotCorner (display.get_context ().get_backend (), (int) x, (int) y, scale, hot_corner_position);
|
||||||
|
|
||||||
hot_corner.trigger.connect (() => {
|
hot_corner.trigger.connect (() => {
|
||||||
if (
|
if (
|
||||||
|
@ -171,7 +171,13 @@ public class Gala.HideTracker : Object {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void toggle_display (bool should_hide) {
|
private void toggle_display (bool should_hide) {
|
||||||
if (should_hide) {
|
#if HAS_MUTTER45
|
||||||
|
hovered = panel.window.has_pointer ();
|
||||||
|
#else
|
||||||
|
hovered = window_has_pointer ();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (should_hide && !hovered) {
|
||||||
// Don't hide if we have transients, e.g. an open popover, dialog, etc.
|
// Don't hide if we have transients, e.g. an open popover, dialog, etc.
|
||||||
var has_transients = false;
|
var has_transients = false;
|
||||||
panel.window.foreach_transient (() => {
|
panel.window.foreach_transient (() => {
|
||||||
@ -179,7 +185,7 @@ public class Gala.HideTracker : Object {
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (hovered || has_transients) {
|
if (has_transients) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,10 +184,7 @@ public class Gala.PanelWindow : Object {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void destroy_barrier () {
|
private void destroy_barrier () {
|
||||||
if (barrier != null) {
|
barrier = null;
|
||||||
barrier.destroy ();
|
|
||||||
barrier = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setup_barrier () {
|
private void setup_barrier () {
|
||||||
@ -217,6 +214,7 @@ public class Gala.PanelWindow : Object {
|
|||||||
private void setup_barrier_top (Meta.Rectangle monitor_geom, int offset) {
|
private void setup_barrier_top (Meta.Rectangle monitor_geom, int offset) {
|
||||||
#endif
|
#endif
|
||||||
barrier = new Barrier (
|
barrier = new Barrier (
|
||||||
|
wm.get_display ().get_context ().get_backend (),
|
||||||
monitor_geom.x + offset,
|
monitor_geom.x + offset,
|
||||||
monitor_geom.y,
|
monitor_geom.y,
|
||||||
monitor_geom.x + monitor_geom.width - offset,
|
monitor_geom.x + monitor_geom.width - offset,
|
||||||
@ -237,6 +235,7 @@ public class Gala.PanelWindow : Object {
|
|||||||
private void setup_barrier_bottom (Meta.Rectangle monitor_geom, int offset) {
|
private void setup_barrier_bottom (Meta.Rectangle monitor_geom, int offset) {
|
||||||
#endif
|
#endif
|
||||||
barrier = new Barrier (
|
barrier = new Barrier (
|
||||||
|
wm.get_display ().get_context ().get_backend (),
|
||||||
monitor_geom.x + offset,
|
monitor_geom.x + offset,
|
||||||
monitor_geom.y + monitor_geom.height,
|
monitor_geom.y + monitor_geom.height,
|
||||||
monitor_geom.x + monitor_geom.width - offset,
|
monitor_geom.x + monitor_geom.width - offset,
|
||||||
|
Loading…
Reference in New Issue
Block a user