Skip to content

Commit 1927925

Browse files
Merge branch 'master' into add-median-filter-blur
2 parents d19c7ff + 5ebf6d6 commit 1927925

21 files changed

Lines changed: 1202 additions & 486 deletions

File tree

desktop/bundle/src/common.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ use std::process::{Command, Stdio};
55

66
pub(crate) const APP_NAME: &str = "Graphite";
77

8+
pub(crate) fn workspace_path() -> PathBuf {
9+
PathBuf::from(env!("CARGO_WORKSPACE_DIR"))
10+
}
11+
812
fn profile_name() -> &'static str {
913
let mut profile = env!("CARGO_PROFILE");
1014
if profile == "debug" {
@@ -14,7 +18,7 @@ fn profile_name() -> &'static str {
1418
}
1519

1620
pub(crate) fn profile_path() -> PathBuf {
17-
PathBuf::from(env!("CARGO_WORKSPACE_DIR")).join(format!("target/{}", env!("CARGO_PROFILE")))
21+
workspace_path().join(format!("target/{}", env!("CARGO_PROFILE")))
1822
}
1923

2024
pub(crate) fn cef_path() -> PathBuf {

desktop/bundle/src/mac.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ const APP_ID: &str = "rs.graphite.Graphite";
1010
const PACKAGE: &str = "graphite-desktop-platform-mac";
1111
const HELPER_BIN: &str = "graphite-desktop-platform-mac-helper";
1212

13+
const ICONS_FILE_NAME: &str = "graphite.icns";
14+
1315
const EXEC_PATH: &str = "Contents/MacOS";
1416
const FRAMEWORKS_PATH: &str = "Contents/Frameworks";
15-
const FRAMEWORK: &str = "Chromium Embedded Framework.framework";
17+
const RESOURCES_PATH: &str = "Contents/Resources";
18+
const CEF_FRAMEWORK: &str = "Chromium Embedded Framework.framework";
1619

1720
pub fn main() -> Result<(), Box<dyn Error>> {
1821
let app_bin = build_bin(PACKAGE, None)?;
@@ -46,7 +49,13 @@ fn bundle(out_dir: &Path, app_bin: &Path, helper_bin: &Path) -> PathBuf {
4649
create_app(&helper_app_dir, &helper_id, &helper_name, helper_bin, true);
4750
}
4851

49-
copy_dir(&cef_path().join(FRAMEWORK), &app_dir.join(FRAMEWORKS_PATH).join(FRAMEWORK));
52+
copy_dir(&cef_path().join(CEF_FRAMEWORK), &app_dir.join(FRAMEWORKS_PATH).join(CEF_FRAMEWORK));
53+
54+
let resource_dir = app_dir.join(RESOURCES_PATH);
55+
fs::create_dir_all(&resource_dir).expect("failed to create app resource dir");
56+
57+
let icon_file = workspace_path().join("branding/app-icons").join(ICONS_FILE_NAME);
58+
fs::copy(icon_file, resource_dir.join(ICONS_FILE_NAME)).expect("failed to copy icon file");
5059

5160
app_dir
5261
}
@@ -61,25 +70,22 @@ fn create_app(app_dir: &Path, id: &str, name: &str, bin: &Path, is_helper: bool)
6170

6271
fn create_info_plist(dir: &Path, id: &str, exec_name: &str, is_helper: bool) -> Result<(), Box<dyn std::error::Error>> {
6372
let info = InfoPlist {
64-
cf_bundle_development_region: "en".to_string(),
73+
cf_bundle_name: exec_name.to_string(),
74+
cf_bundle_identifier: id.to_string(),
6575
cf_bundle_display_name: exec_name.to_string(),
6676
cf_bundle_executable: exec_name.to_string(),
67-
cf_bundle_identifier: id.to_string(),
77+
cf_bundle_icon_file: ICONS_FILE_NAME.to_string(),
6878
cf_bundle_info_dictionary_version: "6.0".to_string(),
69-
cf_bundle_name: exec_name.to_string(),
7079
cf_bundle_package_type: "APPL".to_string(),
7180
cf_bundle_signature: "????".to_string(),
7281
cf_bundle_version: "0.0.0".to_string(),
7382
cf_bundle_short_version_string: "0.0".to_string(),
83+
cf_bundle_development_region: "en".to_string(),
7484
ls_environment: [("MallocNanoZone".to_string(), "0".to_string())].iter().cloned().collect(),
7585
ls_file_quarantine_enabled: true,
7686
ls_minimum_system_version: "11.0".to_string(),
7787
ls_ui_element: if is_helper { Some("1".to_string()) } else { None },
78-
ns_bluetooth_always_usage_description: exec_name.to_string(),
7988
ns_supports_automatic_graphics_switching: true,
80-
ns_web_browser_publickey_credential_usage_description: exec_name.to_string(),
81-
ns_camera_usage_description: exec_name.to_string(),
82-
ns_microphone_usage_description: exec_name.to_string(),
8389
};
8490

8591
let plist_file = dir.join("Info.plist");
@@ -89,18 +95,18 @@ fn create_info_plist(dir: &Path, id: &str, exec_name: &str, is_helper: bool) ->
8995

9096
#[derive(serde::Serialize)]
9197
struct InfoPlist {
92-
#[serde(rename = "CFBundleDevelopmentRegion")]
93-
cf_bundle_development_region: String,
98+
#[serde(rename = "CFBundleName")]
99+
cf_bundle_name: String,
100+
#[serde(rename = "CFBundleIdentifier")]
101+
cf_bundle_identifier: String,
94102
#[serde(rename = "CFBundleDisplayName")]
95103
cf_bundle_display_name: String,
96104
#[serde(rename = "CFBundleExecutable")]
97105
cf_bundle_executable: String,
98-
#[serde(rename = "CFBundleIdentifier")]
99-
cf_bundle_identifier: String,
106+
#[serde(rename = "CFBundleIconFile")]
107+
cf_bundle_icon_file: String,
100108
#[serde(rename = "CFBundleInfoDictionaryVersion")]
101109
cf_bundle_info_dictionary_version: String,
102-
#[serde(rename = "CFBundleName")]
103-
cf_bundle_name: String,
104110
#[serde(rename = "CFBundlePackageType")]
105111
cf_bundle_package_type: String,
106112
#[serde(rename = "CFBundleSignature")]
@@ -109,6 +115,8 @@ struct InfoPlist {
109115
cf_bundle_version: String,
110116
#[serde(rename = "CFBundleShortVersionString")]
111117
cf_bundle_short_version_string: String,
118+
#[serde(rename = "CFBundleDevelopmentRegion")]
119+
cf_bundle_development_region: String,
112120
#[serde(rename = "LSEnvironment")]
113121
ls_environment: HashMap<String, String>,
114122
#[serde(rename = "LSFileQuarantineEnabled")]
@@ -117,14 +125,6 @@ struct InfoPlist {
117125
ls_minimum_system_version: String,
118126
#[serde(rename = "LSUIElement")]
119127
ls_ui_element: Option<String>,
120-
#[serde(rename = "NSBluetoothAlwaysUsageDescription")]
121-
ns_bluetooth_always_usage_description: String,
122128
#[serde(rename = "NSSupportsAutomaticGraphicsSwitching")]
123129
ns_supports_automatic_graphics_switching: bool,
124-
#[serde(rename = "NSWebBrowserPublicKeyCredentialUsageDescription")]
125-
ns_web_browser_publickey_credential_usage_description: String,
126-
#[serde(rename = "NSCameraUsageDescription")]
127-
ns_camera_usage_description: String,
128-
#[serde(rename = "NSMicrophoneUsageDescription")]
129-
ns_microphone_usage_description: String,
130130
}

desktop/src/cef/internal/browser_process_app.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ impl<H: CefEventHandler> ImplApp for BrowserProcessAppImpl<H> {
3333

3434
fn on_before_command_line_processing(&self, _process_type: Option<&cef::CefString>, command_line: Option<&mut cef::CommandLine>) {
3535
if let Some(cmd) = command_line {
36+
cmd.append_switch_with_value(Some(&CefString::from("renderer-process-limit")), Some(&CefString::from("1")));
37+
cmd.append_switch_with_value(Some(&CefString::from("disk-cache-size")), Some(&CefString::from("0")));
38+
cmd.append_switch(Some(&CefString::from("incognito")));
39+
cmd.append_switch(Some(&CefString::from("no-first-run")));
40+
cmd.append_switch(Some(&CefString::from("disable-file-system")));
41+
cmd.append_switch(Some(&CefString::from("disable-local-storage")));
42+
cmd.append_switch(Some(&CefString::from("disable-background-networking")));
43+
cmd.append_switch(Some(&CefString::from("disable-audio-input")));
44+
cmd.append_switch(Some(&CefString::from("disable-audio-output")));
45+
3646
#[cfg(not(feature = "accelerated_paint"))]
3747
{
3848
// Disable GPU acceleration when accelerated_paint feature is not enabled

desktop/src/window/win.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
use winit::dpi::PhysicalSize;
12
use winit::event_loop::ActiveEventLoop;
23
use winit::icon::Icon;
3-
use winit::platform::windows::WinIcon;
4+
use winit::platform::windows::{WinIcon, WindowAttributesWindows};
45
use winit::window::{Window, WindowAttributes};
56

67
use crate::event::AppEventScheduler;
@@ -11,12 +12,10 @@ pub(super) struct NativeWindowImpl {
1112

1213
impl super::NativeWindow for NativeWindowImpl {
1314
fn configure(attributes: WindowAttributes, _event_loop: &dyn ActiveEventLoop) -> WindowAttributes {
14-
if let Ok(win_icon) = WinIcon::from_resource(1, None) {
15-
let icon = Icon(std::sync::Arc::new(win_icon));
16-
attributes.with_window_icon(Some(icon))
17-
} else {
18-
attributes
19-
}
15+
let icon = WinIcon::from_resource(1, Some(PhysicalSize::new(256, 256))).ok().map(|icon| Icon(std::sync::Arc::new(icon)));
16+
let win_window = WindowAttributesWindows::default().with_taskbar_icon(icon);
17+
let icon = WinIcon::from_resource(1, None).ok().map(|icon| Icon(std::sync::Arc::new(icon)));
18+
attributes.with_window_icon(icon).with_platform_attributes(Box::new(win_window))
2019
}
2120

2221
fn new(window: &dyn Window, _app_event_scheduler: AppEventScheduler) -> Self {

editor/src/messages/portfolio/document/data_panel/data_panel_message_handler.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,10 +502,17 @@ impl TableRowLayout for Raster<CPU> {
502502
format!("Raster ({}x{})", self.width, self.height)
503503
}
504504
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
505-
let base64_string = self.data().base64_string.clone().unwrap_or_else(|| {
505+
let raster = self.data();
506+
507+
if raster.width == 0 || raster.height == 0 {
508+
let widgets = vec![TextLabel::new("Image has no area").widget_holder()];
509+
return vec![LayoutGroup::Row { widgets }];
510+
}
511+
512+
let base64_string = raster.base64_string.clone().unwrap_or_else(|| {
506513
use base64::Engine;
507514

508-
let output = self.data().to_png();
515+
let output = raster.to_png();
509516
let preamble = "data:image/png;base64,";
510517
let mut base64_string = String::with_capacity(preamble.len() + output.len() * 4);
511518
base64_string.push_str(preamble);

0 commit comments

Comments
 (0)