Support fullscreen for new windows
Browse files at this commit798d9c55dfaae46ab09e9176f5c3dd8fa21f478aParent: 05613ee2 changed files +29 -2
- src/handlers/xdg_shell.rs +14 -0
- src/layout/workspace.rs +15 -2
src/handlers/xdg_shell.rsmodified+14 -0
| @@ -230,6 +230,13 @@ impl XdgShellHandler for State { | |||
| 230 | } | 230 | } |
| 231 | 231 | ||
| 232 | self.niri.layout.set_fullscreen(&window, true); | 232 | self.niri.layout.set_fullscreen(&window, true); |
| 233 | + } else if let Some(window) = self.niri.unmapped_windows.get(surface.wl_surface()) { | ||
| 234 | + if let Some(ws) = self.niri.layout.active_workspace() { | ||
| 235 | + window.toplevel().with_pending_state(|state| { | ||
| 236 | + state.size = Some(ws.view_size()); | ||
| 237 | + state.states.set(xdg_toplevel::State::Fullscreen); | ||
| 238 | + }); | ||
| 239 | + } | ||
| 233 | } | 240 | } |
| 234 | } | 241 | } |
| 235 | 242 | ||
| @@ -246,6 +253,13 @@ impl XdgShellHandler for State { | |||
| 246 | { | 253 | { |
| 247 | let window = window.clone(); | 254 | let window = window.clone(); |
| 248 | self.niri.layout.set_fullscreen(&window, false); | 255 | self.niri.layout.set_fullscreen(&window, false); |
| 256 | + } else if let Some(window) = self.niri.unmapped_windows.get(surface.wl_surface()) { | ||
| 257 | + if let Some(ws) = self.niri.layout.active_workspace() { | ||
| 258 | + window.toplevel().with_pending_state(|state| { | ||
| 259 | + state.size = Some(ws.new_window_size()); | ||
| 260 | + state.states.unset(xdg_toplevel::State::Fullscreen); | ||
| 261 | + }); | ||
| 262 | + } | ||
| 249 | } | 263 | } |
| 250 | } | 264 | } |
| 251 | 265 | ||
src/layout/workspace.rsmodified+15 -2
| @@ -330,6 +330,10 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 330 | } | 330 | } |
| 331 | } | 331 | } |
| 332 | 332 | ||
| 333 | + pub fn view_size(&self) -> Size<i32, Logical> { | ||
| 334 | + self.view_size | ||
| 335 | + } | ||
| 336 | + | ||
| 333 | pub fn update_output_scale_transform(&mut self) { | 337 | pub fn update_output_scale_transform(&mut self) { |
| 334 | let Some(output) = self.output.as_ref() else { | 338 | let Some(output) = self.output.as_ref() else { |
| 335 | return; | 339 | return; |
| @@ -351,7 +355,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 351 | )) | 355 | )) |
| 352 | } | 356 | } |
| 353 | 357 | ||
| 354 | - pub fn configure_new_window(&self, window: &Window) { | 358 | + pub fn new_window_size(&self) -> Size<i32, Logical> { |
| 355 | let width = if let Some(width) = self.options.default_width { | 359 | let width = if let Some(width) = self.options.default_width { |
| 356 | let mut width = width.resolve(&self.options, self.working_area.size.w); | 360 | let mut width = width.resolve(&self.options, self.working_area.size.w); |
| 357 | if !self.options.border.off { | 361 | if !self.options.border.off { |
| @@ -367,8 +371,11 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 367 | height -= self.options.border.width as i32 * 2; | 371 | height -= self.options.border.width as i32 * 2; |
| 368 | } | 372 | } |
| 369 | 373 | ||
| 370 | - let size = Size::from((width, max(height, 1))); | 374 | + Size::from((width, max(height, 1))) |
| 375 | + } | ||
| 371 | 376 | ||
| 377 | + pub fn configure_new_window(&self, window: &Window) { | ||
| 378 | + let size = self.new_window_size(); | ||
| 372 | let bounds = self.toplevel_bounds(); | 379 | let bounds = self.toplevel_bounds(); |
| 373 | 380 | ||
| 374 | if let Some(output) = self.output.as_ref() { | 381 | if let Some(output) = self.output.as_ref() { |
| @@ -1151,8 +1158,14 @@ impl<W: LayoutElement> Column<W> { | |||
| 1151 | options, | 1158 | options, |
| 1152 | }; | 1159 | }; |
| 1153 | 1160 | ||
| 1161 | + let is_pending_fullscreen = window.is_pending_fullscreen(); | ||
| 1162 | + | ||
| 1154 | rv.add_window(window); | 1163 | rv.add_window(window); |
| 1155 | 1164 | ||
| 1165 | + if is_pending_fullscreen { | ||
| 1166 | + rv.set_fullscreen(true); | ||
| 1167 | + } | ||
| 1168 | + | ||
| 1156 | rv | 1169 | rv |
| 1157 | } | 1170 | } |
| 1158 | 1171 | ||