conformal / spectrwm

A small dynamic tiling window manager for X11.
ISC License
1.33k stars 96 forks source link

Wrong events are sent on left mouse button #505

Closed Turtleb01 closed 1 year ago

Turtleb01 commented 2 years ago

When pressing the left mouse button in xev, the output looks like this:

LeaveNotify event, serial 40, synthetic NO, window 0x1a00001,
    root 0x1e3, subw 0x0, time 144186919, (957,262), root:(958,797),
    mode NotifyGrab, detail NotifyAncestor, same_screen YES,
    focus YES, state 256

EnterNotify event, serial 40, synthetic NO, window 0x1a00001,
    root 0x1e3, subw 0x0, time 144186920, (957,262), root:(958,797),
    mode NotifyUngrab, detail NotifyAncestor, same_screen YES,
    focus YES, state 256

KeymapNotify event, serial 40, synthetic NO, window 0x0,
    keys:  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
           0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0

ButtonPress event, serial 40, synthetic NO, window 0x1a00001,
    root 0x1e3, subw 0x0, time 144186919, (957,262), root:(958,797),
    state 0x0, button 1, same_screen YES

ButtonRelease event, serial 40, synthetic NO, window 0x1a00001,
    root 0x1e3, subw 0x0, time 144187036, (957,262), root:(958,797),
    state 0x100, button 1, same_screen YES

As you can see from the timestamps, LeaveNotify, EnterNotify and KeymapNotify are sent when lmb is pressed down. No additional events appear when it's released.

In other window managers (dwm and i3 tested) only ButtonPress and ButtonRelease are sent.

Due to this weird behavior, chromium pop-up menus like the right-click menu in openstreetmap.org don't work; the incorrect events close the menu before the click is registered.

wavexx commented 2 years ago

See #224

LordReg commented 1 year ago

These events are generated by the X server and are related to ICCCM 6.3-compliant button grabs. When clicking in a client window and a button grab activates on an ancestor window, the pointer is automatically grabbed. The pointer leaves the client window and enters the ancestor window until the ButtonPress is handled and event queue released/replayed.

The pop-up menu issue is because the application doesn't take into account the possibility that window managers may establish button binding grabs (such as click-to-focus) on parent/root in accordance with ICCCM 6.3.

There is now a workaround in master to avoid these issues.