2022-12-25 09:57:27 +02:00
|
|
|
#![cfg(wayland_platform)]
|
2015-04-30 07:49:46 +02:00
|
|
|
|
2023-04-19 00:56:29 +03:00
|
|
|
//! Winit's Wayland backend.
|
|
|
|
|
|
2023-08-13 23:20:09 +04:00
|
|
|
use std::fmt::Display;
|
|
|
|
|
use std::sync::Arc;
|
|
|
|
|
|
|
|
|
|
use sctk::reexports::client::globals::{BindError, GlobalError};
|
Update SCTK to 0.11.0
* Update SCTK to 0.11.0
Updates smithay-client-toolkit to 0.11.0. The major highlight
of that updated, is update of wayland-rs to 0.27.0. Switching
to wayland-cursor, instead of using libwayland-cursor. It
also fixes the following bugs:
- Disabled repeat rate not being handled.
- Decoration buttons not working after tty switch.
- Scaling not being applied on output reenable.
- Crash when `XCURSOR_SIZE` is `0`.
- Pointer getting created in some cases without pointer capability.
- On kwin, fix space between window and decorations on startup.
- Incorrect size event when entering fullscreen when using
client side decorations.
- Client side decorations not being hided properly in fullscreen.
- Size tracking between fullscreen/tiled state changes.
- Repeat rate triggering multiple times from slow callback handler.
- Resizable attribute not being applied properly on startup.
- Not working IME
Besides those fixes it also adds a bunch of missing virtual key codes,
implements proper cursor grabbing, adds right click on decorations
to open application menu, disabled maximize button for non-resizeable
window, and fall back for cursor icon to similar ones, if the requested
is missing.
It also adds new methods to a `Theme` trait, such as:
- `title_font(&self) -> Option<(String, f32)>` - The font for a title.
- `title_color(&self, window_active: bool) -> [u8; 4]` - The color of
the text in the title.
Fixes #1680.
Fixes #1678.
Fixes #1676.
Fixes #1646.
Fixes #1614.
Fixes #1601.
Fixes #1533.
Fixes #1509.
Fixes #952.
Fixes #947.
2020-09-29 00:11:43 +03:00
|
|
|
use sctk::reexports::client::protocol::wl_surface::WlSurface;
|
2023-08-13 23:20:09 +04:00
|
|
|
use sctk::reexports::client::{self, ConnectError, DispatchError, Proxy};
|
2017-03-04 14:04:01 +01:00
|
|
|
|
2023-08-13 23:20:09 +04:00
|
|
|
pub use crate::platform_impl::platform::{OsError, WindowId};
|
Update SCTK to 0.11.0
* Update SCTK to 0.11.0
Updates smithay-client-toolkit to 0.11.0. The major highlight
of that updated, is update of wayland-rs to 0.27.0. Switching
to wayland-cursor, instead of using libwayland-cursor. It
also fixes the following bugs:
- Disabled repeat rate not being handled.
- Decoration buttons not working after tty switch.
- Scaling not being applied on output reenable.
- Crash when `XCURSOR_SIZE` is `0`.
- Pointer getting created in some cases without pointer capability.
- On kwin, fix space between window and decorations on startup.
- Incorrect size event when entering fullscreen when using
client side decorations.
- Client side decorations not being hided properly in fullscreen.
- Size tracking between fullscreen/tiled state changes.
- Repeat rate triggering multiple times from slow callback handler.
- Resizable attribute not being applied properly on startup.
- Not working IME
Besides those fixes it also adds a bunch of missing virtual key codes,
implements proper cursor grabbing, adds right click on decorations
to open application menu, disabled maximize button for non-resizeable
window, and fall back for cursor icon to similar ones, if the requested
is missing.
It also adds new methods to a `Theme` trait, such as:
- `title_font(&self) -> Option<(String, f32)>` - The font for a title.
- `title_color(&self, window_active: bool) -> [u8; 4]` - The color of
the text in the title.
Fixes #1680.
Fixes #1678.
Fixes #1676.
Fixes #1646.
Fixes #1614.
Fixes #1601.
Fixes #1533.
Fixes #1509.
Fixes #952.
Fixes #947.
2020-09-29 00:11:43 +03:00
|
|
|
pub use event_loop::{EventLoop, EventLoopProxy, EventLoopWindowTarget};
|
|
|
|
|
pub use output::{MonitorHandle, VideoMode};
|
|
|
|
|
pub use window::Window;
|
2017-10-20 09:46:42 +02:00
|
|
|
|
2017-03-04 14:04:01 +01:00
|
|
|
mod event_loop;
|
Update SCTK to 0.11.0
* Update SCTK to 0.11.0
Updates smithay-client-toolkit to 0.11.0. The major highlight
of that updated, is update of wayland-rs to 0.27.0. Switching
to wayland-cursor, instead of using libwayland-cursor. It
also fixes the following bugs:
- Disabled repeat rate not being handled.
- Decoration buttons not working after tty switch.
- Scaling not being applied on output reenable.
- Crash when `XCURSOR_SIZE` is `0`.
- Pointer getting created in some cases without pointer capability.
- On kwin, fix space between window and decorations on startup.
- Incorrect size event when entering fullscreen when using
client side decorations.
- Client side decorations not being hided properly in fullscreen.
- Size tracking between fullscreen/tiled state changes.
- Repeat rate triggering multiple times from slow callback handler.
- Resizable attribute not being applied properly on startup.
- Not working IME
Besides those fixes it also adds a bunch of missing virtual key codes,
implements proper cursor grabbing, adds right click on decorations
to open application menu, disabled maximize button for non-resizeable
window, and fall back for cursor icon to similar ones, if the requested
is missing.
It also adds new methods to a `Theme` trait, such as:
- `title_font(&self) -> Option<(String, f32)>` - The font for a title.
- `title_color(&self, window_active: bool) -> [u8; 4]` - The color of
the text in the title.
Fixes #1680.
Fixes #1678.
Fixes #1676.
Fixes #1646.
Fixes #1614.
Fixes #1601.
Fixes #1533.
Fixes #1509.
Fixes #952.
Fixes #947.
2020-09-29 00:11:43 +03:00
|
|
|
mod output;
|
|
|
|
|
mod seat;
|
2023-04-19 00:56:29 +03:00
|
|
|
mod state;
|
|
|
|
|
mod types;
|
2015-12-08 22:54:06 +01:00
|
|
|
mod window;
|
2017-04-22 13:52:35 -07:00
|
|
|
|
2023-08-13 23:20:09 +04:00
|
|
|
#[derive(Debug)]
|
|
|
|
|
pub enum WaylandError {
|
|
|
|
|
/// Error connecting to the socket.
|
|
|
|
|
Connection(ConnectError),
|
|
|
|
|
|
|
|
|
|
/// Error binding the global.
|
|
|
|
|
Global(GlobalError),
|
|
|
|
|
|
|
|
|
|
// Bind error.
|
|
|
|
|
Bind(BindError),
|
|
|
|
|
|
|
|
|
|
/// Error during the dispatching the event queue.
|
|
|
|
|
Dispatch(DispatchError),
|
|
|
|
|
|
|
|
|
|
/// Calloop error.
|
|
|
|
|
Calloop(calloop::Error),
|
|
|
|
|
|
|
|
|
|
/// Wayland
|
|
|
|
|
Wire(client::backend::WaylandError),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Display for WaylandError {
|
|
|
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
|
|
|
match self {
|
|
|
|
|
WaylandError::Connection(error) => error.fmt(f),
|
|
|
|
|
WaylandError::Global(error) => error.fmt(f),
|
|
|
|
|
WaylandError::Bind(error) => error.fmt(f),
|
|
|
|
|
WaylandError::Dispatch(error) => error.fmt(f),
|
|
|
|
|
WaylandError::Calloop(error) => error.fmt(f),
|
|
|
|
|
WaylandError::Wire(error) => error.fmt(f),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl From<WaylandError> for OsError {
|
|
|
|
|
fn from(value: WaylandError) -> Self {
|
|
|
|
|
Self::WaylandError(Arc::new(value))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-19 00:56:29 +03:00
|
|
|
/// Dummy device id, since Wayland doesn't have device events.
|
2017-04-22 13:52:35 -07:00
|
|
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
|
|
|
pub struct DeviceId;
|
2017-10-20 09:46:42 +02:00
|
|
|
|
2018-12-21 09:51:48 -07:00
|
|
|
impl DeviceId {
|
2021-08-30 19:40:02 +02:00
|
|
|
pub const unsafe fn dummy() -> Self {
|
2018-12-21 09:51:48 -07:00
|
|
|
DeviceId
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-19 00:56:29 +03:00
|
|
|
/// Get the WindowId out of the surface.
|
2017-10-20 09:46:42 +02:00
|
|
|
#[inline]
|
Update SCTK to 0.11.0
* Update SCTK to 0.11.0
Updates smithay-client-toolkit to 0.11.0. The major highlight
of that updated, is update of wayland-rs to 0.27.0. Switching
to wayland-cursor, instead of using libwayland-cursor. It
also fixes the following bugs:
- Disabled repeat rate not being handled.
- Decoration buttons not working after tty switch.
- Scaling not being applied on output reenable.
- Crash when `XCURSOR_SIZE` is `0`.
- Pointer getting created in some cases without pointer capability.
- On kwin, fix space between window and decorations on startup.
- Incorrect size event when entering fullscreen when using
client side decorations.
- Client side decorations not being hided properly in fullscreen.
- Size tracking between fullscreen/tiled state changes.
- Repeat rate triggering multiple times from slow callback handler.
- Resizable attribute not being applied properly on startup.
- Not working IME
Besides those fixes it also adds a bunch of missing virtual key codes,
implements proper cursor grabbing, adds right click on decorations
to open application menu, disabled maximize button for non-resizeable
window, and fall back for cursor icon to similar ones, if the requested
is missing.
It also adds new methods to a `Theme` trait, such as:
- `title_font(&self) -> Option<(String, f32)>` - The font for a title.
- `title_color(&self, window_active: bool) -> [u8; 4]` - The color of
the text in the title.
Fixes #1680.
Fixes #1678.
Fixes #1676.
Fixes #1646.
Fixes #1614.
Fixes #1601.
Fixes #1533.
Fixes #1509.
Fixes #952.
Fixes #947.
2020-09-29 00:11:43 +03:00
|
|
|
fn make_wid(surface: &WlSurface) -> WindowId {
|
2023-04-19 00:56:29 +03:00
|
|
|
WindowId(surface.id().as_ptr() as u64)
|
2018-05-05 19:36:34 +02:00
|
|
|
}
|