linux: basic window, display, and atlas
This commit is contained in:
parent
b0376aaf8f
commit
e95bf24a1f
8 changed files with 582 additions and 84 deletions
|
@ -2,9 +2,9 @@
|
|||
|
||||
use crate::{
|
||||
Action, AnyWindowHandle, BackgroundExecutor, ClipboardItem, CursorStyle, DisplayId,
|
||||
ForegroundExecutor, Keymap, LinuxDispatcher, LinuxTextSystem, Menu, PathPromptOptions,
|
||||
Platform, PlatformDisplay, PlatformInput, PlatformTextSystem, PlatformWindow, Result,
|
||||
SemanticVersion, Task, WindowOptions,
|
||||
ForegroundExecutor, Keymap, LinuxDispatcher, LinuxDisplay, LinuxTextSystem, LinuxWindow, Menu,
|
||||
PathPromptOptions, Platform, PlatformDisplay, PlatformInput, PlatformTextSystem,
|
||||
PlatformWindow, Result, SemanticVersion, Task, WindowOptions,
|
||||
};
|
||||
|
||||
use futures::channel::oneshot;
|
||||
|
@ -21,6 +21,7 @@ use time::UtcOffset;
|
|||
pub(crate) struct LinuxPlatform(Mutex<LinuxPlatformState>);
|
||||
|
||||
pub(crate) struct LinuxPlatformState {
|
||||
gpu: Arc<blade::Context>,
|
||||
background_executor: BackgroundExecutor,
|
||||
foreground_executor: ForegroundExecutor,
|
||||
text_system: Arc<LinuxTextSystem>,
|
||||
|
@ -35,7 +36,17 @@ impl Default for LinuxPlatform {
|
|||
impl LinuxPlatform {
|
||||
pub(crate) fn new() -> Self {
|
||||
let dispatcher = Arc::new(LinuxDispatcher::new());
|
||||
let gpu = Arc::new(
|
||||
unsafe {
|
||||
blade::Context::init(blade::ContextDesc {
|
||||
validation: true, //FIXME
|
||||
capture: false,
|
||||
})
|
||||
}
|
||||
.unwrap(),
|
||||
);
|
||||
Self(Mutex::new(LinuxPlatformState {
|
||||
gpu,
|
||||
background_executor: BackgroundExecutor::new(dispatcher.clone()),
|
||||
foreground_executor: ForegroundExecutor::new(dispatcher),
|
||||
text_system: Arc::new(LinuxTextSystem::new()),
|
||||
|
@ -57,43 +68,31 @@ impl Platform for LinuxPlatform {
|
|||
}
|
||||
|
||||
fn run(&self, on_finish_launching: Box<dyn FnOnce()>) {
|
||||
unimplemented!()
|
||||
on_finish_launching()
|
||||
}
|
||||
|
||||
fn quit(&self) {
|
||||
unimplemented!()
|
||||
}
|
||||
fn quit(&self) {}
|
||||
|
||||
fn restart(&self) {
|
||||
unimplemented!()
|
||||
}
|
||||
fn restart(&self) {}
|
||||
|
||||
fn activate(&self, ignoring_other_apps: bool) {
|
||||
unimplemented!()
|
||||
}
|
||||
fn activate(&self, ignoring_other_apps: bool) {}
|
||||
|
||||
fn hide(&self) {
|
||||
unimplemented!()
|
||||
}
|
||||
fn hide(&self) {}
|
||||
|
||||
fn hide_other_apps(&self) {
|
||||
unimplemented!()
|
||||
}
|
||||
fn hide_other_apps(&self) {}
|
||||
|
||||
fn unhide_other_apps(&self) {
|
||||
unimplemented!()
|
||||
}
|
||||
fn unhide_other_apps(&self) {}
|
||||
|
||||
fn displays(&self) -> Vec<Rc<dyn PlatformDisplay>> {
|
||||
unimplemented!()
|
||||
Vec::new()
|
||||
}
|
||||
|
||||
fn display(&self, id: DisplayId) -> Option<Rc<dyn PlatformDisplay>> {
|
||||
unimplemented!()
|
||||
None
|
||||
}
|
||||
|
||||
fn active_window(&self) -> Option<AnyWindowHandle> {
|
||||
unimplemented!()
|
||||
None
|
||||
}
|
||||
|
||||
fn open_window(
|
||||
|
@ -101,7 +100,13 @@ impl Platform for LinuxPlatform {
|
|||
handle: AnyWindowHandle,
|
||||
options: WindowOptions,
|
||||
) -> Box<dyn PlatformWindow> {
|
||||
unimplemented!()
|
||||
let lock = self.0.lock();
|
||||
Box::new(LinuxWindow::new(
|
||||
options,
|
||||
handle,
|
||||
Rc::new(LinuxDisplay),
|
||||
&lock.gpu,
|
||||
))
|
||||
}
|
||||
|
||||
fn set_display_link_output_callback(
|
||||
|
@ -112,21 +117,13 @@ impl Platform for LinuxPlatform {
|
|||
unimplemented!()
|
||||
}
|
||||
|
||||
fn start_display_link(&self, display_id: DisplayId) {
|
||||
unimplemented!()
|
||||
}
|
||||
fn start_display_link(&self, display_id: DisplayId) {}
|
||||
|
||||
fn stop_display_link(&self, display_id: DisplayId) {
|
||||
unimplemented!()
|
||||
}
|
||||
fn stop_display_link(&self, display_id: DisplayId) {}
|
||||
|
||||
fn open_url(&self, url: &str) {
|
||||
unimplemented!()
|
||||
}
|
||||
fn open_url(&self, url: &str) {}
|
||||
|
||||
fn on_open_urls(&self, callback: Box<dyn FnMut(Vec<String>)>) {
|
||||
unimplemented!()
|
||||
}
|
||||
fn on_open_urls(&self, callback: Box<dyn FnMut(Vec<String>)>) {}
|
||||
|
||||
fn prompt_for_paths(
|
||||
&self,
|
||||
|
@ -139,88 +136,72 @@ impl Platform for LinuxPlatform {
|
|||
unimplemented!()
|
||||
}
|
||||
|
||||
fn reveal_path(&self, path: &Path) {
|
||||
unimplemented!()
|
||||
}
|
||||
fn reveal_path(&self, path: &Path) {}
|
||||
|
||||
fn on_become_active(&self, callback: Box<dyn FnMut()>) {
|
||||
unimplemented!()
|
||||
}
|
||||
fn on_become_active(&self, callback: Box<dyn FnMut()>) {}
|
||||
|
||||
fn on_resign_active(&self, callback: Box<dyn FnMut()>) {
|
||||
unimplemented!()
|
||||
}
|
||||
fn on_resign_active(&self, callback: Box<dyn FnMut()>) {}
|
||||
|
||||
fn on_quit(&self, callback: Box<dyn FnMut()>) {
|
||||
unimplemented!()
|
||||
}
|
||||
fn on_quit(&self, callback: Box<dyn FnMut()>) {}
|
||||
|
||||
fn on_reopen(&self, callback: Box<dyn FnMut()>) {
|
||||
unimplemented!()
|
||||
}
|
||||
fn on_reopen(&self, callback: Box<dyn FnMut()>) {}
|
||||
|
||||
fn on_event(&self, callback: Box<dyn FnMut(PlatformInput) -> bool>) {
|
||||
unimplemented!()
|
||||
}
|
||||
fn on_event(&self, callback: Box<dyn FnMut(PlatformInput) -> bool>) {}
|
||||
|
||||
fn on_app_menu_action(&self, callback: Box<dyn FnMut(&dyn Action)>) {
|
||||
unimplemented!()
|
||||
}
|
||||
fn on_app_menu_action(&self, callback: Box<dyn FnMut(&dyn Action)>) {}
|
||||
|
||||
fn on_will_open_app_menu(&self, callback: Box<dyn FnMut()>) {
|
||||
unimplemented!()
|
||||
}
|
||||
fn on_will_open_app_menu(&self, callback: Box<dyn FnMut()>) {}
|
||||
|
||||
fn on_validate_app_menu_command(&self, callback: Box<dyn FnMut(&dyn Action) -> bool>) {
|
||||
unimplemented!()
|
||||
}
|
||||
fn on_validate_app_menu_command(&self, callback: Box<dyn FnMut(&dyn Action) -> bool>) {}
|
||||
|
||||
fn os_name(&self) -> &'static str {
|
||||
"Linux"
|
||||
}
|
||||
|
||||
fn double_click_interval(&self) -> Duration {
|
||||
unimplemented!()
|
||||
Duration::default()
|
||||
}
|
||||
|
||||
fn os_version(&self) -> Result<SemanticVersion> {
|
||||
unimplemented!()
|
||||
Ok(SemanticVersion {
|
||||
major: 1,
|
||||
minor: 0,
|
||||
patch: 0,
|
||||
})
|
||||
}
|
||||
|
||||
fn app_version(&self) -> Result<SemanticVersion> {
|
||||
unimplemented!()
|
||||
Ok(SemanticVersion {
|
||||
major: 1,
|
||||
minor: 0,
|
||||
patch: 0,
|
||||
})
|
||||
}
|
||||
|
||||
fn app_path(&self) -> Result<PathBuf> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn set_menus(&self, menus: Vec<Menu>, keymap: &Keymap) {
|
||||
unimplemented!()
|
||||
}
|
||||
fn set_menus(&self, menus: Vec<Menu>, keymap: &Keymap) {}
|
||||
|
||||
fn local_timezone(&self) -> UtcOffset {
|
||||
unimplemented!()
|
||||
UtcOffset::UTC
|
||||
}
|
||||
|
||||
fn path_for_auxiliary_executable(&self, name: &str) -> Result<PathBuf> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn set_cursor_style(&self, style: CursorStyle) {
|
||||
unimplemented!()
|
||||
}
|
||||
fn set_cursor_style(&self, style: CursorStyle) {}
|
||||
|
||||
fn should_auto_hide_scrollbars(&self) -> bool {
|
||||
unimplemented!()
|
||||
false
|
||||
}
|
||||
|
||||
fn write_to_clipboard(&self, item: ClipboardItem) {
|
||||
unimplemented!()
|
||||
}
|
||||
fn write_to_clipboard(&self, item: ClipboardItem) {}
|
||||
|
||||
fn read_from_clipboard(&self) -> Option<ClipboardItem> {
|
||||
unimplemented!()
|
||||
None
|
||||
}
|
||||
|
||||
fn write_credentials(&self, url: &str, username: &str, password: &[u8]) -> Task<Result<()>> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue