Fixed Ubuntu build.

This commit is contained in:
Samuel 2021-12-22 23:46:23 -03:00
parent 05cd4d55c2
commit 6c4d018c4c
6 changed files with 42 additions and 12 deletions

10
.vscode/settings.json vendored
View File

@ -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"
],
}

View File

@ -106,6 +106,7 @@ impl AppExtension for FontManager {
fn event_preview<EV: EventUpdateArgs>(&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();
}
}

View File

@ -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)
}

View File

@ -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,

View File

@ -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);

View File

@ -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
}