summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Applications/Taskbar/WindowList.cpp10
-rw-r--r--Servers/WindowServer/WSAPITypes.h5
-rw-r--r--Servers/WindowServer/WSClientConnection.cpp18
-rw-r--r--Servers/WindowServer/WSClientConnection.h1
-rw-r--r--Servers/WindowServer/WSMessage.h18
-rw-r--r--Servers/WindowServer/WSMessageLoop.cpp4
-rw-r--r--Servers/WindowServer/WSWindowManager.h3
7 files changed, 58 insertions, 1 deletions
diff --git a/Applications/Taskbar/WindowList.cpp b/Applications/Taskbar/WindowList.cpp
index 8afed41468..2c8be5806f 100644
--- a/Applications/Taskbar/WindowList.cpp
+++ b/Applications/Taskbar/WindowList.cpp
@@ -1,4 +1,6 @@
#include "WindowList.h"
+#include <WindowServer/WSAPITypes.h>
+#include <LibGUI/GEventLoop.h>
Window& WindowList::ensure_window(const WindowIdentifier& identifier)
{
@@ -7,6 +9,14 @@ Window& WindowList::ensure_window(const WindowIdentifier& identifier)
return *it->value;
auto window = make<Window>(identifier);
window->set_button(aid_create_button());
+ window->button()->on_click = [identifier] (GButton&) {
+ WSAPI_ClientMessage message;
+ message.type = WSAPI_ClientMessage::Type::WM_SetActiveWindow;
+ message.wm.client_id = identifier.client_id();
+ message.wm.window_id = identifier.window_id();
+ bool success = GEventLoop::post_message_to_server(message);
+ ASSERT(success);
+ };
auto& window_ref = *window;
m_windows.set(identifier, move(window));
return window_ref;
diff --git a/Servers/WindowServer/WSAPITypes.h b/Servers/WindowServer/WSAPITypes.h
index f8a49de14d..ee271f8961 100644
--- a/Servers/WindowServer/WSAPITypes.h
+++ b/Servers/WindowServer/WSAPITypes.h
@@ -185,6 +185,7 @@ struct WSAPI_ClientMessage {
SetWallpaper,
GetWallpaper,
SetWindowOverrideCursor,
+ WM_SetActiveWindow,
};
Type type { Invalid };
int window_id { -1 };
@@ -197,6 +198,10 @@ struct WSAPI_ClientMessage {
int client_pid;
} greeting;
struct {
+ int client_id;
+ int window_id;
+ } wm;
+ struct {
int menubar_id;
int menu_id;
unsigned identifier;
diff --git a/Servers/WindowServer/WSClientConnection.cpp b/Servers/WindowServer/WSClientConnection.cpp
index 57e5c146d5..e241eefbad 100644
--- a/Servers/WindowServer/WSClientConnection.cpp
+++ b/Servers/WindowServer/WSClientConnection.cpp
@@ -519,6 +519,22 @@ void WSClientConnection::handle_request(const WSAPISetWindowOverrideCursorReques
window.set_override_cursor(WSCursor::create(request.cursor()));
}
+void WSClientConnection::handle_request(const WSWMAPISetActiveWindowRequest& request)
+{
+ auto* client = WSClientConnection::from_client_id(request.target_client_id());
+ if (!client) {
+ post_error("Bad client ID");
+ return;
+ }
+ auto it = client->m_windows.find(request.target_window_id());
+ if (it == client->m_windows.end()) {
+ post_error("Bad window ID");
+ return;
+ }
+ auto& window = *(*it).value;
+ WSWindowManager::the().set_active_window(&window);
+}
+
void WSClientConnection::on_request(const WSAPIClientRequest& request)
{
switch (request.type()) {
@@ -572,6 +588,8 @@ void WSClientConnection::on_request(const WSAPIClientRequest& request)
return handle_request(static_cast<const WSAPIGetWallpaperRequest&>(request));
case WSMessage::APISetWindowOverrideCursorRequest:
return handle_request(static_cast<const WSAPISetWindowOverrideCursorRequest&>(request));
+ case WSMessage::WMAPISetActiveWindowRequest:
+ return handle_request(static_cast<const WSWMAPISetActiveWindowRequest&>(request));
default:
break;
}
diff --git a/Servers/WindowServer/WSClientConnection.h b/Servers/WindowServer/WSClientConnection.h
index 2fed8f1915..1d2e3dd159 100644
--- a/Servers/WindowServer/WSClientConnection.h
+++ b/Servers/WindowServer/WSClientConnection.h
@@ -68,6 +68,7 @@ private:
void handle_request(const WSAPISetWallpaperRequest&);
void handle_request(const WSAPIGetWallpaperRequest&);
void handle_request(const WSAPISetWindowOverrideCursorRequest&);
+ void handle_request(const WSWMAPISetActiveWindowRequest&);
void post_error(const String&);
diff --git a/Servers/WindowServer/WSMessage.h b/Servers/WindowServer/WSMessage.h
index 3911a48d6f..32bf2135ec 100644
--- a/Servers/WindowServer/WSMessage.h
+++ b/Servers/WindowServer/WSMessage.h
@@ -56,6 +56,7 @@ public:
APISetWallpaperRequest,
APIGetWallpaperRequest,
APISetWindowOverrideCursorRequest,
+ WMAPISetActiveWindowRequest,
__End_API_Client_Requests,
};
@@ -101,6 +102,23 @@ private:
int m_client_id { 0 };
};
+class WSWMAPISetActiveWindowRequest : public WSAPIClientRequest {
+public:
+ WSWMAPISetActiveWindowRequest(int client_id, int target_client_id, int target_window_id)
+ : WSAPIClientRequest(WSMessage::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 WSAPISetGlobalCursorTrackingRequest : public WSAPIClientRequest {
public:
WSAPISetGlobalCursorTrackingRequest(int client_id, int window_id, bool value)
diff --git a/Servers/WindowServer/WSMessageLoop.cpp b/Servers/WindowServer/WSMessageLoop.cpp
index 5977f96a0f..8709f50c1f 100644
--- a/Servers/WindowServer/WSMessageLoop.cpp
+++ b/Servers/WindowServer/WSMessageLoop.cpp
@@ -346,6 +346,10 @@ void WSMessageLoop::on_receive_from_client(int client_id, const WSAPI_ClientMess
break;
case WSAPI_ClientMessage::Type::SetWindowOverrideCursor:
post_message(client, make<WSAPISetWindowOverrideCursorRequest>(client_id, message.window_id, (WSStandardCursor)message.cursor.cursor));
+ break;
+ case WSAPI_ClientMessage::Type::WM_SetActiveWindow:
+ post_message(client, make<WSWMAPISetActiveWindowRequest>(client_id, message.wm.client_id, message.wm.window_id));
+ break;
default:
break;
}
diff --git a/Servers/WindowServer/WSWindowManager.h b/Servers/WindowServer/WSWindowManager.h
index b5d4189f15..8436d9a657 100644
--- a/Servers/WindowServer/WSWindowManager.h
+++ b/Servers/WindowServer/WSWindowManager.h
@@ -96,6 +96,8 @@ public:
const WSCursor& disallowed_cursor() const { return *m_disallowed_cursor; }
const WSCursor& move_cursor() const { return *m_move_cursor; }
+ void set_active_window(WSWindow*);
+
private:
void process_mouse_event(const WSMouseEvent&, WSWindow*& event_window);
bool process_ongoing_window_resize(const WSMouseEvent&, WSWindow*& event_window);
@@ -106,7 +108,6 @@ private:
void start_window_resize(WSWindow&, const WSMouseEvent&);
void start_window_drag(WSWindow&, const WSMouseEvent&);
void handle_client_request(const WSAPIClientRequest&);
- void set_active_window(WSWindow*);
void set_hovered_window(WSWindow*);
template<typename Callback> IterationDecision for_each_visible_window_of_type_from_back_to_front(WSWindowType, Callback);
template<typename Callback> IterationDecision for_each_visible_window_of_type_from_front_to_back(WSWindowType, Callback);