From b6b90a04a7c5e27d3f1c4ffaf48f0c409a5e2ae3 Mon Sep 17 00:00:00 2001 From: Malcolm Still Date: Mon, 4 Mar 2024 22:03:45 +0000 Subject: [PATCH] Firefox accepts pointer input --- src/client.zig | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/client.zig b/src/client.zig index bdb75b6..eea1035 100644 --- a/src/client.zig +++ b/src/client.zig @@ -256,7 +256,7 @@ pub const Client = struct { .wl_data_offer => |_| return error.NotImplemented, .wl_data_source => |_| return error.NotImplemented, .wl_data_device => |_| return error.NotImplemented, - .wl_data_device_manager => |_| return error.NotImplemented, + .wl_data_device_manager => |msg| try client.dispatchWlDataDeviceManager(msg), .wl_shell => |_| return error.NotImplemented, .wl_shell_surface => |_| return error.NotImplemented, .wl_surface => |msg| try client.dispatchWlSurface(msg), @@ -298,7 +298,7 @@ pub const Client = struct { try wl_registry.sendGlobal(output.id, "wl_output\x00", 2); } - // try wl_registry.sendGlobal(6, "wl_data_device_manager\x00", 3); + try wl_registry.sendGlobal(6, "wl_data_device_manager\x00", 3); try wl_registry.sendGlobal(8, "wl_shm\x00", 1); // try wl_registry.sendGlobal(10, "zwp_linux_dmabuf_v1\x00", 3); try wl_registry.sendGlobal(11, "fw_control\x00", 1); @@ -332,13 +332,12 @@ pub const Client = struct { 3 => { if (!mem.eql(u8, msg.name_string, "wl_seat\x00")) return error.UnexpectedName; - if (client.wl_seat == null) { - client.wl_seat = wl.WlSeat.init(msg.id, &client.wire, msg.version, null); - } + const wl_seat = wl.WlSeat.init(msg.id, &client.wire, msg.version, null); + try wl_seat.sendCapabilities(.{ .pointer = true, .keyboard = true }); - try client.wl_seat.?.sendCapabilities(.{ .pointer = true, .keyboard = true }); + client.wl_seat = wl_seat; - try client.register(.{ .wl_seat = client.wl_seat.? }); + try client.register(.{ .wl_seat = wl_seat }); }, 4 => { if (!mem.eql(u8, msg.name_string, "xdg_wm_base\x00")) return error.UnexpectedName; @@ -480,6 +479,19 @@ pub const Client = struct { } } + pub fn dispatchWlDataDeviceManager(client: *Client, message: wl.WlDataDeviceManager.Message) !void { + switch (message) { + .create_data_source => |msg| { + const wl_data_source = wl.WlDataSource.init(msg.id, &client.wire, 0, {}); + try client.register(.{ .wl_data_source = wl_data_source }); + }, + .get_data_device => |msg| { + const wl_data_device = wl.WlDataDevice.init(msg.id, &client.wire, 0, {}); + try client.register(.{ .wl_data_device = wl_data_device }); + }, + } + } + pub fn dispatchWlSurface(client: *Client, message: wl.WlSurface.Message) !void { switch (message) { .commit => |msg| { @@ -658,7 +670,11 @@ pub const Client = struct { const wl_keyboard = wl.WlKeyboard.init(msg.id, &client.wire, 0, null); try client.register(.{ .wl_keyboard = wl_keyboard }); - if (client.wl_seat != null) client.wl_keyboard = wl_keyboard; + if (client.wl_seat) |client_wl_seat| { + if (client_wl_seat.id == msg.wl_seat.id) { + client.wl_keyboard = wl_keyboard; + } + } const fd_size = try client.server.xkb.getKeymap();