mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 22:47:44 +00:00
WindowServer: Add API to change virtual desktop settings
This also adds the ability to query how many virtual desktops are set up, and for the Taskbar to be notified when the active virtual desktop has changed.
This commit is contained in:
parent
584b144953
commit
7984c2836d
21 changed files with 383 additions and 64 deletions
|
@ -25,7 +25,7 @@ Desktop::Desktop()
|
|||
{
|
||||
}
|
||||
|
||||
void Desktop::did_receive_screen_rects(Badge<WindowServerConnection>, const Vector<Gfx::IntRect, 4>& rects, size_t main_screen_index)
|
||||
void Desktop::did_receive_screen_rects(Badge<WindowServerConnection>, const Vector<Gfx::IntRect, 4>& rects, size_t main_screen_index, unsigned virtual_desktop_rows, unsigned virtual_desktop_columns)
|
||||
{
|
||||
m_main_screen_index = main_screen_index;
|
||||
m_rects = rects;
|
||||
|
@ -36,6 +36,9 @@ void Desktop::did_receive_screen_rects(Badge<WindowServerConnection>, const Vect
|
|||
} else {
|
||||
m_bounding_rect = {};
|
||||
}
|
||||
|
||||
m_virtual_desktop_rows = virtual_desktop_rows;
|
||||
m_virtual_desktop_columns = virtual_desktop_columns;
|
||||
}
|
||||
|
||||
void Desktop::set_background_color(const StringView& background_color)
|
||||
|
|
|
@ -36,14 +36,19 @@ public:
|
|||
const Vector<Gfx::IntRect, 4>& rects() const { return m_rects; }
|
||||
size_t main_screen_index() const { return m_main_screen_index; }
|
||||
|
||||
unsigned virtual_desktop_rows() const { return m_virtual_desktop_rows; }
|
||||
unsigned virtual_desktop_columns() const { return m_virtual_desktop_columns; }
|
||||
|
||||
int taskbar_height() const { return TaskbarWindow::taskbar_height(); }
|
||||
|
||||
void did_receive_screen_rects(Badge<WindowServerConnection>, const Vector<Gfx::IntRect, 4>&, size_t);
|
||||
void did_receive_screen_rects(Badge<WindowServerConnection>, const Vector<Gfx::IntRect, 4>&, size_t, unsigned, unsigned);
|
||||
|
||||
private:
|
||||
Vector<Gfx::IntRect, default_screen_rect_count> m_rects;
|
||||
size_t m_main_screen_index { 0 };
|
||||
Gfx::IntRect m_bounding_rect;
|
||||
unsigned m_virtual_desktop_rows { 1 };
|
||||
unsigned m_virtual_desktop_columns { 1 };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -64,6 +64,7 @@ public:
|
|||
WM_AppletAreaSizeChanged,
|
||||
WM_SuperKeyPressed,
|
||||
WM_SuperSpaceKeyPressed,
|
||||
WM_VirtualDesktopChanged,
|
||||
__End_WM_Events,
|
||||
};
|
||||
|
||||
|
@ -135,13 +136,15 @@ public:
|
|||
|
||||
class WMWindowStateChangedEvent : public WMEvent {
|
||||
public:
|
||||
WMWindowStateChangedEvent(int client_id, int window_id, int parent_client_id, int parent_window_id, const StringView& title, const Gfx::IntRect& rect, bool is_active, bool is_modal, WindowType window_type, bool is_minimized, bool is_frameless, Optional<int> progress)
|
||||
WMWindowStateChangedEvent(int client_id, int window_id, int parent_client_id, int parent_window_id, const StringView& title, const Gfx::IntRect& rect, unsigned virtual_desktop_row, unsigned virtual_desktop_column, bool is_active, bool is_modal, WindowType window_type, bool is_minimized, bool is_frameless, Optional<int> progress)
|
||||
: WMEvent(Event::Type::WM_WindowStateChanged, client_id, window_id)
|
||||
, m_parent_client_id(parent_client_id)
|
||||
, m_parent_window_id(parent_window_id)
|
||||
, m_title(title)
|
||||
, m_rect(rect)
|
||||
, m_window_type(window_type)
|
||||
, m_virtual_desktop_row(virtual_desktop_row)
|
||||
, m_virtual_desktop_column(virtual_desktop_column)
|
||||
, m_active(is_active)
|
||||
, m_modal(is_modal)
|
||||
, m_minimized(is_minimized)
|
||||
|
@ -160,6 +163,8 @@ public:
|
|||
bool is_minimized() const { return m_minimized; }
|
||||
bool is_frameless() const { return m_frameless; }
|
||||
Optional<int> progress() const { return m_progress; }
|
||||
unsigned virtual_desktop_row() const { return m_virtual_desktop_row; }
|
||||
unsigned virtual_desktop_column() const { return m_virtual_desktop_column; }
|
||||
|
||||
private:
|
||||
int m_parent_client_id;
|
||||
|
@ -167,6 +172,8 @@ private:
|
|||
String m_title;
|
||||
Gfx::IntRect m_rect;
|
||||
WindowType m_window_type;
|
||||
unsigned m_virtual_desktop_row;
|
||||
unsigned m_virtual_desktop_column;
|
||||
bool m_active;
|
||||
bool m_modal;
|
||||
bool m_minimized;
|
||||
|
@ -202,6 +209,23 @@ private:
|
|||
RefPtr<Gfx::Bitmap> m_bitmap;
|
||||
};
|
||||
|
||||
class WMVirtualDesktopChangedEvent : public WMEvent {
|
||||
public:
|
||||
explicit WMVirtualDesktopChangedEvent(int client_id, unsigned current_row, unsigned current_column)
|
||||
: WMEvent(Event::Type::WM_VirtualDesktopChanged, client_id, 0)
|
||||
, m_current_row(current_row)
|
||||
, m_current_column(current_column)
|
||||
{
|
||||
}
|
||||
|
||||
unsigned current_row() const { return m_current_row; }
|
||||
unsigned current_column() const { return m_current_column; }
|
||||
|
||||
private:
|
||||
const unsigned m_current_row;
|
||||
const unsigned m_current_column;
|
||||
};
|
||||
|
||||
class MultiPaintEvent final : public Event {
|
||||
public:
|
||||
explicit MultiPaintEvent(const Vector<Gfx::IntRect, 32>& rects, const Gfx::IntSize& window_size)
|
||||
|
|
|
@ -20,11 +20,12 @@ WindowManagerServerConnection& WindowManagerServerConnection::the()
|
|||
}
|
||||
|
||||
void WindowManagerServerConnection::window_state_changed(i32 wm_id, i32 client_id, i32 window_id,
|
||||
i32 parent_client_id, i32 parent_window_id, bool is_active, bool is_minimized, bool is_modal,
|
||||
bool is_frameless, i32 window_type, String const& title, Gfx::IntRect const& rect, Optional<i32> const& progress)
|
||||
i32 parent_client_id, i32 parent_window_id, u32 virtual_desktop_row, u32 virtual_desktop_column,
|
||||
bool is_active, bool is_minimized, bool is_modal, bool is_frameless, i32 window_type,
|
||||
String const& title, Gfx::IntRect const& rect, Optional<i32> const& progress)
|
||||
{
|
||||
if (auto* window = Window::from_window_id(wm_id))
|
||||
Core::EventLoop::current().post_event(*window, make<WMWindowStateChangedEvent>(client_id, window_id, parent_client_id, parent_window_id, title, rect, is_active, is_modal, static_cast<WindowType>(window_type), is_minimized, is_frameless, progress));
|
||||
Core::EventLoop::current().post_event(*window, make<WMWindowStateChangedEvent>(client_id, window_id, parent_client_id, parent_window_id, title, rect, virtual_desktop_row, virtual_desktop_column, is_active, is_modal, static_cast<WindowType>(window_type), is_minimized, is_frameless, progress));
|
||||
}
|
||||
|
||||
void WindowManagerServerConnection::applet_area_size_changed(i32 wm_id, const Gfx::IntSize& size)
|
||||
|
@ -63,4 +64,11 @@ void WindowManagerServerConnection::super_space_key_pressed(i32 wm_id)
|
|||
if (auto* window = Window::from_window_id(wm_id))
|
||||
Core::EventLoop::current().post_event(*window, make<WMSuperSpaceKeyPressedEvent>(wm_id));
|
||||
}
|
||||
|
||||
void WindowManagerServerConnection::virtual_desktop_changed(i32 wm_id, u32 row, u32 column)
|
||||
{
|
||||
if (auto* window = Window::from_window_id(wm_id))
|
||||
Core::EventLoop::current().post_event(*window, make<WMVirtualDesktopChangedEvent>(wm_id, row, column));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,12 +27,13 @@ public:
|
|||
|
||||
private:
|
||||
virtual void window_removed(i32, i32, i32) override;
|
||||
virtual void window_state_changed(i32, i32, i32, i32, i32, bool, bool, bool, bool, i32, String const&, Gfx::IntRect const&, Optional<i32> const&) override;
|
||||
virtual void window_state_changed(i32, i32, i32, i32, i32, u32, u32, bool, bool, bool, bool, i32, String const&, Gfx::IntRect const&, Optional<i32> const&) override;
|
||||
virtual void window_icon_bitmap_changed(i32, i32, i32, Gfx::ShareableBitmap const&) override;
|
||||
virtual void window_rect_changed(i32, i32, i32, Gfx::IntRect const&) override;
|
||||
virtual void applet_area_size_changed(i32, Gfx::IntSize const&) override;
|
||||
virtual void super_key_pressed(i32) override;
|
||||
virtual void super_space_key_pressed(i32) override;
|
||||
virtual void virtual_desktop_changed(i32, u32, u32) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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_rects({}, message->screen_rects(), message->main_screen_index());
|
||||
Desktop::the().did_receive_screen_rects({}, message->screen_rects(), message->main_screen_index(), message->virtual_desktop_rows(), message->virtual_desktop_columns());
|
||||
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(Vector<Gfx::IntRect> const&, u32, Core::AnonymousBuffer const&, String const&, String const&)
|
||||
void WindowServerConnection::fast_greet(Vector<Gfx::IntRect> const&, u32, u32, u32, Core::AnonymousBuffer const&, String const&, String const&)
|
||||
{
|
||||
// NOTE: This message is handled in the constructor.
|
||||
}
|
||||
|
@ -311,9 +311,9 @@ 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_rects_changed(Vector<Gfx::IntRect> const& rects, u32 main_screen_index)
|
||||
void WindowServerConnection::screen_rects_changed(Vector<Gfx::IntRect> const& rects, u32 main_screen_index, u32 virtual_desktop_rows, u32 virtual_desktop_columns)
|
||||
{
|
||||
Desktop::the().did_receive_screen_rects({}, rects, main_screen_index);
|
||||
Desktop::the().did_receive_screen_rects({}, rects, main_screen_index, virtual_desktop_rows, virtual_desktop_columns);
|
||||
Window::for_each_window({}, [&](auto& window) {
|
||||
Core::EventLoop::current().post_event(window, make<ScreenRectsChangeEvent>(rects, main_screen_index));
|
||||
});
|
||||
|
|
|
@ -23,7 +23,7 @@ public:
|
|||
private:
|
||||
WindowServerConnection();
|
||||
|
||||
virtual void fast_greet(Vector<Gfx::IntRect> const&, u32, Core::AnonymousBuffer const&, String const&, String const&) override;
|
||||
virtual void fast_greet(Vector<Gfx::IntRect> const&, u32, u32, 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;
|
||||
|
@ -44,7 +44,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_rects_changed(Vector<Gfx::IntRect> const&, u32) override;
|
||||
virtual void screen_rects_changed(Vector<Gfx::IntRect> const&, u32, u32, 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