-
-
Notifications
You must be signed in to change notification settings - Fork 24
Feature: window minimisation #420
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
base: main
Are you sure you want to change the base?
Changes from 12 commits
0c9832d
65062c4
3d7bad0
616767d
5786a8a
641ef7a
4d79958
c2fdf27
e768db2
2a7d4cf
e0b1e9a
a842d94
749d1c7
d863624
de4b69b
c19693e
0dd548a
6b2e760
7fc65dc
de32422
33acbf1
1b89758
7a6cc1d
8fc71b1
5a67b22
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -151,6 +151,33 @@ async fn config() { | |
| .group("Window") | ||
| .description("Toggle maximized on the focused window"); | ||
|
|
||
| // `mod_key + n` makes minimized | ||
| input::keybind(mod_key, 'n') | ||
| .on_press(|| { | ||
| if let Some(window) = window::get_focused() { | ||
| window.set_minimized(true); | ||
| } | ||
|
sapient-cogbag marked this conversation as resolved.
|
||
| }) | ||
| .group("Window") | ||
| .description("Minimize the focused window"); | ||
|
|
||
| // `mon_key + shift + n` unminimises the "most recently focused" | ||
| // minimised window that is on the active tags in this current output. | ||
| input::keybind(mod_key | Mod::SHIFT, 'n') | ||
| .on_press(|| { | ||
| let Some(output) = output::get_focused() else { return }; | ||
| let Some(most_recently_minimised_active_window) = output | ||
| .keyboard_focus_stack_visible() | ||
| .filter(|w| w.minimized()) | ||
| .last() | ||
|
Comment on lines
+170
to
+172
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note on recent modification: The name of the API function "keyboard_focus_stack_visible" seems misleading now that minimised windows are a thing >.<
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm guess we can deprecate it and add a renamed function
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some sort of change seems to have made minimized windows not show up in it anyway (as they now lack a location), which makes more sense for the name anyway IMO (as they're not visible :p). But this also breaks the focus stack as a more general tool since it filters out windows by location down in the element check and minimization deletes that for some reason. Or at the very least the minimized windows don't get listed for their associated outputs and I think it's for that reason based on some testing >.<... |
||
| else { | ||
| return; | ||
| }; | ||
| most_recently_minimised_active_window.set_minimized(false); | ||
| }) | ||
| .group("Window") | ||
| .description("Unminimize the most recently focused window on the active tags"); | ||
|
|
||
| // Media keybinds ------------------------------------------------------ | ||
|
|
||
| input::keybind(Mod::empty(), Keysym::XF86_AudioRaiseVolume) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,15 +12,15 @@ use pinnacle_api_defs::pinnacle::{ | |
| self, CloseRequest, GetAppIdRequest, GetAppIdResponse, GetFocusedRequest, | ||
| GetFocusedResponse, GetForeignToplevelListIdentifierRequest, | ||
| GetForeignToplevelListIdentifierResponse, GetLayoutModeRequest, GetLayoutModeResponse, | ||
| GetLocRequest, GetLocResponse, GetRequest, GetResponse, GetSizeRequest, | ||
| GetSizeResponse, GetTagIdsRequest, GetTagIdsResponse, GetTitleRequest, | ||
| GetTitleResponse, GetWindowsInDirRequest, GetWindowsInDirResponse, LowerRequest, | ||
| LowerResponse, MoveGrabRequest, MoveToOutputRequest, MoveToOutputResponse, | ||
| MoveToTagRequest, RaiseRequest, ResizeGrabRequest, ResizeTileRequest, | ||
| SetDecorationModeRequest, SetFloatingRequest, SetFocusedRequest, SetFullscreenRequest, | ||
| SetGeometryRequest, SetMaximizedRequest, SetTagRequest, SetTagsRequest, | ||
| SetTagsResponse, SetVrrDemandRequest, SetVrrDemandResponse, SwapRequest, SwapResponse, | ||
| WindowRuleRequest, WindowRuleResponse, | ||
| GetLocRequest, GetLocResponse, GetMinimizedRequest, GetMinimizedResponse, GetRequest, | ||
| GetResponse, GetSizeRequest, GetSizeResponse, GetTagIdsRequest, GetTagIdsResponse, | ||
| GetTitleRequest, GetTitleResponse, GetWindowsInDirRequest, GetWindowsInDirResponse, | ||
| LowerRequest, LowerResponse, MoveGrabRequest, MoveToOutputRequest, | ||
| MoveToOutputResponse, MoveToTagRequest, RaiseRequest, ResizeGrabRequest, | ||
| ResizeTileRequest, SetDecorationModeRequest, SetFloatingRequest, SetFocusedRequest, | ||
| SetFullscreenRequest, SetGeometryRequest, SetMaximizedRequest, SetMinimizedRequest, | ||
| SetTagRequest, SetTagsRequest, SetTagsResponse, SetVrrDemandRequest, | ||
| SetVrrDemandResponse, SwapRequest, SwapResponse, WindowRuleRequest, WindowRuleResponse, | ||
| }, | ||
| }, | ||
| }; | ||
|
|
@@ -194,6 +194,27 @@ impl v1::window_service_server::WindowService for super::WindowService { | |
| .await | ||
| } | ||
|
|
||
| async fn get_minimized( | ||
| &self, | ||
| request: Request<GetMinimizedRequest>, | ||
| ) -> TonicResult<GetMinimizedResponse> { | ||
| let window_id = WindowId(request.into_inner().window_id); | ||
|
|
||
| run_unary(&self.sender, move |state| { | ||
| let minimized = window_id | ||
| .window(&state.pinnacle) | ||
| .or_else(|| { | ||
| window_id | ||
| .unmapped_window(&state.pinnacle) | ||
| .map(|unmapped| unmapped.window.clone()) | ||
| }) | ||
| .map(|win| win.with_state(|state| state.minimized)) | ||
| .unwrap_or(false); | ||
| Ok(GetMinimizedResponse { minimized }) | ||
| }) | ||
| .await | ||
| } | ||
|
|
||
| async fn get_tag_ids( | ||
| &self, | ||
| request: Request<GetTagIdsRequest>, | ||
|
|
@@ -479,6 +500,31 @@ impl v1::window_service_server::WindowService for super::WindowService { | |
| .await | ||
| } | ||
|
|
||
| async fn set_minimized(&self, request: Request<SetMinimizedRequest>) -> TonicResult<()> { | ||
| let request = request.into_inner(); | ||
| let window_id = WindowId(request.window_id); | ||
| let absolute_minimized = match request.set_or_toggle() { | ||
| SetOrToggle::Unspecified => { | ||
| return Err(Status::invalid_argument("unspecified set or toggle")); | ||
| } | ||
| SetOrToggle::Set => Some(true), | ||
| SetOrToggle::Unset => Some(false), | ||
| SetOrToggle::Toggle => None, | ||
| }; | ||
|
|
||
| run_unary_no_response(&self.sender, move |state| { | ||
| if let Some(window) = window_id.window(&state.pinnacle) { | ||
| crate::api::window::set_minimized(state, &window, absolute_minimized); | ||
| } else if let Some(unmapped) = window_id.unmapped_window_mut(&mut state.pinnacle) | ||
| && let UnmappedState::WaitingForRules { rules: _, .. } = &mut unmapped.state | ||
| { | ||
| // TODO: find a way to immediately minimize a window upon mapping. | ||
| warn!("minimizing unmapped windows not yet supported"); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It does seem to, with my preliminary testing. However during testing I discovered that getting the focus stack of active tags no longer includes minimised windows, since they seem to lose their location value (which makes sense, but I'm not certain what exactly to do about it). During testing I made a custom config that retrieved all windows then filtered them for windows on the focused output and also minimization, but it is less convenient (but still doable if you combined it with some sort of active tag filter). |
||
| } | ||
| }) | ||
| .await | ||
| } | ||
|
|
||
| async fn set_floating(&self, request: Request<SetFloatingRequest>) -> TonicResult<()> { | ||
| let request = request.into_inner(); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.