summaryrefslogtreecommitdiff
path: root/src/gui/gui.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/gui.zig')
-rw-r--r--src/gui/gui.zig17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/gui/gui.zig b/src/gui/gui.zig
index a0f0a3e4..f18f527b 100644
--- a/src/gui/gui.zig
+++ b/src/gui/gui.zig
@@ -1796,6 +1796,9 @@ const Gui = struct {
scene_target_failed: bool = false,
presented_scene: crt.Frame = .{},
pointer_present: bool = false,
+ arrow_cursor: ?*c.SDL_Cursor = null,
+ link_cursor: ?*c.SDL_Cursor = null,
+ pointer_shape: pardes.Surface.PointerShape = .arrow,
pointer_mapped: bool = false,
pointer_cell: ?MouseCell = null,
@@ -2113,7 +2116,11 @@ fn runNative(init: std.process.Init, opts_in: pardes.Options, attach: ?[]const u
return error.SdlInit;
};
if (native_wayland) log.info("Wayland opacity: background-only transparent surface", .{});
- if (c.SDL_CreateCursor(&p9_arrow_set, &p9_arrow_mask, 16, 16, 1, 1)) |cur| {
+ const arrow_cursor = c.SDL_CreateCursor(&p9_arrow_set, &p9_arrow_mask, 16, 16, 1, 1);
+ defer if (arrow_cursor) |cursor| c.SDL_DestroyCursor(cursor);
+ const link_cursor = c.SDL_CreateSystemCursor(c.SDL_SYSTEM_CURSOR_POINTER);
+ defer if (link_cursor) |cursor| c.SDL_DestroyCursor(cursor);
+ if (arrow_cursor) |cur| {
_ = c.SDL_SetCursor(cur);
} else log.err("SDL_CreateCursor: {s}", .{c.SDL_GetError()});
const device = c.SDL_CreateGPUDevice(c.SDL_GPU_SHADERFORMAT_SPIRV, true, null) orelse {
@@ -2238,6 +2245,8 @@ fn runNative(init: std.process.Init, opts_in: pardes.Options, attach: ?[]const u
var g: Gui = .{
.window = window,
+ .arrow_cursor = arrow_cursor,
+ .link_cursor = link_cursor,
.device = device,
.swapchain_format = swapchain_format,
.pipeline = pipeline,
@@ -2571,6 +2580,7 @@ fn paintAttached(g: *Gui, gpa: std.mem.Allocator, client: *detached_client.Clien
.rows = client.rows,
.cells = client.grid.items,
.cursor = if (client.cursor) |cu| .{ .x = cu.x, .y = cu.y, .bar = cu.bar } else null,
+ .pointer_shape = client.pointer_shape,
};
const chrome = frameChromeBg(&surface);
_ = renderFrame(
@@ -4742,6 +4752,11 @@ fn renderFrame(
scene_effects: pardes.layout.SceneEffect,
debug_on: bool,
) !bool {
+ if (surface.pointer_shape != g.pointer_shape) {
+ g.pointer_shape = surface.pointer_shape;
+ const cursor = if (g.pointer_shape == .link) g.link_cursor else g.arrow_cursor orelse c.SDL_GetDefaultCursor();
+ if (cursor) |value| _ = c.SDL_SetCursor(value);
+ }
g.scene_target_failed = false;
const cmd = c.SDL_AcquireGPUCommandBuffer(g.device) orelse return false;
var command_consumed = false;