mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:47:34 +00:00
WindowServer: Give a thread boost to the currently active window
When the currently active (foreground) window is owned by a client, we now apply a +10 priority boost to the client's main thread. You normally want the window you're interacting with to be responsive, so this little boost allows it to run a bit sooner and more often. :^)
This commit is contained in:
parent
610f3ad12f
commit
0dea0fd06f
3 changed files with 29 additions and 3 deletions
|
@ -15,10 +15,8 @@
|
|||
#include <WindowServer/WSWindowSwitcher.h>
|
||||
#include <WindowServer/WindowClientEndpoint.h>
|
||||
#include <errno.h>
|
||||
#include <serenity.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/uio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
HashMap<int, NonnullRefPtr<WSClientConnection>>* s_connections;
|
||||
|
@ -654,3 +652,15 @@ OwnPtr<WindowServer::StartDragResponse> WSClientConnection::handle(const WindowS
|
|||
wm.start_dnd_drag(*this, message.text(), bitmap, message.data_type(), message.data());
|
||||
return make<WindowServer::StartDragResponse>(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");
|
||||
}
|
||||
|
|
|
@ -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<void(WSClientConnection&)>);
|
||||
|
||||
|
|
|
@ -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>(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>(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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue