Merge main: one linux-dmabuf, imported on the GPU or mapped without one
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
d478f58d9b
54 files changed
+1110
-376
No files matched your search
@@ -426,65 +426,3 @@ test "editor: a region screenshot opens at full size when it fits" {
|
||||
assert_eq((v.w, v.h), (400, 300))
|
||||
tap(comp, 1U, 30U)
|
||||
}
|
||||
|
||||
///| Headless pictures of the editor for the docs: written when CHANDRA_EDITOR_SHOTS names a folder.
|
||||
test "editor: headless screenshots" {
|
||||
let out = @sys.getenv("CHANDRA_EDITOR_SHOTS")
|
||||
if out.length() == 0 {
|
||||
return
|
||||
}
|
||||
let socket_path = "/tmp/wayland-moon-edshots-" + @sys.getpid().to_string() + ".sock"
|
||||
let comp = @host.ChandraCompositor::new(socket_path, @scene.ThemeTokens::moon_night(), 1280, 720).unwrap()
|
||||
comp.shot_dir = "/tmp/chandra-edshots-" + @sys.getpid().to_string()
|
||||
ignore(open_and_configure_client(comp, socket_path, "Notes", "notes"))
|
||||
ignore(open_and_configure_client(comp, socket_path, "Terminal", "term"))
|
||||
ignore(comp.compose_frame())
|
||||
key(comp, 99U, true, 1U)
|
||||
key(comp, 99U, false, 2U)
|
||||
ignore(comp.compose_frame())
|
||||
// An arrow, a rectangle, a blur, a redaction, a highlight, text and two markers.
|
||||
tap(comp, 30U, 10U)
|
||||
edit_drag(comp, 200, 560, 420, 380, 20U)
|
||||
tap(comp, 19U, 30U)
|
||||
tap(comp, 6U, 31U) // blue
|
||||
edit_drag(comp, 430, 200, 760, 360, 40U)
|
||||
tap(comp, 48U, 50U)
|
||||
edit_drag(comp, 750, 628, 1275, 674, 60U) // the notification
|
||||
tap(comp, 32U, 70U)
|
||||
tap(comp, 8U, 71U) // black
|
||||
edit_drag(comp, 895, 12, 1025, 42, 80U) // a title
|
||||
tap(comp, 45U, 85U)
|
||||
edit_drag(comp, 930, 686, 1060, 719, 86U) // the clock
|
||||
tap(comp, 35U, 90U)
|
||||
tap(comp, 4U, 91U) // yellow
|
||||
let (h0, h1) = on_screen(comp, 436, 590)
|
||||
let (h2, h3) = on_screen(comp, 640, 590)
|
||||
drag(comp, h0, h1, h2, h3, 100U)
|
||||
tap(comp, 49U, 110U)
|
||||
tap(comp, 2U, 111U) // red
|
||||
let (m0, m1) = on_screen(comp, 450, 190)
|
||||
click_at(comp, m0, m1, 120U)
|
||||
let (m2, m3) = on_screen(comp, 810, 110)
|
||||
click_at(comp, m2, m3, 130U)
|
||||
tap(comp, 20U, 140U)
|
||||
tap(comp, 9U, 141U) // white
|
||||
let (t0, t1) = on_screen(comp, 440, 590)
|
||||
click_at(comp, t0, t1, 150U)
|
||||
for c in [20U, 35U, 18U, 57U, 48U, 22U, 34U, 57U, 23U, 31U, 57U, 35U, 18U, 19U, 18U] {
|
||||
tap(comp, c, 160U)
|
||||
}
|
||||
tap(comp, 28U, 170U)
|
||||
// A crop being drawn.
|
||||
tap(comp, 46U, 180U)
|
||||
let (c0, c1) = on_screen(comp, 60, 60)
|
||||
let (c2, c3) = on_screen(comp, 1220, 690)
|
||||
comp.handle_input(@nested.InputEvent::PointerMove(c0.to_double(), c1.to_double()), 190U)
|
||||
comp.handle_input(@nested.InputEvent::PointerButton(272U, true), 191U)
|
||||
comp.handle_input(@nested.InputEvent::PointerMove(c2.to_double(), c3.to_double()), 192U)
|
||||
let frame = comp.compose_frame()
|
||||
ignore(@sys.mkdir_p(out))
|
||||
assert_eq(@sys.write_file_bytes(out + "/screenshot-editor.png", @renderer.encode_png_compressed(frame)), 0)
|
||||
comp.handle_input(@nested.InputEvent::PointerButton(272U, false), 193U)
|
||||
let saved = comp.screenshot_editor().unwrap().export()
|
||||
assert_eq(@sys.write_file_bytes(out + "/screenshot-editor-saved.png", @renderer.encode_png_compressed(saved)), 0)
|
||||
}
|
||||
@@ -1336,6 +1336,7 @@ fn ChandraCompositor::build_scene(
|
||||
(if self.rec_pointer { 2 } else { 0 })
|
||||
self.shell.osk_visible = self.osk_visible
|
||||
self.shell.rotation = self.pending_rotation.unwrap_or(self.rotation)
|
||||
self.shell.desktop_shown = self.desktop_shown()
|
||||
// A window over the whole desktop (maximized, fullscreen, monocle) pauses a desktop module's
|
||||
// animation: nobody can see it.
|
||||
self.shell.set_desktop_covered(self.desktop_covered())
|
||||
@@ -2025,6 +2026,7 @@ fn ChandraCompositor::run_shell_actions(self : ChandraCompositor) -> Unit {
|
||||
}
|
||||
@shell.ShellAction::SetOskVisible(v) => self.osk_set_manual_visible(v)
|
||||
@shell.ShellAction::SetRotation(r) => self.request_rotation(r)
|
||||
@shell.ShellAction::ToggleDesktop => self.toggle_show_desktop()
|
||||
@shell.ShellAction::SetLayout(m) =>
|
||||
match m {
|
||||
0 => self.set_layout_mode(@wm.LayoutMode::Tiling)
|
||||
|
||||
@@ -264,41 +264,6 @@ test "reload brings the desktop module back from disk with its settings" {
|
||||
assert_eq(comp.shell.desktop_module().unwrap().module_id, "starfield")
|
||||
}
|
||||
|
||||
///|
|
||||
test "desktop screenshots: icons, starfield, the Desktop tab" {
|
||||
let comp = desk_comp("shots", fake_apps=false)
|
||||
assert_true(comp.shell.set_desktop("icon-desktop"))
|
||||
comp.shell.set_module_setting("desktop", "count", "All")
|
||||
ignore(comp.compose_frame())
|
||||
// Hover one icon and select another with the keyboard.
|
||||
click_at(comp, 900, 300, 10U)
|
||||
comp.handle_input(@nested.InputEvent::Key(106U, true), 20U) // Right: selects the first
|
||||
comp.handle_input(@nested.InputEvent::Key(108U, true), 21U) // Down
|
||||
comp.handle_input(@nested.InputEvent::PointerMove(68.0, 68.0), 22U)
|
||||
ignore(@sys.write_file_bytes("_build/desktop_icons.png", @renderer.encode_png(comp.compose_frame())))
|
||||
assert_true(comp.shell.set_desktop("starfield"))
|
||||
comp.shell.set_module_setting("desktop", "speed", "Normal")
|
||||
comp.handle_input(@nested.InputEvent::PointerMove(900.0, 250.0), 30U)
|
||||
for _ in 0..<6 {
|
||||
@sys.sleep_ms(34)
|
||||
ignore(comp.compose_frame())
|
||||
}
|
||||
ignore(@sys.write_file_bytes("_build/desktop_starfield.png", @renderer.encode_png(comp.compose_frame())))
|
||||
// Warp pulse: a click streaks the stars.
|
||||
click_at(comp, 900, 250, 40U)
|
||||
for _ in 0..<3 {
|
||||
@sys.sleep_ms(34)
|
||||
ignore(comp.compose_frame())
|
||||
}
|
||||
ignore(@sys.write_file_bytes("_build/desktop_warp.png", @renderer.encode_png(comp.compose_frame())))
|
||||
assert_true(comp.shell.open_settings(Desktop))
|
||||
for _ in 0..<10 {
|
||||
@sys.sleep_ms(40) // the popup slides in
|
||||
ignore(comp.compose_frame())
|
||||
}
|
||||
ignore(@sys.write_file_bytes("_build/desktop_settings.png", @renderer.encode_png(comp.compose_frame())))
|
||||
}
|
||||
|
||||
///|
|
||||
test "mobile tap on desktop icon with finger drift launches without moving any icon" {
|
||||
let socket_path = "/tmp/wayland-moon-desk-mobile-" + @sys.getpid().to_string() + ".sock"
|
||||
|
||||
@@ -96,11 +96,3 @@ test "dmabuf buffers show their window and are released at once" {
|
||||
assert_eq(gpu.released, [41U, 43U])
|
||||
comp.close()
|
||||
}
|
||||
|
||||
///|
|
||||
test "no dmabuf global without a GPU" {
|
||||
let socket_path = "/tmp/wayland-moon-nodmabuf-" + @sys.getpid().to_string() + ".sock"
|
||||
let comp = @host.ChandraCompositor::new(socket_path, @scene.ThemeTokens::moon_night(), 1280, 720).unwrap()
|
||||
assert_eq(comp.server.dmabuf_formats().1.length(), 0)
|
||||
comp.close()
|
||||
}
|
||||
@@ -1,45 +1,4 @@
|
||||
///| The dock drawn in a real frame, for a look at it: writes _build/dock_hover.png (an icon under
|
||||
/// the pointer, magnified, with its name above) and _build/dock_menu.png (an app's right-click
|
||||
/// menu). Uses the machine's own .desktop files and icon theme, so what it shows varies.
|
||||
|
||||
///|
|
||||
test "dock screenshots: hover label and an app's menu" {
|
||||
let socket_path = "/tmp/wayland-moon-dockshot-" + @sys.getpid().to_string() + ".sock"
|
||||
let comp = @host.ChandraCompositor::new(socket_path, @scene.ThemeTokens::moon_night(), 1280, 720).unwrap()
|
||||
ignore(comp.compose_frame())
|
||||
let slot = comp.shell.slot_of("dock")
|
||||
// Room for the dock's running apps on a 1280-wide screen.
|
||||
for s in comp.shell.slots() {
|
||||
let m = comp.shell.slot_module(s)
|
||||
if m == "inspector" || m == "layout" || m == "screenshot" {
|
||||
ignore(comp.shell.unload_slot(s))
|
||||
}
|
||||
}
|
||||
comp.shell.set_module_setting(
|
||||
slot, "pinned", "libreoffice-writer;libreoffice-calc;libreoffice-impress;debian-xterm;vim",
|
||||
)
|
||||
// Icons only, to see the magnification (titles are the default).
|
||||
comp.shell.set_module_setting(slot, "titles", "off")
|
||||
let _a = open_and_configure_client(comp, socket_path, "Report.odt", "libreoffice-writer")
|
||||
let _b = open_and_configure_client(comp, socket_path, "Notes.odt", "libreoffice-writer")
|
||||
let _c = open_and_configure_client(comp, socket_path, "Terminal", "xterm")
|
||||
let _e = open_and_configure_client(comp, socket_path, "Notes 2", "org.example.Notes")
|
||||
let _d = open_and_configure_client(comp, socket_path, "Notes", "org.example.Notes")
|
||||
ignore(comp.compose_frame())
|
||||
ignore(comp.compose_frame())
|
||||
let r = comp.shell.slot_rect(slot)
|
||||
let cy = r.y + r.h / 2
|
||||
// Hover the second icon (Calc).
|
||||
comp.handle_input(@nested.InputEvent::PointerMove((r.x + 6 + 30 + 12).to_double(), cy.to_double()), 1U)
|
||||
let frame = comp.compose_frame()
|
||||
assert_true(comp.shell.dock_hover_name().length() > 0)
|
||||
ignore(@sys.write_file_bytes("_build/dock_hover.png", @renderer.encode_png(frame)))
|
||||
// Right-click the first (Writer, two windows).
|
||||
click_at(comp, r.x + 6 + 12, cy, 10U, btn=273U)
|
||||
assert_true(comp.shell.menu_open)
|
||||
assert_true(comp.shell.menu_rows.map(m => m.label).contains("Close 2 windows"))
|
||||
ignore(@sys.write_file_bytes("_build/dock_menu.png", @renderer.encode_png(comp.compose_frame())))
|
||||
}
|
||||
///| The dock as the panel's task manager, driven through real frames.
|
||||
|
||||
///| Pick row `label` of the open right-click menu (rows: 26px title, then 28px each).
|
||||
fn dock_pick(comp : @host.ChandraCompositor, label : String, t : UInt) -> Unit raise {
|
||||
|
||||
@@ -498,3 +498,61 @@ test "swapchain pools sent in one message all keep their fds, and a bare commit
|
||||
@sys.close_fd(c.fd)
|
||||
comp.close()
|
||||
}
|
||||
|
||||
///|
|
||||
test "a linear zwp_linux_dmabuf_v1 buffer is shown like an shm one" {
|
||||
// Without this global Mesa's Wayland EGL falls back to llvmpipe and Zed warns about it.
|
||||
let socket_path = "/tmp/wayland-moon-dmabuf-" + @sys.getpid().to_string() + ".sock"
|
||||
let theme = @scene.ThemeTokens::moon_night()
|
||||
let comp = @host.ChandraCompositor::new(socket_path, theme, 1280, 720).unwrap()
|
||||
let (c, _shm, surf, xdg, _tl, _deco) = open_and_configure_client(
|
||||
comp, socket_path, "Zed", "dev.zed.Zed",
|
||||
)
|
||||
match c.configure_serial {
|
||||
Some(ser) => {
|
||||
let ack = @wayland.WireWriter::new()
|
||||
ack.u32(ser)
|
||||
c.send(ack.finish_msg(xdg, 4U))
|
||||
}
|
||||
None => ()
|
||||
}
|
||||
assert_true(c.globals.contains("zwp_linux_dmabuf_v1"))
|
||||
let dmabuf = bind_global(c, 2U, "zwp_linux_dmabuf_v1", 4U)
|
||||
let params = c.alloc_id()
|
||||
let cp = @wayland.WireWriter::new()
|
||||
cp.u32(params)
|
||||
c.send(cp.finish_msg(dmabuf, 1U))
|
||||
let w = c.configured_w
|
||||
let h = c.configured_h
|
||||
let fd = solid_memfd(w, h, b'\x00', b'\xff', b'\x00')
|
||||
// add(fd, plane 0, offset 0, stride, modifier LINEAR) and create_immed in one flush.
|
||||
let msg : Array[Byte] = []
|
||||
let add = @wayland.WireWriter::new()
|
||||
add.u32(0U)
|
||||
add.u32(0U)
|
||||
add.u32((w * 4).reinterpret_as_uint())
|
||||
add.u32(0U)
|
||||
add.u32(0U)
|
||||
for b in add.finish_msg(params, 1U) {
|
||||
msg.push(b)
|
||||
}
|
||||
let buf = c.alloc_id()
|
||||
let ci = @wayland.WireWriter::new()
|
||||
ci.u32(buf)
|
||||
ci.i32(w)
|
||||
ci.i32(h)
|
||||
ci.u32(0x34325241U)
|
||||
ci.u32(0U)
|
||||
for b in ci.finish_msg(params, 3U) {
|
||||
msg.push(b)
|
||||
}
|
||||
assert_true(@sys.sendmsg_fds(c.fd, Bytes::from_array(msg), [fd]) > 0)
|
||||
let win = comp.windows.get(1UL).unwrap()
|
||||
let cx = win.geometry.x + win.geometry.w / 2
|
||||
let cy = win.geometry.y + win.geometry.h / 2
|
||||
attach_commit(comp, c, surf, Some(buf))
|
||||
assert_eq(comp.compose_frame().pixel(cx, cy), Some(@scene.Rgba::new(0, 0xff, 0, 0xff)))
|
||||
@sys.close_fd(fd)
|
||||
@sys.close_fd(c.fd)
|
||||
comp.close()
|
||||
}
|
||||
@@ -218,36 +218,3 @@ test "recent emoji and the skin tone are kept in state.edn" {
|
||||
assert_eq(q.items().map(i => i.text), ["🍕", "👍🏽"])
|
||||
}
|
||||
}
|
||||
|
||||
///| CHANDRA_EMOJI_SHOTS=<dir>: pictures of the picker over a window (docs, the thread).
|
||||
test "screenshots of the picker" {
|
||||
let dir = @sys.getenv("CHANDRA_EMOJI_SHOTS")
|
||||
if dir.length() > 0 {
|
||||
ignore(@sys.mkdir_p(dir))
|
||||
let socket_path = "/tmp/wayland-moon-emojishots-" + @sys.getpid().to_string() + ".sock"
|
||||
let comp = @host.ChandraCompositor::new(socket_path, @scene.ThemeTokens::moon_night(), 1280, 720).unwrap()
|
||||
let (a, shm_a, surf_a, xdg_a, _, _) = open_and_configure_client(comp, socket_path, "Notes", "notes")
|
||||
commit_shm_frame(comp, a, shm_a, surf_a, xdg_a, 1UL)
|
||||
let (ti, _) = text_input_for(comp, a)
|
||||
text_input_state(comp, a, ti, true, 120, 90, 18)
|
||||
let shot = fn(name : String) raise {
|
||||
let frame = comp.compose_frame()
|
||||
assert_eq(@sys.write_file_bytes(dir + "/" + name, @renderer.encode_png_compressed(frame)), 0)
|
||||
}
|
||||
press_super_period(comp, 10U)
|
||||
shot("picker-smileys.png")
|
||||
type_keys(comp, [35U, 18U, 30U, 19U, 20U], 20U) // h e a r t
|
||||
shot("picker-search.png")
|
||||
type_keys(comp, [14U, 14U, 14U, 14U, 14U, 15U], 40U) // clear, then Tab: People
|
||||
comp.handle_input(@nested.InputEvent::Modifiers(4U, 0U, 0U, 0U), 60U)
|
||||
type_keys(comp, [106U, 106U, 106U], 61U) // Ctrl+Right x3: medium skin tone
|
||||
comp.handle_input(@nested.InputEvent::Modifiers(0U, 0U, 0U, 0U), 70U)
|
||||
type_keys(comp, [106U, 108U], 71U)
|
||||
shot("picker-people-tone.png")
|
||||
// The clipboard notice: the app turns its text field off, then an emoji is chosen.
|
||||
text_input_state(comp, a, ti, false, 0, 0, 0)
|
||||
type_keys(comp, [28U], 80U)
|
||||
shot("picker-copied-notice.png")
|
||||
comp.close()
|
||||
}
|
||||
}
|
||||
@@ -264,5 +264,5 @@ test "the Face unlock window: screen fill-light boosts backlight and restores on
|
||||
assert_true(comp.shell.face.window is None)
|
||||
assert_eq(@shell.read_backlight_percent(), 50)
|
||||
comp.close()
|
||||
@shell.set_backlight_root("/sys/class/backlight")
|
||||
@shell.set_backlight_root(@shell.default_backlight_root())
|
||||
}
|
||||
@@ -1460,6 +1460,41 @@ test "super+d minimizes every window to show the desktop, and again brings them
|
||||
assert_false(comp.wm.windows.get(2UL).unwrap().minimized)
|
||||
}
|
||||
|
||||
///|
|
||||
test "the show desktop module hides the windows, lights up, and a second click brings them back" {
|
||||
let socket_path = "/tmp/wayland-moon-showdesk-" + @sys.getpid().to_string() + ".sock"
|
||||
let theme = @scene.ThemeTokens::moon_night()
|
||||
let comp = @host.ChandraCompositor::new(socket_path, theme, 1280, 720).unwrap()
|
||||
assert_true(comp.shell.load_module("show-desktop"))
|
||||
ignore(comp.compose_frame())
|
||||
ignore(open_and_configure_client(comp, socket_path, "A", "a"))
|
||||
ignore(open_and_configure_client(comp, socket_path, "B", "b"))
|
||||
ignore(comp.compose_frame())
|
||||
// Lit (the accent behind the icon) only while the desktop is shown.
|
||||
let lit = fn() {
|
||||
match comp.shell.slot_ops(comp.shell.slot_of("show-desktop")) {
|
||||
[FillRect(f), ..] => {
|
||||
let a = comp.shell.tokens.palette.accent
|
||||
f.color.r == a.r && f.color.g == a.g && f.color.b == a.b
|
||||
}
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
assert_false(lit())
|
||||
click_module(comp, "show-desktop", 1U)
|
||||
assert_true(comp.wm.windows.get(1UL).unwrap().minimized)
|
||||
assert_true(comp.wm.windows.get(2UL).unwrap().minimized)
|
||||
assert_true(comp.desktop_shown())
|
||||
ignore(comp.compose_frame())
|
||||
assert_true(lit())
|
||||
click_module(comp, "show-desktop", 10U)
|
||||
assert_false(comp.wm.windows.get(1UL).unwrap().minimized)
|
||||
assert_false(comp.wm.windows.get(2UL).unwrap().minimized)
|
||||
assert_false(comp.desktop_shown())
|
||||
ignore(comp.compose_frame())
|
||||
assert_false(lit())
|
||||
}
|
||||
|
||||
///| Click (x, y) without drawing, then return the next scene's wallpaper op count (0: no new scene).
|
||||
fn click_wallpaper_ops(comp : @host.ChandraCompositor, x : Int, y : Int, t : UInt) -> Int {
|
||||
comp.handle_input(@nested.InputEvent::PointerMove(x.to_double(), y.to_double()), t)
|
||||
@@ -1841,5 +1876,5 @@ test "settings Power tab displays and adjusts backlight brightness" {
|
||||
assert_true(bright_row >= 1)
|
||||
click_at(comp, pr.x + 25, pr.y + 40 + bright_row * 28 + 13, 10U)
|
||||
assert_eq(@shell.read_backlight_percent(), 70)
|
||||
@shell.set_backlight_root("/sys/class/backlight")
|
||||
@shell.set_backlight_root(@shell.default_backlight_root())
|
||||
}
|
||||
@@ -77,36 +77,3 @@ test "the open Applications menu gets its rows' icons and draws them" {
|
||||
assert_false(comp.shell.icon_app_ids().contains("app5"))
|
||||
comp.shell.shutdown()
|
||||
}
|
||||
|
||||
///| For a look: the menu and the Icon Desktop with theme icons (whatever the machine's hicolor
|
||||
/// theme has for these names; letter tiles or the generic icon where it has nothing). Writes
|
||||
/// _build/launcher_icons_themed.png and _build/desktop_icons_themed.png.
|
||||
test "screenshots: Applications menu and Icon Desktop with theme icons" {
|
||||
let comp = desk_comp("ishot")
|
||||
let apps = [
|
||||
("org.libreoffice.Writer", "Writer", "Word processor", "libreoffice-writer"),
|
||||
("org.libreoffice.Calc", "Calc", "Spreadsheets", "libreoffice-calc"),
|
||||
("org.libreoffice.Impress", "Impress", "Presentations", "libreoffice-impress"),
|
||||
("org.libreoffice.Draw", "Draw", "Drawings and diagrams", "libreoffice-draw"),
|
||||
("xterm", "XTerm", "Terminal emulator", "xterm-color"),
|
||||
("gvim", "GVim", "Text editor", "gvim"),
|
||||
]
|
||||
comp.shell.apps.clear()
|
||||
for a in apps {
|
||||
comp.shell.apps.push({ id: a.0, name: a.1, comment: a.2, category: "", glyph: "" })
|
||||
comp.shell.exec.set(a.0, a.0)
|
||||
comp.shell.icon_names.set(a.0, a.3)
|
||||
comp.shell.icon_handles.remove(a.0)
|
||||
}
|
||||
comp.shell.apps_dirty = true
|
||||
assert_true(comp.shell.set_desktop("icon-desktop"))
|
||||
ignore(comp.compose_frame())
|
||||
ignore(@sys.write_file_bytes("_build/desktop_icons_themed.png", @renderer.encode_png(comp.compose_frame())))
|
||||
comp.shell.toggle_launcher()
|
||||
for _ in 0..<10 {
|
||||
@sys.sleep_ms(30)
|
||||
ignore(comp.compose_frame())
|
||||
}
|
||||
ignore(@sys.write_file_bytes("_build/launcher_icons_themed.png", @renderer.encode_png(comp.compose_frame())))
|
||||
comp.shell.shutdown()
|
||||
}
|
||||
@@ -399,33 +399,6 @@ test "middle click closes a window from the overview and it stays open" {
|
||||
assert_true(drain_msgs(clients[ci]).iter().any(m => m.1 == 1U))
|
||||
}
|
||||
|
||||
///|
|
||||
fn overview_shot(n : Int, dark : Bool) -> Unit raise {
|
||||
let tag = "ovshot" + n.to_string() + (if dark { "d" } else { "l" })
|
||||
let socket_path = "/tmp/wayland-moon-" + tag + "-" + @sys.getpid().to_string() + ".sock"
|
||||
let comp = @host.ChandraCompositor::new(socket_path, @scene.ThemeTokens::moon_night(), 1280, 720).unwrap()
|
||||
comp.shell.dark_mode = dark
|
||||
comp.apply_theme()
|
||||
ignore(comp.compose_frame())
|
||||
ignore(open_windows(comp, socket_path, n))
|
||||
comp.handle_input(@nested.InputEvent::Key(125U, true), 1U)
|
||||
comp.handle_input(@nested.InputEvent::Key(125U, false), 2U)
|
||||
ov_settle(comp)
|
||||
// Hover the first window to show the highlight and close button.
|
||||
let (_, r) = comp.overview_places()[0]
|
||||
comp.handle_input(@nested.InputEvent::PointerMove((r.x + r.w / 2).to_double(), (r.y + r.h / 2).to_double()), 3U)
|
||||
let px = comp.compose_frame()
|
||||
ignore(@sys.write_file_bytes("_build/overview_" + n.to_string() + (if dark { "_dark" } else { "_light" }) + ".png", @renderer.encode_png(px)))
|
||||
}
|
||||
|
||||
///|
|
||||
test "overview screenshots: 1, 4 and 9 windows, dark and light" {
|
||||
for n in [1, 4, 9] {
|
||||
overview_shot(n, true)
|
||||
overview_shot(n, false)
|
||||
}
|
||||
}
|
||||
|
||||
///|
|
||||
test "no overview while the Interface Explorer inspects the launcher" {
|
||||
let comp = new_comp("ov-inspect")
|
||||
|
||||
@@ -172,6 +172,8 @@ pub(all) enum ShellAction {
|
||||
SetOskVisible(Bool)
|
||||
/// The Rotate panel module asked to set display rotation (0..3).
|
||||
SetRotation(Int)
|
||||
/// The Show Desktop module was clicked: hide the windows, or bring them back (as Super+D).
|
||||
ToggleDesktop
|
||||
} derive(Eq, Debug)
|
||||
|
||||
///| One wasm module loaded into the panel.
|
||||
@@ -289,6 +291,9 @@ pub(all) struct DesktopShell {
|
||||
mut osk_visible : Bool
|
||||
/// Current display rotation 0..3 (published to `rotation`).
|
||||
mut rotation : Int
|
||||
/// What the Show Desktop module is told (the compositor sets it every frame): the windows are
|
||||
/// hidden and another toggle would bring them back.
|
||||
mut desktop_shown : Bool
|
||||
/// The network service (network.mbt), while a module imports `network`.
|
||||
mut net : @network.NetService?
|
||||
mut remember_windows : Bool
|
||||
@@ -468,6 +473,7 @@ pub fn DesktopShell::new(display : String) -> DesktopShell {
|
||||
screenshot_state: 2,
|
||||
osk_visible: false,
|
||||
rotation: 0,
|
||||
desktop_shown: false,
|
||||
net: None,
|
||||
remember_windows: true,
|
||||
native_auth_agent: true,
|
||||
|
||||
@@ -14,8 +14,7 @@
|
||||
///| Modules loaded into a fresh panel, in order. The dock (pinned and running apps, the task
|
||||
/// manager) stretches, so what follows it packs right.
|
||||
let default_panel : Array[String] = [
|
||||
"launcher", "inspector", "layout", "dock", "moon-disc", "network", "clock-digital", "screenshot",
|
||||
"session-settings",
|
||||
"launcher", "inspector", "layout", "dock", "network", "clock-digital", "screenshot", "session-settings",
|
||||
]
|
||||
|
||||
///| A fresh panel's modules: the defaults, plus the battery before the clock on a machine that
|
||||
@@ -334,6 +333,9 @@ fn migrate_panel(entries : Array[String]) -> Array[String] {
|
||||
if !has_settings && !out.contains("session-settings") {
|
||||
out.push("session-settings")
|
||||
}
|
||||
} else if e == "moon-disc" {
|
||||
// The moon phase disc never had source in the tree: a saved panel drops it.
|
||||
continue
|
||||
} else if e == "logout" {
|
||||
if !has_launcher && !out.contains("launcher") {
|
||||
out.push("launcher")
|
||||
@@ -353,6 +355,11 @@ test "a saved panel's wallpaper button becomes the settings module" {
|
||||
assert_eq(migrate_panel(["clock"]), ["clock"])
|
||||
}
|
||||
|
||||
///|
|
||||
test "a saved panel drops the moon-disc module, which has no source" {
|
||||
assert_eq(migrate_panel(["launcher", "moon-disc", "clock-digital"]), ["launcher", "clock-digital"])
|
||||
}
|
||||
|
||||
///|
|
||||
test "a saved panel's task list and dock become one dock, in the task list's place" {
|
||||
assert_eq(migrate_panel(["launcher", "tasks", "clock-digital", "dock"]), ["launcher", "dock", "clock-digital"])
|
||||
@@ -855,6 +862,9 @@ fn DesktopShell::publish_host_data(self : DesktopShell) -> Unit {
|
||||
if self.any_cap("rotation") {
|
||||
@wasm.publish_rotation(self.rotation)
|
||||
}
|
||||
if self.any_cap("show-desktop") {
|
||||
@wasm.publish_desktop_shown(self.desktop_shown)
|
||||
}
|
||||
if self.any_cap("battery") {
|
||||
let b = self.battery.refresh()
|
||||
@wasm.publish_battery(b.percent, b.state, b.secs_left)
|
||||
@@ -1033,6 +1043,7 @@ fn DesktopShell::process_requests(self : DesktopShell) -> Unit {
|
||||
Some(GameLibrary(code, game, mode)) => self.gamelib.request(code, game, mode)
|
||||
Some(SetOskVisible(v)) => self.actions.push(SetOskVisible(v))
|
||||
Some(SetRotation(r)) => self.actions.push(SetRotation(r))
|
||||
Some(ToggleDesktop) => self.actions.push(ToggleDesktop)
|
||||
Some(PowerAction(a)) => if a >= 0 && a <= 2 { self.actions.push(SystemPower(a)) }
|
||||
Some(Network(code, ssid, password)) => self.network_request(code, ssid, password)
|
||||
Some(SetInspector(on)) => self.set_inspecting(on)
|
||||
|
||||
@@ -288,6 +288,15 @@ int32_t mp_pwrite_bytes(int32_t fd, moonbit_bytes_t buf, int32_t len, int32_t of
|
||||
return w < 0 ? -1 : (int32_t)w;
|
||||
}
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <linux/dma-buf.h>
|
||||
|
||||
/* Wait for the GPU to finish writing a dma-buf before the CPU reads it; harmless on shm files. */
|
||||
static void dmabuf_sync(int fd, int start) {
|
||||
struct dma_buf_sync sync = { .flags = (start ? DMA_BUF_SYNC_START : DMA_BUF_SYNC_END) | DMA_BUF_SYNC_READ };
|
||||
ioctl(fd, DMA_BUF_IOCTL_SYNC, &sync);
|
||||
}
|
||||
|
||||
MOONBIT_FFI_EXPORT
|
||||
moonbit_bytes_t mp_mmap_read(int32_t fd, int32_t size) {
|
||||
if (fd < 0 || size <= 0) {
|
||||
@@ -302,7 +311,9 @@ moonbit_bytes_t mp_mmap_read(int32_t fd, int32_t size) {
|
||||
return moonbit_make_bytes_raw(0);
|
||||
}
|
||||
moonbit_bytes_t out = moonbit_make_bytes_raw(size);
|
||||
dmabuf_sync(fd, 1);
|
||||
memcpy(out, ptr, (size_t)size);
|
||||
dmabuf_sync(fd, 0);
|
||||
munmap(ptr, (size_t)size);
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -427,6 +427,11 @@ pub fn publish_rotation(rot : Int) -> Unit {
|
||||
@hostpl.publish_rotation(rot.reinterpret_as_uint())
|
||||
}
|
||||
|
||||
///| Publish whether show-desktop has the windows hidden.
|
||||
pub fn publish_desktop_shown(shown : Bool) -> Unit {
|
||||
@hostpl.publish_desktop_shown(shown)
|
||||
}
|
||||
|
||||
///| The power timeouts, in minutes (0: never).
|
||||
pub fn publish_power(screen_off : Int, suspend : Int) -> Unit {
|
||||
@hostpl.publish_power(screen_off.reinterpret_as_uint(), suspend.reinterpret_as_uint())
|
||||
@@ -487,6 +492,8 @@ pub(all) enum HostRequest {
|
||||
SetOskVisible(Bool)
|
||||
/// The rotation capability: set display orientation (0..3).
|
||||
SetRotation(Int)
|
||||
/// The show-desktop capability's `toggle`: hide the windows, or bring back the ones it hid.
|
||||
ToggleDesktop
|
||||
} derive(Eq, Debug)
|
||||
|
||||
///|
|
||||
@@ -518,6 +525,7 @@ pub fn next_request() -> HostRequest? {
|
||||
Some(GameLibrary(r)) => Some(GameLibrary(r.action, r.game, r.mode))
|
||||
Some(SetOskVisible(v)) => Some(SetOskVisible(v))
|
||||
Some(SetRotation(r)) => Some(SetRotation(r))
|
||||
Some(ToggleDesktop) => Some(ToggleDesktop)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -841,6 +841,11 @@ pub fn publish_rotation(rot : Int) -> Unit {
|
||||
c_host_set_int(12, rot)
|
||||
}
|
||||
|
||||
///| Publish whether show-desktop has the windows hidden.
|
||||
pub fn publish_desktop_shown(shown : Bool) -> Unit {
|
||||
c_host_set_int(13, if shown { 1 } else { 0 })
|
||||
}
|
||||
|
||||
///| Publish the power timeouts, in minutes (0: never).
|
||||
pub fn publish_power(screen_off : Int, suspend : Int) -> Unit {
|
||||
c_host_set_int(5, screen_off)
|
||||
@@ -905,6 +910,8 @@ pub(all) enum HostRequest {
|
||||
SetOskVisible(Bool)
|
||||
/// The rotation capability: set display orientation (0..3).
|
||||
SetRotation(Int)
|
||||
/// The show-desktop capability's `toggle`: hide the windows, or bring back the ones it hid.
|
||||
ToggleDesktop
|
||||
} derive(Eq, Debug)
|
||||
|
||||
///|
|
||||
@@ -949,6 +956,7 @@ pub fn next_request() -> HostRequest? {
|
||||
20 => Some(SetBrightness(c_host_req_int()))
|
||||
21 => Some(SetOskVisible(c_host_req_int() != 0))
|
||||
22 => Some(SetRotation(c_host_req_int()))
|
||||
23 => Some(ToggleDesktop)
|
||||
40 => Some(SetDesktop(c_host_req_int()))
|
||||
44 => Some(FaceUnlock(c_host_req_int()))
|
||||
45 => {
|
||||
|
||||
@@ -69,7 +69,8 @@ enum {
|
||||
K_DESKTOPS, K_DESKTOP_CUR, K_SET_DESKTOP,
|
||||
K_FU_STATUS, K_FU_FACES, K_FU_ENROLL, K_FU_REMOVE, K_FU_SET_IN_USE, K_FU_REFRESH,
|
||||
K_GL_STATUS, K_GL_GAMES, K_GL_MODES, K_GL_LAUNCH, K_GL_STOP, K_GL_FOCUS, K_GL_REFRESH,
|
||||
K_OSK_IS_VISIBLE, K_OSK_SET_VISIBLE, K_ROT_CURRENT, K_ROT_SET
|
||||
K_OSK_IS_VISIBLE, K_OSK_SET_VISIBLE, K_ROT_CURRENT, K_ROT_SET,
|
||||
K_DESK_SHOWN, K_DESK_TOGGLE
|
||||
};
|
||||
typedef struct Env { Inst *inst; int kind; } Env;
|
||||
|
||||
@@ -87,7 +88,7 @@ static int32_t host_ints[24] = {[7] = -1, [10] = -1}; /* 0 layout mode, 1 inspec
|
||||
5 screen-off minutes, 6 suspend minutes (0: never),
|
||||
7 battery percent (-1: none), 8 battery charge-state, 9 battery seconds left,
|
||||
10 backlight brightness percent (-1: none), 11 osk visible (0/1),
|
||||
12 display rotation (0..3) */
|
||||
12 display rotation (0..3), 13 desktop shown (show-desktop hid the windows) */
|
||||
|
||||
/* ---- requests a guest made of the host (launch, focus, ...) ; drained by the shell after each call ---- */
|
||||
typedef struct { int kind; int32_t n; char *s; } Req;
|
||||
@@ -503,6 +504,10 @@ static wasm_trap_t *host_import(void *env, const wasm_val_vec_t *args, wasm_val_
|
||||
if (results->size >= 1) results->data[0] = (wasm_val_t)WASM_I32_VAL(host_ints[12]);
|
||||
break;
|
||||
case K_ROT_SET: push_req(22, a0, NULL); break;
|
||||
case K_DESK_SHOWN:
|
||||
if (results->size >= 1) results->data[0] = (wasm_val_t)WASM_I32_VAL(host_ints[13] != 0);
|
||||
break;
|
||||
case K_DESK_TOGGLE: push_req(23, 0, NULL); break;
|
||||
case K_MOD_BROWSE: push_req(7, 0, NULL); break;
|
||||
case K_MOD_LOAD: { char *s = guest_str(in, a0, a1); push_req(5, 0, s); free(s); break; }
|
||||
case K_MOD_UNLOAD: { char *s = guest_str(in, a0, a1); push_req(6, 0, s); free(s); break; }
|
||||
@@ -716,6 +721,8 @@ static int classify_import(const wasm_name_t *m, const wasm_name_t *f) {
|
||||
if (!strcmp(iface, "osk") && !strcmp(fn, "set-visible")) return K_OSK_SET_VISIBLE;
|
||||
if (!strcmp(iface, "rotation") && !strcmp(fn, "current")) return K_ROT_CURRENT;
|
||||
if (!strcmp(iface, "rotation") && !strcmp(fn, "set-rotation")) return K_ROT_SET;
|
||||
if (!strcmp(iface, "show-desktop") && !strcmp(fn, "is-shown")) return K_DESK_SHOWN;
|
||||
if (!strcmp(iface, "show-desktop") && !strcmp(fn, "toggle")) return K_DESK_TOGGLE;
|
||||
if (!strcmp(iface, "modules") && !strcmp(fn, "available")) return K_MOD_AVAILABLE;
|
||||
if (!strcmp(iface, "modules") && !strcmp(fn, "loaded")) return K_MOD_LOADED;
|
||||
if (!strcmp(iface, "modules") && !strcmp(fn, "load-module")) return K_MOD_LOAD;
|
||||
|
||||
@@ -69,22 +69,6 @@ fn load_module(name : String) -> Plasmoid {
|
||||
}
|
||||
}
|
||||
|
||||
///| Like load_module, for a module that may not be built (e.g. moon-disc, which has no source
|
||||
/// in the tree): None, with a skip notice, when it isn't in build/components.
|
||||
fn load_optional_module(name : String) -> Plasmoid? {
|
||||
match load("build/components/" + name + ".wasm", test_tokens()) {
|
||||
Ok(p) => Some(p)
|
||||
Err(_) =>
|
||||
match load("../../build/components/" + name + ".wasm", test_tokens()) {
|
||||
Ok(p) => Some(p)
|
||||
Err(_) => {
|
||||
println("skip: \{name}.wasm is not in build/components (no source in the tree)")
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///|
|
||||
fn texts_of(ops : Array[@types.DrawOp]) -> Array[String] {
|
||||
let out : Array[String] = []
|
||||
@@ -199,7 +183,7 @@ test "the settings module's Panel tab lists host modules and asks to load, move,
|
||||
assert_true(p.imports().contains("modules"))
|
||||
let av = Table::new()
|
||||
for m in [
|
||||
("moon-disc", "Moon Phase (disc)", "/m/moon-disc.wasm", 0),
|
||||
("clock-binary", "Binary Clock", "/m/clock-binary.wasm", 0),
|
||||
("tasks", "Task Manager", "/m/tasks.wasm", 1),
|
||||
("clock-digital", "Digital Clock", "/m/clock-digital.wasm", 1),
|
||||
] {
|
||||
@@ -224,7 +208,7 @@ test "the settings module's Panel tab lists host modules and asks to load, move,
|
||||
None => fail("popup should be open")
|
||||
Some(ps) => {
|
||||
let ts = texts_of(ps.ops)
|
||||
assert_true(ts.contains("Moon Phase (disc)"))
|
||||
assert_true(ts.contains("Binary Clock"))
|
||||
assert_true(ts.contains("Clocks"))
|
||||
// The task manager is in the panel and one is enough: it is not offered again. A clock
|
||||
// can go in twice, so it is.
|
||||
@@ -246,7 +230,7 @@ test "the settings module's Panel tab lists host modules and asks to load, move,
|
||||
FaceUnlock(-1), // opening on the Session tab reads the face unlock status
|
||||
MoveInstance("w1", 1),
|
||||
UnloadInstance("w2"),
|
||||
LoadModule("/m/moon-disc.wasm"),
|
||||
LoadModule("/m/clock-binary.wasm"),
|
||||
Browse,
|
||||
])
|
||||
// Keys: Backspace removes the highlighted panel module, PageUp moves it.
|
||||
@@ -268,11 +252,7 @@ test "interface explorer module toggles through the inspector capability" {
|
||||
}
|
||||
|
||||
///|
|
||||
test "moon and digital clock modules render from the clock capability" {
|
||||
if load_optional_module("moon-disc") is Some(m) {
|
||||
assert_true(m.render(36, 36, test_tokens()).length() > 3)
|
||||
m.unload()
|
||||
}
|
||||
test "the digital clock module renders from the clock capability" {
|
||||
let c = load_module("clock-digital")
|
||||
let ts = texts_of(c.render(120, 36, test_tokens()))
|
||||
assert_true(ts[0].has_suffix("AM") || ts[0].has_suffix("PM")) // 12-hour by default
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
/// and never copy a frame through shared memory. Without it Mesa's EGL and Vulkan fall back to
|
||||
/// drawing on the CPU, whatever GPU the machine has.
|
||||
///
|
||||
/// The buffers live in the host (`@sys.dmabuf_*`); here are only ids. At each commit the host
|
||||
/// copies the buffer on the GPU and it is released at once, as an shm buffer is. The global is
|
||||
/// only advertised when the host draws on a GPU that reads such buffers.
|
||||
/// When the host draws on a GPU, buffers of any layout it samples are imported there; here are only
|
||||
/// ids. At each commit the host copies the buffer on the GPU and it is released at once, as an shm
|
||||
/// buffer is. When it draws on the CPU (and on the native build), only linear ARGB8888 and
|
||||
/// XRGB8888 buffers are taken: they are read by mapping them, like a one-buffer shm pool.
|
||||
|
||||
///| What the server needs of the host's GPU (a fake one in tests).
|
||||
pub(all) struct DmabufHost {
|
||||
@@ -71,12 +72,43 @@ fn ClientConn::drop_dmabufs(self : ClientConn, host : DmabufHost) -> Unit {
|
||||
self.dmabuf_buffers.clear()
|
||||
}
|
||||
|
||||
///| The formats the GPU reads, asked of the host once.
|
||||
pub fn WaylandServer::dmabuf_formats(self : WaylandServer) -> (UInt64, Array[(UInt, UInt64)]) {
|
||||
///| The render node's dev_t, from /sys/class/drm/renderD*/dev ("226:128"); 0 when there is none.
|
||||
fn render_node_dev() -> UInt64 {
|
||||
for minor = 128; minor < 192; minor = minor + 1 {
|
||||
let txt = @sys.read_proc_bytes("/sys/class/drm/renderD" + minor.to_string() + "/dev")
|
||||
if txt.length() == 0 {
|
||||
continue
|
||||
}
|
||||
let mut major = 0
|
||||
let mut mnr = 0
|
||||
let mut after = false
|
||||
for b in txt {
|
||||
let b = b.to_int()
|
||||
if b == 58 {
|
||||
after = true
|
||||
} else if b >= 48 && b <= 57 {
|
||||
if after {
|
||||
mnr = mnr * 10 + (b - 48)
|
||||
} else {
|
||||
major = major * 10 + (b - 48)
|
||||
}
|
||||
}
|
||||
}
|
||||
// glibc makedev() for a 12-bit major and an 8-bit minor (a render node's).
|
||||
return (((major & 0xfff) << 8) | (mnr & 0xff)).to_uint64()
|
||||
}
|
||||
0UL
|
||||
}
|
||||
|
||||
///| The formats the GPU reads, asked of the host once; without one those read by mapping.
|
||||
fn WaylandServer::dmabuf_formats(self : WaylandServer) -> (UInt64, Array[(UInt, UInt64)]) {
|
||||
match self.dmabuf_support {
|
||||
Some(s) => s
|
||||
None => {
|
||||
let s = (self.dmabuf_host.support)()
|
||||
let s = match (self.dmabuf_host.support)() {
|
||||
(_, []) => (render_node_dev(), [(0x34325241U, 0UL), (0x34325258U, 0UL)])
|
||||
gpu => gpu
|
||||
}
|
||||
self.dmabuf_support = Some(s)
|
||||
s
|
||||
}
|
||||
@@ -140,10 +172,11 @@ fn WaylandServer::dmabuf_feedback(self : WaylandServer, c : ClientConn, id : UIn
|
||||
}
|
||||
@sys.close_fd(fd)
|
||||
let w = WireWriter::new()
|
||||
w.array(dev_array(dev))
|
||||
let dev = if dev == 0UL { [] } else { dev_array(dev) }
|
||||
w.array(dev)
|
||||
c.send_msg(w.finish_msg(id, 2U)) // main_device
|
||||
let w = WireWriter::new()
|
||||
w.array(dev_array(dev))
|
||||
w.array(dev)
|
||||
c.send_msg(w.finish_msg(id, 4U)) // tranche_target_device
|
||||
let w = WireWriter::new()
|
||||
w.u32(0U)
|
||||
@@ -184,6 +217,33 @@ fn WaylandServer::dmabuf_request(
|
||||
}
|
||||
}
|
||||
|
||||
///| Take a linear buffer to be read by mapping it: it owns the fd, like a one-buffer pool that is
|
||||
/// already destroyed. False when it isn't one.
|
||||
fn ClientConn::map_dmabuf(
|
||||
self : ClientConn,
|
||||
p : DmabufParams,
|
||||
buf : UInt,
|
||||
width : Int,
|
||||
height : Int,
|
||||
fourcc : UInt,
|
||||
) -> Bool {
|
||||
guard p.planes is [(fd, 0U, offset, stride)] else { return false }
|
||||
let format = match fourcc {
|
||||
0x34325241U => 0
|
||||
0x34325258U => 1
|
||||
_ => return false
|
||||
}
|
||||
let offset = offset.reinterpret_as_int()
|
||||
let stride = stride.reinterpret_as_int()
|
||||
if p.modifier != 0UL || width <= 0 || height <= 0 || offset < 0 || stride < width * 4 {
|
||||
return false
|
||||
}
|
||||
p.planes.clear()
|
||||
self.shm_pools.set(buf, { fd, size: offset + stride * height, destroyed: true })
|
||||
self.shm_buffers.set(buf, { pool_id: buf, offset, width, height, stride, format })
|
||||
true
|
||||
}
|
||||
|
||||
///| A request on the zwp_linux_buffer_params_v1 `id`.
|
||||
fn WaylandServer::dmabuf_params_request(
|
||||
self : WaylandServer,
|
||||
@@ -236,9 +296,17 @@ fn WaylandServer::dmabuf_params_request(
|
||||
} else {
|
||||
(self.dmabuf_host.import_buffer)(planes, p.modifier, width, height, fourcc, (flags & 1U) != 0U)
|
||||
}
|
||||
let buf = if immed {
|
||||
want
|
||||
} else {
|
||||
let b = c.next_offer // any id of the server's
|
||||
c.next_offer = b + 1U
|
||||
b
|
||||
}
|
||||
let mapped = got == 0U && !p.used && flags == 0U && c.map_dmabuf(p, buf, width, height, fourcc)
|
||||
p.used = true
|
||||
p.close_fds()
|
||||
if got == 0U {
|
||||
if got == 0U && !mapped {
|
||||
@sys.log(
|
||||
"dmabuf: can't use a client's buffer (\{width}x\{height}, format 0x\{fourcc.to_string(radix=16)}, modifier 0x\{p.modifier.to_string(radix=16)}, \{planes.length()} planes)",
|
||||
)
|
||||
@@ -247,15 +315,10 @@ fn WaylandServer::dmabuf_params_request(
|
||||
return
|
||||
}
|
||||
}
|
||||
let buf = if immed {
|
||||
want
|
||||
} else {
|
||||
let b = c.next_offer // any id of the server's
|
||||
c.next_offer = b + 1U
|
||||
b
|
||||
}
|
||||
c.objects.set(buf, ObjBuffer(buf))
|
||||
c.dmabuf_buffers.set(buf, { id: got, width, height, opaque: fourcc_opaque(fourcc) })
|
||||
if !mapped {
|
||||
c.dmabuf_buffers.set(buf, { id: got, width, height, opaque: fourcc_opaque(fourcc) })
|
||||
}
|
||||
if !immed {
|
||||
let w = WireWriter::new()
|
||||
w.u32(buf)
|
||||
|
||||
@@ -137,7 +137,9 @@ struct SurfaceState {
|
||||
/// without a new attach (a client changing only its regions or geometry) neither shows the
|
||||
/// old buffer again nor releases it a second time: the client may already be drawing into it.
|
||||
mut attached_buffer : UInt?
|
||||
mut pending_frame_cb : UInt?
|
||||
/// Every wl_surface.frame callback since the last commit; a client may queue several (Zed
|
||||
/// and Mesa's EGL each do) and waits on all of them.
|
||||
pending_frame_cbs : Array[UInt]
|
||||
mut xdg_surface_id : UInt?
|
||||
mut window_id : UInt64?
|
||||
/// wl_surface.set_buffer_scale: the buffer is this many times the window's size.
|
||||
@@ -485,7 +487,7 @@ fn WaylandServer::next_serial(self : WaylandServer) -> UInt {
|
||||
}
|
||||
|
||||
///|
|
||||
fn emit_registry_globals(c : ClientConn, reg_id : UInt, dmabuf : Bool) -> Unit {
|
||||
fn emit_registry_globals(c : ClientConn, reg_id : UInt) -> Unit {
|
||||
let globals : Array[(UInt, String, UInt)] = [
|
||||
(1U, "wl_compositor", 5U),
|
||||
(2U, "wl_shm", 1U),
|
||||
@@ -499,10 +501,8 @@ fn emit_registry_globals(c : ClientConn, reg_id : UInt, dmabuf : Bool) -> Unit {
|
||||
(10U, "org_kde_kwin_server_decoration_manager", 1U),
|
||||
(11U, "zwp_primary_selection_device_manager_v1", 1U),
|
||||
(12U, "zwp_text_input_manager_v3", 1U),
|
||||
(13U, "zwp_linux_dmabuf_v1", 4U),
|
||||
]
|
||||
if dmabuf {
|
||||
globals.push((13U, "zwp_linux_dmabuf_v1", 4U))
|
||||
}
|
||||
for g in globals {
|
||||
let w = WireWriter::new()
|
||||
w.u32(g.0)
|
||||
@@ -698,7 +698,7 @@ fn WaylandServer::dispatch_msg(
|
||||
// get_registry(registry: new_id)
|
||||
let reg_id = reader.u32()
|
||||
c.objects.set(reg_id, ObjRegistry)
|
||||
emit_registry_globals(c, reg_id, self.dmabuf_formats().1.length() > 0)
|
||||
emit_registry_globals(c, reg_id)
|
||||
}
|
||||
ObjRegistry =>
|
||||
if opcode == 0U {
|
||||
@@ -752,7 +752,7 @@ fn WaylandServer::dispatch_msg(
|
||||
c.objects.set(sid, ObjSurface(sid))
|
||||
c.surfaces.set(sid, {
|
||||
attached_buffer: None,
|
||||
pending_frame_cb: None,
|
||||
pending_frame_cbs: [],
|
||||
xdg_surface_id: None,
|
||||
window_id: None,
|
||||
buffer_scale: 1,
|
||||
@@ -801,7 +801,7 @@ fn WaylandServer::dispatch_msg(
|
||||
} else if opcode == 3U {
|
||||
// frame(callback)
|
||||
let cb_id = reader.u32()
|
||||
surf.pending_frame_cb = Some(cb_id)
|
||||
surf.pending_frame_cbs.push(cb_id)
|
||||
} else if opcode == 10U {
|
||||
// offset(x, y) (version 5): moves the surface; for a drag icon, its hotspot.
|
||||
surf.pend_dx = surf.pend_dx + reader.i32()
|
||||
@@ -898,17 +898,14 @@ fn WaylandServer::dispatch_msg(
|
||||
None => ()
|
||||
}
|
||||
surf.attached_buffer = None
|
||||
match surf.pending_frame_cb {
|
||||
Some(cb_id) => {
|
||||
surf.pending_frame_cb = None
|
||||
if self.hold_frames {
|
||||
self.held_frames.push((c.client_id, cb_id))
|
||||
} else {
|
||||
self.frame_done(c, cb_id)
|
||||
}
|
||||
for cb_id in surf.pending_frame_cbs {
|
||||
if self.hold_frames {
|
||||
self.held_frames.push((c.client_id, cb_id))
|
||||
} else {
|
||||
self.frame_done(c, cb_id)
|
||||
}
|
||||
None => ()
|
||||
}
|
||||
surf.pending_frame_cbs.clear()
|
||||
}
|
||||
}
|
||||
ObjSubcompositor =>
|
||||
|
||||
Reference in new issue
Block a user