Skip to content

Commit

Permalink
Make triggered bool and have everything add their own
Browse files Browse the repository at this point in the history
  • Loading branch information
leolost2605 committed Dec 19, 2024
1 parent 1c7456f commit c8c0bee
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 29 deletions.
6 changes: 0 additions & 6 deletions lib/WindowManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 2 additions & 4 deletions src/SuperScrollAction.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down Expand Up @@ -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;
Expand Down
33 changes: 17 additions & 16 deletions src/WindowManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 ();

Expand Down Expand Up @@ -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) {
Expand Down
11 changes: 8 additions & 3 deletions src/Zoom.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand Down

0 comments on commit c8c0bee

Please sign in to comment.