-
-
Notifications
You must be signed in to change notification settings - Fork 578
Add windows' fullscreen states to ipc #2836
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 all commits
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 |
|---|---|---|
|
|
@@ -32,7 +32,7 @@ use smithay::wayland::shell::wlr_layer::{KeyboardInteractivity, Layer}; | |
|
|
||
| use crate::backend::IpcOutputMap; | ||
| use crate::input::pick_window_grab::PickWindowGrab; | ||
| use crate::layout::workspace::WorkspaceId; | ||
| use crate::layout::{workspace::WorkspaceId, LayoutElement}; | ||
| use crate::niri::State; | ||
| use crate::utils::{version, with_toplevel_role}; | ||
| use crate::window::Mapped; | ||
|
|
@@ -504,6 +504,9 @@ fn make_ipc_window( | |
| workspace_id: Option<WorkspaceId>, | ||
| layout: WindowLayout, | ||
| ) -> niri_ipc::Window { | ||
| // Quick hack to fix the consistent halting if we tried to access the sizing mode | ||
| // inside the constructor | ||
| let fullscreen_state = mapped.sizing_mode().into(); | ||
|
Comment on lines
+507
to
+509
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. Will the "quick hack" stay? Usually a hack is not really a good thing for a project, although I don't have insight if this is avoidable or not
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. well, it's not a hack per se. the 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. Hmmm... It's not necessary for any of the other values. That looks weird to me, but perhaps I'm just not knowledgeable enough regarding the code |
||
| with_toplevel_role(mapped.toplevel(), |role| niri_ipc::Window { | ||
| id: mapped.id().get(), | ||
| title: role.title.clone(), | ||
|
|
@@ -512,6 +515,7 @@ fn make_ipc_window( | |
| workspace_id: workspace_id.map(|id| id.get()), | ||
| is_focused: mapped.is_focused(), | ||
| is_floating: mapped.is_floating(), | ||
| fullscreen_state, | ||
| is_urgent: mapped.is_urgent(), | ||
| layout, | ||
| focus_timestamp: mapped.get_focus_timestamp().map(Timestamp::from), | ||
|
|
@@ -726,6 +730,13 @@ impl State { | |
| events.push(Event::WindowFocusChanged { id: Some(id) }); | ||
| } | ||
|
|
||
| if mapped.sizing_mode() != ipc_win.fullscreen_state.into() { | ||
| events.push(Event::WindowFullscreenStateChanged { | ||
| id, | ||
| fullscreen_state: mapped.sizing_mode().into(), | ||
| }); | ||
| } | ||
|
|
||
| let focus_timestamp = mapped.get_focus_timestamp().map(Timestamp::from); | ||
| if focus_timestamp != ipc_win.focus_timestamp { | ||
| events.push(Event::WindowFocusTimestampChanged { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -526,6 +526,27 @@ impl SizingMode { | |
| } | ||
| } | ||
|
|
||
| impl From<u8> for SizingMode { | ||
| fn from(value: u8) -> Self { | ||
| match value { | ||
| 0 => Self::Normal, | ||
| 1 => Self::Maximized, | ||
| 2 => Self::Fullscreen, | ||
| _ => Self::Normal, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl From<SizingMode> for u8 { | ||
| fn from(value: SizingMode) -> Self { | ||
| match value { | ||
| SizingMode::Normal => 0, | ||
| SizingMode::Maximized => 1, | ||
| SizingMode::Fullscreen => 2, | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
Comment on lines
+529
to
+549
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. Instead of this, the SizingMode could instead be a unit only enum, which saves on these functions, and goes hand in hand with the idea I proposed to change it to sizing_mode instead of fullscreen_state |
||
| impl<W: LayoutElement> InteractiveMoveState<W> { | ||
| fn moving(&self) -> Option<&InteractiveMoveData<W>> { | ||
| match self { | ||
|
|
||
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.
Have you considered using
sizing_mode: SizingModeinstead? This could get rid of one translation (fullscreen_state -> sizing_mode), which can help with general reasoning about this code. Would also save on the comments above. Something likeThis would of course go with changes in the rest of the PR, but if there is no good reason to do the sizing_mode -> fullscreen_state translation, this would help with the mental indirection, and make things more obvious, which is always good in a large (or any) code base.
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.
Yeah, i actually considered this when creating the pr, but i instead decided to follow Hyprland's implementation.
I agree, this would also eliminate some useless conversions between
u8andSizingModethat only gets used once.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.
Small issue is that
SizingModeis defined inside theniricrate and is therefore inaccessable insideniri_ipc. it's possible to move the definition and implementations fromniritoniri_ipc, but this would be a breaking change and it's just stupid to refactor the entire project for a single featture.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.
Flexing my missing rust knowledge - could you serialzie the SizingMode as is? Who cares if it comes out as a lil string or number. But idk how rust is about this stuff