xdg_activation works

This commit is contained in:
Harrison DiAmbrosio 2025-12-14 11:48:05 -05:00
parent 42d66ea2b6
commit 209cd8a540
3 changed files with 20 additions and 237 deletions

View file

@ -305,9 +305,6 @@ fn handleDestroy(
}
pub fn arrangeLayers(self: *Output) void {
const debug = @import("Debug.zig");
debug.debugPrintSceneTree();
var full_box: wlr.Box = .{
.x = 0,
.y = 0,

View file

@ -11,13 +11,14 @@ const Keyboard = @import("Keyboard.zig");
const LayerSurface = @import("LayerSurface.zig");
const Output = @import("Output.zig");
const View = @import("View.zig");
const Utils = @import("Utils.zig");
const Keymap = @import("types/Keymap.zig");
const Hook = @import("types/Hook.zig");
const Events = @import("types/Events.zig");
const Popup = @import("Popup.zig");
const RemoteLua = @import("RemoteLua.zig");
const RemoteLuaManager = @import("RemoteLuaManager.zig");
const Utils = @import("Utils.zig");
const SceneNodeData = @import("SceneNodeData.zig").SceneNodeData;
const gpa = std.heap.c_allocator;
const server = &@import("main.zig").server;
@ -34,6 +35,7 @@ shm: *wlr.Shm,
xdg_shell: *wlr.XdgShell,
layer_shell: *wlr.LayerShellV1,
xdg_toplevel_decoration_manager: *wlr.XdgDecorationManagerV1,
xdg_activation: *wlr.XdgActivationV1,
allocator: *wlr.Allocator,
@ -51,14 +53,11 @@ remote_lua_clients: std.DoublyLinkedList,
new_input: wl.Listener(*wlr.InputDevice) = .init(handleNewInput),
new_output: wl.Listener(*wlr.Output) = .init(handleNewOutput),
// backend.events.destroy
// XdgShell listeners
new_xdg_toplevel: wl.Listener(*wlr.XdgToplevel) = .init(handleNewXdgToplevel),
new_xdg_popup: wl.Listener(*wlr.XdgPopup) = .init(handleNewXdgPopup),
new_xdg_toplevel_decoration: wl.Listener(*wlr.XdgToplevelDecorationV1) = .init(handleNewXdgToplevelDecoration),
// LayerShell Listeners
new_layer_surface: wl.Listener(*wlr.LayerSurfaceV1) = .init(handleNewLayerSurface),
request_activate: wl.Listener(*wlr.XdgActivationV1.event.RequestActivate) = .init(handleRequestActivate),
pub fn init(self: *Server) void {
errdefer Utils.oomPanic();
@ -92,6 +91,7 @@ pub fn init(self: *Server) void {
.xdg_shell = try wlr.XdgShell.create(wl_server, 2),
.layer_shell = try wlr.LayerShellV1.create(wl_server, 4),
.xdg_toplevel_decoration_manager = try wlr.XdgDecorationManagerV1.create(self.wl_server),
.xdg_activation = try wlr.XdgActivationV1.create(self.wl_server),
.event_loop = event_loop,
.session = session,
.compositor = try wlr.Compositor.create(wl_server, 6, renderer),
@ -131,19 +131,13 @@ pub fn init(self: *Server) void {
self.root.scene.setGammaControlManagerV1(try wlr.GammaControlManagerV1.create(self.wl_server));
// Add event listeners to events
// Backend events
self.backend.events.new_input.add(&self.new_input);
self.backend.events.new_output.add(&self.new_output);
// XdgShell events
self.xdg_shell.events.new_toplevel.add(&self.new_xdg_toplevel);
self.xdg_shell.events.new_popup.add(&self.new_xdg_popup);
// XdgDecorationManagerV1 events
self.xdg_toplevel_decoration_manager.events.new_toplevel_decoration.add(&self.new_xdg_toplevel_decoration);
// LayerShell events
self.layer_shell.events.new_surface.add(&self.new_layer_surface);
self.xdg_activation.events.request_activate.add(&self.request_activate);
self.events.exec("ServerStartPost", .{});
}
@ -236,3 +230,17 @@ fn handleNewLayerSurface(
_ = LayerSurface.init(layer_surface);
}
fn handleRequestActivate(
_: *wl.Listener(*wlr.XdgActivationV1.event.RequestActivate),
event: *wlr.XdgActivationV1.event.RequestActivate,
) void {
if(event.surface.data == null) return;
const scene_node_data: *SceneNodeData = @ptrCast(@alignCast(event.surface.data.?));
if(scene_node_data.* == .view) {
scene_node_data.view.setFocused();
} else {
std.log.warn("Ignoring request to activate non-view", .{});
}
}