summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2020-01-02 03:29:21 +0100
committerAndreas Kling <awesomekling@gmail.com>2020-01-02 03:29:21 +0100
commit8c8118fbf872fe0de399b4845f306285a373a22d (patch)
tree80fe51119e368ba03c1475ff88976a52103ab37a
parent9619dab727c1bf715482b146058121bccc2d5ce9 (diff)
downloadserenity-8c8118fbf872fe0de399b4845f306285a373a22d.zip
WindowServer+LibGUI: Taskbar should show all windows from each process
We were not sending the ID of the window that was listening for window management (WM) events along with the WM messages. They only included the "target" window's ID. Since the taskbar's single window had the first window ID for its own connection to the WindowServer, it meant that it would only receive WM events for the first window ID in other processes as well. This broke when I ported WindowServer to LibIPC. Fix this by including the WM listener ID in all WM messages, and since we're here anyway, get rid of a bunch of unnecessary indirection where we were passing WM events through the WindowServer event loop before sending them to the listener.
-rw-r--r--Libraries/LibGUI/GWindowServerConnection.cpp8
-rw-r--r--Servers/WindowServer/WSEvent.h87
-rw-r--r--Servers/WindowServer/WSWindow.cpp47
-rw-r--r--Servers/WindowServer/WSWindowManager.cpp27
-rw-r--r--Servers/WindowServer/WindowClient.ipc8
5 files changed, 25 insertions, 152 deletions
diff --git a/Libraries/LibGUI/GWindowServerConnection.cpp b/Libraries/LibGUI/GWindowServerConnection.cpp
index 39e3713c85..fde0ee7064 100644
--- a/Libraries/LibGUI/GWindowServerConnection.cpp
+++ b/Libraries/LibGUI/GWindowServerConnection.cpp
@@ -234,7 +234,7 @@ void GWindowServerConnection::handle(const WindowClient::WM_WindowStateChanged&
#ifdef GEVENTLOOP_DEBUG
dbgprintf("GEventLoop: handle_wm_event: %d\n", (int)event.type);
#endif
- if (auto* window = GWindow::from_window_id(message.window_id()))
+ if (auto* window = GWindow::from_window_id(message.wm_id()))
CEventLoop::current().post_event(*window, make<GWMWindowStateChangedEvent>(message.client_id(), message.window_id(), message.title(), message.rect(), message.is_active(), (GWindowType)message.window_type(), message.is_minimized()));
}
@@ -243,7 +243,7 @@ void GWindowServerConnection::handle(const WindowClient::WM_WindowRectChanged& m
#ifdef GEVENTLOOP_DEBUG
dbgprintf("GEventLoop: handle_wm_event: %d\n", (int)event.type);
#endif
- if (auto* window = GWindow::from_window_id(message.window_id()))
+ if (auto* window = GWindow::from_window_id(message.wm_id()))
CEventLoop::current().post_event(*window, make<GWMWindowRectChangedEvent>(message.client_id(), message.window_id(), message.rect()));
}
@@ -252,7 +252,7 @@ void GWindowServerConnection::handle(const WindowClient::WM_WindowIconBitmapChan
#ifdef GEVENTLOOP_DEBUG
dbgprintf("GEventLoop: handle_wm_event: %d\n", (int)event.type);
#endif
- if (auto* window = GWindow::from_window_id(message.window_id()))
+ if (auto* window = GWindow::from_window_id(message.wm_id()))
CEventLoop::current().post_event(*window, make<GWMWindowIconBitmapChangedEvent>(message.client_id(), message.window_id(), message.icon_buffer_id(), message.icon_size()));
}
@@ -261,7 +261,7 @@ void GWindowServerConnection::handle(const WindowClient::WM_WindowRemoved& messa
#ifdef GEVENTLOOP_DEBUG
dbgprintf("GEventLoop: handle_wm_event: %d\n", (int)event.type);
#endif
- if (auto* window = GWindow::from_window_id(message.window_id()))
+ if (auto* window = GWindow::from_window_id(message.wm_id()))
CEventLoop::current().post_event(*window, make<GWMWindowRemovedEvent>(message.client_id(), message.window_id()));
}
diff --git a/Servers/WindowServer/WSEvent.h b/Servers/WindowServer/WSEvent.h
index 0ad51bd7d6..4216780f52 100644
--- a/Servers/WindowServer/WSEvent.h
+++ b/Servers/WindowServer/WSEvent.h
@@ -25,11 +25,6 @@ public:
WindowDeactivated,
WindowCloseRequest,
WindowResized,
-
- WM_WindowRemoved,
- WM_WindowStateChanged,
- WM_WindowRectChanged,
- WM_WindowIconBitmapChanged,
};
WSEvent() {}
@@ -122,85 +117,3 @@ private:
Rect m_old_rect;
Rect m_rect;
};
-
-class WSWMEvent : public WSEvent {
-public:
- WSWMEvent(Type type, int client_id, int window_id)
- : WSEvent(type)
- , m_client_id(client_id)
- , m_window_id(window_id)
- {
- }
-
- int client_id() const { return m_client_id; }
- int window_id() const { return m_window_id; }
-
-private:
- int m_client_id;
- int m_window_id;
-};
-
-class WSWMWindowRemovedEvent : public WSWMEvent {
-public:
- WSWMWindowRemovedEvent(int client_id, int window_id)
- : WSWMEvent(WSEvent::WM_WindowRemoved, client_id, window_id)
- {
- }
-};
-
-class WSWMWindowStateChangedEvent : public WSWMEvent {
-public:
- WSWMWindowStateChangedEvent(int client_id, int window_id, const String& title, const Rect& rect, bool is_active, WSWindowType window_type, bool is_minimized)
- : WSWMEvent(WSEvent::WM_WindowStateChanged, client_id, window_id)
- , m_title(title)
- , m_rect(rect)
- , m_active(is_active)
- , m_window_type(window_type)
- , m_minimized(is_minimized)
- {
- }
-
- String title() const { return m_title; }
- Rect rect() const { return m_rect; }
- bool is_active() const { return m_active; }
- WSWindowType window_type() const { return m_window_type; }
- bool is_minimized() const { return m_minimized; }
-
-private:
- String m_title;
- Rect m_rect;
- bool m_active;
- WSWindowType m_window_type;
- bool m_minimized;
-};
-
-class WSWMWindowIconBitmapChangedEvent : public WSWMEvent {
-public:
- WSWMWindowIconBitmapChangedEvent(int client_id, int window_id, int icon_buffer_id, const Size& icon_size)
- : WSWMEvent(WSEvent::WM_WindowIconBitmapChanged, client_id, window_id)
- , m_icon_buffer_id(icon_buffer_id)
- , m_icon_size(icon_size)
- {
- }
-
- int icon_buffer_id() const { return m_icon_buffer_id; }
- const Size icon_size() const { return m_icon_size; }
-
-private:
- int m_icon_buffer_id;
- Size m_icon_size;
-};
-
-class WSWMWindowRectChangedEvent : public WSWMEvent {
-public:
- WSWMWindowRectChangedEvent(int client_id, int window_id, const Rect& rect)
- : WSWMEvent(WSEvent::WM_WindowRectChanged, client_id, window_id)
- , m_rect(rect)
- {
- }
-
- Rect rect() const { return m_rect; }
-
-private:
- Rect m_rect;
-};
diff --git a/Servers/WindowServer/WSWindow.cpp b/Servers/WindowServer/WSWindow.cpp
index 5d30d596cb..1b15688c2e 100644
--- a/Servers/WindowServer/WSWindow.cpp
+++ b/Servers/WindowServer/WSWindow.cpp
@@ -193,53 +193,6 @@ void WSWindow::event(CEvent& event)
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);
- 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);
- 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);
- // FIXME: Perhaps we should update the bitmap sharing list somewhere else instead?
- dbg() << "WindowServer: Sharing icon buffer " << changed_event.icon_buffer_id() << " with PID " << client()->client_pid();
- 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);
- m_client->post_message(
- WindowClient::WM_WindowRectChanged(
- changed_event.client_id(),
- changed_event.window_id(),
- changed_event.rect()));
- break;
- }
-
default:
break;
}
diff --git a/Servers/WindowServer/WSWindowManager.cpp b/Servers/WindowServer/WSWindowManager.cpp
index 4877853f54..3470cb7d89 100644
--- a/Servers/WindowServer/WSWindowManager.cpp
+++ b/Servers/WindowServer/WSWindowManager.cpp
@@ -359,7 +359,7 @@ void WSWindowManager::remove_window(WSWindow& window)
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()));
+ listener.client()->post_message(WindowClient::WM_WindowRemoved(listener.window_id(), window.client()->client_id(), window.window_id()));
return IterationDecision::Continue;
});
}
@@ -368,24 +368,33 @@ void WSWindowManager::tell_wm_listener_about_window(WSWindow& listener, WSWindow
{
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()));
+ if (!window.client())
+ return;
+ listener.client()->post_message(WindowClient::WM_WindowStateChanged(listener.window_id(), window.client()->client_id(), window.window_id(), window.is_active(), window.is_minimized(), (i32)window.type(), window.title(), window.rect()));
}
void WSWindowManager::tell_wm_listener_about_window_rect(WSWindow& listener, WSWindow& window)
{
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()));
+ if (!window.client())
+ return;
+ listener.client()->post_message(WindowClient::WM_WindowRectChanged(listener.window_id(), window.client()->client_id(), window.window_id(), window.rect()));
}
void WSWindowManager::tell_wm_listener_about_window_icon(WSWindow& listener, WSWindow& window)
{
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()));
+ if (!window.client())
+ return;
+ if (window.icon().shared_buffer_id() == -1)
+ return;
+ dbg() << "WindowServer: Sharing icon buffer " << window.icon().shared_buffer_id() << " with PID " << listener.client()->client_pid();
+ if (share_buffer_with(window.icon().shared_buffer_id(), listener.client()->client_pid()) < 0) {
+ ASSERT_NOT_REACHED();
+ }
+ listener.client()->post_message(WindowClient::WM_WindowIconBitmapChanged(listener.window_id(), window.client()->client_id(), window.window_id(), window.icon().shared_buffer_id(), window.icon().size()));
}
void WSWindowManager::tell_wm_listeners_window_state_changed(WSWindow& window)
@@ -980,7 +989,6 @@ void WSWindowManager::process_mouse_event(WSMouseEvent& event, WSWindow*& hovere
// Clicked outside of any window
if (!hovered_window && !event_window_with_frame && event.type() == WSEvent::MouseDown)
set_active_window(nullptr);
-
}
if (event_window_with_frame != m_resize_candidate.ptr())
@@ -1078,8 +1086,7 @@ void WSWindowManager::event(CEvent& event)
return;
}
- if (key_event.type() == WSEvent::KeyDown && ((key_event.modifiers() == Mod_Logo && key_event.key() == Key_Tab) ||
- (key_event.modifiers() == (Mod_Logo | Mod_Shift) && key_event.key() == Key_Tab)))
+ if (key_event.type() == WSEvent::KeyDown && ((key_event.modifiers() == Mod_Logo && key_event.key() == Key_Tab) || (key_event.modifiers() == (Mod_Logo | Mod_Shift) && key_event.key() == Key_Tab)))
m_switcher.show();
if (m_switcher.is_visible()) {
m_switcher.on_key_event(key_event);
diff --git a/Servers/WindowServer/WindowClient.ipc b/Servers/WindowServer/WindowClient.ipc
index d443b3264d..7c28e9d30c 100644
--- a/Servers/WindowServer/WindowClient.ipc
+++ b/Servers/WindowServer/WindowClient.ipc
@@ -22,10 +22,10 @@ endpoint WindowClient = 4
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) =|
+ WM_WindowRemoved(i32 wm_id, i32 client_id, i32 window_id) =|
+ WM_WindowStateChanged(i32 wm_id, i32 client_id, i32 window_id, bool is_active, bool is_minimized, i32 window_type, String title, Rect rect) =|
+ WM_WindowIconBitmapChanged(i32 wm_id, i32 client_id, i32 window_id, i32 icon_buffer_id, Size icon_size) =|
+ WM_WindowRectChanged(i32 wm_id, i32 client_id, i32 window_id, Rect rect) =|
AsyncSetWallpaperFinished(bool success) =|