An attempt at fixing a bug involving DGA and mouse buttons

Ville Syrjälä syrjala at
Wed Aug 22 06:04:46 PDT 2012

On Sat, Aug 18, 2012 at 08:46:01PM -0500, Steven Elliott wrote:
> I'd like to describe a bug I've encountered involving mouse events and
> DGA as well as my attempt at fixing it.  Hopefully either my patch is
> acceptable, or people will have ideas about how it can be improved.
> I'll mention some specifics about my setup at the end.
> Recently I debugged a problem where an application I used seemed to
> break the X Server so that it was no longer possible to cause windows to
> gain focus by clicking on them.  The application is MCEdit.  It's a
> pygame based python program that edits Minecraft maps.
> In MCEdit clicking the right mouse button engages a freelook mode so
> that moving the mouse changes the user's perspective instead of moving
> the mouse pointer.  Engaging freelook mode in MCEdit causes the problem
> which persists after MCEdit has been shutdown.
> Debugging has revealed that the reason I'm no longer able cause windows
> to gain focus by clicking on them once freelook mode has been used in
> MCEdit is that device->button->buttonsDown ("buttonsDown" only occurs in
> one structure) is not decremented when the mouse button is released
> which causes CheckDeviceGrabs() to return early instead of sending the
> mouse button event to the window being clicked on.
> Further debugging revealed that the reason buttonsDown is not
> decremented when the mouse is released has to do with the fact that DGA
> mode is active during freelook mode.  When DGA mode is active  (when it
> has registered a hook that is called for events so that DGAHandleEvent()
> is called for keyboard and mouse events instead of
> ProcessKeyboardEvent() and ProcessPointerEvent()) the following seems to
> be true:
>   1) DGAProcessPointerEvent() calls UpdateDeviceState() with mouse
> button events where ev.detail.key is not set.
>   2) DGAHandleEvent() refuses to process events that are not master
> events:
>         if (!IsMaster(device))
>             return;
>      which causes UpdateDeviceState() to ignore the master event as it
> thinks the child event has not been processed.

I added this early return because otherwise I would get multiple DGA
events for each button/key press/release.

Unfortunately I don't know the input code very well, so I can't say
whether your patch is he right approach or not. But I wonder if it
would be enough to move the master check to happen inside
DGAProcessKeyboardEvent() and DGAProcessPointerEvent(), after
they've called UpdateDeviceState().

Ville Syrjälä
syrjala at

More information about the xorg-devel mailing list