Skip to content

Commit

Permalink
fix: improve fullscreen detection with no outer gaps
Browse files Browse the repository at this point in the history
  • Loading branch information
lars-berger committed Aug 5, 2024
1 parent 25c6071 commit 5d52d12
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
21 changes: 9 additions & 12 deletions packages/wm/src/common/events/handle_window_location_changed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,16 @@ pub fn handle_window_location_changed(
)?;
}

match window.state() {
WindowState::Fullscreen(fullscreen_state) => {
let monitor_rect = if config.has_outer_gaps() {
nearest_monitor.native().working_rect()?.clone()
} else {
nearest_monitor.to_rect()?
};
let monitor_rect = if config.has_outer_gaps() {
nearest_monitor.native().working_rect()?.clone()
} else {
nearest_monitor.to_rect()?
};

let is_fullscreen =
window.native().is_fullscreen(&monitor_rect)?;
let is_fullscreen = window.native().is_fullscreen(&monitor_rect)?;

match window.state() {
WindowState::Fullscreen(fullscreen_state) => {
// A fullscreen window that gets minimized can hit this arm, so
// ignore such events and let it be handled by the handler for
// `PlatformEvent::WindowMinimized` instead.
Expand Down Expand Up @@ -93,9 +92,7 @@ pub fn handle_window_location_changed(
// Update the window to be fullscreen if there's been a change in
// maximized state or if the window is now fullscreen.
if (is_maximized && old_is_maximized != is_maximized)
|| window
.native()
.is_fullscreen(nearest_monitor.native().working_rect()?)?
|| is_fullscreen
{
info!("Window fullscreened");

Expand Down
10 changes: 6 additions & 4 deletions packages/wm/src/user_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,12 @@ impl UserConfig {

pub fn has_outer_gaps(&self) -> bool {
let outer_gap = &self.value.gaps.outer_gap;
outer_gap.bottom.amount > 0.0
|| outer_gap.left.amount > 0.0
|| outer_gap.right.amount > 0.0
|| outer_gap.top.amount > 0.0

// Allow for 1px/1% of leeway.
outer_gap.bottom.amount > 1.0
|| outer_gap.left.amount > 1.0
|| outer_gap.right.amount > 1.0
|| outer_gap.top.amount > 1.0
}
}

Expand Down

0 comments on commit 5d52d12

Please sign in to comment.