Bug 257910 - [GTK] No key modifier present in wheel event
Summary: [GTK] No key modifier present in wheel event
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: Other
Hardware: PC Linux
: P2 Normal
Assignee: Michael Catanzaro
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-06-09 13:54 PDT by Elie Donadio
Modified: 2023-06-12 23:08 PDT (History)
2 users (show)

See Also:


Attachments
test case of the bug (686 bytes, text/html)
2023-06-09 13:54 PDT, Elie Donadio
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Elie Donadio 2023-06-09 13:54:52 PDT
Created attachment 466656 [details]
test case of the bug

The modifier key (ctrlKey, shiftKey,...) properties of the WheelEvent are always false when read from a wheel event callback. 

Tested in Epiphany 44.3-1 and in an embedded application using Webkit2gtk 2.40.2-1, on Arch Linux. 

A test case is provided as an attachement. When scrolling over the red square while the Ctrl key is held down, should turn green. Passes on Firefox 114.0.
Comment 1 Elie Donadio 2023-06-10 02:25:33 PDT
I've done a first investigation myself on the question, and I found the problem to be here : https://github.com/WebKit/WebKit/blob/ef93c1b412c09e10975907c8fd683269eb36a413/Source/WebKit/Shared/gtk/NativeWebWheelEventGtk.cpp#LL41C13-L41C13

The modifier events that could have been extracted from the GtkEventScroll are not transmitted to the constructor of WebEvent. This is handled better for key presses (https://github.com/WebKit/WebKit/blob/ef93c1b412c09e10975907c8fd683269eb36a413/Source/WebKit/Shared/gtk/WebEventFactory.cpp#L259), where a factory function parses the GtkEventScroll.state property and transmits the modifier keys using the modifiersForEvent(const GdkEvent*) function. 

This is my first time delving into the Webkit codebase and I'm not a professional programmer so I don't really want to make the change myself, but I can try if nobody's up for it...
Comment 2 Elie Donadio 2023-06-10 02:35:09 PDT
See also https://github.com/WebKit/WebKit/blob/ef93c1b412c09e10975907c8fd683269eb36a413/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp#L1409 for where the event is handled on the Gtk side and first dispatched to the page Proxy. Strangely enough the key modifiers are even queried a few lines up (l402), but never checked again further down the call stack.
Comment 3 Michael Catanzaro 2023-06-10 07:15:55 PDT
Nice investigation. This probably explains why all those "hold Ctrl to scroll" maps on various websites do not work.
Comment 4 Michael Catanzaro 2023-06-12 08:19:58 PDT
Pull request: https://github.com/WebKit/WebKit/pull/14863
Comment 5 EWS 2023-06-12 23:08:36 PDT
Committed 265104@main (c313668f2cf7): <https://commits.webkit.org/265104@main>

Reviewed commits have been landed. Closing PR #14863 and removing active labels.