Excess MotionNotify events to a minimized window in multiwindow mode
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 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.09375 +0100 +++ xserver-cygwin-1.13.0-1/hw/xwin/win.h 2012-12-10 15:27:40.03125 +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.18750 +0100 +++ xserver-cygwin-1.13.0-1/hw/xwin/winwndproc.c2012-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: -- 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/
Re: Excess MotionNotify events to a minimized window in multiwindow mode
On 10/12/2012 19:01, Heiko Bihr wrote: > 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. I'm not sure I follow your reasoning. If you run 'xev -root', you can see that MotionNotify events are sent from everywhere. Is there some specific problem you are trying to fix? > 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. Thanks for the patch. There are definitely some things wrong with the way that this mouse pointer polling timer works, I noticed during testing that is was possible sometimes to move the pointer out of an xeyes without starting the polling timer. I'm not sure this patch is right though: With this patch applied, if you have 2 xeyes running, minimizing the first one stops the second one from tracking the mouse pointer. -- Jon TURNEY Volunteer Cygwin/X X Server maintainer -- 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/
Re: Excess MotionNotify events to a minimized window in multiwindow mode
On 17.12.2012 19:38, Jon TURNEY wrote: > On 10/12/2012 19:01, Heiko Bihr wrote: >> 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. > I'm not sure I follow your reasoning. If you run 'xev -root', you can see > that MotionNotify events are sent from everywhere. > > Is there some specific problem you are trying to fix? We're running a terminal server setup, that delivers X11 applications (e.g. firefox) via X display forwarding to users' desktops, which run Cygwin/X in multiwindow mode. We noticed quite some network traffic, even if all application windows were minimized. This network traffic is caused by the MotionNotify events, that were still reported to miminized windows. As we want to serve 500+ users, we have to keep an eye on network traffic. > Thanks for the patch. > > There are definitely some things wrong with the way that this mouse pointer > polling timer works, I noticed during testing that is was possible sometimes > to move the pointer out of an xeyes without starting the polling timer. > > I'm not sure this patch is right though: With this patch applied, if you have > 2 xeyes running, minimizing the first one stops the second one from tracking > the mouse pointer. You're right. I did not test with xeyes (although I noticed it being mentioned in a comment), but only with our applications. Unfortunately, I'm not that familiar with Cygwin/X' internal data structures and window handler functions. I thought, each window will have its own timer. But after looking into the source again, i assume, this timer is a global one. Maybe it would be a better approach to disable reporting of MotionNotify events to minimized X client windows, instead of messing with the timer. I'll take a look at it. Regards Heiko -- Dipl.-Inform. Heiko Bihr Senior Consultant, Software Development Business Unit Government secunet Security Networks AG -- 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/
Re: Excess MotionNotify events to a minimized window in multiwindow mode
On 18/12/2012 07:29, Heiko Bihr wrote: > On 17.12.2012 19:38, Jon TURNEY wrote: >> On 10/12/2012 19:01, Heiko Bihr wrote: >>> 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. >> I'm not sure I follow your reasoning. If you run 'xev -root', you can see >> that MotionNotify events are sent from everywhere. >> >> Is there some specific problem you are trying to fix? > We're running a terminal server setup, that delivers X11 applications > (e.g. firefox) via X display forwarding to users' desktops, which run > Cygwin/X in multiwindow mode. > We noticed quite some network traffic, even if all application windows > were minimized. This network traffic is caused by the MotionNotify > events, that were still reported to miminized windows. As we want to > serve 500+ users, we have to keep an eye on network traffic. It might be relevant to note that MotionNotify events were potentially being sent every time the polling timer fired, even if the mouse wasn't moved. This was fixed in 1.13.0-1. In any case, the events should only be sent to clients which have registered an interest using XSelectInput() with PointerMotionMask. >> Thanks for the patch. >> >> There are definitely some things wrong with the way that this mouse pointer >> polling timer works, I noticed during testing that is was possible sometimes >> to move the pointer out of an xeyes without starting the polling timer. >> >> I'm not sure this patch is right though: With this patch applied, if you have >> 2 xeyes running, minimizing the first one stops the second one from tracking >> the mouse pointer. > You're right. I did not test with xeyes (although I noticed it being > mentioned in a comment), but only with our applications. > > Unfortunately, I'm not that familiar with Cygwin/X' internal data > structures and window handler functions. I thought, each window will > have its own timer. But after looking into the source again, i assume, > this timer is a global one. > > Maybe it would be a better approach to disable reporting of MotionNotify > events to minimized X client windows, instead of messing with the timer. > I'll take a look at it. Unfortunately, the way that XWin treats minimized windows is not correct (which also causes other problems), they should probably be unmapped, but aren't. I did work on some patches fixing that a while ago, but that ended up getting blocked by other problems, which I think have now been fixed, so it might be worth revisiting them. -- Jon TURNEY Volunteer Cygwin/X X Server maintainer -- 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/