Make triggered bool and have everything add their own

This commit is contained in:
Leonhard Kargl 2024-12-19 18:41:30 +01:00
parent 1c7456f2df
commit c8c0bee60b
4 changed files with 27 additions and 29 deletions

View File

@ -123,12 +123,6 @@ namespace Gala {
*/
public abstract Gala.ActivatableComponent workspace_view { get; protected set; }
/*
* This signal is sent when Super + Scroll was performed and WindowManager couldn't handle it
* which probably means that the user doesn't want to switch workspaces on Super + Scroll.
*/
public abstract signal void super_scroll_triggered (uint32 timestamp, double dx, double dy);
/**
* Enters the modal mode, which means that all events are directed to the stage instead
* of the windows. This is the only way to receive keyboard events besides shortcut listeners.

View File

@ -4,7 +4,7 @@
*/
public class Gala.SuperScrollAction : Clutter.Action {
public signal void triggered (uint32 timestamp, double dx, double dy);
public signal bool triggered (uint32 timestamp, double dx, double dy);
public Meta.Display display { private get; construct; }
@ -37,9 +37,7 @@ public class Gala.SuperScrollAction : Clutter.Action {
// TODO: support natural scroll settings
triggered (event.get_time (), dx, dy);
return Clutter.EVENT_STOP;
return triggered (event.get_time (), dx, dy);
}
return Clutter.EVENT_PROPAGATE;

View File

@ -159,21 +159,6 @@ namespace Gala {
#endif
}
private void handle_super_scroll (uint32 timestamp, double dx, double dy) {
if (behavior_settings.get_enum ("super-scroll-action") != 1) {
super_scroll_triggered (timestamp, dx, dy);
return;
}
var d = dx.abs () > dy.abs () ? dx : dy;
if (d > 0) {
switch_to_next_workspace (Meta.MotionDirection.RIGHT, timestamp);
} else if (d < 0) {
switch_to_next_workspace (Meta.MotionDirection.LEFT, timestamp);
}
}
#if WITH_SYSTEMD
private async void start_x11_services (GLib.Task task) {
try {
@ -413,7 +398,7 @@ namespace Gala {
var scroll_action = new SuperScrollAction (display);
scroll_action.triggered.connect (handle_super_scroll);
stage.add_action_full ("super-scroll-action", CAPTURE, scroll_action);
stage.add_action_full ("wm-super-scroll-action", CAPTURE, scroll_action);
stage.show ();
@ -473,6 +458,22 @@ namespace Gala {
screen_shield.expand_to_screen_size ();
}
private bool handle_super_scroll (uint32 timestamp, double dx, double dy) {
if (behavior_settings.get_enum ("super-scroll-action") != 1) {
return Clutter.EVENT_PROPAGATE;
}
var d = dx.abs () > dy.abs () ? dx : dy;
if (d > 0) {
switch_to_next_workspace (Meta.MotionDirection.RIGHT, timestamp);
} else if (d < 0) {
switch_to_next_workspace (Meta.MotionDirection.LEFT, timestamp);
}
return Clutter.EVENT_STOP;
}
[CCode (instance_pos = -1)]
private void handle_cycle_workspaces (Meta.Display display, Meta.Window? window, Clutter.KeyEvent event,
Meta.KeyBinding binding) {

View File

@ -35,7 +35,10 @@ public class Gala.Zoom : Object {
gesture_tracker.on_gesture_detected.connect (on_gesture_detected);
behavior_settings = new GLib.Settings ("io.elementary.desktop.wm.behavior");
wm.super_scroll_triggered.connect (handle_super_scroll);
var scroll_action = new SuperScrollAction (display);
scroll_action.triggered.connect (handle_super_scroll);
display.get_stage ().add_action_full ("zoom-super-scroll-action", CAPTURE, scroll_action);
}
~Zoom () {
@ -79,9 +82,9 @@ public class Gala.Zoom : Object {
}
}
private void handle_super_scroll (uint32 timestamp, double dx, double dy) {
private bool handle_super_scroll (uint32 timestamp, double dx, double dy) {
if (behavior_settings.get_enum ("super-scroll-action") != 2) {
return;
return Clutter.EVENT_PROPAGATE;
}
var d = dx.abs () > dy.abs () ? dx : dy;
@ -91,6 +94,8 @@ public class Gala.Zoom : Object {
} else if (d < 0) {
zoom (-SHORTCUT_DELTA, true, AnimationsSettings.get_enable_animations ());
}
return Clutter.EVENT_STOP;
}
private void zoom_with_gesture (GestureDirection direction) {