mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:37:46 +00:00
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.
This commit is contained in:
parent
b180132c87
commit
a1dceb5b97
4 changed files with 0 additions and 55 deletions
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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&);
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue