fix: feature gates
This commit is contained in:
parent
f6daee14ac
commit
b3b0ab1cd5
26 changed files with 176 additions and 101 deletions
|
|
@ -92,7 +92,7 @@ impl Clipboard {
|
|||
})
|
||||
.unwrap_or(State::Unavailable);
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg(wayland_platform)]
|
||||
if let State::Connected { clipboard, .. } = &state {
|
||||
clipboard.init_dnd(Box::new(sender));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -424,7 +424,7 @@ pub fn window_event(
|
|||
WindowEvent::ScaleFactorChanged { scale_factor, .. } => {
|
||||
Some(Event::Window(window::Event::Rescaled(scale_factor as f32)))
|
||||
}
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
WindowEvent::SuggestedBounds(bounds) => {
|
||||
let size = bounds.map(|bounds| {
|
||||
let size = bounds.to_logical(scale_factor);
|
||||
|
|
@ -437,7 +437,7 @@ pub fn window_event(
|
|||
),
|
||||
)))
|
||||
}
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
WindowEvent::WindowStateChanged => {
|
||||
use cctk::sctk::reexports::csd_frame::WindowState;
|
||||
use winit::platform::wayland::WindowExtWayland;
|
||||
|
|
@ -1491,7 +1491,7 @@ pub fn winit_key_code(
|
|||
})
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
fn winit_native_key_code(
|
||||
keycode: keyboard::key::NativeCode,
|
||||
) -> winit::keyboard::NativeKeyCode {
|
||||
|
|
@ -1515,7 +1515,7 @@ fn winit_native_key_code(
|
|||
}
|
||||
|
||||
/// Reconstruct the raw keycode
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
pub fn physical_to_scancode(physical: keyboard::key::Physical) -> Option<u32> {
|
||||
let Some(physical_key) = (match physical {
|
||||
keyboard::key::Physical::Code(code) => {
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@ mod window;
|
|||
pub use clipboard::Clipboard;
|
||||
pub use error::Error;
|
||||
pub use proxy::Proxy;
|
||||
use winit::dpi::LogicalSize;
|
||||
use winit::dpi::PhysicalPosition;
|
||||
use winit::dpi::PhysicalSize;
|
||||
|
||||
|
|
@ -92,10 +91,10 @@ where
|
|||
|
||||
let event_loop = EventLoop::new().expect("Create event loop");
|
||||
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
let is_wayland =
|
||||
winit::platform::wayland::EventLoopExtWayland::is_wayland(&event_loop);
|
||||
#[cfg(not(all(feature = "cctk", target_os = "linux")))]
|
||||
#[cfg(not(wayland_platform))]
|
||||
let is_wayland = false;
|
||||
|
||||
// TODO this is new..
|
||||
|
|
@ -260,7 +259,7 @@ where
|
|||
| winit::event::WindowEvent::Moved(_)
|
||||
);
|
||||
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
{
|
||||
if matches!(event, WindowEvent::RedrawRequested) {
|
||||
for id in
|
||||
|
|
@ -575,10 +574,7 @@ where
|
|||
.expect("Send event");
|
||||
}
|
||||
Control::Winit(id, e) => {
|
||||
#[cfg(all(
|
||||
feature = "cctk",
|
||||
target_os = "linux"
|
||||
))]
|
||||
#[cfg(wayland_platform)]
|
||||
{
|
||||
if matches!(e, WindowEvent::RedrawRequested)
|
||||
{
|
||||
|
|
@ -774,7 +770,7 @@ async fn run_instance<P>(
|
|||
|
||||
let mut platform_specific_handler =
|
||||
crate::platform_specific::PlatformSpecific::default();
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
if is_wayland {
|
||||
platform_specific_handler = platform_specific_handler.with_wayland(
|
||||
control_sender.clone(),
|
||||
|
|
@ -885,7 +881,7 @@ async fn run_instance<P>(
|
|||
on_open,
|
||||
resize_border,
|
||||
} => {
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
platform_specific_handler.send_wayland(
|
||||
platform_specific::Action::TrackWindow(window.clone(), id),
|
||||
);
|
||||
|
|
@ -1054,7 +1050,7 @@ async fn run_instance<P>(
|
|||
continue;
|
||||
}
|
||||
// XX must force update to corner radius before the surface is committed.
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
if (window.surface_version != window.state.surface_version()
|
||||
|| window.logical_size() != window.state.logical_size())
|
||||
&& !crate::subsurface_widget::is_subsurface(window_id)
|
||||
|
|
@ -1394,7 +1390,7 @@ async fn run_instance<P>(
|
|||
}
|
||||
});
|
||||
let no_window_events = window_events.is_empty();
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
window_events.push(core::Event::PlatformSpecific(
|
||||
core::event::PlatformSpecific::Wayland(
|
||||
core::event::wayland::Event::RequestResize,
|
||||
|
|
@ -2126,7 +2122,7 @@ where
|
|||
_ = control_sender.start_send(Control::Cleanup(id)).ok();
|
||||
}
|
||||
let proxy = clipboard.proxy();
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
platform_specific
|
||||
.send_wayland(platform_specific::Action::RemoveWindow(id));
|
||||
if let Some(window) = window_manager.remove(id) {
|
||||
|
|
|
|||
|
|
@ -1,24 +1,20 @@
|
|||
//! Wayland specific shell
|
||||
//!
|
||||
|
||||
use std::{borrow::Cow, collections::HashMap, sync::Arc};
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
use cctk::sctk::reexports::client::Connection;
|
||||
use iced_graphics::{Compositor, compositor};
|
||||
use iced_graphics::compositor;
|
||||
use iced_runtime::{
|
||||
core::{Vector, window},
|
||||
platform_specific, user_interface,
|
||||
user_interface,
|
||||
};
|
||||
use winit::raw_window_handle::HasWindowHandle;
|
||||
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
pub mod wayland;
|
||||
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
pub use wayland::*;
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
use wayland_backend::client::Backend;
|
||||
|
||||
use crate::{CreateCompositor, Program, WindowManager};
|
||||
|
||||
|
|
@ -35,7 +31,7 @@ pub type UserInterfaces<'a, P> = HashMap<
|
|||
|
||||
#[derive(Debug)]
|
||||
pub enum Event {
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
Wayland(sctk_event::SctkEvent),
|
||||
}
|
||||
|
||||
|
|
@ -61,7 +57,7 @@ impl SurfaceIdWrapper {
|
|||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct PlatformSpecific {
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
wayland: WaylandSpecific,
|
||||
}
|
||||
|
||||
|
|
@ -71,7 +67,7 @@ impl PlatformSpecific {
|
|||
action: iced_runtime::platform_specific::Action,
|
||||
) {
|
||||
match action {
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
iced_runtime::platform_specific::Action::Wayland(a) => {
|
||||
self.send_wayland(wayland::Action::Action(a));
|
||||
}
|
||||
|
|
@ -82,14 +78,14 @@ impl PlatformSpecific {
|
|||
&mut self,
|
||||
keep: F,
|
||||
) {
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
{
|
||||
self.wayland.retain_subsurfaces(keep);
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn clear_subsurface_list(&mut self) {
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
{
|
||||
self.wayland.clear_subsurface_list();
|
||||
}
|
||||
|
|
@ -100,7 +96,7 @@ impl PlatformSpecific {
|
|||
id: window::Id,
|
||||
window: &dyn HasWindowHandle,
|
||||
) {
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
{
|
||||
use cctk::sctk::reexports::client::{
|
||||
Proxy, protocol::wl_surface::WlSurface,
|
||||
|
|
@ -151,7 +147,7 @@ impl PlatformSpecific {
|
|||
pub(crate) fn create_surface(
|
||||
&mut self,
|
||||
) -> Option<Box<dyn HasWindowHandle + Send + Sync + 'static>> {
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
{
|
||||
return self.wayland.create_surface();
|
||||
}
|
||||
|
|
@ -167,7 +163,7 @@ impl PlatformSpecific {
|
|||
data: &[u8],
|
||||
offset: Vector,
|
||||
) {
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
{
|
||||
return self.wayland.update_surface_shm(
|
||||
surface, width, height, scale, data, offset,
|
||||
|
|
@ -195,7 +191,7 @@ pub(crate) async fn handle_event<'a, 'b, P>(
|
|||
P: Program,
|
||||
{
|
||||
match e {
|
||||
#[cfg(all(feature = "cctk", target_os = "linux"))]
|
||||
#[cfg(wayland_platform)]
|
||||
Event::Wayland(e) => {
|
||||
platform_specific
|
||||
.wayland
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue