Excess MotionNotify events to a minimized window in multiwindow mode

Heiko Bihr heiko.bihr@secunet.com
Mon Dec 10 19:01:00 GMT 2012


Hi,

I think, there is a problem with mouse polling in multiwindow mode
(XWin.exe :0 -multiwindow) in Cygwin/X 1.13.
If a window gets maximized and then minimized, it will receive motion
notify events, whenever the user moves the mouse cursor over the screen.

To reproduce the problem, please follow these steps:

1) start XWin.exe in -multiwindow mode
2) start xev
3) maximize xev window
4) minimize xev window
5) move mouse cursor around and watch xev output

You will see lots of MotionNotify events from all over the screen.
X.org does not show this behaviour and I think, Cygwin/X should not either.

The problem is caused by the WIN_POLLING_MOUSE_TIMER_ID, which doesn't
get stopped, when the user minimizes a window.

I made a small patch against Cygwin/X 1.13.0-1 which will stop the
WIN_POLLING_MOUSE_TIMER_ID, whenever the user minimizes a window. If the
user changes the window's size again, and the timer was stopped, it will
be started again.
The patch introduces a new flag in s_pScreenPriv to remember the state
of the timer.

Regards
Heiko Bihr

-- 
Dipl.-Inform. Heiko Bihr
Senior Consultant, Software Development
Business Unit Government
secunet Security Networks AG

-------------- next part --------------
diff -ur xserver-cygwin-1.13.0-1.orig/hw/xwin/win.h xserver-cygwin-1.13.0-1/hw/xwin/win.h
--- xserver-cygwin-1.13.0-1.orig/hw/xwin/win.h	2012-12-10 15:19:42.093750000 +0100
+++ xserver-cygwin-1.13.0-1/hw/xwin/win.h	2012-12-10 15:27:40.031250000 +0100
@@ -595,6 +595,9 @@
     UnrealizeFontPtr UnrealizeFont;
 #endif
 
+    /* mouse polling */
+    BOOL bMousePollingTimerStoppedWhileMinimized;
+
 } winPrivScreenRec;
 
 #ifdef XWIN_MULTIWINDOWEXTWM
diff -ur xserver-cygwin-1.13.0-1.orig/hw/xwin/winmultiwindowwndproc.c xserver-cygwin-1.13.0-1/hw/xwin/winmultiwindowwndproc.c
--- xserver-cygwin-1.13.0-1.orig/hw/xwin/winmultiwindowwndproc.c	2012-12-10 15:19:42.140625000 +0100
+++ xserver-cygwin-1.13.0-1/hw/xwin/winmultiwindowwndproc.c	2012-12-10 15:26:50.359375000 +0100
@@ -415,6 +415,22 @@
 
         SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR) XMING_SIGNATURE);
 
+        /*
+         * Initialize variables for mouse polling in s_pScreenPriv.
+         * Need to initialize s_pSreenPriv first, as WIN_WINDOW_PROP
+         * was read before we set it in WM_CREATE 
+         */
+        if ((pWin = GetProp (hwnd, WIN_WINDOW_PROP)) != NULL)
+          {
+            /* Get a pointer to our window privates */
+            pWinPriv = winGetWindowPriv(pWin);
+            
+            /* Get pointers to our screen privates and screen info */
+            s_pScreenPriv = pWinPriv->pScreenPriv;
+            
+            s_pScreenPriv->bMousePollingTimerStoppedWhileMinimized = FALSE;
+  	}
+
         return 0;
 
     case WM_INIT_SYS_MENU:
@@ -1007,6 +1023,27 @@
         return 0;
 
     case WM_SIZE:
+        if(wParam == SIZE_MINIMIZED)
+          {
+            /* Kill the timer used to poll mouse events, if window gets minimized */
+            if (g_uipMousePollingTimerID != 0)
+              {
+                KillTimer (s_pScreenPriv->hwndScreen, WIN_POLLING_MOUSE_TIMER_ID);
+                g_uipMousePollingTimerID = 0;
+                s_pScreenPriv->bMousePollingTimerStoppedWhileMinimized = TRUE;
+              }
+          }
+        else
+          {
+            /* If timer was killed on minimize, restart it */
+            if(s_pScreenPriv->bMousePollingTimerStoppedWhileMinimized == TRUE)
+              {
+                s_pScreenPriv->bMousePollingTimerStoppedWhileMinimized = FALSE;
+                winStartMousePolling(s_pScreenPriv);
+              }
+          }
+
+
         /* see dix/window.c */
 #if CYGWINDOWING_DEBUG
     {
diff -ur xserver-cygwin-1.13.0-1.orig/hw/xwin/winwndproc.c xserver-cygwin-1.13.0-1/hw/xwin/winwndproc.c
--- xserver-cygwin-1.13.0-1.orig/hw/xwin/winwndproc.c	2012-12-10 15:19:42.187500000 +0100
+++ xserver-cygwin-1.13.0-1/hw/xwin/winwndproc.c	2012-12-10 15:20:52.703125000 +0100
@@ -139,6 +139,10 @@
 
             winInitNotifyIcon(s_pScreenPriv);
         }
+
+	/* initialize variables for mouse polling in s_pScreenPriv */
+	s_pScreenPriv->bMousePollingTimerStoppedWhileMinimized = FALSE;
+
         return 0;
 
     case WM_DISPLAYCHANGE:

-------------- next part --------------
--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://x.cygwin.com/docs/
FAQ:                   http://x.cygwin.com/docs/faq/


More information about the Cygwin-xfree mailing list