Draft
Conversation
Finally figured out how to do this. This change makes it possible for the first time for the overlay window to react to keyboard events, and so it's possible to make any arbitrary interactive web UI with it! It's pretty neato. This is a proof of concept! There are many minor bugs, like drag-and-drop completely breaks when trying to drag out of the overlay's clickable area, and enter/leave events jitter when sweeping the mouse along edges of the screen. That kind of thing. Related to #3 and #5, but not global; no events are duplicated here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
So I finally figured out how to make an
override_redirectwindow get keyboard focus: it has to grab the keyboard device itself. d40cb15 is an initial proof of concept that this works. This draft PR is a dumping ground for thoughts and plans on how to proceed, toward something stable enough to release, as if I ever finished anything worthwhile.If you check out the
grab-keyboardbranch and run theexample/, the leftmost 100 pixels of column on your leftmost monitor should be a clickable area, and when you hover over it, you can also type text, which the webview can react to as you'd expect by listening tokeydownevents.Peek.2021-05-03.04-00.mp4
Incidentally, this also makes it possible to type into the Web Inspector also when it is docked to the overlay window.
Bugs to be fixed:
Drag-and-drop gets into a broken state when trying to drag selected text out of the overlay's clickable area.
It would be real smooth if it were possible to drag and drop whatever across the boundary, but if it turns out to be too hard, just cancelling the drag and not breaking is still good enough to release.
The window gets erroneously jittery enter/leave events when moving the mouse near the edges of the screen.
A workaround that seems to work according to brief testing: Just make the window 1 pixel larger in every dimension than the desktop area, and position it so it's indistinguishable. The event jitter only happens on the edge pixel.
Also have to think about the API design of this. My plan so far is to add
Hudkit.grabKeyboard()/.ungrabKeyboard()to the JS API, so user code can grab it when appropriate, instead of always. You might for example want some elements to only be clickable, without grabbing keyboard focus when they are hovered, while others should grab keyboard focus.The command line flag to control this could look like
--grab-keyboardfollowed bynever: do not ever grab keyboard focus; related JS API does nothingon-hover: always grab keyboard when clickable part of overlay is hovered; related JS API does nothingon-js: enable the related JS APIHaven't decided what the default should be yet.