From d7a9483ad484d51be3896556ac7f1ea1bf1757d4 Mon Sep 17 00:00:00 2001 From: Regolith Linux Date: Sun, 28 Jul 2024 00:51:52 -0700 Subject: [PATCH 1/4] chore: extract functions from contracts --- src/DialogPage.vala | 36 ------------------------------------ src/Util.vala | 35 +++++++++++++++++++++++++++++++++++ src/meson.build | 1 + 3 files changed, 36 insertions(+), 36 deletions(-) create mode 100644 src/Util.vala diff --git a/src/DialogPage.vala b/src/DialogPage.vala index acab715..af6c36c 100644 --- a/src/DialogPage.vala +++ b/src/DialogPage.vala @@ -1,5 +1,3 @@ -using Gtk; - namespace Ilia { /** * A DialogPage represents a filtered, sorted view for the global search entry upon some domain. @@ -60,38 +58,4 @@ namespace Ilia { */ public abstract void show (); } - - /** - * Implement prev/next item for emacs and vim bindings - * - * returns true if key entry was handled - */ - public static bool handle_emacs_vim_nav(Gtk.TreeView item_view, Gtk.TreePath path, Gdk.EventKey key) { - if ((key.state & Gdk.ModifierType.CONTROL_MASK) == Gdk.ModifierType.CONTROL_MASK) { //CTRL - bool is_last = selection_is_last (item_view.get_selection ()); - - if (key.keyval == 'p' || key.keyval == 'k') { - path.prev (); - item_view.get_selection ().select_path (path); - item_view.set_cursor (path, null, false); - } else if ((key.keyval == 'n' || key.keyval == 'j') && !is_last) { - path.next (); - item_view.get_selection ().select_path (path); - item_view.set_cursor (path, null, false); - } - - return true; - } - - return false; - } - - public static bool selection_is_last (TreeSelection selection) { - TreeModel model; - TreeIter iter; - if (selection.get_selected(out model, out iter)) { - return !model.iter_next(ref iter); - } - return false; - } } diff --git a/src/Util.vala b/src/Util.vala new file mode 100644 index 0000000..41e6563 --- /dev/null +++ b/src/Util.vala @@ -0,0 +1,35 @@ +namespace Ilia { + /** + * Implement prev/next item for emacs and vim bindings + * + * returns true if key entry was handled + */ + public static bool handle_emacs_vim_nav(Gtk.TreeView item_view, Gtk.TreePath path, Gdk.EventKey key) { + if ((key.state & Gdk.ModifierType.CONTROL_MASK) == Gdk.ModifierType.CONTROL_MASK) { //CTRL + bool is_last = selection_is_last (item_view.get_selection ()); + + if (key.keyval == 'p' || key.keyval == 'k') { + path.prev (); + item_view.get_selection ().select_path (path); + item_view.set_cursor (path, null, false); + } else if ((key.keyval == 'n' || key.keyval == 'j') && !is_last) { + path.next (); + item_view.get_selection ().select_path (path); + item_view.set_cursor (path, null, false); + } + + return true; + } + + return false; + } + + public static bool selection_is_last (Gtk.TreeSelection selection) { + Gtk.TreeModel model; + Gtk.TreeIter iter; + if (selection.get_selected(out model, out iter)) { + return !model.iter_next(ref iter); + } + return false; + } +} \ No newline at end of file diff --git a/src/meson.build b/src/meson.build index b7cfe4f..574ac6f 100644 --- a/src/meson.build +++ b/src/meson.build @@ -34,6 +34,7 @@ ilia_sources += ['Application.vala'] ilia_sources += ['Main.vala'] ilia_sources += ['IconLoader.vala'] ilia_sources += ['SessionController.vala'] +ilia_sources += ['Util.vala'] ilia_sources += ['apps/DesktopAppPage.vala'] ilia_sources += ['commands/CommandPage.vala'] ilia_sources += ['keybindings/ConfigParser.vala'] From 2e9dcf8a31427f7e9efc443c3b5924c359109864 Mon Sep 17 00:00:00 2001 From: Regolith Linux Date: Sun, 28 Jul 2024 01:44:09 -0700 Subject: [PATCH 2/4] chore: extract global state to module apis --- src/Application.vala | 24 ++++++++++++++--- src/DialogWindow.vala | 36 ++++++++++++++----------- src/Main.vala | 34 ----------------------- src/{DialogPage.vala => ModuleApi.vala} | 14 +++++++++- src/SessionController.vala | 8 ------ src/Util.vala | 12 +++++++++ src/apps/DesktopAppPage.vala | 2 +- src/commands/CommandPage.vala | 2 +- src/keybindings/I3Ipc.vala | 16 ++++++----- src/keybindings/KeybindingsPage.vala | 11 +++++--- src/meson.build | 3 +-- src/notifications/RoficationPage.vala | 2 +- src/textlist/TextListPage.vala | 2 +- src/tracker/TrackerPage.vala | 2 +- src/windows/WindowPage.vala | 16 +++++++---- 15 files changed, 99 insertions(+), 85 deletions(-) rename src/{DialogPage.vala => ModuleApi.vala} (83%) delete mode 100644 src/SessionController.vala diff --git a/src/Application.vala b/src/Application.vala index 7958fd3..1ba1fb9 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -20,11 +20,27 @@ namespace Ilia { } protected override void activate () { - var window = new Ilia.DialogWindow (this.arg_map); + // Get session type (wayland or x11) and set the flag + string session_type = Environment.get_variable ("XDG_SESSION_TYPE"); + string gdk_backend = Environment.get_variable ("GDK_BACKEND"); + var is_wayland_session = session_type == "wayland" && gdk_backend != "x11"; + + // Set window manager + string sway_sock = Environment.get_variable ("SWAYSOCK"); + string i3_sock = Environment.get_variable ("I3SOCK"); + + string wm_name = "Unknown"; + if (sway_sock != null) { + wm_name = "sway"; + } else if (i3_sock != null) { + wm_name = "i3"; + } + + var window = new Ilia.DialogWindow (this.arg_map, is_wayland_session, wm_name); window.set_application (this); // Grab inputs from wayland backend before showing window - if (IS_SESSION_WAYLAND) { + if (is_wayland_session) { bool is_layer_shell_supported = GtkLayerShell.is_supported (); if (!is_layer_shell_supported) { stderr.printf ("The wayland compositor does not support the layer-shell protocol, aborting."); @@ -39,8 +55,8 @@ namespace Ilia { window.show_all (); // Grab inputs from X11 backend after showing window - if (!IS_SESSION_WAYLAND) { - Gdk.Window gdkwin = window.get_window (); + if (!is_wayland_session) { + Gdk.Window gdkwin = window.get_window (); var seat = grab_inputs (gdkwin); if (seat == null) { stderr.printf ("Failed to aquire access to input devices, aborting."); diff --git a/src/DialogWindow.vala b/src/DialogWindow.vala index 7059f3c..91c5f93 100644 --- a/src/DialogWindow.vala +++ b/src/DialogWindow.vala @@ -48,10 +48,16 @@ namespace Ilia { private Gtk.TreeView keybinding_view; - public DialogWindow (HashTable arg_map) { + private string wm_name; + private bool is_wayland; + + public DialogWindow (HashTable arg_map, bool is_wayland_session, string wm_name) { Object(type: Gtk.WindowType.POPUP); // Window is unmanaged window_position = WindowPosition.CENTER_ALWAYS; + this.wm_name = wm_name; + this.is_wayland = is_wayland; + settings = new GLib.Settings ("org.regolith-linux.ilia"); entry = new Gtk.Entry (); @@ -79,7 +85,7 @@ namespace Ilia { grid.attach (notebook, 0, 1, 1, 1); add (grid); - if (IS_SESSION_WAYLAND) { + if (is_wayland_session) { set_size_request (settings.get_int ("window-width"), settings.get_int ("window-height")); } else { set_default_size (settings.get_int ("window-width"), settings.get_int ("window-height")); @@ -241,31 +247,31 @@ namespace Ilia { switch (focus_page.down ()) { case "apps": dialog_pages[0] = new DesktopAppPage (); - dialog_pages[0].initialize.begin (settings, arg_map, entry, this); + dialog_pages[0].initialize.begin (settings, arg_map, entry, this, this.wm_name, this.is_wayland); break; case "terminal": dialog_pages[0] = new CommandPage (); - dialog_pages[0].initialize.begin (settings, arg_map, entry, this); + dialog_pages[0].initialize.begin (settings, arg_map, entry, this, this.wm_name, this.is_wayland); break; case "notifications": dialog_pages[0] = new RoficationPage (); - dialog_pages[0].initialize.begin (settings, arg_map, entry, this); + dialog_pages[0].initialize.begin (settings, arg_map, entry, this, this.wm_name, this.is_wayland); break; case "keybindings": dialog_pages[0] = new KeybingingsPage (); - dialog_pages[0].initialize.begin (settings, arg_map, entry, this); + dialog_pages[0].initialize.begin (settings, arg_map, entry, this, this.wm_name, this.is_wayland); break; case "textlist": dialog_pages[0] = new TextListPage (); - dialog_pages[0].initialize.begin (settings, arg_map, entry, this); + dialog_pages[0].initialize.begin (settings, arg_map, entry, this, this.wm_name, this.is_wayland); break; case "windows": dialog_pages[0] = new WindowPage (); - dialog_pages[0].initialize.begin (settings, arg_map, entry, this); + dialog_pages[0].initialize.begin (settings, arg_map, entry, this, this.wm_name, this.is_wayland); break; case "tracker": dialog_pages[0] = new TrackerPage (); - dialog_pages[0].initialize.begin (settings, arg_map, entry, this); + dialog_pages[0].initialize.begin (settings, arg_map, entry, this, this.wm_name, this.is_wayland); break; default: stderr.printf ("Unknown page type: %s\n", focus_page); @@ -281,17 +287,17 @@ namespace Ilia { dialog_pages = new DialogPage[page_count]; dialog_pages[0] = new DesktopAppPage (); - dialog_pages[0].initialize.begin (settings, arg_map, entry, this); + dialog_pages[0].initialize.begin (settings, arg_map, entry, this, this.wm_name, this.is_wayland); dialog_pages[1] = new CommandPage (); - dialog_pages[1].initialize.begin (settings, arg_map, entry, this); + dialog_pages[1].initialize.begin (settings, arg_map, entry, this, this.wm_name, this.is_wayland); dialog_pages[2] = new RoficationPage (); - dialog_pages[2].initialize.begin (settings, arg_map, entry, this); + dialog_pages[2].initialize.begin (settings, arg_map, entry, this, this.wm_name, this.is_wayland); dialog_pages[3] = new KeybingingsPage (); - dialog_pages[3].initialize.begin (settings, arg_map, entry, this); + dialog_pages[3].initialize.begin (settings, arg_map, entry, this, this.wm_name, this.is_wayland); dialog_pages[4] = new WindowPage (); - dialog_pages[4].initialize.begin (settings, arg_map, entry, this); + dialog_pages[4].initialize.begin (settings, arg_map, entry, this, this.wm_name, this.is_wayland); dialog_pages[5] = new TrackerPage (); - dialog_pages[5].initialize.begin (settings, arg_map, entry, this); + dialog_pages[5].initialize.begin (settings, arg_map, entry, this, this.wm_name, this.is_wayland); // last page, help, will be initialized later in init switch (focus_page.down ()) { diff --git a/src/Main.vala b/src/Main.vala index cb396f8..e9e931f 100644 --- a/src/Main.vala +++ b/src/Main.vala @@ -1,9 +1,6 @@ using Gtk; using GtkLayerShell; -// Globals -bool IS_SESSION_WAYLAND; -string WM_NAME; // Default style char* default_css = """ .root_box { @@ -37,41 +34,10 @@ char* default_css = """ public static int main (string[] args) { Gtk.Application app = new Ilia.Application (); - // Get session type (wayland or x11) and set the flag - string session_type = Environment.get_variable ("XDG_SESSION_TYPE"); - string gdk_backend = Environment.get_variable ("GDK_BACKEND"); - IS_SESSION_WAYLAND = session_type == "wayland" && gdk_backend != "x11"; - - // Set window manager - string sway_sock = Environment.get_variable ("SWAYSOCK"); - string i3_sock = Environment.get_variable ("I3SOCK"); - - if (sway_sock != null) { - WM_NAME = "sway"; - } else if (i3_sock != null) { - WM_NAME = "i3"; - } else { - WM_NAME = "Unknown"; - } - app.run (args); return 0; } - -/* - Get the location for swaymsg or i3-msg as per the current session type - */ -string? get_wm_cli() { - if(WM_NAME == "i3") { - return "/usr/bin/i3-msg "; - } else if (WM_NAME == "sway") { - return "/usr/bin/swaymsg "; - } - return null; -} - - /* Get AppInfo object used to run a command */ public AppInfo get_runner_app_info (AppInfo app_info) throws GLib.Error { string systemd_run_path = GLib.Environment.find_program_in_path ("systemd-run"); diff --git a/src/DialogPage.vala b/src/ModuleApi.vala similarity index 83% rename from src/DialogPage.vala rename to src/ModuleApi.vala index af6c36c..8553461 100644 --- a/src/DialogPage.vala +++ b/src/ModuleApi.vala @@ -1,4 +1,16 @@ +/** + * Ilia module contracts + */ namespace Ilia { + /** + * Represents actions and state that DialogPage types may access from the active session. + */ + public interface SessionContoller : GLib.Object { + + // Exit the app + public abstract void quit (); + } + /** * A DialogPage represents a filtered, sorted view for the global search entry upon some domain. */ @@ -6,7 +18,7 @@ namespace Ilia { /** * Initialize the page. Create widgets, load model data, etc. */ - public async abstract void initialize (GLib.Settings settings, HashTable arg_map, Gtk.Entry entry, SessionContoller sessionController) throws GLib.Error; + public async abstract void initialize (GLib.Settings settings, HashTable arg_map, Gtk.Entry entry, SessionContoller sessionController, string wm_name, bool is_wayland) throws GLib.Error; /** * Return the root widget of the page diff --git a/src/SessionController.vala b/src/SessionController.vala deleted file mode 100644 index 275fef4..0000000 --- a/src/SessionController.vala +++ /dev/null @@ -1,8 +0,0 @@ -namespace Ilia { - // Represents actions and state that DialogPage types may access from the active session. - public interface SessionContoller : GLib.Object { - - // Exit the app - public abstract void quit (); - } -} \ No newline at end of file diff --git a/src/Util.vala b/src/Util.vala index 41e6563..a7cd701 100644 --- a/src/Util.vala +++ b/src/Util.vala @@ -32,4 +32,16 @@ namespace Ilia { } return false; } + + /* + * Get the location for swaymsg or i3-msg as per the current session type + */ + string? get_wm_cli(string wm_name) { + if (wm_name == "i3") { + return "/usr/bin/i3-msg "; + } else if (wm_name == "sway") { + return "/usr/bin/swaymsg "; + } + return null; + } } \ No newline at end of file diff --git a/src/apps/DesktopAppPage.vala b/src/apps/DesktopAppPage.vala index 0d14e14..c24d75f 100644 --- a/src/apps/DesktopAppPage.vala +++ b/src/apps/DesktopAppPage.vala @@ -70,7 +70,7 @@ namespace Ilia { return keybindings; } - public async void initialize (GLib.Settings settings, HashTable arg_map, Gtk.Entry entry, SessionContoller sessionController) throws GLib.Error { + public async void initialize (GLib.Settings settings, HashTable arg_map, Gtk.Entry entry, SessionContoller sessionController, string wm_name, bool is_wayland) throws GLib.Error { this.settings = settings; this.entry = entry; this.session_controller = sessionController; diff --git a/src/commands/CommandPage.vala b/src/commands/CommandPage.vala index 1291338..9a3dca0 100644 --- a/src/commands/CommandPage.vala +++ b/src/commands/CommandPage.vala @@ -49,7 +49,7 @@ namespace Ilia { return keybindings; } - public async void initialize (GLib.Settings settings, HashTable arg_map, Gtk.Entry entry, SessionContoller sessionController) throws GLib.Error { + public async void initialize (GLib.Settings settings, HashTable arg_map, Gtk.Entry entry, SessionContoller sessionController, string wm_name, bool is_wayland) throws GLib.Error { this.entry = entry; this.session_controller = sessionController; diff --git a/src/keybindings/I3Ipc.vala b/src/keybindings/I3Ipc.vala index 53ff108..ce4d705 100644 --- a/src/keybindings/I3Ipc.vala +++ b/src/keybindings/I3Ipc.vala @@ -169,8 +169,8 @@ namespace Ilia { return baseConfig + walked_configs; } - internal ConfigReply (Json.Node responseJson) throws GLib.FileError { - if (WM_NAME == "sway") { + internal ConfigReply (Json.Node responseJson, string wm_name) throws GLib.FileError { + if (wm_name == "sway") { config = get_sway_config (responseJson); } else { config = get_i3_config (responseJson); @@ -261,8 +261,10 @@ namespace Ilia { private uint8[] terminator = { '\0' }; private int bytes_to_payload = 14; private int buffer_size = 1024 * 128; + private string wm_name; - public IPCClient () throws GLib.Error { + public IPCClient (string wm_name) throws GLib.Error { + this.wm_name = wm_name; var socket_path = Environment.get_variable ("I3SOCK"); var socketAddress = new UnixSocketAddress (socket_path); @@ -280,7 +282,7 @@ namespace Ilia { socket.close (); } catch (GLib.Error err) { // TODO consistent error handling - stderr.printf ("Failed to close %s socket: %s\n", WM_NAME, err.message); + stderr.printf ("Failed to close %s socket: %s\n", wm_name, err.message); } } } @@ -313,12 +315,12 @@ namespace Ilia { private Json.Node ? wm_ipc (WM_COMMAND command) throws GLib.Error { ssize_t sent = socket.send (generate_request (command)); - debug ("Sent " + sent.to_string () + " bytes to " + WM_NAME + ".\n"); + debug ("Sent " + sent.to_string () + " bytes to " + wm_name + ".\n"); uint8[] buffer = new uint8[buffer_size]; ssize_t len = socket.receive (buffer); - debug ("Received " + len.to_string () + " bytes from " + WM_NAME + ".\n"); + debug ("Received " + len.to_string () + " bytes from " + wm_name + ".\n"); Bytes responseBytes = new Bytes.take (buffer[0 : len]); @@ -347,7 +349,7 @@ namespace Ilia { throw new WM_ERROR.RPC_ERROR ("No Response"); } - return new ConfigReply (response); + return new ConfigReply (response, this.wm_name); } public TreeReply getTree () throws WM_ERROR, GLib.Error { diff --git a/src/keybindings/KeybindingsPage.vala b/src/keybindings/KeybindingsPage.vala index 218fdcc..9770bc1 100644 --- a/src/keybindings/KeybindingsPage.vala +++ b/src/keybindings/KeybindingsPage.vala @@ -25,6 +25,8 @@ namespace Ilia { private Gtk.TreePath path; + private string wm_name; + public string get_name () { return "Keybindings"; } @@ -49,9 +51,10 @@ namespace Ilia { return keybindings; } - public async void initialize (GLib.Settings settings, HashTable arg_map, Gtk.Entry entry, SessionContoller sessionController) { + public async void initialize (GLib.Settings settings, HashTable arg_map, Gtk.Entry entry, SessionContoller sessionController, string wm_name, bool is_wayland) { this.entry = entry; this.session_controller = sessionController; + this.wm_name = wm_name; model = new Gtk.ListStore (ITEM_VIEW_COLUMNS, typeof (string), typeof (string), typeof (string)); @@ -164,7 +167,7 @@ namespace Ilia { // Read the active configuration and populate the model with keybindings private async void read_config () { try { - var ipc_client = new IPCClient (); + var ipc_client = new IPCClient (this.wm_name); var config_file = ipc_client.getConfig ().config; var parser = new ConfigParser (config_file, ""); @@ -188,7 +191,7 @@ namespace Ilia { } } catch (GLib.Error err) { // TODO consistent error handling - stderr.printf ("Failed to read config from %s: %s\n", WM_NAME, err.message); + stderr.printf ("Failed to read config from %s: %s\n", this.wm_name, err.message); } } @@ -228,7 +231,7 @@ namespace Ilia { } private void execute_keybinding (string exec) { - string cli_bin = get_wm_cli(); + string cli_bin = get_wm_cli(this.wm_name); if(cli_bin == null) { stderr.printf ("Error: execute_keybinding failed - Action not supported for your WM"); diff --git a/src/meson.build b/src/meson.build index 574ac6f..14b0fc3 100644 --- a/src/meson.build +++ b/src/meson.build @@ -28,12 +28,11 @@ ilia_deps += [pango_dep] ilia_deps += [x11_dep] ilia_deps += [gtk_layer_shell_dep] ilia_sources = [cfgfile_1] -ilia_sources += ['DialogPage.vala'] +ilia_sources += ['ModuleApi.vala'] ilia_sources += ['DialogWindow.vala'] ilia_sources += ['Application.vala'] ilia_sources += ['Main.vala'] ilia_sources += ['IconLoader.vala'] -ilia_sources += ['SessionController.vala'] ilia_sources += ['Util.vala'] ilia_sources += ['apps/DesktopAppPage.vala'] ilia_sources += ['commands/CommandPage.vala'] diff --git a/src/notifications/RoficationPage.vala b/src/notifications/RoficationPage.vala index a619e35..44b8862 100644 --- a/src/notifications/RoficationPage.vala +++ b/src/notifications/RoficationPage.vala @@ -61,7 +61,7 @@ namespace Ilia { return keybindings; } - public async void initialize (GLib.Settings settings, HashTable arg_map, Gtk.Entry entry, SessionContoller sessionController) throws GLib.Error { + public async void initialize (GLib.Settings settings, HashTable arg_map, Gtk.Entry entry, SessionContoller sessionController, string wm_name, bool is_wayland) throws GLib.Error { this.entry = entry; this.session_controller = sessionController; this.icon_size = settings.get_int ("icon-size"); diff --git a/src/textlist/TextListPage.vala b/src/textlist/TextListPage.vala index 48b0b74..4f7c789 100644 --- a/src/textlist/TextListPage.vala +++ b/src/textlist/TextListPage.vala @@ -60,7 +60,7 @@ namespace Ilia { item_view.grab_focus (); } - public async void initialize (GLib.Settings settings, HashTable arg_map, Gtk.Entry entry, SessionContoller sessionController) throws GLib.Error { + public async void initialize (GLib.Settings settings, HashTable arg_map, Gtk.Entry entry, SessionContoller sessionController, string wm_name, bool is_wayland) throws GLib.Error { this.entry = entry; this.session_controller = sessionController; diff --git a/src/tracker/TrackerPage.vala b/src/tracker/TrackerPage.vala index f415c4b..cdd59a6 100644 --- a/src/tracker/TrackerPage.vala +++ b/src/tracker/TrackerPage.vala @@ -66,7 +66,7 @@ namespace Ilia { item_view.grab_focus (); } - public async void initialize (GLib.Settings settings, HashTable arg_map, Gtk.Entry entry, SessionContoller sessionController) throws GLib.Error { + public async void initialize (GLib.Settings settings, HashTable arg_map, Gtk.Entry entry, SessionContoller sessionController, string wm_name, bool is_wayland) throws GLib.Error { this.entry = entry; this.session_controller = sessionController; diff --git a/src/windows/WindowPage.vala b/src/windows/WindowPage.vala index 1e860b1..91382aa 100644 --- a/src/windows/WindowPage.vala +++ b/src/windows/WindowPage.vala @@ -28,6 +28,10 @@ namespace Ilia { private Gtk.TreePath path; + private string wm_name; + + private bool is_wayland; + public string get_name () { return "Windows"; } @@ -52,9 +56,11 @@ namespace Ilia { return keybindings; } - public async void initialize (GLib.Settings settings, HashTable arg_map, Gtk.Entry entry, SessionContoller sessionController) throws GLib.Error { + public async void initialize (GLib.Settings settings, HashTable arg_map, Gtk.Entry entry, SessionContoller sessionController, string wm_name, bool is_wayland) throws GLib.Error { this.entry = entry; this.session_controller = sessionController; + this.wm_name = wm_name; + this.is_wayland = is_wayland; icon_size = settings.get_int ("icon-size"); @@ -161,7 +167,7 @@ namespace Ilia { private void load_windows () { try { - var ipc_client = new IPCClient (); + var ipc_client = new IPCClient (this.wm_name); var node = ipc_client.getTree (); if (node != null) { @@ -170,7 +176,7 @@ namespace Ilia { } } catch (GLib.Error err) { // TODO consistent error handling - stderr.printf ("Failed to read or parse window tree from %s: %s\n", WM_NAME, err.message); + stderr.printf ("Failed to read or parse window tree from %s: %s\n", this.wm_name, err.message); } } @@ -210,7 +216,7 @@ namespace Ilia { bool rv = (node.ntype == "con" || node.ntype == "floating_con") // specifies actual windows && (node.window_type == "normal" || node.window_type == "unknown" - || IS_SESSION_WAYLAND && node.layout == "none") // window type + || is_wayland && node.layout == "none") // window type && node.windowProperties.clazz != "i3bar"; // ignore i3bar return rv; @@ -246,7 +252,7 @@ namespace Ilia { // [window_role="gnome-terminal-window-6bee2ec0-eb8b-4b10-aafc-7c2708201d43" title="Terminal"] focus private void focus_window (string id) { string exec = "[con_id=\"" + id + "\"] focus"; - string cli_bin = get_wm_cli(); + string cli_bin = get_wm_cli(this.wm_name); if (cli_bin == null) { stderr.printf("Error: Cannot focus window - action not supported for your WM.\n"); From 15f0809117ac0c11b2820bc3edb31a72f1eb2bb1 Mon Sep 17 00:00:00 2001 From: Regolith Linux Date: Mon, 29 Jul 2024 19:04:36 -0700 Subject: [PATCH 3/4] fix: util functions are pub static --- src/Util.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Util.vala b/src/Util.vala index a7cd701..7f8c070 100644 --- a/src/Util.vala +++ b/src/Util.vala @@ -36,7 +36,7 @@ namespace Ilia { /* * Get the location for swaymsg or i3-msg as per the current session type */ - string? get_wm_cli(string wm_name) { + public static string? get_wm_cli(string wm_name) { if (wm_name == "i3") { return "/usr/bin/i3-msg "; } else if (wm_name == "sway") { From c5bee484ad18a16ce23507a90b8d17450dfbe538 Mon Sep 17 00:00:00 2001 From: Regolith Linux Date: Sat, 7 Sep 2024 13:16:23 -0700 Subject: [PATCH 4/4] fix: member var set typo --- src/DialogWindow.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DialogWindow.vala b/src/DialogWindow.vala index 91c5f93..a433e09 100644 --- a/src/DialogWindow.vala +++ b/src/DialogWindow.vala @@ -56,7 +56,7 @@ namespace Ilia { window_position = WindowPosition.CENTER_ALWAYS; this.wm_name = wm_name; - this.is_wayland = is_wayland; + this.is_wayland = is_wayland_session; settings = new GLib.Settings ("org.regolith-linux.ilia");