Skip to content

Commit 0462d0e

Browse files
Desktop: Linux improve desktop integration (#3003)
* Move consts to extra module * Add desktop icons * Add xdg desktop file * Improve window attributes * Make icon background white
1 parent caa228a commit 0462d0e

File tree

7 files changed

+46
-11
lines changed

7 files changed

+46
-11
lines changed
84.1 KB
Loading
Lines changed: 9 additions & 0 deletions
Loading
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[Desktop Entry]
2+
Name=Graphite
3+
GenericName=Vector & Raster Graphics Editor
4+
Comment=Open-source vector & raster graphics editor. Featuring node based procedural nondestructive editing workflow.
5+
Exec=graphite-editor
6+
Terminal=false
7+
Type=Application
8+
Icon=graphite-icon-color
9+
Categories=Graphics;VectorGraphics;RasterGraphics;
10+
Keywords=graphite;editor;vector;raster;procedural;design;
11+
StartupWMClass=rs.graphite.GraphiteEditor

desktop/src/app.rs

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::CustomEvent;
22
use crate::WindowSize;
3+
use crate::consts::APP_NAME;
34
use crate::dialogs::dialog_open_graphite_file;
45
use crate::dialogs::dialog_save_graphite_file;
56
use crate::render::GraphicsState;
@@ -142,15 +143,24 @@ impl ApplicationHandler<CustomEvent> for WinitApp {
142143
}
143144

144145
fn resumed(&mut self, event_loop: &ActiveEventLoop) {
145-
let window = Arc::new(
146-
event_loop
147-
.create_window(
148-
Window::default_attributes()
149-
.with_title("CEF Offscreen Rendering")
150-
.with_inner_size(winit::dpi::LogicalSize::new(1200, 800)),
151-
)
152-
.unwrap(),
153-
);
146+
let mut window = Window::default_attributes()
147+
.with_title(APP_NAME)
148+
.with_min_inner_size(winit::dpi::LogicalSize::new(400, 300))
149+
.with_inner_size(winit::dpi::LogicalSize::new(1200, 800));
150+
151+
#[cfg(target_family = "unix")]
152+
{
153+
use crate::consts::APP_ID;
154+
use winit::platform::wayland::ActiveEventLoopExtWayland;
155+
156+
window = if event_loop.is_wayland() {
157+
winit::platform::wayland::WindowAttributesExtWayland::with_name(window, APP_ID, "")
158+
} else {
159+
winit::platform::x11::WindowAttributesExtX11::with_name(window, APP_ID, APP_NAME)
160+
}
161+
}
162+
163+
let window = Arc::new(event_loop.create_window(window).unwrap());
154164
let graphics_state = GraphicsState::new(window.clone(), self.wgpu_context.clone());
155165

156166
self.window = Some(window);

desktop/src/consts.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pub(crate) static APP_NAME: &str = "Graphite";
2+
pub(crate) static APP_ID: &str = "rs.graphite.GraphiteEditor";
3+
pub(crate) static APP_DIRECTORY_NAME: &str = "graphite-editor";

desktop/src/dirs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::fs::create_dir_all;
22
use std::path::PathBuf;
33

4-
static APP_NAME: &str = "graphite-desktop";
4+
use crate::consts::APP_DIRECTORY_NAME;
55

66
pub(crate) fn ensure_dir_exists(path: &PathBuf) {
77
if !path.exists() {
@@ -10,7 +10,7 @@ pub(crate) fn ensure_dir_exists(path: &PathBuf) {
1010
}
1111

1212
pub(crate) fn graphite_data_dir() -> PathBuf {
13-
let path = dirs::data_dir().expect("Failed to get data directory").join(APP_NAME);
13+
let path = dirs::data_dir().expect("Failed to get data directory").join(APP_DIRECTORY_NAME);
1414
ensure_dir_exists(&path);
1515
path
1616
}

desktop/src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ use graphite_editor::messages::prelude::Message;
66
use tracing_subscriber::EnvFilter;
77
use winit::event_loop::EventLoop;
88

9+
pub(crate) mod consts;
10+
911
mod cef;
1012
use cef::{Setup, WindowSize};
1113

0 commit comments

Comments
 (0)