Fix XI2 Scrolling Issue (#12603)

Owen Law created

ref #11679
https://github.com/zed-industries/zed/pull/11235#issuecomment-2144727144

Filters leave events to ensure they are in the normal notify leave
events (not grab or ungrab)
([spec](https://www.x.org/releases/X11R7.7/doc/inputproto/XI2proto.txt)).
Confirmed to fix the issue @mrnugget was having.

Release Notes:

- linux: Fixed a regression that caused some X11 input devices being
unable to scroll.

Change summary

crates/gpui/src/platform/linux/x11/client.rs | 2 +-
crates/gpui/src/platform/linux/x11/window.rs | 2 --
2 files changed, 1 insertion(+), 3 deletions(-)

Detailed changes

crates/gpui/src/platform/linux/x11/client.rs 🔗

@@ -766,7 +766,7 @@ impl X11Client {
                     valuator_idx += 1;
                 }
             }
-            Event::XinputLeave(event) => {
+            Event::XinputLeave(event) if event.mode == xinput::NotifyMode::NORMAL => {
                 self.0.borrow_mut().scroll_x = None; // Set last scroll to `None` so that a large delta isn't created if scrolling is done outside the window (the valuator is global)
                 self.0.borrow_mut().scroll_y = None;
 

crates/gpui/src/platform/linux/x11/window.rs 🔗

@@ -261,8 +261,6 @@ impl X11WindowState {
             .event_mask(
                 xproto::EventMask::EXPOSURE
                     | xproto::EventMask::STRUCTURE_NOTIFY
-                    | xproto::EventMask::ENTER_WINDOW
-                    | xproto::EventMask::LEAVE_WINDOW
                     | xproto::EventMask::FOCUS_CHANGE
                     | xproto::EventMask::KEY_PRESS
                     | xproto::EventMask::KEY_RELEASE,