Skip to content

Commit

Permalink
Firefox accepts pointer input
Browse files Browse the repository at this point in the history
  • Loading branch information
malcolmstill committed Mar 4, 2024
1 parent 3e7e3e0 commit b6b90a0
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions src/client.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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| {
Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit b6b90a0

Please sign in to comment.