Skip to content

Commit

Permalink
fix(keyboard): space event (#251)
Browse files Browse the repository at this point in the history
  • Loading branch information
pewsheen authored Dec 3, 2024
1 parent fe31655 commit 0bcade2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
10 changes: 8 additions & 2 deletions src/compositor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,16 @@ use servo_geometry::{DeviceIndependentIntSize, DeviceIndependentPixel};
use style_traits::{CSSPixel, PinchZoomFactor};
use webrender::{RenderApi, Transaction};
use webrender_api::units::{
DeviceIntPoint, DeviceIntRect, DeviceIntSize, DevicePixel, DevicePoint, LayoutPoint, LayoutRect, LayoutSize, LayoutVector2D, WorldPoint
DeviceIntPoint, DeviceIntRect, DeviceIntSize, DevicePixel, DevicePoint, LayoutPoint,
LayoutRect, LayoutSize, LayoutVector2D, WorldPoint,
};
use webrender_api::{
BorderRadius, BoxShadowClipMode, BuiltDisplayList, ClipMode, ColorF, CommonItemProperties, ComplexClipRegion, DirtyRect, DisplayListPayload, DocumentId, Epoch as WebRenderEpoch, ExternalScrollId, FontInstanceFlags, FontInstanceKey, FontInstanceOptions, FontKey, HitTestFlags, PipelineId as WebRenderPipelineId, PropertyBinding, ReferenceFrameKind, RenderReasons, SampledScrollOffset, ScrollLocation, SpaceAndClipInfo, SpatialId, SpatialTreeItemKey, TransformStyle
BorderRadius, BoxShadowClipMode, BuiltDisplayList, ClipMode, ColorF, CommonItemProperties,
ComplexClipRegion, DirtyRect, DisplayListPayload, DocumentId, Epoch as WebRenderEpoch,
ExternalScrollId, FontInstanceFlags, FontInstanceKey, FontInstanceOptions, FontKey,
HitTestFlags, PipelineId as WebRenderPipelineId, PropertyBinding, ReferenceFrameKind,
RenderReasons, SampledScrollOffset, ScrollLocation, SpaceAndClipInfo, SpatialId,
SpatialTreeItemKey, TransformStyle,
};
use webrender_traits::display_list::{HitTestInfo, ScrollTree};
use webrender_traits::{
Expand Down
10 changes: 5 additions & 5 deletions src/keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ pub const CMD_OR_ALT: Modifiers = Modifiers::ALT;
/// matches [`NamedKey::Escape`] => [`Key::Escape`], [`NamedKey::F1`] => [`Key::F2`], [`NamedKey::F3`] => [`Key::F3`],...
macro_rules! logical_to_winit_key {
// Matches an optional token
(@opt $_: ident, $optional: ident) => {
Key::$optional
(@opt $_: ident, $optional: expr) => {
$optional
};

(@opt $variant: ident) => {
Key::$variant
};

($key: ident $(,$variant: ident $(=> $matchto: ident)?)+) => {
($key: ident $(,$variant: ident $(=> $matchto: expr)?)+) => {
match $key {
LogicalKey::Character(c) => Key::Character(c.to_string()),
$(LogicalKey::Named(NamedKey::$variant) => logical_to_winit_key!(@opt $variant $(, $matchto)?),)+
Expand All @@ -64,7 +64,6 @@ fn get_servo_key_from_winit_key(key: &LogicalKey) -> Key {
Pause, Insert, Home, Delete, End, PageDown, PageUp,
ArrowLeft, ArrowUp, ArrowRight, ArrowDown,
Backspace, Enter,
// printable: Space
Compose,
// Caret not mapped
NumLock,
Expand Down Expand Up @@ -104,7 +103,8 @@ fn get_servo_key_from_winit_key(key: &LogicalKey) -> Key {
// printable Yen,
Copy,
Paste,
Cut
Cut,
Space => Key::Character(" ".to_string())
}
}

Expand Down

0 comments on commit 0bcade2

Please sign in to comment.