diff options
author | thankyouverycool <66646555+thankyouverycool@users.noreply.github.com> | 2022-08-17 19:43:52 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-08-25 13:28:50 +0200 |
commit | a1dceb5b97480100e5f03aaee53ee3cbfa549c26 (patch) | |
tree | 7bb1f266eb52ac4be0c7a96bee227a98208310e4 | |
parent | b180132c878f7ec4fc768c422e7e171abf0cefb1 (diff) | |
download | serenity-a1dceb5b97480100e5f03aaee53ee3cbfa549c26.zip |
WindowServer: Remove nudge_into_desktop() from Window
Positioning windows outside visible coordinates is valid if sometimes
curious behavior, but it shouldn't be considered misbehavior by default.
There are multiple ways to recover windows with obscured title bars,
and this function papers over actual resize bugs and is no longer
needed to normalize window size, so let's remove it for now.
-rw-r--r-- | Userland/Services/WindowServer/ConnectionFromClient.cpp | 3 | ||||
-rw-r--r-- | Userland/Services/WindowServer/Window.cpp | 46 | ||||
-rw-r--r-- | Userland/Services/WindowServer/Window.h | 1 | ||||
-rw-r--r-- | Userland/Services/WindowServer/WindowManager.cpp | 5 |
4 files changed, 0 insertions, 55 deletions
diff --git a/Userland/Services/WindowServer/ConnectionFromClient.cpp b/Userland/Services/WindowServer/ConnectionFromClient.cpp index 13aed5f3de..39869edea3 100644 --- a/Userland/Services/WindowServer/ConnectionFromClient.cpp +++ b/Userland/Services/WindowServer/ConnectionFromClient.cpp @@ -453,7 +453,6 @@ Messages::WindowServer::SetWindowRectResponse ConnectionFromClient::set_window_r auto new_rect = rect; window.apply_minimum_size(new_rect); window.set_rect(new_rect); - window.nudge_into_desktop(nullptr); window.request_update(window.rect()); return window.rect(); } @@ -523,7 +522,6 @@ void ConnectionFromClient::set_window_minimum_size(i32 window_id, Gfx::IntSize c auto new_rect = window.rect(); bool did_size_clamp = window.apply_minimum_size(new_rect); window.set_rect(new_rect); - window.nudge_into_desktop(nullptr); window.request_update(window.rect()); if (did_size_clamp) @@ -610,7 +608,6 @@ void ConnectionFromClient::create_window(i32 window_id, Gfx::IntRect const& rect max(minimum_size.height(), system_window_minimum_size.height()) }); bool did_size_clamp = window->apply_minimum_size(new_rect); window->set_rect(new_rect); - window->nudge_into_desktop(nullptr); if (did_size_clamp) window->refresh_client_size(); diff --git a/Userland/Services/WindowServer/Window.cpp b/Userland/Services/WindowServer/Window.cpp index cabcfdface..43fc259806 100644 --- a/Userland/Services/WindowServer/Window.cpp +++ b/Userland/Services/WindowServer/Window.cpp @@ -190,52 +190,6 @@ bool Window::apply_minimum_size(Gfx::IntRect& rect) return did_size_clamp; } -void Window::nudge_into_desktop(Screen* target_screen, bool force_titlebar_visible) -{ - if (!target_screen) { - // If no explicit target screen was supplied, - // guess based on the current frame rectangle - target_screen = &Screen::closest_to_rect(rect()); - } - Gfx::IntRect arena = WindowManager::the().arena_rect_for_type(*target_screen, type()); - auto min_visible = 1; - switch (type()) { - case WindowType::Normal: - min_visible = 30; - break; - case WindowType::Desktop: - set_rect(arena); - return; - default: - break; - } - - // Push the frame around such that at least `min_visible` pixels of the *frame* are in the desktop rect. - auto old_frame_rect = frame().rect(); - Gfx::IntRect new_frame_rect = { - clamp(old_frame_rect.x(), arena.left() + min_visible - width(), arena.right() - min_visible), - clamp(old_frame_rect.y(), arena.top() + min_visible - height(), arena.bottom() - min_visible), - old_frame_rect.width(), - old_frame_rect.height(), - }; - - // Make sure that at least half of the titlebar is visible. - auto min_frame_y = arena.top() - (y() - old_frame_rect.y()) / 2; - if (force_titlebar_visible && new_frame_rect.y() < min_frame_y) { - new_frame_rect.set_y(min_frame_y); - } - - // Deduce new window rect: - Gfx::IntRect new_window_rect = { - x() + new_frame_rect.x() - old_frame_rect.x(), - y() + new_frame_rect.y() - old_frame_rect.y(), - width(), - height(), - }; - - set_rect(new_window_rect); -} - void Window::set_minimum_size(Gfx::IntSize const& size) { VERIFY(size.width() >= 0 && size.height() >= 0); diff --git a/Userland/Services/WindowServer/Window.h b/Userland/Services/WindowServer/Window.h index d6a5e44748..f3dfc83f02 100644 --- a/Userland/Services/WindowServer/Window.h +++ b/Userland/Services/WindowServer/Window.h @@ -190,7 +190,6 @@ public: void set_rect(int x, int y, int width, int height) { set_rect({ x, y, width, height }); } void set_rect_without_repaint(Gfx::IntRect const&); bool apply_minimum_size(Gfx::IntRect&); - void nudge_into_desktop(Screen*, bool force_titlebar_visible = true); Gfx::IntSize minimum_size() const { return m_minimum_size; } void set_minimum_size(Gfx::IntSize const&); diff --git a/Userland/Services/WindowServer/WindowManager.cpp b/Userland/Services/WindowServer/WindowManager.cpp index 918f57ca35..14ed94af4c 100644 --- a/Userland/Services/WindowServer/WindowManager.cpp +++ b/Userland/Services/WindowServer/WindowManager.cpp @@ -835,11 +835,6 @@ bool WindowManager::process_ongoing_window_move(MouseEvent& event) } else if (!m_move_window->is_tiled()) { Gfx::IntPoint pos = m_move_window_origin.translated(event.position() - m_move_origin); m_move_window->set_position_without_repaint(pos); - // "Bounce back" the window if it would end up too far outside the screen. - // If the user has let go of Mod_Super, maybe they didn't intentionally press it to begin with. - // Therefore, refuse to go into a state where knowledge about super-drags is necessary. - bool force_titlebar_visible = !(m_keyboard_modifiers & Mod_Super); - m_move_window->nudge_into_desktop(&cursor_screen, force_titlebar_visible); } else if (pixels_moved_from_start > 5) { Gfx::IntPoint adjusted_position = event.position().translated(-m_move_window_cursor_position); m_move_window->set_untiled(); |