Skip to content

Commit

Permalink
fix: update Wayland maximize process condition
Browse files Browse the repository at this point in the history
  • Loading branch information
Zamoca42 committed Sep 26, 2024
1 parent 4fca9b1 commit baa6877
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/platform_impl/linux/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ impl<T: 'static> EventLoop<T> {
WindowRequest::Maximized(maximized, resizable) => {
if maximized {
let maximize_process =
util::WindowMaximizeProcess::new(window.clone(), maximized, resizable);
util::WindowMaximizeProcess::new(window.clone(), resizable);
glib::idle_add_local_full(glib::Priority::DEFAULT_IDLE, move || {
let mut maximize_process = maximize_process.borrow_mut();
maximize_process.next_step()
Expand Down
16 changes: 4 additions & 12 deletions src/platform_impl/linux/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,14 @@ pub fn set_size_constraints<W: GtkWindowExt + WidgetExt>(

pub struct WindowMaximizeProcess<W: GtkWindowExt + WidgetExt> {
window: W,
maximized: bool,
resizable: bool,
step: u8,
}

impl<W: GtkWindowExt + WidgetExt> WindowMaximizeProcess<W> {
pub fn new(window: W, maximized: bool, resizable: bool) -> Rc<RefCell<Self>> {
pub fn new(window: W, resizable: bool) -> Rc<RefCell<Self>> {
Rc::new(RefCell::new(Self {
window,
maximized,
resizable,
step: 0,
}))
Expand All @@ -95,15 +93,9 @@ impl<W: GtkWindowExt + WidgetExt> WindowMaximizeProcess<W> {
pub fn next_step(&mut self) -> glib::ControlFlow {
match self.step {
0 => {
if self.maximized {
self.window.set_resizable(true);
self.step += 1;
glib::ControlFlow::Continue
} else {
//It should still revert to the previous resizable state.
self.step = 2;
glib::ControlFlow::Continue
}
self.window.set_resizable(true);
self.step += 1;
glib::ControlFlow::Continue
}
1 => {
self.window.maximize();
Expand Down
1 change: 0 additions & 1 deletion src/platform_impl/linux/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ impl Window {
if attributes.maximized {
let maximize_process = util::WindowMaximizeProcess::new(
window.clone(),
attributes.maximized,
attributes.resizable,
);
glib::idle_add_local_full(glib::Priority::HIGH_IDLE, move || {
Expand Down

0 comments on commit baa6877

Please sign in to comment.