Skip to content

Commit 1cacf91

Browse files
update CEF to 142
1 parent 94e5c8f commit 1cacf91

File tree

7 files changed

+101
-118
lines changed

7 files changed

+101
-118
lines changed

.nix/deps/cef.nix

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,24 @@
11
{ pkgs, inputs, ... }:
22

33
let
4-
libcef = pkgs.libcef.overrideAttrs (
5-
_: _: {
6-
postInstall = ''
7-
strip $out/lib/*
8-
'';
9-
}
10-
);
11-
cefPath = pkgs.runCommand "cef-path" { } ''
4+
cef = pkgs.cef-binary.overrideAttrs (_: _: {
5+
postInstall = ''
6+
strip $out/Release/*.so*
7+
'';
8+
});
9+
10+
cefPath = pkgs.runCommand "cef-path" {} ''
1211
mkdir -p $out
1312
14-
ln -s ${libcef}/include $out/include
15-
find ${libcef}/lib -type f -name "*" -exec ln -s {} $out/ \;
16-
find ${libcef}/libexec -type f -name "*" -exec ln -s {} $out/ \;
17-
cp -r ${libcef}/share/cef/* $out/
13+
ln -s ${cef}/include $out/include
14+
find ${cef}/Release -name "*" -type f -exec ln -s {} $out/ \;
15+
find ${cef}/Resources -name "*" -maxdepth 1 -exec ln -s {} $out/ \;
1816
19-
echo '${
20-
builtins.toJSON {
21-
type = "minimal";
22-
name = builtins.baseNameOf libcef.src.url;
23-
sha1 = "";
24-
}
25-
}' > $out/archive.json
17+
echo '${builtins.toJSON {
18+
type = "minimal";
19+
name = builtins.baseNameOf cef.src.url;
20+
sha1 = "";
21+
}}' > $out/archive.json
2622
'';
2723
in
2824
{

.nix/flake.lock

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.lock

Lines changed: 27 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,8 @@ iai-callgrind = { version = "0.16" }
227227
ndarray = "0.16"
228228
strum = { version = "0.27", features = ["derive"] }
229229
dirs = "6.0"
230-
# TODO: remove fork usage when https://github.com/tauri-apps/cef-rs/pull/272 is merged and published
231-
cef = { git = "https://github.com/timon-schelling/cef-rs.git", rev = "98493a182928f1ff8d5bf8b9eea61483235df75d" }
232-
cef-dll-sys = { git = "https://github.com/timon-schelling/cef-rs.git", rev = "98493a182928f1ff8d5bf8b9eea61483235df75d" }
230+
cef = "142"
231+
cef-dll-sys = "142"
233232
include_dir = "0.7"
234233
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
235234
tracing = "0.1"
@@ -270,4 +269,3 @@ debug = true
270269
[patch.crates-io]
271270
# Force cargo to use only one version of the dpi crate (vendoring breaks without this)
272271
dpi = { git = "https://github.com/rust-windowing/winit.git" }
273-

desktop/src/cef/input.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pub(crate) fn handle_window_event(browser: &Browser, input_state: &mut InputStat
7979
..Default::default()
8080
};
8181

82-
key_event.modifiers = input_state.cef_modifiers(&event.location, event.repeat).raw();
82+
key_event.modifiers = input_state.cef_modifiers(&event.location, event.repeat).0;
8383

8484
key_event.windows_key_code = match &event.logical_key {
8585
winit::keyboard::Key::Named(named) => named.to_vk_bits(),
@@ -130,8 +130,8 @@ pub(crate) fn handle_window_event(browser: &Browser, input_state: &mut InputStat
130130
let Some(host) = browser.host() else { return };
131131

132132
let mut mouse_event: MouseEvent = input_state.into();
133-
mouse_event.modifiers |= cef_event_flags_t::EVENTFLAG_CONTROL_DOWN as u32;
134-
mouse_event.modifiers |= cef_event_flags_t::EVENTFLAG_PRECISION_SCROLLING_DELTA as u32;
133+
mouse_event.modifiers |= cef_event_flags_t::EVENTFLAG_CONTROL_DOWN.0;
134+
mouse_event.modifiers |= cef_event_flags_t::EVENTFLAG_PRECISION_SCROLLING_DELTA.0;
135135

136136
let delta = (delta * PINCH_ZOOM_SPEED).round() as i32;
137137

desktop/src/cef/input/state.rs

Lines changed: 43 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
use cef::MouseEvent;
2+
use cef::sys::cef_event_flags_t;
23
use std::time::Instant;
34
use winit::dpi::PhysicalPosition;
45
use winit::event::{ElementState, MouseButton};
6+
use winit::keyboard::KeyLocation;
57

68
use crate::cef::consts::{MULTICLICK_ALLOWED_TRAVEL, MULTICLICK_TIMEOUT};
79

@@ -31,26 +33,57 @@ impl InputState {
3133
self.mouse_click_tracker.input(button, state, self.mouse_position)
3234
}
3335

34-
pub(crate) fn cef_modifiers(&self, location: &winit::keyboard::KeyLocation, is_repeat: bool) -> CefModifiers {
35-
CefModifiers::new(self, location, is_repeat)
36+
pub(crate) fn cef_modifiers(&self, location: &winit::keyboard::KeyLocation, is_repeat: bool) -> cef_event_flags_t {
37+
let mut flags = cef_event_flags_t::EVENTFLAG_NONE;
38+
39+
if self.modifiers.shift_key() {
40+
flags |= cef_event_flags_t::EVENTFLAG_SHIFT_DOWN;
41+
}
42+
if self.modifiers.control_key() {
43+
flags |= cef_event_flags_t::EVENTFLAG_CONTROL_DOWN;
44+
}
45+
if self.modifiers.alt_key() {
46+
flags |= cef_event_flags_t::EVENTFLAG_ALT_DOWN;
47+
}
48+
if self.modifiers.meta_key() {
49+
flags |= cef_event_flags_t::EVENTFLAG_COMMAND_DOWN;
50+
}
51+
52+
if self.mouse_state.left {
53+
flags |= cef_event_flags_t::EVENTFLAG_LEFT_MOUSE_BUTTON;
54+
}
55+
if self.mouse_state.right {
56+
flags |= cef_event_flags_t::EVENTFLAG_RIGHT_MOUSE_BUTTON;
57+
}
58+
if self.mouse_state.middle {
59+
flags |= cef_event_flags_t::EVENTFLAG_MIDDLE_MOUSE_BUTTON;
60+
}
61+
62+
if is_repeat {
63+
flags |= cef_event_flags_t::EVENTFLAG_IS_REPEAT;
64+
}
65+
66+
flags |= match location {
67+
KeyLocation::Left => cef_event_flags_t::EVENTFLAG_IS_LEFT,
68+
KeyLocation::Right => cef_event_flags_t::EVENTFLAG_IS_RIGHT,
69+
KeyLocation::Numpad => cef_event_flags_t::EVENTFLAG_IS_KEY_PAD,
70+
KeyLocation::Standard => cef_event_flags_t::EVENTFLAG_NONE,
71+
};
72+
73+
flags
3674
}
3775

38-
pub(crate) fn cef_mouse_modifiers(&self) -> CefModifiers {
76+
pub(crate) fn cef_mouse_modifiers(&self) -> cef_event_flags_t {
3977
self.cef_modifiers(&winit::keyboard::KeyLocation::Standard, false)
4078
}
4179
}
4280

43-
impl From<InputState> for CefModifiers {
44-
fn from(val: InputState) -> Self {
45-
CefModifiers::new(&val, &winit::keyboard::KeyLocation::Standard, false)
46-
}
47-
}
4881
impl From<&InputState> for MouseEvent {
4982
fn from(val: &InputState) -> Self {
5083
MouseEvent {
5184
x: val.mouse_position.x as i32,
5285
y: val.mouse_position.y as i32,
53-
modifiers: val.cef_mouse_modifiers().raw(),
86+
modifiers: val.cef_mouse_modifiers().0,
5487
}
5588
}
5689
}
@@ -59,7 +92,7 @@ impl From<&mut InputState> for MouseEvent {
5992
MouseEvent {
6093
x: val.mouse_position.x as i32,
6194
y: val.mouse_position.y as i32,
62-
modifiers: val.cef_mouse_modifiers().raw(),
95+
modifiers: val.cef_mouse_modifiers().0,
6396
}
6497
}
6598
}
@@ -196,52 +229,3 @@ impl Default for ClickRecord {
196229
}
197230
}
198231
}
199-
200-
pub(crate) struct CefModifiers(u32);
201-
impl CefModifiers {
202-
fn new(input_state: &InputState, location: &winit::keyboard::KeyLocation, is_repeat: bool) -> Self {
203-
use cef::sys::cef_event_flags_t;
204-
205-
let mut inner = 0;
206-
207-
if input_state.modifiers.shift_key() {
208-
inner |= cef_event_flags_t::EVENTFLAG_SHIFT_DOWN as u32;
209-
}
210-
if input_state.modifiers.control_key() {
211-
inner |= cef_event_flags_t::EVENTFLAG_CONTROL_DOWN as u32;
212-
}
213-
if input_state.modifiers.alt_key() {
214-
inner |= cef_event_flags_t::EVENTFLAG_ALT_DOWN as u32;
215-
}
216-
if input_state.modifiers.meta_key() {
217-
inner |= cef_event_flags_t::EVENTFLAG_COMMAND_DOWN as u32;
218-
}
219-
220-
if input_state.mouse_state.left {
221-
inner |= cef_event_flags_t::EVENTFLAG_LEFT_MOUSE_BUTTON as u32;
222-
}
223-
if input_state.mouse_state.right {
224-
inner |= cef_event_flags_t::EVENTFLAG_RIGHT_MOUSE_BUTTON as u32;
225-
}
226-
if input_state.mouse_state.middle {
227-
inner |= cef_event_flags_t::EVENTFLAG_MIDDLE_MOUSE_BUTTON as u32;
228-
}
229-
230-
if is_repeat {
231-
inner |= cef_event_flags_t::EVENTFLAG_IS_REPEAT as u32;
232-
}
233-
234-
inner |= match location {
235-
winit::keyboard::KeyLocation::Left => cef_event_flags_t::EVENTFLAG_IS_LEFT as u32,
236-
winit::keyboard::KeyLocation::Right => cef_event_flags_t::EVENTFLAG_IS_RIGHT as u32,
237-
winit::keyboard::KeyLocation::Numpad => cef_event_flags_t::EVENTFLAG_IS_KEY_PAD as u32,
238-
winit::keyboard::KeyLocation::Standard => 0,
239-
};
240-
241-
Self(inner)
242-
}
243-
244-
pub(crate) fn raw(&self) -> u32 {
245-
self.0
246-
}
247-
}

0 commit comments

Comments
 (0)