cargo fmt
This commit is contained in:
parent
1d1819c9b1
commit
df4b94edf2
5 changed files with 140 additions and 81 deletions
|
|
@ -1406,7 +1406,7 @@ async fn run_instance<P>(
|
||||||
}
|
}
|
||||||
Event::Exit => break,
|
Event::Exit => break,
|
||||||
Event::Dnd(e) => {
|
Event::Dnd(e) => {
|
||||||
use raw_window_handle::HasWindowHandle;
|
use winit::raw_window_handle::HasWindowHandle;
|
||||||
match &e {
|
match &e {
|
||||||
dnd::DndEvent::Offer(_, dnd::OfferEvent::Leave) => {
|
dnd::DndEvent::Offer(_, dnd::OfferEvent::Leave) => {
|
||||||
events.push((cur_dnd_surface, core::Event::Dnd(e)));
|
events.push((cur_dnd_surface, core::Event::Dnd(e)));
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,7 @@ use sctk::{
|
||||||
seat::{
|
seat::{
|
||||||
keyboard::Modifiers,
|
keyboard::Modifiers,
|
||||||
pointer::{
|
pointer::{
|
||||||
AxisScroll, BTN_EXTRA, BTN_LEFT, BTN_MIDDLE, BTN_RIGHT,
|
AxisScroll, BTN_EXTRA, BTN_LEFT, BTN_MIDDLE, BTN_RIGHT, BTN_SIDE,
|
||||||
BTN_SIDE,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,36 +1,41 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
handlers::activation::IcedRequestData, platform_specific::{
|
Control,
|
||||||
|
handlers::activation::IcedRequestData,
|
||||||
|
platform_specific::{
|
||||||
|
Event,
|
||||||
wayland::{
|
wayland::{
|
||||||
handlers::{
|
handlers::{
|
||||||
wp_fractional_scaling::FractionalScalingManager,
|
wp_fractional_scaling::FractionalScalingManager,
|
||||||
wp_viewporter::ViewporterState,
|
wp_viewporter::ViewporterState,
|
||||||
},
|
},
|
||||||
sctk_event::{
|
sctk_event::{LayerSurfaceEventVariant, SctkEvent},
|
||||||
LayerSurfaceEventVariant, SctkEvent,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
Event,
|
},
|
||||||
}, Control
|
|
||||||
};
|
};
|
||||||
use iced_futures::futures::channel::{mpsc, oneshot};
|
use iced_futures::futures::channel::{mpsc, oneshot};
|
||||||
use raw_window_handle::HasWindowHandle;
|
use raw_window_handle::HasWindowHandle;
|
||||||
use std::{
|
use std::{
|
||||||
collections::{HashMap, HashSet},
|
collections::{HashMap, HashSet},
|
||||||
convert::Infallible,
|
convert::Infallible,
|
||||||
fmt::Debug, sync::{atomic::AtomicU32, Arc, Mutex}, time::Duration,
|
fmt::Debug,
|
||||||
|
sync::{Arc, Mutex, atomic::AtomicU32},
|
||||||
|
time::Duration,
|
||||||
};
|
};
|
||||||
use wayland_backend::client::ObjectId;
|
use wayland_backend::client::ObjectId;
|
||||||
use winit::{dpi::{LogicalPosition, LogicalSize}, platform::wayland::WindowExtWayland};
|
use winit::{
|
||||||
|
dpi::{LogicalPosition, LogicalSize},
|
||||||
|
platform::wayland::WindowExtWayland,
|
||||||
|
};
|
||||||
|
|
||||||
use iced_runtime::{
|
use iced_runtime::{
|
||||||
core::{self, touch, Point},
|
core::{self, Point, touch},
|
||||||
keyboard::Modifiers,
|
keyboard::Modifiers,
|
||||||
platform_specific::{
|
platform_specific::{
|
||||||
self,
|
self,
|
||||||
wayland::{
|
wayland::{
|
||||||
|
Action,
|
||||||
layer_surface::{IcedMargin, IcedOutput, SctkLayerSurfaceSettings},
|
layer_surface::{IcedMargin, IcedOutput, SctkLayerSurfaceSettings},
|
||||||
popup::SctkPopupSettings,
|
popup::SctkPopupSettings,
|
||||||
Action,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
@ -40,9 +45,9 @@ use sctk::{
|
||||||
error::GlobalError,
|
error::GlobalError,
|
||||||
output::OutputState,
|
output::OutputState,
|
||||||
reexports::{
|
reexports::{
|
||||||
calloop::{timer::TimeoutAction, LoopHandle},
|
calloop::{LoopHandle, timer::TimeoutAction},
|
||||||
client::{
|
client::{
|
||||||
delegate_noop,
|
Connection, Proxy, QueueHandle, delegate_noop,
|
||||||
protocol::{
|
protocol::{
|
||||||
wl_keyboard::WlKeyboard,
|
wl_keyboard::WlKeyboard,
|
||||||
wl_output::WlOutput,
|
wl_output::WlOutput,
|
||||||
|
|
@ -52,34 +57,39 @@ use sctk::{
|
||||||
wl_surface::{self, WlSurface},
|
wl_surface::{self, WlSurface},
|
||||||
wl_touch::WlTouch,
|
wl_touch::WlTouch,
|
||||||
},
|
},
|
||||||
Connection, Proxy, QueueHandle,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
registry::RegistryState,
|
registry::RegistryState,
|
||||||
seat::{
|
seat::{
|
||||||
keyboard::KeyEvent, pointer::{CursorIcon, PointerData, ThemedPointer}, touch::TouchData, SeatState
|
SeatState,
|
||||||
|
keyboard::KeyEvent,
|
||||||
|
pointer::{CursorIcon, PointerData, ThemedPointer},
|
||||||
|
touch::TouchData,
|
||||||
},
|
},
|
||||||
session_lock::{
|
session_lock::{
|
||||||
SessionLock, SessionLockState, SessionLockSurface,
|
SessionLock, SessionLockState, SessionLockSurface,
|
||||||
SessionLockSurfaceConfigure,
|
SessionLockSurfaceConfigure,
|
||||||
},
|
},
|
||||||
shell::{
|
shell::{
|
||||||
|
WaylandSurface,
|
||||||
wlr_layer::{
|
wlr_layer::{
|
||||||
Anchor, KeyboardInteractivity, Layer, LayerShell, LayerSurface,
|
Anchor, KeyboardInteractivity, Layer, LayerShell, LayerSurface,
|
||||||
LayerSurfaceConfigure,
|
LayerSurfaceConfigure,
|
||||||
},
|
},
|
||||||
xdg::{
|
xdg::{
|
||||||
popup::{Popup, PopupConfigure},
|
|
||||||
XdgPositioner, XdgShell,
|
XdgPositioner, XdgShell,
|
||||||
|
popup::{Popup, PopupConfigure},
|
||||||
},
|
},
|
||||||
WaylandSurface,
|
|
||||||
},
|
},
|
||||||
shm::{multi::MultiPool, Shm},
|
shm::{Shm, multi::MultiPool},
|
||||||
|
};
|
||||||
|
use wayland_protocols::{
|
||||||
|
wp::{
|
||||||
|
fractional_scale::v1::client::wp_fractional_scale_v1::WpFractionalScaleV1,
|
||||||
|
viewporter::client::wp_viewport::WpViewport,
|
||||||
|
},
|
||||||
|
xdg::shell::client::xdg_surface::XdgSurface,
|
||||||
};
|
};
|
||||||
use wayland_protocols::{wp::{
|
|
||||||
fractional_scale::v1::client::wp_fractional_scale_v1::WpFractionalScaleV1,
|
|
||||||
viewporter::client::wp_viewport::WpViewport,
|
|
||||||
}, xdg::shell::client::xdg_surface::XdgSurface};
|
|
||||||
|
|
||||||
pub static TOKEN_CTR: AtomicU32 = AtomicU32::new(0);
|
pub static TOKEN_CTR: AtomicU32 = AtomicU32::new(0);
|
||||||
|
|
||||||
|
|
@ -167,16 +177,17 @@ impl PopupParent {
|
||||||
pub enum CommonSurface {
|
pub enum CommonSurface {
|
||||||
Popup(Popup, Arc<XdgPositioner>),
|
Popup(Popup, Arc<XdgPositioner>),
|
||||||
Layer(LayerSurface),
|
Layer(LayerSurface),
|
||||||
Lock(SessionLockSurface)
|
Lock(SessionLockSurface),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CommonSurface {
|
impl CommonSurface {
|
||||||
pub fn wl_surface(&self) -> &WlSurface {
|
pub fn wl_surface(&self) -> &WlSurface {
|
||||||
let wl_surface =
|
let wl_surface = match self {
|
||||||
match self {
|
|
||||||
CommonSurface::Popup(popup, _) => popup.wl_surface(),
|
CommonSurface::Popup(popup, _) => popup.wl_surface(),
|
||||||
CommonSurface::Layer(layer_surface) => layer_surface.wl_surface(),
|
CommonSurface::Layer(layer_surface) => layer_surface.wl_surface(),
|
||||||
CommonSurface::Lock(session_lock_surface) => session_lock_surface.wl_surface(),
|
CommonSurface::Lock(session_lock_surface) => {
|
||||||
|
session_lock_surface.wl_surface()
|
||||||
|
}
|
||||||
};
|
};
|
||||||
wl_surface
|
wl_surface
|
||||||
}
|
}
|
||||||
|
|
@ -195,7 +206,15 @@ pub struct Common {
|
||||||
|
|
||||||
impl Default for Common {
|
impl Default for Common {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self { fractional_scale: Default::default(), has_focus: Default::default(), ime_pos: Default::default(), ime_size: Default::default(), size: LogicalSize::new(1, 1), requested_size: (None, None), wp_viewport: None}
|
Self {
|
||||||
|
fractional_scale: Default::default(),
|
||||||
|
has_focus: Default::default(),
|
||||||
|
ime_pos: Default::default(),
|
||||||
|
ime_size: Default::default(),
|
||||||
|
size: LogicalSize::new(1, 1),
|
||||||
|
requested_size: (None, None),
|
||||||
|
wp_viewport: None,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -208,8 +227,6 @@ impl From<LogicalSize<u32>> for Common {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct SctkPopup {
|
pub struct SctkPopup {
|
||||||
pub(crate) popup: Popup,
|
pub(crate) popup: Popup,
|
||||||
|
|
@ -253,31 +270,39 @@ pub struct SctkPopupData {
|
||||||
|
|
||||||
pub struct SctkWindow {
|
pub struct SctkWindow {
|
||||||
pub(crate) window: Arc<dyn winit::window::Window>,
|
pub(crate) window: Arc<dyn winit::window::Window>,
|
||||||
pub(crate) id: core::window::Id
|
pub(crate) id: core::window::Id,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SctkWindow {
|
impl SctkWindow {
|
||||||
pub fn wl_surface(&self, conn: &Connection) -> WlSurface {
|
pub fn wl_surface(&self, conn: &Connection) -> WlSurface {
|
||||||
let window_handle = self.window.window_handle().unwrap();
|
let window_handle = self.window.window_handle().unwrap();
|
||||||
let ptr = {
|
let ptr = {
|
||||||
let raw_window_handle::RawWindowHandle::Wayland(h) = window_handle.as_raw() else {
|
let raw_window_handle::RawWindowHandle::Wayland(h) =
|
||||||
|
window_handle.as_raw()
|
||||||
|
else {
|
||||||
panic!("Invalid window handle");
|
panic!("Invalid window handle");
|
||||||
};
|
};
|
||||||
h.surface
|
h.surface
|
||||||
|
|
||||||
};
|
};
|
||||||
let id = unsafe { ObjectId::from_ptr(WlSurface::interface(), ptr.as_ptr().cast()) }.unwrap();
|
let id = unsafe {
|
||||||
|
ObjectId::from_ptr(WlSurface::interface(), ptr.as_ptr().cast())
|
||||||
|
}
|
||||||
|
.unwrap();
|
||||||
WlSurface::from_id(conn, id).unwrap()
|
WlSurface::from_id(conn, id).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn xdg_surface(&self, conn: &Connection) -> XdgSurface {
|
pub fn xdg_surface(&self, conn: &Connection) -> XdgSurface {
|
||||||
let window_handle = self.window.xdg_surface_handle().unwrap();
|
let window_handle = self.window.xdg_surface_handle().unwrap();
|
||||||
let ptr = {
|
let ptr = {
|
||||||
let h = window_handle.xdg_surface_handle().expect("Invalid window handle");
|
let h = window_handle
|
||||||
|
.xdg_surface_handle()
|
||||||
|
.expect("Invalid window handle");
|
||||||
h.as_raw()
|
h.as_raw()
|
||||||
|
|
||||||
};
|
};
|
||||||
let id = unsafe { ObjectId::from_ptr(XdgSurface::interface(), ptr.as_ptr().cast()) }.unwrap();
|
let id = unsafe {
|
||||||
|
ObjectId::from_ptr(XdgSurface::interface(), ptr.as_ptr().cast())
|
||||||
|
}
|
||||||
|
.unwrap();
|
||||||
XdgSurface::from_id(conn, id).unwrap()
|
XdgSurface::from_id(conn, id).unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -288,7 +313,7 @@ pub(crate) enum FrameStatus {
|
||||||
/// Requested redraw, but frame wasn't received
|
/// Requested redraw, but frame wasn't received
|
||||||
RequestedRedraw,
|
RequestedRedraw,
|
||||||
/// Ready for requested redraw
|
/// Ready for requested redraw
|
||||||
Ready
|
Ready,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Wrapper to carry sctk state.
|
/// Wrapper to carry sctk state.
|
||||||
|
|
@ -395,7 +420,10 @@ pub enum LayerSurfaceCreationError {
|
||||||
LayerSurfaceCreationFailed(GlobalError),
|
LayerSurfaceCreationFailed(GlobalError),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn receive_frame(frame_status: &mut HashMap<ObjectId, FrameStatus>, s: &WlSurface) {
|
pub(crate) fn receive_frame(
|
||||||
|
frame_status: &mut HashMap<ObjectId, FrameStatus>,
|
||||||
|
s: &WlSurface,
|
||||||
|
) {
|
||||||
let e = frame_status.entry(s.id()).or_insert(FrameStatus::Received);
|
let e = frame_status.entry(s.id()).or_insert(FrameStatus::Received);
|
||||||
if matches!(e, FrameStatus::RequestedRedraw) {
|
if matches!(e, FrameStatus::RequestedRedraw) {
|
||||||
*e = FrameStatus::Ready;
|
*e = FrameStatus::Ready;
|
||||||
|
|
@ -404,7 +432,10 @@ pub(crate) fn receive_frame(frame_status: &mut HashMap<ObjectId, FrameStatus>, s
|
||||||
|
|
||||||
impl SctkState {
|
impl SctkState {
|
||||||
pub fn request_redraw(&mut self, surface: &WlSurface) {
|
pub fn request_redraw(&mut self, surface: &WlSurface) {
|
||||||
let e = self.frame_status.entry(surface.id()).or_insert(FrameStatus::RequestedRedraw);
|
let e = self
|
||||||
|
.frame_status
|
||||||
|
.entry(surface.id())
|
||||||
|
.or_insert(FrameStatus::RequestedRedraw);
|
||||||
if matches!(e, FrameStatus::Received) {
|
if matches!(e, FrameStatus::Received) {
|
||||||
*e = FrameStatus::Ready;
|
*e = FrameStatus::Ready;
|
||||||
}
|
}
|
||||||
|
|
@ -446,10 +477,11 @@ impl SctkState {
|
||||||
let mut common = layer_surface.common.lock().unwrap();
|
let mut common = layer_surface.common.lock().unwrap();
|
||||||
common.fractional_scale = Some(scale_factor);
|
common.fractional_scale = Some(scale_factor);
|
||||||
if legacy {
|
if legacy {
|
||||||
let _ =
|
let _ = layer_surface
|
||||||
layer_surface.surface.wl_surface().set_buffer_scale(scale_factor as i32);
|
.surface
|
||||||
|
.wl_surface()
|
||||||
|
.set_buffer_scale(scale_factor as i32);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(lock_surface) = self
|
if let Some(lock_surface) = self
|
||||||
|
|
@ -464,13 +496,19 @@ impl SctkState {
|
||||||
let mut common = lock_surface.common.lock().unwrap();
|
let mut common = lock_surface.common.lock().unwrap();
|
||||||
common.fractional_scale = Some(scale_factor);
|
common.fractional_scale = Some(scale_factor);
|
||||||
if legacy {
|
if legacy {
|
||||||
let _ =
|
let _ = lock_surface
|
||||||
lock_surface.session_lock_surface.wl_surface().set_buffer_scale(scale_factor as i32);
|
.session_lock_surface
|
||||||
|
.wl_surface()
|
||||||
|
.set_buffer_scale(scale_factor as i32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(id) = id {
|
if let Some(id) = id {
|
||||||
self.sctk_events.push(SctkEvent::SurfaceScaleFactorChanged(scale_factor, surface.clone(), id));
|
self.sctk_events.push(SctkEvent::SurfaceScaleFactorChanged(
|
||||||
|
scale_factor,
|
||||||
|
surface.clone(),
|
||||||
|
id,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO winit sets cursor size after handling the change for the window, so maybe that should be done as well.
|
// TODO winit sets cursor size after handling the change for the window, so maybe that should be done as well.
|
||||||
|
|
@ -482,7 +520,13 @@ impl SctkState {
|
||||||
&mut self,
|
&mut self,
|
||||||
settings: SctkPopupSettings,
|
settings: SctkPopupSettings,
|
||||||
) -> Result<
|
) -> Result<
|
||||||
(core::window::Id, WlSurface, WlSurface, CommonSurface, Arc<Mutex<Common>>),
|
(
|
||||||
|
core::window::Id,
|
||||||
|
WlSurface,
|
||||||
|
WlSurface,
|
||||||
|
CommonSurface,
|
||||||
|
Arc<Mutex<Common>>,
|
||||||
|
),
|
||||||
PopupCreationError,
|
PopupCreationError,
|
||||||
> {
|
> {
|
||||||
let (parent, toplevel) = if let Some(parent) =
|
let (parent, toplevel) = if let Some(parent) =
|
||||||
|
|
@ -613,20 +657,32 @@ impl SctkState {
|
||||||
};
|
};
|
||||||
if grab {
|
if grab {
|
||||||
if let Some(s) = self.seats.first() {
|
if let Some(s) = self.seats.first() {
|
||||||
let ptr_data = s.ptr.as_ref().and_then(|p| p.pointer().data::<PointerData>()).and_then(|data| data.latest_button_serial());
|
let ptr_data = s
|
||||||
if let Some(serial) = ptr_data.or_else(|| s.touch.as_ref().and_then(|t| t.data::<TouchData>()).and_then(|t| t.latest_down_serial())).or_else(|| s.last_kbd_press
|
.ptr
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|p| p.1)) {
|
.and_then(|p| p.pointer().data::<PointerData>())
|
||||||
popup.xdg_popup().grab(
|
.and_then(|data| data.latest_button_serial());
|
||||||
&s.seat,
|
if let Some(serial) = ptr_data
|
||||||
serial
|
.or_else(|| {
|
||||||
);
|
s.touch
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|t| t.data::<TouchData>())
|
||||||
|
.and_then(|t| t.latest_down_serial())
|
||||||
|
})
|
||||||
|
.or_else(|| s.last_kbd_press.as_ref().map(|p| p.1))
|
||||||
|
{
|
||||||
|
popup.xdg_popup().grab(&s.seat, serial);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log::error!("Can't take grab on popup. Missing serial.");
|
log::error!("Can't take grab on popup. Missing serial.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
popup.xdg_surface().set_window_geometry(0, 0, size.0 as i32, size.1 as i32);
|
popup.xdg_surface().set_window_geometry(
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
size.0 as i32,
|
||||||
|
size.1 as i32,
|
||||||
|
);
|
||||||
_ = wl_surface.frame(&self.queue_handle, wl_surface.clone());
|
_ = wl_surface.frame(&self.queue_handle, wl_surface.clone());
|
||||||
wl_surface.commit();
|
wl_surface.commit();
|
||||||
|
|
||||||
|
|
@ -656,7 +712,7 @@ impl SctkState {
|
||||||
last_configure: None,
|
last_configure: None,
|
||||||
_pending_requests: Default::default(),
|
_pending_requests: Default::default(),
|
||||||
wp_fractional_scale,
|
wp_fractional_scale,
|
||||||
common: common.clone()
|
common: common.clone(),
|
||||||
});
|
});
|
||||||
|
|
||||||
Ok((
|
Ok((
|
||||||
|
|
@ -664,7 +720,7 @@ impl SctkState {
|
||||||
parent.wl_surface().clone(),
|
parent.wl_surface().clone(),
|
||||||
toplevel.clone(),
|
toplevel.clone(),
|
||||||
CommonSurface::Popup(popup.clone(), positioner.clone()),
|
CommonSurface::Popup(popup.clone(), positioner.clone()),
|
||||||
common
|
common,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -683,7 +739,10 @@ impl SctkState {
|
||||||
exclusive_zone,
|
exclusive_zone,
|
||||||
..
|
..
|
||||||
}: SctkLayerSurfaceSettings,
|
}: SctkLayerSurfaceSettings,
|
||||||
) -> Result<(core::window::Id, CommonSurface, Arc<Mutex<Common>>), LayerSurfaceCreationError> {
|
) -> Result<
|
||||||
|
(core::window::Id, CommonSurface, Arc<Mutex<Common>>),
|
||||||
|
LayerSurfaceCreationError,
|
||||||
|
> {
|
||||||
let wl_output = match output {
|
let wl_output = match output {
|
||||||
IcedOutput::All => None, // TODO
|
IcedOutput::All => None, // TODO
|
||||||
IcedOutput::Active => None,
|
IcedOutput::Active => None,
|
||||||
|
|
@ -746,7 +805,10 @@ impl SctkState {
|
||||||
&self.queue_handle,
|
&self.queue_handle,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
let mut common = Common::from(LogicalSize::new(size.0.unwrap_or(1), size.1.unwrap_or(1)));
|
let mut common = Common::from(LogicalSize::new(
|
||||||
|
size.0.unwrap_or(1),
|
||||||
|
size.1.unwrap_or(1),
|
||||||
|
));
|
||||||
common.requested_size = size;
|
common.requested_size = size;
|
||||||
common.wp_viewport = wp_viewport;
|
common.wp_viewport = wp_viewport;
|
||||||
let common = Arc::new(Mutex::new(common));
|
let common = Arc::new(Mutex::new(common));
|
||||||
|
|
@ -763,7 +825,7 @@ impl SctkState {
|
||||||
last_configure: None,
|
last_configure: None,
|
||||||
_pending_requests: Vec::new(),
|
_pending_requests: Vec::new(),
|
||||||
wp_fractional_scale,
|
wp_fractional_scale,
|
||||||
common: common.clone()
|
common: common.clone(),
|
||||||
});
|
});
|
||||||
Ok((id, CommonSurface::Layer(layer_surface), common))
|
Ok((id, CommonSurface::Layer(layer_surface), common))
|
||||||
}
|
}
|
||||||
|
|
@ -787,19 +849,18 @@ impl SctkState {
|
||||||
viewport
|
viewport
|
||||||
});
|
});
|
||||||
let wp_fractional_scale =
|
let wp_fractional_scale =
|
||||||
self.fractional_scaling_manager.as_ref().map(|fsm| {
|
self.fractional_scaling_manager.as_ref().map(|fsm| {
|
||||||
fsm.fractional_scaling(&wl_surface, &self.queue_handle)
|
fsm.fractional_scaling(&wl_surface, &self.queue_handle)
|
||||||
});
|
});
|
||||||
let common = Arc::new(Mutex::new(Common::from(
|
let common =
|
||||||
LogicalSize::new(1, 1)
|
Arc::new(Mutex::new(Common::from(LogicalSize::new(1, 1))));
|
||||||
)));
|
|
||||||
self.lock_surfaces.push(SctkLockSurface {
|
self.lock_surfaces.push(SctkLockSurface {
|
||||||
id,
|
id,
|
||||||
session_lock_surface: session_lock_surface.clone(),
|
session_lock_surface: session_lock_surface.clone(),
|
||||||
last_configure: None,
|
last_configure: None,
|
||||||
wp_fractional_scale,
|
wp_fractional_scale,
|
||||||
wp_viewport,
|
wp_viewport,
|
||||||
common: common.clone()
|
common: common.clone(),
|
||||||
});
|
});
|
||||||
Some((CommonSurface::Lock(session_lock_surface), common))
|
Some((CommonSurface::Lock(session_lock_surface), common))
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -842,7 +903,6 @@ impl SctkState {
|
||||||
prev_configure.new_size = (width.unwrap_or(prev_configure.new_size.0), width.unwrap_or(prev_configure.new_size.1));
|
prev_configure.new_size = (width.unwrap_or(prev_configure.new_size.0), width.unwrap_or(prev_configure.new_size.1));
|
||||||
_ = send_event(&self.events_sender, &self.proxy,
|
_ = send_event(&self.events_sender, &self.proxy,
|
||||||
SctkEvent::LayerSurfaceEvent { variant: LayerSurfaceEventVariant::Configure(prev_configure, wl_surface.clone(), false), id: wl_surface.clone()});
|
SctkEvent::LayerSurfaceEvent { variant: LayerSurfaceEventVariant::Configure(prev_configure, wl_surface.clone(), false), id: wl_surface.clone()});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -857,7 +917,6 @@ impl SctkState {
|
||||||
id: l.surface.wl_surface().clone(),
|
id: l.surface.wl_surface().clone(),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
platform_specific::wayland::layer_surface::Action::Anchor { id, anchor } => {
|
platform_specific::wayland::layer_surface::Action::Anchor { id, anchor } => {
|
||||||
|
|
@ -939,7 +998,7 @@ impl SctkState {
|
||||||
TimeoutAction::Drop
|
TimeoutAction::Drop
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
match state.get_popup(popup) {
|
match state.get_popup(popup) {
|
||||||
Ok((id, parent_id, toplevel_id, surface, common)) => {
|
Ok((id, parent_id, toplevel_id, surface, common)) => {
|
||||||
let wl_surface = surface.wl_surface().clone();
|
let wl_surface = surface.wl_surface().clone();
|
||||||
receive_frame(&mut state.frame_status, &wl_surface);
|
receive_frame(&mut state.frame_status, &wl_surface);
|
||||||
|
|
@ -947,7 +1006,7 @@ impl SctkState {
|
||||||
SctkEvent::PopupEvent {
|
SctkEvent::PopupEvent {
|
||||||
variant: crate::platform_specific::wayland::sctk_event::PopupEventVariant::Created(queue_handle.clone(), surface, id, common, state.connection.display()),
|
variant: crate::platform_specific::wayland::sctk_event::PopupEventVariant::Created(queue_handle.clone(), surface, id, common, state.connection.display()),
|
||||||
toplevel_id, parent_id, id: wl_surface });
|
toplevel_id, parent_id, id: wl_surface });
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
log::error!("Failed to create popup. {err:?}");
|
log::error!("Failed to create popup. {err:?}");
|
||||||
}
|
}
|
||||||
|
|
@ -959,16 +1018,15 @@ impl SctkState {
|
||||||
// log::error!("Invalid popup Id {:?}", popup.id);
|
// log::error!("Invalid popup Id {:?}", popup.id);
|
||||||
} else {
|
} else {
|
||||||
self.pending_popup = None;
|
self.pending_popup = None;
|
||||||
match self.get_popup(popup) {
|
match self.get_popup(popup) {
|
||||||
Ok((id, parent_id, toplevel_id, surface, common)) => {
|
Ok((id, parent_id, toplevel_id, surface, common)) => {
|
||||||
let wl_surface = surface.wl_surface().clone();
|
let wl_surface = surface.wl_surface().clone();
|
||||||
|
|
||||||
receive_frame(&mut self.frame_status, &wl_surface);
|
receive_frame(&mut self.frame_status, &wl_surface);
|
||||||
send_event(&self.events_sender, &self.proxy,
|
send_event(&self.events_sender, &self.proxy,
|
||||||
SctkEvent::PopupEvent {
|
SctkEvent::PopupEvent {
|
||||||
variant: crate::platform_specific::wayland::sctk_event::PopupEventVariant::Created(self.queue_handle.clone(), surface, id, common, self.connection.display()),
|
variant: crate::platform_specific::wayland::sctk_event::PopupEventVariant::Created(self.queue_handle.clone(), surface, id, common, self.connection.display()),
|
||||||
toplevel_id, parent_id, id: wl_surface });
|
toplevel_id, parent_id, id: wl_surface });
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
log::error!("Failed to create popup. {err:?}");
|
log::error!("Failed to create popup. {err:?}");
|
||||||
}
|
}
|
||||||
|
|
@ -1068,7 +1126,6 @@ impl SctkState {
|
||||||
} else {
|
} else {
|
||||||
// if we don't have the global, we don't want to stall the app
|
// if we don't have the global, we don't want to stall the app
|
||||||
_ = channel.send(None);
|
_ = channel.send(None);
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
platform_specific::wayland::activation::Action::Activate { window, token } => {
|
platform_specific::wayland::activation::Action::Activate { window, token } => {
|
||||||
|
|
@ -1124,8 +1181,13 @@ impl SctkState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn send_event(sender: &mpsc::UnboundedSender<Control>, proxy: &winit::event_loop::EventLoopProxy, sctk_event: SctkEvent) {
|
pub(crate) fn send_event(
|
||||||
_ = sender.unbounded_send(Control::PlatformSpecific(Event::Wayland(sctk_event)));
|
sender: &mpsc::UnboundedSender<Control>,
|
||||||
|
proxy: &winit::event_loop::EventLoopProxy,
|
||||||
|
sctk_event: SctkEvent,
|
||||||
|
) {
|
||||||
|
_ = sender
|
||||||
|
.unbounded_send(Control::PlatformSpecific(Event::Wayland(sctk_event)));
|
||||||
proxy.wake_up();
|
proxy.wake_up();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
// From: https://github.com/rust-windowing/winit/blob/master/src/platform_impl/linux/wayland/types/wp_fractional_scaling.rs
|
// From: https://github.com/rust-windowing/winit/blob/master/src/platform_impl/linux/wayland/types/wp_fractional_scaling.rs
|
||||||
//! Handling of the fractional scaling.
|
//! Handling of the fractional scaling.
|
||||||
|
|
||||||
|
|
||||||
use sctk::reexports::client::globals::{BindError, GlobalList};
|
use sctk::reexports::client::globals::{BindError, GlobalList};
|
||||||
use sctk::reexports::client::protocol::wl_surface::WlSurface;
|
use sctk::reexports::client::protocol::wl_surface::WlSurface;
|
||||||
use sctk::reexports::client::Dispatch;
|
use sctk::reexports::client::Dispatch;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
//! Handling of the wp-viewporter.
|
//! Handling of the wp-viewporter.
|
||||||
|
|
||||||
|
|
||||||
use sctk::reexports::client::globals::{BindError, GlobalList};
|
use sctk::reexports::client::globals::{BindError, GlobalList};
|
||||||
use sctk::reexports::client::protocol::wl_surface::WlSurface;
|
use sctk::reexports::client::protocol::wl_surface::WlSurface;
|
||||||
use sctk::reexports::client::Dispatch;
|
use sctk::reexports::client::Dispatch;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue