From 5dabe448bda68a483bf444a4adfed2b25b30f600 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Sat, 24 Nov 2007 15:00:43 +1030 Subject: [PATCH] dix: Add special treatment of NotifyUngrab for enter/leave events. In some cases (e.g. using x2x) the previous model broke, with a window ending not counting down to 0 anymore. Special treatment for NotifyUngrab seems to help here. Current solution: If a NotifyGrab is to be sent ignore it. If a NotifyUngrab enter is sent, only adjust the semaphore if it is on 0. Likewise, do the same for a NotifyUngrab leave if the semaphore is on 1. This seems to work alright so far. --- dix/events.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/dix/events.c b/dix/events.c index 88ce50179..123f21f41 100644 --- a/dix/events.c +++ b/dix/events.c @@ -4468,15 +4468,20 @@ LeaveNotifies(DeviceIntPtr pDev, } } +/* welcome to insanity */ #define FOCUS_SEMAPHORE_MODIFY(win, field, mode, val) \ - { \ - if (mode != NotifyGrab && mode != NotifyUngrab) \ - { \ - FocusSemaphoresPtr sem;\ - sem = (FocusSemaphoresPtr)win->devPrivates[FocusPrivatesIndex].ptr; \ +{ \ + FocusSemaphoresPtr sem;\ + sem = (FocusSemaphoresPtr)win->devPrivates[FocusPrivatesIndex].ptr; \ + if (mode != NotifyGrab && mode != NotifyUngrab) { \ + sem->field += val; \ + } else if (mode == NotifyUngrab) { \ + if (sem->field == 0 && val > 0) \ sem->field += val; \ - } \ - } + else if (sem->field == 1 && val < 0) \ + sem->field += val; \ + } \ +} #define ENTER_LEAVE_SEMAPHORE_UP(win, mode) \ FOCUS_SEMAPHORE_MODIFY(win, enterleave, mode, 1);