mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-11-22 21:50:51 -05:00
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.
This commit is contained in:
1 parent
6d563f72c2
commit
ec6e124658
3 files changed
+38
-13
No files matched your search
@@ -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
|
||||
|
||||
|
||||
@@ -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_<name>`, 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_<name>`, 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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user