Skip to content

gdk: Don't reset scroll valuators on XINotifyUngrab

Vlad Zahorodnii requested to merge zzag/gtk:wip/zzag/kwin-passive-grab into gtk-3-24

The window manager may establish a passive grab in order to implement things such as moving or resizing windows with Alt or Meta key. But the window manager can go a bit further and provide the user a way to assign a custom mouse wheel action for inactive windows. One of such window managers is kwin. If no custom mouse wheel action is assigned, kwin will just replay the wheel event.

Since the wheel event is going to be delivered to the grabbing client (kwin) and the actual client (e.g. gedit), a crossing event will be generated. The client needs to filter out that crossing event or else scroll valuators will be reset every time a wheel event is delivered.

In order to filter out crossing events generated by passive grabs, the client needs to check whether the received XI_Enter event comes with mode XINotifyUngrab.

Unfortunately, only the grabbing client will receive an XI_Enter event with mode XINotifyPassiveUngrab. From the XI2 spec:

"If an enter or focus in grab activates, additional EnterNotify events with mode XIPassiveGrabNotify are generated as if the pointer or focus were to suddenly warp from its current position to some position in the grab window. These events are sent to the grabbing client only and only if the grab event mask has selected for it. If such a passive grab deactivates, addional LeaveNotify events with mode XIPassiveUngrabNotify are generated and sent to the grabbing client before the grab deactivates."

fixes #1213

Edited by Vlad Zahorodnii

Merge request reports