1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:57:43 +00:00

LibGUI+WindowServer: Introduce new mouse tracking mechanism

This commit is contained in:
Ben Wiederhake 2021-09-07 21:04:35 +02:00 committed by Andreas Kling
parent bde3c7301e
commit 45126655cd
10 changed files with 94 additions and 3 deletions

View file

@ -0,0 +1,36 @@
/*
* Copyright (c) 2021, Ben Wiederhake <BenWiederhake.GitHub@gmx.de>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibGUI/MouseTracker.h>
#include <LibGUI/WindowServerConnection.h>
namespace GUI {
MouseTracker::List MouseTracker::s_trackers;
MouseTracker::MouseTracker()
{
if (s_trackers.is_empty()) {
WindowServerConnection::the().async_set_global_mouse_tracking(true);
}
s_trackers.append(*this);
}
MouseTracker::~MouseTracker()
{
m_list_node.remove();
if (s_trackers.is_empty()) {
WindowServerConnection::the().async_set_global_mouse_tracking(false);
}
}
void MouseTracker::track_mouse_move(Badge<WindowServerConnection>, Gfx::IntPoint const& point)
{
for (auto& tracker : s_trackers) {
tracker.track_mouse_move(point);
}
}
}