mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 20:47:45 +00:00
WindowServer: Add initial support for rendering on multiple screens
This allows WindowServer to use multiple framebuffer devices and compose the desktop with any arbitrary layout. Currently, it is assumed that it is configured contiguous and non-overlapping, but this should eventually be enforced. To make rendering efficient, each window now also tracks on which screens it needs to be rendered. This way we don't have to iterate all the windows for each screen but instead use the same rendering loop and then only render to the screen (or screens) that the window actually uses.
This commit is contained in:
parent
499c33ae0c
commit
4392da970a
42 changed files with 1127 additions and 563 deletions
|
@ -25,11 +25,17 @@ Desktop::Desktop()
|
|||
{
|
||||
}
|
||||
|
||||
void Desktop::did_receive_screen_rect(Badge<WindowServerConnection>, const Gfx::IntRect& rect)
|
||||
void Desktop::did_receive_screen_rects(Badge<WindowServerConnection>, const Vector<Gfx::IntRect, 4>& rects, size_t main_screen_index)
|
||||
{
|
||||
if (m_rect == rect)
|
||||
return;
|
||||
m_rect = rect;
|
||||
m_main_screen_index = main_screen_index;
|
||||
m_rects = rects;
|
||||
if (!m_rects.is_empty()) {
|
||||
m_bounding_rect = m_rects[0];
|
||||
for (size_t i = 1; i < m_rects.size(); i++)
|
||||
m_bounding_rect = m_bounding_rect.united(m_rects[i]);
|
||||
} else {
|
||||
m_bounding_rect = {};
|
||||
}
|
||||
}
|
||||
|
||||
void Desktop::set_background_color(const StringView& background_color)
|
||||
|
|
|
@ -26,14 +26,18 @@ public:
|
|||
String wallpaper() const;
|
||||
bool set_wallpaper(const StringView& path, bool save_config = true);
|
||||
|
||||
Gfx::IntRect rect() const { return m_rect; }
|
||||
Gfx::IntRect rect() const { return m_bounding_rect; }
|
||||
const Vector<Gfx::IntRect, 4>& rects() const { return m_rects; }
|
||||
size_t main_screen_index() const { return m_main_screen_index; }
|
||||
|
||||
int taskbar_height() const { return TaskbarWindow::taskbar_height(); }
|
||||
|
||||
void did_receive_screen_rect(Badge<WindowServerConnection>, const Gfx::IntRect&);
|
||||
void did_receive_screen_rects(Badge<WindowServerConnection>, const Vector<Gfx::IntRect, 4>&, size_t);
|
||||
|
||||
private:
|
||||
Gfx::IntRect m_rect;
|
||||
Vector<Gfx::IntRect, 4> m_rects;
|
||||
size_t m_main_screen_index { 0 };
|
||||
Gfx::IntRect m_bounding_rect;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ public:
|
|||
DragMove,
|
||||
Drop,
|
||||
ThemeChange,
|
||||
ScreenRectChange,
|
||||
ScreenRectsChange,
|
||||
ActionEnter,
|
||||
ActionLeave,
|
||||
|
||||
|
@ -392,18 +392,21 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class ScreenRectChangeEvent final : public Event {
|
||||
class ScreenRectsChangeEvent final : public Event {
|
||||
public:
|
||||
explicit ScreenRectChangeEvent(const Gfx::IntRect& rect)
|
||||
: Event(Type::ScreenRectChange)
|
||||
, m_rect(rect)
|
||||
explicit ScreenRectsChangeEvent(const Vector<Gfx::IntRect, 4>& rects, size_t main_screen_index)
|
||||
: Event(Type::ScreenRectsChange)
|
||||
, m_rects(rects)
|
||||
, m_main_screen_index(main_screen_index)
|
||||
{
|
||||
}
|
||||
|
||||
const Gfx::IntRect& rect() const { return m_rect; }
|
||||
const Vector<Gfx::IntRect, 4>& rects() const { return m_rects; }
|
||||
size_t main_screen_index() const { return m_main_screen_index; }
|
||||
|
||||
private:
|
||||
Gfx::IntRect m_rect;
|
||||
Vector<Gfx::IntRect, 4> m_rects;
|
||||
size_t m_main_screen_index;
|
||||
};
|
||||
|
||||
class FocusEvent final : public Event {
|
||||
|
|
|
@ -52,7 +52,7 @@ class Painter;
|
|||
class RadioButton;
|
||||
class ResizeCorner;
|
||||
class ResizeEvent;
|
||||
class ScreenRectChangeEvent;
|
||||
class ScreenRectsChangeEvent;
|
||||
class Scrollbar;
|
||||
class AbstractScrollableWidget;
|
||||
class Slider;
|
||||
|
|
|
@ -506,7 +506,7 @@ void Widget::theme_change_event(ThemeChangeEvent&)
|
|||
{
|
||||
}
|
||||
|
||||
void Widget::screen_rect_change_event(ScreenRectChangeEvent&)
|
||||
void Widget::screen_rects_change_event(ScreenRectsChangeEvent&)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -312,7 +312,7 @@ protected:
|
|||
virtual void drag_leave_event(Event&);
|
||||
virtual void drop_event(DropEvent&);
|
||||
virtual void theme_change_event(ThemeChangeEvent&);
|
||||
virtual void screen_rect_change_event(ScreenRectChangeEvent&);
|
||||
virtual void screen_rects_change_event(ScreenRectsChangeEvent&);
|
||||
|
||||
virtual void did_begin_inspection() override;
|
||||
virtual void did_end_inspection() override;
|
||||
|
|
|
@ -495,11 +495,11 @@ void Window::handle_theme_change_event(ThemeChangeEvent& event)
|
|||
dispatch_theme_change(*m_main_widget.ptr(), dispatch_theme_change);
|
||||
}
|
||||
|
||||
void Window::handle_screen_rect_change_event(ScreenRectChangeEvent& event)
|
||||
void Window::handle_screen_rects_change_event(ScreenRectsChangeEvent& event)
|
||||
{
|
||||
if (!m_main_widget)
|
||||
return;
|
||||
auto dispatch_screen_rect_change = [&](auto& widget, auto recursive) {
|
||||
auto dispatch_screen_rects_change = [&](auto& widget, auto recursive) {
|
||||
widget.dispatch_event(event, this);
|
||||
widget.for_each_child_widget([&](auto& widget) -> IterationDecision {
|
||||
widget.dispatch_event(event, this);
|
||||
|
@ -507,8 +507,8 @@ void Window::handle_screen_rect_change_event(ScreenRectChangeEvent& event)
|
|||
return IterationDecision::Continue;
|
||||
});
|
||||
};
|
||||
dispatch_screen_rect_change(*m_main_widget.ptr(), dispatch_screen_rect_change);
|
||||
screen_rect_change_event(event);
|
||||
dispatch_screen_rects_change(*m_main_widget.ptr(), dispatch_screen_rects_change);
|
||||
screen_rects_change_event(event);
|
||||
}
|
||||
|
||||
void Window::handle_drag_move_event(DragEvent& event)
|
||||
|
@ -578,8 +578,8 @@ void Window::event(Core::Event& event)
|
|||
if (event.type() == Event::ThemeChange)
|
||||
return handle_theme_change_event(static_cast<ThemeChangeEvent&>(event));
|
||||
|
||||
if (event.type() == Event::ScreenRectChange)
|
||||
return handle_screen_rect_change_event(static_cast<ScreenRectChangeEvent&>(event));
|
||||
if (event.type() == Event::ScreenRectsChange)
|
||||
return handle_screen_rects_change_event(static_cast<ScreenRectsChangeEvent&>(event));
|
||||
|
||||
Core::Object::event(event);
|
||||
}
|
||||
|
@ -811,7 +811,7 @@ void Window::wm_event(WMEvent&)
|
|||
{
|
||||
}
|
||||
|
||||
void Window::screen_rect_change_event(ScreenRectChangeEvent&)
|
||||
void Window::screen_rects_change_event(ScreenRectsChangeEvent&)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -203,7 +203,7 @@ public:
|
|||
protected:
|
||||
Window(Core::Object* parent = nullptr);
|
||||
virtual void wm_event(WMEvent&);
|
||||
virtual void screen_rect_change_event(ScreenRectChangeEvent&);
|
||||
virtual void screen_rects_change_event(ScreenRectsChangeEvent&);
|
||||
|
||||
private:
|
||||
void update_cursor();
|
||||
|
@ -218,7 +218,7 @@ private:
|
|||
void handle_became_active_or_inactive_event(Core::Event&);
|
||||
void handle_close_request();
|
||||
void handle_theme_change_event(ThemeChangeEvent&);
|
||||
void handle_screen_rect_change_event(ScreenRectChangeEvent&);
|
||||
void handle_screen_rects_change_event(ScreenRectsChangeEvent&);
|
||||
void handle_drag_move_event(DragEvent&);
|
||||
void handle_left_event();
|
||||
|
||||
|
|
|
@ -48,12 +48,12 @@ WindowServerConnection::WindowServerConnection()
|
|||
// All we have to do is wait for it to arrive. This avoids a round-trip during application startup.
|
||||
auto message = wait_for_specific_message<Messages::WindowClient::FastGreet>();
|
||||
set_system_theme_from_anonymous_buffer(message->theme_buffer());
|
||||
Desktop::the().did_receive_screen_rect({}, message->screen_rect());
|
||||
Desktop::the().did_receive_screen_rects({}, message->screen_rects(), message->main_screen_index());
|
||||
Gfx::FontDatabase::set_default_font_query(message->default_font_query());
|
||||
Gfx::FontDatabase::set_fixed_width_font_query(message->fixed_width_font_query());
|
||||
}
|
||||
|
||||
void WindowServerConnection::fast_greet(Gfx::IntRect const&, Core::AnonymousBuffer const&, String const&, String const&)
|
||||
void WindowServerConnection::fast_greet(Vector<Gfx::IntRect> const&, u32, Core::AnonymousBuffer const&, String const&, String const&)
|
||||
{
|
||||
// NOTE: This message is handled in the constructor.
|
||||
}
|
||||
|
@ -311,11 +311,11 @@ void WindowServerConnection::menu_item_left(i32 menu_id, u32 identifier)
|
|||
Core::EventLoop::current().post_event(*app, make<ActionEvent>(GUI::Event::ActionLeave, *action));
|
||||
}
|
||||
|
||||
void WindowServerConnection::screen_rect_changed(Gfx::IntRect const& rect)
|
||||
void WindowServerConnection::screen_rects_changed(Vector<Gfx::IntRect> const& rects, u32 main_screen_index)
|
||||
{
|
||||
Desktop::the().did_receive_screen_rect({}, rect);
|
||||
Window::for_each_window({}, [rect](auto& window) {
|
||||
Core::EventLoop::current().post_event(window, make<ScreenRectChangeEvent>(rect));
|
||||
Desktop::the().did_receive_screen_rects({}, rects, main_screen_index);
|
||||
Window::for_each_window({}, [&](auto& window) {
|
||||
Core::EventLoop::current().post_event(window, make<ScreenRectsChangeEvent>(rects, main_screen_index));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ public:
|
|||
private:
|
||||
WindowServerConnection();
|
||||
|
||||
virtual void fast_greet(Gfx::IntRect const&, Core::AnonymousBuffer const&, String const&, String const&) override;
|
||||
virtual void fast_greet(Vector<Gfx::IntRect> const&, u32, Core::AnonymousBuffer const&, String const&, String const&) override;
|
||||
virtual void paint(i32, Gfx::IntSize const&, Vector<Gfx::IntRect> const&) override;
|
||||
virtual void mouse_move(i32, Gfx::IntPoint const&, u32, u32, u32, i32, bool, Vector<String> const&) override;
|
||||
virtual void mouse_down(i32, Gfx::IntPoint const&, u32, u32, u32, i32) override;
|
||||
|
@ -43,7 +43,7 @@ private:
|
|||
virtual void menu_item_entered(i32, u32) override;
|
||||
virtual void menu_item_left(i32, u32) override;
|
||||
virtual void menu_visibility_did_change(i32, bool) override;
|
||||
virtual void screen_rect_changed(Gfx::IntRect const&) override;
|
||||
virtual void screen_rects_changed(Vector<Gfx::IntRect> const&, u32) override;
|
||||
virtual void set_wallpaper_finished(bool) override;
|
||||
virtual void drag_dropped(i32, Gfx::IntPoint const&, String const&, HashMap<String, ByteBuffer> const&) override;
|
||||
virtual void drag_accepted() override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue