mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
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
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use crate::CustomEvent;
|
||||
use crate::WindowSize;
|
||||
use crate::consts::APP_NAME;
|
||||
use crate::dialogs::dialog_open_graphite_file;
|
||||
use crate::dialogs::dialog_save_graphite_file;
|
||||
use crate::render::GraphicsState;
|
||||
@@ -142,15 +143,24 @@ impl ApplicationHandler<CustomEvent> for WinitApp {
|
||||
}
|
||||
|
||||
fn resumed(&mut self, event_loop: &ActiveEventLoop) {
|
||||
let window = Arc::new(
|
||||
event_loop
|
||||
.create_window(
|
||||
Window::default_attributes()
|
||||
.with_title("CEF Offscreen Rendering")
|
||||
.with_inner_size(winit::dpi::LogicalSize::new(1200, 800)),
|
||||
)
|
||||
.unwrap(),
|
||||
);
|
||||
let mut window = Window::default_attributes()
|
||||
.with_title(APP_NAME)
|
||||
.with_min_inner_size(winit::dpi::LogicalSize::new(400, 300))
|
||||
.with_inner_size(winit::dpi::LogicalSize::new(1200, 800));
|
||||
|
||||
#[cfg(target_family = "unix")]
|
||||
{
|
||||
use crate::consts::APP_ID;
|
||||
use winit::platform::wayland::ActiveEventLoopExtWayland;
|
||||
|
||||
window = if event_loop.is_wayland() {
|
||||
winit::platform::wayland::WindowAttributesExtWayland::with_name(window, APP_ID, "")
|
||||
} else {
|
||||
winit::platform::x11::WindowAttributesExtX11::with_name(window, APP_ID, APP_NAME)
|
||||
}
|
||||
}
|
||||
|
||||
let window = Arc::new(event_loop.create_window(window).unwrap());
|
||||
let graphics_state = GraphicsState::new(window.clone(), self.wgpu_context.clone());
|
||||
|
||||
self.window = Some(window);
|
||||
|
||||
3
desktop/src/consts.rs
Normal file
3
desktop/src/consts.rs
Normal file
@@ -0,0 +1,3 @@
|
||||
pub(crate) static APP_NAME: &str = "Graphite";
|
||||
pub(crate) static APP_ID: &str = "rs.graphite.GraphiteEditor";
|
||||
pub(crate) static APP_DIRECTORY_NAME: &str = "graphite-editor";
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::fs::create_dir_all;
|
||||
use std::path::PathBuf;
|
||||
|
||||
static APP_NAME: &str = "graphite-desktop";
|
||||
use crate::consts::APP_DIRECTORY_NAME;
|
||||
|
||||
pub(crate) fn ensure_dir_exists(path: &PathBuf) {
|
||||
if !path.exists() {
|
||||
@@ -10,7 +10,7 @@ pub(crate) fn ensure_dir_exists(path: &PathBuf) {
|
||||
}
|
||||
|
||||
pub(crate) fn graphite_data_dir() -> PathBuf {
|
||||
let path = dirs::data_dir().expect("Failed to get data directory").join(APP_NAME);
|
||||
let path = dirs::data_dir().expect("Failed to get data directory").join(APP_DIRECTORY_NAME);
|
||||
ensure_dir_exists(&path);
|
||||
path
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ use graphite_editor::messages::prelude::Message;
|
||||
use tracing_subscriber::EnvFilter;
|
||||
use winit::event_loop::EventLoop;
|
||||
|
||||
pub(crate) mod consts;
|
||||
|
||||
mod cef;
|
||||
use cef::{Setup, WindowSize};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user