Skip to content

Shorten long keybinding lines #2310

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions plugins/pip/Main.vala
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class Gala.Plugins.PIP.Plugin : Gala.Plugin {
var display = wm.get_display ();
var settings = new GLib.Settings ("io.elementary.desktop.wm.keybindings");

display.add_keybinding ("pip", settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, (Meta.KeyHandlerFunc) on_initiate);
display.add_keybinding ("pip", settings, IGNORE_AUTOREPEAT, on_initiate);
}

public override void destroy () {
Expand All @@ -50,7 +50,7 @@ public class Gala.Plugins.PIP.Plugin : Gala.Plugin {
}

[CCode (instance_pos = -1)]
private void on_initiate (Meta.Display display, Meta.Window? window, Clutter.KeyEvent event,
private void on_initiate (Meta.Display display, Meta.Window? window, Clutter.KeyEvent? event,
Meta.KeyBinding binding) {
selection_area = new SelectionArea (wm);
selection_area.selected.connect (on_selection_actor_selected);
Expand Down
2 changes: 1 addition & 1 deletion src/Widgets/WindowSwitcher/WindowSwitcher.vala
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ public class Gala.WindowSwitcher : CanvasActor, GestureTarget {
[CCode (instance_pos = -1)]
public void handle_switch_windows (
Meta.Display display, Meta.Window? window,
Clutter.KeyEvent event, Meta.KeyBinding binding
Clutter.KeyEvent? event, Meta.KeyBinding binding
) {
if (gesture_controller.recognizing) {
return;
Expand Down
79 changes: 42 additions & 37 deletions src/WindowManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,12 @@ namespace Gala {
window_switcher = new WindowSwitcher (this);
ui_group.add_child (window_switcher);

Meta.KeyBinding.set_custom_handler ("switch-applications", (Meta.KeyHandlerFunc) window_switcher.handle_switch_windows);
Meta.KeyBinding.set_custom_handler ("switch-applications-backward", (Meta.KeyHandlerFunc) window_switcher.handle_switch_windows);
Meta.KeyBinding.set_custom_handler ("switch-windows", (Meta.KeyHandlerFunc) window_switcher.handle_switch_windows);
Meta.KeyBinding.set_custom_handler ("switch-windows-backward", (Meta.KeyHandlerFunc) window_switcher.handle_switch_windows);
Meta.KeyBinding.set_custom_handler ("switch-group", (Meta.KeyHandlerFunc) window_switcher.handle_switch_windows);
Meta.KeyBinding.set_custom_handler ("switch-group-backward", (Meta.KeyHandlerFunc) window_switcher.handle_switch_windows);
Meta.KeyBinding.set_custom_handler ("switch-applications", window_switcher.handle_switch_windows);
Meta.KeyBinding.set_custom_handler ("switch-applications-backward", window_switcher.handle_switch_windows);
Meta.KeyBinding.set_custom_handler ("switch-windows", window_switcher.handle_switch_windows);
Meta.KeyBinding.set_custom_handler ("switch-windows-backward", window_switcher.handle_switch_windows);
Meta.KeyBinding.set_custom_handler ("switch-group", window_switcher.handle_switch_windows);
Meta.KeyBinding.set_custom_handler ("switch-group-backward", window_switcher.handle_switch_windows);
}

if (plugin_manager.window_overview_provider == null
Expand Down Expand Up @@ -287,17 +287,17 @@ namespace Gala {
/*keybindings*/
var keybinding_settings = new GLib.Settings ("io.elementary.desktop.wm.keybindings");

display.add_keybinding ("switch-to-workspace-first", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, (Meta.KeyHandlerFunc) handle_switch_to_workspace_end);
display.add_keybinding ("switch-to-workspace-last", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, (Meta.KeyHandlerFunc) handle_switch_to_workspace_end);
display.add_keybinding ("move-to-workspace-first", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, (Meta.KeyHandlerFunc) handle_move_to_workspace_end);
display.add_keybinding ("move-to-workspace-last", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, (Meta.KeyHandlerFunc) handle_move_to_workspace_end);
display.add_keybinding ("cycle-workspaces-next", keybinding_settings, Meta.KeyBindingFlags.NONE, (Meta.KeyHandlerFunc) handle_cycle_workspaces);
display.add_keybinding ("cycle-workspaces-previous", keybinding_settings, Meta.KeyBindingFlags.NONE, (Meta.KeyHandlerFunc) handle_cycle_workspaces);
display.add_keybinding ("panel-main-menu", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, (Meta.KeyHandlerFunc) handle_applications_menu);
display.add_keybinding ("switch-input-source", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, (Meta.KeyHandlerFunc) handle_switch_input_source);
display.add_keybinding ("switch-input-source-backward", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, (Meta.KeyHandlerFunc) handle_switch_input_source);

display.add_keybinding ("expose-all-windows", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, () => {
display.add_keybinding ("switch-to-workspace-first", keybinding_settings, IGNORE_AUTOREPEAT, handle_switch_to_workspace_end);
display.add_keybinding ("switch-to-workspace-last", keybinding_settings, IGNORE_AUTOREPEAT, handle_switch_to_workspace_end);
display.add_keybinding ("move-to-workspace-first", keybinding_settings, IGNORE_AUTOREPEAT, handle_move_to_workspace_end);
display.add_keybinding ("move-to-workspace-last", keybinding_settings, IGNORE_AUTOREPEAT, handle_move_to_workspace_end);
display.add_keybinding ("cycle-workspaces-next", keybinding_settings, NONE, handle_cycle_workspaces);
display.add_keybinding ("cycle-workspaces-previous", keybinding_settings, NONE, handle_cycle_workspaces);
display.add_keybinding ("panel-main-menu", keybinding_settings, IGNORE_AUTOREPEAT, handle_applications_menu);
display.add_keybinding ("switch-input-source", keybinding_settings, IGNORE_AUTOREPEAT, handle_switch_input_source);
display.add_keybinding ("switch-input-source-backward", keybinding_settings, IGNORE_AUTOREPEAT, handle_switch_input_source);

display.add_keybinding ("expose-all-windows", keybinding_settings, IGNORE_AUTOREPEAT, () => {
if (window_overview.is_opened ()) {
window_overview.close ();
} else {
Expand All @@ -323,17 +323,17 @@ namespace Gala {

Meta.KeyBinding.set_custom_handler ("switch-to-workspace-up", () => {});
Meta.KeyBinding.set_custom_handler ("switch-to-workspace-down", () => {});
Meta.KeyBinding.set_custom_handler ("switch-to-workspace-left", (Meta.KeyHandlerFunc) handle_switch_to_workspace);
Meta.KeyBinding.set_custom_handler ("switch-to-workspace-right", (Meta.KeyHandlerFunc) handle_switch_to_workspace);
Meta.KeyBinding.set_custom_handler ("switch-to-workspace-left", handle_switch_to_workspace);
Meta.KeyBinding.set_custom_handler ("switch-to-workspace-right", handle_switch_to_workspace);

Meta.KeyBinding.set_custom_handler ("move-to-workspace-up", () => {});
Meta.KeyBinding.set_custom_handler ("move-to-workspace-down", () => {});
Meta.KeyBinding.set_custom_handler ("move-to-workspace-left", (Meta.KeyHandlerFunc) handle_move_to_workspace);
Meta.KeyBinding.set_custom_handler ("move-to-workspace-right", (Meta.KeyHandlerFunc) handle_move_to_workspace);
Meta.KeyBinding.set_custom_handler ("move-to-workspace-left", handle_move_to_workspace);
Meta.KeyBinding.set_custom_handler ("move-to-workspace-right", handle_move_to_workspace);

for (int i = 1; i < 13; i++) {
Meta.KeyBinding.set_custom_handler ("switch-to-workspace-%d".printf (i), (Meta.KeyHandlerFunc) handle_switch_to_workspace);
Meta.KeyBinding.set_custom_handler ("move-to-workspace-%d".printf (i), (Meta.KeyHandlerFunc) handle_move_to_workspace);
Meta.KeyBinding.set_custom_handler ("switch-to-workspace-%d".printf (i), handle_switch_to_workspace);
Meta.KeyBinding.set_custom_handler ("move-to-workspace-%d".printf (i), handle_move_to_workspace);
}

unowned var monitor_manager = display.get_context ().get_backend ().get_monitor_manager ();
Expand Down Expand Up @@ -428,7 +428,7 @@ namespace Gala {
}

[CCode (instance_pos = -1)]
private void handle_cycle_workspaces (Meta.Display display, Meta.Window? window, Clutter.KeyEvent event,
private void handle_cycle_workspaces (Meta.Display display, Meta.Window? window, Clutter.KeyEvent? event,
Meta.KeyBinding binding) {
var direction = (binding.get_name () == "cycle-workspaces-next" ? 1 : -1);
unowned var manager = display.get_workspace_manager ();
Expand All @@ -442,15 +442,16 @@ namespace Gala {
}

if (active_workspace_index != index) {
manager.get_workspace_by_index (index).activate (event.get_time ());
var timestamp = event != null ? event.get_time () : Meta.CURRENT_TIME;
manager.get_workspace_by_index (index).activate (timestamp);
} else {
InternalUtils.bell_notify (display);
}
}

[CCode (instance_pos = -1)]
private void handle_move_to_workspace (Meta.Display display, Meta.Window? window,
Clutter.KeyEvent event, Meta.KeyBinding binding) {
Clutter.KeyEvent? event, Meta.KeyBinding binding) {
if (window == null) {
return;
}
Expand All @@ -471,31 +472,35 @@ namespace Gala {
}

if (target_workspace != null) {
move_window (window, target_workspace, event.get_time ());
var timestamp = event != null ? event.get_time () : Meta.CURRENT_TIME;
move_window (window, target_workspace, timestamp);
}
}

[CCode (instance_pos = -1)]
private void handle_move_to_workspace_end (Meta.Display display, Meta.Window? window,
Clutter.KeyEvent event, Meta.KeyBinding binding) {
if (window == null)
Clutter.KeyEvent? event, Meta.KeyBinding binding) {
if (window == null) {
return;
}

var timestamp = event != null ? event.get_time (): Meta.CURRENT_TIME;
unowned Meta.WorkspaceManager manager = display.get_workspace_manager ();
var index = (binding.get_name () == "move-to-workspace-first" ? 0 : manager.get_n_workspaces () - 1);
unowned var workspace = manager.get_workspace_by_index (index);
window.change_workspace (workspace);
workspace.activate_with_focus (window, event.get_time ());
workspace.activate_with_focus (window, timestamp);
}

[CCode (instance_pos = -1)]
private void handle_switch_to_workspace (Meta.Display display, Meta.Window? window,
Clutter.KeyEvent event, Meta.KeyBinding binding) {
Clutter.KeyEvent? event, Meta.KeyBinding binding) {
var timestamp = event != null ? event.get_time () : Meta.CURRENT_TIME;
unowned var name = binding.get_name ();

if (name == "switch-to-workspace-left" || name == "switch-to-workspace-right") {
var direction = (name == "switch-to-workspace-left" ? Meta.MotionDirection.LEFT : Meta.MotionDirection.RIGHT);
switch_to_next_workspace (direction, event.get_time ());
switch_to_next_workspace (direction, timestamp);
} else {
unowned var workspace_manager = get_display ().get_workspace_manager ();

Expand All @@ -507,27 +512,27 @@ namespace Gala {
return;
}

workspace.activate (event.get_time ());
workspace.activate (timestamp);
}
}

[CCode (instance_pos = -1)]
private void handle_switch_to_workspace_end (Meta.Display display, Meta.Window? window,
Clutter.KeyEvent event, Meta.KeyBinding binding) {
Clutter.KeyEvent? event, Meta.KeyBinding binding) {
unowned Meta.WorkspaceManager manager = display.get_workspace_manager ();
var index = (binding.get_name () == "switch-to-workspace-first" ? 0 : manager.n_workspaces - 1);
manager.get_workspace_by_index (index).activate (event.get_time ());
manager.get_workspace_by_index (index).activate (event != null ? event.get_time () : Meta.CURRENT_TIME);
}

[CCode (instance_pos = -1)]
private void handle_applications_menu (Meta.Display display, Meta.Window? window,
Clutter.KeyEvent event, Meta.KeyBinding binding) {
Clutter.KeyEvent? event, Meta.KeyBinding binding) {
launch_action (ActionKeys.PANEL_MAIN_MENU_ACTION);
}

[CCode (instance_pos = -1)]
private void handle_switch_input_source (Meta.Display display, Meta.Window? window,
Clutter.KeyEvent event, Meta.KeyBinding binding) {
Clutter.KeyEvent? event, Meta.KeyBinding binding) {
KeyboardManager.handle_modifiers_accelerator_activated (display, binding.get_name ().has_suffix ("-backward"));
}

Expand Down
8 changes: 4 additions & 4 deletions src/Zoom.vala
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public class Gala.Zoom : Object, GestureTarget {
unowned var display = wm.get_display ();
var schema = new GLib.Settings ("io.elementary.desktop.wm.keybindings");

display.add_keybinding ("zoom-in", schema, Meta.KeyBindingFlags.NONE, (Meta.KeyHandlerFunc) zoom_in);
display.add_keybinding ("zoom-out", schema, Meta.KeyBindingFlags.NONE, (Meta.KeyHandlerFunc) zoom_out);
display.add_keybinding ("zoom-in", schema, NONE, zoom_in);
display.add_keybinding ("zoom-out", schema, NONE, zoom_out);

gesture_controller = new GestureController (ZOOM, this, wm) {
snap = false
Expand Down Expand Up @@ -63,13 +63,13 @@ public class Gala.Zoom : Object, GestureTarget {

[CCode (instance_pos = -1)]
private void zoom_in (Meta.Display display, Meta.Window? window,
Clutter.KeyEvent event, Meta.KeyBinding binding) {
Clutter.KeyEvent? event, Meta.KeyBinding binding) {
zoom (SHORTCUT_DELTA, true);
}

[CCode (instance_pos = -1)]
private void zoom_out (Meta.Display display, Meta.Window? window,
Clutter.KeyEvent event, Meta.KeyBinding binding) {
Clutter.KeyEvent? event, Meta.KeyBinding binding) {
zoom (-SHORTCUT_DELTA, true);
}

Expand Down
Loading