Skip to content

Commit a1dceb5

Browse files
thankyouverycoolawesomekling
authored andcommitted
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.
1 parent b180132 commit a1dceb5

File tree

4 files changed

+0
-55
lines changed

4 files changed

+0
-55
lines changed

Userland/Services/WindowServer/ConnectionFromClient.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,6 @@ Messages::WindowServer::SetWindowRectResponse ConnectionFromClient::set_window_r
453453
auto new_rect = rect;
454454
window.apply_minimum_size(new_rect);
455455
window.set_rect(new_rect);
456-
window.nudge_into_desktop(nullptr);
457456
window.request_update(window.rect());
458457
return window.rect();
459458
}
@@ -523,7 +522,6 @@ void ConnectionFromClient::set_window_minimum_size(i32 window_id, Gfx::IntSize c
523522
auto new_rect = window.rect();
524523
bool did_size_clamp = window.apply_minimum_size(new_rect);
525524
window.set_rect(new_rect);
526-
window.nudge_into_desktop(nullptr);
527525
window.request_update(window.rect());
528526

529527
if (did_size_clamp)
@@ -610,7 +608,6 @@ void ConnectionFromClient::create_window(i32 window_id, Gfx::IntRect const& rect
610608
max(minimum_size.height(), system_window_minimum_size.height()) });
611609
bool did_size_clamp = window->apply_minimum_size(new_rect);
612610
window->set_rect(new_rect);
613-
window->nudge_into_desktop(nullptr);
614611

615612
if (did_size_clamp)
616613
window->refresh_client_size();

Userland/Services/WindowServer/Window.cpp

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -190,52 +190,6 @@ bool Window::apply_minimum_size(Gfx::IntRect& rect)
190190
return did_size_clamp;
191191
}
192192

193-
void Window::nudge_into_desktop(Screen* target_screen, bool force_titlebar_visible)
194-
{
195-
if (!target_screen) {
196-
// If no explicit target screen was supplied,
197-
// guess based on the current frame rectangle
198-
target_screen = &Screen::closest_to_rect(rect());
199-
}
200-
Gfx::IntRect arena = WindowManager::the().arena_rect_for_type(*target_screen, type());
201-
auto min_visible = 1;
202-
switch (type()) {
203-
case WindowType::Normal:
204-
min_visible = 30;
205-
break;
206-
case WindowType::Desktop:
207-
set_rect(arena);
208-
return;
209-
default:
210-
break;
211-
}
212-
213-
// Push the frame around such that at least `min_visible` pixels of the *frame* are in the desktop rect.
214-
auto old_frame_rect = frame().rect();
215-
Gfx::IntRect new_frame_rect = {
216-
clamp(old_frame_rect.x(), arena.left() + min_visible - width(), arena.right() - min_visible),
217-
clamp(old_frame_rect.y(), arena.top() + min_visible - height(), arena.bottom() - min_visible),
218-
old_frame_rect.width(),
219-
old_frame_rect.height(),
220-
};
221-
222-
// Make sure that at least half of the titlebar is visible.
223-
auto min_frame_y = arena.top() - (y() - old_frame_rect.y()) / 2;
224-
if (force_titlebar_visible && new_frame_rect.y() < min_frame_y) {
225-
new_frame_rect.set_y(min_frame_y);
226-
}
227-
228-
// Deduce new window rect:
229-
Gfx::IntRect new_window_rect = {
230-
x() + new_frame_rect.x() - old_frame_rect.x(),
231-
y() + new_frame_rect.y() - old_frame_rect.y(),
232-
width(),
233-
height(),
234-
};
235-
236-
set_rect(new_window_rect);
237-
}
238-
239193
void Window::set_minimum_size(Gfx::IntSize const& size)
240194
{
241195
VERIFY(size.width() >= 0 && size.height() >= 0);

Userland/Services/WindowServer/Window.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ class Window final : public Core::Object {
190190
void set_rect(int x, int y, int width, int height) { set_rect({ x, y, width, height }); }
191191
void set_rect_without_repaint(Gfx::IntRect const&);
192192
bool apply_minimum_size(Gfx::IntRect&);
193-
void nudge_into_desktop(Screen*, bool force_titlebar_visible = true);
194193

195194
Gfx::IntSize minimum_size() const { return m_minimum_size; }
196195
void set_minimum_size(Gfx::IntSize const&);

Userland/Services/WindowServer/WindowManager.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -835,11 +835,6 @@ bool WindowManager::process_ongoing_window_move(MouseEvent& event)
835835
} else if (!m_move_window->is_tiled()) {
836836
Gfx::IntPoint pos = m_move_window_origin.translated(event.position() - m_move_origin);
837837
m_move_window->set_position_without_repaint(pos);
838-
// "Bounce back" the window if it would end up too far outside the screen.
839-
// If the user has let go of Mod_Super, maybe they didn't intentionally press it to begin with.
840-
// Therefore, refuse to go into a state where knowledge about super-drags is necessary.
841-
bool force_titlebar_visible = !(m_keyboard_modifiers & Mod_Super);
842-
m_move_window->nudge_into_desktop(&cursor_screen, force_titlebar_visible);
843838
} else if (pixels_moved_from_start > 5) {
844839
Gfx::IntPoint adjusted_position = event.position().translated(-m_move_window_cursor_position);
845840
m_move_window->set_untiled();

0 commit comments

Comments
 (0)