From 6c4d018c4cd40489c6febacdf776721758316ef7 Mon Sep 17 00:00:00 2001 From: Samuel Date: Wed, 22 Dec 2021 23:46:23 -0300 Subject: [PATCH] Fixed Ubuntu build. --- .vscode/settings.json | 10 ++++++++++ zero-ui-core/src/text/font_loading.rs | 2 ++ zero-ui-view/src/config.rs | 19 +++++++++++-------- zero-ui-view/src/lib.rs | 1 + zero-ui-view/src/surface.rs | 5 +++-- zero-ui-view/src/window.rs | 17 +++++++++++++++-- 6 files changed, 42 insertions(+), 12 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 85d457d86..a71b2c964 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,4 +5,14 @@ "rust-analyzer.runnables.overrideCargo": "cargo do rust_analyzer_run", "rust-analyzer.checkOnSave.overrideCommand": ["cargo", "do", "rust_analyzer_check"], "files.eol": "\n", + "spellright.language": [ + "en" + ], + "spellright.documentTypes": [ + "markdown", + "latex", + "plaintext", + "toml", + "json" + ], } \ No newline at end of file diff --git a/zero-ui-core/src/text/font_loading.rs b/zero-ui-core/src/text/font_loading.rs index 750884518..ff6eb45e6 100644 --- a/zero-ui-core/src/text/font_loading.rs +++ b/zero-ui-core/src/text/font_loading.rs @@ -106,6 +106,7 @@ impl AppExtension for FontManager { fn event_preview(&mut self, ctx: &mut AppContext, args: &EV) { if RawFontChangedEvent.update(args).is_some() { FontChangedEvent.notify(ctx.events, FontChangedArgs::now(FontChange::SystemFonts)); + #[cfg(windows)] ctx.services.fonts().on_system_fonts_changed(); } else if let Some(args) = RawTextAaChangedEvent.update(args) { ctx.services.fonts().text_aa.set_ne(ctx.vars, args.aa); @@ -131,6 +132,7 @@ impl AppExtension for FontManager { } if fonts.prune_requested { + #[cfg(windows)] fonts.on_prune(); } } diff --git a/zero-ui-view/src/config.rs b/zero-ui-view/src/config.rs index e60719a57..839f7ae57 100644 --- a/zero-ui-view/src/config.rs +++ b/zero-ui-view/src/config.rs @@ -1,6 +1,9 @@ -use crate::{AppEvent, MultiClickConfig, TextAntiAliasing}; +use crate::{MultiClickConfig, TextAntiAliasing}; use std::time::Duration; +#[cfg(windows)] +use crate::AppEvent; + /// Create a hidden window that listen to Windows config change events. #[cfg(windows)] pub(crate) fn config_listener( @@ -80,12 +83,12 @@ pub fn text_aa() -> TextAntiAliasing { } #[cfg(not(windows))] pub fn text_aa() -> TextAntiAliasing { - // TODO + tracing::error!("`text_aa` not implemented for this OS, will use default"); TextAntiAliasing::Subpixel } /// Gets the "double-click" settings. -#[cfg(target_os = "windows")] +#[cfg(windows)] pub fn multi_click_config() -> MultiClickConfig { use winapi::um::winuser::*; use zero_ui_view_api::units::*; @@ -101,11 +104,9 @@ pub fn multi_click_config() -> MultiClickConfig { } } -#[cfg(not(target_os = "windows"))] -pub fn multi_click_time() -> MultiClickConfig { - // TODO - // https://stackoverflow.com/questions/50868129/how-to-get-double-click-time-interval-value-programmatically-on-linux - // https://developer.apple.com/documentation/appkit/nsevent/1532495-mouseevent +#[cfg(not(windows))] +pub fn multi_click_config() -> MultiClickConfig { + tracing::error!("`multi_click_config` not implemented for this OS, will use default"); MultiClickConfig::default() } @@ -127,6 +128,7 @@ pub fn animation_enabled() -> bool { } #[cfg(not(windows))] pub fn animation_enabled() -> bool { + tracing::error!("`animation_enabled` not implemented for this OS, will use default"); true } @@ -161,5 +163,6 @@ pub fn key_repeat_delay() -> Duration { #[cfg(not(windows))] pub fn key_repeat_delay() -> Duration { + tracing::error!("`key_repeat_delay` not implemented for this OS, will use default"); Duration::from_millis(600) } diff --git a/zero-ui-view/src/lib.rs b/zero-ui-view/src/lib.rs index 8128e5be7..d075666e2 100644 --- a/zero-ui-view/src/lib.rs +++ b/zero-ui-view/src/lib.rs @@ -1425,6 +1425,7 @@ pub(crate) enum AppEvent { /// A frame is ready for redraw. FrameReady(WindowId, FrameReadyMsg), /// Re-query available monitors and send update event. + #[cfg_attr(not(windows), allow(unused))] RefreshMonitors, /// Lost connection with app-process. ParentProcessExited, diff --git a/zero-ui-view/src/surface.rs b/zero-ui-view/src/surface.rs index 159de7a39..4303e3454 100644 --- a/zero-ui-view/src/surface.rs +++ b/zero-ui-view/src/surface.rs @@ -1,6 +1,8 @@ use std::{collections::VecDeque, fmt}; use glutin::{dpi::PhysicalSize, event_loop::EventLoopWindowTarget, ContextBuilder, GlRequest}; +#[cfg(target_os = "linux")] +use glutin::platform::unix::HeadlessContextExt; use webrender::{ api::{ BuiltDisplayList, DisplayListPayload, DocumentId, DynamicProperties, FontInstanceKey, FontInstanceOptions, @@ -85,7 +87,7 @@ impl Surface { #[cfg(target_os = "linux")] match builder.clone().build_surfaceless(window_target) { Ok(c) => { - glutin = Some(c); + context = Some(c); render_mode = mode; break; } @@ -95,7 +97,6 @@ impl Surface { } } - #[cfg(not(target_os = "linux"))] match builder.build_headless(window_target, size_one) { Ok(c) => { context = Some(c); diff --git a/zero-ui-view/src/window.rs b/zero-ui-view/src/window.rs index cbe109b6a..05be29952 100644 --- a/zero-ui-view/src/window.rs +++ b/zero-ui-view/src/window.rs @@ -26,10 +26,13 @@ use webrender::{ RenderApi, Renderer, RendererOptions, Transaction, }; use zero_ui_view_api::{ - units::*, CursorIcon, DeviceId, Event, FrameId, FrameRequest, FrameUpdateRequest, HeadlessOpenData, ImageId, ImageLoadedData, Key, - KeyState, RenderMode, ScanCode, TextAntiAliasing, VideoMode, ViewProcessGen, WindowId, WindowRequest, WindowState, + units::*, CursorIcon, DeviceId, FrameId, FrameRequest, FrameUpdateRequest, HeadlessOpenData, ImageId, ImageLoadedData, + RenderMode, TextAntiAliasing, VideoMode, ViewProcessGen, WindowId, WindowRequest, WindowState, }; +#[cfg(windows)] +use zero_ui_view_api::{Event, KeyState, ScanCode, Key}; + use crate::{ config, image_cache::{Image, ImageCache, ImageUseMap, WrImageCache}, @@ -676,6 +679,15 @@ impl Window { } } + #[cfg(not(windows))] + pub fn set_taskbar_visible(&mut self, visible: bool) { + if visible != self.taskbar_visible { + return; + } + self.taskbar_visible = visible; + tracing::error!("`set_taskbar_visible` not implemented for this OS"); + } + #[cfg(windows)] pub fn set_taskbar_visible(&mut self, visible: bool) { if visible == self.taskbar_visible { @@ -964,6 +976,7 @@ impl Window { } } + #[cfg(windows)] pub fn is_maximized(&self) -> bool { self.state == WindowState::Maximized }