summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-02-01 11:23:54 +0100
committerAndreas Kling <kling@serenityos.org>2021-02-01 11:23:54 +0100
commita5bbe3280d2a492f861cccb641b1b35b8b667b61 (patch)
treee2118c7656edbb216e4b344e3d6a6d397bb46690
parentc41d340983b803c1c12a58ac7884b243906bda36 (diff)
downloadserenity-a5bbe3280d2a492f861cccb641b1b35b8b667b61.zip
LibGUI+WindowServer: Don't use a WM IPC to initiate own window resize
The WM_* IPC messages are intended for "outsider" window management, not for a client's own windows. Make a separate StartWindowResize message for this. This was the only reason that every IPC client had to know its server side client ID.
-rw-r--r--Userland/Libraries/LibGUI/ResizeCorner.cpp2
-rw-r--r--Userland/Libraries/LibGUI/Window.cpp4
-rw-r--r--Userland/Libraries/LibGUI/Window.h2
-rw-r--r--Userland/Services/WindowServer/ClientConnection.cpp13
-rw-r--r--Userland/Services/WindowServer/ClientConnection.h1
-rw-r--r--Userland/Services/WindowServer/WindowServer.ipc2
6 files changed, 20 insertions, 4 deletions
diff --git a/Userland/Libraries/LibGUI/ResizeCorner.cpp b/Userland/Libraries/LibGUI/ResizeCorner.cpp
index b1b2f5e1d0..5e7f18bd6f 100644
--- a/Userland/Libraries/LibGUI/ResizeCorner.cpp
+++ b/Userland/Libraries/LibGUI/ResizeCorner.cpp
@@ -106,7 +106,7 @@ void ResizeCorner::paint_event(PaintEvent& event)
void ResizeCorner::mousedown_event(MouseEvent& event)
{
if (event.button() == MouseButton::Left)
- window()->start_wm_resize();
+ window()->start_interactive_resize();
Widget::mousedown_event(event);
}
diff --git a/Userland/Libraries/LibGUI/Window.cpp b/Userland/Libraries/LibGUI/Window.cpp
index c2e684c237..1dc2d8ce7a 100644
--- a/Userland/Libraries/LibGUI/Window.cpp
+++ b/Userland/Libraries/LibGUI/Window.cpp
@@ -774,9 +774,9 @@ void Window::apply_icon()
WindowServerConnection::the().send_sync<Messages::WindowServer::SetWindowIconBitmap>(m_window_id, m_icon->to_shareable_bitmap());
}
-void Window::start_wm_resize()
+void Window::start_interactive_resize()
{
- WindowServerConnection::the().post_message(Messages::WindowServer::WM_StartWindowResize(WindowServerConnection::the().my_client_id(), m_window_id));
+ WindowServerConnection::the().post_message(Messages::WindowServer::StartWindowResize(m_window_id));
}
Vector<Widget*> Window::focusable_widgets(FocusSource source) const
diff --git a/Userland/Libraries/LibGUI/Window.h b/Userland/Libraries/LibGUI/Window.h
index 3e734d2e56..7ee73ea752 100644
--- a/Userland/Libraries/LibGUI/Window.h
+++ b/Userland/Libraries/LibGUI/Window.h
@@ -126,7 +126,7 @@ public:
virtual void close();
void move_to_front();
- void start_wm_resize();
+ void start_interactive_resize();
Widget* main_widget() { return m_main_widget; }
const Widget* main_widget() const { return m_main_widget; }
diff --git a/Userland/Services/WindowServer/ClientConnection.cpp b/Userland/Services/WindowServer/ClientConnection.cpp
index 1ef98dcd39..bd805c02f9 100644
--- a/Userland/Services/WindowServer/ClientConnection.cpp
+++ b/Userland/Services/WindowServer/ClientConnection.cpp
@@ -673,6 +673,19 @@ void ClientConnection::handle(const Messages::WindowServer::WM_PopupWindowMenu&
}
}
+void ClientConnection::handle(const Messages::WindowServer::StartWindowResize& request)
+{
+ auto it = m_windows.find(request.window_id());
+ if (it == m_windows.end()) {
+ did_misbehave("WM_StartWindowResize: Bad window ID");
+ return;
+ }
+ auto& window = *(*it).value;
+ // FIXME: We are cheating a bit here by using the current cursor location and hard-coding the left button.
+ // Maybe the client should be allowed to specify what initiated this request?
+ WindowManager::the().start_window_resize(window, Screen::the().cursor_location(), MouseButton::Left);
+}
+
void ClientConnection::handle(const Messages::WindowServer::WM_StartWindowResize& request)
{
auto* client = ClientConnection::from_client_id(request.client_id());
diff --git a/Userland/Services/WindowServer/ClientConnection.h b/Userland/Services/WindowServer/ClientConnection.h
index 89aaa71aae..e4048cba7c 100644
--- a/Userland/Services/WindowServer/ClientConnection.h
+++ b/Userland/Services/WindowServer/ClientConnection.h
@@ -105,6 +105,7 @@ private:
virtual OwnPtr<Messages::WindowServer::SetWindowTitleResponse> handle(const Messages::WindowServer::SetWindowTitle&) override;
virtual OwnPtr<Messages::WindowServer::GetWindowTitleResponse> handle(const Messages::WindowServer::GetWindowTitle&) override;
virtual OwnPtr<Messages::WindowServer::IsMaximizedResponse> handle(const Messages::WindowServer::IsMaximized&) override;
+ virtual void handle(const Messages::WindowServer::StartWindowResize&) override;
virtual OwnPtr<Messages::WindowServer::SetWindowRectResponse> handle(const Messages::WindowServer::SetWindowRect&) override;
virtual OwnPtr<Messages::WindowServer::GetWindowRectResponse> handle(const Messages::WindowServer::GetWindowRect&) override;
virtual OwnPtr<Messages::WindowServer::GetWindowRectInMenubarResponse> handle(const Messages::WindowServer::GetWindowRectInMenubar&) override;
diff --git a/Userland/Services/WindowServer/WindowServer.ipc b/Userland/Services/WindowServer/WindowServer.ipc
index 3b528228f1..a9dec18bdf 100644
--- a/Userland/Services/WindowServer/WindowServer.ipc
+++ b/Userland/Services/WindowServer/WindowServer.ipc
@@ -60,6 +60,8 @@ endpoint WindowServer = 2
GetWindowRectInMenubar(i32 window_id) => (Gfx::IntRect rect)
+ StartWindowResize(i32 window_id) =|
+
IsMaximized(i32 window_id) => (bool maximized)
InvalidateRect(i32 window_id, Vector<Gfx::IntRect> rects, bool ignore_occlusion) =|