Gecko:Notes for mouse driver developers on Windows

From MozillaWiki
Jump to: navigation, search

This document is informative.


Gecko supports both WM_MOUSEWHEEL and WM_MOUSEHWHEEL messages, so, all mouse drivers and utilities should post (or send) them to Gecko's window.

Be aware, Gecko 1.9.3 and later (Firefox 3.7 and later) is going to support WM_VSCROLL and WM_HSCROLL messages too, however, do not post/send these messages for the wheel action. Gecko handles these messages in different path with WM_MOUSEWHEEL and WM_MOUSEHWHEEL because Gecko thinks that the messages are used only for scrolling. To put it concretely, WM_MOUSEWHEEL and WM_MOUSEHWHEEL messages cause DOMMouseScroll event on the web pages, so, web application developers can handle the wheel actions and they can prevent scrolling. However, WM_VSCROLL and WM_HSCROLL don't cause the DOM event, it only scrolls a scrollable area. So, the scrolling by these messages are same as the scrolling by scrollbar operation. I.e., web developers cannot know whether the scrolling is caused by scrollbar operation or mouse wheel action.

Post/Send the messages to focused Gecko's window

Please post/send the messages to focused Gecko's window rather than the window under the mouse cursor. Gecko honors the mouse cursor position when Gecko chose a scrolling target (detail of the rule is documented in Gecko:Mouse_Wheel_Scrolling). So, Gecko redirects the messages to a window under the cursor automatically.

Note that Gecko doesn't redirect the messages to a plug-in window even if it's under the mouse cursor (Gecko 1.9.3 and later). The reason is that Gecko manages mouse wheel transaction (documented in Gecko:Mouse_Wheel_Scrolling). The user may want to scroll the parent scrollable area of plug-in. For example, a plug-in window may come under the mouse cursor by scrolling its parent scrollable area, then, Gecko tries to keep scrolling the parent scrollable area rather than the plug-in's content. So, if some mouse drivers/utilities post/send messages to a plug-in window directly, it causes breaking this feature.

Please use wheel messages to unknown window

Gecko 1.9.2 and later (Firefox 3.6 and later) create following class name windows. Note that this could be changed in future version.

  • MozillaHiddenWindowClass
  • MozillaUIWindowClass
  • MozillaContentWindowClass
  • MozillaContentFrameWindowClass
  • MozillaWindowClass
  • MozillaDialogClass
  • MozillaDropShadowWindowClass

You can assume that if focused window class name is one of them, you can post/send WM_MOUSEWHEEL and WM_MOUSEHWHEEL messages without any hacks.

Unfortunately, Gecko window structure was changed at Firefox 3.6. Then, we confirmed that some mouse drivers/utilities become that they don't post/send the messages. The messages are standard mouse wheel events on Windows applications. I can understand that some old applications don't support them by historical reasons. The mouse drivers/utilities developers can use hacky way for them, however, it's bad if you assume that all unknown windows are so.