Skip to content

Commit 3fd0460

Browse files
Desktop: Update CEF to 142 (#3431)
* update CEF to 142 * fix win * fixup * post merge fix * use getter instead
1 parent e8ebcc2 commit 3fd0460

File tree

11 files changed

+95
-88
lines changed

11 files changed

+95
-88
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.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ impl CefEventHandler for CefHandler {
158158
mip_level_count: 1,
159159
sample_count: 1,
160160
dimension: wgpu::TextureDimension::D2,
161-
format: wgpu::TextureFormat::Bgra8UnormSrgb,
161+
format: wgpu::TextureFormat::Bgra8Unorm,
162162
usage: wgpu::TextureUsages::TEXTURE_BINDING | wgpu::TextureUsages::COPY_DST,
163163
view_formats: &[],
164164
});

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).into();
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 as u32;
134+
mouse_event.modifiers |= cef_event_flags_t::EVENTFLAG_PRECISION_SCROLLING_DELTA.0 as u32;
135135

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

desktop/src/cef/input/state.rs

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
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, ModifiersState};
57

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

810
#[derive(Default)]
911
pub(crate) struct InputState {
10-
modifiers: winit::keyboard::ModifiersState,
12+
modifiers: ModifiersState,
1113
mouse_position: MousePosition,
1214
mouse_state: MouseState,
1315
mouse_click_tracker: ClickTracker,
1416
}
1517
impl InputState {
16-
pub(crate) fn modifiers_changed(&mut self, modifiers: &winit::keyboard::ModifiersState) {
18+
pub(crate) fn modifiers_changed(&mut self, modifiers: &ModifiersState) {
1719
self.modifiers = *modifiers;
1820
}
1921

@@ -31,26 +33,26 @@ 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 {
36+
pub(crate) fn cef_modifiers(&self, location: &KeyLocation, is_repeat: bool) -> CefModifiers {
3537
CefModifiers::new(self, location, is_repeat)
3638
}
3739

3840
pub(crate) fn cef_mouse_modifiers(&self) -> CefModifiers {
39-
self.cef_modifiers(&winit::keyboard::KeyLocation::Standard, false)
41+
self.cef_modifiers(&KeyLocation::Standard, false)
4042
}
4143
}
4244

4345
impl From<InputState> for CefModifiers {
4446
fn from(val: InputState) -> Self {
45-
CefModifiers::new(&val, &winit::keyboard::KeyLocation::Standard, false)
47+
CefModifiers::new(&val, &KeyLocation::Standard, false)
4648
}
4749
}
4850
impl From<&InputState> for MouseEvent {
4951
fn from(val: &InputState) -> Self {
5052
MouseEvent {
5153
x: val.mouse_position.x as i32,
5254
y: val.mouse_position.y as i32,
53-
modifiers: val.cef_mouse_modifiers().raw(),
55+
modifiers: val.cef_mouse_modifiers().into(),
5456
}
5557
}
5658
}
@@ -59,7 +61,7 @@ impl From<&mut InputState> for MouseEvent {
5961
MouseEvent {
6062
x: val.mouse_position.x as i32,
6163
y: val.mouse_position.y as i32,
62-
modifiers: val.cef_mouse_modifiers().raw(),
64+
modifiers: val.cef_mouse_modifiers().into(),
6365
}
6466
}
6567
}
@@ -197,51 +199,51 @@ impl Default for ClickRecord {
197199
}
198200
}
199201

200-
pub(crate) struct CefModifiers(u32);
202+
pub(crate) struct CefModifiers(cef_event_flags_t);
201203
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;
204+
fn new(input_state: &InputState, location: &KeyLocation, is_repeat: bool) -> Self {
205+
let mut inner = cef_event_flags_t::EVENTFLAG_NONE;
206206

207207
if input_state.modifiers.shift_key() {
208-
inner |= cef_event_flags_t::EVENTFLAG_SHIFT_DOWN as u32;
208+
inner |= cef_event_flags_t::EVENTFLAG_SHIFT_DOWN;
209209
}
210210
if input_state.modifiers.control_key() {
211-
inner |= cef_event_flags_t::EVENTFLAG_CONTROL_DOWN as u32;
211+
inner |= cef_event_flags_t::EVENTFLAG_CONTROL_DOWN;
212212
}
213213
if input_state.modifiers.alt_key() {
214-
inner |= cef_event_flags_t::EVENTFLAG_ALT_DOWN as u32;
214+
inner |= cef_event_flags_t::EVENTFLAG_ALT_DOWN;
215215
}
216216
if input_state.modifiers.meta_key() {
217-
inner |= cef_event_flags_t::EVENTFLAG_COMMAND_DOWN as u32;
217+
inner |= cef_event_flags_t::EVENTFLAG_COMMAND_DOWN;
218218
}
219219

220220
if input_state.mouse_state.left {
221-
inner |= cef_event_flags_t::EVENTFLAG_LEFT_MOUSE_BUTTON as u32;
221+
inner |= cef_event_flags_t::EVENTFLAG_LEFT_MOUSE_BUTTON;
222222
}
223223
if input_state.mouse_state.right {
224-
inner |= cef_event_flags_t::EVENTFLAG_RIGHT_MOUSE_BUTTON as u32;
224+
inner |= cef_event_flags_t::EVENTFLAG_RIGHT_MOUSE_BUTTON;
225225
}
226226
if input_state.mouse_state.middle {
227-
inner |= cef_event_flags_t::EVENTFLAG_MIDDLE_MOUSE_BUTTON as u32;
227+
inner |= cef_event_flags_t::EVENTFLAG_MIDDLE_MOUSE_BUTTON;
228228
}
229229

230230
if is_repeat {
231-
inner |= cef_event_flags_t::EVENTFLAG_IS_REPEAT as u32;
231+
inner |= cef_event_flags_t::EVENTFLAG_IS_REPEAT;
232232
}
233233

234234
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,
235+
KeyLocation::Left => cef_event_flags_t::EVENTFLAG_IS_LEFT,
236+
KeyLocation::Right => cef_event_flags_t::EVENTFLAG_IS_RIGHT,
237+
KeyLocation::Numpad => cef_event_flags_t::EVENTFLAG_IS_KEY_PAD,
238+
KeyLocation::Standard => cef_event_flags_t::EVENTFLAG_NONE,
239239
};
240240

241241
Self(inner)
242242
}
243+
}
243244

244-
pub(crate) fn raw(&self) -> u32 {
245-
self.0
245+
impl Into<u32> for CefModifiers {
246+
fn into(self) -> u32 {
247+
self.0.0 as u32
246248
}
247249
}

0 commit comments

Comments
 (0)