From 11e2882cb2b6296c716a02f2ff8b1ca5ded856c1 Mon Sep 17 00:00:00 2001 From: Timon Date: Mon, 22 Dec 2025 22:48:13 +0000 Subject: [PATCH] Desktop: Fix Windows build (#3522) * fix win build * fix mac * Change window button colors to match Windows colors --------- Co-authored-by: Keavon Chambers --- desktop/src/cef/input.rs | 34 ++----------------- desktop/src/cef/input/state.rs | 14 +++++++- desktop/wrapper/src/utils.rs | 2 +- .../title-bar/WindowButtonsWindows.svelte | 4 +-- 4 files changed, 19 insertions(+), 35 deletions(-) diff --git a/desktop/src/cef/input.rs b/desktop/src/cef/input.rs index bf15ec46..a13d8fa2 100644 --- a/desktop/src/cef/input.rs +++ b/desktop/src/cef/input.rs @@ -1,7 +1,6 @@ -use cef::sys::{cef_event_flags_t, cef_key_event_type_t, cef_mouse_button_type_t}; +use cef::sys::{cef_key_event_type_t, cef_mouse_button_type_t}; use cef::{Browser, ImplBrowser, ImplBrowserHost, KeyEvent, MouseEvent}; use winit::event::{ButtonSource, ElementState, MouseButton, MouseScrollDelta, WindowEvent}; -use winit::keyboard::Key; mod keymap; use keymap::{ToCharRepresentation, ToNativeKeycode, ToVKBits}; @@ -70,6 +69,8 @@ pub(crate) fn handle_window_event(browser: &Browser, input_state: &mut InputStat WindowEvent::KeyboardInput { device_id: _, event, is_synthetic: _ } => { let Some(host) = browser.host() else { return }; + input_state.modifiers_apply_key_event(&event.logical_key, &event.state); + let mut key_event = KeyEvent { type_: match (event.state, &event.logical_key) { (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 key_event.modifiers = input_state.cef_modifiers(&event.location, event.repeat).into(); - match (&event.logical_key, event.state) { - (Key::Named(winit::keyboard::NamedKey::Control), ElementState::Pressed) => { - key_event.modifiers |= cef_event_flags_t::EVENTFLAG_CONTROL_DOWN.0; - } - (Key::Named(winit::keyboard::NamedKey::Control), ElementState::Released) => { - key_event.modifiers &= !(cef_event_flags_t::EVENTFLAG_CONTROL_DOWN.0); - } - (Key::Named(winit::keyboard::NamedKey::Shift), ElementState::Pressed) => { - key_event.modifiers |= cef_event_flags_t::EVENTFLAG_SHIFT_DOWN.0; - } - (Key::Named(winit::keyboard::NamedKey::Shift), ElementState::Released) => { - key_event.modifiers &= !(cef_event_flags_t::EVENTFLAG_SHIFT_DOWN.0); - } - (Key::Named(winit::keyboard::NamedKey::Alt), ElementState::Pressed) => { - key_event.modifiers |= cef_event_flags_t::EVENTFLAG_ALT_DOWN.0; - } - (Key::Named(winit::keyboard::NamedKey::Alt), ElementState::Released) => { - key_event.modifiers &= !(cef_event_flags_t::EVENTFLAG_ALT_DOWN.0); - } - (Key::Named(winit::keyboard::NamedKey::Meta), ElementState::Pressed) => { - key_event.modifiers |= cef_event_flags_t::EVENTFLAG_COMMAND_DOWN.0; - } - (Key::Named(winit::keyboard::NamedKey::Meta), ElementState::Released) => { - key_event.modifiers &= !(cef_event_flags_t::EVENTFLAG_COMMAND_DOWN.0); - } - - _ => {} - } - key_event.windows_key_code = match &event.logical_key { winit::keyboard::Key::Named(named) => named.to_vk_bits(), winit::keyboard::Key::Character(char) => char.chars().next().unwrap_or_default().to_vk_bits(), diff --git a/desktop/src/cef/input/state.rs b/desktop/src/cef/input/state.rs index d3c249cb..79fa65ee 100644 --- a/desktop/src/cef/input/state.rs +++ b/desktop/src/cef/input/state.rs @@ -3,7 +3,7 @@ use cef::sys::cef_event_flags_t; use std::time::Instant; use winit::dpi::PhysicalPosition; use winit::event::{ElementState, MouseButton}; -use winit::keyboard::{KeyLocation, ModifiersState}; +use winit::keyboard::{Key, KeyLocation, ModifiersState, NamedKey}; use crate::cef::consts::{MULTICLICK_ALLOWED_TRAVEL, MULTICLICK_TIMEOUT}; @@ -19,6 +19,18 @@ impl InputState { self.modifiers = *modifiers; } + pub(crate) fn modifiers_apply_key_event(&mut self, key: &Key, state: &ElementState) { + let bits = match key { + Key::Named(NamedKey::Shift) => ModifiersState::SHIFT, + Key::Named(NamedKey::Control) => ModifiersState::CONTROL, + Key::Named(NamedKey::Alt) => ModifiersState::ALT, + Key::Named(NamedKey::Meta) => ModifiersState::META, + _ => return, + }; + let is_pressed = matches!(state, ElementState::Pressed); + self.modifiers.set(bits, is_pressed); + } + pub(crate) fn cursor_move(&mut self, position: &PhysicalPosition) -> bool { let new = position.into(); if self.mouse_position == new { diff --git a/desktop/wrapper/src/utils.rs b/desktop/wrapper/src/utils.rs index c62fe8f4..ca246dfa 100644 --- a/desktop/wrapper/src/utils.rs +++ b/desktop/wrapper/src/utils.rs @@ -21,7 +21,7 @@ pub(crate) mod menu { widgets .into_iter() .map(|widget| { - let text_button = match &widget.widget { + let text_button = match widget.widget.as_ref() { Widget::TextButton(text_button) => text_button, _ => panic!("Menu bar layout top-level widgets are supposed to be text buttons"), }; diff --git a/frontend/src/components/window/title-bar/WindowButtonsWindows.svelte b/frontend/src/components/window/title-bar/WindowButtonsWindows.svelte index 38e40661..72e305cf 100644 --- a/frontend/src/components/window/title-bar/WindowButtonsWindows.svelte +++ b/frontend/src/components/window/title-bar/WindowButtonsWindows.svelte @@ -32,7 +32,7 @@ } &:hover { - background: var(--color-6-lowergray); + background: #2d2d2d; svg { fill: var(--color-f-white); @@ -40,7 +40,7 @@ } &:last-of-type:hover { - background: #e81123; + background: #c42b1c; } }