mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:27:45 +00:00
WindowServer: Move child windows together with their parents
When moving a window, we will now move any child windows by the same position delta as the parent. This makes ComboBox popup list windows follow the window they were opened by, which looks nice. :^)
This commit is contained in:
parent
6228f72b87
commit
c6899b0910
2 changed files with 22 additions and 9 deletions
|
@ -142,6 +142,25 @@ void Window::set_rect(const Gfx::Rect& rect)
|
||||||
m_frame.notify_window_rect_changed(old_rect, rect);
|
m_frame.notify_window_rect_changed(old_rect, rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Window::set_rect_without_repaint(const Gfx::Rect& rect)
|
||||||
|
{
|
||||||
|
ASSERT(!rect.is_empty());
|
||||||
|
if (m_rect == rect)
|
||||||
|
return;
|
||||||
|
auto old_rect = m_rect;
|
||||||
|
m_rect = rect;
|
||||||
|
|
||||||
|
if (old_rect.size() == m_rect.size()) {
|
||||||
|
auto delta = m_rect.location() - old_rect.location();
|
||||||
|
for (auto& child_window : m_child_windows) {
|
||||||
|
if (child_window)
|
||||||
|
child_window->move_by(delta);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_frame.notify_window_rect_changed(old_rect, rect);
|
||||||
|
}
|
||||||
|
|
||||||
void Window::handle_mouse_event(const MouseEvent& event)
|
void Window::handle_mouse_event(const MouseEvent& event)
|
||||||
{
|
{
|
||||||
set_automatic_cursor_tracking_enabled(event.buttons() != 0);
|
set_automatic_cursor_tracking_enabled(event.buttons() != 0);
|
||||||
|
|
|
@ -142,15 +142,7 @@ public:
|
||||||
Gfx::Rect rect() const { return m_rect; }
|
Gfx::Rect rect() const { return m_rect; }
|
||||||
void set_rect(const Gfx::Rect&);
|
void set_rect(const Gfx::Rect&);
|
||||||
void set_rect(int x, int y, int width, int height) { set_rect({ x, y, width, height }); }
|
void set_rect(int x, int y, int width, int height) { set_rect({ x, y, width, height }); }
|
||||||
void set_rect_without_repaint(const Gfx::Rect& rect)
|
void set_rect_without_repaint(const Gfx::Rect&);
|
||||||
{
|
|
||||||
ASSERT(!rect.is_empty());
|
|
||||||
if (m_rect == rect)
|
|
||||||
return;
|
|
||||||
auto old_rect = m_rect;
|
|
||||||
m_rect = rect;
|
|
||||||
m_frame.notify_window_rect_changed(old_rect, rect);
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_taskbar_rect(const Gfx::Rect& rect) { m_taskbar_rect = rect; }
|
void set_taskbar_rect(const Gfx::Rect& rect) { m_taskbar_rect = rect; }
|
||||||
const Gfx::Rect& taskbar_rect() const { return m_taskbar_rect; }
|
const Gfx::Rect& taskbar_rect() const { return m_taskbar_rect; }
|
||||||
|
@ -158,6 +150,8 @@ public:
|
||||||
void move_to(const Gfx::Point& position) { set_rect({ position, size() }); }
|
void move_to(const Gfx::Point& position) { set_rect({ position, size() }); }
|
||||||
void move_to(int x, int y) { move_to({ x, y }); }
|
void move_to(int x, int y) { move_to({ x, y }); }
|
||||||
|
|
||||||
|
void move_by(const Gfx::Point& delta) { set_position_without_repaint(position().translated(delta)); }
|
||||||
|
|
||||||
Gfx::Point position() const { return m_rect.location(); }
|
Gfx::Point position() const { return m_rect.location(); }
|
||||||
void set_position(const Gfx::Point& position) { set_rect({ position.x(), position.y(), width(), height() }); }
|
void set_position(const Gfx::Point& position) { set_rect({ position.x(), position.y(), width(), height() }); }
|
||||||
void set_position_without_repaint(const Gfx::Point& position) { set_rect_without_repaint({ position.x(), position.y(), width(), height() }); }
|
void set_position_without_repaint(const Gfx::Point& position) { set_rect_without_repaint({ position.x(), position.y(), width(), height() }); }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue