-
-
Notifications
You must be signed in to change notification settings - Fork 188
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
add option to not move cursor when focussing a window via ipc #1094
base: main
Are you sure you want to change the base?
Conversation
@@ -765,6 +765,13 @@ impl State { | |||
self.niri.queue_redraw_all(); | |||
} | |||
|
|||
/// Focus a specific window without moving the cursor. | |||
pub fn focus_window_without_moving_cursor(&mut self, window: &Window) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe instead a bool argument to focus_window()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, I just thought maybe there's more and more arguments coming and it's better to just duplicate since I didn't know what to do with the maybe warp cursor. I guess not moving cursor should override warp to focus but I wasnt sure.
niri-ipc/src/lib.rs
Outdated
/// Dont move the cursor when focussing the window. | ||
#[cfg_attr(feature = "clap", arg(long = "dont-move-cursor", action = clap::ArgAction::SetFalse))] | ||
move_cursor: bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking to make it something like no_mouse_warp: bool
(especially since it's "warp mouse to focus" in the config).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I just thought maybe the negation in the argument is confusing, since we then have a no_mouse_warp that is by default false.
niri-config/src/lib.rs
Outdated
@@ -1322,7 +1322,7 @@ pub enum Action { | |||
#[knuffel(skip)] | |||
FullscreenWindowById(u64), | |||
#[knuffel(skip)] | |||
FocusWindow(u64), | |||
FocusWindow(u64, bool), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change it to named fields please { id: u64, ... }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/input/mod.rs
Outdated
@@ -674,11 +674,15 @@ impl State { | |||
self.niri.queue_redraw_all(); | |||
} | |||
} | |||
Action::FocusWindow(id) => { | |||
Action::FocusWindow(id, move_cursor) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you also want to add it to FocusWorkspace, FocusWorkspaceDown, FocusWorkspaceUp? Same argument and works the same way. Others were asking for these
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, but I had a problem. I didn't manage to do the focus workspace the same as the others cause it had the #[knuffel(argument)] WorkspaceReference
in it.
956b484
to
d6e7203
Compare
git didn't do what I wanted... |
c1a4697
to
45832ce
Compare
niri-config/src/lib.rs
Outdated
FocusWorkspaceDown, | ||
FocusWorkspaceUp, | ||
FocusWorkspace(#[knuffel(argument)] WorkspaceReference), | ||
#[knuffel(skip)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They shouldn't be skipped, otherwise you cannot put them in the config.
niri-ipc/src/lib.rs
Outdated
@@ -214,6 +214,9 @@ pub enum Action { | |||
/// Id of the window to focus. | |||
#[cfg_attr(feature = "clap", arg(long))] | |||
id: u64, | |||
/// Dont move the cursor when focussing the window. | |||
#[cfg_attr(feature = "clap", arg(long = "no_mouse_warp", action = clap::ArgAction::SetTrue))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why spell out the name in long = "no_mouse_warp"
? Also, is SetTrue
needed even for bools?
niri-ipc/src/lib.rs
Outdated
@@ -214,6 +214,9 @@ pub enum Action { | |||
/// Id of the window to focus. | |||
#[cfg_attr(feature = "clap", arg(long))] | |||
id: u64, | |||
/// Dont move the cursor when focussing the window. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Dont move the cursor when focussing the window. | |
/// Disable moving the cursor to the newly focused window or output. |
Same change in other places
@YaLTeR sorry I am super stuck. The reason I commented out the needed knuffel thing is because I wanted to change it to a named struct so there are no weird bools flying around. It seems I have to implement something for the knuffle derive to work but I don't have any clue how to do it. Sorry I am new to the macro stuff. Maybe I am on a completely wrong track. |
No, you should be able to just skip the field itself (rather than the whole enum variant). |
45832ce
to
e1523e8
Compare
e1523e8
to
6315557
Compare
Hi, I added a flag for not moving the cursor when focussing a window via ipc. Seems like I was the only one interested in that, but it was a personal pet peeve of mine.
#935
Thanks for the amazing compositor.