Parcourir la 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 il y a 4 ans
Parent
commit
a671a5ba7e
1 fichiers modifiés avec 2 ajouts et 0 suppressions
  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) {
             } else if (m_move_window->tiled() == WindowTileType::None) {
                 Gfx::IntPoint pos = m_move_window_origin.translated(event.position() - m_move_origin);
                 Gfx::IntPoint pos = m_move_window_origin.translated(event.position() - m_move_origin);
                 m_move_window->set_position_without_repaint(pos);
                 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) {
             } else if (pixels_moved_from_start > 5) {
                 m_move_window->set_untiled(event.position());
                 m_move_window->set_untiled(event.position());
                 m_move_origin = event.position();
                 m_move_origin = event.position();