Move Wayland backend to winit-wayland (#4252)
This commit is contained in:
parent
927af44aa4
commit
1126e9ea2f
29 changed files with 181 additions and 138 deletions
3
.github/CODEOWNERS
vendored
3
.github/CODEOWNERS
vendored
|
|
@ -12,8 +12,7 @@
|
|||
/winit-common/src/xkb @kchibisov
|
||||
|
||||
# Wayland
|
||||
/src/platform/wayland.rs @kchibisov
|
||||
/src/platform_impl/linux/wayland @kchibisov
|
||||
/winit-wayland @kchibisov
|
||||
|
||||
# X11
|
||||
/src/platform/x11.rs @kchibisov @notgull
|
||||
|
|
|
|||
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
|
|
@ -194,7 +194,7 @@ jobs:
|
|||
run: cargo $CMD test -p winit-common --features core-foundation --no-run
|
||||
|
||||
- name: Test winit Common (XKB)
|
||||
if: contains(matrix.platform.target, 'linux')
|
||||
if: contains(matrix.platform.target, 'linux-gnu')
|
||||
run: cargo $CMD test -p winit-common --features xkb,x11,wayland --no-run
|
||||
|
||||
- name: Test winit Orbital
|
||||
|
|
@ -210,6 +210,10 @@ jobs:
|
|||
if: contains(matrix.platform.target, 'windows')
|
||||
run: cargo $CMD test -p winit-win32 --target=${{ matrix.platform.target }}
|
||||
|
||||
- name: Test winit Wayland
|
||||
if: contains(matrix.platform.target, 'linux-gnu')
|
||||
run: cargo $CMD test -p winit-wayland --target=${{ matrix.platform.target }}
|
||||
|
||||
# Test only on Linux x86_64, so we avoid spending unnecessary CI hours.
|
||||
- name: Test dpi crate
|
||||
if: >
|
||||
|
|
|
|||
29
Cargo.toml
29
Cargo.toml
|
|
@ -17,6 +17,7 @@ winit-common = { version = "0.0.0", path = "winit-common" }
|
|||
winit-core = { version = "0.0.0", path = "winit-core" }
|
||||
winit-orbital = { version = "0.0.0", path = "winit-orbital" }
|
||||
winit-uikit = { version = "0.0.0", path = "winit-uikit" }
|
||||
winit-wayland = { version = "0.0.0", path = "winit-wayland", default-features = false }
|
||||
winit-win32 = { version = "0.0.0", path = "winit-win32" }
|
||||
|
||||
# Core dependencies.
|
||||
|
|
@ -167,20 +168,11 @@ serde = [
|
|||
"winit-core/serde",
|
||||
"winit-uikit/serde",
|
||||
]
|
||||
wayland = [
|
||||
"wayland-client",
|
||||
"wayland-backend",
|
||||
"wayland-protocols",
|
||||
"wayland-protocols-plasma",
|
||||
"sctk",
|
||||
"ahash",
|
||||
"memmap2",
|
||||
"winit-common/wayland",
|
||||
]
|
||||
wayland-csd-adwaita = ["sctk-adwaita", "sctk-adwaita/ab_glyph"]
|
||||
wayland-csd-adwaita-crossfont = ["sctk-adwaita", "sctk-adwaita/crossfont"]
|
||||
wayland-csd-adwaita-notitle = ["sctk-adwaita"]
|
||||
wayland-dlopen = ["wayland-backend/dlopen"]
|
||||
wayland = ["winit-wayland"]
|
||||
wayland-csd-adwaita = ["winit-wayland/csd-adwaita"]
|
||||
wayland-csd-adwaita-crossfont = ["winit-wayland/csd-adwaita-crossfont"]
|
||||
wayland-csd-adwaita-notitle = ["winit-wayland/csd-adwaita-notitle"]
|
||||
wayland-dlopen = ["winit-wayland/dlopen"]
|
||||
x11 = ["x11-dl", "bytemuck", "percent-encoding", "xkbcommon-dl/x11", "x11rb", "winit-common/x11"]
|
||||
|
||||
[build-dependencies]
|
||||
|
|
@ -306,20 +298,13 @@ winit-win32.workspace = true
|
|||
|
||||
# Linux
|
||||
[target.'cfg(all(unix, not(any(target_os = "redox", target_family = "wasm", target_os = "android", target_vendor = "apple"))))'.dependencies]
|
||||
ahash = { workspace = true, optional = true }
|
||||
bytemuck = { workspace = true, optional = true }
|
||||
calloop.workspace = true
|
||||
libc.workspace = true
|
||||
memmap2 = { workspace = true, optional = true }
|
||||
percent-encoding = { workspace = true, optional = true }
|
||||
rustix = { workspace = true, features = ["std", "system", "thread", "process"] }
|
||||
sctk = { workspace = true, optional = true }
|
||||
sctk-adwaita = { workspace = true, optional = true }
|
||||
wayland-backend = { workspace = true, optional = true }
|
||||
wayland-client = { workspace = true, optional = true }
|
||||
wayland-protocols = { workspace = true, optional = true }
|
||||
wayland-protocols-plasma = { workspace = true, optional = true }
|
||||
winit-common = { workspace = true, features = ["xkb"] }
|
||||
winit-wayland = { workspace = true, optional = true, default-features = false }
|
||||
x11-dl = { workspace = true, optional = true }
|
||||
x11rb = { workspace = true, optional = true, features = [
|
||||
"allow-unsafe-code",
|
||||
|
|
|
|||
|
|
@ -348,6 +348,29 @@ impl winit_android::EventLoopBuilderExtAndroid for EventLoopBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(wayland_platform)]
|
||||
impl winit_wayland::EventLoopExtWayland for EventLoop {
|
||||
#[inline]
|
||||
fn is_wayland(&self) -> bool {
|
||||
self.event_loop.is_wayland()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(wayland_platform)]
|
||||
impl winit_wayland::EventLoopBuilderExtWayland for EventLoopBuilder {
|
||||
#[inline]
|
||||
fn with_wayland(&mut self) -> &mut Self {
|
||||
self.platform_specific.forced_backend = Some(crate::platform_impl::Backend::Wayland);
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn with_any_thread(&mut self, any_thread: bool) -> &mut Self {
|
||||
self.platform_specific.any_thread = any_thread;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows_platform)]
|
||||
impl winit_win32::EventLoopBuilderExtWindows for EventLoopBuilder {
|
||||
#[inline]
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ pub use winit_orbital as orbital;
|
|||
#[cfg(any(x11_platform, wayland_platform))]
|
||||
pub mod startup_notify;
|
||||
#[cfg(wayland_platform)]
|
||||
pub mod wayland;
|
||||
pub use winit_wayland as wayland;
|
||||
#[cfg(web_platform)]
|
||||
pub mod web;
|
||||
#[cfg(windows_platform)]
|
||||
|
|
|
|||
|
|
@ -15,12 +15,11 @@ use winit_core::error::{EventLoopError, NotSupportedError};
|
|||
use winit_core::event_loop::pump_events::PumpStatus;
|
||||
use winit_core::event_loop::ActiveEventLoop;
|
||||
use winit_core::window::ActivationToken;
|
||||
#[cfg(wayland_platform)]
|
||||
pub(crate) use winit_wayland as wayland;
|
||||
|
||||
#[cfg(x11_platform)]
|
||||
use crate::platform::x11::WindowType as XWindowType;
|
||||
|
||||
#[cfg(wayland_platform)]
|
||||
pub(crate) mod wayland;
|
||||
#[cfg(x11_platform)]
|
||||
pub(crate) mod x11;
|
||||
|
||||
|
|
@ -45,6 +44,7 @@ pub struct ApplicationName {
|
|||
}
|
||||
|
||||
impl ApplicationName {
|
||||
#[allow(dead_code)]
|
||||
pub fn new(general: String, instance: String) -> Self {
|
||||
Self { general, instance }
|
||||
}
|
||||
|
|
@ -196,6 +196,7 @@ impl EventLoop {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(dead_code)]
|
||||
pub fn is_wayland(&self) -> bool {
|
||||
match *self {
|
||||
#[cfg(wayland_platform)]
|
||||
|
|
@ -244,6 +245,7 @@ impl AsRawFd for EventLoop {
|
|||
/// Returns the minimum `Option<Duration>`, taking into account that `None`
|
||||
/// equates to an infinite timeout, not a zero timeout (so can't just use
|
||||
/// `Option::min`)
|
||||
#[allow(dead_code)]
|
||||
fn min_timeout(a: Option<Duration>, b: Option<Duration>) -> Option<Duration> {
|
||||
a.map_or(b, |a_timeout| b.map_or(Some(a_timeout), |b_timeout| Some(a_timeout.min(b_timeout))))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,29 +0,0 @@
|
|||
//! Winit's Wayland backend.
|
||||
|
||||
use dpi::{LogicalSize, PhysicalSize};
|
||||
use sctk::reexports::client::protocol::wl_surface::WlSurface;
|
||||
use sctk::reexports::client::Proxy;
|
||||
use winit_core::window::WindowId;
|
||||
|
||||
mod event_loop;
|
||||
mod output;
|
||||
mod seat;
|
||||
mod state;
|
||||
mod types;
|
||||
mod window;
|
||||
|
||||
pub use event_loop::{ActiveEventLoop, EventLoop};
|
||||
pub use window::Window;
|
||||
|
||||
/// Get the WindowId out of the surface.
|
||||
#[inline]
|
||||
fn make_wid(surface: &WlSurface) -> WindowId {
|
||||
WindowId::from_raw(surface.id().as_ptr() as usize)
|
||||
}
|
||||
|
||||
/// The default routine does floor, but we need round on Wayland.
|
||||
fn logical_to_physical_rounded(size: LogicalSize<u32>, scale_factor: f64) -> PhysicalSize<u32> {
|
||||
let width = size.width as f64 * scale_factor;
|
||||
let height = size.height as f64 * scale_factor;
|
||||
(width.round(), height.round()).into()
|
||||
}
|
||||
45
winit-wayland/Cargo.toml
Normal file
45
winit-wayland/Cargo.toml
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
[package]
|
||||
description = "Winit's Wayland backend"
|
||||
documentation = "https://docs.rs/winit-wayland"
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
name = "winit-wayland"
|
||||
repository.workspace = true
|
||||
rust-version.workspace = true
|
||||
version = "0.0.0"
|
||||
|
||||
[features]
|
||||
default = ["dlopen", "csd-adwaita"]
|
||||
|
||||
csd-adwaita = ["sctk-adwaita", "sctk-adwaita/ab_glyph"]
|
||||
csd-adwaita-crossfont = ["sctk-adwaita", "sctk-adwaita/crossfont"]
|
||||
csd-adwaita-notitle = ["sctk-adwaita"]
|
||||
dlopen = ["wayland-backend/dlopen"]
|
||||
serde = ["dep:serde", "bitflags/serde", "smol_str/serde", "dpi/serde"]
|
||||
|
||||
[dependencies]
|
||||
bitflags.workspace = true
|
||||
cursor-icon.workspace = true
|
||||
dpi.workspace = true
|
||||
rwh_06.workspace = true
|
||||
serde = { workspace = true, optional = true }
|
||||
smol_str.workspace = true
|
||||
tracing.workspace = true
|
||||
winit-core.workspace = true
|
||||
|
||||
# Platform-specific
|
||||
ahash.workspace = true
|
||||
calloop.workspace = true
|
||||
libc.workspace = true
|
||||
memmap2.workspace = true
|
||||
rustix = { workspace = true, features = ["std", "system", "thread", "process"] }
|
||||
sctk.workspace = true
|
||||
sctk-adwaita = { workspace = true, optional = true }
|
||||
wayland-backend.workspace = true
|
||||
wayland-client.workspace = true
|
||||
wayland-protocols.workspace = true
|
||||
wayland-protocols-plasma.workspace = true
|
||||
winit-common = { workspace = true, features = ["xkb", "wayland"] }
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
features = ["dlopen", "serde", "csd-adwaita"]
|
||||
1
winit-wayland/README.md
Symbolic link
1
winit-wayland/README.md
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../README.md
|
||||
|
|
@ -29,8 +29,7 @@ use winit_core::event_loop::{
|
|||
use winit_core::monitor::MonitorHandle as CoreMonitorHandle;
|
||||
use winit_core::window::Theme;
|
||||
|
||||
use crate::platform_impl::platform::min_timeout;
|
||||
use crate::platform_impl::wayland::types::cursor::WaylandCustomCursor;
|
||||
use crate::types::cursor::WaylandCustomCursor;
|
||||
|
||||
mod proxy;
|
||||
pub mod sink;
|
||||
|
|
@ -650,7 +649,7 @@ impl RootActiveEventLoop for ActiveEventLoop {
|
|||
&self,
|
||||
window_attributes: winit_core::window::WindowAttributes,
|
||||
) -> Result<Box<dyn winit_core::window::Window>, RequestError> {
|
||||
let window = crate::platform_impl::wayland::Window::new(self, window_attributes)?;
|
||||
let window = crate::Window::new(self, window_attributes)?;
|
||||
Ok(Box::new(window))
|
||||
}
|
||||
|
||||
|
|
@ -813,3 +812,10 @@ enum PumpEventNotifierAction {
|
|||
/// Shutdown the thread.
|
||||
Shutdown,
|
||||
}
|
||||
|
||||
/// Returns the minimum `Option<Duration>`, taking into account that `None`
|
||||
/// equates to an infinite timeout, not a zero timeout (so can't just use
|
||||
/// `Option::min`)
|
||||
fn min_timeout(a: Option<Duration>, b: Option<Duration>) -> Option<Duration> {
|
||||
a.map_or(b, |a_timeout| b.map_or(Some(a_timeout), |b_timeout| Some(a_timeout.min(b_timeout))))
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
//! # Wayland
|
||||
//! # Winit's Wayland backend.
|
||||
//!
|
||||
//! **Note:** Windows don't appear on Wayland until you draw/present to them.
|
||||
//!
|
||||
|
|
@ -16,12 +16,29 @@
|
|||
use std::ffi::c_void;
|
||||
use std::ptr::NonNull;
|
||||
|
||||
use winit_core::window::PlatformWindowAttributes;
|
||||
use dpi::{LogicalSize, PhysicalSize};
|
||||
use sctk::reexports::client::protocol::wl_surface::WlSurface;
|
||||
use sctk::reexports::client::Proxy;
|
||||
use winit_core::event_loop::ActiveEventLoop as CoreActiveEventLoop;
|
||||
use winit_core::window::{
|
||||
ActivationToken, PlatformWindowAttributes, Window as CoreWindow, WindowId,
|
||||
};
|
||||
|
||||
use crate::event_loop::{ActiveEventLoop, EventLoop, EventLoopBuilder};
|
||||
use crate::platform_impl::wayland::Window;
|
||||
use crate::platform_impl::ApplicationName;
|
||||
use crate::window::{ActivationToken, Window as CoreWindow};
|
||||
macro_rules! os_error {
|
||||
($error:expr) => {{
|
||||
winit_core::error::OsError::new(line!(), file!(), $error)
|
||||
}};
|
||||
}
|
||||
|
||||
mod event_loop;
|
||||
mod output;
|
||||
mod seat;
|
||||
mod state;
|
||||
mod types;
|
||||
mod window;
|
||||
|
||||
pub use self::event_loop::{ActiveEventLoop, EventLoop};
|
||||
pub use self::window::Window;
|
||||
|
||||
/// Additional methods on [`ActiveEventLoop`] that are specific to Wayland.
|
||||
pub trait ActiveEventLoopExtWayland {
|
||||
|
|
@ -29,10 +46,10 @@ pub trait ActiveEventLoopExtWayland {
|
|||
fn is_wayland(&self) -> bool;
|
||||
}
|
||||
|
||||
impl ActiveEventLoopExtWayland for dyn ActiveEventLoop + '_ {
|
||||
impl ActiveEventLoopExtWayland for dyn CoreActiveEventLoop + '_ {
|
||||
#[inline]
|
||||
fn is_wayland(&self) -> bool {
|
||||
self.cast_ref::<crate::platform_impl::wayland::ActiveEventLoop>().is_some()
|
||||
self.cast_ref::<ActiveEventLoop>().is_some()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -42,13 +59,6 @@ pub trait EventLoopExtWayland {
|
|||
fn is_wayland(&self) -> bool;
|
||||
}
|
||||
|
||||
impl EventLoopExtWayland for EventLoop {
|
||||
#[inline]
|
||||
fn is_wayland(&self) -> bool {
|
||||
self.event_loop.is_wayland()
|
||||
}
|
||||
}
|
||||
|
||||
/// Additional methods on [`EventLoopBuilder`] that are specific to Wayland.
|
||||
pub trait EventLoopBuilderExtWayland {
|
||||
/// Force using Wayland.
|
||||
|
|
@ -61,20 +71,6 @@ pub trait EventLoopBuilderExtWayland {
|
|||
fn with_any_thread(&mut self, any_thread: bool) -> &mut Self;
|
||||
}
|
||||
|
||||
impl EventLoopBuilderExtWayland for EventLoopBuilder {
|
||||
#[inline]
|
||||
fn with_wayland(&mut self) -> &mut Self {
|
||||
self.platform_specific.forced_backend = Some(crate::platform_impl::Backend::Wayland);
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn with_any_thread(&mut self, any_thread: bool) -> &mut Self {
|
||||
self.platform_specific.any_thread = any_thread;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
/// Additional methods on [`Window`] that are specific to Wayland.
|
||||
///
|
||||
/// [`Window`]: crate::window::Window
|
||||
|
|
@ -90,6 +86,12 @@ impl WindowExtWayland for dyn CoreWindow + '_ {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub(crate) struct ApplicationName {
|
||||
pub(crate) general: String,
|
||||
pub(crate) instance: String,
|
||||
}
|
||||
|
||||
/// Window attributes methods specific to Wayland.
|
||||
#[derive(Debug, Default, Clone)]
|
||||
pub struct WindowAttributesWayland {
|
||||
|
|
@ -107,8 +109,7 @@ impl WindowAttributesWayland {
|
|||
/// [Desktop Entry Spec](https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#desktop-file-id)
|
||||
#[inline]
|
||||
pub fn with_name(mut self, general: impl Into<String>, instance: impl Into<String>) -> Self {
|
||||
self.name =
|
||||
Some(crate::platform_impl::ApplicationName::new(general.into(), instance.into()));
|
||||
self.name = Some(ApplicationName { general: general.into(), instance: instance.into() });
|
||||
self
|
||||
}
|
||||
|
||||
|
|
@ -124,3 +125,16 @@ impl PlatformWindowAttributes for WindowAttributesWayland {
|
|||
Box::from(self.clone())
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the WindowId out of the surface.
|
||||
#[inline]
|
||||
fn make_wid(surface: &WlSurface) -> WindowId {
|
||||
WindowId::from_raw(surface.id().as_ptr() as usize)
|
||||
}
|
||||
|
||||
/// The default routine does floor, but we need round on Wayland.
|
||||
fn logical_to_physical_rounded(size: LogicalSize<u32>, scale_factor: f64) -> PhysicalSize<u32> {
|
||||
let width = size.width as f64 * scale_factor;
|
||||
let height = size.height as f64 * scale_factor;
|
||||
(width.round(), height.round()).into()
|
||||
}
|
||||
|
|
@ -15,9 +15,9 @@ use winit_common::xkb::Context;
|
|||
use winit_core::event::{ElementState, WindowEvent};
|
||||
use winit_core::keyboard::ModifiersState;
|
||||
|
||||
use crate::platform_impl::wayland::event_loop::sink::EventSink;
|
||||
use crate::platform_impl::wayland::state::WinitState;
|
||||
use crate::platform_impl::wayland::{self, WindowId};
|
||||
use crate::event_loop::sink::EventSink;
|
||||
use crate::state::WinitState;
|
||||
use crate::WindowId;
|
||||
|
||||
impl Dispatch<WlKeyboard, KeyboardData, WinitState> for WinitState {
|
||||
fn event(
|
||||
|
|
@ -60,7 +60,7 @@ impl Dispatch<WlKeyboard, KeyboardData, WinitState> for WinitState {
|
|||
},
|
||||
},
|
||||
WlKeyboardEvent::Enter { surface, .. } => {
|
||||
let window_id = wayland::make_wid(&surface);
|
||||
let window_id = crate::make_wid(&surface);
|
||||
|
||||
// Mark the window as focused.
|
||||
let was_unfocused = match state.windows.get_mut().get(&window_id) {
|
||||
|
|
@ -95,7 +95,7 @@ impl Dispatch<WlKeyboard, KeyboardData, WinitState> for WinitState {
|
|||
}
|
||||
},
|
||||
WlKeyboardEvent::Leave { surface, .. } => {
|
||||
let window_id = wayland::make_wid(&surface);
|
||||
let window_id = crate::make_wid(&surface);
|
||||
|
||||
// NOTE: we should drop the repeat regardless whethere it was for the present
|
||||
// window of for the window which just went gone.
|
||||
|
|
@ -15,7 +15,7 @@ use tracing::warn;
|
|||
use winit_core::event::WindowEvent;
|
||||
use winit_core::keyboard::ModifiersState;
|
||||
|
||||
use crate::platform_impl::wayland::state::WinitState;
|
||||
use crate::state::WinitState;
|
||||
|
||||
mod keyboard;
|
||||
mod pointer;
|
||||
|
|
@ -33,8 +33,8 @@ use winit_core::event::{
|
|||
WindowEvent,
|
||||
};
|
||||
|
||||
use crate::platform_impl::wayland::state::WinitState;
|
||||
use crate::platform_impl::wayland::{self, WindowId};
|
||||
use crate::state::WinitState;
|
||||
use crate::WindowId;
|
||||
|
||||
pub mod relative_pointer;
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ impl PointerHandler for WinitState {
|
|||
None => continue,
|
||||
};
|
||||
|
||||
let window_id = wayland::make_wid(parent_surface);
|
||||
let window_id = crate::make_wid(parent_surface);
|
||||
|
||||
// Ensure that window exists.
|
||||
let mut window = match self.windows.get_mut().get_mut(&window_id) {
|
||||
|
|
@ -13,7 +13,7 @@ use sctk::reexports::protocols::wp::relative_pointer::zv1::{
|
|||
use sctk::globals::GlobalData;
|
||||
|
||||
use winit_core::event::DeviceEvent;
|
||||
use crate::platform_impl::wayland::state::WinitState;
|
||||
use crate::state::WinitState;
|
||||
|
||||
/// Wrapper around the relative pointer.
|
||||
#[derive(Debug)]
|
||||
|
|
@ -11,8 +11,7 @@ use sctk::reexports::protocols::wp::text_input::zv3::client::zwp_text_input_v3::
|
|||
use winit_core::event::{Ime, WindowEvent};
|
||||
use winit_core::window::ImePurpose;
|
||||
|
||||
use crate::platform_impl::wayland;
|
||||
use crate::platform_impl::wayland::state::WinitState;
|
||||
use crate::state::WinitState;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct TextInputState {
|
||||
|
|
@ -62,7 +61,7 @@ impl Dispatch<ZwpTextInputV3, TextInputData, WinitState> for TextInputState {
|
|||
let mut text_input_data = data.inner.lock().unwrap();
|
||||
match event {
|
||||
TextInputEvent::Enter { surface } => {
|
||||
let window_id = wayland::make_wid(&surface);
|
||||
let window_id = crate::make_wid(&surface);
|
||||
text_input_data.surface = Some(surface);
|
||||
|
||||
let mut window = match windows.get(&window_id) {
|
||||
|
|
@ -86,7 +85,7 @@ impl Dispatch<ZwpTextInputV3, TextInputData, WinitState> for TextInputState {
|
|||
text_input.disable();
|
||||
text_input.commit();
|
||||
|
||||
let window_id = wayland::make_wid(&surface);
|
||||
let window_id = crate::make_wid(&surface);
|
||||
|
||||
// XXX this check is essential, because `leave` could have a
|
||||
// reference to nil surface...
|
||||
|
|
@ -116,7 +115,7 @@ impl Dispatch<ZwpTextInputV3, TextInputData, WinitState> for TextInputState {
|
|||
},
|
||||
TextInputEvent::Done { .. } => {
|
||||
let window_id = match text_input_data.surface.as_ref() {
|
||||
Some(surface) => wayland::make_wid(surface),
|
||||
Some(surface) => crate::make_wid(surface),
|
||||
None => return,
|
||||
};
|
||||
|
||||
|
|
@ -11,8 +11,7 @@ use winit_core::event::{
|
|||
ButtonSource, ElementState, FingerId, PointerKind, PointerSource, WindowEvent,
|
||||
};
|
||||
|
||||
use crate::platform_impl::wayland;
|
||||
use crate::platform_impl::wayland::state::WinitState;
|
||||
use crate::state::WinitState;
|
||||
|
||||
impl TouchHandler for WinitState {
|
||||
fn down(
|
||||
|
|
@ -26,7 +25,7 @@ impl TouchHandler for WinitState {
|
|||
id: i32,
|
||||
position: (f64, f64),
|
||||
) {
|
||||
let window_id = wayland::make_wid(&surface);
|
||||
let window_id = crate::make_wid(&surface);
|
||||
let scale_factor = match self.windows.get_mut().get(&window_id) {
|
||||
Some(window) => window.lock().unwrap().scale_factor(),
|
||||
None => return,
|
||||
|
|
@ -105,7 +104,7 @@ impl TouchHandler for WinitState {
|
|||
seat_state.first_touch_id = None;
|
||||
}
|
||||
|
||||
let window_id = wayland::make_wid(&touch_point.surface);
|
||||
let window_id = crate::make_wid(&touch_point.surface);
|
||||
let scale_factor = match self.windows.get_mut().get(&window_id) {
|
||||
Some(window) => window.lock().unwrap().scale_factor(),
|
||||
None => return,
|
||||
|
|
@ -160,7 +159,7 @@ impl TouchHandler for WinitState {
|
|||
|
||||
let primary = seat_state.first_touch_id == Some(id);
|
||||
|
||||
let window_id = wayland::make_wid(&touch_point.surface);
|
||||
let window_id = crate::make_wid(&touch_point.surface);
|
||||
let scale_factor = match self.windows.get_mut().get(&window_id) {
|
||||
Some(window) => window.lock().unwrap().scale_factor(),
|
||||
None => return,
|
||||
|
|
@ -192,7 +191,7 @@ impl TouchHandler for WinitState {
|
|||
};
|
||||
|
||||
for (id, touch_point) in seat_state.touch_map.drain() {
|
||||
let window_id = wayland::make_wid(&touch_point.surface);
|
||||
let window_id = crate::make_wid(&touch_point.surface);
|
||||
let scale_factor = match self.windows.get_mut().get(&window_id) {
|
||||
Some(window) => window.lock().unwrap().scale_factor(),
|
||||
None => return,
|
||||
|
|
@ -22,18 +22,18 @@ use sctk::shm::{Shm, ShmHandler};
|
|||
use sctk::subcompositor::SubcompositorState;
|
||||
use winit_core::error::OsError;
|
||||
|
||||
use crate::platform_impl::wayland::event_loop::sink::EventSink;
|
||||
use crate::platform_impl::wayland::output::MonitorHandle;
|
||||
use crate::platform_impl::wayland::seat::{
|
||||
use crate::event_loop::sink::EventSink;
|
||||
use crate::output::MonitorHandle;
|
||||
use crate::seat::{
|
||||
PointerConstraintsState, RelativePointerState, TextInputState, WinitPointerData,
|
||||
WinitPointerDataExt, WinitSeatState,
|
||||
};
|
||||
use crate::platform_impl::wayland::types::kwin_blur::KWinBlurManager;
|
||||
use crate::platform_impl::wayland::types::wp_fractional_scaling::FractionalScalingManager;
|
||||
use crate::platform_impl::wayland::types::wp_viewporter::ViewporterState;
|
||||
use crate::platform_impl::wayland::types::xdg_activation::XdgActivationState;
|
||||
use crate::platform_impl::wayland::window::{WindowRequests, WindowState};
|
||||
use crate::platform_impl::wayland::WindowId;
|
||||
use crate::types::kwin_blur::KWinBlurManager;
|
||||
use crate::types::wp_fractional_scaling::FractionalScalingManager;
|
||||
use crate::types::wp_viewporter::ViewporterState;
|
||||
use crate::types::xdg_activation::XdgActivationState;
|
||||
use crate::window::{WindowRequests, WindowState};
|
||||
use crate::WindowId;
|
||||
|
||||
/// Winit's Wayland state.
|
||||
#[derive(Debug)]
|
||||
|
|
@ -7,7 +7,7 @@ use sctk::reexports::client::{delegate_dispatch, Connection, Dispatch, Proxy, Qu
|
|||
use wayland_protocols_plasma::blur::client::org_kde_kwin_blur::OrgKdeKwinBlur;
|
||||
use wayland_protocols_plasma::blur::client::org_kde_kwin_blur_manager::OrgKdeKwinBlurManager;
|
||||
|
||||
use crate::platform_impl::wayland::state::WinitState;
|
||||
use crate::state::WinitState;
|
||||
|
||||
/// KWin blur manager.
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
@ -9,7 +9,7 @@ use sctk::reexports::protocols::wp::fractional_scale::v1::client::wp_fractional_
|
|||
Event as FractionalScalingEvent, WpFractionalScaleV1,
|
||||
};
|
||||
|
||||
use crate::platform_impl::wayland::state::WinitState;
|
||||
use crate::state::WinitState;
|
||||
|
||||
/// The scaling factor denominator.
|
||||
const SCALE_DENOMINATOR: f64 = 120.;
|
||||
|
|
@ -7,7 +7,7 @@ use sctk::reexports::client::{delegate_dispatch, Connection, Dispatch, Proxy, Qu
|
|||
use sctk::reexports::protocols::wp::viewporter::client::wp_viewport::WpViewport;
|
||||
use sctk::reexports::protocols::wp::viewporter::client::wp_viewporter::WpViewporter;
|
||||
|
||||
use crate::platform_impl::wayland::state::WinitState;
|
||||
use crate::state::WinitState;
|
||||
|
||||
/// Viewporter.
|
||||
#[derive(Debug)]
|
||||
|
|
@ -14,7 +14,7 @@ use sctk::reexports::protocols::xdg::activation::v1::client::xdg_activation_v1::
|
|||
use winit_core::event_loop::AsyncRequestSerial;
|
||||
use winit_core::window::{ActivationToken, WindowId};
|
||||
|
||||
use crate::platform_impl::wayland::state::WinitState;
|
||||
use crate::state::WinitState;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct XdgActivationState {
|
||||
|
|
@ -29,8 +29,7 @@ use super::output::MonitorHandle;
|
|||
use super::state::WinitState;
|
||||
use super::types::xdg_activation::XdgActivationTokenData;
|
||||
use super::ActiveEventLoop;
|
||||
use crate::platform::wayland::WindowAttributesWayland;
|
||||
use crate::platform_impl::wayland::output;
|
||||
use crate::{output, WindowAttributesWayland};
|
||||
|
||||
pub(crate) mod state;
|
||||
|
||||
|
|
@ -153,7 +152,6 @@ impl Window {
|
|||
Some(Fullscreen::Exclusive(..)) => {
|
||||
warn!("`Fullscreen::Exclusive` is ignored on Wayland");
|
||||
},
|
||||
#[cfg_attr(not(x11_platform), allow(clippy::bind_instead_of_map))]
|
||||
Some(Fullscreen::Borderless(monitor)) => {
|
||||
let output = monitor.as_ref().and_then(|monitor| {
|
||||
monitor.cast_ref::<output::MonitorHandle>().map(|handle| &handle.proxy)
|
||||
|
|
@ -452,7 +450,6 @@ impl CoreWindow for Window {
|
|||
Some(Fullscreen::Exclusive(..)) => {
|
||||
warn!("`Fullscreen::Exclusive` is ignored on Wayland");
|
||||
},
|
||||
#[cfg_attr(not(x11_platform), allow(clippy::bind_instead_of_map))]
|
||||
Some(Fullscreen::Borderless(monitor)) => {
|
||||
let output = monitor.as_ref().and_then(|monitor| {
|
||||
monitor.cast_ref::<output::MonitorHandle>().map(|handle| &handle.proxy)
|
||||
|
|
@ -32,16 +32,14 @@ use winit_core::cursor::{CursorIcon, CustomCursor as CoreCustomCursor};
|
|||
use winit_core::error::{NotSupportedError, RequestError};
|
||||
use winit_core::window::{CursorGrabMode, ImePurpose, ResizeDirection, Theme, WindowId};
|
||||
|
||||
use crate::platform_impl::wayland::event_loop::OwnedDisplayHandle;
|
||||
use crate::platform_impl::wayland::logical_to_physical_rounded;
|
||||
use crate::platform_impl::wayland::seat::{
|
||||
use crate::event_loop::OwnedDisplayHandle;
|
||||
use crate::logical_to_physical_rounded;
|
||||
use crate::seat::{
|
||||
PointerConstraintsState, WinitPointerData, WinitPointerDataExt, ZwpTextInputV3Ext,
|
||||
};
|
||||
use crate::platform_impl::wayland::state::{WindowCompositorUpdate, WinitState};
|
||||
use crate::platform_impl::wayland::types::cursor::{
|
||||
CustomCursor, SelectedCursor, WaylandCustomCursor,
|
||||
};
|
||||
use crate::platform_impl::wayland::types::kwin_blur::KWinBlurManager;
|
||||
use crate::state::{WindowCompositorUpdate, WinitState};
|
||||
use crate::types::cursor::{CustomCursor, SelectedCursor, WaylandCustomCursor};
|
||||
use crate::types::kwin_blur::KWinBlurManager;
|
||||
|
||||
#[cfg(feature = "sctk-adwaita")]
|
||||
pub type WinitFrame = sctk_adwaita::AdwaitaFrame<WinitState>;
|
||||
Loading…
Add table
Add a link
Reference in a new issue