Make LayerSurface a toplevel struct
This commit is contained in:
parent
96f2ff793c
commit
a0d56ef635
5 changed files with 144 additions and 145 deletions
|
@ -1,7 +1,7 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const c = @import("c.zig");
|
const c = @import("c.zig");
|
||||||
|
|
||||||
const LayerSurface = @import("layer_surface.zig").LayerSurface;
|
const LayerSurface = @import("layer_surface.zig");
|
||||||
const Log = @import("log.zig").Log;
|
const Log = @import("log.zig").Log;
|
||||||
const Output = @import("output.zig");
|
const Output = @import("output.zig");
|
||||||
const Seat = @import("seat.zig");
|
const Seat = @import("seat.zig");
|
||||||
|
|
|
@ -1,37 +1,37 @@
|
||||||
|
const Self = @This();
|
||||||
|
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
|
||||||
const c = @import("c.zig");
|
const c = @import("c.zig");
|
||||||
|
|
||||||
const Box = @import("box.zig");
|
const Box = @import("box.zig");
|
||||||
const Log = @import("log.zig").Log;
|
const Log = @import("log.zig").Log;
|
||||||
const Output = @import("output.zig");
|
const Output = @import("output.zig");
|
||||||
|
|
||||||
pub const LayerSurface = struct {
|
output: *Output,
|
||||||
const Self = @This();
|
wlr_layer_surface: *c.wlr_layer_surface_v1,
|
||||||
|
|
||||||
output: *Output,
|
/// True if the layer surface is currently mapped
|
||||||
wlr_layer_surface: *c.wlr_layer_surface_v1,
|
mapped: bool,
|
||||||
|
|
||||||
/// True if the layer surface is currently mapped
|
box: Box,
|
||||||
mapped: bool,
|
layer: c.zwlr_layer_shell_v1_layer,
|
||||||
|
|
||||||
box: Box,
|
// Listeners active the entire lifetime of the layser surface
|
||||||
layer: c.zwlr_layer_shell_v1_layer,
|
listen_destroy: c.wl_listener,
|
||||||
|
listen_map: c.wl_listener,
|
||||||
|
listen_unmap: c.wl_listener,
|
||||||
|
|
||||||
// Listeners active the entire lifetime of the layser surface
|
// Listeners only active while the layer surface is mapped
|
||||||
listen_destroy: c.wl_listener,
|
listen_commit: c.wl_listener,
|
||||||
listen_map: c.wl_listener,
|
listen_new_popup: c.wl_listener,
|
||||||
listen_unmap: c.wl_listener,
|
|
||||||
|
|
||||||
// Listeners only active while the layer surface is mapped
|
pub fn init(
|
||||||
listen_commit: c.wl_listener,
|
|
||||||
listen_new_popup: c.wl_listener,
|
|
||||||
|
|
||||||
pub fn init(
|
|
||||||
self: *Self,
|
self: *Self,
|
||||||
output: *Output,
|
output: *Output,
|
||||||
wlr_layer_surface: *c.wlr_layer_surface_v1,
|
wlr_layer_surface: *c.wlr_layer_surface_v1,
|
||||||
layer: c.zwlr_layer_shell_v1_layer,
|
layer: c.zwlr_layer_shell_v1_layer,
|
||||||
) void {
|
) void {
|
||||||
self.output = output;
|
self.output = output;
|
||||||
self.wlr_layer_surface = wlr_layer_surface;
|
self.wlr_layer_surface = wlr_layer_surface;
|
||||||
wlr_layer_surface.data = self;
|
wlr_layer_surface.data = self;
|
||||||
|
@ -55,9 +55,9 @@ pub const LayerSurface = struct {
|
||||||
|
|
||||||
self.listen_unmap.notify = handleUnmap;
|
self.listen_unmap.notify = handleUnmap;
|
||||||
c.wl_signal_add(&self.wlr_layer_surface.events.unmap, &self.listen_unmap);
|
c.wl_signal_add(&self.wlr_layer_surface.events.unmap, &self.listen_unmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handleDestroy(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
fn handleDestroy(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||||
const self = @fieldParentPtr(Self, "listen_destroy", listener.?);
|
const self = @fieldParentPtr(Self, "listen_destroy", listener.?);
|
||||||
const output = self.output;
|
const output = self.output;
|
||||||
|
|
||||||
|
@ -73,9 +73,9 @@ pub const LayerSurface = struct {
|
||||||
output.root.server.allocator.destroy(node);
|
output.root.server.allocator.destroy(node);
|
||||||
|
|
||||||
self.output.arrangeLayers();
|
self.output.arrangeLayers();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handleMap(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
fn handleMap(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||||
const self = @fieldParentPtr(Self, "listen_map", listener.?);
|
const self = @fieldParentPtr(Self, "listen_map", listener.?);
|
||||||
const wlr_layer_surface = self.wlr_layer_surface;
|
const wlr_layer_surface = self.wlr_layer_surface;
|
||||||
|
|
||||||
|
@ -94,9 +94,9 @@ pub const LayerSurface = struct {
|
||||||
wlr_layer_surface.surface,
|
wlr_layer_surface.surface,
|
||||||
wlr_layer_surface.output,
|
wlr_layer_surface.output,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handleUnmap(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
fn handleUnmap(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||||
const self = @fieldParentPtr(Self, "listen_unmap", listener.?);
|
const self = @fieldParentPtr(Self, "listen_unmap", listener.?);
|
||||||
|
|
||||||
Log.Debug.log("Layer surface '{}' unmapped.", .{self.wlr_layer_surface.namespace});
|
Log.Debug.log("Layer surface '{}' unmapped.", .{self.wlr_layer_surface.namespace});
|
||||||
|
@ -135,9 +135,9 @@ pub const LayerSurface = struct {
|
||||||
const seat = &node.data;
|
const seat = &node.data;
|
||||||
seat.focus(null);
|
seat.focus(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handleCommit(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
fn handleCommit(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||||
const self = @fieldParentPtr(Self, "listen_commit", listener.?);
|
const self = @fieldParentPtr(Self, "listen_commit", listener.?);
|
||||||
const wlr_layer_surface = self.wlr_layer_surface;
|
const wlr_layer_surface = self.wlr_layer_surface;
|
||||||
|
|
||||||
|
@ -162,12 +162,11 @@ pub const LayerSurface = struct {
|
||||||
// TODO: only reconfigure if things haven't changed
|
// TODO: only reconfigure if things haven't changed
|
||||||
// https://github.com/swaywm/wlroots/issues/1079
|
// https://github.com/swaywm/wlroots/issues/1079
|
||||||
self.output.arrangeLayers();
|
self.output.arrangeLayers();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handleNewPopup(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
fn handleNewPopup(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||||
const self = @fieldParentPtr(Self, "listen_new_popup", listener.?);
|
const self = @fieldParentPtr(Self, "listen_new_popup", listener.?);
|
||||||
Log.Debug.log("new layer surface popup.", .{});
|
Log.Debug.log("new layer surface popup.", .{});
|
||||||
// TODO: handle popups
|
// TODO: handle popups
|
||||||
unreachable;
|
unreachable;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ const c = @import("c.zig");
|
||||||
const render = @import("render.zig");
|
const render = @import("render.zig");
|
||||||
|
|
||||||
const Box = @import("box.zig");
|
const Box = @import("box.zig");
|
||||||
const LayerSurface = @import("layer_surface.zig").LayerSurface;
|
const LayerSurface = @import("layer_surface.zig");
|
||||||
const Log = @import("log.zig").Log;
|
const Log = @import("log.zig").Log;
|
||||||
const Root = @import("root.zig").Root;
|
const Root = @import("root.zig").Root;
|
||||||
const View = @import("view.zig").View;
|
const View = @import("view.zig").View;
|
||||||
|
|
|
@ -2,7 +2,7 @@ const std = @import("std");
|
||||||
const c = @import("c.zig");
|
const c = @import("c.zig");
|
||||||
|
|
||||||
const Box = @import("box.zig");
|
const Box = @import("box.zig");
|
||||||
const LayerSurface = @import("layer_surface.zig").LayerSurface;
|
const LayerSurface = @import("layer_surface.zig");
|
||||||
const Output = @import("output.zig");
|
const Output = @import("output.zig");
|
||||||
const Server = @import("server.zig");
|
const Server = @import("server.zig");
|
||||||
const View = @import("view.zig").View;
|
const View = @import("view.zig").View;
|
||||||
|
|
|
@ -6,7 +6,7 @@ const std = @import("std");
|
||||||
const Cursor = @import("cursor.zig").Cursor;
|
const Cursor = @import("cursor.zig").Cursor;
|
||||||
const InputManager = @import("input_manager.zig");
|
const InputManager = @import("input_manager.zig");
|
||||||
const Keyboard = @import("keyboard.zig").Keyboard;
|
const Keyboard = @import("keyboard.zig").Keyboard;
|
||||||
const LayerSurface = @import("layer_surface.zig").LayerSurface;
|
const LayerSurface = @import("layer_surface.zig");
|
||||||
const Output = @import("output.zig");
|
const Output = @import("output.zig");
|
||||||
const View = @import("view.zig").View;
|
const View = @import("view.zig").View;
|
||||||
const ViewStack = @import("view_stack.zig").ViewStack;
|
const ViewStack = @import("view_stack.zig").ViewStack;
|
||||||
|
|
Loading…
Reference in a new issue