code: clean up listener initialization
This commit is contained in:
parent
3985b89d62
commit
cc08be2dee
18 changed files with 126 additions and 188 deletions
2
deps/zig-wayland
vendored
2
deps/zig-wayland
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit d693b3704ee73762c71a68d634ef1a538c3307bd
|
Subproject commit 0dd1bee2dea065d45ce674c5b3ece2fda38f775d
|
|
@ -37,7 +37,7 @@ global: *wl.Global,
|
||||||
|
|
||||||
args_map: std.AutoHashMap(u32, std.ArrayList([]const u8)),
|
args_map: std.AutoHashMap(u32, std.ArrayList([]const u8)),
|
||||||
|
|
||||||
server_destroy: wl.Listener(*wl.Server) = undefined,
|
server_destroy: wl.Listener(*wl.Server) = wl.Listener(*wl.Server).init(handleServerDestroy),
|
||||||
|
|
||||||
pub fn init(self: *Self, server: *Server) !void {
|
pub fn init(self: *Self, server: *Server) !void {
|
||||||
self.* = .{
|
self.* = .{
|
||||||
|
@ -45,7 +45,6 @@ pub fn init(self: *Self, server: *Server) !void {
|
||||||
.args_map = std.AutoHashMap(u32, std.ArrayList([]const u8)).init(util.gpa),
|
.args_map = std.AutoHashMap(u32, std.ArrayList([]const u8)).init(util.gpa),
|
||||||
};
|
};
|
||||||
|
|
||||||
self.server_destroy.setNotify(handleServerDestroy);
|
|
||||||
server.wl_server.addDestroyListener(&self.server_destroy);
|
server.wl_server.addDestroyListener(&self.server_destroy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,12 +61,18 @@ xcursor_manager: *wlr.XcursorManager,
|
||||||
/// Number of distinct buttons currently pressed
|
/// Number of distinct buttons currently pressed
|
||||||
pressed_count: u32 = 0,
|
pressed_count: u32 = 0,
|
||||||
|
|
||||||
axis: wl.Listener(*wlr.Pointer.event.Axis) = undefined,
|
axis: wl.Listener(*wlr.Pointer.event.Axis) = wl.Listener(*wlr.Pointer.event.Axis).init(handleAxis),
|
||||||
button: wl.Listener(*wlr.Pointer.event.Button) = undefined,
|
frame: wl.Listener(*wlr.Cursor) = wl.Listener(*wlr.Cursor).init(handleFrame),
|
||||||
frame: wl.Listener(*wlr.Cursor) = undefined,
|
// zig fmt: off
|
||||||
motion_absolute: wl.Listener(*wlr.Pointer.event.MotionAbsolute) = undefined,
|
button: wl.Listener(*wlr.Pointer.event.Button) =
|
||||||
motion: wl.Listener(*wlr.Pointer.event.Motion) = undefined,
|
wl.Listener(*wlr.Pointer.event.Button).init(handleButton),
|
||||||
request_set_cursor: wl.Listener(*wlr.Seat.event.RequestSetCursor) = undefined,
|
motion_absolute: wl.Listener(*wlr.Pointer.event.MotionAbsolute) =
|
||||||
|
wl.Listener(*wlr.Pointer.event.MotionAbsolute).init(handleMotionAbsolute),
|
||||||
|
motion: wl.Listener(*wlr.Pointer.event.Motion) =
|
||||||
|
wl.Listener(*wlr.Pointer.event.Motion).init(handleMotion),
|
||||||
|
request_set_cursor: wl.Listener(*wlr.Seat.event.RequestSetCursor) =
|
||||||
|
wl.Listener(*wlr.Seat.event.RequestSetCursor).init(handleRequestSetCursor),
|
||||||
|
// zig fmt: on
|
||||||
|
|
||||||
pub fn init(self: *Self, seat: *Seat) !void {
|
pub fn init(self: *Self, seat: *Seat) !void {
|
||||||
const wlr_cursor = try wlr.Cursor.create();
|
const wlr_cursor = try wlr.Cursor.create();
|
||||||
|
@ -92,23 +98,12 @@ pub fn init(self: *Self, seat: *Seat) !void {
|
||||||
// can choose how we want to process them, forwarding them to clients and
|
// can choose how we want to process them, forwarding them to clients and
|
||||||
// moving the cursor around. See following post for more detail:
|
// moving the cursor around. See following post for more detail:
|
||||||
// https://drewdevault.com/2018/07/17/Input-handling-in-wlroots.html
|
// https://drewdevault.com/2018/07/17/Input-handling-in-wlroots.html
|
||||||
self.axis.setNotify(handleAxis);
|
wlr_cursor.events.axis.add(&self.axis);
|
||||||
self.wlr_cursor.events.axis.add(&self.axis);
|
wlr_cursor.events.button.add(&self.button);
|
||||||
|
wlr_cursor.events.frame.add(&self.frame);
|
||||||
self.button.setNotify(handleButton);
|
wlr_cursor.events.motion_absolute.add(&self.motion_absolute);
|
||||||
self.wlr_cursor.events.button.add(&self.button);
|
wlr_cursor.events.motion.add(&self.motion);
|
||||||
|
seat.wlr_seat.events.request_set_cursor.add(&self.request_set_cursor);
|
||||||
self.frame.setNotify(handleFrame);
|
|
||||||
self.wlr_cursor.events.frame.add(&self.frame);
|
|
||||||
|
|
||||||
self.motion_absolute.setNotify(handleMotionAbsolute);
|
|
||||||
self.wlr_cursor.events.motion_absolute.add(&self.motion_absolute);
|
|
||||||
|
|
||||||
self.motion.setNotify(handleMotion);
|
|
||||||
self.wlr_cursor.events.motion.add(&self.motion);
|
|
||||||
|
|
||||||
self.request_set_cursor.setNotify(handleRequestSetCursor);
|
|
||||||
self.seat.wlr_seat.events.request_set_cursor.add(&self.request_set_cursor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn deinit(self: *Self) void {
|
pub fn deinit(self: *Self) void {
|
||||||
|
|
|
@ -29,8 +29,12 @@ server: *Server,
|
||||||
|
|
||||||
xdg_toplevel_decoration: *wlr.XdgToplevelDecorationV1,
|
xdg_toplevel_decoration: *wlr.XdgToplevelDecorationV1,
|
||||||
|
|
||||||
destroy: wl.Listener(*wlr.XdgToplevelDecorationV1) = undefined,
|
// zig fmt: off
|
||||||
request_mode: wl.Listener(*wlr.XdgToplevelDecorationV1) = undefined,
|
destroy: wl.Listener(*wlr.XdgToplevelDecorationV1) =
|
||||||
|
wl.Listener(*wlr.XdgToplevelDecorationV1).init(handleDestroy),
|
||||||
|
request_mode: wl.Listener(*wlr.XdgToplevelDecorationV1) =
|
||||||
|
wl.Listener(*wlr.XdgToplevelDecorationV1).init(handleRequestMode),
|
||||||
|
// zig fmt: on
|
||||||
|
|
||||||
pub fn init(
|
pub fn init(
|
||||||
self: *Self,
|
self: *Self,
|
||||||
|
@ -39,11 +43,8 @@ pub fn init(
|
||||||
) void {
|
) void {
|
||||||
self.* = .{ .server = server, .xdg_toplevel_decoration = xdg_toplevel_decoration };
|
self.* = .{ .server = server, .xdg_toplevel_decoration = xdg_toplevel_decoration };
|
||||||
|
|
||||||
self.destroy.setNotify(handleDestroy);
|
xdg_toplevel_decoration.events.destroy.add(&self.destroy);
|
||||||
self.xdg_toplevel_decoration.events.destroy.add(&self.destroy);
|
xdg_toplevel_decoration.events.request_mode.add(&self.request_mode);
|
||||||
|
|
||||||
self.request_mode.setNotify(handleRequestMode);
|
|
||||||
self.xdg_toplevel_decoration.events.request_mode.add(&self.request_mode);
|
|
||||||
|
|
||||||
handleRequestMode(&self.request_mode, self.xdg_toplevel_decoration);
|
handleRequestMode(&self.request_mode, self.xdg_toplevel_decoration);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,10 @@ server: *Server,
|
||||||
|
|
||||||
xdg_decoration_manager: *wlr.XdgDecorationManagerV1,
|
xdg_decoration_manager: *wlr.XdgDecorationManagerV1,
|
||||||
|
|
||||||
new_toplevel_decoration: wl.Listener(*wlr.XdgToplevelDecorationV1) = undefined,
|
// zig fmt: off
|
||||||
|
new_toplevel_decoration: wl.Listener(*wlr.XdgToplevelDecorationV1) =
|
||||||
|
wl.Listener(*wlr.XdgToplevelDecorationV1).init(handleNewToplevelDecoration),
|
||||||
|
// zig fmt: on
|
||||||
|
|
||||||
pub fn init(self: *Self, server: *Server) !void {
|
pub fn init(self: *Self, server: *Server) !void {
|
||||||
self.* = .{
|
self.* = .{
|
||||||
|
@ -38,7 +41,6 @@ pub fn init(self: *Self, server: *Server) !void {
|
||||||
.xdg_decoration_manager = try wlr.XdgDecorationManagerV1.create(server.wl_server),
|
.xdg_decoration_manager = try wlr.XdgDecorationManagerV1.create(server.wl_server),
|
||||||
};
|
};
|
||||||
|
|
||||||
self.new_toplevel_decoration.setNotify(handleNewToplevelDecoration);
|
|
||||||
self.xdg_decoration_manager.events.new_toplevel_decoration.add(&self.new_toplevel_decoration);
|
self.xdg_decoration_manager.events.new_toplevel_decoration.add(&self.new_toplevel_decoration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,12 +28,10 @@ const Seat = @import("Seat.zig");
|
||||||
seat: *Seat,
|
seat: *Seat,
|
||||||
wlr_drag_icon: *wlr.Drag.Icon,
|
wlr_drag_icon: *wlr.Drag.Icon,
|
||||||
|
|
||||||
destroy: wl.Listener(*wlr.Drag.Icon) = undefined,
|
destroy: wl.Listener(*wlr.Drag.Icon) = wl.Listener(*wlr.Drag.Icon).init(handleDestroy),
|
||||||
|
|
||||||
pub fn init(self: *Self, seat: *Seat, wlr_drag_icon: *wlr.Drag.Icon) void {
|
pub fn init(self: *Self, seat: *Seat, wlr_drag_icon: *wlr.Drag.Icon) void {
|
||||||
self.* = .{ .seat = seat, .wlr_drag_icon = wlr_drag_icon };
|
self.* = .{ .seat = seat, .wlr_drag_icon = wlr_drag_icon };
|
||||||
|
|
||||||
self.destroy.setNotify(handleDestroy);
|
|
||||||
wlr_drag_icon.events.destroy.add(&self.destroy);
|
wlr_drag_icon.events.destroy.add(&self.destroy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ const View = @import("View.zig");
|
||||||
const default_seat_name = "default";
|
const default_seat_name = "default";
|
||||||
|
|
||||||
server: *Server,
|
server: *Server,
|
||||||
|
new_input: wl.Listener(*wlr.InputDevice) = wl.Listener(*wlr.InputDevice).init(handleNewInput),
|
||||||
|
|
||||||
idle: *wlr.Idle,
|
idle: *wlr.Idle,
|
||||||
input_inhibit_manager: *wlr.InputInhibitManager,
|
input_inhibit_manager: *wlr.InputInhibitManager,
|
||||||
|
@ -42,11 +43,16 @@ seats: std.TailQueue(Seat) = .{},
|
||||||
|
|
||||||
exclusive_client: ?*wl.Client = null,
|
exclusive_client: ?*wl.Client = null,
|
||||||
|
|
||||||
inhibit_activate: wl.Listener(*wlr.InputInhibitManager) = undefined,
|
// zig fmt: off
|
||||||
inhibit_deactivate: wl.Listener(*wlr.InputInhibitManager) = undefined,
|
inhibit_activate: wl.Listener(*wlr.InputInhibitManager) =
|
||||||
new_input: wl.Listener(*wlr.InputDevice) = undefined,
|
wl.Listener(*wlr.InputInhibitManager).init(handleInhibitActivate),
|
||||||
new_virtual_pointer: wl.Listener(*wlr.VirtualPointerManagerV1.event.NewPointer) = undefined,
|
inhibit_deactivate: wl.Listener(*wlr.InputInhibitManager) =
|
||||||
new_virtual_keyboard: wl.Listener(*wlr.VirtualKeyboardV1) = undefined,
|
wl.Listener(*wlr.InputInhibitManager).init(handleInhibitDeactivate),
|
||||||
|
new_virtual_pointer: wl.Listener(*wlr.VirtualPointerManagerV1.event.NewPointer) =
|
||||||
|
wl.Listener(*wlr.VirtualPointerManagerV1.event.NewPointer).init(handleNewVirtualPointer),
|
||||||
|
new_virtual_keyboard: wl.Listener(*wlr.VirtualKeyboardV1) =
|
||||||
|
wl.Listener(*wlr.VirtualKeyboardV1).init(handleNewVirtualKeyboard),
|
||||||
|
// zig fmt: on
|
||||||
|
|
||||||
pub fn init(self: *Self, server: *Server) !void {
|
pub fn init(self: *Self, server: *Server) !void {
|
||||||
const seat_node = try util.gpa.create(std.TailQueue(Seat).Node);
|
const seat_node = try util.gpa.create(std.TailQueue(Seat).Node);
|
||||||
|
@ -66,19 +72,10 @@ pub fn init(self: *Self, server: *Server) !void {
|
||||||
|
|
||||||
if (build_options.xwayland) server.xwayland.setSeat(self.defaultSeat().wlr_seat);
|
if (build_options.xwayland) server.xwayland.setSeat(self.defaultSeat().wlr_seat);
|
||||||
|
|
||||||
self.inhibit_activate.setNotify(handleInhibitActivate);
|
server.backend.events.new_input.add(&self.new_input);
|
||||||
self.input_inhibit_manager.events.activate.add(&self.inhibit_activate);
|
self.input_inhibit_manager.events.activate.add(&self.inhibit_activate);
|
||||||
|
|
||||||
self.inhibit_deactivate.setNotify(handleInhibitDeactivate);
|
|
||||||
self.input_inhibit_manager.events.deactivate.add(&self.inhibit_deactivate);
|
self.input_inhibit_manager.events.deactivate.add(&self.inhibit_deactivate);
|
||||||
|
|
||||||
self.new_input.setNotify(handleNewInput);
|
|
||||||
self.server.backend.events.new_input.add(&self.new_input);
|
|
||||||
|
|
||||||
self.new_virtual_pointer.setNotify(handleNewVirtualPointer);
|
|
||||||
self.virtual_pointer_manager.events.new_virtual_pointer.add(&self.new_virtual_pointer);
|
self.virtual_pointer_manager.events.new_virtual_pointer.add(&self.new_virtual_pointer);
|
||||||
|
|
||||||
self.new_virtual_keyboard.setNotify(handleNewVirtualKeyboard);
|
|
||||||
self.virtual_keyboard_manager.events.new_virtual_keyboard.add(&self.new_virtual_keyboard);
|
self.virtual_keyboard_manager.events.new_virtual_keyboard.add(&self.new_virtual_keyboard);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,9 +30,9 @@ const Seat = @import("Seat.zig");
|
||||||
seat: *Seat,
|
seat: *Seat,
|
||||||
input_device: *wlr.InputDevice,
|
input_device: *wlr.InputDevice,
|
||||||
|
|
||||||
key: wl.Listener(*wlr.Keyboard.event.Key) = undefined,
|
key: wl.Listener(*wlr.Keyboard.event.Key) = wl.Listener(*wlr.Keyboard.event.Key).init(handleKey),
|
||||||
modifiers: wl.Listener(*wlr.Keyboard) = undefined,
|
modifiers: wl.Listener(*wlr.Keyboard) = wl.Listener(*wlr.Keyboard).init(handleModifiers),
|
||||||
destroy: wl.Listener(*wlr.Keyboard) = undefined,
|
destroy: wl.Listener(*wlr.Keyboard) = wl.Listener(*wlr.Keyboard).init(handleDestroy),
|
||||||
|
|
||||||
pub fn init(self: *Self, seat: *Seat, input_device: *wlr.InputDevice) !void {
|
pub fn init(self: *Self, seat: *Seat, input_device: *wlr.InputDevice) !void {
|
||||||
self.* = .{
|
self.* = .{
|
||||||
|
@ -62,13 +62,8 @@ pub fn init(self: *Self, seat: *Seat, input_device: *wlr.InputDevice) !void {
|
||||||
const config = &seat.input_manager.server.config;
|
const config = &seat.input_manager.server.config;
|
||||||
wlr_keyboard.setRepeatInfo(config.repeat_rate, config.repeat_delay);
|
wlr_keyboard.setRepeatInfo(config.repeat_rate, config.repeat_delay);
|
||||||
|
|
||||||
self.key.setNotify(handleKey);
|
|
||||||
wlr_keyboard.events.key.add(&self.key);
|
wlr_keyboard.events.key.add(&self.key);
|
||||||
|
|
||||||
self.modifiers.setNotify(handleModifiers);
|
|
||||||
wlr_keyboard.events.modifiers.add(&self.modifiers);
|
wlr_keyboard.events.modifiers.add(&self.modifiers);
|
||||||
|
|
||||||
self.destroy.setNotify(handleDestroy);
|
|
||||||
wlr_keyboard.events.destroy.add(&self.destroy);
|
wlr_keyboard.events.destroy.add(&self.destroy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,13 +35,13 @@ box: Box = undefined,
|
||||||
state: wlr.LayerSurfaceV1.State,
|
state: wlr.LayerSurfaceV1.State,
|
||||||
|
|
||||||
// Listeners active the entire lifetime of the layser surface
|
// Listeners active the entire lifetime of the layser surface
|
||||||
destroy: wl.Listener(*wlr.LayerSurfaceV1) = undefined,
|
destroy: wl.Listener(*wlr.LayerSurfaceV1) = wl.Listener(*wlr.LayerSurfaceV1).init(handleDestroy),
|
||||||
map: wl.Listener(*wlr.LayerSurfaceV1) = undefined,
|
map: wl.Listener(*wlr.LayerSurfaceV1) = wl.Listener(*wlr.LayerSurfaceV1).init(handleMap),
|
||||||
unmap: wl.Listener(*wlr.LayerSurfaceV1) = undefined,
|
unmap: wl.Listener(*wlr.LayerSurfaceV1) = wl.Listener(*wlr.LayerSurfaceV1).init(handleUnmap),
|
||||||
|
|
||||||
// Listeners only active while the layer surface is mapped
|
// Listeners only active while the layer surface is mapped
|
||||||
commit: wl.Listener(*wlr.Surface) = undefined,
|
commit: wl.Listener(*wlr.Surface) = wl.Listener(*wlr.Surface).init(handleCommit),
|
||||||
new_popup: wl.Listener(*wlr.XdgPopup) = undefined,
|
new_popup: wl.Listener(*wlr.XdgPopup) = wl.Listener(*wlr.XdgPopup).init(handleNewPopup),
|
||||||
|
|
||||||
pub fn init(self: *Self, output: *Output, wlr_layer_surface: *wlr.LayerSurfaceV1) void {
|
pub fn init(self: *Self, output: *Output, wlr_layer_surface: *wlr.LayerSurfaceV1) void {
|
||||||
self.* = .{
|
self.* = .{
|
||||||
|
@ -60,13 +60,8 @@ pub fn init(self: *Self, output: *Output, wlr_layer_surface: *wlr.LayerSurfaceV1
|
||||||
list.remove(node);
|
list.remove(node);
|
||||||
|
|
||||||
// Set up listeners that are active for the entire lifetime of the layer surface
|
// Set up listeners that are active for the entire lifetime of the layer surface
|
||||||
self.destroy.setNotify(handleDestroy);
|
|
||||||
self.wlr_layer_surface.events.destroy.add(&self.destroy);
|
self.wlr_layer_surface.events.destroy.add(&self.destroy);
|
||||||
|
|
||||||
self.map.setNotify(handleMap);
|
|
||||||
self.wlr_layer_surface.events.map.add(&self.map);
|
self.wlr_layer_surface.events.map.add(&self.map);
|
||||||
|
|
||||||
self.unmap.setNotify(handleUnmap);
|
|
||||||
self.wlr_layer_surface.events.unmap.add(&self.unmap);
|
self.wlr_layer_surface.events.unmap.add(&self.unmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,10 +85,7 @@ fn handleMap(listener: *wl.Listener(*wlr.LayerSurfaceV1), wlr_layer_surface: *wl
|
||||||
log.debug(.layer_shell, "layer surface '{}' mapped", .{wlr_layer_surface.namespace});
|
log.debug(.layer_shell, "layer surface '{}' mapped", .{wlr_layer_surface.namespace});
|
||||||
|
|
||||||
// Add listeners that are only active while mapped
|
// Add listeners that are only active while mapped
|
||||||
self.commit.setNotify(handleCommit);
|
|
||||||
wlr_layer_surface.surface.events.commit.add(&self.commit);
|
wlr_layer_surface.surface.events.commit.add(&self.commit);
|
||||||
|
|
||||||
self.new_popup.setNotify(handleNewPopup);
|
|
||||||
wlr_layer_surface.events.new_popup.add(&self.new_popup);
|
wlr_layer_surface.events.new_popup.add(&self.new_popup);
|
||||||
|
|
||||||
wlr_layer_surface.surface.sendEnter(wlr_layer_surface.output.?);
|
wlr_layer_surface.surface.sendEnter(wlr_layer_surface.output.?);
|
||||||
|
|
|
@ -76,10 +76,10 @@ attach_mode: AttachMode = .top,
|
||||||
/// List of status tracking objects relaying changes to this output to clients.
|
/// List of status tracking objects relaying changes to this output to clients.
|
||||||
status_trackers: std.SinglyLinkedList(OutputStatus) = .{},
|
status_trackers: std.SinglyLinkedList(OutputStatus) = .{},
|
||||||
|
|
||||||
destroy: wl.Listener(*wlr.Output) = undefined,
|
destroy: wl.Listener(*wlr.Output) = wl.Listener(*wlr.Output).init(handleDestroy),
|
||||||
enable: wl.Listener(*wlr.Output) = undefined,
|
enable: wl.Listener(*wlr.Output) = wl.Listener(*wlr.Output).init(handleEnable),
|
||||||
frame: wl.Listener(*wlr.Output) = undefined,
|
frame: wl.Listener(*wlr.Output) = wl.Listener(*wlr.Output).init(handleFrame),
|
||||||
mode: wl.Listener(*wlr.Output) = undefined,
|
mode: wl.Listener(*wlr.Output) = wl.Listener(*wlr.Output).init(handleMode),
|
||||||
|
|
||||||
pub fn init(self: *Self, root: *Root, wlr_output: *wlr.Output) !void {
|
pub fn init(self: *Self, root: *Root, wlr_output: *wlr.Output) !void {
|
||||||
// Some backends don't have modes. DRM+KMS does, and we need to set a mode
|
// Some backends don't have modes. DRM+KMS does, and we need to set a mode
|
||||||
|
@ -104,16 +104,9 @@ pub fn init(self: *Self, root: *Root, wlr_output: *wlr.Output) !void {
|
||||||
};
|
};
|
||||||
wlr_output.data = @ptrToInt(self);
|
wlr_output.data = @ptrToInt(self);
|
||||||
|
|
||||||
self.destroy.setNotify(handleDestroy);
|
|
||||||
wlr_output.events.destroy.add(&self.destroy);
|
wlr_output.events.destroy.add(&self.destroy);
|
||||||
|
|
||||||
self.enable.setNotify(handleEnable);
|
|
||||||
wlr_output.events.enable.add(&self.enable);
|
wlr_output.events.enable.add(&self.enable);
|
||||||
|
|
||||||
self.frame.setNotify(handleFrame);
|
|
||||||
wlr_output.events.frame.add(&self.frame);
|
wlr_output.events.frame.add(&self.frame);
|
||||||
|
|
||||||
self.mode.setNotify(handleMode);
|
|
||||||
wlr_output.events.mode.add(&self.mode);
|
wlr_output.events.mode.add(&self.mode);
|
||||||
|
|
||||||
if (wlr_output.isNoop()) {
|
if (wlr_output.isNoop()) {
|
||||||
|
|
|
@ -41,17 +41,22 @@ const DragIcon = @import("DragIcon.zig");
|
||||||
const min_size = 50;
|
const min_size = 50;
|
||||||
|
|
||||||
server: *Server,
|
server: *Server,
|
||||||
new_output: wl.Listener(*wlr.Output) = undefined,
|
new_output: wl.Listener(*wlr.Output) = wl.Listener(*wlr.Output).init(handleNewOutput),
|
||||||
|
|
||||||
output_layout: *wlr.OutputLayout,
|
output_layout: *wlr.OutputLayout,
|
||||||
layout_change: wl.Listener(*wlr.OutputLayout) = undefined,
|
layout_change: wl.Listener(*wlr.OutputLayout) = wl.Listener(*wlr.OutputLayout).init(handleLayoutChange),
|
||||||
|
|
||||||
|
// zig fmt: off
|
||||||
output_manager: *wlr.OutputManagerV1,
|
output_manager: *wlr.OutputManagerV1,
|
||||||
manager_apply: wl.Listener(*wlr.OutputConfigurationV1) = undefined,
|
manager_apply: wl.Listener(*wlr.OutputConfigurationV1) =
|
||||||
manager_test: wl.Listener(*wlr.OutputConfigurationV1) = undefined,
|
wl.Listener(*wlr.OutputConfigurationV1).init(handleManagerApply),
|
||||||
|
manager_test: wl.Listener(*wlr.OutputConfigurationV1) =
|
||||||
|
wl.Listener(*wlr.OutputConfigurationV1).init(handleManagerTest),
|
||||||
|
|
||||||
power_manager: *wlr.OutputPowerManagerV1,
|
power_manager: *wlr.OutputPowerManagerV1,
|
||||||
power_manager_set_mode: wl.Listener(*wlr.OutputPowerManagerV1.event.SetMode) = undefined,
|
power_manager_set_mode: wl.Listener(*wlr.OutputPowerManagerV1.event.SetMode) =
|
||||||
|
wl.Listener(*wlr.OutputPowerManagerV1.event.SetMode).init(handlePowerManagerSetMode),
|
||||||
|
// zig fmt: on
|
||||||
|
|
||||||
/// A list of all outputs
|
/// A list of all outputs
|
||||||
all_outputs: std.TailQueue(*Output) = .{},
|
all_outputs: std.TailQueue(*Output) = .{},
|
||||||
|
@ -97,19 +102,10 @@ pub fn init(self: *Self, server: *Server) !void {
|
||||||
const noop_wlr_output = try server.noop_backend.noopAddOutput();
|
const noop_wlr_output = try server.noop_backend.noopAddOutput();
|
||||||
try self.noop_output.init(self, noop_wlr_output);
|
try self.noop_output.init(self, noop_wlr_output);
|
||||||
|
|
||||||
self.new_output.setNotify(handleNewOutput);
|
|
||||||
server.backend.events.new_output.add(&self.new_output);
|
server.backend.events.new_output.add(&self.new_output);
|
||||||
|
|
||||||
self.manager_apply.setNotify(handleOutputManagerApply);
|
|
||||||
self.output_manager.events.apply.add(&self.manager_apply);
|
self.output_manager.events.apply.add(&self.manager_apply);
|
||||||
|
|
||||||
self.manager_test.setNotify(handleOutputManagerTest);
|
|
||||||
self.output_manager.events.@"test".add(&self.manager_test);
|
self.output_manager.events.@"test".add(&self.manager_test);
|
||||||
|
|
||||||
self.layout_change.setNotify(handleOutputLayoutChange);
|
|
||||||
self.output_layout.events.change.add(&self.layout_change);
|
self.output_layout.events.change.add(&self.layout_change);
|
||||||
|
|
||||||
self.power_manager_set_mode.setNotify(handleOutputPowerManagementSetMode);
|
|
||||||
self.power_manager.events.set_mode.add(&self.power_manager_set_mode);
|
self.power_manager.events.set_mode.add(&self.power_manager_set_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -389,7 +385,7 @@ fn commitTransaction(self: *Self) void {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Send the new output configuration to all wlr-output-manager clients
|
/// Send the new output configuration to all wlr-output-manager clients
|
||||||
fn handleOutputLayoutChange(
|
fn handleLayoutChange(
|
||||||
listener: *wl.Listener(*wlr.OutputLayout),
|
listener: *wl.Listener(*wlr.OutputLayout),
|
||||||
output_layout: *wlr.OutputLayout,
|
output_layout: *wlr.OutputLayout,
|
||||||
) void {
|
) void {
|
||||||
|
@ -402,7 +398,7 @@ fn handleOutputLayoutChange(
|
||||||
self.output_manager.setConfiguration(config);
|
self.output_manager.setConfiguration(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handleOutputManagerApply(
|
fn handleManagerApply(
|
||||||
listener: *wl.Listener(*wlr.OutputConfigurationV1),
|
listener: *wl.Listener(*wlr.OutputConfigurationV1),
|
||||||
config: *wlr.OutputConfigurationV1,
|
config: *wlr.OutputConfigurationV1,
|
||||||
) void {
|
) void {
|
||||||
|
@ -423,7 +419,7 @@ fn handleOutputManagerApply(
|
||||||
self.output_manager.setConfiguration(applied_config);
|
self.output_manager.setConfiguration(applied_config);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handleOutputManagerTest(
|
fn handleManagerTest(
|
||||||
listener: *wl.Listener(*wlr.OutputConfigurationV1),
|
listener: *wl.Listener(*wlr.OutputConfigurationV1),
|
||||||
config: *wlr.OutputConfigurationV1,
|
config: *wlr.OutputConfigurationV1,
|
||||||
) void {
|
) void {
|
||||||
|
@ -560,7 +556,7 @@ fn createHead(self: *Self, output: *Output, config: *wlr.OutputConfigurationV1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handleOutputPowerManagementSetMode(
|
fn handlePowerManagerSetMode(
|
||||||
listener: *wl.Listener(*wlr.OutputPowerManagerV1.event.SetMode),
|
listener: *wl.Listener(*wlr.OutputPowerManagerV1.event.SetMode),
|
||||||
event: *wlr.OutputPowerManagerV1.event.SetMode,
|
event: *wlr.OutputPowerManagerV1.event.SetMode,
|
||||||
) void {
|
) void {
|
||||||
|
|
|
@ -72,10 +72,15 @@ focus_stack: ViewStack(*View) = .{},
|
||||||
/// List of status tracking objects relaying changes to this seat to clients.
|
/// List of status tracking objects relaying changes to this seat to clients.
|
||||||
status_trackers: std.SinglyLinkedList(SeatStatus) = .{},
|
status_trackers: std.SinglyLinkedList(SeatStatus) = .{},
|
||||||
|
|
||||||
request_set_selection: wl.Listener(*wlr.Seat.event.RequestSetSelection) = undefined,
|
// zig fmt: off
|
||||||
request_start_drag: wl.Listener(*wlr.Seat.event.RequestStartDrag) = undefined,
|
request_set_selection: wl.Listener(*wlr.Seat.event.RequestSetSelection) =
|
||||||
start_drag: wl.Listener(*wlr.Drag) = undefined,
|
wl.Listener(*wlr.Seat.event.RequestSetSelection).init(handleRequestSetSelection),
|
||||||
request_set_primary_selection: wl.Listener(*wlr.Seat.event.RequestSetPrimarySelection) = undefined,
|
request_start_drag: wl.Listener(*wlr.Seat.event.RequestStartDrag) =
|
||||||
|
wl.Listener(*wlr.Seat.event.RequestStartDrag).init(handleRequestStartDrag),
|
||||||
|
start_drag: wl.Listener(*wlr.Drag) = wl.Listener(*wlr.Drag).init(handleStartDrag),
|
||||||
|
request_set_primary_selection: wl.Listener(*wlr.Seat.event.RequestSetPrimarySelection) =
|
||||||
|
wl.Listener(*wlr.Seat.event.RequestSetPrimarySelection).init(handleRequestSetPrimarySelection),
|
||||||
|
// zig fmt: on
|
||||||
|
|
||||||
pub fn init(self: *Self, input_manager: *InputManager, name: [*:0]const u8) !void {
|
pub fn init(self: *Self, input_manager: *InputManager, name: [*:0]const u8) !void {
|
||||||
self.* = .{
|
self.* = .{
|
||||||
|
@ -88,16 +93,9 @@ pub fn init(self: *Self, input_manager: *InputManager, name: [*:0]const u8) !voi
|
||||||
|
|
||||||
try self.cursor.init(self);
|
try self.cursor.init(self);
|
||||||
|
|
||||||
self.request_set_selection.setNotify(handleRequestSetSelection);
|
|
||||||
self.wlr_seat.events.request_set_selection.add(&self.request_set_selection);
|
self.wlr_seat.events.request_set_selection.add(&self.request_set_selection);
|
||||||
|
|
||||||
self.request_start_drag.setNotify(handleRequestStartDrag);
|
|
||||||
self.wlr_seat.events.request_start_drag.add(&self.request_start_drag);
|
self.wlr_seat.events.request_start_drag.add(&self.request_start_drag);
|
||||||
|
|
||||||
self.start_drag.setNotify(handleStartDrag);
|
|
||||||
self.wlr_seat.events.start_drag.add(&self.start_drag);
|
self.wlr_seat.events.start_drag.add(&self.start_drag);
|
||||||
|
|
||||||
self.request_set_primary_selection.setNotify(handleRequestPrimarySelection);
|
|
||||||
self.wlr_seat.events.request_set_primary_selection.add(&self.request_set_primary_selection);
|
self.wlr_seat.events.request_set_primary_selection.add(&self.request_set_primary_selection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -399,7 +397,7 @@ fn handleStartDrag(
|
||||||
self.cursor.mode = .passthrough;
|
self.cursor.mode = .passthrough;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handleRequestPrimarySelection(
|
fn handleRequestSetPrimarySelection(
|
||||||
listener: *wl.Listener(*wlr.Seat.event.RequestSetPrimarySelection),
|
listener: *wl.Listener(*wlr.Seat.event.RequestSetPrimarySelection),
|
||||||
event: *wlr.Seat.event.RequestSetPrimarySelection,
|
event: *wlr.Seat.event.RequestSetPrimarySelection,
|
||||||
) void {
|
) void {
|
||||||
|
|
|
@ -34,14 +34,13 @@ const Server = @import("Server.zig");
|
||||||
|
|
||||||
global: *wl.Global,
|
global: *wl.Global,
|
||||||
|
|
||||||
server_destroy: wl.Listener(*wl.Server) = undefined,
|
server_destroy: wl.Listener(*wl.Server) = wl.Listener(*wl.Server).init(handleServerDestroy),
|
||||||
|
|
||||||
pub fn init(self: *Self, server: *Server) !void {
|
pub fn init(self: *Self, server: *Server) !void {
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.global = try wl.Global.create(server.wl_server, zriver.StatusManagerV1, 1, *Self, self, bind),
|
.global = try wl.Global.create(server.wl_server, zriver.StatusManagerV1, 1, *Self, self, bind),
|
||||||
};
|
};
|
||||||
|
|
||||||
self.server_destroy.setNotify(handleServerDestroy);
|
|
||||||
server.wl_server.addDestroyListener(&self.server_destroy);
|
server.wl_server.addDestroyListener(&self.server_destroy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -126,9 +126,14 @@ draw_borders: bool = true,
|
||||||
|
|
||||||
/// This is created when the view is mapped and destroyed with the view
|
/// This is created when the view is mapped and destroyed with the view
|
||||||
foreign_toplevel_handle: ?*wlr.ForeignToplevelHandleV1 = null,
|
foreign_toplevel_handle: ?*wlr.ForeignToplevelHandleV1 = null,
|
||||||
foreign_activate: wl.Listener(*wlr.ForeignToplevelHandleV1.event.Activated) = undefined,
|
// zig fmt: off
|
||||||
foreign_fullscreen: wl.Listener(*wlr.ForeignToplevelHandleV1.event.Fullscreen) = undefined,
|
foreign_activate: wl.Listener(*wlr.ForeignToplevelHandleV1.event.Activated) =
|
||||||
foreign_close: wl.Listener(*wlr.ForeignToplevelHandleV1) = undefined,
|
wl.Listener(*wlr.ForeignToplevelHandleV1.event.Activated).init(handleForeignActivate),
|
||||||
|
foreign_fullscreen: wl.Listener(*wlr.ForeignToplevelHandleV1.event.Fullscreen) =
|
||||||
|
wl.Listener(*wlr.ForeignToplevelHandleV1.event.Fullscreen).init(handleForeignFullscreen),
|
||||||
|
foreign_close: wl.Listener(*wlr.ForeignToplevelHandleV1) =
|
||||||
|
wl.Listener(*wlr.ForeignToplevelHandleV1).init(handleForeignClose),
|
||||||
|
// zig fmt: on
|
||||||
|
|
||||||
pub fn init(self: *Self, output: *Output, tags: u32, surface: anytype) void {
|
pub fn init(self: *Self, output: *Output, tags: u32, surface: anytype) void {
|
||||||
self.* = .{
|
self.* = .{
|
||||||
|
@ -369,8 +374,8 @@ pub fn getAppId(self: Self) ?[*:0]const u8 {
|
||||||
pub fn applyConstraints(self: *Self) void {
|
pub fn applyConstraints(self: *Self) void {
|
||||||
const constraints = self.getConstraints();
|
const constraints = self.getConstraints();
|
||||||
const box = &self.pending.box;
|
const box = &self.pending.box;
|
||||||
box.width = std.math.clamp(box.width, constraints.min_width, constraints.max_width);
|
box.width = math.clamp(box.width, constraints.min_width, constraints.max_width);
|
||||||
box.height = std.math.clamp(box.height, constraints.min_height, constraints.max_height);
|
box.height = math.clamp(box.height, constraints.min_height, constraints.max_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return bounds on the dimensions of the view
|
/// Return bounds on the dimensions of the view
|
||||||
|
@ -448,13 +453,8 @@ pub fn map(self: *Self) void {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
self.foreign_activate.setNotify(handleForeignActivate);
|
|
||||||
self.foreign_toplevel_handle.?.events.request_activate.add(&self.foreign_activate);
|
self.foreign_toplevel_handle.?.events.request_activate.add(&self.foreign_activate);
|
||||||
|
|
||||||
self.foreign_fullscreen.setNotify(handleForeignFullscreen);
|
|
||||||
self.foreign_toplevel_handle.?.events.request_fullscreen.add(&self.foreign_fullscreen);
|
self.foreign_toplevel_handle.?.events.request_fullscreen.add(&self.foreign_fullscreen);
|
||||||
|
|
||||||
self.foreign_close.setNotify(handleForeignClose);
|
|
||||||
self.foreign_toplevel_handle.?.events.request_close.add(&self.foreign_close);
|
self.foreign_toplevel_handle.?.events.request_close.add(&self.foreign_close);
|
||||||
|
|
||||||
if (self.getTitle()) |s| self.foreign_toplevel_handle.?.setTitle(s);
|
if (self.getTitle()) |s| self.foreign_toplevel_handle.?.setTitle(s);
|
||||||
|
|
|
@ -36,8 +36,8 @@ parent_box: *const Box,
|
||||||
/// The corresponding wlroots object
|
/// The corresponding wlroots object
|
||||||
wlr_xdg_popup: *wlr.XdgPopup,
|
wlr_xdg_popup: *wlr.XdgPopup,
|
||||||
|
|
||||||
destroy: wl.Listener(*wlr.XdgSurface) = undefined,
|
destroy: wl.Listener(*wlr.XdgSurface) = wl.Listener(*wlr.XdgSurface).init(handleDestroy),
|
||||||
new_popup: wl.Listener(*wlr.XdgPopup) = undefined,
|
new_popup: wl.Listener(*wlr.XdgPopup) = wl.Listener(*wlr.XdgPopup).init(handleNewPopup),
|
||||||
|
|
||||||
pub fn init(self: *Self, output: *Output, parent_box: *const Box, wlr_xdg_popup: *wlr.XdgPopup) void {
|
pub fn init(self: *Self, output: *Output, parent_box: *const Box, wlr_xdg_popup: *wlr.XdgPopup) void {
|
||||||
self.* = .{
|
self.* = .{
|
||||||
|
@ -52,10 +52,7 @@ pub fn init(self: *Self, output: *Output, parent_box: *const Box, wlr_xdg_popup:
|
||||||
box.y -= parent_box.y;
|
box.y -= parent_box.y;
|
||||||
wlr_xdg_popup.unconstrainFromBox(&box);
|
wlr_xdg_popup.unconstrainFromBox(&box);
|
||||||
|
|
||||||
self.destroy.setNotify(handleDestroy);
|
|
||||||
wlr_xdg_popup.base.events.destroy.add(&self.destroy);
|
wlr_xdg_popup.base.events.destroy.add(&self.destroy);
|
||||||
|
|
||||||
self.new_popup.setNotify(handleNewPopup);
|
|
||||||
wlr_xdg_popup.base.events.new_popup.add(&self.new_popup);
|
wlr_xdg_popup.base.events.new_popup.add(&self.new_popup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,30 +37,30 @@ view: *View,
|
||||||
xdg_surface: *wlr.XdgSurface,
|
xdg_surface: *wlr.XdgSurface,
|
||||||
|
|
||||||
// Listeners that are always active over the view's lifetime
|
// Listeners that are always active over the view's lifetime
|
||||||
destroy: wl.Listener(*wlr.XdgSurface) = undefined,
|
destroy: wl.Listener(*wlr.XdgSurface) = wl.Listener(*wlr.XdgSurface).init(handleDestroy),
|
||||||
map: wl.Listener(*wlr.XdgSurface) = undefined,
|
map: wl.Listener(*wlr.XdgSurface) = wl.Listener(*wlr.XdgSurface).init(handleMap),
|
||||||
unmap: wl.Listener(*wlr.XdgSurface) = undefined,
|
unmap: wl.Listener(*wlr.XdgSurface) = wl.Listener(*wlr.XdgSurface).init(handleUnmap),
|
||||||
|
|
||||||
// Listeners that are only active while the view is mapped
|
// Listeners that are only active while the view is mapped
|
||||||
commit: wl.Listener(*wlr.Surface) = undefined,
|
commit: wl.Listener(*wlr.Surface) = wl.Listener(*wlr.Surface).init(handleCommit),
|
||||||
new_popup: wl.Listener(*wlr.XdgPopup) = undefined,
|
new_popup: wl.Listener(*wlr.XdgPopup) = wl.Listener(*wlr.XdgPopup).init(handleNewPopup),
|
||||||
request_fullscreen: wl.Listener(*wlr.XdgToplevel.event.SetFullscreen) = undefined,
|
// zig fmt: off
|
||||||
request_move: wl.Listener(*wlr.XdgToplevel.event.Move) = undefined,
|
request_fullscreen: wl.Listener(*wlr.XdgToplevel.event.SetFullscreen) =
|
||||||
request_resize: wl.Listener(*wlr.XdgToplevel.event.Resize) = undefined,
|
wl.Listener(*wlr.XdgToplevel.event.SetFullscreen).init(handleRequestFullscreen),
|
||||||
set_title: wl.Listener(*wlr.XdgSurface) = undefined,
|
request_move: wl.Listener(*wlr.XdgToplevel.event.Move) =
|
||||||
|
wl.Listener(*wlr.XdgToplevel.event.Move).init(handleRequestMove),
|
||||||
|
request_resize: wl.Listener(*wlr.XdgToplevel.event.Resize) =
|
||||||
|
wl.Listener(*wlr.XdgToplevel.event.Resize).init(handleRequestResize),
|
||||||
|
// zig fmt: on
|
||||||
|
set_title: wl.Listener(*wlr.XdgSurface) = wl.Listener(*wlr.XdgSurface).init(handleSetTitle),
|
||||||
|
|
||||||
pub fn init(self: *Self, view: *View, xdg_surface: *wlr.XdgSurface) void {
|
pub fn init(self: *Self, view: *View, xdg_surface: *wlr.XdgSurface) void {
|
||||||
self.* = .{ .view = view, .xdg_surface = xdg_surface };
|
self.* = .{ .view = view, .xdg_surface = xdg_surface };
|
||||||
xdg_surface.data = @ptrToInt(self);
|
xdg_surface.data = @ptrToInt(self);
|
||||||
|
|
||||||
// Add listeners that are active over the view's entire lifetime
|
// Add listeners that are active over the view's entire lifetime
|
||||||
self.destroy.setNotify(handleDestroy);
|
|
||||||
self.xdg_surface.events.destroy.add(&self.destroy);
|
self.xdg_surface.events.destroy.add(&self.destroy);
|
||||||
|
|
||||||
self.map.setNotify(handleMap);
|
|
||||||
self.xdg_surface.events.map.add(&self.map);
|
self.xdg_surface.events.map.add(&self.map);
|
||||||
|
|
||||||
self.unmap.setNotify(handleUnmap);
|
|
||||||
self.xdg_surface.events.unmap.add(&self.unmap);
|
self.xdg_surface.events.unmap.add(&self.unmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,22 +159,11 @@ fn handleMap(listener: *wl.Listener(*wlr.XdgSurface), xdg_surface: *wlr.XdgSurfa
|
||||||
const toplevel = self.xdg_surface.role_data.toplevel;
|
const toplevel = self.xdg_surface.role_data.toplevel;
|
||||||
|
|
||||||
// Add listeners that are only active while mapped
|
// Add listeners that are only active while mapped
|
||||||
self.commit.setNotify(handleCommit);
|
|
||||||
self.xdg_surface.surface.events.commit.add(&self.commit);
|
self.xdg_surface.surface.events.commit.add(&self.commit);
|
||||||
|
|
||||||
self.new_popup.setNotify(handleNewPopup);
|
|
||||||
self.xdg_surface.events.new_popup.add(&self.new_popup);
|
self.xdg_surface.events.new_popup.add(&self.new_popup);
|
||||||
|
|
||||||
self.request_fullscreen.setNotify(handleRequestFullscreen);
|
|
||||||
toplevel.events.request_fullscreen.add(&self.request_fullscreen);
|
toplevel.events.request_fullscreen.add(&self.request_fullscreen);
|
||||||
|
|
||||||
self.request_move.setNotify(handleRequestMove);
|
|
||||||
toplevel.events.request_move.add(&self.request_move);
|
toplevel.events.request_move.add(&self.request_move);
|
||||||
|
|
||||||
self.request_resize.setNotify(handleRequestResize);
|
|
||||||
toplevel.events.request_resize.add(&self.request_resize);
|
toplevel.events.request_resize.add(&self.request_resize);
|
||||||
|
|
||||||
self.set_title.setNotify(handleSetTitle);
|
|
||||||
toplevel.events.set_title.add(&self.set_title);
|
toplevel.events.set_title.add(&self.set_title);
|
||||||
|
|
||||||
view.surface = self.xdg_surface.surface;
|
view.surface = self.xdg_surface.surface;
|
||||||
|
|
|
@ -32,28 +32,24 @@ root: *Root,
|
||||||
xwayland_surface: *wlr.XwaylandSurface,
|
xwayland_surface: *wlr.XwaylandSurface,
|
||||||
|
|
||||||
// Listeners that are always active over the view's lifetime
|
// Listeners that are always active over the view's lifetime
|
||||||
request_configure: wl.Listener(*wlr.XwaylandSurface.event.Configure) = undefined,
|
// zig fmt: off
|
||||||
destroy: wl.Listener(*wlr.XwaylandSurface) = undefined,
|
request_configure: wl.Listener(*wlr.XwaylandSurface.event.Configure) =
|
||||||
map: wl.Listener(*wlr.XwaylandSurface) = undefined,
|
wl.Listener(*wlr.XwaylandSurface.event.Configure).init(handleRequestConfigure),
|
||||||
unmap: wl.Listener(*wlr.XwaylandSurface) = undefined,
|
// zig fmt: on
|
||||||
|
destroy: wl.Listener(*wlr.XwaylandSurface) = wl.Listener(*wlr.XwaylandSurface).init(handleDestroy),
|
||||||
|
map: wl.Listener(*wlr.XwaylandSurface) = wl.Listener(*wlr.XwaylandSurface).init(handleMap),
|
||||||
|
unmap: wl.Listener(*wlr.XwaylandSurface) = wl.Listener(*wlr.XwaylandSurface).init(handleUnmap),
|
||||||
|
|
||||||
// Listeners that are only active while the view is mapped
|
// Listeners that are only active while the view is mapped
|
||||||
commit: wl.Listener(*wlr.Surface) = undefined,
|
commit: wl.Listener(*wlr.Surface) = wl.Listener(*wlr.Surface).init(handleCommit),
|
||||||
|
|
||||||
pub fn init(self: *Self, root: *Root, xwayland_surface: *wlr.XwaylandSurface) void {
|
pub fn init(self: *Self, root: *Root, xwayland_surface: *wlr.XwaylandSurface) void {
|
||||||
self.* = .{ .root = root, .xwayland_surface = xwayland_surface };
|
self.* = .{ .root = root, .xwayland_surface = xwayland_surface };
|
||||||
|
|
||||||
// Add listeners that are active over the view's entire lifetime
|
// Add listeners that are active over the view's entire lifetime
|
||||||
self.request_configure.setNotify(handleRequestConfigure);
|
|
||||||
xwayland_surface.events.request_configure.add(&self.request_configure);
|
xwayland_surface.events.request_configure.add(&self.request_configure);
|
||||||
|
|
||||||
self.destroy.setNotify(handleDestroy);
|
|
||||||
xwayland_surface.events.destroy.add(&self.destroy);
|
xwayland_surface.events.destroy.add(&self.destroy);
|
||||||
|
|
||||||
self.map.setNotify(handleMap);
|
|
||||||
xwayland_surface.events.map.add(&self.map);
|
xwayland_surface.events.map.add(&self.map);
|
||||||
|
|
||||||
self.unmap.setNotify(handleUnmap);
|
|
||||||
xwayland_surface.events.unmap.add(&self.unmap);
|
xwayland_surface.events.unmap.add(&self.unmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +96,6 @@ fn handleMap(listener: *wl.Listener(*wlr.XwaylandSurface), xwayland_surface: *wl
|
||||||
root.xwayland_unmanaged_views.prepend(node);
|
root.xwayland_unmanaged_views.prepend(node);
|
||||||
|
|
||||||
// Add listeners that are only active while mapped
|
// Add listeners that are only active while mapped
|
||||||
self.commit.setNotify(handleCommit);
|
|
||||||
xwayland_surface.surface.?.events.commit.add(&self.commit);
|
xwayland_surface.surface.?.events.commit.add(&self.commit);
|
||||||
|
|
||||||
// TODO: handle keyboard focus
|
// TODO: handle keyboard focus
|
||||||
|
|
|
@ -34,30 +34,23 @@ view: *View,
|
||||||
xwayland_surface: *wlr.XwaylandSurface,
|
xwayland_surface: *wlr.XwaylandSurface,
|
||||||
|
|
||||||
// Listeners that are always active over the view's lifetime
|
// Listeners that are always active over the view's lifetime
|
||||||
destroy: wl.Listener(*wlr.XwaylandSurface) = undefined,
|
destroy: wl.Listener(*wlr.XwaylandSurface) = wl.Listener(*wlr.XwaylandSurface).init(handleDestroy),
|
||||||
map: wl.Listener(*wlr.XwaylandSurface) = undefined,
|
map: wl.Listener(*wlr.XwaylandSurface) = wl.Listener(*wlr.XwaylandSurface).init(handleMap),
|
||||||
unmap: wl.Listener(*wlr.XwaylandSurface) = undefined,
|
unmap: wl.Listener(*wlr.XwaylandSurface) = wl.Listener(*wlr.XwaylandSurface).init(handleUnmap),
|
||||||
title: wl.Listener(*wlr.XwaylandSurface) = undefined,
|
title: wl.Listener(*wlr.XwaylandSurface) = wl.Listener(*wlr.XwaylandSurface).init(handleTitle),
|
||||||
|
|
||||||
// Listeners that are only active while the view is mapped
|
// Listeners that are only active while the view is mapped
|
||||||
commit: wl.Listener(*wlr.Surface) = undefined,
|
commit: wl.Listener(*wlr.Surface) = wl.Listener(*wlr.Surface).init(handleCommit),
|
||||||
|
|
||||||
pub fn init(self: *Self, view: *View, xwayland_surface: *wlr.XwaylandSurface) void {
|
pub fn init(self: *Self, view: *View, xwayland_surface: *wlr.XwaylandSurface) void {
|
||||||
self.* = .{ .view = view, .xwayland_surface = xwayland_surface };
|
self.* = .{ .view = view, .xwayland_surface = xwayland_surface };
|
||||||
xwayland_surface.data = @ptrToInt(self);
|
xwayland_surface.data = @ptrToInt(self);
|
||||||
|
|
||||||
// Add listeners that are active over the view's entire lifetime
|
// Add listeners that are active over the view's entire lifetime
|
||||||
self.destroy.setNotify(handleDestroy);
|
xwayland_surface.events.destroy.add(&self.destroy);
|
||||||
self.xwayland_surface.events.destroy.add(&self.destroy);
|
xwayland_surface.events.map.add(&self.map);
|
||||||
|
xwayland_surface.events.unmap.add(&self.unmap);
|
||||||
self.map.setNotify(handleMap);
|
xwayland_surface.events.set_title.add(&self.title);
|
||||||
self.xwayland_surface.events.map.add(&self.map);
|
|
||||||
|
|
||||||
self.unmap.setNotify(handleUnmap);
|
|
||||||
self.xwayland_surface.events.unmap.add(&self.unmap);
|
|
||||||
|
|
||||||
self.title.setNotify(handleTitle);
|
|
||||||
self.xwayland_surface.events.set_title.add(&self.title);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn deinit(self: *Self) void {
|
pub fn deinit(self: *Self) void {
|
||||||
|
@ -164,8 +157,7 @@ fn handleMap(listener: *wl.Listener(*wlr.XwaylandSurface), xwayland_surface: *wl
|
||||||
const root = view.output.root;
|
const root = view.output.root;
|
||||||
|
|
||||||
// Add listeners that are only active while mapped
|
// Add listeners that are only active while mapped
|
||||||
self.commit.setNotify(handleCommit);
|
xwayland_surface.surface.?.events.commit.add(&self.commit);
|
||||||
self.xwayland_surface.surface.?.events.commit.add(&self.commit);
|
|
||||||
|
|
||||||
view.surface = self.xwayland_surface.surface;
|
view.surface = self.xwayland_surface.surface;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue