Skip to content
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

wish: highlight current window #11

Closed
markstos opened this issue Oct 26, 2023 · 2 comments · Fixed by #14
Closed

wish: highlight current window #11

markstos opened this issue Oct 26, 2023 · 2 comments · Fixed by #14

Comments

@markstos
Copy link
Contributor

It would be a nice enhancement if the currently focused window was visually noted during the overlay.

For example, usually white letters are shown on a black square. Perhaps for the currently focused window, black letters on a white square could be used.

@markstos
Copy link
Contributor Author

I believe this is the right code to a new CSS class to the focused window. However, I'm not having any luck targeting the CSS class to get it to display differently:

diff --git a/src/ui.rs b/src/ui.rs
index 771d94e..d15948e 100644
--- a/src/ui.rs
+++ b/src/ui.rs
@@ -80,6 +80,11 @@ fn build_ui(app: &Application, args: Arc<Args>, conn: Arc<Mutex<Connection>>) {
         // TODO: make this work for workspaces with more than 26 windows
         label.set_markup(&format!("{}", ('a' as usize + idx % 26) as u8 as char));
         fixed.put(&label, x, y);
+
+        // Apply a CSS class to the focused window so it can be stylced differently
+        if window.focused {
+            fixed.set_widget_name("focused");
+        }
     }
 
     window.add(&fixed);

@edzdez edzdez linked a pull request Oct 26, 2023 that will close this issue
@edzdez
Copy link
Owner

edzdez commented Oct 26, 2023

Thanks @markstos! You were very close; after taking a quick look at the gtkrs docs, I tried widget.style_context().add_class(class);, which seems to have worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants