Skip to content

fix(keyevent): do not emit default ignorable codepoint - #20327

Merged
bors-servo merged 1 commit into
servo:masterfrom
kwonoj:fix-ignore
Mar 22, 2018
Merged

bors-servo merged 1 commit into
servo:masterfrom
kwonoj:fix-ignore

Conversation

@kwonoj

@kwonoj kwonoj commented Mar 18, 2018 •

Copy link
Copy Markdown
Contributor

This PR intends to update KeyEvent emit behavior around #18130. Issue #17146 (comment) briefly explains what's happening in servo currently - there are KeyboardInput event emitted for separated key (modifier, and V in case of paste) and there are also ReceivedCharacter event corresponds to \u{0016}.

0x0016 is unicode representation of Synchronous Idle (https://en.wikipedia.org/wiki/Synchronous_Idle), belong under category of Default Ignorable charater in unicode range doesn't have visual representation (http://www.unicode.org/L2/L2002/02368-default-ignorable.pdf). Currently servo forwards all of emitted event from winit including this, eventually leads into double execution of control event.

In this change try to omit default ignorable charater , if given char received is within range of ignorable do not dispatch KeyEvent. Once those are omitted, current event handling logic already takes care of key event with correct modifier state so duplicated event handling won't occur.

For implementation perspective, std::char in Rust doesn't seem to support isIdentifierIgnorable like other platform does (i.e: https://msdn.microsoft.com/en-us/library/aa285330(v=vs.60).aspx / https://docs.oracle.com/javase/7/docs/api/java/lang/Character.html) - so does quick, naïve range comparison check based on unicode range specified in spec, similar to halfbuzz and other does. (https://github.com/harfbuzz/harfbuzz/blob/master/src/hb-unicode-private.hh#L134)

Lastly, this is indeed behavior of winit to emit all characters by default. Why not try to make upstream changes instead? While I've been reading through issues in winit, issue like rust-windowing/winit#350 trying to emit ignorable character by its intention (delete key ReceivedCharacter is also under category of default ignorable) and let each consumer application handles it as needed. I assume it'll cause breaking changes in winit's design if it intends to omit those characters, instead tried to make application-level changes.

Couple of consideration for review


  • There are tests for these changes OR
  • These changes do not require tests because _____
  • This PR has been locally tested on Windows, Linux machines.

This change is Reviewable

@kwonoj

kwonoj commented Mar 18, 2018

Copy link
Copy Markdown
Contributor Author

Also I feel this is very debatable changes, might not feasible to be accepted. Feel freely close if so.

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Mar 18, 2018
@paulrouget

Copy link
Copy Markdown
Contributor

I'll read more about this, and see how it plays with #17146.
I wish we could find a fix that would address both #17146 and #18130.

@kwonoj

kwonoj commented Mar 19, 2018 •

Copy link
Copy Markdown
Contributor Author

When I gave quick try with this PR unfortunately, it doesn't seem like solve #17146 as well and might need additional digging.

(edited): Confirmed, this PR doesn't fix #17146. It seems different issue.

@paulrouget

Copy link
Copy Markdown
Contributor

I confirmed this fixes #18130, and that might be enough. But I'm still investigating see if there would be a way to get the same behavior as Mac and Linux.

@kwonoj

kwonoj commented Mar 21, 2018 •

Copy link
Copy Markdown
Contributor Author

I agree #17146 should be fixed as well (it bites me too when I try on windows). I just did quick peek and noticed something odd, might try to dig deeper to see if I can conclude on those issues too. So far my observation, ignorable codepoint isn't root cause for #17146. (course it's related though)

@paulrouget

Copy link
Copy Markdown
Contributor

#17146 and #18130 have in common the fact that it's Windows specific. Should we expect Winit to send the same events no matter the OS?

@kwonoj

kwonoj commented Mar 22, 2018 •

Copy link
Copy Markdown
Contributor Author

@paulrouget I feel it's more like way how to winit compose those event, not platform specific. The reason macOS works properly is currently servo binds KeyModifiers::SUPER to CMD_OR_CONTROL - trying same composition via KeyModifiers::CONTROL I could observe same behavior on macOS (also linux distro I'm using too) : confirmed via servo, and winit's bare minimum windows example. In short, with actual KeyModifiers::CONTROL, it works same - winit consistently send event (including unicode codepoint ReceivedCharacter).

What it's needed seems consistent translation in servo's window across platform, regardless of taking CTRL or SUPER. For this PR specific, feel freely close if you think both issue need to be considered as dupe and need single PR to fix for it.

@paulrouget

Copy link
Copy Markdown
Contributor

I see. This is not Windows specific, so Winit is consistent, and I don't find it absurd that Winit sends these key events.

@bors-servo r+

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit da586d0 has been approved by paulrouget

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Mar 22, 2018
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit da586d0 with merge 28c92db...

bors-servo pushed a commit that referenced this pull request Mar 22, 2018
fix(keyevent): do not emit default ignorable codepoint

<!-- Please describe your changes on the following line: -->
This PR intends to update `KeyEvent` emit behavior around #18130. Issue #17146 (comment) briefly explains what's happening in servo currently - there are KeyboardInput event emitted for separated key (modifier, and `V` in case of paste) and there are also `ReceivedCharacter` event corresponds to `\u{0016}`.

`0x0016` is unicode representation of `Synchronous Idle` (https://en.wikipedia.org/wiki/Synchronous_Idle), belong under category of `Default Ignorable` charater in unicode range doesn't have visual representation (http://www.unicode.org/L2/L2002/02368-default-ignorable.pdf). Currently servo forwards all of emitted event from `winit` including this, eventually leads into double execution of control event.

In this change try to omit default ignorable charater , if given char received is within range of ignorable do not dispatch `KeyEvent`. Once those are omitted, current event handling logic already takes care of key event with correct modifier state so duplicated event handling won't occur.

For implementation perspective, `std::char` in Rust doesn't seem to support `isIdentifierIgnorable` like other platform does (i.e: https://msdn.microsoft.com/en-us/library/aa285330(v=vs.60).aspx / https://docs.oracle.com/javase/7/docs/api/java/lang/Character.html) - so does quick, naïve range comparison check based on unicode range specified in spec, similar to halfbuzz and other does. (https://github.com/harfbuzz/harfbuzz/blob/master/src/hb-unicode-private.hh#L134)

Lastly, this is indeed behavior of `winit` to emit all characters by default. *Why not try to make upstream changes instead?* While I've been reading through issues in `winit`, issue like rust-windowing/winit#350 trying to emit ignorable character by its intention (delete key `ReceivedCharacter` is also under category of default ignorable) and let each consumer application handles it as needed. I assume it'll cause breaking changes in winit's design if it intends to omit those characters, instead tried to make application-level changes.

Couple of consideration for review

- Is it desired changes to not emit `KeyEvent` for default ignorable chars? Do we rather want mapping / or restoring back to original char as @paulrouget mentioned in #17146 (comment)?
- Any better, recommended approach to detect unicode char range?
- Maybe try to make upstream changes to `winit` still, like having configuratble way to opt-in(out) those char event?

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #18130 (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____
- This PR has been locally tested on Windows, Linux machines.

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/20327)
<!-- Reviewable:end -->
@bors-servo

Copy link
Copy Markdown
Contributor

☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev
Approved by: paulrouget
Pushing 28c92db to master...

@bors-servo
bors-servo merged commit da586d0 into servo:master Mar 22, 2018
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Mar 22, 2018
@kwonoj
kwonoj deleted the fix-ignore branch March 24, 2018 06:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issue with Double paste on Windows 10

4 participants