feat(wayland): serial counter
This commit is contained in:
@@ -12,6 +12,7 @@ mod xdg_shell;
|
||||
use self::{state::WaylandState, surface::CORE_SURFACES};
|
||||
use crate::wayland::state::ClientState;
|
||||
use color_eyre::eyre::{ensure, Result};
|
||||
use global_counter::primitive::exact::CounterU32;
|
||||
use once_cell::sync::OnceCell;
|
||||
use parking_lot::Mutex;
|
||||
use slog::Drain;
|
||||
@@ -32,6 +33,8 @@ use tokio::{
|
||||
};
|
||||
use tracing::info;
|
||||
|
||||
pub static SERIAL_COUNTER: CounterU32 = CounterU32::new(0);
|
||||
|
||||
struct EGLRawHandles {
|
||||
display: *const c_void,
|
||||
config: *const c_void,
|
||||
|
||||
@@ -2,6 +2,7 @@ use super::{
|
||||
seat::{Cursor, KeyboardInfo, SeatData},
|
||||
surface::CoreSurface,
|
||||
xdg_shell::{XdgSurfaceData, XdgToplevelData},
|
||||
SERIAL_COUNTER,
|
||||
};
|
||||
use crate::{
|
||||
core::{
|
||||
@@ -26,7 +27,6 @@ use smithay::{
|
||||
wayland_protocols::xdg::shell::server::xdg_toplevel::{
|
||||
XdgToplevel, EVT_CONFIGURE_BOUNDS_SINCE, EVT_WM_CAPABILITIES_SINCE,
|
||||
},
|
||||
wayland_protocols_wlr::foreign_toplevel::v1::server::zwlr_foreign_toplevel_handle_v1::State,
|
||||
wayland_server::{
|
||||
backend::Credentials,
|
||||
protocol::{
|
||||
@@ -307,7 +307,7 @@ impl PanelItem {
|
||||
let Some(wl_surface) = core_surface.wl_surface() else { return Ok(()) };
|
||||
let Some(pointer) = panel_item.seat_data.pointer() else { return Ok(()) };
|
||||
|
||||
pointer.leave(0, &wl_surface);
|
||||
pointer.leave(SERIAL_COUNTER.inc(), &wl_surface);
|
||||
*panel_item.seat_data.pointer_focus.lock() = None;
|
||||
pointer.frame();
|
||||
core_surface.flush_clients();
|
||||
@@ -334,11 +334,11 @@ impl PanelItem {
|
||||
.and_then(|surf| surf.upgrade().ok())
|
||||
.filter(|surf| surf.id() != wl_surface.id())
|
||||
{
|
||||
pointer.leave(0, &old_surface);
|
||||
pointer.leave(SERIAL_COUNTER.inc(), &old_surface);
|
||||
*pointer_focus = None;
|
||||
}
|
||||
if pointer_focus.is_none() {
|
||||
pointer.enter(0, &wl_surface, position.x, position.y);
|
||||
pointer.enter(SERIAL_COUNTER.inc(), &wl_surface, position.x, position.y);
|
||||
*pointer_focus = Some(wl_surface.downgrade());
|
||||
} else {
|
||||
pointer.motion(0, position.x, position.y);
|
||||
@@ -359,7 +359,7 @@ impl PanelItem {
|
||||
|
||||
let (button, state): (u32, u32) = deserialize(data)?;
|
||||
pointer.button(
|
||||
0,
|
||||
SERIAL_COUNTER.inc(),
|
||||
0,
|
||||
button,
|
||||
match state {
|
||||
@@ -462,7 +462,7 @@ impl PanelItem {
|
||||
|
||||
let mut keyboard_info = panel_item.seat_data.keyboard_info.lock();
|
||||
if keyboard_info.is_none() {
|
||||
keyboard.enter(0, &wl_surface, vec![]);
|
||||
keyboard.enter(SERIAL_COUNTER.inc(), &wl_surface, vec![]);
|
||||
keyboard.repeat_info(0, 0);
|
||||
}
|
||||
keyboard_info.replace(KeyboardInfo::new(keymap));
|
||||
@@ -483,7 +483,7 @@ impl PanelItem {
|
||||
|
||||
let mut keyboard_info = panel_item.seat_data.keyboard_info.lock();
|
||||
if keyboard_info.is_some() {
|
||||
keyboard.leave(0, &wl_surface);
|
||||
keyboard.leave(SERIAL_COUNTER.inc(), &wl_surface);
|
||||
*keyboard_info = None;
|
||||
}
|
||||
|
||||
@@ -534,7 +534,7 @@ impl PanelItem {
|
||||
}
|
||||
let size = info.size.unwrap_or(Vector2::from([0; 2]));
|
||||
xdg_toplevel.configure(size.x as i32, size.y as i32, info.states);
|
||||
xdg_surface.configure(0);
|
||||
xdg_surface.configure(SERIAL_COUNTER.inc());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -549,7 +549,7 @@ impl PanelItem {
|
||||
let Some(xdg_surface) = panel_item.toplevel_surface_data().and_then(|d| d.xdg_surface.upgrade().ok()) else { return Ok(()) };
|
||||
|
||||
xdg_toplevel.wm_capabilities(deserialize(data)?);
|
||||
xdg_surface.configure(0);
|
||||
xdg_surface.configure(SERIAL_COUNTER.inc());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -609,7 +609,7 @@ impl PanelItem {
|
||||
|
||||
if focused_surface.id() == toplevel_surface.id() {
|
||||
let Some(pointer) = self.seat_data.pointer() else { return };
|
||||
pointer.leave(0, &toplevel_surface);
|
||||
pointer.leave(SERIAL_COUNTER.inc(), &toplevel_surface);
|
||||
pointer.frame();
|
||||
*self.seat_data.pointer_focus.lock() = None;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use super::{
|
||||
panel_item::PanelItem, state::WaylandState, surface::CoreSurface, GLOBAL_DESTROY_QUEUE,
|
||||
SERIAL_COUNTER,
|
||||
};
|
||||
use color_eyre::eyre::Result;
|
||||
use mint::Vector2;
|
||||
@@ -66,7 +67,7 @@ impl KeyboardInfo {
|
||||
0,
|
||||
);
|
||||
}
|
||||
keyboard.key(0, 0, key, wl_key_state);
|
||||
keyboard.key(SERIAL_COUNTER.inc(), 0, key, wl_key_state);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ use std::sync::Arc;
|
||||
use super::{
|
||||
panel_item::{PanelItem, RecommendedState, ToplevelState},
|
||||
state::WaylandState,
|
||||
SERIAL_COUNTER,
|
||||
};
|
||||
use mint::Vector2;
|
||||
use parking_lot::Mutex;
|
||||
@@ -243,8 +244,8 @@ impl Dispatch<XdgSurface, WaylandSurface, WaylandState> for WaylandState {
|
||||
if toplevel.version() >= EVT_WM_CAPABILITIES_SINCE {
|
||||
toplevel.wm_capabilities(vec![]);
|
||||
}
|
||||
toplevel.configure(0, 0, vec![]);
|
||||
xdg_surface.configure(0);
|
||||
toplevel.configure(0, 0, vec![1]);
|
||||
xdg_surface.configure(SERIAL_COUNTER.inc());
|
||||
|
||||
let (node, item) = PanelItem::create(
|
||||
toplevel,
|
||||
@@ -264,8 +265,8 @@ impl Dispatch<XdgSurface, WaylandSurface, WaylandState> for WaylandState {
|
||||
data_init.init(id, ());
|
||||
}
|
||||
xdg_surface::Request::SetWindowGeometry {
|
||||
x: _,
|
||||
y: _,
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
height,
|
||||
} => {
|
||||
|
||||
Reference in New Issue
Block a user