diff --git a/Servers/WindowServer/WSClientConnection.cpp b/Servers/WindowServer/WSClientConnection.cpp index 959265e627..24835ed49a 100644 --- a/Servers/WindowServer/WSClientConnection.cpp +++ b/Servers/WindowServer/WSClientConnection.cpp @@ -15,10 +15,8 @@ #include #include #include +#include #include -#include -#include -#include #include HashMap>* s_connections; @@ -654,3 +652,15 @@ OwnPtr WSClientConnection::handle(const WindowS wm.start_dnd_drag(*this, message.text(), bitmap, message.data_type(), message.data()); return make(true); } + +void WSClientConnection::boost() +{ + if (set_thread_boost(client_pid(), 10) < 0) + perror("boost: set_thread_boost"); +} + +void WSClientConnection::deboost() +{ + if (set_thread_boost(client_pid(), 0) < 0) + perror("deboost: set_thread_boost"); +} diff --git a/Servers/WindowServer/WSClientConnection.h b/Servers/WindowServer/WSClientConnection.h index 3d2e0a8d9c..a32768c4fa 100644 --- a/Servers/WindowServer/WSClientConnection.h +++ b/Servers/WindowServer/WSClientConnection.h @@ -22,6 +22,9 @@ public: ~WSClientConnection() override; virtual void die() override; + void boost(); + void deboost(); + static WSClientConnection* from_client_id(int client_id); static void for_each_client(Function); diff --git a/Servers/WindowServer/WSWindowManager.cpp b/Servers/WindowServer/WSWindowManager.cpp index 33b468fb26..42ce56c17c 100644 --- a/Servers/WindowServer/WSWindowManager.cpp +++ b/Servers/WindowServer/WSWindowManager.cpp @@ -1095,12 +1095,18 @@ void WSWindowManager::set_active_window(WSWindow* window) return; auto* previously_active_window = m_active_window.ptr(); + + WSClientConnection* previously_active_client = nullptr; + WSClientConnection* active_client = nullptr; + if (previously_active_window) { + previously_active_client = previously_active_window->client(); CEventLoop::current().post_event(*previously_active_window, make(WSEvent::WindowDeactivated)); invalidate(*previously_active_window); } m_active_window = window->make_weak_ptr(); if (m_active_window) { + active_client = m_active_window->client(); CEventLoop::current().post_event(*m_active_window, make(WSEvent::WindowActivated)); invalidate(*m_active_window); @@ -1111,6 +1117,13 @@ void WSWindowManager::set_active_window(WSWindow* window) tell_wm_listeners_window_state_changed(*previously_active_window); tell_wm_listeners_window_state_changed(*m_active_window); } + + if (active_client != previously_active_client) { + if (previously_active_client) + previously_active_client->deboost(); + if (active_client) + active_client->boost(); + } } void WSWindowManager::set_hovered_window(WSWindow* window)