Re: [dev] [dwm] Avoid requesting MotionNotify events

From: FRIGN <>
Date: Sat, 16 Jul 2016 23:25:12 +0200

On Sat, 16 Jul 2016 14:33:18 +0300 (MSK)
Alexander Monakov <> wrote:

Hey Alexander,

> A while ago dwm started requesting MotionNotify events from the X
> server (that wasn't always the case). This was added when
> focus-follows-mouse was implemented for monitors (in addition to
> windows) in 2011 by commit b5068e32e9.
> This causes lots of useless communication between the X server and
> dwm every time the mouse pointer is moved, even when nothing could
> possibly change as a result (e.g. if Xinerama is not compiled in, or
> only one monitor is present). On my system, the resulting
> syscalls-per-second count in dwm is about 490, if the mouse if moved
> continuously.
> The following patch fixes the issue in the minimal way only when
> Xinerama support is not enabled at all. I'd find it worthwhile to
> fix this under Xinerama too. To outline a partial solution for
> one-monitor-connected case, moving XSelectInput to updategeom will
> allow to request MotionNotify events only when monitor count is 2 or
> more. I don't have a patch for this yet, but I'll be happy to create
> one if desired.
> For multiple-monitors case, it should be possible to avoid
> MotionNotify events too, by creating InputOnly subwindows of the root
> window corresponding to monitor boundaries, and using EnterNotify
> events on those to trigger monitor focus changes. I'm not really
> familiar with Xlib, so I haven't worked out the details here, but if
> there's interest in this solution I can look into it.

nice work soldier! Can you elaborate on how you measured the syscalls
per second? I'd be really interested because this telemetry data could
really help improve the tools, especially those wrt to
the Xlibs, which might run but can turn out to be quite ineffective
(as you have shown here).

I wondered about these CPU-spikes in dwm as well.



Received on Sat Jul 16 2016 - 23:25:12 CEST

This archive was generated by hypermail 2.3.0 : Sat Jul 16 2016 - 23:36:10 CEST