Desktop card: click and drag it around the wallpaper
Press on the card (when no window covers it) to grab it; it follows the pointer, clamped to the screen, with a hand cursor on hover and grabbing while dragged. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
783618b89f
commit
bca69d8c90
4 files changed
+100
-6
No files matched your search
@@ -740,6 +740,10 @@ pub fn MoonPlasmaCompositor::handle_input(
|
||||
}
|
||||
None => ()
|
||||
}
|
||||
if self.window_at(xi, yi) is None && self.shell.desk_press(xi, yi) {
|
||||
self.leave_pointer()
|
||||
return
|
||||
}
|
||||
match self.window_at(xi, yi) {
|
||||
Some((wid, _)) => {
|
||||
self.apply_actions([
|
||||
@@ -827,6 +831,10 @@ pub fn MoonPlasmaCompositor::desired_cursor(self : MoonPlasmaCompositor) -> UInt
|
||||
Some(h) => return if h.horizontal { 26U } else { 27U } // ew-resize / ns-resize
|
||||
None => ()
|
||||
}
|
||||
if self.ptr_win is None && self.shell.desk_hit(self.ptr_x.to_int(), self.ptr_y.to_int()) &&
|
||||
self.window_at(self.ptr_x.to_int(), self.ptr_y.to_int()) is None {
|
||||
return 4U // the desktop card can be dragged
|
||||
}
|
||||
match self.ptr_win {
|
||||
Some(w) => self.server.client_cursor_shape(w)
|
||||
None => 1U
|
||||
|
||||
@@ -531,3 +531,25 @@ test "Desktop Pulse reads live machine and window state through its granted inte
|
||||
assert_eq(others_focused, 0)
|
||||
}
|
||||
}
|
||||
|
||||
///|
|
||||
test "the desktop card can be dragged across the wallpaper" {
|
||||
let socket_path = "/tmp/wayland-moon-desk-" + @sys.getpid().to_string() + ".sock"
|
||||
let theme = @scene.ThemeTokens::moon_night()
|
||||
let comp = @host.MoonPlasmaCompositor::new(socket_path, theme, 1280, 720).unwrap()
|
||||
ignore(comp.compose_frame())
|
||||
// Default: top-right, 24px in. Grab it by its body.
|
||||
let gx = 1280 - 260 - 24 + 40
|
||||
let gy = 24 + 30
|
||||
assert_true(comp.shell.desk_hit(gx, gy))
|
||||
comp.handle_input(@nested.InputEvent::PointerMove(gx.to_double(), gy.to_double()), 1U)
|
||||
assert_eq(comp.desired_cursor(), 4U)
|
||||
comp.handle_input(@nested.InputEvent::PointerButton(272U, true), 2U)
|
||||
comp.handle_input(@nested.InputEvent::PointerMove(300.0, 300.0), 3U)
|
||||
assert_eq(comp.desired_cursor(), 17U)
|
||||
comp.handle_input(@nested.InputEvent::PointerButton(272U, false), 4U)
|
||||
// It moved: new top-left is pointer minus the grab offset.
|
||||
assert_true(comp.shell.desk_hit(300, 300))
|
||||
assert_true(!comp.shell.desk_hit(gx, gy))
|
||||
assert_true(!comp.shell.desk_dragging())
|
||||
}
|
||||
Reference in new issue
Block a user