chore(rustfmt): use nightly (#2325)
Stable rustfmt lacks a lot of features resulting in worse formatted code, thus use nightly formatter.
This commit is contained in:
parent
7006c7ceca
commit
7b0c7b6cb2
154 changed files with 3439 additions and 5891 deletions
|
|
@ -1,11 +1,9 @@
|
|||
use std::{
|
||||
cell::Cell,
|
||||
collections::VecDeque,
|
||||
marker::PhantomData,
|
||||
mem, slice,
|
||||
sync::{mpsc, Arc, Mutex},
|
||||
time::Instant,
|
||||
};
|
||||
use std::cell::Cell;
|
||||
use std::collections::VecDeque;
|
||||
use std::marker::PhantomData;
|
||||
use std::sync::{mpsc, Arc, Mutex};
|
||||
use std::time::Instant;
|
||||
use std::{mem, slice};
|
||||
|
||||
use bitflags::bitflags;
|
||||
use orbclient::{
|
||||
|
|
@ -14,15 +12,15 @@ use orbclient::{
|
|||
};
|
||||
use smol_str::SmolStr;
|
||||
|
||||
use crate::{
|
||||
error::EventLoopError,
|
||||
event::{self, Ime, Modifiers, StartCause},
|
||||
event_loop::{self, ControlFlow, DeviceEvents},
|
||||
keyboard::{
|
||||
Key, KeyCode, KeyLocation, ModifiersKeys, ModifiersState, NamedKey, NativeKey,
|
||||
NativeKeyCode, PhysicalKey,
|
||||
},
|
||||
window::{CustomCursor as RootCustomCursor, CustomCursorSource, WindowId as RootWindowId},
|
||||
use crate::error::EventLoopError;
|
||||
use crate::event::{self, Ime, Modifiers, StartCause};
|
||||
use crate::event_loop::{self, ControlFlow, DeviceEvents};
|
||||
use crate::keyboard::{
|
||||
Key, KeyCode, KeyLocation, ModifiersKeys, ModifiersState, NamedKey, NativeKey, NativeKeyCode,
|
||||
PhysicalKey,
|
||||
};
|
||||
use crate::window::{
|
||||
CustomCursor as RootCustomCursor, CustomCursorSource, WindowId as RootWindowId,
|
||||
};
|
||||
|
||||
use super::{
|
||||
|
|
@ -181,7 +179,7 @@ impl EventState {
|
|||
if character.is_ascii_lowercase() {
|
||||
return ((character as u8 - b'a') + 1) as char;
|
||||
}
|
||||
//TODO: more control key variants?
|
||||
// TODO: more control key variants?
|
||||
}
|
||||
|
||||
// Return character as-is if no special handling required
|
||||
|
|
@ -235,74 +233,41 @@ impl EventState {
|
|||
let mut state = ModifiersState::empty();
|
||||
let mut pressed_mods = ModifiersKeys::empty();
|
||||
|
||||
if self
|
||||
.keyboard
|
||||
.intersects(KeyboardModifierState::LSHIFT | KeyboardModifierState::RSHIFT)
|
||||
{
|
||||
if self.keyboard.intersects(KeyboardModifierState::LSHIFT | KeyboardModifierState::RSHIFT) {
|
||||
state |= ModifiersState::SHIFT;
|
||||
}
|
||||
|
||||
pressed_mods.set(
|
||||
ModifiersKeys::LSHIFT,
|
||||
self.keyboard.contains(KeyboardModifierState::LSHIFT),
|
||||
);
|
||||
pressed_mods.set(
|
||||
ModifiersKeys::RSHIFT,
|
||||
self.keyboard.contains(KeyboardModifierState::RSHIFT),
|
||||
);
|
||||
pressed_mods
|
||||
.set(ModifiersKeys::LSHIFT, self.keyboard.contains(KeyboardModifierState::LSHIFT));
|
||||
pressed_mods
|
||||
.set(ModifiersKeys::RSHIFT, self.keyboard.contains(KeyboardModifierState::RSHIFT));
|
||||
|
||||
if self
|
||||
.keyboard
|
||||
.intersects(KeyboardModifierState::LCTRL | KeyboardModifierState::RCTRL)
|
||||
{
|
||||
if self.keyboard.intersects(KeyboardModifierState::LCTRL | KeyboardModifierState::RCTRL) {
|
||||
state |= ModifiersState::CONTROL;
|
||||
}
|
||||
|
||||
pressed_mods.set(
|
||||
ModifiersKeys::LCONTROL,
|
||||
self.keyboard.contains(KeyboardModifierState::LCTRL),
|
||||
);
|
||||
pressed_mods.set(
|
||||
ModifiersKeys::RCONTROL,
|
||||
self.keyboard.contains(KeyboardModifierState::RCTRL),
|
||||
);
|
||||
pressed_mods
|
||||
.set(ModifiersKeys::LCONTROL, self.keyboard.contains(KeyboardModifierState::LCTRL));
|
||||
pressed_mods
|
||||
.set(ModifiersKeys::RCONTROL, self.keyboard.contains(KeyboardModifierState::RCTRL));
|
||||
|
||||
if self
|
||||
.keyboard
|
||||
.intersects(KeyboardModifierState::LALT | KeyboardModifierState::RALT)
|
||||
{
|
||||
if self.keyboard.intersects(KeyboardModifierState::LALT | KeyboardModifierState::RALT) {
|
||||
state |= ModifiersState::ALT;
|
||||
}
|
||||
|
||||
pressed_mods.set(
|
||||
ModifiersKeys::LALT,
|
||||
self.keyboard.contains(KeyboardModifierState::LALT),
|
||||
);
|
||||
pressed_mods.set(
|
||||
ModifiersKeys::RALT,
|
||||
self.keyboard.contains(KeyboardModifierState::RALT),
|
||||
);
|
||||
pressed_mods.set(ModifiersKeys::LALT, self.keyboard.contains(KeyboardModifierState::LALT));
|
||||
pressed_mods.set(ModifiersKeys::RALT, self.keyboard.contains(KeyboardModifierState::RALT));
|
||||
|
||||
if self
|
||||
.keyboard
|
||||
.intersects(KeyboardModifierState::LSUPER | KeyboardModifierState::RSUPER)
|
||||
{
|
||||
if self.keyboard.intersects(KeyboardModifierState::LSUPER | KeyboardModifierState::RSUPER) {
|
||||
state |= ModifiersState::SUPER
|
||||
}
|
||||
|
||||
pressed_mods.set(
|
||||
ModifiersKeys::LSUPER,
|
||||
self.keyboard.contains(KeyboardModifierState::LSUPER),
|
||||
);
|
||||
pressed_mods.set(
|
||||
ModifiersKeys::RSUPER,
|
||||
self.keyboard.contains(KeyboardModifierState::RSUPER),
|
||||
);
|
||||
pressed_mods
|
||||
.set(ModifiersKeys::LSUPER, self.keyboard.contains(KeyboardModifierState::LSUPER));
|
||||
pressed_mods
|
||||
.set(ModifiersKeys::RSUPER, self.keyboard.contains(KeyboardModifierState::RSUPER));
|
||||
|
||||
Modifiers {
|
||||
state,
|
||||
pressed_mods,
|
||||
}
|
||||
Modifiers { state, pressed_mods }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -366,11 +331,7 @@ impl<T: 'static> EventLoop<T> {
|
|||
F: FnMut(event::Event<T>),
|
||||
{
|
||||
match event_option {
|
||||
EventOption::Key(KeyEvent {
|
||||
character,
|
||||
scancode,
|
||||
pressed,
|
||||
}) => {
|
||||
EventOption::Key(KeyEvent { character, scancode, pressed }) => {
|
||||
// Convert scancode
|
||||
let (physical_key, named_key_opt) = convert_scancode(scancode);
|
||||
|
||||
|
|
@ -437,7 +398,7 @@ impl<T: 'static> EventLoop<T> {
|
|||
event: event::WindowEvent::ModifiersChanged(event_state.modifiers()),
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
EventOption::TextInput(TextInputEvent { character }) => {
|
||||
event_handler(event::Event::WindowEvent {
|
||||
window_id: RootWindowId(window_id),
|
||||
|
|
@ -447,7 +408,7 @@ impl<T: 'static> EventLoop<T> {
|
|||
window_id: RootWindowId(window_id),
|
||||
event: event::WindowEvent::Ime(Ime::Commit(character.into())),
|
||||
});
|
||||
}
|
||||
},
|
||||
EventOption::Mouse(MouseEvent { x, y }) => {
|
||||
event_handler(event::Event::WindowEvent {
|
||||
window_id: RootWindowId(window_id),
|
||||
|
|
@ -456,20 +417,14 @@ impl<T: 'static> EventLoop<T> {
|
|||
position: (x, y).into(),
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
EventOption::MouseRelative(MouseRelativeEvent { dx, dy }) => {
|
||||
event_handler(event::Event::DeviceEvent {
|
||||
device_id: event::DeviceId(DeviceId),
|
||||
event: event::DeviceEvent::MouseMotion {
|
||||
delta: (dx as f64, dy as f64),
|
||||
},
|
||||
event: event::DeviceEvent::MouseMotion { delta: (dx as f64, dy as f64) },
|
||||
});
|
||||
}
|
||||
EventOption::Button(ButtonEvent {
|
||||
left,
|
||||
middle,
|
||||
right,
|
||||
}) => {
|
||||
},
|
||||
EventOption::Button(ButtonEvent { left, middle, right }) => {
|
||||
while let Some((button, state)) = event_state.mouse(left, middle, right) {
|
||||
event_handler(event::Event::WindowEvent {
|
||||
window_id: RootWindowId(window_id),
|
||||
|
|
@ -480,7 +435,7 @@ impl<T: 'static> EventLoop<T> {
|
|||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
EventOption::Scroll(ScrollEvent { x, y }) => {
|
||||
event_handler(event::Event::WindowEvent {
|
||||
window_id: RootWindowId(window_id),
|
||||
|
|
@ -490,25 +445,25 @@ impl<T: 'static> EventLoop<T> {
|
|||
phase: event::TouchPhase::Moved,
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
EventOption::Quit(QuitEvent {}) => {
|
||||
event_handler(event::Event::WindowEvent {
|
||||
window_id: RootWindowId(window_id),
|
||||
event: event::WindowEvent::CloseRequested,
|
||||
});
|
||||
}
|
||||
},
|
||||
EventOption::Focus(FocusEvent { focused }) => {
|
||||
event_handler(event::Event::WindowEvent {
|
||||
window_id: RootWindowId(window_id),
|
||||
event: event::WindowEvent::Focused(focused),
|
||||
});
|
||||
}
|
||||
},
|
||||
EventOption::Move(MoveEvent { x, y }) => {
|
||||
event_handler(event::Event::WindowEvent {
|
||||
window_id: RootWindowId(window_id),
|
||||
event: event::WindowEvent::Moved((x, y).into()),
|
||||
});
|
||||
}
|
||||
},
|
||||
EventOption::Resize(ResizeEvent { width, height }) => {
|
||||
event_handler(event::Event::WindowEvent {
|
||||
window_id: RootWindowId(window_id),
|
||||
|
|
@ -517,8 +472,8 @@ impl<T: 'static> EventLoop<T> {
|
|||
|
||||
// Acknowledge resize after event loop.
|
||||
event_state.resize_opt = Some((width, height));
|
||||
}
|
||||
//TODO: Screen, Clipboard, Drop
|
||||
},
|
||||
// TODO: Screen, Clipboard, Drop
|
||||
EventOption::Hover(HoverEvent { entered }) => {
|
||||
if entered {
|
||||
event_handler(event::Event::WindowEvent {
|
||||
|
|
@ -535,10 +490,10 @@ impl<T: 'static> EventLoop<T> {
|
|||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
other => {
|
||||
tracing::warn!("unhandled event: {:?}", other);
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -565,9 +520,7 @@ impl<T: 'static> EventLoop<T> {
|
|||
let mut creates = self.window_target.p.creates.lock().unwrap();
|
||||
creates.pop_front()
|
||||
} {
|
||||
let window_id = WindowId {
|
||||
fd: window.fd as u64,
|
||||
};
|
||||
let window_id = WindowId { fd: window.fd as u64 };
|
||||
|
||||
let mut buf: [u8; 4096] = [0; 4096];
|
||||
let path = window.fpath(&mut buf).expect("failed to read properties");
|
||||
|
|
@ -607,22 +560,20 @@ impl<T: 'static> EventLoop<T> {
|
|||
&self.window_target,
|
||||
);
|
||||
|
||||
self.windows
|
||||
.retain(|(window, _event_state)| window.fd as u64 != destroy_id.fd);
|
||||
self.windows.retain(|(window, _event_state)| window.fd as u64 != destroy_id.fd);
|
||||
}
|
||||
|
||||
// Handle window events.
|
||||
let mut i = 0;
|
||||
// While loop is used here because the same window may be processed more than once.
|
||||
while let Some((window, event_state)) = self.windows.get_mut(i) {
|
||||
let window_id = WindowId {
|
||||
fd: window.fd as u64,
|
||||
};
|
||||
let window_id = WindowId { fd: window.fd as u64 };
|
||||
|
||||
let mut event_buf = [0u8; 16 * mem::size_of::<orbclient::Event>()];
|
||||
let count =
|
||||
syscall::read(window.fd, &mut event_buf).expect("failed to read window events");
|
||||
// Safety: orbclient::Event is a packed struct designed to be transferred over a socket.
|
||||
// Safety: orbclient::Event is a packed struct designed to be transferred over a
|
||||
// socket.
|
||||
let events = unsafe {
|
||||
slice::from_raw_parts(
|
||||
event_buf.as_ptr() as *const orbclient::Event,
|
||||
|
|
@ -640,7 +591,8 @@ impl<T: 'static> EventLoop<T> {
|
|||
}
|
||||
|
||||
if count == event_buf.len() {
|
||||
// If event buf was full, process same window again to ensure all events are drained.
|
||||
// If event buf was full, process same window again to ensure all events are
|
||||
// drained.
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -689,7 +641,7 @@ impl<T: 'static> EventLoop<T> {
|
|||
ControlFlow::Poll => {
|
||||
start_cause = StartCause::Poll;
|
||||
continue;
|
||||
}
|
||||
},
|
||||
ControlFlow::Wait => None,
|
||||
ControlFlow::WaitUntil(instant) => Some(instant),
|
||||
};
|
||||
|
|
@ -734,18 +686,12 @@ impl<T: 'static> EventLoop<T> {
|
|||
Some(requested_resume) if event.id == timeout_socket.0.fd => {
|
||||
// If the event is from the special timeout socket, report that resume
|
||||
// time was reached.
|
||||
start_cause = StartCause::ResumeTimeReached {
|
||||
start,
|
||||
requested_resume,
|
||||
};
|
||||
}
|
||||
start_cause = StartCause::ResumeTimeReached { start, requested_resume };
|
||||
},
|
||||
_ => {
|
||||
// Normal window event or spurious timeout.
|
||||
start_cause = StartCause::WaitCancelled {
|
||||
start,
|
||||
requested_resume,
|
||||
};
|
||||
}
|
||||
start_cause = StartCause::WaitCancelled { start, requested_resume };
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -807,9 +753,7 @@ pub struct ActiveEventLoop {
|
|||
impl ActiveEventLoop {
|
||||
pub fn create_custom_cursor(&self, source: CustomCursorSource) -> RootCustomCursor {
|
||||
let _ = source.inner;
|
||||
RootCustomCursor {
|
||||
inner: super::PlatformCustomCursor,
|
||||
}
|
||||
RootCustomCursor { inner: super::PlatformCustomCursor }
|
||||
}
|
||||
|
||||
pub fn primary_monitor(&self) -> Option<MonitorHandle> {
|
||||
|
|
@ -836,9 +780,7 @@ impl ActiveEventLoop {
|
|||
pub fn raw_display_handle_rwh_06(
|
||||
&self,
|
||||
) -> Result<rwh_06::RawDisplayHandle, rwh_06::HandleError> {
|
||||
Ok(rwh_06::RawDisplayHandle::Orbital(
|
||||
rwh_06::OrbitalDisplayHandle::new(),
|
||||
))
|
||||
Ok(rwh_06::RawDisplayHandle::Orbital(rwh_06::OrbitalDisplayHandle::new()))
|
||||
}
|
||||
|
||||
pub fn set_control_flow(&self, control_flow: ControlFlow) {
|
||||
|
|
|
|||
|
|
@ -6,10 +6,8 @@ use std::sync::Arc;
|
|||
|
||||
use smol_str::SmolStr;
|
||||
|
||||
use crate::{
|
||||
dpi::{PhysicalPosition, PhysicalSize},
|
||||
keyboard::Key,
|
||||
};
|
||||
use crate::dpi::{PhysicalPosition, PhysicalSize};
|
||||
use crate::keyboard::Key;
|
||||
|
||||
pub(crate) use self::event_loop::{ActiveEventLoop, EventLoop, EventLoopProxy, OwnedDisplayHandle};
|
||||
mod event_loop;
|
||||
|
|
@ -105,9 +103,7 @@ pub struct WindowId {
|
|||
|
||||
impl WindowId {
|
||||
pub const fn dummy() -> Self {
|
||||
WindowId {
|
||||
fd: u64::max_value(),
|
||||
}
|
||||
WindowId { fd: u64::max_value() }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -149,27 +145,12 @@ impl<'a> WindowProperties<'a> {
|
|||
// orbital:flags/x/y/w/h/t
|
||||
let mut parts = path.splitn(6, '/');
|
||||
let flags = parts.next().unwrap_or("");
|
||||
let x = parts
|
||||
.next()
|
||||
.map_or(0, |part| part.parse::<i32>().unwrap_or(0));
|
||||
let y = parts
|
||||
.next()
|
||||
.map_or(0, |part| part.parse::<i32>().unwrap_or(0));
|
||||
let w = parts
|
||||
.next()
|
||||
.map_or(0, |part| part.parse::<u32>().unwrap_or(0));
|
||||
let h = parts
|
||||
.next()
|
||||
.map_or(0, |part| part.parse::<u32>().unwrap_or(0));
|
||||
let x = parts.next().map_or(0, |part| part.parse::<i32>().unwrap_or(0));
|
||||
let y = parts.next().map_or(0, |part| part.parse::<i32>().unwrap_or(0));
|
||||
let w = parts.next().map_or(0, |part| part.parse::<u32>().unwrap_or(0));
|
||||
let h = parts.next().map_or(0, |part| part.parse::<u32>().unwrap_or(0));
|
||||
let title = parts.next().unwrap_or("");
|
||||
Self {
|
||||
flags,
|
||||
x,
|
||||
y,
|
||||
w,
|
||||
h,
|
||||
title,
|
||||
}
|
||||
Self { flags, x, y, w, h, title }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -198,8 +179,9 @@ impl Display for OsError {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) use crate::cursor::NoCustomCursor as PlatformCustomCursor;
|
||||
pub(crate) use crate::cursor::NoCustomCursor as PlatformCustomCursorSource;
|
||||
pub(crate) use crate::cursor::{
|
||||
NoCustomCursor as PlatformCustomCursor, NoCustomCursor as PlatformCustomCursorSource,
|
||||
};
|
||||
pub(crate) use crate::icon::NoIcon as PlatformIcon;
|
||||
|
||||
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
|
||||
|
|
|
|||
|
|
@ -1,16 +1,11 @@
|
|||
use std::{
|
||||
collections::VecDeque,
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
use std::collections::VecDeque;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use crate::{
|
||||
cursor::Cursor,
|
||||
dpi::{PhysicalPosition, PhysicalSize, Position, Size},
|
||||
error,
|
||||
platform_impl::Fullscreen,
|
||||
window,
|
||||
window::ImePurpose,
|
||||
};
|
||||
use crate::cursor::Cursor;
|
||||
use crate::dpi::{PhysicalPosition, PhysicalSize, Position, Size};
|
||||
use crate::platform_impl::Fullscreen;
|
||||
use crate::window::ImePurpose;
|
||||
use crate::{error, window};
|
||||
|
||||
use super::{
|
||||
ActiveEventLoop, MonitorHandle, OsError, RedoxSocket, TimeSocket, WindowId, WindowProperties,
|
||||
|
|
@ -54,7 +49,7 @@ impl Window {
|
|||
(1024, 768)
|
||||
};
|
||||
|
||||
//TODO: min/max inner_size
|
||||
// TODO: min/max inner_size
|
||||
|
||||
// Async by default.
|
||||
let mut flag_str = ORBITAL_FLAG_ASYNC.to_string();
|
||||
|
|
@ -67,7 +62,7 @@ impl Window {
|
|||
flag_str.push(ORBITAL_FLAG_RESIZABLE);
|
||||
}
|
||||
|
||||
//TODO: fullscreen
|
||||
// TODO: fullscreen
|
||||
|
||||
if attrs.transparent {
|
||||
flag_str.push(ORBITAL_FLAG_TRANSPARENT);
|
||||
|
|
@ -84,14 +79,14 @@ impl Window {
|
|||
match attrs.window_level {
|
||||
window::WindowLevel::AlwaysOnBottom => {
|
||||
flag_str.push(ORBITAL_FLAG_BACK);
|
||||
}
|
||||
window::WindowLevel::Normal => {}
|
||||
},
|
||||
window::WindowLevel::Normal => {},
|
||||
window::WindowLevel::AlwaysOnTop => {
|
||||
flag_str.push(ORBITAL_FLAG_FRONT);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
//TODO: window_icon
|
||||
// TODO: window_icon
|
||||
|
||||
// Open window.
|
||||
let window = RedoxSocket::orbital(&WindowProperties {
|
||||
|
|
@ -158,9 +153,7 @@ impl Window {
|
|||
|
||||
#[inline]
|
||||
pub fn id(&self) -> WindowId {
|
||||
WindowId {
|
||||
fd: self.window_socket.fd as u64,
|
||||
}
|
||||
WindowId { fd: self.window_socket.fd as u64 }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
@ -207,36 +200,28 @@ impl Window {
|
|||
#[inline]
|
||||
pub fn inner_position(&self) -> Result<PhysicalPosition<i32>, error::NotSupportedError> {
|
||||
let mut buf: [u8; 4096] = [0; 4096];
|
||||
let path = self
|
||||
.window_socket
|
||||
.fpath(&mut buf)
|
||||
.expect("failed to read properties");
|
||||
let path = self.window_socket.fpath(&mut buf).expect("failed to read properties");
|
||||
let properties = WindowProperties::new(path);
|
||||
Ok((properties.x, properties.y).into())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn outer_position(&self) -> Result<PhysicalPosition<i32>, error::NotSupportedError> {
|
||||
//TODO: adjust for window decorations
|
||||
// TODO: adjust for window decorations
|
||||
self.inner_position()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_outer_position(&self, position: Position) {
|
||||
//TODO: adjust for window decorations
|
||||
// TODO: adjust for window decorations
|
||||
let (x, y): (i32, i32) = position.to_physical::<i32>(self.scale_factor()).into();
|
||||
self.window_socket
|
||||
.write(format!("P,{x},{y}").as_bytes())
|
||||
.expect("failed to set position");
|
||||
self.window_socket.write(format!("P,{x},{y}").as_bytes()).expect("failed to set position");
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn inner_size(&self) -> PhysicalSize<u32> {
|
||||
let mut buf: [u8; 4096] = [0; 4096];
|
||||
let path = self
|
||||
.window_socket
|
||||
.fpath(&mut buf)
|
||||
.expect("failed to read properties");
|
||||
let path = self.window_socket.fpath(&mut buf).expect("failed to read properties");
|
||||
let properties = WindowProperties::new(path);
|
||||
(properties.w, properties.h).into()
|
||||
}
|
||||
|
|
@ -244,15 +229,13 @@ impl Window {
|
|||
#[inline]
|
||||
pub fn request_inner_size(&self, size: Size) -> Option<PhysicalSize<u32>> {
|
||||
let (w, h): (u32, u32) = size.to_physical::<u32>(self.scale_factor()).into();
|
||||
self.window_socket
|
||||
.write(format!("S,{w},{h}").as_bytes())
|
||||
.expect("failed to set size");
|
||||
self.window_socket.write(format!("S,{w},{h}").as_bytes()).expect("failed to set size");
|
||||
None
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn outer_size(&self) -> PhysicalSize<u32> {
|
||||
//TODO: adjust for window decorations
|
||||
// TODO: adjust for window decorations
|
||||
self.inner_size()
|
||||
}
|
||||
|
||||
|
|
@ -265,19 +248,14 @@ impl Window {
|
|||
#[inline]
|
||||
pub fn title(&self) -> String {
|
||||
let mut buf: [u8; 4096] = [0; 4096];
|
||||
let path = self
|
||||
.window_socket
|
||||
.fpath(&mut buf)
|
||||
.expect("failed to read properties");
|
||||
let path = self.window_socket.fpath(&mut buf).expect("failed to read properties");
|
||||
let properties = WindowProperties::new(path);
|
||||
properties.title.to_string()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_title(&self, title: &str) {
|
||||
self.window_socket
|
||||
.write(format!("T,{title}").as_bytes())
|
||||
.expect("failed to set title");
|
||||
self.window_socket.write(format!("T,{title}").as_bytes()).expect("failed to set title");
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
@ -357,14 +335,14 @@ impl Window {
|
|||
match level {
|
||||
window::WindowLevel::AlwaysOnBottom => {
|
||||
let _ = self.set_flag(ORBITAL_FLAG_BACK, true);
|
||||
}
|
||||
},
|
||||
window::WindowLevel::Normal => {
|
||||
let _ = self.set_flag(ORBITAL_FLAG_BACK, false);
|
||||
let _ = self.set_flag(ORBITAL_FLAG_FRONT, false);
|
||||
}
|
||||
},
|
||||
window::WindowLevel::AlwaysOnTop => {
|
||||
let _ = self.set_flag(ORBITAL_FLAG_FRONT, true);
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -391,9 +369,7 @@ impl Window {
|
|||
|
||||
#[inline]
|
||||
pub fn set_cursor_position(&self, _: Position) -> Result<(), error::ExternalError> {
|
||||
Err(error::ExternalError::NotSupported(
|
||||
error::NotSupportedError::new(),
|
||||
))
|
||||
Err(error::ExternalError::NotSupported(error::NotSupportedError::new()))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
@ -417,9 +393,7 @@ impl Window {
|
|||
|
||||
#[inline]
|
||||
pub fn set_cursor_visible(&self, visible: bool) {
|
||||
let _ = self
|
||||
.window_socket
|
||||
.write(format!("M,C,{}", if visible { 1 } else { 0 }).as_bytes());
|
||||
let _ = self.window_socket.write(format!("M,C,{}", if visible { 1 } else { 0 }).as_bytes());
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
@ -456,9 +430,7 @@ impl Window {
|
|||
|
||||
#[inline]
|
||||
pub fn set_cursor_hittest(&self, _hittest: bool) -> Result<(), error::ExternalError> {
|
||||
Err(error::ExternalError::NotSupported(
|
||||
error::NotSupportedError::new(),
|
||||
))
|
||||
Err(error::ExternalError::NotSupported(error::NotSupportedError::new()))
|
||||
}
|
||||
|
||||
#[cfg(feature = "rwh_04")]
|
||||
|
|
@ -498,9 +470,7 @@ impl Window {
|
|||
pub fn raw_display_handle_rwh_06(
|
||||
&self,
|
||||
) -> Result<rwh_06::RawDisplayHandle, rwh_06::HandleError> {
|
||||
Ok(rwh_06::RawDisplayHandle::Orbital(
|
||||
rwh_06::OrbitalDisplayHandle::new(),
|
||||
))
|
||||
Ok(rwh_06::RawDisplayHandle::Orbital(rwh_06::OrbitalDisplayHandle::new()))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue