Merge commits bca69d8c90
CI / test (push) Failing after 54s
CI / test (push) Failing after 54s
This commit is contained in:
commit
3b2e19ace5
4 files changed
+100
-6
No files matched your search
@@ -740,6 +740,10 @@ pub fn MoonPlasmaCompositor::handle_input(
|
|||||||
}
|
}
|
||||||
None => ()
|
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) {
|
match self.window_at(xi, yi) {
|
||||||
Some((wid, _)) => {
|
Some((wid, _)) => {
|
||||||
self.apply_actions([
|
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
|
Some(h) => return if h.horizontal { 26U } else { 27U } // ew-resize / ns-resize
|
||||||
None => ()
|
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 {
|
match self.ptr_win {
|
||||||
Some(w) => self.server.client_cursor_shape(w)
|
Some(w) => self.server.client_cursor_shape(w)
|
||||||
None => 1U
|
None => 1U
|
||||||
|
|||||||
@@ -531,3 +531,25 @@ test "Desktop Pulse reads live machine and window state through its granted inte
|
|||||||
assert_eq(others_focused, 0)
|
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())
|
||||||
|
}
|
||||||
@@ -10,7 +10,8 @@ let desktop_widget_h : Int = 120
|
|||||||
|
|
||||||
///|
|
///|
|
||||||
fn render_desktop_widget(
|
fn render_desktop_widget(
|
||||||
screen_w : Int,
|
x0 : Int,
|
||||||
|
y0 : Int,
|
||||||
tokens : @theme.Tokens,
|
tokens : @theme.Tokens,
|
||||||
at : @types.Datetime,
|
at : @types.Datetime,
|
||||||
out : Array[@scene.DrawOp],
|
out : Array[@scene.DrawOp],
|
||||||
@@ -38,7 +39,41 @@ fn render_desktop_widget(
|
|||||||
tokens.palette.foreground,
|
tokens.palette.foreground,
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
let x0 = screen_w - desktop_widget_w - 24
|
translate(ops, x0, y0, out)
|
||||||
translate(ops, x0, 24, out)
|
translate(@moon.render_disc(@ui.size(56, 56), tokens, p), x0 + desktop_widget_w - 56 - 18, y0 + 18, out)
|
||||||
translate(@moon.render_disc(@ui.size(56, 56), tokens, p), x0 + desktop_widget_w - 56 - 18, 24 + 18, out)
|
}
|
||||||
|
|
||||||
|
///| Default top-right position of the card, and the clamp that keeps it on screen.
|
||||||
|
fn DesktopShell::desk_pos(self : DesktopShell) -> (Int, Int) {
|
||||||
|
let (x, y) = if self.desk_set {
|
||||||
|
(self.desk_x, self.desk_y)
|
||||||
|
} else {
|
||||||
|
(self.screen_w - desktop_widget_w - 24, 24)
|
||||||
|
}
|
||||||
|
let mx = if self.screen_w > desktop_widget_w { self.screen_w - desktop_widget_w } else { 0 }
|
||||||
|
let my = if self.screen_h > desktop_widget_h { self.screen_h - desktop_widget_h } else { 0 }
|
||||||
|
(if x < 0 { 0 } else if x > mx { mx } else { x }, if y < 0 { 0 } else if y > my { my } else { y })
|
||||||
|
}
|
||||||
|
|
||||||
|
///| True if (x, y) is over the desktop card.
|
||||||
|
pub fn DesktopShell::desk_hit(self : DesktopShell, x : Int, y : Int) -> Bool {
|
||||||
|
let (cx, cy) = self.desk_pos()
|
||||||
|
x >= cx && x < cx + desktop_widget_w && y >= cy && y < cy + desktop_widget_h
|
||||||
|
}
|
||||||
|
|
||||||
|
///| Start dragging the card if the press is on it. Call only when no window covers (x, y).
|
||||||
|
pub fn DesktopShell::desk_press(self : DesktopShell, x : Int, y : Int) -> Bool {
|
||||||
|
if !self.desk_hit(x, y) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
let (cx, cy) = self.desk_pos()
|
||||||
|
self.desk_drag = true
|
||||||
|
self.desk_off_x = x - cx
|
||||||
|
self.desk_off_y = y - cy
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
///| True while the card is being dragged.
|
||||||
|
pub fn DesktopShell::desk_dragging(self : DesktopShell) -> Bool {
|
||||||
|
self.desk_drag
|
||||||
}
|
}
|
||||||
@@ -191,6 +191,13 @@ pub(all) struct DesktopShell {
|
|||||||
mut persist : Bool
|
mut persist : Bool
|
||||||
mut tokens : @theme.Tokens
|
mut tokens : @theme.Tokens
|
||||||
mut screen_w : Int
|
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 screen_h : Int
|
||||||
mut panel_h : Int
|
mut panel_h : Int
|
||||||
/// Window list + layout mode, set by the compositor before each frame.
|
/// Window list + layout mode, set by the compositor before each frame.
|
||||||
@@ -259,6 +266,12 @@ pub fn DesktopShell::new(display : String) -> DesktopShell {
|
|||||||
persist: false,
|
persist: false,
|
||||||
tokens: conv_theme(@scene.ThemeTokens::moon_night()),
|
tokens: conv_theme(@scene.ThemeTokens::moon_night()),
|
||||||
screen_w: 0,
|
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,
|
screen_h: 0,
|
||||||
panel_h: 40,
|
panel_h: 40,
|
||||||
windows: [],
|
windows: [],
|
||||||
@@ -513,7 +526,9 @@ pub fn DesktopShell::cursor_at(self : DesktopShell, x : Int, y : Int) -> UInt {
|
|||||||
_ => 3U
|
_ => 3U
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if self.drag_active {
|
if self.desk_drag {
|
||||||
|
17U
|
||||||
|
} else if self.drag_active {
|
||||||
17U // grabbing
|
17U // grabbing
|
||||||
} else if self.menu_open && inside(self.menu_rect, x, y) {
|
} else if self.menu_open && inside(self.menu_rect, x, y) {
|
||||||
if self.menu_hover >= 0 { 4U } else { 1U }
|
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.
|
///| 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 {
|
pub fn DesktopShell::pointer_up(self : DesktopShell) -> Bool {
|
||||||
|
if self.desk_drag {
|
||||||
|
self.desk_drag = false
|
||||||
|
return true
|
||||||
|
}
|
||||||
let slot = self.drag_slot
|
let slot = self.drag_slot
|
||||||
let was_drag = self.drag_active
|
let was_drag = self.drag_active
|
||||||
self.drag_slot = ""
|
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).
|
///| 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 {
|
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_slot != "" {
|
||||||
if !self.drag_active && (x - self.drag_x0 > 4 || self.drag_x0 - x > 4) {
|
if !self.drag_active && (x - self.drag_x0 > 4 || self.drag_x0 - x > 4) {
|
||||||
self.drag_active = true
|
self.drag_active = true
|
||||||
@@ -685,7 +713,8 @@ pub fn DesktopShell::render(
|
|||||||
}
|
}
|
||||||
let bg : Array[@scene.DrawOp] = []
|
let bg : Array[@scene.DrawOp] = []
|
||||||
translate(@libshell.render_background(@ui.size(w, h), tokens), 0, 0, bg)
|
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] = []
|
let panel_ops : Array[@scene.DrawOp] = []
|
||||||
self.comps.clear()
|
self.comps.clear()
|
||||||
|
|||||||
Reference in new issue
Block a user