WindowServer+LibGUI: Implement automatic cursor tracking.

When a mouse button is pressed inside a window, put that window into an
automatic mouse tracking state where all mouse events are sent to that
window until all mouse buttons are released.

This might feel even better if it only cared about the mouse buttons you
actually pressed while *inside* the windows to get released, I don't know.
I'll have to use it for a while and see how it's like.
This commit is contained in:
Andreas Kling 2019-03-24 15:01:56 +01:00
parent e84823360d
commit b4da451c9a
Notes: sideshowbarker 2024-07-19 14:57:11 +09:00
11 changed files with 66 additions and 56 deletions

View file

@ -46,7 +46,7 @@ void GButton::paint_event(GPaintEvent& event)
void GButton::mousemove_event(GMouseEvent& event)
{
if (m_tracking_cursor) {
if (event.buttons() == GMouseButton::Left) {
bool being_pressed = rect().contains(event.position());
if (being_pressed != m_being_pressed) {
m_being_pressed = being_pressed;
@ -63,8 +63,6 @@ void GButton::mousedown_event(GMouseEvent& event)
#endif
if (event.button() == GMouseButton::Left) {
m_being_pressed = true;
m_tracking_cursor = true;
set_global_cursor_tracking(true);
update();
}
GWidget::mousedown_event(event);
@ -84,8 +82,6 @@ void GButton::mouseup_event(GMouseEvent& event)
if (event.button() == GMouseButton::Left) {
bool was_being_pressed = m_being_pressed;
m_being_pressed = false;
m_tracking_cursor = false;
set_global_cursor_tracking(false);
update();
if (was_being_pressed)
click();