mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-24 22:31:30 +11:00
Continue wayland API: WindowProxy, MonitorID,
and some other little stuff.
This commit is contained in:
parent
bfa7e091d0
commit
a3921ea88a
|
@ -50,15 +50,15 @@ kernel32-sys = "0.1"
|
||||||
|
|
||||||
[target.i686-unknown-linux-gnu.dependencies]
|
[target.i686-unknown-linux-gnu.dependencies]
|
||||||
osmesa-sys = "0.0.5"
|
osmesa-sys = "0.0.5"
|
||||||
wayland-client = "0.1.3"
|
wayland-client = "0.1.4"
|
||||||
x11-dl = "=1.0.1"
|
x11-dl = "=1.0.1"
|
||||||
|
|
||||||
[target.x86_64-unknown-linux-gnu.dependencies]
|
[target.x86_64-unknown-linux-gnu.dependencies]
|
||||||
osmesa-sys = "0.0.5"
|
osmesa-sys = "0.0.5"
|
||||||
wayland-client = "0.1.3"
|
wayland-client = "0.1.4"
|
||||||
x11-dl = "=1.0.1"
|
x11-dl = "=1.0.1"
|
||||||
|
|
||||||
[target.arm-unknown-linux-gnueabihf.dependencies]
|
[target.arm-unknown-linux-gnueabihf.dependencies]
|
||||||
osmesa-sys = "0.0.5"
|
osmesa-sys = "0.0.5"
|
||||||
wayland-client = "0.1.3"
|
wayland-client = "0.1.4"
|
||||||
x11-dl = "=1.0.1"
|
x11-dl = "=1.0.1"
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
use self::wayland::egl::{EGLSurface, is_egl_available};
|
use self::wayland::egl::{EGLSurface, is_egl_available};
|
||||||
use self::wayland::core::{Display, Registry, Compositor, Shell, ShellSurface,
|
use self::wayland::core::{Display, Registry, Compositor, Shell, ShellSurface,
|
||||||
Seat, Pointer, default_display, WSurface, SurfaceId,
|
Seat, Pointer, default_display, WSurface, SurfaceId,
|
||||||
Surface};
|
Surface, Output};
|
||||||
|
|
||||||
use libc;
|
use libc;
|
||||||
use api::dlopen;
|
use api::dlopen;
|
||||||
|
@ -32,7 +32,8 @@ struct WaylandContext {
|
||||||
pub seat: Seat,
|
pub seat: Seat,
|
||||||
pub pointer: Option<Pointer<WSurface>>,
|
pub pointer: Option<Pointer<WSurface>>,
|
||||||
windows_event_queues: Arc<Mutex<HashMap<SurfaceId, Arc<Mutex<VecDeque<Event>>>>>>,
|
windows_event_queues: Arc<Mutex<HashMap<SurfaceId, Arc<Mutex<VecDeque<Event>>>>>>,
|
||||||
current_pointer_surface: Arc<Mutex<Option<SurfaceId>>>
|
current_pointer_surface: Arc<Mutex<Option<SurfaceId>>>,
|
||||||
|
outputs: Vec<Arc<Output>>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WaylandContext {
|
impl WaylandContext {
|
||||||
|
@ -56,6 +57,7 @@ impl WaylandContext {
|
||||||
Some(s) => s,
|
Some(s) => s,
|
||||||
None => return None,
|
None => return None,
|
||||||
};
|
};
|
||||||
|
let outputs = registry.get_outputs().into_iter().map(Arc::new).collect::<Vec<_>>();
|
||||||
// let the other globals get their events
|
// let the other globals get their events
|
||||||
display.sync_roundtrip();
|
display.sync_roundtrip();
|
||||||
|
|
||||||
|
@ -125,7 +127,8 @@ impl WaylandContext {
|
||||||
seat: seat,
|
seat: seat,
|
||||||
pointer: pointer,
|
pointer: pointer,
|
||||||
windows_event_queues: windows_event_queues,
|
windows_event_queues: windows_event_queues,
|
||||||
current_pointer_surface: current_pointer_surface
|
current_pointer_surface: current_pointer_surface,
|
||||||
|
outputs: outputs
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,22 +162,35 @@ pub struct WindowProxy;
|
||||||
|
|
||||||
impl WindowProxy {
|
impl WindowProxy {
|
||||||
pub fn wakeup_event_loop(&self) {
|
pub fn wakeup_event_loop(&self) {
|
||||||
unimplemented!()
|
if let Some(ref ctxt) = *WAYLAND_CONTEXT {
|
||||||
|
ctxt.display.sync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct MonitorID;
|
pub struct MonitorID {
|
||||||
|
output: Arc<Output>
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_available_monitors() -> VecDeque<MonitorID> {
|
pub fn get_available_monitors() -> VecDeque<MonitorID> {
|
||||||
VecDeque::new()
|
WAYLAND_CONTEXT.as_ref().unwrap().outputs.iter().map(|o| MonitorID::new(o.clone())).collect()
|
||||||
}
|
}
|
||||||
pub fn get_primary_monitor() -> MonitorID {
|
pub fn get_primary_monitor() -> MonitorID {
|
||||||
MonitorID
|
match WAYLAND_CONTEXT.as_ref().unwrap().outputs.iter().next() {
|
||||||
|
Some(o) => MonitorID::new(o.clone()),
|
||||||
|
None => panic!("No monitor is available.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MonitorID {
|
impl MonitorID {
|
||||||
|
fn new(output: Arc<Output>) -> MonitorID {
|
||||||
|
MonitorID {
|
||||||
|
output: output
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_name(&self) -> Option<String> {
|
pub fn get_name(&self) -> Option<String> {
|
||||||
unimplemented!();
|
Some(format!("{} - {}", self.output.manufacturer(), self.output.model()))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_native_identifier(&self) -> ::native_monitor::NativeMonitorId {
|
pub fn get_native_identifier(&self) -> ::native_monitor::NativeMonitorId {
|
||||||
|
@ -182,7 +198,8 @@ impl MonitorID {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_dimensions(&self) -> (u32, u32) {
|
pub fn get_dimensions(&self) -> (u32, u32) {
|
||||||
unimplemented!();
|
let (w, h) = self.output.dimensions();
|
||||||
|
(w as u32, h as u32)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,10 +299,12 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_position(&self) -> Option<(i32, i32)> {
|
pub fn get_position(&self) -> Option<(i32, i32)> {
|
||||||
unimplemented!()
|
// not available with wayland
|
||||||
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_position(&self, x: i32, y: i32) {
|
pub fn set_position(&self, _x: i32, _y: i32) {
|
||||||
|
// not available with wayland
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_inner_size(&self) -> Option<(u32, u32)> {
|
pub fn get_inner_size(&self) -> Option<(u32, u32)> {
|
||||||
|
@ -301,7 +320,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_window_proxy(&self) -> WindowProxy {
|
pub fn create_window_proxy(&self) -> WindowProxy {
|
||||||
unimplemented!()
|
WindowProxy
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn poll_events(&self) -> PollEventsIterator {
|
pub fn poll_events(&self) -> PollEventsIterator {
|
||||||
|
|
Loading…
Reference in a new issue