🎉 Phase 7.4 — focus + raise on click validés runtime
Sur clic gauche, le compositor fait hit_test à la position curseur, raise la surface ciblée au top du Z-order et transfère le keyboard focus à cette surface (broadcast wl_keyboard.leave/enter via le set_focus déjà implémenté en 7.2). Frontend additions : - HashMap<SurfaceId, wl_surface::WlSurface> dans WaylandFrontend, peuplée au wl_compositor.create_surface (capture du retour de data_init.init), nettoyée au wl_surface.destroy - Au wl_surface.destroy : clear focused_surface et cursor_surface_id si la surface détruite était l'une de ces références (évite les wl_surface fantômes dans les events suivants) - forward_input(PointerButton.left=true) déclenche registry.hit_test(cursor_x, cursor_y), puis si la cible n'est pas une surface curseur : registry.raise + set_focus(target) - println! tracing pour [frontend] left-click et focus change Nouveau crate : redox-wl-test-client-shm-two - Binaire qui fork() : parent = fenêtre A (verte, pyramide), enfant = fenêtre B (magenta, double cercle) après sleep 800ms - 2 connexions Wayland indépendantes au même socket compositor - timeout 160s aligné sur le compositor 180s Validation runtime : 4 captures synchronisées via cycle de positionnement curseur temporaire (retiré après) prouvent les 2 transitions de Z-order : - initial : B au top (commit le plus récent) - click@(80,80) → hit A → A passe au top - click@(400,280) → hit B → B repasse au top Traces /tmp/comp.log (extraites via redoxfs) confirment : [frontend] left-click @ (80, 80) → hit_test = Some(SurfaceId(0)) [frontend] focus change: Some(SurfaceId(1)) → Some(SurfaceId(0)) [frontend] left-click @ (400, 280) → hit_test = Some(SurfaceId(1)) [frontend] focus change: Some(SurfaceId(0)) → Some(SurfaceId(1)) Pipeline validé end-to-end : mouse_button QEMU → ps2d → inputd → InputBackend::poll → RedoxInputEvent::PointerButton → forward_input → hit_test → raise + set_focus → wl_keyboard.leave/enter broadcast. Doc complète : docs/phase7-4-focus-raise.md. Leyoda 2026 – GPLv3
This commit is contained in:
parent
5f7587e79e
commit
c40ca9fcc8
7 changed files with 653 additions and 1 deletions
10
crates/redox-wl-test-client-shm-two/Cargo.toml
Normal file
10
crates/redox-wl-test-client-shm-two/Cargo.toml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
[package]
|
||||
name = "redox-wl-test-client-shm-two"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
wayland-client = { path = "../../../wayland-rs/wayland-client", default-features = false }
|
||||
wayland-backend = { path = "../../../wayland-rs/wayland-backend", default-features = false }
|
||||
wayland-protocols = { path = "../../../wayland-rs/wayland-protocols", default-features = false, features = ["client"] }
|
||||
libc = "0.2"
|
||||
385
crates/redox-wl-test-client-shm-two/src/main.rs
Normal file
385
crates/redox-wl-test-client-shm-two/src/main.rs
Normal file
|
|
@ -0,0 +1,385 @@
|
|||
//! Phase 7.4 — Client à deux fenêtres pour valider focus + raise on click.
|
||||
//!
|
||||
//! Le parent fork 1 enfant. Chacun se connecte indépendamment au socket
|
||||
//! Wayland du compositor, crée son propre xdg_toplevel avec une couleur
|
||||
//! différente (vert pastel pour A, magenta pour B), et reste vivant 160 s.
|
||||
//!
|
||||
//! Avec le cascading offset du compositor (60, 60 puis 120, 120), les deux
|
||||
//! fenêtres se chevauchent partiellement. La fenêtre B est créée en dernier
|
||||
//! donc affichée au-dessus initialement.
|
||||
//!
|
||||
//! Pour valider le clic-raise : avec un cycle programmatique côté
|
||||
//! compositor qui repositionne le curseur sur A puis sur B et envoie un
|
||||
//! mouse_button via QEMU monitor, on peut voir le Z-order changer dans
|
||||
//! les screendumps.
|
||||
|
||||
use std::env;
|
||||
use std::ffi::CString;
|
||||
use std::fs::OpenOptions;
|
||||
use std::io::Write;
|
||||
use std::os::fd::{AsFd, FromRawFd, OwnedFd};
|
||||
use std::os::unix::net::UnixStream;
|
||||
use std::process::ExitCode;
|
||||
use std::ptr;
|
||||
use std::sync::{Mutex, OnceLock};
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
use wayland_client::{
|
||||
Connection, Dispatch, EventQueue, Proxy, QueueHandle,
|
||||
backend::Backend,
|
||||
protocol::{
|
||||
wl_buffer::WlBuffer, wl_compositor::WlCompositor, wl_registry, wl_shm::WlShm,
|
||||
wl_shm_pool::WlShmPool, wl_surface::WlSurface,
|
||||
},
|
||||
};
|
||||
use wayland_protocols::xdg::shell::client::{
|
||||
xdg_surface::{self, XdgSurface},
|
||||
xdg_toplevel::{self, XdgToplevel},
|
||||
xdg_wm_base::{self, XdgWmBase},
|
||||
};
|
||||
|
||||
const SOCKET_PATH: &str = "/tmp/redox-wl-comp.sock";
|
||||
const W: i32 = 300;
|
||||
const H: i32 = 200;
|
||||
const STRIDE: i32 = W * 4;
|
||||
const SIZE: i32 = STRIDE * H;
|
||||
|
||||
struct DebugSink(Mutex<Option<std::fs::File>>);
|
||||
impl DebugSink {
|
||||
fn new() -> Self {
|
||||
Self(Mutex::new(
|
||||
OpenOptions::new().write(true).open("/scheme/debug").ok(),
|
||||
))
|
||||
}
|
||||
fn writeln(&self, s: &str) {
|
||||
println!("{s}");
|
||||
if let Ok(mut g) = self.0.lock() {
|
||||
if let Some(f) = g.as_mut() {
|
||||
let _ = writeln!(f, "{s}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fn dlog(s: &str) {
|
||||
static SINK: OnceLock<DebugSink> = OnceLock::new();
|
||||
SINK.get_or_init(DebugSink::new).writeln(s);
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct ClientState {
|
||||
compositor: Option<WlCompositor>,
|
||||
shm: Option<WlShm>,
|
||||
wm_base: Option<XdgWmBase>,
|
||||
pending_serial: Option<u32>,
|
||||
configured: bool,
|
||||
label: String,
|
||||
}
|
||||
|
||||
impl Dispatch<wl_registry::WlRegistry, ()> for ClientState {
|
||||
fn event(
|
||||
state: &mut Self,
|
||||
registry: &wl_registry::WlRegistry,
|
||||
event: wl_registry::Event,
|
||||
_data: &(),
|
||||
_conn: &Connection,
|
||||
qh: &QueueHandle<Self>,
|
||||
) {
|
||||
if let wl_registry::Event::Global { name, interface, version } = event {
|
||||
match interface.as_str() {
|
||||
"wl_compositor" => {
|
||||
state.compositor = Some(registry.bind(name, version.min(5), qh, ()));
|
||||
}
|
||||
"wl_shm" => {
|
||||
state.shm = Some(registry.bind(name, version.min(1), qh, ()));
|
||||
}
|
||||
"xdg_wm_base" => {
|
||||
state.wm_base = Some(registry.bind(name, version.min(5), qh, ()));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! noop {
|
||||
($ty:ty) => {
|
||||
impl Dispatch<$ty, ()> for ClientState {
|
||||
fn event(
|
||||
_state: &mut Self,
|
||||
_r: &$ty,
|
||||
_ev: <$ty as Proxy>::Event,
|
||||
_: &(),
|
||||
_conn: &Connection,
|
||||
_qh: &QueueHandle<Self>,
|
||||
) {
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
noop!(WlCompositor);
|
||||
noop!(WlShm);
|
||||
noop!(WlShmPool);
|
||||
noop!(WlBuffer);
|
||||
noop!(WlSurface);
|
||||
|
||||
impl Dispatch<XdgWmBase, ()> for ClientState {
|
||||
fn event(
|
||||
_state: &mut Self,
|
||||
wm_base: &XdgWmBase,
|
||||
event: xdg_wm_base::Event,
|
||||
_: &(),
|
||||
_conn: &Connection,
|
||||
_qh: &QueueHandle<Self>,
|
||||
) {
|
||||
if let xdg_wm_base::Event::Ping { serial } = event {
|
||||
wm_base.pong(serial);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Dispatch<XdgSurface, ()> for ClientState {
|
||||
fn event(
|
||||
state: &mut Self,
|
||||
_xdg_surf: &XdgSurface,
|
||||
event: xdg_surface::Event,
|
||||
_: &(),
|
||||
_conn: &Connection,
|
||||
_qh: &QueueHandle<Self>,
|
||||
) {
|
||||
if let xdg_surface::Event::Configure { serial } = event {
|
||||
state.pending_serial = Some(serial);
|
||||
state.configured = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Dispatch<XdgToplevel, ()> for ClientState {
|
||||
fn event(
|
||||
_state: &mut Self,
|
||||
_r: &XdgToplevel,
|
||||
_event: xdg_toplevel::Event,
|
||||
_: &(),
|
||||
_conn: &Connection,
|
||||
_qh: &QueueHandle<Self>,
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
/// Génère un pattern de remplissage uni avec bordure noire 2px, et un
|
||||
/// gros caractère central A ou B pour distinguer visuellement les
|
||||
/// fenêtres dans les screendumps.
|
||||
unsafe fn create_shm_pattern(name: &str, base: u32, letter: char) -> Result<OwnedFd, String> {
|
||||
let cname = CString::new(name).unwrap();
|
||||
let _ = libc::shm_unlink(cname.as_ptr());
|
||||
let fd = libc::shm_open(cname.as_ptr(), libc::O_RDWR | libc::O_CREAT, 0o600);
|
||||
if fd < 0 {
|
||||
return Err("shm_open failed".into());
|
||||
}
|
||||
if libc::ftruncate(fd, SIZE as _) != 0 {
|
||||
libc::close(fd);
|
||||
return Err("ftruncate failed".into());
|
||||
}
|
||||
let p = libc::mmap(
|
||||
ptr::null_mut(),
|
||||
SIZE as usize,
|
||||
libc::PROT_READ | libc::PROT_WRITE,
|
||||
libc::MAP_SHARED,
|
||||
fd,
|
||||
0,
|
||||
);
|
||||
if p == libc::MAP_FAILED {
|
||||
libc::close(fd);
|
||||
return Err("mmap failed".into());
|
||||
}
|
||||
let pixels = std::slice::from_raw_parts_mut(p as *mut u32, (W * H) as usize);
|
||||
for y in 0..H {
|
||||
for x in 0..W {
|
||||
let on_border = x < 2 || x >= W - 2 || y < 2 || y >= H - 2;
|
||||
pixels[(y * W + x) as usize] = if on_border { 0xFF_10_10_10 } else { base };
|
||||
}
|
||||
}
|
||||
// Gros bloc 80x80 au centre formant la lettre (A : triangle ; B : rectangle barré)
|
||||
let cx = W / 2;
|
||||
let cy = H / 2;
|
||||
let lc: u32 = 0xFF_FF_FF_FF;
|
||||
match letter {
|
||||
'A' => {
|
||||
// pyramide simple 80x80
|
||||
for dy in -40i32..=40i32 {
|
||||
let halfw = 40 - dy.abs();
|
||||
for dx in -halfw..=halfw {
|
||||
let x = cx + dx;
|
||||
let y = cy + dy;
|
||||
if x >= 0 && x < W && y >= 0 && y < H {
|
||||
pixels[(y * W + x) as usize] = lc;
|
||||
}
|
||||
}
|
||||
}
|
||||
// un trou horizontal au tiers pour faire un "A"
|
||||
for dy in 10i32..=14i32 {
|
||||
let halfw = 40 - dy.abs();
|
||||
for dx in -halfw + 4..=halfw - 4 {
|
||||
let x = cx + dx;
|
||||
let y = cy + dy;
|
||||
if x >= 0 && x < W && y >= 0 && y < H {
|
||||
pixels[(y * W + x) as usize] = base;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
'B' | _ => {
|
||||
// 2 cercles empilés simulés par 2 carrés arrondis
|
||||
for dy in -40i32..=40i32 {
|
||||
for dx in -30i32..=30i32 {
|
||||
let x = cx + dx;
|
||||
let y = cy + dy;
|
||||
let in_top = dy < -2 && (dx * dx + (dy + 20) * (dy + 20)) <= 20 * 20;
|
||||
let in_bot = dy > 2 && (dx * dx + (dy - 20) * (dy - 20)) <= 20 * 20;
|
||||
if (in_top || in_bot) && x >= 0 && x < W && y >= 0 && y < H {
|
||||
pixels[(y * W + x) as usize] = lc;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
libc::munmap(p, SIZE as usize);
|
||||
Ok(OwnedFd::from_raw_fd(fd))
|
||||
}
|
||||
|
||||
fn run_one(label: &str, base_color: u32, letter: char, shm_name: &str) -> Result<(), Box<dyn std::error::Error>> {
|
||||
dlog(&format!("[{label}] connect to compositor"));
|
||||
|
||||
for i in 0..50 {
|
||||
if std::path::Path::new(SOCKET_PATH).exists() {
|
||||
break;
|
||||
}
|
||||
if i == 49 {
|
||||
return Err("compositor socket missing after 5s".into());
|
||||
}
|
||||
thread::sleep(Duration::from_millis(100));
|
||||
}
|
||||
|
||||
let stream = UnixStream::connect(SOCKET_PATH)?;
|
||||
let backend = Backend::connect(stream)?;
|
||||
let conn = Connection::from_backend(backend);
|
||||
let mut event_queue: EventQueue<ClientState> = conn.new_event_queue();
|
||||
let qh = event_queue.handle();
|
||||
let _registry = conn.display().get_registry(&qh, ());
|
||||
|
||||
let mut state = ClientState {
|
||||
label: label.to_string(),
|
||||
..ClientState::default()
|
||||
};
|
||||
event_queue.roundtrip(&mut state)?;
|
||||
let compositor = state.compositor.clone().ok_or("no wl_compositor")?;
|
||||
let shm = state.shm.clone().ok_or("no wl_shm")?;
|
||||
let wm_base = state.wm_base.clone().ok_or("no xdg_wm_base")?;
|
||||
|
||||
let surface = compositor.create_surface(&qh, ());
|
||||
let xdg_surface = wm_base.get_xdg_surface(&surface, &qh, ());
|
||||
let toplevel = xdg_surface.get_toplevel(&qh, ());
|
||||
toplevel.set_title(format!("Phase 7.4 — fenêtre {label}"));
|
||||
toplevel.set_app_id(format!("redox.wl.test.client.shm-two.{label}"));
|
||||
surface.commit();
|
||||
dlog(&format!("[{label}] xdg_toplevel créé"));
|
||||
|
||||
let start = std::time::Instant::now();
|
||||
while !state.configured && start.elapsed() < Duration::from_secs(5) {
|
||||
event_queue.roundtrip(&mut state)?;
|
||||
thread::sleep(Duration::from_millis(50));
|
||||
}
|
||||
let serial = state.pending_serial.ok_or("no initial configure")?;
|
||||
xdg_surface.ack_configure(serial);
|
||||
state.pending_serial = None;
|
||||
dlog(&format!("[{label}] ack_configure({serial})"));
|
||||
|
||||
let fd = unsafe { create_shm_pattern(shm_name, base_color, letter) }?;
|
||||
let pool = shm.create_pool(fd.as_fd(), SIZE, &qh, ());
|
||||
let buffer = pool.create_buffer(
|
||||
0,
|
||||
W,
|
||||
H,
|
||||
STRIDE,
|
||||
wayland_client::protocol::wl_shm::Format::Argb8888,
|
||||
&qh,
|
||||
(),
|
||||
);
|
||||
|
||||
surface.attach(Some(&buffer), 0, 0);
|
||||
surface.damage_buffer(0, 0, W, H);
|
||||
surface.commit();
|
||||
event_queue.flush()?;
|
||||
dlog(&format!("[{label}] buffer commit POST-ack"));
|
||||
|
||||
// Boucle vivante 160 s avec dispatch des events
|
||||
let start = std::time::Instant::now();
|
||||
while start.elapsed() < Duration::from_secs(160) {
|
||||
// Pattern flush + prepare_read + dispatch (cf phase 7.2 memo)
|
||||
let _ = event_queue.flush();
|
||||
if let Some(guard) = event_queue.prepare_read() {
|
||||
let _ = guard.read();
|
||||
}
|
||||
let _ = event_queue.dispatch_pending(&mut state);
|
||||
thread::sleep(Duration::from_millis(50));
|
||||
}
|
||||
|
||||
dlog(&format!("[{label}] destroy propre"));
|
||||
toplevel.destroy();
|
||||
xdg_surface.destroy();
|
||||
surface.destroy();
|
||||
let _ = event_queue.flush();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn run() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Mode enfant : le parent nous a re-exec avec ce flag.
|
||||
if env::var("REDOX_WL_CHILD").as_deref() == Ok("B") {
|
||||
// Décalage pour que l'ordre A→B soit déterministe : on attend 1s
|
||||
thread::sleep(Duration::from_millis(800));
|
||||
return run_one("B", 0xFF_8C_60_D0, 'B', "/redox-wl-client-shm-two-B");
|
||||
}
|
||||
|
||||
// Parent : fork
|
||||
let pid = unsafe { libc::fork() };
|
||||
if pid < 0 {
|
||||
return Err("fork failed".into());
|
||||
}
|
||||
if pid == 0 {
|
||||
// Côté enfant : exec self avec REDOX_WL_CHILD=B
|
||||
// On peut aussi appeler run_one directement (pas besoin d'exec).
|
||||
unsafe {
|
||||
libc::setenv(
|
||||
CString::new("REDOX_WL_CHILD").unwrap().as_ptr(),
|
||||
CString::new("B").unwrap().as_ptr(),
|
||||
1,
|
||||
);
|
||||
}
|
||||
// Inline : pas besoin d'exec, on fait directement le client B.
|
||||
thread::sleep(Duration::from_millis(800));
|
||||
return run_one("B", 0xFF_8C_60_D0, 'B', "/redox-wl-client-shm-two-B");
|
||||
}
|
||||
|
||||
// Parent : c'est le client A.
|
||||
let res = run_one("A", 0xFF_5A_C0_50, 'A', "/redox-wl-client-shm-two-A");
|
||||
|
||||
// Attendre l'enfant
|
||||
let mut status: i32 = 0;
|
||||
unsafe {
|
||||
libc::waitpid(pid, &mut status, 0);
|
||||
}
|
||||
res
|
||||
}
|
||||
|
||||
fn main() -> ExitCode {
|
||||
match run() {
|
||||
Ok(()) => {
|
||||
dlog("[parent] PASS");
|
||||
ExitCode::SUCCESS
|
||||
}
|
||||
Err(e) => {
|
||||
dlog(&format!("[parent] FAIL: {e}"));
|
||||
ExitCode::FAILURE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -215,6 +215,10 @@ pub struct WaylandFrontend {
|
|||
/// dernier `wl_pointer.set_cursor`. `None` = pas de curseur custom,
|
||||
/// on dessine le sprite par défaut (flèche 16x16).
|
||||
cursor_surface_id: Option<SurfaceId>,
|
||||
/// Phase 7.4 : mapping inverse SurfaceId → wl_surface, pour pouvoir
|
||||
/// faire set_focus(target) après un hit_test au clic. Peuplé au
|
||||
/// `wl_compositor.create_surface`, nettoyé au `wl_surface.destroy`.
|
||||
surfaces_by_id: HashMap<SurfaceId, wl_surface::WlSurface>,
|
||||
/// Hot-spot du curseur (offset à soustraire à cursor_x/y pour le placement).
|
||||
cursor_hot_x: i32,
|
||||
cursor_hot_y: i32,
|
||||
|
|
@ -259,6 +263,7 @@ impl WaylandFrontend {
|
|||
cursor_hot_x: 0,
|
||||
cursor_hot_y: 0,
|
||||
cursor_visible: false,
|
||||
surfaces_by_id: HashMap::new(),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -339,6 +344,18 @@ impl WaylandFrontend {
|
|||
if same {
|
||||
return;
|
||||
}
|
||||
let old_sid = self
|
||||
.focused_surface
|
||||
.as_ref()
|
||||
.and_then(|s| s.data::<Arc<SurfaceData>>())
|
||||
.and_then(|d| *d.id.lock().unwrap());
|
||||
let new_sid = new_focus
|
||||
.as_ref()
|
||||
.and_then(|s| s.data::<Arc<SurfaceData>>())
|
||||
.and_then(|d| *d.id.lock().unwrap());
|
||||
println!(
|
||||
"[frontend] focus change: {old_sid:?} → {new_sid:?}"
|
||||
);
|
||||
let serial_leave = self.alloc_input_serial();
|
||||
let serial_enter = self.alloc_input_serial();
|
||||
|
||||
|
|
@ -448,6 +465,32 @@ impl WaylandFrontend {
|
|||
middle,
|
||||
right,
|
||||
} => {
|
||||
// Phase 7.4 : sur clic gauche (left pressed), hit_test à la
|
||||
// position curseur et raise + set_focus à la surface ciblée.
|
||||
// À faire AVANT l'envoi des events button pour que la nouvelle
|
||||
// surface reçoive enter+modifiers en premier, puis le button.
|
||||
if *left {
|
||||
let hit = self.registry.hit_test(self.cursor_x, self.cursor_y);
|
||||
println!(
|
||||
"[frontend] left-click @ ({}, {}) → hit_test = {:?}",
|
||||
self.cursor_x, self.cursor_y, hit
|
||||
);
|
||||
if let Some(sid) = hit {
|
||||
// Ne pas réagir aux surfaces curseur (elles ne devraient pas
|
||||
// apparaître dans hit_test car visible=false, mais double-belt).
|
||||
if let Some(surf) = self.surfaces_by_id.get(&sid).cloned() {
|
||||
if !surf
|
||||
.data::<Arc<SurfaceData>>()
|
||||
.map(|d| d.is_cursor.load(Ordering::Relaxed))
|
||||
.unwrap_or(false)
|
||||
{
|
||||
self.registry.raise(sid);
|
||||
self.set_focus(Some(surf));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let time = self.alloc_input_time();
|
||||
// Code BTN_LEFT/MIDDLE/RIGHT linux/input-event-codes.h
|
||||
const BTN_LEFT: u32 = 0x110;
|
||||
|
|
@ -723,7 +766,10 @@ impl wayland_server::Dispatch<wl_compositor::WlCompositor, ()> for WaylandFronte
|
|||
xdg_pending_initial_configure: Mutex::new(false),
|
||||
is_cursor: AtomicBool::new(false),
|
||||
};
|
||||
data_init.init(id, Arc::new(data));
|
||||
let surf = data_init.init(id, Arc::new(data));
|
||||
// Phase 7.4 : enregistrer le mapping SurfaceId → WlSurface
|
||||
// pour permettre raise_at_cursor / set_focus depuis un hit_test.
|
||||
state.surfaces_by_id.insert(surface_id, surf);
|
||||
}
|
||||
wl_compositor::Request::CreateRegion { id } => {
|
||||
// Région no-op : on alloue la resource pour que le client
|
||||
|
|
@ -946,6 +992,18 @@ impl wayland_server::Dispatch<wl_surface::WlSurface, Arc<SurfaceData>> for Wayla
|
|||
let mut id_lock = data.id.lock().unwrap();
|
||||
if let Some(id) = id_lock.take() {
|
||||
state.registry.destroy(id);
|
||||
// Phase 7.4 : retirer du mapping inverse + clear focus
|
||||
// si c'était la surface focalisée (sinon des events seraient
|
||||
// envoyés à un wl_surface fantôme).
|
||||
if let Some(removed) = state.surfaces_by_id.remove(&id) {
|
||||
if state.focused_surface.as_ref() == Some(&removed) {
|
||||
state.focused_surface = None;
|
||||
}
|
||||
}
|
||||
// Si c'était le curseur custom, retomber sur le sprite par défaut.
|
||||
if state.cursor_surface_id == Some(id) {
|
||||
state.cursor_surface_id = None;
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue