From ec6e124658dc887a56cccbcb3aa09876a0bef8bf Mon Sep 17 00:00:00 2001 From: Lam Wei Lun Date: Mon, 23 Nov 2026 08:14:35 +0800 Subject: [PATCH] Fix main window opening fullscreen instead of maximized on X11 (#17585) Restore a maximized main window without resizing it on X11 Mutter/Muffin turn a client resize of an undecorated window to exactly the monitor rect into a fullscreen window, so the main frame came up fullscreen instead of maximized when the panel reserved no strut (#17191). On X11, skip SetSize when the saved state is maximized and skip window_pos_sanitize for maximized or fullscreen windows. Windows and macOS keep the resize, which sets the normal size Restore Down returns to. persist_window_geometry also ignored the window name and stored the non-modal settings dialog under window_mainframe. Use the window's own name. --- .../orca-wxwidgets/references/platforms.md | 8 +++++ .../references/windows-dialogs.md | 14 +++++---- src/slic3r/GUI/GUI_App.cpp | 29 ++++++++++++++----- 3 files changed, 38 insertions(+), 13 deletions(-) diff --git a/.claude/skills/orca-wxwidgets/references/platforms.md b/.claude/skills/orca-wxwidgets/references/platforms.md index 85c9fb505b..e2bdd2b9a8 100644 --- a/.claude/skills/orca-wxwidgets/references/platforms.md +++ b/.claude/skills/orca-wxwidgets/references/platforms.md @@ -771,6 +771,14 @@ required by other styles (#23575)" (`docs/changes.txt:581`). Commit eefdabcd98 a gtk_window_begin_move_drag(GTK_WINDOW(m_frame->m_widget), 1, p.x, p.y, gtk_get_current_event_time()); ``` Cite: `BBLTopbar::OnMouseLeftDown`; `ResizeEdgePanel::OnLeftDown` (`MainFrame.cpp`). +- **Rule:** On X11, never move or resize a borderless frame that is maximized or fullscreen: + `window_pos_restore` skips `SetSize` for a maximized save, and `window_pos_sanitize` returns early. + **Why:** a client-side resize that lands on exactly the monitor rect counts as a legacy fullscreen + request to Mutter/Muffin (`force_fullscreen` defaults on) for an undecorated window without + `_GTK_FRAME_EXTENTS`, so the frame came up `_NET_WM_STATE_FULLSCREEN` and an auto-hide panel became + unreachable (#17191). It needs a work area equal to the monitor to reproduce, i.e. a panel that + reserves no strut. Windows and macOS keep that `SetSize`: it is what gives Restore Down a saved + normal size. ### macOS: a native titled window diff --git a/.claude/skills/orca-wxwidgets/references/windows-dialogs.md b/.claude/skills/orca-wxwidgets/references/windows-dialogs.md index ff8a858e24..eb74f013c0 100644 --- a/.claude/skills/orca-wxwidgets/references/windows-dialogs.md +++ b/.claude/skills/orca-wxwidgets/references/windows-dialogs.md @@ -463,12 +463,14 @@ ignored (observed; recorded in `GUI_App::window_pos_restore`, not documented by **OrcaSlicer geometry persistence.** Orca uses `AppConfig`, not `wxPersistentTLW`: `GUI_App::window_pos_save` / `window_pos_restore` / `window_pos_sanitize` / `window_pos_center` (key -`window_`, a `WindowMetrics` = screen rect + maximized; restore skips `SetPosition` on Wayland), and -`on_window_geometry(tlw, callback)` (`GUI_Utils.cpp`) to run the callback when geometry is real — MSW -immediately (no `wxEVT_SHOW` for windows created maximized), Linux on `wxEVT_SHOW` + `CallAfter`, macOS on -`wxEVT_SHOW`. `GUI_App::persist_window_geometry(window, default_maximized)` saves on -`wxEVT_CLOSE_WINDOW` (then `Skip()`) but always uses the key `window_mainframe`, whatever the window's -name — for any other window call `window_pos_save/restore` with its own name. +`window_`, a `WindowMetrics` = screen rect + maximized; restore skips `SetPosition` on Wayland and, +on X11, skips `SetSize` when the saved state is maximized; `window_pos_sanitize` returns early for a +maximized or fullscreen window on X11), and `on_window_geometry(tlw, callback)` (`GUI_Utils.cpp`) to run +the callback when geometry is real — MSW immediately (no `wxEVT_SHOW` for windows created maximized), +Linux on `wxEVT_SHOW` + `CallAfter`, macOS on `wxEVT_SHOW`. +`GUI_App::persist_window_geometry(window, default_maximized)` saves on +`wxEVT_CLOSE_WINDOW` (then `Skip()`) and restores under the window's own name, so the main frame +(`"mainframe"`) and the non-modal settings dialog (`"settings_dialog"`) keep separate entries. **Pitfalls.** - **Rule:** When restoring a top-level window (the main frame after hiding a popup or overlay frame, or a diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 3257f9bbaa..3bf8abe41b 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -5286,12 +5286,12 @@ void GUI_App::persist_window_geometry(wxTopLevelWindow *window, bool default_max const std::string name = into_u8(window->GetName()); window->Bind(wxEVT_CLOSE_WINDOW, [=](wxCloseEvent &event) { - BOOST_LOG_TRIVIAL(info) << __FUNCTION__<< ": received wxEVT_CLOSE_WINDOW, trigger save for window_mainframe"; - window_pos_save(window, "mainframe"); + BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": received wxEVT_CLOSE_WINDOW, trigger save for window_" << name; + window_pos_save(window, name); event.Skip(); }); - if (window_pos_restore(window, "mainframe", default_maximized)) { + if (window_pos_restore(window, name, default_maximized)) { on_window_geometry(window, [=]() { window_pos_sanitize(window); }); @@ -10141,19 +10141,34 @@ bool GUI_App::window_pos_restore(wxTopLevelWindow* window, const std::string &na } const wxRect& rect = metrics->get_rect(); + const bool maximized = metrics->get_maximized(); #if defined(__WXGTK__) + const bool on_x11 = !Slic3r::GUI::is_running_on_wayland(); // On Wayland, SetPosition() is a no-op for top-level windows. - // Only restore size and maximize state. - if (!Slic3r::GUI::is_running_on_wayland()) + if (on_x11) +#else + constexpr bool on_x11 = false; #endif window->SetPosition(rect.GetPosition()); - window->SetSize(rect.GetSize()); - window->Maximize(metrics->get_maximized()); + // The rect saved for a maximized window is the maximized one. On X11 an + // undecorated window that resizes itself to exactly the monitor rect is turned + // into a fullscreen window by Mutter based WMs; the other ports need the resize + // to give Restore Down the saved normal size. #17191 + if (! on_x11 || ! maximized) + window->SetSize(rect.GetSize()); + window->Maximize(maximized); return true; } void GUI_App::window_pos_sanitize(wxTopLevelWindow* window) { +#if defined(__WXGTK__) + // On X11, moving or resizing a maximized or fullscreen window is read as a + // fullscreen request by Mutter based WMs. #17191 + if (!Slic3r::GUI::is_running_on_wayland() && (window->IsMaximized() || window->IsFullScreen())) + return; +#endif + /*unsigned*/int display_idx = wxDisplay::GetFromWindow(window); wxRect display; if (display_idx == wxNOT_FOUND) {