mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-25 15:39:55 +00:00
WindowServer: Remove WindowManager::invalidate(Window) API's
Instead, we now tell Windows to invalidate themselves. Window will then pass on the requests to Compositor. My basic idea here is that WindowManager should do window management, dealing with incoming events, moving, resizing, etc. Compositor should deal with painting the window stack in the right order with the least amount of effort. :^)
This commit is contained in:
parent
10699b347f
commit
191073000e
Notes:
sideshowbarker
2024-07-19 06:20:53 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/191073000ef
6 changed files with 32 additions and 42 deletions
|
@ -471,7 +471,7 @@ void ClientConnection::destroy_window(Window& window, Vector<i32>& destroyed_win
|
|||
if (window.type() == WindowType::MenuApplet)
|
||||
AppletManager::the().remove_applet(window);
|
||||
|
||||
WindowManager::the().invalidate(window);
|
||||
window.invalidate();
|
||||
remove_child(window);
|
||||
m_windows.remove(window.window_id());
|
||||
}
|
||||
|
@ -520,7 +520,7 @@ void ClientConnection::handle(const Messages::WindowServer::DidFinishPainting& m
|
|||
}
|
||||
auto& window = *(*it).value;
|
||||
for (auto& rect : message.rects())
|
||||
WindowManager::the().invalidate(window, rect);
|
||||
window.invalidate(rect);
|
||||
|
||||
WindowSwitcher::the().refresh_if_needed();
|
||||
}
|
||||
|
|
|
@ -25,7 +25,9 @@
|
|||
*/
|
||||
|
||||
#include "Window.h"
|
||||
#include "AppletManager.h"
|
||||
#include "ClientConnection.h"
|
||||
#include "Compositor.h"
|
||||
#include "Event.h"
|
||||
#include "EventLoop.h"
|
||||
#include "Screen.h"
|
||||
|
@ -347,12 +349,26 @@ void Window::set_visible(bool b)
|
|||
|
||||
void Window::invalidate()
|
||||
{
|
||||
WindowManager::the().invalidate(*this);
|
||||
Compositor::the().invalidate(frame().rect());
|
||||
}
|
||||
|
||||
void Window::invalidate(const Gfx::Rect& rect)
|
||||
{
|
||||
WindowManager::the().invalidate(*this, rect);
|
||||
if (type() == WindowType::MenuApplet) {
|
||||
AppletManager::the().invalidate_applet(*this, rect);
|
||||
return;
|
||||
}
|
||||
|
||||
if (rect.is_empty()) {
|
||||
invalidate();
|
||||
return;
|
||||
}
|
||||
auto outer_rect = frame().rect();
|
||||
auto inner_rect = rect;
|
||||
inner_rect.move_by(position());
|
||||
// FIXME: This seems slightly wrong; the inner rect shouldn't intersect the border part of the outer rect.
|
||||
inner_rect.intersect(outer_rect);
|
||||
Compositor::the().invalidate(inner_rect);
|
||||
}
|
||||
|
||||
bool Window::is_active() const
|
||||
|
|
|
@ -314,7 +314,7 @@ Gfx::Rect WindowFrame::rect() const
|
|||
|
||||
void WindowFrame::invalidate_title_bar()
|
||||
{
|
||||
WindowManager::the().invalidate(title_bar_rect().translated(rect().location()));
|
||||
Compositor::the().invalidate(title_bar_rect().translated(rect().location()));
|
||||
}
|
||||
|
||||
void WindowFrame::notify_window_rect_changed(const Gfx::Rect& old_rect, const Gfx::Rect& new_rect)
|
||||
|
|
|
@ -207,7 +207,7 @@ void WindowManager::move_to_front_and_make_active(Window& window)
|
|||
return;
|
||||
|
||||
if (m_windows_in_order.tail() != &window)
|
||||
invalidate(window);
|
||||
window.invalidate();
|
||||
m_windows_in_order.remove(&window);
|
||||
m_windows_in_order.append(&window);
|
||||
|
||||
|
@ -229,7 +229,7 @@ void WindowManager::move_to_front_and_make_active(Window& window)
|
|||
|
||||
void WindowManager::remove_window(Window& window)
|
||||
{
|
||||
invalidate(window);
|
||||
window.invalidate();
|
||||
m_windows_in_order.remove(&window);
|
||||
if (window.is_active())
|
||||
pick_new_active_window();
|
||||
|
@ -380,7 +380,7 @@ void WindowManager::start_window_move(Window& window, const MouseEvent& event)
|
|||
m_move_window = window.make_weak_ptr();
|
||||
m_move_origin = event.position();
|
||||
m_move_window_origin = window.position();
|
||||
invalidate(window);
|
||||
window.invalidate();
|
||||
}
|
||||
|
||||
void WindowManager::start_window_resize(Window& window, const Gfx::Point& position, MouseButton button)
|
||||
|
@ -411,7 +411,7 @@ void WindowManager::start_window_resize(Window& window, const Gfx::Point& positi
|
|||
m_resize_origin = position;
|
||||
m_resize_window_original_rect = window.rect();
|
||||
|
||||
invalidate(window);
|
||||
window.invalidate();
|
||||
}
|
||||
|
||||
void WindowManager::start_window_resize(Window& window, const MouseEvent& event)
|
||||
|
@ -428,7 +428,7 @@ bool WindowManager::process_ongoing_window_move(MouseEvent& event, Window*& hove
|
|||
dbg() << "[WM] Finish moving Window{" << m_move_window << "}";
|
||||
#endif
|
||||
|
||||
invalidate(*m_move_window);
|
||||
m_move_window->invalidate();
|
||||
if (m_move_window->rect().contains(event.position()))
|
||||
hovered_window = m_move_window;
|
||||
if (m_move_window->is_resizable()) {
|
||||
|
@ -505,7 +505,7 @@ bool WindowManager::process_ongoing_window_resize(const MouseEvent& event, Windo
|
|||
dbg() << "[WM] Finish resizing Window{" << m_resize_window << "}";
|
||||
#endif
|
||||
Core::EventLoop::current().post_event(*m_resize_window, make<ResizeEvent>(m_resize_window->rect(), m_resize_window->rect()));
|
||||
invalidate(*m_resize_window);
|
||||
m_resize_window->invalidate();
|
||||
if (m_resize_window->rect().contains(event.position()))
|
||||
hovered_window = m_resize_window;
|
||||
m_resize_window = nullptr;
|
||||
|
@ -1006,10 +1006,10 @@ void WindowManager::set_highlight_window(Window* window)
|
|||
if (window == m_highlight_window)
|
||||
return;
|
||||
if (auto* previous_highlight_window = m_highlight_window.ptr())
|
||||
invalidate(*previous_highlight_window);
|
||||
previous_highlight_window->invalidate();
|
||||
m_highlight_window = window ? window->make_weak_ptr() : nullptr;
|
||||
if (m_highlight_window)
|
||||
invalidate(*m_highlight_window);
|
||||
m_highlight_window->invalidate();
|
||||
}
|
||||
|
||||
static bool window_type_can_become_active(WindowType type)
|
||||
|
@ -1036,7 +1036,7 @@ void WindowManager::set_active_window(Window* window)
|
|||
if (previously_active_window) {
|
||||
previously_active_client = previously_active_window->client();
|
||||
Core::EventLoop::current().post_event(*previously_active_window, make<Event>(Event::WindowDeactivated));
|
||||
invalidate(*previously_active_window);
|
||||
previously_active_window->invalidate();
|
||||
m_active_window = nullptr;
|
||||
m_active_input_window = nullptr;
|
||||
tell_wm_listeners_window_state_changed(*previously_active_window);
|
||||
|
@ -1046,7 +1046,7 @@ void WindowManager::set_active_window(Window* window)
|
|||
m_active_window = window->make_weak_ptr();
|
||||
active_client = m_active_window->client();
|
||||
Core::EventLoop::current().post_event(*m_active_window, make<Event>(Event::WindowActivated));
|
||||
invalidate(*m_active_window);
|
||||
m_active_window->invalidate();
|
||||
|
||||
auto* client = window->client();
|
||||
ASSERT(client);
|
||||
|
@ -1088,30 +1088,6 @@ void WindowManager::invalidate(const Gfx::Rect& rect)
|
|||
Compositor::the().invalidate(rect);
|
||||
}
|
||||
|
||||
void WindowManager::invalidate(const Window& window)
|
||||
{
|
||||
invalidate(window.frame().rect());
|
||||
}
|
||||
|
||||
void WindowManager::invalidate(const Window& window, const Gfx::Rect& rect)
|
||||
{
|
||||
if (window.type() == WindowType::MenuApplet) {
|
||||
AppletManager::the().invalidate_applet(window, rect);
|
||||
return;
|
||||
}
|
||||
|
||||
if (rect.is_empty()) {
|
||||
invalidate(window);
|
||||
return;
|
||||
}
|
||||
auto outer_rect = window.frame().rect();
|
||||
auto inner_rect = rect;
|
||||
inner_rect.move_by(window.position());
|
||||
// FIXME: This seems slightly wrong; the inner rect shouldn't intersect the border part of the outer rect.
|
||||
inner_rect.intersect(outer_rect);
|
||||
invalidate(inner_rect);
|
||||
}
|
||||
|
||||
const ClientConnection* WindowManager::active_client() const
|
||||
{
|
||||
if (m_active_window)
|
||||
|
|
|
@ -130,8 +130,6 @@ public:
|
|||
const Cursor& move_cursor() const { return *m_move_cursor; }
|
||||
const Cursor& drag_cursor() const { return *m_drag_cursor; }
|
||||
|
||||
void invalidate(const Window&);
|
||||
void invalidate(const Window&, const Gfx::Rect&);
|
||||
void invalidate(const Gfx::Rect&);
|
||||
void invalidate();
|
||||
void flush(const Gfx::Rect&);
|
||||
|
|
|
@ -162,7 +162,7 @@ void WindowSwitcher::select_window_at_index(int index)
|
|||
void WindowSwitcher::redraw()
|
||||
{
|
||||
draw();
|
||||
WindowManager::the().invalidate(m_rect);
|
||||
Compositor::the().invalidate(m_rect);
|
||||
}
|
||||
|
||||
Gfx::Rect WindowSwitcher::item_rect(int index) const
|
||||
|
|
Loading…
Reference in a new issue