summaryrefslogtreecommitdiff
path: root/Servers
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-12-02 09:33:37 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-12-02 11:11:05 +0100
commit272d65e3e2ed32981114d89df26d9154e51fb47e (patch)
treeaac9b2f42f311eb86336175ca57ec0fea7ff3930 /Servers
parent30db7813dedcb16afa67a9c9b6d4f39e04bce536 (diff)
downloadserenity-272d65e3e2ed32981114d89df26d9154e51fb47e.zip
WindowServer: Port to the new IPC system
This patch introduces code generation for the WindowServer IPC with its clients. The client/server endpoints are defined by the two .ipc files in Servers/WindowServer/: WindowServer.ipc and WindowClient.ipc It now becomes significantly easier to add features and capabilities to WindowServer since you don't have to know nearly as much about all the intricate paths that IPC messages take between LibGUI and WSWindow. The new system also uses significantly less IPC bandwidth since we're now doing packed serialization instead of passing fixed-sized structs of ~600 bytes for each message. Some repaint coalescing optimizations are lost in this conversion and we'll need to look at how to implement those in the new world. The old CoreIPC::Client::Connection and CoreIPC::Server::Connection classes are removed by this patch and replaced by use of ConnectionNG, which will be renamed eventually. Goodbye, old WindowServer IPC. You served us well :^)
Diffstat (limited to 'Servers')
-rw-r--r--Servers/WindowServer/Makefile10
-rw-r--r--Servers/WindowServer/WSAPITypes.h328
-rw-r--r--Servers/WindowServer/WSClientConnection.cpp824
-rw-r--r--Servers/WindowServer/WSClientConnection.h85
-rw-r--r--Servers/WindowServer/WSEvent.h699
-rw-r--r--Servers/WindowServer/WSEventLoop.cpp3
-rw-r--r--Servers/WindowServer/WSEventLoop.h1
-rw-r--r--Servers/WindowServer/WSMenu.cpp9
-rw-r--r--Servers/WindowServer/WSWindow.cpp154
-rw-r--r--Servers/WindowServer/WSWindow.h9
-rw-r--r--Servers/WindowServer/WSWindowManager.cpp9
-rw-r--r--Servers/WindowServer/WSWindowManager.h2
-rw-r--r--Servers/WindowServer/WindowClient.ipc30
-rw-r--r--Servers/WindowServer/WindowServer.ipc68
-rw-r--r--Servers/WindowServer/main.cpp6
15 files changed, 419 insertions, 1818 deletions
diff --git a/Servers/WindowServer/Makefile b/Servers/WindowServer/Makefile
index f731caa25b..411ec11953 100644
--- a/Servers/WindowServer/Makefile
+++ b/Servers/WindowServer/Makefile
@@ -25,6 +25,14 @@ DEFINES += -DUSERLAND
all: $(APP)
+*.cpp: WindowServerEndpoint.h WindowClientEndpoint.h
+
+WindowServerEndpoint.h: WindowServer.ipc
+ @echo "IPC $<"; $(IPCCOMPILER) $< > $@
+
+WindowClientEndpoint.h: WindowClient.ipc
+ @echo "IPC $<"; $(IPCCOMPILER) $< > $@
+
$(APP): $(OBJS)
$(LD) -o $(APP) $(LDFLAGS) $(OBJS) -lc -ldraw -lcore -lthread -lpthread -laudio -lipc
@@ -34,5 +42,5 @@ $(APP): $(OBJS)
-include $(OBJS:%.o=%.d)
clean:
- @echo "CLEAN"; rm -f $(APP) $(OBJS) *.d
+ @echo "CLEAN"; rm -f $(APP) $(OBJS) *.d WindowServerEndpoint.h WindowClientEndpoint.h
diff --git a/Servers/WindowServer/WSAPITypes.h b/Servers/WindowServer/WSAPITypes.h
deleted file mode 100644
index 20908401d0..0000000000
--- a/Servers/WindowServer/WSAPITypes.h
+++ /dev/null
@@ -1,328 +0,0 @@
-#pragma once
-
-#include <LibDraw/Color.h>
-#include <LibDraw/Rect.h>
-
-typedef unsigned WSAPI_Color;
-
-struct WSAPI_Point {
- int x;
- int y;
-};
-
-struct WSAPI_Size {
- int width;
- int height;
-};
-
-struct WSAPI_Rect {
- WSAPI_Point location;
- WSAPI_Size size;
-};
-
-enum WSAPI_WindowType {
- Invalid = 0,
- Normal,
- Menu,
- WindowSwitcher,
- Taskbar,
- Tooltip,
- Menubar,
-};
-
-struct WSAPI_WindowBackingStoreInfo {
- WSAPI_Size size;
- size_t bpp;
- size_t pitch;
- RGBA32* pixels;
-};
-
-enum class WSAPI_MouseButton : unsigned char {
- NoButton = 0,
- Left = 1,
- Right = 2,
- Middle = 4,
-};
-
-struct WSAPI_KeyModifiers {
- enum {
- Shift = 1 << 0,
- Alt = 1 << 1,
- Ctrl = 1 << 2,
- };
-};
-
-enum class WSAPI_StandardCursor : unsigned char {
- None = 0,
- Arrow,
- IBeam,
- ResizeHorizontal,
- ResizeVertical,
- ResizeDiagonalTLBR,
- ResizeDiagonalBLTR,
-};
-
-enum WSAPI_WMEventMask : unsigned {
- WindowRectChanges = 1 << 0,
- WindowStateChanges = 1 << 1,
- WindowIconChanges = 1 << 2,
- WindowRemovals = 1 << 3,
-};
-
-struct WSAPI_ServerMessage {
- enum Type : unsigned {
- Invalid,
- Error,
- Paint,
- MouseMove,
- MouseDown,
- MouseDoubleClick,
- MouseUp,
- MouseWheel,
- WindowEntered,
- WindowLeft,
- KeyDown,
- KeyUp,
- WindowActivated,
- WindowDeactivated,
- WindowResized,
- WindowCloseRequest,
- MenuItemActivated,
- DidCreateMenubar,
- DidDestroyMenubar,
- DidCreateMenu,
- DidDestroyMenu,
- DidAddMenuToMenubar,
- DidSetApplicationMenubar,
- DidAddMenuItem,
- DidAddMenuSeparator,
- DidUpdateMenuItem,
- DidCreateWindow,
- DidDestroyWindow,
- DidGetWindowTitle,
- DidGetWindowRect,
- Greeting,
- DidGetClipboardContents,
- DidSetClipboardContents,
- DidSetWindowBackingStore,
- DidSetWallpaper,
- DidGetWallpaper,
- DidSetResolution,
- DidSetWindowHasAlphaChannel,
- ScreenRectChanged,
- ClipboardContentsChanged,
- DidSetFullscreen,
-
- __Begin_WM_Events__,
- WM_WindowRemoved,
- WM_WindowStateChanged,
- WM_WindowRectChanged,
- WM_WindowIconBitmapChanged,
- __End_WM_Events__,
- };
- Type type { Invalid };
- int window_id { -1 };
- unsigned extra_size { 0 };
-
- union {
- int text_length { 0 };
- int rect_count;
- };
-
- static const int max_inline_rect_count = 32;
- union {
- char text[512];
- WSAPI_Rect rects[32];
- };
- int value { 0 };
-
- union {
- struct {
- int server_pid;
- int your_client_id;
- WSAPI_Rect screen_rect;
- } greeting;
- struct {
- int client_id;
- int window_id;
- WSAPI_Rect rect;
- bool is_active;
- bool is_minimized;
- WSAPI_WindowType window_type;
- int icon_buffer_id;
- WSAPI_Size icon_size;
- } wm;
- struct {
- WSAPI_Rect rect;
- } screen;
- struct {
- WSAPI_Rect rect;
- WSAPI_Rect old_rect;
- } window;
- struct {
- WSAPI_Size window_size;
- } paint;
- struct {
- WSAPI_Point position;
- WSAPI_MouseButton button;
- unsigned buttons;
- u8 modifiers;
- int wheel_delta;
- } mouse;
- struct {
- char character;
- u8 key;
- u8 modifiers;
- bool ctrl : 1;
- bool alt : 1;
- bool shift : 1;
- } key;
- struct {
- int menubar_id;
- int menu_id;
- unsigned identifier;
- } menu;
- struct {
- WSAPI_Size size;
- size_t bpp;
- size_t pitch;
- int shared_buffer_id;
- bool has_alpha_channel;
- } backing;
- struct {
- int shared_buffer_id;
- int contents_size;
- } clipboard;
- };
-};
-
-struct WSAPI_ClientMessage {
- enum Type : unsigned {
- Invalid,
- CreateMenubar,
- DestroyMenubar,
- CreateMenu,
- DestroyMenu,
- AddMenuToMenubar,
- SetApplicationMenubar,
- AddMenuItem,
- AddMenuSeparator,
- UpdateMenuItem,
- CreateWindow,
- DestroyWindow,
- SetWindowTitle,
- GetWindowTitle,
- SetWindowRect,
- GetWindowRect,
- InvalidateRect,
- DidFinishPainting,
- SetGlobalCursorTracking,
- SetWindowOpacity,
- SetWindowBackingStore,
- GetClipboardContents,
- SetClipboardContents,
- Greeting,
- SetWallpaper,
- GetWallpaper,
- SetResolution,
- SetWindowOverrideCursor,
- WM_SetActiveWindow,
- WM_SetWindowMinimized,
- WM_StartWindowResize,
- WM_PopupWindowMenu,
- PopupMenu,
- DismissMenu,
- SetWindowHasAlphaChannel,
- MoveWindowToFront,
- SetWindowIconBitmap,
- SetFullscreen,
- };
- Type type { Invalid };
- int window_id { -1 };
- unsigned extra_size { 0 };
- union {
- int text_length { 0 };
- int rect_count;
- };
-
- static const int max_inline_rect_count = 32;
- union {
- char text[512];
- WSAPI_Rect rects[max_inline_rect_count];
- };
- int value { 0 };
-
- union {
- struct {
- int client_pid;
- } greeting;
- struct {
- int client_id;
- int window_id;
- bool minimized;
- WSAPI_Point position;
- } wm;
- struct {
- WSAPI_Size resolution;
- } wm_conf;
- struct {
- int menubar_id;
- int menu_id;
- int submenu_id;
- int icon_buffer_id;
- unsigned identifier;
- char shortcut_text[32];
- int shortcut_text_length;
- bool enabled;
- bool checkable;
- bool checked;
- WSAPI_Point position;
- } menu;
- struct {
- WSAPI_Rect rect;
- bool has_alpha_channel;
- bool modal;
- bool resizable;
- bool fullscreen;
- bool show_titlebar;
- WSAPI_WindowType type;
- float opacity;
- WSAPI_Size base_size;
- WSAPI_Size size_increment;
- WSAPI_Color background_color;
- int icon_buffer_id;
- WSAPI_Size icon_size;
- } window;
- struct {
- WSAPI_Size size;
- size_t bpp;
- size_t pitch;
- int shared_buffer_id;
- bool has_alpha_channel;
- bool flush_immediately;
- } backing;
- struct {
- int shared_buffer_id;
- int contents_size;
- } clipboard;
- struct {
- WSAPI_StandardCursor cursor;
- } cursor;
- };
-};
-
-inline Rect::Rect(const WSAPI_Rect& r)
- : Rect(r.location, r.size)
-{
-}
-inline Point::Point(const WSAPI_Point& p)
- : Point(p.x, p.y)
-{
-}
-inline Size::Size(const WSAPI_Size& s)
- : Size(s.width, s.height)
-{
-}
-inline Rect::operator WSAPI_Rect() const { return { m_location, m_size }; }
-inline Point::operator WSAPI_Point() const { return { m_x, m_y }; }
-inline Size::operator WSAPI_Size() const { return { m_width, m_height }; }
diff --git a/Servers/WindowServer/WSClientConnection.cpp b/Servers/WindowServer/WSClientConnection.cpp
index 4ea53cbfeb..0adb383ca0 100644
--- a/Servers/WindowServer/WSClientConnection.cpp
+++ b/Servers/WindowServer/WSClientConnection.cpp
@@ -1,7 +1,6 @@
#include <LibC/SharedBuffer.h>
#include <LibDraw/GraphicsBitmap.h>
#include <SharedBuffer.h>
-#include <WindowServer/WSAPITypes.h>
#include <WindowServer/WSClientConnection.h>
#include <WindowServer/WSClipboard.h>
#include <WindowServer/WSCompositor.h>
@@ -13,6 +12,7 @@
#include <WindowServer/WSWindow.h>
#include <WindowServer/WSWindowManager.h>
#include <WindowServer/WSWindowSwitcher.h>
+#include <WindowServer/WindowClientEndpoint.h>
#include <errno.h>
#include <stdio.h>
#include <sys/ioctl.h>
@@ -42,7 +42,7 @@ WSClientConnection* WSClientConnection::from_client_id(int client_id)
}
WSClientConnection::WSClientConnection(CLocalSocket& client_socket, int client_id)
- : Connection(client_socket, client_id)
+ : ConnectionNG(*this, client_socket, client_id)
{
if (!s_connections)
s_connections = new HashMap<int, NonnullRefPtr<WSClientConnection>>;
@@ -54,16 +54,6 @@ WSClientConnection::~WSClientConnection()
auto windows = move(m_windows);
}
-void WSClientConnection::send_greeting()
-{
- WSAPI_ServerMessage message;
- message.type = WSAPI_ServerMessage::Type::Greeting;
- message.greeting.server_pid = getpid();
- message.greeting.your_client_id = client_id();
- message.greeting.screen_rect = WSScreen::the().rect();
- post_message(message);
-}
-
void WSClientConnection::die()
{
s_connections->remove(client_id());
@@ -72,642 +62,327 @@ void WSClientConnection::die()
void WSClientConnection::post_error(const String& error_message)
{
dbgprintf("WSClientConnection::post_error: client_id=%d: %s\n", client_id(), error_message.characters());
- WSAPI_ServerMessage message;
- message.type = WSAPI_ServerMessage::Type::Error;
- ASSERT(error_message.length() < (ssize_t)sizeof(message.text));
- strcpy(message.text, error_message.characters());
- message.text_length = error_message.length();
- post_message(message);
+ did_misbehave();
}
void WSClientConnection::notify_about_new_screen_rect(const Rect& rect)
{
- WSAPI_ServerMessage message;
- message.type = WSAPI_ServerMessage::Type::ScreenRectChanged;
- message.screen.rect = rect;
- post_message(message);
+ post_message(WindowClient::ScreenRectChanged(rect));
}
void WSClientConnection::notify_about_clipboard_contents_changed()
{
- auto& clipboard = WSClipboard::the();
- WSAPI_ServerMessage message;
- message.type = WSAPI_ServerMessage::Type::ClipboardContentsChanged;
- message.clipboard.shared_buffer_id = -1;
- message.clipboard.contents_size = -1;
- ASSERT(clipboard.data_type().length() < (ssize_t)sizeof(message.text));
- strcpy(message.text, clipboard.data_type().characters());
- message.text_length = clipboard.data_type().length();
- post_message(message);
-}
-
-void WSClientConnection::event(CEvent& event)
-{
- if (static_cast<WSEvent&>(event).is_client_request()) {
- on_request(static_cast<const WSAPIClientRequest&>(event));
- return;
- }
-
- Connection::event(event);
-}
-
-static Vector<Rect, 32> get_rects(const WSAPI_ClientMessage& message, const ByteBuffer& extra_data)
-{
- Vector<Rect, 32> rects;
- if (message.rect_count > (int)(WSAPI_ClientMessage::max_inline_rect_count + extra_data.size() / sizeof(WSAPI_Rect))) {
- return {};
- }
- for (int i = 0; i < min(WSAPI_ClientMessage::max_inline_rect_count, message.rect_count); ++i)
- rects.append(message.rects[i]);
- if (!extra_data.is_empty()) {
- auto* extra_rects = reinterpret_cast<const WSAPI_Rect*>(extra_data.data());
- for (int i = 0; i < (int)(extra_data.size() / sizeof(WSAPI_Rect)); ++i)
- rects.append(extra_rects[i]);
- }
- return rects;
+ post_message(WindowClient::ClipboardContentsChanged(WSClipboard::the().data_type()));
}
-bool WSClientConnection::handle_message(const WSAPI_ClientMessage& message, const ByteBuffer&& extra_data)
-{
- switch (message.type) {
- case WSAPI_ClientMessage::Type::Greeting:
- set_client_pid(message.greeting.client_pid);
- break;
- case WSAPI_ClientMessage::Type::CreateMenubar:
- CEventLoop::current().post_event(*this, make<WSAPICreateMenubarRequest>(client_id()));
- break;
- case WSAPI_ClientMessage::Type::DestroyMenubar:
- CEventLoop::current().post_event(*this, make<WSAPIDestroyMenubarRequest>(client_id(), message.menu.menubar_id));
- break;
- case WSAPI_ClientMessage::Type::SetApplicationMenubar:
- CEventLoop::current().post_event(*this, make<WSAPISetApplicationMenubarRequest>(client_id(), message.menu.menubar_id));
- break;
- case WSAPI_ClientMessage::Type::AddMenuToMenubar:
- CEventLoop::current().post_event(*this, make<WSAPIAddMenuToMenubarRequest>(client_id(), message.menu.menubar_id, message.menu.menu_id));
- break;
- case WSAPI_ClientMessage::Type::CreateMenu:
- if (message.text_length > (int)sizeof(message.text)) {
- did_misbehave();
- return false;
- }
- CEventLoop::current().post_event(*this, make<WSAPICreateMenuRequest>(client_id(), String(message.text, message.text_length)));
- break;
- case WSAPI_ClientMessage::Type::PopupMenu:
- CEventLoop::current().post_event(*this, make<WSAPIPopupMenuRequest>(client_id(), message.menu.menu_id, message.menu.position));
- break;
- case WSAPI_ClientMessage::Type::DismissMenu:
- CEventLoop::current().post_event(*this, make<WSAPIDismissMenuRequest>(client_id(), message.menu.menu_id));
- break;
- case WSAPI_ClientMessage::Type::SetWindowIconBitmap:
- CEventLoop::current().post_event(*this, make<WSAPISetWindowIconBitmapRequest>(client_id(), message.window_id, message.window.icon_buffer_id, message.window.icon_size));
- break;
- case WSAPI_ClientMessage::Type::DestroyMenu:
- CEventLoop::current().post_event(*this, make<WSAPIDestroyMenuRequest>(client_id(), message.menu.menu_id));
- break;
- case WSAPI_ClientMessage::Type::AddMenuItem:
- if (message.text_length > (int)sizeof(message.text)) {
- did_misbehave();
- return false;
- }
- if (message.menu.shortcut_text_length > (int)sizeof(message.menu.shortcut_text)) {
- did_misbehave();
- return false;
- }
- CEventLoop::current().post_event(*this, make<WSAPIAddMenuItemRequest>(client_id(), message.menu.menu_id, message.menu.identifier, String(message.text, message.text_length), String(message.menu.shortcut_text, message.menu.shortcut_text_length), message.menu.enabled, message.menu.checkable, message.menu.checked, message.menu.icon_buffer_id, message.menu.submenu_id));
- break;
- case WSAPI_ClientMessage::Type::UpdateMenuItem:
- if (message.text_length > (int)sizeof(message.text)) {
- did_misbehave();
- return false;
- }
- if (message.menu.shortcut_text_length > (int)sizeof(message.menu.shortcut_text)) {
- did_misbehave();
- return false;
- }
- CEventLoop::current().post_event(*this, make<WSAPIUpdateMenuItemRequest>(client_id(), message.menu.menu_id, message.menu.identifier, String(message.text, message.text_length), String(message.menu.shortcut_text, message.menu.shortcut_text_length), message.menu.enabled, message.menu.checkable, message.menu.checked));
- break;
- case WSAPI_ClientMessage::Type::AddMenuSeparator:
- CEventLoop::current().post_event(*this, make<WSAPIAddMenuSeparatorRequest>(client_id(), message.menu.menu_id));
- break;
- case WSAPI_ClientMessage::Type::CreateWindow: {
- if (message.text_length > (int)sizeof(message.text)) {
- did_misbehave();
- return false;
- }
-
- auto ws_window_type = WSWindowType::Invalid;
- switch (message.window.type) {
- case WSAPI_WindowType::Normal:
- ws_window_type = WSWindowType::Normal;
- break;
- case WSAPI_WindowType::Menu:
- ws_window_type = WSWindowType::Menu;
- break;
- case WSAPI_WindowType::WindowSwitcher:
- ws_window_type = WSWindowType::WindowSwitcher;
- break;
- case WSAPI_WindowType::Taskbar:
- ws_window_type = WSWindowType::Taskbar;
- break;
- case WSAPI_WindowType::Tooltip:
- ws_window_type = WSWindowType::Tooltip;
- break;
- case WSAPI_WindowType::Menubar:
- ws_window_type = WSWindowType::Menubar;
- break;
- case WSAPI_WindowType::Invalid:
- default:
- dbgprintf("Unknown WSAPI_WindowType: %d\n", message.window.type);
- did_misbehave();
- return false;
- }
-
- CEventLoop::current().post_event(*this,
- make<WSAPICreateWindowRequest>(client_id(),
- message.window.rect,
- String(message.text, message.text_length),
- message.window.has_alpha_channel,
- message.window.modal,
- message.window.resizable,
- message.window.fullscreen,
- message.window.show_titlebar,
- message.window.opacity,
- message.window.base_size,
- message.window.size_increment,
- ws_window_type,
- Color::from_rgba(message.window.background_color)));
- break;
- }
- case WSAPI_ClientMessage::Type::DestroyWindow:
- CEventLoop::current().post_event(*this, make<WSAPIDestroyWindowRequest>(client_id(), message.window_id));
- break;
- case WSAPI_ClientMessage::Type::SetWindowTitle:
- if (message.text_length > (int)sizeof(message.text)) {
- did_misbehave();
- return false;
- }
- CEventLoop::current().post_event(*this, make<WSAPISetWindowTitleRequest>(client_id(), message.window_id, String(message.text, message.text_length)));
- break;
- case WSAPI_ClientMessage::Type::GetWindowTitle:
- CEventLoop::current().post_event(*this, make<WSAPIGetWindowTitleRequest>(client_id(), message.window_id));
- break;
- case WSAPI_ClientMessage::Type::SetWindowRect:
- CEventLoop::current().post_event(*this, make<WSAPISetWindowRectRequest>(client_id(), message.window_id, message.window.rect));
- break;
- case WSAPI_ClientMessage::Type::GetWindowRect:
- CEventLoop::current().post_event(*this, make<WSAPIGetWindowRectRequest>(client_id(), message.window_id));
- break;
- case WSAPI_ClientMessage::Type::SetClipboardContents:
- if (message.text_length > (int)sizeof(message.text)) {
- did_misbehave();
- return false;
- }
- CEventLoop::current().post_event(*this, make<WSAPISetClipboardContentsRequest>(client_id(), message.clipboard.shared_buffer_id, message.clipboard.contents_size, String(message.text, message.text_length)));
- break;
- case WSAPI_ClientMessage::Type::GetClipboardContents:
- CEventLoop::current().post_event(*this, make<WSAPIGetClipboardContentsRequest>(client_id()));
- break;
- case WSAPI_ClientMessage::Type::InvalidateRect: {
- auto rects = get_rects(message, extra_data);
- if (rects.is_empty()) {
- did_misbehave();
- return false;
- }
- CEventLoop::current().post_event(*this, make<WSAPIInvalidateRectRequest>(client_id(), message.window_id, rects));
- break;
- }
- case WSAPI_ClientMessage::Type::DidFinishPainting: {
- auto rects = get_rects(message, extra_data);
- if (rects.is_empty()) {
- did_misbehave();
- return false;
- }
- CEventLoop::current().post_event(*this, make<WSAPIDidFinishPaintingNotification>(client_id(), message.window_id, rects));
- break;
- }
- case WSAPI_ClientMessage::Type::SetWindowBackingStore:
- CEventLoop::current().post_event(*this, make<WSAPISetWindowBackingStoreRequest>(client_id(), message.window_id, message.backing.shared_buffer_id, message.backing.size, message.backing.bpp, message.backing.pitch, message.backing.has_alpha_channel, message.backing.flush_immediately));
- break;
- case WSAPI_ClientMessage::Type::SetGlobalCursorTracking:
- CEventLoop::current().post_event(*this, make<WSAPISetGlobalCursorTrackingRequest>(client_id(), message.window_id, message.value));
- break;
- case WSAPI_ClientMessage::Type::SetWallpaper:
- if (message.text_length > (int)sizeof(message.text)) {
- did_misbehave();
- return false;
- }
- CEventLoop::current().post_event(*this, make<WSAPISetWallpaperRequest>(client_id(), String(message.text, message.text_length)));
- break;
- case WSAPI_ClientMessage::Type::GetWallpaper:
- CEventLoop::current().post_event(*this, make<WSAPIGetWallpaperRequest>(client_id()));
- break;
- case WSAPI_ClientMessage::Type::SetResolution:
- CEventLoop::current().post_event(*this, make<WSAPISetResolutionRequest>(client_id(), message.wm_conf.resolution.width, message.wm_conf.resolution.height));
- break;
- case WSAPI_ClientMessage::Type::SetWindowOverrideCursor:
- CEventLoop::current().post_event(*this, make<WSAPISetWindowOverrideCursorRequest>(client_id(), message.window_id, (WSStandardCursor)message.cursor.cursor));
- break;
- case WSAPI_ClientMessage::SetWindowHasAlphaChannel:
- CEventLoop::current().post_event(*this, make<WSAPISetWindowHasAlphaChannelRequest>(client_id(), message.window_id, message.value));
- break;
- case WSAPI_ClientMessage::Type::WM_SetActiveWindow:
- CEventLoop::current().post_event(*this, make<WSWMAPISetActiveWindowRequest>(client_id(), message.wm.client_id, message.wm.window_id));
- break;
- case WSAPI_ClientMessage::Type::WM_SetWindowMinimized:
- CEventLoop::current().post_event(*this, make<WSWMAPISetWindowMinimizedRequest>(client_id(), message.wm.client_id, message.wm.window_id, message.wm.minimized));
- break;
- case WSAPI_ClientMessage::Type::WM_StartWindowResize:
- CEventLoop::current().post_event(*this, make<WSWMAPIStartWindowResizeRequest>(client_id(), message.wm.client_id, message.wm.window_id));
- break;
- case WSAPI_ClientMessage::Type::WM_PopupWindowMenu:
- CEventLoop::current().post_event(*this, make<WSWMAPIPopupWindowMenuRequest>(client_id(), message.wm.client_id, message.wm.window_id, message.wm.position));
- break;
- case WSAPI_ClientMessage::Type::MoveWindowToFront:
- CEventLoop::current().post_event(*this, make<WSAPIMoveWindowToFrontRequest>(client_id(), message.window_id));
- break;
- case WSAPI_ClientMessage::Type::SetFullscreen:
- CEventLoop::current().post_event(*this, make<WSAPISetFullscreenRequest>(client_id(), message.window_id, message.value));
- break;
- default:
- break;
- }
- return true;
-}
-
-void WSClientConnection::handle_request(const WSAPICreateMenubarRequest&)
+OwnPtr<WindowServer::CreateMenubarResponse> WSClientConnection::handle(const WindowServer::CreateMenubar&)
{
int menubar_id = m_next_menubar_id++;
auto menubar = make<WSMenuBar>(*this, menubar_id);
m_menubars.set(menubar_id, move(menubar));
- WSAPI_ServerMessage response;
- response.type = WSAPI_ServerMessage::Type::DidCreateMenubar;
- response.menu.menubar_id = menubar_id;
- post_message(response);
+ return make<WindowServer::CreateMenubarResponse>(menubar_id);
}
-void WSClientConnection::handle_request(const WSAPIDestroyMenubarRequest& request)
+OwnPtr<WindowServer::DestroyMenubarResponse> WSClientConnection::handle(const WindowServer::DestroyMenubar& message)
{
- int menubar_id = request.menubar_id();
+ int menubar_id = message.menubar_id();
auto it = m_menubars.find(menubar_id);
if (it == m_menubars.end()) {
post_error("WSAPIDestroyMenubarRequest: Bad menubar ID");
- return;
+ return make<WindowServer::DestroyMenubarResponse>();
}
auto& menubar = *(*it).value;
WSWindowManager::the().close_menubar(menubar);
m_menubars.remove(it);
- WSAPI_ServerMessage response;
- response.type = WSAPI_ServerMessage::Type::DidDestroyMenubar;
- response.menu.menubar_id = menubar_id;
- post_message(response);
+ return make<WindowServer::DestroyMenubarResponse>();
}
-void WSClientConnection::handle_request(const WSAPICreateMenuRequest& request)
+OwnPtr<WindowServer::CreateMenuResponse> WSClientConnection::handle(const WindowServer::CreateMenu& message)
{
int menu_id = m_next_menu_id++;
- auto menu = WSMenu::construct(this, menu_id, request.text());
+ auto menu = WSMenu::construct(this, menu_id, message.menu_title());
m_menus.set(menu_id, move(menu));
- WSAPI_ServerMessage response;
- response.type = WSAPI_ServerMessage::Type::DidCreateMenu;
- response.menu.menu_id = menu_id;
- post_message(response);
+ dbg() << "Created menu ID " << menu_id << " (" << message.menu_title() << ")";
+ return make<WindowServer::CreateMenuResponse>(menu_id);
}
-void WSClientConnection::handle_request(const WSAPIDestroyMenuRequest& request)
+OwnPtr<WindowServer::DestroyMenuResponse> WSClientConnection::handle(const WindowServer::DestroyMenu& message)
{
- int menu_id = static_cast<const WSAPIDestroyMenuRequest&>(request).menu_id();
+ int menu_id = message.menu_id();
auto it = m_menus.find(menu_id);
if (it == m_menus.end()) {
post_error("WSAPIDestroyMenuRequest: Bad menu ID");
- return;
+ return make<WindowServer::DestroyMenuResponse>();
}
auto& menu = *(*it).value;
menu.close();
m_menus.remove(it);
remove_child(menu);
- WSAPI_ServerMessage response;
- response.type = WSAPI_ServerMessage::Type::DidDestroyMenu;
- response.menu.menu_id = menu_id;
- post_message(response);
+ return make<WindowServer::DestroyMenuResponse>();
}
-void WSClientConnection::handle_request(const WSAPISetApplicationMenubarRequest& request)
+OwnPtr<WindowServer::SetApplicationMenubarResponse> WSClientConnection::handle(const WindowServer::SetApplicationMenubar& message)
{
- int menubar_id = request.menubar_id();
+ int menubar_id = message.menubar_id();
auto it = m_menubars.find(menubar_id);
if (it == m_menubars.end()) {
post_error("WSAPISetApplicationMenubarRequest: Bad menubar ID");
- return;
+ return make<WindowServer::SetApplicationMenubarResponse>();
}
auto& menubar = *(*it).value;
m_app_menubar = menubar.make_weak_ptr();
WSWindowManager::the().notify_client_changed_app_menubar(*this);
- WSAPI_ServerMessage response;
- response.type = WSAPI_ServerMessage::Type::DidSetApplicationMenubar;
- response.menu.menubar_id = menubar_id;
- post_message(response);
+ return make<WindowServer::SetApplicationMenubarResponse>();
}
-void WSClientConnection::handle_request(const WSAPIAddMenuToMenubarRequest& request)
+OwnPtr<WindowServer::AddMenuToMenubarResponse> WSClientConnection::handle(const WindowServer::AddMenuToMenubar& message)
{
- int menubar_id = request.menubar_id();
- int menu_id = request.menu_id();
+ int menubar_id = message.menubar_id();
+ int menu_id = message.menu_id();
auto it = m_menubars.find(menubar_id);
auto jt = m_menus.find(menu_id);
if (it == m_menubars.end()) {
post_error("WSAPIAddMenuToMenubarRequest: Bad menubar ID");
- return;
+ return make<WindowServer::AddMenuToMenubarResponse>();
}
if (jt == m_menus.end()) {
post_error("WSAPIAddMenuToMenubarRequest: Bad menu ID");
- return;
+ return make<WindowServer::AddMenuToMenubarResponse>();
}
auto& menubar = *(*it).value;
auto& menu = *(*jt).value;
menubar.add_menu(menu);
- WSAPI_ServerMessage response;
- response.type = WSAPI_ServerMessage::Type::DidAddMenuToMenubar;
- response.menu.menubar_id = menubar_id;
- response.menu.menu_id = menu_id;
- post_message(response);
+ return make<WindowServer::AddMenuToMenubarResponse>();
}
-void WSClientConnection::handle_request(const WSAPIAddMenuItemRequest& request)
+OwnPtr<WindowServer::AddMenuItemResponse> WSClientConnection::handle(const WindowServer::AddMenuItem& message)
{
- int menu_id = request.menu_id();
- unsigned identifier = request.identifier();
+ int menu_id = message.menu_id();
+ unsigned identifier = message.identifier();
auto it = m_menus.find(menu_id);
if (it == m_menus.end()) {
- post_error("WSAPIAddMenuItemRequest: Bad menu ID");
- return;
+ dbg() << "WSAPIAddMenuItemRequest: Bad menu ID: " << menu_id;
+ return make<WindowServer::AddMenuItemResponse>();
}
auto& menu = *(*it).value;
- auto menu_item = make<WSMenuItem>(menu, identifier, request.text(), request.shortcut_text(), request.is_enabled(), request.is_checkable(), request.is_checked());
- if (request.icon_buffer_id() != -1) {
- auto icon_buffer = SharedBuffer::create_from_shared_buffer_id(request.icon_buffer_id());
+ auto menu_item = make<WSMenuItem>(menu, identifier, message.text(), message.shortcut(), message.enabled(), message.checkable(), message.checked());
+ if (message.icon_buffer_id() != -1) {
+ auto icon_buffer = SharedBuffer::create_from_shared_buffer_id(message.icon_buffer_id());
if (!icon_buffer) {
did_misbehave();
- return;
+ return make<WindowServer::AddMenuItemResponse>();
}
// FIXME: Verify that the icon buffer can accomodate a 16x16 bitmap view.
auto shared_icon = GraphicsBitmap::create_with_shared_buffer(GraphicsBitmap::Format::RGBA32, icon_buffer.release_nonnull(), { 16, 16 });
menu_item->set_icon(shared_icon);
}
- menu_item->set_submenu_id(request.submenu_id());
+ menu_item->set_submenu_id(message.submenu_id());
menu.add_item(move(menu_item));
- WSAPI_ServerMessage response;
- response.type = WSAPI_ServerMessage::Type::DidAddMenuItem;
- response.menu.menu_id = menu_id;
- response.menu.identifier = identifier;
- post_message(response);
+ return make<WindowServer::AddMenuItemResponse>();
}
-void WSClientConnection::handle_request(const WSAPIPopupMenuRequest& request)
+OwnPtr<WindowServer::PopupMenuResponse> WSClientConnection::handle(const WindowServer::PopupMenu& message)
{
- int menu_id = request.menu_id();
- auto position = request.position();
+ int menu_id = message.menu_id();
+ auto position = message.screen_position();
auto it = m_menus.find(menu_id);
if (it == m_menus.end()) {
post_error("WSAPIPopupMenuRequest: Bad menu ID");
- return;
+ return make<WindowServer::PopupMenuResponse>();
}
auto& menu = *(*it).value;
menu.popup(position);
+ return make<WindowServer::PopupMenuResponse>();
}
-void WSClientConnection::handle_request(const WSAPIDismissMenuRequest& request)
+OwnPtr<WindowServer::DismissMenuResponse> WSClientConnection::handle(const WindowServer::DismissMenu& message)
{
- int menu_id = request.menu_id();
+ int menu_id = message.menu_id();
auto it = m_menus.find(menu_id);
if (it == m_menus.end()) {
post_error("WSAPIDismissMenuRequest: Bad menu ID");
- return;
+ return make<WindowServer::DismissMenuResponse>();
}
auto& menu = *(*it).value;
menu.close();
+ return make<WindowServer::DismissMenuResponse>();
}
-void WSClientConnection::handle_request(const WSAPIUpdateMenuItemRequest& request)
+OwnPtr<WindowServer::UpdateMenuItemResponse> WSClientConnection::handle(const WindowServer::UpdateMenuItem& message)
{
- int menu_id = request.menu_id();
- unsigned identifier = request.identifier();
+ int menu_id = message.menu_id();
auto it = m_menus.find(menu_id);
if (it == m_menus.end()) {
post_error("WSAPIUpdateMenuItemRequest: Bad menu ID");
- return;
+ return make<WindowServer::UpdateMenuItemResponse>();
}
auto& menu = *(*it).value;
- auto* menu_item = menu.item_with_identifier(request.identifier());
+ auto* menu_item = menu.item_with_identifier(message.identifier());
if (!menu_item) {
post_error("WSAPIUpdateMenuItemRequest: Bad menu item identifier");
- return;
+ return make<WindowServer::UpdateMenuItemResponse>();
}
- menu_item->set_text(request.text());
- menu_item->set_shortcut_text(request.shortcut_text());
- menu_item->set_enabled(request.is_enabled());
- menu_item->set_checkable(request.is_checkable());
- if (request.is_checkable())
- menu_item->set_checked(request.is_checked());
- WSAPI_ServerMessage response;
- response.type = WSAPI_ServerMessage::Type::DidUpdateMenuItem;
- response.menu.menu_id = menu_id;
- response.menu.identifier = identifier;
- post_message(response);
+ menu_item->set_text(message.text());
+ menu_item->set_shortcut_text(message.shortcut());
+ menu_item->set_enabled(message.enabled());
+ menu_item->set_checkable(message.checkable());
+ if (message.checkable())
+ menu_item->set_checked(message.checked());
+ return make<WindowServer::UpdateMenuItemResponse>();
}
-void WSClientConnection::handle_request(const WSAPIAddMenuSeparatorRequest& request)
+OwnPtr<WindowServer::AddMenuSeparatorResponse> WSClientConnection::handle(const WindowServer::AddMenuSeparator& message)
{
- int menu_id = request.menu_id();
+ int menu_id = message.menu_id();
auto it = m_menus.find(menu_id);
if (it == m_menus.end()) {
post_error("WSAPIAddMenuSeparatorRequest: Bad menu ID");
- return;
+ return make<WindowServer::AddMenuSeparatorResponse>();
}
auto& menu = *(*it).value;
menu.add_item(make<WSMenuItem>(menu, WSMenuItem::Separator));
- WSAPI_ServerMessage response;
- response.type = WSAPI_ServerMessage::Type::DidAddMenuSeparator;
- response.menu.menu_id = menu_id;
- post_message(response);
+ return make<WindowServer::AddMenuSeparatorResponse>();
}
-void WSClientConnection::handle_request(const WSAPIMoveWindowToFrontRequest& request)
+OwnPtr<WindowServer::MoveWindowToFrontResponse> WSClientConnection::handle(const WindowServer::MoveWindowToFront& message)
{
- int window_id = request.window_id();
- auto it = m_windows.find(window_id);
+ auto it = m_windows.find(message.window_id());
if (it == m_windows.end()) {
post_error("WSAPIMoveWindowToFrontRequest: Bad window ID");
- return;
+ return make<WindowServer::MoveWindowToFrontResponse>();
}
- auto& window = *(*it).value;
- WSWindowManager::the().move_to_front_and_make_active(window);
+ WSWindowManager::the().move_to_front_and_make_active(*(*it).value);
+ return make<WindowServer::MoveWindowToFrontResponse>();
}
-void WSClientConnection::handle_request(const WSAPISetFullscreenRequest& request)
+OwnPtr<WindowServer::SetFullscreenResponse> WSClientConnection::handle(const WindowServer::SetFullscreen& message)
{
- int window_id = request.window_id();
- auto it = m_windows.find(window_id);
+ auto it = m_windows.find(message.window_id());
if (it == m_windows.end()) {
post_error("WSAPISetFullscreenRequest: Bad window ID");
- return;
+ return make<WindowServer::SetFullscreenResponse>();
}
- auto& window = *(*it).value;
- window.set_fullscreen(request.fullscreen());
-
- WSAPI_ServerMessage response;
- response.type = WSAPI_ServerMessage::Type::DidSetFullscreen;
- response.window_id = window_id;
- post_message(response);
+ it->value->set_fullscreen(message.fullscreen());
+ return make<WindowServer::SetFullscreenResponse>();
}
-void WSClientConnection::handle_request(const WSAPISetWindowOpacityRequest& request)
+OwnPtr<WindowServer::SetWindowOpacityResponse> WSClientConnection::handle(const WindowServer::SetWindowOpacity& message)
{
- int window_id = request.window_id();
- auto it = m_windows.find(window_id);
+ auto it = m_windows.find(message.window_id());
if (it == m_windows.end()) {
post_error("WSAPISetWindowOpacityRequest: Bad window ID");
- return;
+ return make<WindowServer::SetWindowOpacityResponse>();
}
- auto& window = *(*it).value;
- window.set_opacity(request.opacity());
+ it->value->set_opacity(message.opacity());
+ return make<WindowServer::SetWindowOpacityResponse>();
}
-void WSClientConnection::handle_request(const WSAPISetWallpaperRequest& request)
+void WSClientConnection::handle(const WindowServer::AsyncSetWallpaper& message)
{
- WSCompositor::the().set_wallpaper(request.wallpaper(), [&](bool success) {
- WSAPI_ServerMessage response;
- response.type = WSAPI_ServerMessage::Type::DidSetWallpaper;
- response.value = success;
- post_message(response);
+ WSCompositor::the().set_wallpaper(message.path(), [&](bool success) {
+ post_message(WindowClient::AsyncSetWallpaperFinished(success));
});
}
-void WSClientConnection::handle_request(const WSAPIGetWallpaperRequest&)
+OwnPtr<WindowServer::GetWallpaperResponse> WSClientConnection::handle(const WindowServer::GetWallpaper&)
{
- auto path = WSCompositor::the().wallpaper_path();
- WSAPI_ServerMessage response;
- response.type = WSAPI_ServerMessage::Type::DidGetWallpaper;
- ASSERT(path.length() < (int)sizeof(response.text));
- memcpy(response.text, path.characters(), path.length() + 1);
- response.text_length = path.length();
- post_message(response);
+ return make<WindowServer::GetWallpaperResponse>(WSCompositor::the().wallpaper_path());
}
-void WSClientConnection::handle_request(const WSAPISetResolutionRequest& request)
+OwnPtr<WindowServer::SetResolutionResponse> WSClientConnection::handle(const WindowServer::SetResolution& message)
{
- WSWindowManager::the().set_resolution(request.resolution().width(), request.resolution().height());
- WSAPI_ServerMessage response;
- response.type = WSAPI_ServerMessage::Type::DidSetResolution;
- response.value = true;
- post_message(response);
+ WSWindowManager::the().set_resolution(message.resolution().width(), message.resolution().height());
+ return make<WindowServer::SetResolutionResponse>();
}
-void WSClientConnection::handle_request(const WSAPISetWindowTitleRequest& request)
+OwnPtr<WindowServer::SetWindowTitleResponse> WSClientConnection::handle(const WindowServer::SetWindowTitle& message)
{
- int window_id = request.window_id();
- auto it = m_windows.find(window_id);
+ auto it = m_windows.find(message.window_id());
if (it == m_windows.end()) {
post_error("WSAPISetWindowTitleRequest: Bad window ID");
- return;
+ return make<WindowServer::SetWindowTitleResponse>();
}
- auto& window = *(*it).value;
- window.set_title(request.title());
+ it->value->set_title(message.title());
+ return make<WindowServer::SetWindowTitleResponse>();
}
-void WSClientConnection::handle_request(const WSAPIGetWindowTitleRequest& request)
+OwnPtr<WindowServer::GetWindowTitleResponse> WSClientConnection::handle(const WindowServer::GetWindowTitle& message)
{
- int window_id = request.window_id();
- auto it = m_windows.find(window_id);
+ auto it = m_windows.find(message.window_id());
if (it == m_windows.end()) {
post_error("WSAPIGetWindowTitleRequest: Bad window ID");
- return;
+ return make<WindowServer::GetWindowTitleResponse>("");
}
- auto& window = *(*it).value;
- WSAPI_ServerMessage response;
- response.type = WSAPI_ServerMessage::Type::DidGetWindowTitle;
- response.window_id = window.window_id();
- ASSERT(window.title().length() < (ssize_t)sizeof(response.text));
- strcpy(response.text, window.title().characters());
- response.text_length = window.title().length();
- post_message(response);
+ return make<WindowServer::GetWindowTitleResponse>(it->value->title());
}
-void WSClientConnection::handle_request(const WSAPISetWindowIconBitmapRequest& request)
+OwnPtr<WindowServer::SetWindowIconBitmapResponse> WSClientConnection::handle(const WindowServer::SetWindowIconBitmap& message)
{
- int window_id = request.window_id();
- auto it = m_windows.find(window_id);
+ auto it = m_windows.find(message.window_id());
if (it == m_windows.end()) {
post_error("WSAPISetWindowIconBitmapRequest: Bad window ID");
- return;
+ return make<WindowServer::SetWindowIconBitmapResponse>();
}
auto& window = *(*it).value;
- auto icon_buffer = SharedBuffer::create_from_shared_buffer_id(request.icon_buffer_id());
+ auto icon_buffer = SharedBuffer::create_from_shared_buffer_id(message.icon_buffer_id());
if (!icon_buffer) {
window.set_default_icon();
} else {
- window.set_icon(GraphicsBitmap::create_with_shared_buffer(GraphicsBitmap::Format::RGBA32, *icon_buffer, request.icon_size()));
+ window.set_icon(GraphicsBitmap::create_with_shared_buffer(GraphicsBitmap::Format::RGBA32, *icon_buffer, message.icon_size()));
}
window.frame().invalidate_title_bar();
WSWindowManager::the().tell_wm_listeners_window_icon_changed(window);
+ return make<WindowServer::SetWindowIconBitmapResponse>();
}
-void WSClientConnection::handle_request(const WSAPISetWindowRectRequest& request)
+OwnPtr<WindowServer::SetWindowRectResponse> WSClientConnection::handle(const WindowServer::SetWindowRect& message)
{
- int window_id = request.window_id();
+ int window_id = message.window_id();
auto it = m_windows.find(window_id);
if (it == m_windows.end()) {
post_error("WSAPISetWindowRectRequest: Bad window ID");
- return;
+ return make<WindowServer::SetWindowRectResponse>();
}
auto& window = *(*it).value;
if (window.is_fullscreen()) {
dbgprintf("WSClientConnection: Ignoring SetWindowRect request for fullscreen window\n");
- return;
+ return make<WindowServer::SetWindowRectResponse>();
}
- window.set_rect(request.rect());
- window.request_update(request.rect());
+ window.set_rect(message.rect());
+ window.request_update(message.rect());
+ return make<WindowServer::SetWindowRectResponse>();
}
-void WSClientConnection::handle_request(const WSAPIGetWindowRectRequest& request)
+OwnPtr<WindowServer::GetWindowRectResponse> WSClientConnection::handle(const WindowServer::GetWindowRect& message)
{
- int window_id = request.window_id();
+ int window_id = message.window_id();
auto it = m_windows.find(window_id);
if (it == m_windows.end()) {
post_error("WSAPIGetWindowRectRequest: Bad window ID");
- return;
+ return make<WindowServer::GetWindowRectResponse>(Rect());
}
- auto& window = *(*it).value;
- WSAPI_ServerMessage response;
- response.type = WSAPI_ServerMessage::Type::DidGetWindowRect;
- response.window_id = window.window_id();
- response.window.rect = window.rect();
- post_message(response);
+ return make<WindowServer::GetWindowRectResponse>(it->value->rect());
}
-void WSClientConnection::handle_request(const WSAPISetClipboardContentsRequest& request)
+OwnPtr<WindowServer::SetClipboardContentsResponse> WSClientConnection::handle(const WindowServer::SetClipboardContents& message)
{
- auto shared_buffer = SharedBuffer::create_from_shared_buffer_id(request.shared_buffer_id());
+ auto shared_buffer = SharedBuffer::create_from_shared_buffer_id(message.shared_buffer_id());
if (!shared_buffer) {
post_error("WSAPISetClipboardContentsRequest: Bad shared buffer ID");
- return;
+ return make<WindowServer::SetClipboardContentsResponse>();
}
- WSClipboard::the().set_data(*shared_buffer, request.size(), request.data_type());
- WSAPI_ServerMessage response;
- response.type = WSAPI_ServerMessage::Type::DidSetClipboardContents;
- response.clipboard.shared_buffer_id = shared_buffer->shared_buffer_id();
- post_message(response);
+ WSClipboard::the().set_data(*shared_buffer, message.content_size(), message.content_type());
+ return make<WindowServer::SetClipboardContentsResponse>();
}
-void WSClientConnection::handle_request(const WSAPIGetClipboardContentsRequest&)
+OwnPtr<WindowServer::GetClipboardContentsResponse> WSClientConnection::handle(const WindowServer::GetClipboardContents&)
{
auto& clipboard = WSClipboard::the();
- WSAPI_ServerMessage response;
- response.type = WSAPI_ServerMessage::Type::DidGetClipboardContents;
- response.clipboard.shared_buffer_id = -1;
- response.clipboard.contents_size = 0;
+
+ i32 shared_buffer_id = -1;
if (clipboard.size()) {
// FIXME: Optimize case where an app is copy/pasting within itself.
// We can just reuse the SharedBuffer then, since it will have the same peer PID.
@@ -717,59 +392,47 @@ void WSClientConnection::handle_request(const WSAPIGetClipboardContentsRequest&)
memcpy(shared_buffer->data(), clipboard.data(), clipboard.size());
shared_buffer->seal();
shared_buffer->share_with(client_pid());
- response.clipboard.shared_buffer_id = shared_buffer->shared_buffer_id();
- response.clipboard.contents_size = clipboard.size();
+ shared_buffer_id = shared_buffer->shared_buffer_id();
// FIXME: This is a workaround for the fact that SharedBuffers will go away if neither side is retaining them.
// After we respond to GetClipboardContents, we have to wait for the client to ref the buffer on his side.
m_last_sent_clipboard_content = move(shared_buffer);
}
- ASSERT(clipboard.data_type().length() < (ssize_t)sizeof(response.text));
- if (!clipboard.data_type().is_null())
- strcpy(response.text, clipboard.data_type().characters());
- response.text_length = clipboard.data_type().length();
- post_message(response);
+ return make<WindowServer::GetClipboardContentsResponse>(shared_buffer_id, clipboard.size(), clipboard.data_type());
}
-void WSClientConnection::handle_request(const WSAPICreateWindowRequest& request)
+OwnPtr<WindowServer::CreateWindowResponse> WSClientConnection::handle(const WindowServer::CreateWindow& message)
{
int window_id = m_next_window_id++;
- auto window = WSWindow::construct(*this, request.window_type(), window_id, request.is_modal(), request.is_resizable(), request.is_fullscreen());
- window->set_background_color(request.background_color());
- window->set_has_alpha_channel(request.has_alpha_channel());
- window->set_title(request.title());
- if (!request.is_fullscreen())
- window->set_rect(request.rect());
- window->set_show_titlebar(request.show_titlebar());
- window->set_opacity(request.opacity());
- window->set_size_increment(request.size_increment());
- window->set_base_size(request.base_size());
+ auto window = WSWindow::construct(*this, (WSWindowType)message.type(), window_id, message.modal(), message.resizable(), message.fullscreen());
+ window->set_background_color(message.background_color());
+ window->set_has_alpha_channel(message.has_alpha_channel());
+ window->set_title(message.title());
+ if (!message.fullscreen())
+ window->set_rect(message.rect());
+ window->set_show_titlebar(message.show_titlebar());
+ window->set_opacity(message.opacity());
+ window->set_size_increment(message.size_increment());
+ window->set_base_size(message.base_size());
window->invalidate();
m_windows.set(window_id, move(window));
- WSAPI_ServerMessage response;
- response.type = WSAPI_ServerMessage::Type::DidCreateWindow;
- response.window_id = window_id;
- post_message(response);
+ return make<WindowServer::CreateWindowResponse>(window_id);
}
-void WSClientConnection::handle_request(const WSAPIDestroyWindowRequest& request)
+OwnPtr<WindowServer::DestroyWindowResponse> WSClientConnection::handle(const WindowServer::DestroyWindow& message)
{
- int window_id = request.window_id();
- auto it = m_windows.find(window_id);
+ auto it = m_windows.find(message.window_id());
if (it == m_windows.end()) {
post_error("WSAPIDestroyWindowRequest: Bad window ID");
- return;
+ return make<WindowServer::DestroyWindowResponse>();
}
auto& window = *(*it).value;
WSWindowManager::the().invalidate(window);
- WSAPI_ServerMessage response;
- response.type = WSAPI_ServerMessage::Type::DidDestroyWindow;
- response.window_id = window.window_id();
- post_message(response);
-
remove_child(window);
ASSERT(it->value.ptr() == &window);
- m_windows.remove(window_id);
+ m_windows.remove(message.window_id());
+
+ return make<WindowServer::DestroyWindowResponse>();
}
void WSClientConnection::post_paint_message(WSWindow& window)
@@ -777,130 +440,113 @@ void WSClientConnection::post_paint_message(WSWindow& window)
auto rect_set = window.take_pending_paint_rects();
if (window.is_minimized())
return;
- WSAPI_ServerMessage message;
- message.type = WSAPI_ServerMessage::Type::Paint;
- message.window_id = window.window_id();
- auto& rects = rect_set.rects();
- message.rect_count = rects.size();
- for (int i = 0; i < min(WSAPI_ServerMessage::max_inline_rect_count, rects.size()); ++i)
- message.rects[i] = rects[i];
- message.paint.window_size = window.size();
- ByteBuffer extra_data;
- if (rects.size() > WSAPI_ServerMessage::max_inline_rect_count)
- extra_data = ByteBuffer::wrap(&rects[WSAPI_ServerMessage::max_inline_rect_count], (rects.size() - WSAPI_ServerMessage::max_inline_rect_count) * sizeof(WSAPI_Rect));
- post_message(message, extra_data);
+
+ Vector<Rect> rects;
+ rects.ensure_capacity(rect_set.size());
+ for (auto& r : rect_set.rects()) {
+ rects.append(r);
+ }
+ post_message(WindowClient::Paint(window.window_id(), window.size(), rects));
}
-void WSClientConnection::handle_request(const WSAPIInvalidateRectRequest& request)
+void WSClientConnection::handle(const WindowServer::InvalidateRect& message)
{
- int window_id = request.window_id();
- auto it = m_windows.find(window_id);
+ auto it = m_windows.find(message.window_id());
if (it == m_windows.end()) {
post_error("WSAPIInvalidateRectRequest: Bad window ID");
return;
}
auto& window = *(*it).value;
- for (int i = 0; i < request.rects().size(); ++i)
- window.request_update(request.rects()[i].intersected({ {}, window.size() }));
+ for (int i = 0; i < message.rects().size(); ++i)
+ window.request_update(message.rects()[i].intersected({ {}, window.size() }));
}
-void WSClientConnection::handle_request(const WSAPIDidFinishPaintingNotification& request)
+void WSClientConnection::handle(const WindowServer::DidFinishPainting& message)
{
- int window_id = request.window_id();
+ int window_id = message.window_id();
auto it = m_windows.find(window_id);
if (it == m_windows.end()) {
post_error("WSAPIDidFinishPaintingNotification: Bad window ID");
return;
}
auto& window = *(*it).value;
- for (auto& rect : request.rects())
+ for (auto& rect : message.rects())
WSWindowManager::the().invalidate(window, rect);
WSWindowSwitcher::the().refresh_if_needed();
}
-void WSClientConnection::handle_request(const WSAPISetWindowBackingStoreRequest& request)
+OwnPtr<WindowServer::SetWindowBackingStoreResponse> WSClientConnection::handle(const WindowServer::SetWindowBackingStore& message)
{
- int window_id = request.window_id();
+ int window_id = message.window_id();
auto it = m_windows.find(window_id);
if (it == m_windows.end()) {
post_error("WSAPISetWindowBackingStoreRequest: Bad window ID");
- return;
+ return make<WindowServer::SetWindowBackingStoreResponse>();
}
auto& window = *(*it).value;
- if (window.last_backing_store() && window.last_backing_store()->shared_buffer_id() == request.shared_buffer_id()) {
+ if (window.last_backing_store() && window.last_backing_store()->shared_buffer_id() == message.shared_buffer_id()) {
window.swap_backing_stores();
} else {
- auto shared_buffer = SharedBuffer::create_from_shared_buffer_id(request.shared_buffer_id());
+ auto shared_buffer = SharedBuffer::create_from_shared_buffer_id(message.shared_buffer_id());
if (!shared_buffer)
- return;
+ return make<WindowServer::SetWindowBackingStoreResponse>();
auto backing_store = GraphicsBitmap::create_with_shared_buffer(
- request.has_alpha_channel() ? GraphicsBitmap::Format::RGBA32 : GraphicsBitmap::Format::RGB32,
+ message.has_alpha_channel() ? GraphicsBitmap::Format::RGBA32 : GraphicsBitmap::Format::RGB32,
*shared_buffer,
- request.size());
+ message.size());
window.set_backing_store(move(backing_store));
}
- if (request.flush_immediately())
+ if (message.flush_immediately())
window.invalidate();
- WSAPI_ServerMessage response;
- response.type = WSAPI_ServerMessage::Type::DidSetWindowBackingStore;
- response.window_id = window_id;
- response.backing.shared_buffer_id = request.shared_buffer_id();
- post_message(response);
+ return make<WindowServer::SetWindowBackingStoreResponse>();
}
-void WSClientConnection::handle_request(const WSAPISetGlobalCursorTrackingRequest& request)
+OwnPtr<WindowServer::SetGlobalCursorTrackingResponse> WSClientConnection::handle(const WindowServer::SetGlobalCursorTracking& message)
{
- int window_id = request.window_id();
+ int window_id = message.window_id();
auto it = m_windows.find(window_id);
if (it == m_windows.end()) {
post_error("WSAPISetGlobalCursorTrackingRequest: Bad window ID");
- return;
+ return make<WindowServer::SetGlobalCursorTrackingResponse>();
}
- auto& window = *(*it).value;
- window.set_global_cursor_tracking_enabled(request.value());
+ it->value->set_global_cursor_tracking_enabled(message.enabled());
+ return make<WindowServer::SetGlobalCursorTrackingResponse>();
}
-void WSClientConnection::handle_request(const WSAPISetWindowOverrideCursorRequest& request)
+OwnPtr<WindowServer::SetWindowOverrideCursorResponse> WSClientConnection::handle(const WindowServer::SetWindowOverrideCursor& message)
{
- int window_id = request.window_id();
- auto it = m_windows.find(window_id);
+ auto it = m_windows.find(message.window_id());
if (it == m_windows.end()) {
post_error("WSAPISetWindowOverrideCursorRequest: Bad window ID");
- return;
+ return make<WindowServer::SetWindowOverrideCursorResponse>();
}
auto& window = *(*it).value;
- window.set_override_cursor(WSCursor::create(request.cursor()));
+ window.set_override_cursor(WSCursor::create((WSStandardCursor)message.cursor_type()));
+ return make<WindowServer::SetWindowOverrideCursorResponse>();
}
-void WSClientConnection::handle_request(const WSAPISetWindowHasAlphaChannelRequest& request)
+OwnPtr<WindowServer::SetWindowHasAlphaChannelResponse> WSClientConnection::handle(const WindowServer::SetWindowHasAlphaChannel& message)
{
- int window_id = request.window_id();
- auto it = m_windows.find(window_id);
+ auto it = m_windows.find(message.window_id());
if (it == m_windows.end()) {
post_error("WSAPISetWindowHasAlphaChannelRequest: Bad window ID");
- return;
+ return make<WindowServer::SetWindowHasAlphaChannelResponse>();
}
- auto& window = *(*it).value;
- window.set_has_alpha_channel(request.value());
-
- WSAPI_ServerMessage response;
- response.type = WSAPI_ServerMessage::Type::DidSetWindowHasAlphaChannel;
- response.window_id = window_id;
- response.value = request.value();
- post_message(response);
+ it->value->set_has_alpha_channel(message.has_alpha_channel());
+ return make<WindowServer::SetWindowHasAlphaChannelResponse>();
}
-void WSClientConnection::handle_request(const WSWMAPISetActiveWindowRequest& request)
+void WSClientConnection::handle(const WindowServer::WM_SetActiveWindow& message)
{
- auto* client = WSClientConnection::from_client_id(request.target_client_id());
+ auto* client = WSClientConnection::from_client_id(message.client_id());
if (!client) {
post_error("WSWMAPISetActiveWindowRequest: Bad client ID");
return;
}
- auto it = client->m_windows.find(request.target_window_id());
+ auto it = client->m_windows.find(message.window_id());
if (it == client->m_windows.end()) {
post_error("WSWMAPISetActiveWindowRequest: Bad window ID");
return;
@@ -910,30 +556,30 @@ void WSClientConnection::handle_request(const WSWMAPISetActiveWindowRequest& req
WSWindowManager::the().move_to_front_and_make_active(window);
}
-void WSClientConnection::handle_request(const WSWMAPIPopupWindowMenuRequest& request)
+void WSClientConnection::handle(const WindowServer::WM_PopupWindowMenu& message)
{
- auto* client = WSClientConnection::from_client_id(request.target_client_id());
+ auto* client = WSClientConnection::from_client_id(message.client_id());
if (!client) {
post_error("WSWMAPIPopupWindowMenuRequest: Bad client ID");
return;
}
- auto it = client->m_windows.find(request.target_window_id());
+ auto it = client->m_windows.find(message.window_id());
if (it == client->m_windows.end()) {
post_error("WSWMAPIPopupWindowMenuRequest: Bad window ID");
return;
}
auto& window = *(*it).value;
- window.popup_window_menu(request.position());
+ window.popup_window_menu(message.screen_position());
}
-void WSClientConnection::handle_request(const WSWMAPIStartWindowResizeRequest& request)
+void WSClientConnection::handle(const WindowServer::WM_StartWindowResize& request)
{
- auto* client = WSClientConnection::from_client_id(request.target_client_id());
+ auto* client = WSClientConnection::from_client_id(request.client_id());
if (!client) {
post_error("WSWMAPIStartWindowResizeRequest: Bad client ID");
return;
}
- auto it = client->m_windows.find(request.target_window_id());
+ auto it = client->m_windows.find(request.window_id());
if (it == client->m_windows.end()) {
post_error("WSWMAPIStartWindowResizeRequest: Bad window ID");
return;
@@ -944,100 +590,26 @@ void WSClientConnection::handle_request(const WSWMAPIStartWindowResizeRequest& r
WSWindowManager::the().start_window_resize(window, WSScreen::the().cursor_location(), MouseButton::Left);
}
-void WSClientConnection::handle_request(const WSWMAPISetWindowMinimizedRequest& request)
+void WSClientConnection::handle(const WindowServer::WM_SetWindowMinimized& message)
{
- auto* client = WSClientConnection::from_client_id(request.target_client_id());
+ auto* client = WSClientConnection::from_client_id(message.client_id());
if (!client) {
post_error("WSWMAPISetWindowMinimizedRequest: Bad client ID");
return;
}
- auto it = client->m_windows.find(request.target_window_id());
+ auto it = client->m_windows.find(message.window_id());
if (it == client->m_windows.end()) {
post_error("WSWMAPISetWindowMinimizedRequest: Bad window ID");
return;
}
auto& window = *(*it).value;
- window.set_minimized(request.is_minimized());
+ window.set_minimized(message.minimized());
}
-void WSClientConnection::on_request(const WSAPIClientRequest& request)
+OwnPtr<WindowServer::GreetResponse> WSClientConnection::handle(const WindowServer::Greet& message)
{
- switch (request.type()) {
- case WSEvent::APICreateMenubarRequest:
- return handle_request(static_cast<const WSAPICreateMenubarRequest&>(request));
- case WSEvent::APIDestroyMenubarRequest:
- return handle_request(static_cast<const WSAPIDestroyMenubarRequest&>(request));
- case WSEvent::APICreateMenuRequest:
- return handle_request(static_cast<const WSAPICreateMenuRequest&>(request));
- case WSEvent::APIDestroyMenuRequest:
- return handle_request(static_cast<const WSAPIDestroyMenuRequest&>(request));
- case WSEvent::APISetApplicationMenubarRequest:
- return handle_request(static_cast<const WSAPISetApplicationMenubarRequest&>(request));
- case WSEvent::APIAddMenuToMenubarRequest:
- return handle_request(static_cast<const WSAPIAddMenuToMenubarRequest&>(request));
- case WSEvent::APIAddMenuItemRequest:
- return handle_request(static_cast<const WSAPIAddMenuItemRequest&>(request));
- case WSEvent::APIAddMenuSeparatorRequest:
- return handle_request(static_cast<const WSAPIAddMenuSeparatorRequest&>(request));
- case WSEvent::APIUpdateMenuItemRequest:
- return handle_request(static_cast<const WSAPIUpdateMenuItemRequest&>(request));
- case WSEvent::APISetWindowTitleRequest:
- return handle_request(static_cast<const WSAPISetWindowTitleRequest&>(request));
- case WSEvent::APIGetWindowTitleRequest:
- return handle_request(static_cast<const WSAPIGetWindowTitleRequest&>(request));
- case WSEvent::APISetWindowRectRequest:
- return handle_request(static_cast<const WSAPISetWindowRectRequest&>(request));
- case WSEvent::APIGetWindowRectRequest:
- return handle_request(static_cast<const WSAPIGetWindowRectRequest&>(request));
- case WSEvent::APISetWindowIconBitmapRequest:
- return handle_request(static_cast<const WSAPISetWindowIconBitmapRequest&>(request));
- case WSEvent::APISetClipboardContentsRequest:
- return handle_request(static_cast<const WSAPISetClipboardContentsRequest&>(request));
- case WSEvent::APIGetClipboardContentsRequest:
- return handle_request(static_cast<const WSAPIGetClipboardContentsRequest&>(request));
- case WSEvent::APICreateWindowRequest:
- return handle_request(static_cast<const WSAPICreateWindowRequest&>(request));
- case WSEvent::APIDestroyWindowRequest:
- return handle_request(static_cast<const WSAPIDestroyWindowRequest&>(request));
- case WSEvent::APIInvalidateRectRequest:
- return handle_request(static_cast<const WSAPIInvalidateRectRequest&>(request));
- case WSEvent::APIDidFinishPaintingNotification:
- return handle_request(static_cast<const WSAPIDidFinishPaintingNotification&>(request));
- case WSEvent::APISetGlobalCursorTrackingRequest:
- return handle_request(static_cast<const WSAPISetGlobalCursorTrackingRequest&>(request));
- case WSEvent::APISetWindowOpacityRequest:
- return handle_request(static_cast<const WSAPISetWindowOpacityRequest&>(request));
- case WSEvent::APISetWindowBackingStoreRequest:
- return handle_request(static_cast<const WSAPISetWindowBackingStoreRequest&>(request));
- case WSEvent::APISetWallpaperRequest:
- return handle_request(static_cast<const WSAPISetWallpaperRequest&>(request));
- case WSEvent::APIGetWallpaperRequest:
- return handle_request(static_cast<const WSAPIGetWallpaperRequest&>(request));
- case WSEvent::APISetResolutionRequest:
- return handle_request(static_cast<const WSAPISetResolutionRequest&>(request));
- case WSEvent::APISetWindowOverrideCursorRequest:
- return handle_request(static_cast<const WSAPISetWindowOverrideCursorRequest&>(request));
- case WSEvent::WMAPISetActiveWindowRequest:
- return handle_request(static_cast<const WSWMAPISetActiveWindowRequest&>(request));
- case WSEvent::WMAPISetWindowMinimizedRequest:
- return handle_request(static_cast<const WSWMAPISetWindowMinimizedRequest&>(request));
- case WSEvent::WMAPIStartWindowResizeRequest:
- return handle_request(static_cast<const WSWMAPIStartWindowResizeRequest&>(request));
- case WSEvent::WMAPIPopupWindowMenuRequest:
- return handle_request(static_cast<const WSWMAPIPopupWindowMenuRequest&>(request));
- case WSEvent::APIPopupMenuRequest:
- return handle_request(static_cast<const WSAPIPopupMenuRequest&>(request));
- case WSEvent::APIDismissMenuRequest:
- return handle_request(static_cast<const WSAPIDismissMenuRequest&>(request));
- case WSEvent::APISetWindowHasAlphaChannelRequest:
- return handle_request(static_cast<const WSAPISetWindowHasAlphaChannelRequest&>(request));
- case WSEvent::APIMoveWindowToFrontRequest:
- return handle_request(static_cast<const WSAPIMoveWindowToFrontRequest&>(request));
- case WSEvent::APISetFullscreenRequest:
- return handle_request(static_cast<const WSAPISetFullscreenRequest&>(request));
- default:
- break;
- }
+ set_client_pid(message.client_pid());
+ return make<WindowServer::GreetResponse>(getpid(), client_id(), WSScreen::the().rect());
}
bool WSClientConnection::is_showing_modal_window() const
diff --git a/Servers/WindowServer/WSClientConnection.h b/Servers/WindowServer/WSClientConnection.h
index 1cef9072b3..adbd64b901 100644
--- a/Servers/WindowServer/WSClientConnection.h
+++ b/Servers/WindowServer/WSClientConnection.h
@@ -7,20 +7,20 @@
#include <LibCore/CObject.h>
#include <LibCore/CoreIPCServer.h>
#include <LibDraw/GraphicsBitmap.h>
-#include <WindowServer/WSAPITypes.h>
#include <WindowServer/WSEvent.h>
+#include <WindowServer/WindowServerEndpoint.h>
class WSWindow;
class WSMenu;
class WSMenuBar;
-class WSClientConnection final : public IPC::Server::Connection<WSAPI_ServerMessage, WSAPI_ClientMessage> {
+class WSClientConnection final
+ : public IPC::Server::ConnectionNG<WindowServerEndpoint>
+ , public WindowServerEndpoint {
C_OBJECT(WSClientConnection)
public:
~WSClientConnection() override;
- virtual void send_greeting() override;
virtual void die() override;
- bool handle_message(const WSAPI_ClientMessage&, const ByteBuffer&& = {}) override;
static WSClientConnection* from_client_id(int client_id);
static void for_each_client(Function<void(WSClientConnection&)>);
@@ -48,45 +48,44 @@ public:
private:
explicit WSClientConnection(CLocalSocket&, int client_id);
- virtual void event(CEvent&) override;
-
- void on_request(const WSAPIClientRequest&);
- void handle_request(const WSAPICreateMenubarRequest&);
- void handle_request(const WSAPIDestroyMenubarRequest&);
- void handle_request(const WSAPICreateMenuRequest&);
- void handle_request(const WSAPIDestroyMenuRequest&);
- void handle_request(const WSAPISetApplicationMenubarRequest&);
- void handle_request(const WSAPIAddMenuToMenubarRequest&);
- void handle_request(const WSAPIAddMenuItemRequest&);
- void handle_request(const WSAPIUpdateMenuItemRequest&);
- void handle_request(const WSAPIAddMenuSeparatorRequest&);
- void handle_request(const WSAPISetWindowTitleRequest&);
- void handle_request(const WSAPIGetWindowTitleRequest&);
- void handle_request(const WSAPISetWindowRectRequest&);
- void handle_request(const WSAPIGetWindowRectRequest&);
- void handle_request(const WSAPISetWindowIconBitmapRequest&);
- void handle_request(const WSAPISetClipboardContentsRequest&);
- void handle_request(const WSAPIGetClipboardContentsRequest&);
- void handle_request(const WSAPICreateWindowRequest&);
- void handle_request(const WSAPIDestroyWindowRequest&);
- void handle_request(const WSAPIInvalidateRectRequest&);
- void handle_request(const WSAPIDidFinishPaintingNotification&);
- void handle_request(const WSAPISetWindowBackingStoreRequest&);
- void handle_request(const WSAPISetGlobalCursorTrackingRequest&);
- void handle_request(const WSAPISetWindowOpacityRequest&);
- void handle_request(const WSAPISetWallpaperRequest&);
- void handle_request(const WSAPIGetWallpaperRequest&);
- void handle_request(const WSAPISetResolutionRequest&);
- void handle_request(const WSAPISetWindowOverrideCursorRequest&);
- void handle_request(const WSWMAPISetActiveWindowRequest&);
- void handle_request(const WSWMAPISetWindowMinimizedRequest&);
- void handle_request(const WSWMAPIStartWindowResizeRequest&);
- void handle_request(const WSWMAPIPopupWindowMenuRequest&);
- void handle_request(const WSAPIPopupMenuRequest&);
- void handle_request(const WSAPIDismissMenuRequest&);
- void handle_request(const WSAPISetWindowHasAlphaChannelRequest&);
- void handle_request(const WSAPIMoveWindowToFrontRequest&);
- void handle_request(const WSAPISetFullscreenRequest&);
+
+ virtual OwnPtr<WindowServer::GreetResponse> handle(const WindowServer::Greet&) override;
+ virtual OwnPtr<WindowServer::CreateMenubarResponse> handle(const WindowServer::CreateMenubar&) override;
+ virtual OwnPtr<WindowServer::DestroyMenubarResponse> handle(const WindowServer::DestroyMenubar&) override;
+ virtual OwnPtr<WindowServer::CreateMenuResponse> handle(const WindowServer::CreateMenu&) override;
+ virtual OwnPtr<WindowServer::DestroyMenuResponse> handle(const WindowServer::DestroyMenu&) override;
+ virtual OwnPtr<WindowServer::AddMenuToMenubarResponse> handle(const WindowServer::AddMenuToMenubar&) override;
+ virtual OwnPtr<WindowServer::SetApplicationMenubarResponse> handle(const WindowServer::SetApplicationMenubar&) override;
+ virtual OwnPtr<WindowServer::AddMenuItemResponse> handle(const WindowServer::AddMenuItem&) override;
+ virtual OwnPtr<WindowServer::AddMenuSeparatorResponse> handle(const WindowServer::AddMenuSeparator&) override;
+ virtual OwnPtr<WindowServer::UpdateMenuItemResponse> handle(const WindowServer::UpdateMenuItem&) override;
+ virtual OwnPtr<WindowServer::CreateWindowResponse> handle(const WindowServer::CreateWindow&) override;
+ virtual OwnPtr<WindowServer::DestroyWindowResponse> handle(const WindowServer::DestroyWindow&) override;
+ virtual OwnPtr<WindowServer::SetWindowTitleResponse> handle(const WindowServer::SetWindowTitle&) override;
+ virtual OwnPtr<WindowServer::GetWindowTitleResponse> handle(const WindowServer::GetWindowTitle&) override;
+ virtual OwnPtr<WindowServer::SetWindowRectResponse> handle(const WindowServer::SetWindowRect&) override;
+ virtual OwnPtr<WindowServer::GetWindowRectResponse> handle(const WindowServer::GetWindowRect&) override;
+ virtual void handle(const WindowServer::InvalidateRect&) override;
+ virtual void handle(const WindowServer::DidFinishPainting&) override;
+ virtual OwnPtr<WindowServer::SetGlobalCursorTrackingResponse> handle(const WindowServer::SetGlobalCursorTracking&) override;
+ virtual OwnPtr<WindowServer::SetWindowOpacityResponse> handle(const WindowServer::SetWindowOpacity&) override;
+ virtual OwnPtr<WindowServer::SetWindowBackingStoreResponse> handle(const WindowServer::SetWindowBackingStore&) override;
+ virtual OwnPtr<WindowServer::GetClipboardContentsResponse> handle(const WindowServer::GetClipboardContents&) override;
+ virtual OwnPtr<WindowServer::SetClipboardContentsResponse> handle(const WindowServer::SetClipboardContents&) override;
+ virtual void handle(const WindowServer::WM_SetActiveWindow&) override;
+ virtual void handle(const WindowServer::WM_SetWindowMinimized&) override;
+ virtual void handle(const WindowServer::WM_StartWindowResize&) override;
+ virtual void handle(const WindowServer::WM_PopupWindowMenu&) override;
+ virtual OwnPtr<WindowServer::SetWindowHasAlphaChannelResponse> handle(const WindowServer::SetWindowHasAlphaChannel&) override;
+ virtual OwnPtr<WindowServer::MoveWindowToFrontResponse> handle(const WindowServer::MoveWindowToFront&) override;
+ virtual OwnPtr<WindowServer::SetFullscreenResponse> handle(const WindowServer::SetFullscreen&) override;
+ virtual void handle(const WindowServer::AsyncSetWallpaper&) override;
+ virtual OwnPtr<WindowServer::GetWallpaperResponse> handle(const WindowServer::GetWallpaper&) override;
+ virtual OwnPtr<WindowServer::SetResolutionResponse> handle(const WindowServer::SetResolution&) override;
+ virtual OwnPtr<WindowServer::SetWindowOverrideCursorResponse> handle(const WindowServer::SetWindowOverrideCursor&) override;
+ virtual OwnPtr<WindowServer::PopupMenuResponse> handle(const WindowServer::PopupMenu&) override;
+ virtual OwnPtr<WindowServer::DismissMenuResponse> handle(const WindowServer::DismissMenu&) override;
+ virtual OwnPtr<WindowServer::SetWindowIconBitmapResponse> handle(const WindowServer::SetWindowIconBitmap&) override;
void post_error(const String&);
diff --git a/Servers/WindowServer/WSEvent.h b/Servers/WindowServer/WSEvent.h
index 6059c784d1..0ad51bd7d6 100644
--- a/Servers/WindowServer/WSEvent.h
+++ b/Servers/WindowServer/WSEvent.h
@@ -1,13 +1,10 @@
#pragma once
#include <AK/String.h>
-#include <AK/Types.h>
#include <Kernel/KeyCode.h>
#include <LibCore/CEvent.h>
-#include <LibDraw/Point.h>
#include <LibDraw/Rect.h>
#include <WindowServer/WSCursor.h>
-#include <WindowServer/WSAPITypes.h>
#include <WindowServer/WSWindowType.h>
class WSEvent : public CEvent {
@@ -33,45 +30,6 @@ public:
WM_WindowStateChanged,
WM_WindowRectChanged,
WM_WindowIconBitmapChanged,
-
- __Begin_API_Client_Requests,
- APICreateMenubarRequest,
- APIDestroyMenubarRequest,
- APIAddMenuToMenubarRequest,
- APISetApplicationMenubarRequest,
- APICreateMenuRequest,
- APIDestroyMenuRequest,
- APIAddMenuItemRequest,
- APIAddMenuSeparatorRequest,
- APIUpdateMenuItemRequest,
- APICreateWindowRequest,
- APIDestroyWindowRequest,
- APISetWindowTitleRequest,
- APIGetWindowTitleRequest,
- APISetWindowRectRequest,
- APIGetWindowRectRequest,
- APISetWindowIconBitmapRequest,
- APIInvalidateRectRequest,
- APIDidFinishPaintingNotification,
- APISetGlobalCursorTrackingRequest,
- APISetWindowOpacityRequest,
- APISetWindowBackingStoreRequest,
- APISetClipboardContentsRequest,
- APIGetClipboardContentsRequest,
- APISetWallpaperRequest,
- APIGetWallpaperRequest,
- APISetResolutionRequest,
- APISetWindowOverrideCursorRequest,
- APISetWindowHasAlphaChannelRequest,
- APIMoveWindowToFrontRequest,
- APISetFullscreenRequest,
- WMAPISetActiveWindowRequest,
- WMAPISetWindowMinimizedRequest,
- WMAPIStartWindowResizeRequest,
- WMAPIPopupWindowMenuRequest,
- APIPopupMenuRequest,
- APIDismissMenuRequest,
- __End_API_Client_Requests,
};
WSEvent() {}
@@ -81,667 +39,10 @@ public:
}
virtual ~WSEvent() {}
- bool is_client_request() const { return type() > __Begin_API_Client_Requests && type() < __End_API_Client_Requests; }
bool is_mouse_event() const { return type() == MouseMove || type() == MouseDown || type() == MouseDoubleClick || type() == MouseUp || type() == MouseWheel; }
bool is_key_event() const { return type() == KeyUp || type() == KeyDown; }
};
-class WSAPIClientRequest : public WSEvent {
-public:
- WSAPIClientRequest(Type type, int client_id)
- : WSEvent(type)
- , m_client_id(client_id)
- {
- }
-
- int client_id() const { return m_client_id; }
-
-private:
- int m_client_id { 0 };
-};
-
-class WSWMAPIStartWindowResizeRequest : public WSAPIClientRequest {
-public:
- WSWMAPIStartWindowResizeRequest(int client_id, int target_client_id, int target_window_id)
- : WSAPIClientRequest(WSEvent::WMAPIStartWindowResizeRequest, client_id)
- , m_target_client_id(target_client_id)
- , m_target_window_id(target_window_id)
- {
- }
-
- int target_client_id() const { return m_target_client_id; }
- int target_window_id() const { return m_target_window_id; }
-
-private:
- int m_target_client_id;
- int m_target_window_id;
-};
-
-class WSWMAPIPopupWindowMenuRequest : public WSAPIClientRequest {
-public:
- WSWMAPIPopupWindowMenuRequest(int client_id, int target_client_id, int target_window_id, const Point& position)
- : WSAPIClientRequest(WSEvent::WMAPIPopupWindowMenuRequest, client_id)
- , m_target_client_id(target_client_id)
- , m_target_window_id(target_window_id)
- , m_position(position)
- {
- }
-
- int target_client_id() const { return m_target_client_id; }
- int target_window_id() const { return m_target_window_id; }
- Point position() const { return m_position; }
-
-private:
- int m_target_client_id;
- int m_target_window_id;
- Point m_position;
-};
-
-class WSWMAPISetActiveWindowRequest : public WSAPIClientRequest {
-public:
- WSWMAPISetActiveWindowRequest(int client_id, int target_client_id, int target_window_id)
- : WSAPIClientRequest(WSEvent::WMAPISetActiveWindowRequest, client_id)
- , m_target_client_id(target_client_id)
- , m_target_window_id(target_window_id)
- {
- }
-
- int target_client_id() const { return m_target_client_id; }
- int target_window_id() const { return m_target_window_id; }
-
-private:
- int m_target_client_id;
- int m_target_window_id;
-};
-
-class WSWMAPISetWindowMinimizedRequest : public WSAPIClientRequest {
-public:
- WSWMAPISetWindowMinimizedRequest(int client_id, int target_client_id, int target_window_id, bool minimized)
- : WSAPIClientRequest(WSEvent::WMAPISetWindowMinimizedRequest, client_id)
- , m_target_client_id(target_client_id)
- , m_target_window_id(target_window_id)
- , m_minimized(minimized)
- {
- }
-
- int target_client_id() const { return m_target_client_id; }
- int target_window_id() const { return m_target_window_id; }
- bool is_minimized() const { return m_minimized; }
-
-private:
- int m_target_client_id;
- int m_target_window_id;
- bool m_minimized;
-};
-
-class WSAPISetGlobalCursorTrackingRequest : public WSAPIClientRequest {
-public:
- WSAPISetGlobalCursorTrackingRequest(int client_id, int window_id, bool value)
- : WSAPIClientRequest(WSEvent::APISetGlobalCursorTrackingRequest, client_id)
- , m_window_id(window_id)
- , m_value(value)
- {
- }
-
- int window_id() const { return m_window_id; }
- bool value() const { return m_value; }
-
-private:
- int m_window_id { 0 };
- bool m_value { false };
-};
-
-class WSAPICreateMenubarRequest : public WSAPIClientRequest {
-public:
- WSAPICreateMenubarRequest(int client_id)
- : WSAPIClientRequest(WSEvent::APICreateMenubarRequest, client_id)
- {
- }
-};
-
-class WSAPIDestroyMenubarRequest : public WSAPIClientRequest {
-public:
- WSAPIDestroyMenubarRequest(int client_id, int menubar_id)
- : WSAPIClientRequest(WSEvent::APIDestroyMenubarRequest, client_id)
- , m_menubar_id(menubar_id)
- {
- }
-
- int menubar_id() const { return m_menubar_id; }
-
-private:
- int m_menubar_id { 0 };
-};
-
-class WSAPISetApplicationMenubarRequest : public WSAPIClientRequest {
-public:
- WSAPISetApplicationMenubarRequest(int client_id, int menubar_id)
- : WSAPIClientRequest(WSEvent::APISetApplicationMenubarRequest, client_id)
- , m_menubar_id(menubar_id)
- {
- }
-
- int menubar_id() const { return m_menubar_id; }
-
-private:
- int m_menubar_id { 0 };
-};
-
-class WSAPIAddMenuToMenubarRequest : public WSAPIClientRequest {
-public:
- WSAPIAddMenuToMenubarRequest(int client_id, int menubar_id, int menu_id)
- : WSAPIClientRequest(WSEvent::APIAddMenuToMenubarRequest, client_id)
- , m_menubar_id(menubar_id)
- , m_menu_id(menu_id)
- {
- }
-
- int menubar_id() const { return m_menubar_id; }
- int menu_id() const { return m_menu_id; }
-
-private:
- int m_menubar_id { 0 };
- int m_menu_id { 0 };
-};
-
-class WSAPIPopupMenuRequest : public WSAPIClientRequest {
-public:
- WSAPIPopupMenuRequest(int client_id, int menu_id, const Point& position)
- : WSAPIClientRequest(WSEvent::APIPopupMenuRequest, client_id)
- , m_menu_id(menu_id)
- , m_position(position)
- {
- }
-
- int menu_id() const { return m_menu_id; }
- Point position() const { return m_position; }
-
-private:
- int m_menu_id;
- Point m_position;
-};
-
-class WSAPIDismissMenuRequest : public WSAPIClientRequest {
-public:
- WSAPIDismissMenuRequest(int client_id, int menu_id)
- : WSAPIClientRequest(WSEvent::APIDismissMenuRequest, client_id)
- , m_menu_id(menu_id)
- {
- }
-
- int menu_id() const { return m_menu_id; }
-
-private:
- int m_menu_id;
-};
-
-class WSAPICreateMenuRequest : public WSAPIClientRequest {
-public:
- WSAPICreateMenuRequest(int client_id, const String& text)
- : WSAPIClientRequest(WSEvent::APICreateMenuRequest, client_id)
- , m_text(text)
- {
- }
-
- String text() const { return m_text; }
-
-private:
- String m_text;
-};
-
-class WSAPIDestroyMenuRequest : public WSAPIClientRequest {
-public:
- WSAPIDestroyMenuRequest(int client_id, int menu_id)
- : WSAPIClientRequest(WSEvent::APIDestroyMenuRequest, client_id)
- , m_menu_id(menu_id)
- {
- }
-
- int menu_id() const { return m_menu_id; }
-
-private:
- int m_menu_id { 0 };
-};
-
-class WSAPIAddMenuItemRequest : public WSAPIClientRequest {
-public:
- WSAPIAddMenuItemRequest(int client_id, int menu_id, unsigned identifier, const String& text, const String& shortcut_text, bool enabled, bool checkable, bool checked, int icon_buffer_id, int submenu_id)
- : WSAPIClientRequest(WSEvent::APIAddMenuItemRequest, client_id)
- , m_menu_id(menu_id)
- , m_identifier(identifier)
- , m_text(text)
- , m_shortcut_text(shortcut_text)
- , m_enabled(enabled)
- , m_checkable(checkable)
- , m_checked(checked)
- , m_icon_buffer_id(icon_buffer_id)
- , m_submenu_id(submenu_id)
- {
- }
-
- int menu_id() const { return m_menu_id; }
- unsigned identifier() const { return m_identifier; }
- String text() const { return m_text; }
- String shortcut_text() const { return m_shortcut_text; }
- bool is_enabled() const { return m_enabled; }
- bool is_checkable() const { return m_checkable; }
- bool is_checked() const { return m_checked; }
- int icon_buffer_id() const { return m_icon_buffer_id; }
- int submenu_id() const { return m_submenu_id; }
-
-private:
- int m_menu_id { 0 };
- unsigned m_identifier { 0 };
- String m_text;
- String m_shortcut_text;
- bool m_enabled;
- bool m_checkable;
- bool m_checked;
- int m_icon_buffer_id { 0 };
- int m_submenu_id { 0 };
-};
-
-class WSAPIUpdateMenuItemRequest : public WSAPIClientRequest {
-public:
- WSAPIUpdateMenuItemRequest(int client_id, int menu_id, unsigned identifier, const String& text, const String& shortcut_text, bool enabled, bool checkable, bool checked)
- : WSAPIClientRequest(WSEvent::APIUpdateMenuItemRequest, client_id)
- , m_menu_id(menu_id)
- , m_identifier(identifier)
- , m_text(text)
- , m_shortcut_text(shortcut_text)
- , m_enabled(enabled)
- , m_checkable(checkable)
- , m_checked(checked)
- {
- }
-
- int menu_id() const { return m_menu_id; }
- unsigned identifier() const { return m_identifier; }
- String text() const { return m_text; }
- String shortcut_text() const { return m_shortcut_text; }
- bool is_enabled() const { return m_enabled; }
- bool is_checkable() const { return m_checkable; }
- bool is_checked() const { return m_checked; }
-
-private:
- int m_menu_id { 0 };
- unsigned m_identifier { 0 };
- String m_text;
- String m_shortcut_text;
- bool m_enabled { true };
- bool m_checkable;
- bool m_checked;
-};
-
-class WSAPIAddMenuSeparatorRequest : public WSAPIClientRequest {
-public:
- WSAPIAddMenuSeparatorRequest(int client_id, int menu_id)
- : WSAPIClientRequest(WSEvent::APIAddMenuSeparatorRequest, client_id)
- , m_menu_id(menu_id)
- {
- }
-
- int menu_id() const { return m_menu_id; }
-
-private:
- int m_menu_id { 0 };
-};
-
-class WSAPISetWindowOverrideCursorRequest final : public WSAPIClientRequest {
-public:
- explicit WSAPISetWindowOverrideCursorRequest(int client_id, int window_id, WSStandardCursor cursor)
- : WSAPIClientRequest(WSEvent::APISetWindowOverrideCursorRequest, client_id)
- , m_window_id(window_id)
- , m_cursor(cursor)
- {
- }
-
- int window_id() const { return m_window_id; }
- WSStandardCursor cursor() const { return m_cursor; }
-
-private:
- int m_window_id { 0 };
- WSStandardCursor m_cursor { WSStandardCursor::None };
-};
-
-class WSAPISetWindowHasAlphaChannelRequest final : public WSAPIClientRequest {
-public:
- explicit WSAPISetWindowHasAlphaChannelRequest(int client_id, int window_id, bool value)
- : WSAPIClientRequest(WSEvent::APISetWindowHasAlphaChannelRequest, client_id)
- , m_window_id(window_id)
- , m_value(value)
- {
- }
-
- int window_id() const { return m_window_id; }
- bool value() const { return m_value; }
-
-private:
- int m_window_id { 0 };
- bool m_value { 0 };
-};
-
-class WSAPISetWallpaperRequest final : public WSAPIClientRequest {
-public:
- explicit WSAPISetWallpaperRequest(int client_id, const String& wallpaper)
- : WSAPIClientRequest(WSEvent::APISetWallpaperRequest, client_id)
- , m_wallpaper(wallpaper)
- {
- }
-
- String wallpaper() const { return m_wallpaper; }
-
-private:
- String m_wallpaper;
-};
-
-class WSAPIGetWallpaperRequest final : public WSAPIClientRequest {
-public:
- explicit WSAPIGetWallpaperRequest(int client_id)
- : WSAPIClientRequest(WSEvent::APIGetWallpaperRequest, client_id)
- {
- }
-};
-
-class WSAPISetResolutionRequest final : public WSAPIClientRequest {
-public:
- explicit WSAPISetResolutionRequest(int client_id, int width, int height)
- : WSAPIClientRequest(WSEvent::APISetResolutionRequest, client_id),
- m_resolution(width, height)
- {
- }
-
- Size resolution() const { return m_resolution; }
-
-private:
- Size m_resolution;
-};
-
-class WSAPISetWindowTitleRequest final : public WSAPIClientRequest {
-public:
- explicit WSAPISetWindowTitleRequest(int client_id, int window_id, const String& title)
- : WSAPIClientRequest(WSEvent::APISetWindowTitleRequest, client_id)
- , m_window_id(window_id)
- , m_title(title)
- {
- }
-
- int window_id() const { return m_window_id; }
- String title() const { return m_title; }
-
-private:
- int m_window_id { 0 };
- String m_title;
-};
-
-class WSAPIGetWindowTitleRequest final : public WSAPIClientRequest {
-public:
- explicit WSAPIGetWindowTitleRequest(int client_id, int window_id)
- : WSAPIClientRequest(WSEvent::APIGetWindowTitleRequest, client_id)
- , m_window_id(window_id)
- {
- }
-
- int window_id() const { return m_window_id; }
-
-private:
- int m_window_id { 0 };
-};
-
-class WSAPIMoveWindowToFrontRequest final : public WSAPIClientRequest {
-public:
- explicit WSAPIMoveWindowToFrontRequest(int client_id, int window_id)
- : WSAPIClientRequest(WSEvent::APIMoveWindowToFrontRequest, client_id)
- , m_window_id(window_id)
- {
- }
-
- int window_id() const { return m_window_id; }
-
-private:
- int m_window_id { 0 };
-};
-
-class WSAPISetFullscreenRequest final : public WSAPIClientRequest {
-public:
- explicit WSAPISetFullscreenRequest(int client_id, int window_id, bool fullscreen)
- : WSAPIClientRequest(WSEvent::APISetFullscreenRequest, client_id)
- , m_window_id(window_id)
- , m_fullscreen(fullscreen)
- {
- }
-
- int window_id() const { return m_window_id; }
- bool fullscreen() const { return m_fullscreen; }
-
-private:
- int m_window_id { 0 };
- bool m_fullscreen;
-};
-
-class WSAPISetClipboardContentsRequest final : public WSAPIClientRequest {
-public:
- explicit WSAPISetClipboardContentsRequest(int client_id, int shared_buffer_id, int size, const String& data_type)
- : WSAPIClientRequest(WSEvent::APISetClipboardContentsRequest, client_id)
- , m_shared_buffer_id(shared_buffer_id)
- , m_size(size)
- , m_data_type(data_type)
- {
- }
-
- int shared_buffer_id() const { return m_shared_buffer_id; }
- int size() const { return m_size; }
- const String& data_type() const { return m_data_type; }
-
-private:
- int m_shared_buffer_id { 0 };
- int m_size { 0 };
- String m_data_type;
-};
-
-class WSAPIGetClipboardContentsRequest final : public WSAPIClientRequest {
-public:
- explicit WSAPIGetClipboardContentsRequest(int client_id)
- : WSAPIClientRequest(WSEvent::APIGetClipboardContentsRequest, client_id)
- {
- }
-};
-
-class WSAPISetWindowOpacityRequest final : public WSAPIClientRequest {
-public:
- explicit WSAPISetWindowOpacityRequest(int client_id, int window_id, float opacity)
- : WSAPIClientRequest(WSEvent::APISetWindowOpacityRequest, client_id)
- , m_window_id(window_id)
- , m_opacity(opacity)
- {
- }
-
- int window_id() const { return m_window_id; }
- float opacity() const { return m_opacity; }
-
-private:
- int m_window_id { 0 };
- float m_opacity { 0 };
-};
-
-class WSAPISetWindowBackingStoreRequest final : public WSAPIClientRequest {
-public:
- explicit WSAPISetWindowBackingStoreRequest(int client_id, int window_id, int shared_buffer_id, const Size& size, size_t bpp, size_t pitch, bool has_alpha_channel, bool flush_immediately)
- : WSAPIClientRequest(WSEvent::APISetWindowBackingStoreRequest, client_id)
- , m_window_id(window_id)
- , m_shared_buffer_id(shared_buffer_id)
- , m_size(size)
- , m_bpp(bpp)
- , m_pitch(pitch)
- , m_has_alpha_channel(has_alpha_channel)
- , m_flush_immediately(flush_immediately)
- {
- }
-
- int window_id() const { return m_window_id; }
- int shared_buffer_id() const { return m_shared_buffer_id; }
- Size size() const { return m_size; }
- size_t bpp() const { return m_bpp; }
- size_t pitch() const { return m_pitch; }
- bool has_alpha_channel() const { return m_has_alpha_channel; }
- bool flush_immediately() const { return m_flush_immediately; }
-
-private:
- int m_window_id { 0 };
- int m_shared_buffer_id { 0 };
- Size m_size;
- size_t m_bpp;
- size_t m_pitch;
- bool m_has_alpha_channel;
- bool m_flush_immediately;
-};
-
-class WSAPISetWindowRectRequest final : public WSAPIClientRequest {
-public:
- explicit WSAPISetWindowRectRequest(int client_id, int window_id, const Rect& rect)
- : WSAPIClientRequest(WSEvent::APISetWindowRectRequest, client_id)
- , m_window_id(window_id)
- , m_rect(rect)
- {
- }
-
- int window_id() const { return m_window_id; }
- Rect rect() const { return m_rect; }
-
-private:
- int m_window_id { 0 };
- Rect m_rect;
-};
-
-class WSAPISetWindowIconBitmapRequest final : public WSAPIClientRequest {
-public:
- explicit WSAPISetWindowIconBitmapRequest(int client_id, int window_id, int icon_buffer_id, const Size& icon_size)
- : WSAPIClientRequest(WSEvent::APISetWindowIconBitmapRequest, client_id)
- , m_window_id(window_id)
- , m_icon_buffer_id(icon_buffer_id)
- , m_icon_size(icon_size)
- {
- }
-
- int window_id() const { return m_window_id; }
- int icon_buffer_id() const { return m_icon_buffer_id; }
- const Size& icon_size() const { return m_icon_size; }
-
-private:
- int m_window_id { 0 };
- int m_icon_buffer_id { 0 };
- Size m_icon_size;
-};
-
-class WSAPIGetWindowRectRequest final : public WSAPIClientRequest {
-public:
- explicit WSAPIGetWindowRectRequest(int client_id, int window_id)
- : WSAPIClientRequest(WSEvent::APIGetWindowRectRequest, client_id)
- , m_window_id(window_id)
- {
- }
-
- int window_id() const { return m_window_id; }
-
-private:
- int m_window_id { 0 };
-};
-
-class WSAPICreateWindowRequest : public WSAPIClientRequest {
-public:
- WSAPICreateWindowRequest(int client_id, const Rect& rect, const String& title, bool has_alpha_channel, bool modal, bool resizable, bool fullscreen, bool show_titlebar, float opacity, const Size& base_size, const Size& size_increment, WSWindowType window_type, Color background_color)
- : WSAPIClientRequest(WSEvent::APICreateWindowRequest, client_id)
- , m_rect(rect)
- , m_title(title)
- , m_opacity(opacity)
- , m_has_alpha_channel(has_alpha_channel)
- , m_modal(modal)
- , m_resizable(resizable)
- , m_fullscreen(fullscreen)
- , m_show_titlebar(show_titlebar)
- , m_size_increment(size_increment)
- , m_base_size(base_size)
- , m_window_type(window_type)
- , m_background_color(background_color)
- {
- }
-
- Rect rect() const { return m_rect; }
- String title() const { return m_title; }
- bool has_alpha_channel() const { return m_has_alpha_channel; }
- bool is_modal() const { return m_modal; }
- bool is_resizable() const { return m_resizable; }
- bool is_fullscreen() const { return m_fullscreen; }
- bool show_titlebar() const { return m_show_titlebar; }
- float opacity() const { return m_opacity; }
- Size size_increment() const { return m_size_increment; }
- Size base_size() const { return m_base_size; }
- WSWindowType window_type() const { return m_window_type; }
- Color background_color() const { return m_background_color; }
-
-private:
- Rect m_rect;
- String m_title;
- float m_opacity { 0 };
- bool m_has_alpha_channel { false };
- bool m_modal { false };
- bool m_resizable { false };
- bool m_fullscreen { false };
- bool m_show_titlebar { true };
- Size m_size_increment;
- Size m_base_size;
- WSWindowType m_window_type;
- Color m_background_color;
-};
-
-class WSAPIDestroyWindowRequest : public WSAPIClientRequest {
-public:
- WSAPIDestroyWindowRequest(int client_id, int window_id)
- : WSAPIClientRequest(WSEvent::APIDestroyWindowRequest, client_id)
- , m_window_id(window_id)
- {
- }
-
- int window_id() const { return m_window_id; }
-
-private:
- int m_window_id { 0 };
-};
-
-class WSAPIInvalidateRectRequest final : public WSAPIClientRequest {
-public:
- explicit WSAPIInvalidateRectRequest(int client_id, int window_id, const Vector<Rect, 32>& rects)
- : WSAPIClientRequest(WSEvent::APIInvalidateRectRequest, client_id)
- , m_window_id(window_id)
- , m_rects(rects)
- {
- }
-
- int window_id() const { return m_window_id; }
- const Vector<Rect, 32>& rects() const { return m_rects; }
-
-private:
- int m_window_id { 0 };
- Vector<Rect, 32> m_rects;
-};
-
-class WSAPIDidFinishPaintingNotification final : public WSAPIClientRequest {
-public:
- explicit WSAPIDidFinishPaintingNotification(int client_id, int window_id, const Vector<Rect, 32>& rects)
- : WSAPIClientRequest(WSEvent::APIDidFinishPaintingNotification, client_id)
- , m_window_id(window_id)
- , m_rects(rects)
- {
- }
-
- int window_id() const { return m_window_id; }
- const Vector<Rect, 32>& rects() const { return m_rects; }
-
-private:
- int m_window_id { 0 };
- Vector<Rect, 32> m_rects;
-};
-
enum class MouseButton : u8 {
None = 0,
Left = 1,
diff --git a/Servers/WindowServer/WSEventLoop.cpp b/Servers/WindowServer/WSEventLoop.cpp
index dbcd0e68a2..7909229a3a 100644
--- a/Servers/WindowServer/WSEventLoop.cpp
+++ b/Servers/WindowServer/WSEventLoop.cpp
@@ -3,7 +3,6 @@
#include <Kernel/MousePacket.h>
#include <LibCore/CLocalSocket.h>
#include <LibCore/CObject.h>
-#include <WindowServer/WSAPITypes.h>
#include <WindowServer/WSClientConnection.h>
#include <WindowServer/WSCursor.h>
#include <WindowServer/WSEvent.h>
@@ -38,7 +37,7 @@ WSEventLoop::WSEventLoop()
}
static int s_next_client_id = 0;
int client_id = ++s_next_client_id;
- IPC::Server::new_connection_for_client<WSClientConnection>(*client_socket, client_id);
+ IPC::Server::new_connection_ng_for_client<WSClientConnection>(*client_socket, client_id);
};
ASSERT(m_keyboard_fd >= 0);
diff --git a/Servers/WindowServer/WSEventLoop.h b/Servers/WindowServer/WSEventLoop.h
index 7d13f45502..84a5558d97 100644
--- a/Servers/WindowServer/WSEventLoop.h
+++ b/Servers/WindowServer/WSEventLoop.h
@@ -6,7 +6,6 @@
#include <LibCore/CNotifier.h>
class WSClientConnection;
-struct WSAPI_ClientMessage;
class WSEventLoop {
public:
diff --git a/Servers/WindowServer/WSMenu.cpp b/Servers/WindowServer/WSMenu.cpp
index 1cacfa534e..71186e4fa9 100644
--- a/Servers/WindowServer/WSMenu.cpp
+++ b/Servers/WindowServer/WSMenu.cpp
@@ -11,8 +11,8 @@
#include <LibDraw/GraphicsBitmap.h>
#include <LibDraw/Painter.h>
#include <LibDraw/StylePainter.h>
-#include <WindowServer/WSAPITypes.h>
#include <WindowServer/WSClientConnection.h>
+#include <WindowServer/WindowClientEndpoint.h>
WSMenu::WSMenu(WSClientConnection* client, int menu_id, const String& name)
: CObject(client)
@@ -247,13 +247,8 @@ void WSMenu::did_activate(WSMenuItem& item)
WSWindowManager::the().menu_manager().close_bar();
- WSAPI_ServerMessage message;
- message.type = WSAPI_ServerMessage::Type::MenuItemActivated;
- message.menu.menu_id = m_menu_id;
- message.menu.identifier = item.identifier();
-
if (m_client)
- m_client->post_message(message);
+ m_client->post_message(WindowClient::MenuItemActivated(m_menu_id, item.identifier()));
}
WSMenuItem* WSMenu::item_with_identifier(unsigned identifer)
diff --git a/Servers/WindowServer/WSWindow.cpp b/Servers/WindowServer/WSWindow.cpp
index debd983f83..855ece5094 100644
--- a/Servers/WindowServer/WSWindow.cpp
+++ b/Servers/WindowServer/WSWindow.cpp
@@ -3,8 +3,8 @@
#include "WSEventLoop.h"
#include "WSScreen.h"
#include "WSWindowManager.h"
-#include <WindowServer/WSAPITypes.h>
#include <WindowServer/WSClientConnection.h>
+#include <WindowServer/WindowClientEndpoint.h>
static String default_window_icon_path()
{
@@ -41,7 +41,7 @@ WSWindow::WSWindow(WSClientConnection& client, WSWindowType window_type, int win
{
// FIXME: This should not be hard-coded here.
if (m_type == WSWindowType::Taskbar) {
- m_wm_event_mask = WSAPI_WMEventMask::WindowStateChanges | WSAPI_WMEventMask::WindowRemovals | WSAPI_WMEventMask::WindowIconChanges;
+ m_wm_event_mask = WSWMEventMask::WindowStateChanges | WSWMEventMask::WindowRemovals | WSWMEventMask::WindowIconChanges;
m_listens_to_wm_events = true;
}
WSWindowManager::the().add_window(*this);
@@ -73,76 +73,29 @@ void WSWindow::set_rect(const Rect& rect)
m_frame.notify_window_rect_changed(old_rect, rect);
}
-// FIXME: Just use the same types.
-static WSAPI_MouseButton to_api(MouseButton button)
-{
- switch (button) {
- case MouseButton::None:
- return WSAPI_MouseButton::NoButton;
- case MouseButton::Left:
- return WSAPI_MouseButton::Left;
- case MouseButton::Right:
- return WSAPI_MouseButton::Right;
- case MouseButton::Middle:
- return WSAPI_MouseButton::Middle;
- }
- ASSERT_NOT_REACHED();
-}
-
void WSWindow::handle_mouse_event(const WSMouseEvent& event)
{
set_automatic_cursor_tracking_enabled(event.buttons() != 0);
- WSAPI_ServerMessage server_message;
- server_message.window_id = window_id();
-
switch (event.type()) {
case WSEvent::MouseMove:
- server_message.type = WSAPI_ServerMessage::Type::MouseMove;
+ m_client->post_message(WindowClient::MouseMove(m_window_id, event.position(), (u32)event.button(), event.buttons(), event.modifiers(), event.wheel_delta()));
break;
case WSEvent::MouseDown:
- server_message.type = WSAPI_ServerMessage::Type::MouseDown;
+ m_client->post_message(WindowClient::MouseDown(m_window_id, event.position(), (u32)event.button(), event.buttons(), event.modifiers(), event.wheel_delta()));
break;
case WSEvent::MouseDoubleClick:
- server_message.type = WSAPI_ServerMessage::Type::MouseDoubleClick;
+ m_client->post_message(WindowClient::MouseDoubleClick(m_window_id, event.position(), (u32)event.button(), event.buttons(), event.modifiers(), event.wheel_delta()));
break;
case WSEvent::MouseUp:
- server_message.type = WSAPI_ServerMessage::Type::MouseUp;
+ m_client->post_message(WindowClient::MouseUp(m_window_id, event.position(), (u32)event.button(), event.buttons(), event.modifiers(), event.wheel_delta()));
break;
case WSEvent::MouseWheel:
- server_message.type = WSAPI_ServerMessage::Type::MouseWheel;
+ m_client->post_message(WindowClient::MouseWheel(m_window_id, event.position(), (u32)event.button(), event.buttons(), event.modifiers(), event.wheel_delta()));
break;
default:
ASSERT_NOT_REACHED();
}
-
- server_message.mouse.position = event.position();
- server_message.mouse.button = to_api(event.button());
- server_message.mouse.buttons = event.buttons();
- server_message.mouse.modifiers = event.modifiers();
- server_message.mouse.wheel_delta = event.wheel_delta();
-
- m_client->post_message(server_message);
-}
-
-static WSAPI_WindowType to_api(WSWindowType ws_type)
-{
- switch (ws_type) {
- case WSWindowType::Normal:
- return WSAPI_WindowType::Normal;
- case WSWindowType::Menu:
- return WSAPI_WindowType::Menu;
- case WSWindowType::WindowSwitcher:
- return WSAPI_WindowType::WindowSwitcher;
- case WSWindowType::Taskbar:
- return WSAPI_WindowType::Taskbar;
- case WSWindowType::Tooltip:
- return WSAPI_WindowType::Tooltip;
- case WSWindowType::Menubar:
- return WSAPI_WindowType::Menubar;
- default:
- ASSERT_NOT_REACHED();
- }
}
void WSWindow::set_minimized(bool minimized)
@@ -183,101 +136,96 @@ void WSWindow::event(CEvent& event)
if (is_blocked_by_modal_window())
return;
- WSAPI_ServerMessage server_message;
- server_message.window_id = window_id();
-
if (static_cast<WSEvent&>(event).is_mouse_event())
return handle_mouse_event(static_cast<const WSMouseEvent&>(event));
switch (event.type()) {
case WSEvent::WindowEntered:
- server_message.type = WSAPI_ServerMessage::Type::WindowEntered;
+ m_client->post_message(WindowClient::WindowEntered(m_window_id));
break;
case WSEvent::WindowLeft:
- server_message.type = WSAPI_ServerMessage::Type::WindowLeft;
+ m_client->post_message(WindowClient::WindowLeft(m_window_id));
break;
case WSEvent::KeyDown:
- server_message.type = WSAPI_ServerMessage::Type::KeyDown;
- server_message.key.character = static_cast<const WSKeyEvent&>(event).character();
- server_message.key.key = static_cast<const WSKeyEvent&>(event).key();
- server_message.key.modifiers = static_cast<const WSKeyEvent&>(event).modifiers();
+ m_client->post_message(
+ WindowClient::KeyDown(m_window_id,
+ (u8) static_cast<const WSKeyEvent&>(event).character(),
+ (u32) static_cast<const WSKeyEvent&>(event).key(),
+ static_cast<const WSKeyEvent&>(event).modifiers()));
break;
case WSEvent::KeyUp:
- server_message.type = WSAPI_ServerMessage::Type::KeyUp;
- server_message.key.character = static_cast<const WSKeyEvent&>(event).character();
- server_message.key.key = static_cast<const WSKeyEvent&>(event).key();
- server_message.key.modifiers = static_cast<const WSKeyEvent&>(event).modifiers();
+ m_client->post_message(
+ WindowClient::KeyUp(m_window_id,
+ (u8) static_cast<const WSKeyEvent&>(event).character(),
+ (u32) static_cast<const WSKeyEvent&>(event).key(),
+ static_cast<const WSKeyEvent&>(event).modifiers()));
break;
case WSEvent::WindowActivated:
- server_message.type = WSAPI_ServerMessage::Type::WindowActivated;
+ m_client->post_message(WindowClient::WindowActivated(m_window_id));
break;
case WSEvent::WindowDeactivated:
- server_message.type = WSAPI_ServerMessage::Type::WindowDeactivated;
+ m_client->post_message(WindowClient::WindowDeactivated(m_window_id));
break;
case WSEvent::WindowCloseRequest:
- server_message.type = WSAPI_ServerMessage::Type::WindowCloseRequest;
+ m_client->post_message(WindowClient::WindowCloseRequest(m_window_id));
break;
case WSEvent::WindowResized:
- server_message.type = WSAPI_ServerMessage::Type::WindowResized;
- server_message.window.old_rect = static_cast<const WSResizeEvent&>(event).old_rect();
- server_message.window.rect = static_cast<const WSResizeEvent&>(event).rect();
+ m_client->post_message(
+ WindowClient::WindowResized(
+ m_window_id,
+ static_cast<const WSResizeEvent&>(event).old_rect(),
+ static_cast<const WSResizeEvent&>(event).rect()));
break;
case WSEvent::WM_WindowRemoved: {
auto& removed_event = static_cast<const WSWMWindowRemovedEvent&>(event);
- server_message.type = WSAPI_ServerMessage::Type::WM_WindowRemoved;
- server_message.wm.client_id = removed_event.client_id();
- server_message.wm.window_id = removed_event.window_id();
+ m_client->post_message(WindowClient::WM_WindowRemoved(
+ removed_event.client_id(),
+ removed_event.window_id()));
break;
}
case WSEvent::WM_WindowStateChanged: {
auto& changed_event = static_cast<const WSWMWindowStateChangedEvent&>(event);
- server_message.type = WSAPI_ServerMessage::Type::WM_WindowStateChanged;
- server_message.wm.client_id = changed_event.client_id();
- server_message.wm.window_id = changed_event.window_id();
- server_message.wm.is_active = changed_event.is_active();
- server_message.wm.is_minimized = changed_event.is_minimized();
- server_message.wm.window_type = to_api(changed_event.window_type());
- ASSERT(changed_event.title().length() < (int)sizeof(server_message.text));
- memcpy(server_message.text, changed_event.title().characters(), changed_event.title().length());
- server_message.text_length = changed_event.title().length();
- server_message.wm.rect = changed_event.rect();
+ m_client->post_message(WindowClient::WM_WindowStateChanged(
+ changed_event.client_id(),
+ changed_event.window_id(),
+ changed_event.is_active(),
+ changed_event.is_minimized(),
+ (i32)(changed_event.window_type()),
+ changed_event.title(),
+ changed_event.rect()));
break;
}
case WSEvent::WM_WindowIconBitmapChanged: {
auto& changed_event = static_cast<const WSWMWindowIconBitmapChangedEvent&>(event);
- server_message.type = WSAPI_ServerMessage::Type::WM_WindowIconBitmapChanged;
- server_message.wm.client_id = changed_event.client_id();
- server_message.wm.window_id = changed_event.window_id();
- server_message.wm.icon_buffer_id = changed_event.icon_buffer_id();
- server_message.wm.icon_size = changed_event.icon_size();
-
// FIXME: Perhaps we should update the bitmap sharing list somewhere else instead?
- ASSERT(client());
dbg() << "WindowServer: Sharing icon buffer " << changed_event.icon_buffer_id() << " with PID " << client()->client_pid();
- if (share_buffer_with(changed_event.icon_buffer_id(), client()->client_pid()) < 0) {
+ if (share_buffer_with(changed_event.icon_buffer_id(), m_client->client_pid()) < 0) {
ASSERT_NOT_REACHED();
}
+ m_client->post_message(
+ WindowClient::WM_WindowIconBitmapChanged(
+ changed_event.client_id(),
+ changed_event.window_id(),
+ changed_event.icon_buffer_id(),
+ changed_event.icon_size()));
+
break;
}
case WSEvent::WM_WindowRectChanged: {
auto& changed_event = static_cast<const WSWMWindowRectChangedEvent&>(event);
- server_message.type = WSAPI_ServerMessage::Type::WM_WindowRectChanged;
- server_message.wm.client_id = changed_event.client_id();
- server_message.wm.window_id = changed_event.window_id();
- server_message.wm.rect = changed_event.rect();
+ m_client->post_message(
+ WindowClient::WM_WindowRectChanged(
+ changed_event.client_id(),
+ changed_event.window_id(),
+ changed_event.rect()));
break;
}
default:
break;
}
-
- if (server_message.type == WSAPI_ServerMessage::Type::Invalid)
- return;
-
- m_client->post_message(server_message);
}
void WSWindow::set_global_cursor_tracking_enabled(bool enabled)
diff --git a/Servers/WindowServer/WSWindow.h b/Servers/WindowServer/WSWindow.h
index a77aba5d1c..0be54481ca 100644
--- a/Servers/WindowServer/WSWindow.h
+++ b/Servers/WindowServer/WSWindow.h
@@ -1,7 +1,7 @@
#pragma once
-#include <AK/String.h>
#include <AK/InlineLinkedList.h>
+#include <AK/String.h>
#include <LibCore/CObject.h>
#include <LibDraw/DisjointRectSet.h>
#include <LibDraw/GraphicsBitmap.h>
@@ -14,6 +14,13 @@ class WSCursor;
class WSMenu;
class WSMouseEvent;
+enum WSWMEventMask {
+ WindowRectChanges = 1 << 0,
+ WindowStateChanges = 1 << 1,
+ WindowIconChanges = 1 << 2,
+ WindowRemovals = 1 << 3,
+};
+
class WSWindow final : public CObject
, public InlineLinkedListNode<WSWindow> {
C_OBJECT(WSWindow)
diff --git a/Servers/WindowServer/WSWindowManager.cpp b/Servers/WindowServer/WSWindowManager.cpp
index a9ca19f2f9..c9433ac779 100644
--- a/Servers/WindowServer/WSWindowManager.cpp
+++ b/Servers/WindowServer/WSWindowManager.cpp
@@ -17,7 +17,6 @@
#include <LibDraw/PNGLoader.h>
#include <LibDraw/Painter.h>
#include <LibDraw/StylePainter.h>
-#include <WindowServer/WSAPITypes.h>
#include <WindowServer/WSButton.h>
#include <WindowServer/WSClientConnection.h>
#include <WindowServer/WSCursor.h>
@@ -318,7 +317,7 @@ void WSWindowManager::remove_window(WSWindow& window)
m_switcher.refresh();
for_each_window_listening_to_wm_events([&window](WSWindow& listener) {
- if (!(listener.wm_event_mask() & WSAPI_WMEventMask::WindowRemovals))
+ if (!(listener.wm_event_mask() & WSWMEventMask::WindowRemovals))
return IterationDecision::Continue;
if (window.client())
CEventLoop::current().post_event(listener, make<WSWMWindowRemovedEvent>(window.client()->client_id(), window.window_id()));
@@ -328,7 +327,7 @@ void WSWindowManager::remove_window(WSWindow& window)
void WSWindowManager::tell_wm_listener_about_window(WSWindow& listener, WSWindow& window)
{
- if (!(listener.wm_event_mask() & WSAPI_WMEventMask::WindowStateChanges))
+ if (!(listener.wm_event_mask() & WSWMEventMask::WindowStateChanges))
return;
if (window.client())
CEventLoop::current().post_event(listener, make<WSWMWindowStateChangedEvent>(window.client()->client_id(), window.window_id(), window.title(), window.rect(), window.is_active(), window.type(), window.is_minimized()));
@@ -336,7 +335,7 @@ void WSWindowManager::tell_wm_listener_about_window(WSWindow& listener, WSWindow
void WSWindowManager::tell_wm_listener_about_window_rect(WSWindow& listener, WSWindow& window)
{
- if (!(listener.wm_event_mask() & WSAPI_WMEventMask::WindowRectChanges))
+ if (!(listener.wm_event_mask() & WSWMEventMask::WindowRectChanges))
return;
if (window.client())
CEventLoop::current().post_event(listener, make<WSWMWindowRectChangedEvent>(window.client()->client_id(), window.window_id(), window.rect()));
@@ -344,7 +343,7 @@ void WSWindowManager::tell_wm_listener_about_window_rect(WSWindow& listener, WSW
void WSWindowManager::tell_wm_listener_about_window_icon(WSWindow& listener, WSWindow& window)
{
- if (!(listener.wm_event_mask() & WSAPI_WMEventMask::WindowIconChanges))
+ if (!(listener.wm_event_mask() & WSWMEventMask::WindowIconChanges))
return;
if (window.client() && window.icon().shared_buffer_id() != -1)
CEventLoop::current().post_event(listener, make<WSWMWindowIconBitmapChangedEvent>(window.client()->client_id(), window.window_id(), window.icon().shared_buffer_id(), window.icon().size()));
diff --git a/Servers/WindowServer/WSWindowManager.h b/Servers/WindowServer/WSWindowManager.h
index 3929adf7df..b0ef9fcbf8 100644
--- a/Servers/WindowServer/WSWindowManager.h
+++ b/Servers/WindowServer/WSWindowManager.h
@@ -18,7 +18,6 @@
#include <WindowServer/WSWindowSwitcher.h>
#include <WindowServer/WSWindowType.h>
-class WSAPIClientRequest;
class WSScreen;
class WSMenuBar;
class WSMouseEvent;
@@ -158,7 +157,6 @@ private:
bool process_ongoing_window_resize(const WSMouseEvent&, WSWindow*& hovered_window);
bool process_ongoing_window_drag(WSMouseEvent&, WSWindow*& hovered_window);
void start_window_drag(WSWindow&, const WSMouseEvent&);
- void handle_client_request(const WSAPIClientRequest&);
void set_hovered_window(WSWindow*);
template<typename Callback>
IterationDecision for_each_visible_window_of_type_from_back_to_front(WSWindowType, Callback, bool ignore_highlight = false);
diff --git a/Servers/WindowServer/WindowClient.ipc b/Servers/WindowServer/WindowClient.ipc
new file mode 100644
index 0000000000..d4a0917921
--- /dev/null
+++ b/Servers/WindowServer/WindowClient.ipc
@@ -0,0 +1,30 @@
+endpoint WindowClient = 4
+{
+ Paint(i32 window_id, Size window_size, Vector<Rect> rects) =|
+ MouseMove(i32 window_id, Point mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta) =|
+ MouseDown(i32 window_id, Point mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta) =|
+ MouseDoubleClick(i32 window_id, Point mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta) =|
+ MouseUp(i32 window_id, Point mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta) =|
+ MouseWheel(i32 window_id, Point mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta) =|
+ WindowEntered(i32 window_id) =|
+ WindowLeft(i32 window_id) =|
+ KeyDown(i32 window_id, u8 character, u32 key, u32 modifiers) =|
+ KeyUp(i32 window_id, u8 character, u32 key, u32 modifiers) =|
+ WindowActivated(i32 window_id) =|
+ WindowDeactivated(i32 window_id) =|
+ WindowCloseRequest(i32 window_id) =|
+ WindowResized(i32 window_id, Rect old_rect, Rect new_rect) =|
+
+ MenuItemActivated(i32 menu_id, i32 identifier) =|
+
+ ScreenRectChanged(Rect rect) =|
+
+ ClipboardContentsChanged(String content_type) =|
+
+ WM_WindowRemoved(i32 client_id, i32 window_id) =|
+ WM_WindowStateChanged(i32 client_id, i32 window_id, bool is_active, bool is_minimized, i32 window_type, String title, Rect rect) =|
+ WM_WindowIconBitmapChanged(i32 client_id, i32 window_id, i32 icon_buffer_id, Size icon_size) =|
+ WM_WindowRectChanged(i32 client_id, i32 window_id, Rect rect) =|
+
+ AsyncSetWallpaperFinished(bool success) =|
+}
diff --git a/Servers/WindowServer/WindowServer.ipc b/Servers/WindowServer/WindowServer.ipc
new file mode 100644
index 0000000000..e75ad0daf0
--- /dev/null
+++ b/Servers/WindowServer/WindowServer.ipc
@@ -0,0 +1,68 @@
+endpoint WindowServer = 2
+{
+ Greet(i32 client_pid) => (i32 server_pid, i32 client_id, Rect screen_rect)
+
+ CreateMenubar() => (i32 menubar_id)
+ DestroyMenubar(i32 menubar_id) => ()
+
+ CreateMenu(String menu_title) => (i32 menu_id)
+ DestroyMenu(i32 menu_id) => ()
+
+ AddMenuToMenubar(i32 menubar_id, i32 menu_id) => ()
+ SetApplicationMenubar(i32 menubar_id) => ()
+
+ AddMenuItem(i32 menu_id, i32 identifier, i32 submenu_id, String text, bool enabled, bool checkable, bool checked, String shortcut, i32 icon_buffer_id) => ()
+ AddMenuSeparator(i32 menu_id) => ()
+
+ UpdateMenuItem(i32 menu_id, i32 identifier, i32 submenu_id, String text, bool enabled, bool checkable, bool checked, String shortcut) => ()
+
+ CreateWindow(
+ Rect rect,
+ bool has_alpha_channel,
+ bool modal,
+ bool resizable,
+ bool fullscreen,
+ bool show_titlebar,
+ float opacity,
+ Color background_color,
+ Size base_size,
+ Size size_increment,
+ i32 type,
+ String title) => (i32 window_id)
+
+ DestroyWindow(i32 window_id) => ()
+
+ SetWindowTitle(i32 window_id, String title) => ()
+ GetWindowTitle(i32 window_id) => (String title)
+
+ SetWindowRect(i32 window_id, Rect rect) => ()
+ GetWindowRect(i32 window_id) => (Rect rect)
+
+ InvalidateRect(i32 window_id, Vector<Rect> rects) =|
+ DidFinishPainting(i32 window_id, Vector<Rect> rects) =|
+
+ SetGlobalCursorTracking(i32 window_id, bool enabled) => ()
+ SetWindowOpacity(i32 window_id, float opacity) => ()
+
+ SetWindowBackingStore(i32 window_id, i32 bpp, i32 pitch, i32 shared_buffer_id, bool has_alpha_channel, Size size, bool flush_immediately) => ()
+ GetClipboardContents() => (i32 shared_buffer_id, i32 content_size, String content_type)
+ SetClipboardContents(i32 shared_buffer_id, i32 content_size, String content_type) => ()
+
+ WM_SetActiveWindow(i32 client_id, i32 window_id) =|
+ WM_SetWindowMinimized(i32 client_id, i32 window_id, bool minimized) =|
+ WM_StartWindowResize(i32 client_id, i32 window_id) =|
+ WM_PopupWindowMenu(i32 client_id, i32 window_id, Point screen_position) =|
+
+ SetWindowHasAlphaChannel(i32 window_id, bool has_alpha_channel) => ()
+ MoveWindowToFront(i32 window_id) => ()
+ SetFullscreen(i32 window_id, bool fullscreen) => ()
+ PopupMenu(i32 menu_id, Point screen_position) => ()
+ DismissMenu(i32 menu_id) => ()
+
+ AsyncSetWallpaper(String path) =|
+ SetResolution(Size resolution) => ()
+ SetWindowIconBitmap(i32 window_id, i32 icon_buffer_id, Size icon_size) => ()
+
+ GetWallpaper() => (String path)
+ SetWindowOverrideCursor(i32 window_id, i32 cursor_type) => ()
+}
diff --git a/Servers/WindowServer/main.cpp b/Servers/WindowServer/main.cpp
index 542998a3d0..cbd3830627 100644
--- a/Servers/WindowServer/main.cpp
+++ b/Servers/WindowServer/main.cpp
@@ -18,13 +18,19 @@ int main(int, char**)
return 1;
}
+ dbg() << "1";
WSEventLoop loop;
+ dbg() << "2";
auto wm_config = CConfigFile::get_for_app("WindowManager");
+ dbg() << "3";
WSScreen screen(wm_config->read_num_entry("Screen", "Width", 1024),
wm_config->read_num_entry("Screen", "Height", 768));
+ dbg() << "4";
WSCompositor::the();
+ dbg() << "5";
auto wm = WSWindowManager::construct();
+ dbg() << "6";
dbgprintf("Entering WindowServer main loop.\n");
loop.exec();