Skip to content

Commit 11e2882

Browse files
Desktop: Fix Windows build (#3522)
* fix win build * fix mac * Change window button colors to match Windows colors --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
1 parent 9d26c04 commit 11e2882

4 files changed

Lines changed: 19 additions & 35 deletions

File tree

desktop/src/cef/input.rs

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
use cef::sys::{cef_event_flags_t, cef_key_event_type_t, cef_mouse_button_type_t};
1+
use cef::sys::{cef_key_event_type_t, cef_mouse_button_type_t};
22
use cef::{Browser, ImplBrowser, ImplBrowserHost, KeyEvent, MouseEvent};
33
use winit::event::{ButtonSource, ElementState, MouseButton, MouseScrollDelta, WindowEvent};
4-
use winit::keyboard::Key;
54

65
mod keymap;
76
use keymap::{ToCharRepresentation, ToNativeKeycode, ToVKBits};
@@ -70,6 +69,8 @@ pub(crate) fn handle_window_event(browser: &Browser, input_state: &mut InputStat
7069
WindowEvent::KeyboardInput { device_id: _, event, is_synthetic: _ } => {
7170
let Some(host) = browser.host() else { return };
7271

72+
input_state.modifiers_apply_key_event(&event.logical_key, &event.state);
73+
7374
let mut key_event = KeyEvent {
7475
type_: match (event.state, &event.logical_key) {
7576
(ElementState::Pressed, winit::keyboard::Key::Character(_)) => cef_key_event_type_t::KEYEVENT_CHAR,
@@ -82,35 +83,6 @@ pub(crate) fn handle_window_event(browser: &Browser, input_state: &mut InputStat
8283

8384
key_event.modifiers = input_state.cef_modifiers(&event.location, event.repeat).into();
8485

85-
match (&event.logical_key, event.state) {
86-
(Key::Named(winit::keyboard::NamedKey::Control), ElementState::Pressed) => {
87-
key_event.modifiers |= cef_event_flags_t::EVENTFLAG_CONTROL_DOWN.0;
88-
}
89-
(Key::Named(winit::keyboard::NamedKey::Control), ElementState::Released) => {
90-
key_event.modifiers &= !(cef_event_flags_t::EVENTFLAG_CONTROL_DOWN.0);
91-
}
92-
(Key::Named(winit::keyboard::NamedKey::Shift), ElementState::Pressed) => {
93-
key_event.modifiers |= cef_event_flags_t::EVENTFLAG_SHIFT_DOWN.0;
94-
}
95-
(Key::Named(winit::keyboard::NamedKey::Shift), ElementState::Released) => {
96-
key_event.modifiers &= !(cef_event_flags_t::EVENTFLAG_SHIFT_DOWN.0);
97-
}
98-
(Key::Named(winit::keyboard::NamedKey::Alt), ElementState::Pressed) => {
99-
key_event.modifiers |= cef_event_flags_t::EVENTFLAG_ALT_DOWN.0;
100-
}
101-
(Key::Named(winit::keyboard::NamedKey::Alt), ElementState::Released) => {
102-
key_event.modifiers &= !(cef_event_flags_t::EVENTFLAG_ALT_DOWN.0);
103-
}
104-
(Key::Named(winit::keyboard::NamedKey::Meta), ElementState::Pressed) => {
105-
key_event.modifiers |= cef_event_flags_t::EVENTFLAG_COMMAND_DOWN.0;
106-
}
107-
(Key::Named(winit::keyboard::NamedKey::Meta), ElementState::Released) => {
108-
key_event.modifiers &= !(cef_event_flags_t::EVENTFLAG_COMMAND_DOWN.0);
109-
}
110-
111-
_ => {}
112-
}
113-
11486
key_event.windows_key_code = match &event.logical_key {
11587
winit::keyboard::Key::Named(named) => named.to_vk_bits(),
11688
winit::keyboard::Key::Character(char) => char.chars().next().unwrap_or_default().to_vk_bits(),

desktop/src/cef/input/state.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use cef::sys::cef_event_flags_t;
33
use std::time::Instant;
44
use winit::dpi::PhysicalPosition;
55
use winit::event::{ElementState, MouseButton};
6-
use winit::keyboard::{KeyLocation, ModifiersState};
6+
use winit::keyboard::{Key, KeyLocation, ModifiersState, NamedKey};
77

88
use crate::cef::consts::{MULTICLICK_ALLOWED_TRAVEL, MULTICLICK_TIMEOUT};
99

@@ -19,6 +19,18 @@ impl InputState {
1919
self.modifiers = *modifiers;
2020
}
2121

22+
pub(crate) fn modifiers_apply_key_event(&mut self, key: &Key, state: &ElementState) {
23+
let bits = match key {
24+
Key::Named(NamedKey::Shift) => ModifiersState::SHIFT,
25+
Key::Named(NamedKey::Control) => ModifiersState::CONTROL,
26+
Key::Named(NamedKey::Alt) => ModifiersState::ALT,
27+
Key::Named(NamedKey::Meta) => ModifiersState::META,
28+
_ => return,
29+
};
30+
let is_pressed = matches!(state, ElementState::Pressed);
31+
self.modifiers.set(bits, is_pressed);
32+
}
33+
2234
pub(crate) fn cursor_move(&mut self, position: &PhysicalPosition<f64>) -> bool {
2335
let new = position.into();
2436
if self.mouse_position == new {

desktop/wrapper/src/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub(crate) mod menu {
2121
widgets
2222
.into_iter()
2323
.map(|widget| {
24-
let text_button = match &widget.widget {
24+
let text_button = match widget.widget.as_ref() {
2525
Widget::TextButton(text_button) => text_button,
2626
_ => panic!("Menu bar layout top-level widgets are supposed to be text buttons"),
2727
};

frontend/src/components/window/title-bar/WindowButtonsWindows.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@
3232
}
3333
3434
&:hover {
35-
background: var(--color-6-lowergray);
35+
background: #2d2d2d;
3636
3737
svg {
3838
fill: var(--color-f-white);
3939
}
4040
}
4141
4242
&:last-of-type:hover {
43-
background: #e81123;
43+
background: #c42b1c;
4444
}
4545
}
4646
</style>

0 commit comments

Comments
 (0)