Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions data/gala.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
<value nick="switch-to-workspace-last" value="10" />
</enum>

<enum id="SuperScrollAction">
<value nick="none" value="0" />
<value nick="switch-workspace" value="1" />
<value nick="zoom" value="2" />
</enum>

<schema path="/io/elementary/desktop/screensaver/" id="io.elementary.desktop.screensaver">
<key type="b" name="lock-on-suspend">
<default>true</default>
Expand Down Expand Up @@ -96,6 +102,11 @@
<summary>Whether hotcorners should be enabled when fullscreen window is opened</summary>
<description></description>
</key>
<key enum="SuperScrollAction" name="super-scroll-action">
<default>"none"</default>
<summary>What action should be performed on Super + Scroll</summary>
<description></description>
</key>
</schema>

<schema path="/io/elementary/desktop/wm/keybindings/" id="io.elementary.desktop.wm.keybindings">
Expand Down
45 changes: 45 additions & 0 deletions src/SuperScrollAction.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* SPDX-License-Identifier: GPL-3.0-or-later
* SPDX-FileCopyrightText: 2024 elementary, Inc. (https://elementary.io)
*/

public class Gala.SuperScrollAction : Clutter.Action {
public signal bool triggered (uint32 timestamp, double dx, double dy);

public Meta.Display display { private get; construct; }

public SuperScrollAction (Meta.Display display) {
Object (display: display);
}

public override bool handle_event (Clutter.Event event) {
if (
event.get_type () == SCROLL &&
(event.get_state () & display.compositor_modifiers) != 0
) {
double dx = 0.0, dy = 0.0;
switch (event.get_scroll_direction ()) {
case LEFT:
dx = -1.0;
break;
case RIGHT:
dx = 1.0;
break;
case UP:
dy = 1.0;
break;
case DOWN:
dy = -1.0;
break;
default:
break;
}

// TODO: support natural scroll settings

return triggered (event.get_time (), dx, dy);
}

return Clutter.EVENT_PROPAGATE;
}
}
21 changes: 21 additions & 0 deletions src/WindowManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,10 @@ namespace Gala {

display.window_created.connect ((window) => window_created (window));

var scroll_action = new SuperScrollAction (display);
scroll_action.triggered.connect (handle_super_scroll);
stage.add_action_full ("wm-super-scroll-action", CAPTURE, scroll_action);

stage.show ();

plugin_manager.load_waiting_plugins ();
Expand Down Expand Up @@ -438,6 +442,23 @@ namespace Gala {
}
}


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
23 changes: 23 additions & 0 deletions src/Zoom.vala
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class Gala.Zoom : Object {
private ulong wins_handler_id = 0UL;

private GestureTracker gesture_tracker;
private GLib.Settings behavior_settings;

public Zoom (WindowManager wm) {
Object (wm: wm);
Expand All @@ -33,6 +34,12 @@ public class Gala.Zoom : Object {
gesture_tracker.enable_touchpad ();
gesture_tracker.on_gesture_detected.connect (on_gesture_detected);
gesture_tracker.on_gesture_handled.connect ((gesture) => zoom_with_gesture (gesture.direction));

behavior_settings = new GLib.Settings ("io.elementary.desktop.wm.behavior");

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 @@ -78,6 +85,22 @@ public class Gala.Zoom : Object {
return false;
}

private bool handle_super_scroll (uint32 timestamp, double dx, double dy) {
if (behavior_settings.get_enum ("super-scroll-action") != 2) {
return Clutter.EVENT_PROPAGATE;
}

var d = dx.abs () > dy.abs () ? dx : dy;

if (d > 0) {
zoom (SHORTCUT_DELTA, true, AnimationsSettings.get_enable_animations ());
} else if (d < 0) {
zoom (-SHORTCUT_DELTA, true, AnimationsSettings.get_enable_animations ());
}

return Clutter.EVENT_STOP;
}

private void zoom_with_gesture (GestureDirection direction) {
var initial_zoom = current_zoom;
var target_zoom = (direction == GestureDirection.IN)
Expand Down
1 change: 1 addition & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ gala_bin_sources = files(
'ScreenSaverManager.vala',
'ScreenshotManager.vala',
'SessionManager.vala',
'SuperScrollAction.vala',
'WindowAttentionTracker.vala',
'WindowGrabTracker.vala',
'WindowListener.vala',
Expand Down
Loading