diff options
| author | srdusr <[email protected]> | 2024-12-24 20:44:00 +0200 |
|---|---|---|
| committer | srdusr <[email protected]> | 2024-12-24 20:44:00 +0200 |
| commit | 3d73ed0f057a555ded67ad58dbe02b36cd4d2d1f (patch) | |
| tree | 71e9bab462b9073444183e2a969ba512cb94559f /crates/wayland/src/winit/platform.rs | |
| parent | 331a1a1d3a0d8dfd4c285b755c2e13785c95ee2a (diff) | |
| download | srdwm-3d73ed0f057a555ded67ad58dbe02b36cd4d2d1f.tar.gz srdwm-3d73ed0f057a555ded67ad58dbe02b36cd4d2d1f.zip | |
Accumulate wayland-crate additions: capture rendering, focus/Space sync, VT resume, plumbing
Bundles the remaining wayland-crate changes built up here,
touching both backends (udev and winit) and the shared input/rendering
code:
- udev/capture.rs: off-screen Pixman render of an arbitrary (not
necessarily on-screen) workspace's window content to a PPM file --
what crates/core's capture-request queue drives, for a workspace
switcher's thumbnail previews. wlr-screencopy structurally can't do
this (it can only see what an output is presenting), which is why
this exists as a separate render path rather than reusing it.
- input::focus_window now also raises the window in smithay's own
Space, not just core's stacking order - Space is what actually
renders on top and what pointer hit-testing reads, so any focus path
that skipped this (an IPC "focus" dispatch, concretely) left a
window genuinely focused while still rendering, and receiving
clicks, underneath whatever was already topmost. Both backends'
poll loops now re-sync this after any IPC mutation.
- udev/session.rs's VT-switch resume fix (drains a stale pending page
flip before reasserting CRTCs) already has its own earlier, cleanly
isolated commit - not duplicated here.
- Assorted decoration/cursor/rounded-corners/output-management/
screencopy/XWayland changes and their cross-backend wiring.
Coarser than the repo's usual one-purpose-per-commit convention,
deliberately - see the core-crate sweep commit's own message for why.
Diffstat (limited to 'crates/wayland/src/winit/platform.rs')
| -rw-r--r-- | crates/wayland/src/winit/platform.rs | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/crates/wayland/src/winit/platform.rs b/crates/wayland/src/winit/platform.rs index 23387b7..96adde8 100644 --- a/crates/wayland/src/winit/platform.rs +++ b/crates/wayland/src/winit/platform.rs @@ -43,8 +43,26 @@ impl Platform for WaylandPlatform { if let Some(ipc) = self.ipc.as_mut() { if ipc.poll(&self.wm) { self.pending.borrow_mut().push(CoreEvent::WorkspaceChanged); + // Same re-sync as `udev/platform.rs`'s matching block - see + // its own comment. `handle_request` only ever touches core's + // `WindowManager`, never `state.space`, so an IPC focus + // change left rendering/hit-testing on the stale topmost + // window until something else happened to raise it. + let focused = self.wm.borrow().focused_id(); + if let Some(id) = focused { + crate::input::focus_window(&mut self.state, id); + } } } + // Same lock-request draining as `udev/platform.rs`'s matching + // block - see its own comment. Exercised here too (not just on + // the real udev backend) specifically so a native lock can be + // tested against this nested dev session without ever touching + // the live tty1 one. + if self.wm.borrow_mut().drain_lock_request() { + self.state.begin_native_lock(); + } + self.state.poll_native_lock_auth(); let wait = TARGET_FRAME_TIME.saturating_sub(self.last_frame.elapsed()); let _ = self.idle_event_loop.dispatch(Some(wait), &mut self.state); self.last_frame = Instant::now(); @@ -69,6 +87,7 @@ impl Platform for WaylandPlatform { // "usable, shrunk rect" `toggle_maximize` targets. let full = self.backend.window_size(); m.full_geometry = srdwm_core::Rect::new(0, 0, full.w as u32, full.h as u32); + m.maximize_geometry = crate::input::maximize_geometry_for(&self.output, m.full_geometry); m.primary = true; m }]) @@ -145,4 +164,23 @@ impl Platform for WaylandPlatform { fn ungrab_keyboard(&mut self) -> PlatformResult<()> { Ok(()) } + + fn keyboard_layout(&mut self) -> PlatformResult<String> { + let Some(keyboard) = self.state.seat.get_keyboard() else { return Ok(String::new()) }; + Ok(keyboard.with_xkb_state(&mut self.state, |ctx| { + let xkb = ctx.xkb().lock().unwrap(); + let layout = xkb.active_layout(); + xkb.layout_name(layout).to_string() + })) + } + + fn cycle_keyboard_layout(&mut self) -> PlatformResult<String> { + let Some(keyboard) = self.state.seat.get_keyboard() else { return Ok(String::new()) }; + Ok(keyboard.with_xkb_state(&mut self.state, |mut ctx| { + ctx.cycle_next_layout(); + let xkb = ctx.xkb().lock().unwrap(); + let layout = xkb.active_layout(); + xkb.layout_name(layout).to_string() + })) + } } |