Browse Source

WindowServer: Prevent moving a window to inaccessible region

This is based on a comment by @tomuta on #4644, and should prevent all future
instances of bugs like #4644.

Disadvantage: The current implementation may generate a lot of WM_WindowRectChanged
events for a listener while bouncing occurs. Feel free to improve this.
Ben Wiederhake 4 năm trước cách đây
mục cha
commit
a671a5ba7e
1 tập tin đã thay đổi với 2 bổ sung0 xóa
  1. 2 0
      Userland/Services/WindowServer/WindowManager.cpp

+ 2 - 0
Userland/Services/WindowServer/WindowManager.cpp

@@ -559,6 +559,8 @@ bool WindowManager::process_ongoing_window_move(MouseEvent& event, Window*& hove
             } else if (m_move_window->tiled() == WindowTileType::None) {
                 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 it it would end up too far outside the screen:
+                m_move_window->normalize_rect();
             } else if (pixels_moved_from_start > 5) {
                 m_move_window->set_untiled(event.position());
                 m_move_origin = event.position();