Skip to content

Commit ba590de

Browse files
Review
1 parent 9f9180b commit ba590de

4 files changed

Lines changed: 11 additions & 16 deletions

File tree

desktop/src/app.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ pub(crate) struct App {
4848
#[cfg_attr(not(target_os = "macos"), expect(unused))]
4949
preferences: Preferences,
5050
launch_documents: Option<Vec<PathBuf>>,
51-
disable_ui_acceleration: bool,
5251
startup_time: Option<Instant>,
5352
exiting: Arc<AtomicBool>,
5453
exit_reason: ExitReason,
@@ -68,7 +67,6 @@ impl App {
6867
app_event_scheduler: AppEventScheduler,
6968
preferences: Preferences,
7069
launch_documents: Vec<PathBuf>,
71-
disable_ui_acceleration: bool,
7270
) -> Self {
7371
let ctrlc_app_event_scheduler = app_event_scheduler.clone();
7472
ctrlc::set_handler(move || {
@@ -119,7 +117,6 @@ impl App {
119117
web_communication_startup_buffer: Vec::new(),
120118
preferences,
121119
launch_documents: Some(launch_documents),
122-
disable_ui_acceleration,
123120
startup_time: None,
124121
exiting,
125122
exit_reason: ExitReason::Shutdown,
@@ -312,7 +309,7 @@ impl App {
312309
}
313310
DesktopFrontendMessage::OpenLaunchDocuments => {
314311
let Some(launch_documents) = std::mem::take(&mut self.launch_documents) else {
315-
tracing::error!("OpenLaunchDocuments should only be send once");
312+
tracing::error!("OpenLaunchDocuments should only be sent once");
316313
return;
317314
};
318315
self.open_files(launch_documents);
@@ -589,7 +586,7 @@ impl ApplicationHandler for App {
589586
}
590587

591588
if !self.cef_init_successful
592-
&& !self.disable_ui_acceleration
589+
&& !self.preferences.disable_ui_acceleration
593590
&& self.web_communication_initialized
594591
&& let Some(startup_time) = self.startup_time
595592
&& startup_time.elapsed() > Duration::from_secs(3)

desktop/src/cef/context/builder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,13 @@ fn platform_settings(instance_dir: &Path) -> Settings {
131131
{
132132
let exe = std::env::current_exe().expect("cannot get current exe path");
133133
let app_root = exe.parent().and_then(|p| p.parent()).expect("bad path structure").parent().expect("bad path structure");
134-
return Settings {
134+
Settings {
135135
main_bundle_path: app_root.to_str().map(CefString::from).unwrap(),
136136
multi_threaded_message_loop: 0,
137137
external_message_pump: 1,
138138
no_sandbox: 1, // GPU helper crashes when running with sandbox
139139
..base
140-
};
140+
}
141141
}
142142

143143
#[cfg(not(target_os = "macos"))]

desktop/src/lib.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ pub fn start() {
6767
// TODO: Eventually remove this cleanup code for the old "browser" CEF directory
6868
dirs::delete_old_cef_browser_directory();
6969

70-
let prefs = preferences::read();
70+
let mut prefs = preferences::read();
7171

7272
// Must be called before event loop initialization or native window integrations will break
7373
App::init();
@@ -80,13 +80,15 @@ pub fn start() {
8080

8181
let (cef_view_info_sender, cef_view_info_receiver) = std::sync::mpsc::channel();
8282

83-
let disable_ui_acceleration = prefs.disable_ui_acceleration || cli.disable_ui_acceleration;
84-
if disable_ui_acceleration {
83+
if cli.disable_ui_acceleration {
84+
prefs.disable_ui_acceleration = true;
85+
}
86+
if prefs.disable_ui_acceleration {
8587
println!("UI acceleration is disabled");
8688
}
8789

8890
let cef_handler = cef::CefHandler::new(wgpu_context.clone(), app_event_scheduler.clone(), cef_view_info_receiver);
89-
let cef_context = match cef_context_builder.create(cef_handler, disable_ui_acceleration) {
91+
let cef_context = match cef_context_builder.create(cef_handler, prefs.disable_ui_acceleration) {
9092
Ok(context) => {
9193
tracing::info!("CEF initialized successfully");
9294
context
@@ -110,7 +112,6 @@ pub fn start() {
110112
app_event_scheduler,
111113
prefs,
112114
cli.files,
113-
cli.disable_ui_acceleration,
114115
);
115116

116117
let exit_reason = app.run(event_loop);

desktop/src/window/mac/app.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,7 @@ define_class!(
4747
unsafe impl NSApplicationDelegate for GraphiteApplicationDelegate {
4848
#[unsafe(method(application:openURLs:))]
4949
fn application_open_urls(&self, _application: &NSApplication, urls: &NSArray<NSURL>) {
50-
let Some(app_event_scheduler) = APP_EVENT_SCHEDULER.lock().ok() else {
51-
tracing::error!("Received macOS open URL event before the app event scheduler was initialized");
52-
return;
53-
};
50+
let app_event_scheduler = APP_EVENT_SCHEDULER.lock().unwrap();
5451

5552
let mut pending_paths_to_open = LAUNCH_DOCUMENTS.lock().unwrap();
5653

0 commit comments

Comments
 (0)