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
@@ -191,6 +191,13 @@ pub(all) struct DesktopShell {
|
||||
mut persist : Bool
|
||||
mut tokens : @theme.Tokens
|
||||
mut screen_w : Int
|
||||
/// Desktop card position (once moved) and drag state.
|
||||
mut desk_set : Bool
|
||||
mut desk_x : Int
|
||||
mut desk_y : Int
|
||||
mut desk_drag : Bool
|
||||
mut desk_off_x : Int
|
||||
mut desk_off_y : Int
|
||||
mut screen_h : Int
|
||||
mut panel_h : Int
|
||||
/// Window list + layout mode, set by the compositor before each frame.
|
||||
@@ -259,6 +266,12 @@ pub fn DesktopShell::new(display : String) -> DesktopShell {
|
||||
persist: false,
|
||||
tokens: conv_theme(@scene.ThemeTokens::moon_night()),
|
||||
screen_w: 0,
|
||||
desk_set: false,
|
||||
desk_x: 0,
|
||||
desk_y: 0,
|
||||
desk_drag: false,
|
||||
desk_off_x: 0,
|
||||
desk_off_y: 0,
|
||||
screen_h: 0,
|
||||
panel_h: 40,
|
||||
windows: [],
|
||||
@@ -513,7 +526,9 @@ pub fn DesktopShell::cursor_at(self : DesktopShell, x : Int, y : Int) -> UInt {
|
||||
_ => 3U
|
||||
}
|
||||
}
|
||||
if self.drag_active {
|
||||
if self.desk_drag {
|
||||
17U
|
||||
} else if self.drag_active {
|
||||
17U // grabbing
|
||||
} else if self.menu_open && inside(self.menu_rect, x, y) {
|
||||
if self.menu_hover >= 0 { 4U } else { 1U }
|
||||
@@ -594,6 +609,10 @@ fn DesktopShell::reorder_dragged(self : DesktopShell, x : Int) -> Unit {
|
||||
|
||||
///| Pointer release: ends a widget drag, or clicks the widget if it never moved. True when a press was pending.
|
||||
pub fn DesktopShell::pointer_up(self : DesktopShell) -> Bool {
|
||||
if self.desk_drag {
|
||||
self.desk_drag = false
|
||||
return true
|
||||
}
|
||||
let slot = self.drag_slot
|
||||
let was_drag = self.drag_active
|
||||
self.drag_slot = ""
|
||||
@@ -614,6 +633,15 @@ pub fn DesktopShell::pointer_up(self : DesktopShell) -> Bool {
|
||||
|
||||
///| Pointer motion; returns true when over a popup or the menu (so windows don't see it).
|
||||
pub fn DesktopShell::pointer_move(self : DesktopShell, x : Int, y : Int) -> Bool {
|
||||
if self.desk_drag {
|
||||
self.desk_set = true
|
||||
self.desk_x = x - self.desk_off_x
|
||||
self.desk_y = y - self.desk_off_y
|
||||
let (cx, cy) = self.desk_pos()
|
||||
self.desk_x = cx
|
||||
self.desk_y = cy
|
||||
return true
|
||||
}
|
||||
if self.drag_slot != "" {
|
||||
if !self.drag_active && (x - self.drag_x0 > 4 || self.drag_x0 - x > 4) {
|
||||
self.drag_active = true
|
||||
@@ -685,7 +713,8 @@ pub fn DesktopShell::render(
|
||||
}
|
||||
let bg : Array[@scene.DrawOp] = []
|
||||
translate(@libshell.render_background(@ui.size(w, h), tokens), 0, 0, bg)
|
||||
render_desktop_widget(w, tokens, now(), bg)
|
||||
let (dx, dy) = self.desk_pos()
|
||||
render_desktop_widget(dx, dy, tokens, now(), bg)
|
||||
|
||||
let panel_ops : Array[@scene.DrawOp] = []
|
||||
self.comps.clear()
|
||||
|
||||
Reference in new issue
Block a user