mirror of
https://github.com/MezzalunaWM/Mezzaluna.git
synced 2026-03-07 19:49:53 -05:00
reformatted with zig fmt
This commit is contained in:
parent
e6a45f91b6
commit
6be66b6a71
32 changed files with 2108 additions and 2237 deletions
|
|
@ -6,11 +6,6 @@ root = true
|
|||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
|
||||
[*.zig]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.lua]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
|
|
|||
|
|
@ -31,15 +31,11 @@ mode: enum { normal, drag } = .normal,
|
|||
// Drag information
|
||||
drag: ?struct {
|
||||
event_code: u32,
|
||||
start: struct {
|
||||
start: struct { x: c_int, y: c_int },
|
||||
view: ?struct { view: *View, dims: struct { width: c_int, height: c_int }, offset: struct {
|
||||
x: c_int,
|
||||
y: c_int
|
||||
},
|
||||
view: ?struct {
|
||||
view: *View,
|
||||
dims: struct { width: c_int, height: c_int },
|
||||
offset: struct { x: c_int, y: c_int, }
|
||||
},
|
||||
y: c_int,
|
||||
} },
|
||||
},
|
||||
|
||||
pub fn init(self: *Cursor) void {
|
||||
|
|
@ -48,7 +44,7 @@ pub fn init(self: *Cursor) void {
|
|||
self.* = .{
|
||||
.wlr_cursor = try wlr.Cursor.create(),
|
||||
.x_cursor_manager = try wlr.XcursorManager.create(null, 24),
|
||||
.drag = null
|
||||
.drag = null,
|
||||
};
|
||||
|
||||
try self.x_cursor_manager.load(1);
|
||||
|
|
@ -88,20 +84,7 @@ pub fn processCursorMotion(self: *Cursor, time_msec: u32) void {
|
|||
// Proceed if mousemap for current mouse and modifier state's exist
|
||||
if (server.mousemaps.get(Mousemap.hash(modifiers, @bitCast(self.drag.?.event_code)))) |map| {
|
||||
if (map.options.lua_drag_ref_idx > 0) {
|
||||
passthrough = map.callback(.drag, .{
|
||||
.{
|
||||
.x = @as(c_int, @intFromFloat(self.wlr_cursor.x)),
|
||||
.y = @as(c_int, @intFromFloat(self.wlr_cursor.y))
|
||||
},
|
||||
.{
|
||||
.start = self.drag.?.start,
|
||||
.view = if (self.drag.?.view != null) .{
|
||||
.id = self.drag.?.view.?.view.id,
|
||||
.dims = self.drag.?.view.?.dims,
|
||||
.offset = self.drag.?.view.?.offset
|
||||
} else null
|
||||
}
|
||||
});
|
||||
passthrough = map.callback(.drag, .{ .{ .x = @as(c_int, @intFromFloat(self.wlr_cursor.x)), .y = @as(c_int, @intFromFloat(self.wlr_cursor.y)) }, .{ .start = self.drag.?.start, .view = if (self.drag.?.view != null) .{ .id = self.drag.?.view.?.view.id, .dims = self.drag.?.view.?.dims, .offset = self.drag.?.view.?.offset } else null } });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -114,11 +97,7 @@ pub fn processCursorMotion(self: *Cursor, time_msec: u32) void {
|
|||
const surfaceAtResult = output.?.surfaceAt(self.wlr_cursor.x, self.wlr_cursor.y);
|
||||
if (surfaceAtResult) |surface| {
|
||||
if (surface.scene_node_data.* == .view) {
|
||||
server.events.exec("ViewPointerMotion", .{
|
||||
surface.scene_node_data.view.id,
|
||||
@as(c_int, @intFromFloat(self.wlr_cursor.x)),
|
||||
@as(c_int, @intFromFloat(self.wlr_cursor.y))
|
||||
});
|
||||
server.events.exec("ViewPointerMotion", .{ surface.scene_node_data.view.id, @as(c_int, @intFromFloat(self.wlr_cursor.x)), @as(c_int, @intFromFloat(self.wlr_cursor.y)) });
|
||||
}
|
||||
|
||||
server.seat.wlr_seat.pointerNotifyEnter(surfaceAtResult.?.surface, surfaceAtResult.?.sx, surfaceAtResult.?.sy);
|
||||
|
|
@ -148,38 +127,22 @@ event: *wlr.Pointer.event.MotionAbsolute,
|
|||
server.cursor.processCursorMotion(event.time_msec);
|
||||
}
|
||||
|
||||
fn handleButton(
|
||||
listener: *wl.Listener(*wlr.Pointer.event.Button),
|
||||
event: *wlr.Pointer.event.Button
|
||||
) void {
|
||||
fn handleButton(listener: *wl.Listener(*wlr.Pointer.event.Button), event: *wlr.Pointer.event.Button) void {
|
||||
const cursor: *Cursor = @fieldParentPtr("button", listener);
|
||||
|
||||
switch (event.state) {
|
||||
.pressed => {
|
||||
cursor.mode = .drag;
|
||||
|
||||
cursor.drag = .{
|
||||
.event_code = event.button,
|
||||
.start = .{
|
||||
.x = @as(c_int, @intFromFloat(cursor.wlr_cursor.x)),
|
||||
.y = @as(c_int, @intFromFloat(cursor.wlr_cursor.y))
|
||||
},
|
||||
.view = null
|
||||
};
|
||||
cursor.drag = .{ .event_code = event.button, .start = .{ .x = @as(c_int, @intFromFloat(cursor.wlr_cursor.x)), .y = @as(c_int, @intFromFloat(cursor.wlr_cursor.y)) }, .view = null };
|
||||
|
||||
// Keep track of where the drag started
|
||||
if (server.seat.focused_surface) |fs| {
|
||||
if (fs == .view) {
|
||||
cursor.drag.?.view = .{
|
||||
.view = fs.view,
|
||||
.dims = .{
|
||||
.width = fs.view.xdg_toplevel.base.geometry.width,
|
||||
.height = fs.view.xdg_toplevel.base.geometry.height
|
||||
},
|
||||
.offset = .{
|
||||
.x = cursor.drag.?.start.x - fs.view.scene_tree.node.x,
|
||||
.y = cursor.drag.?.start.y - fs.view.scene_tree.node.y
|
||||
},
|
||||
.dims = .{ .width = fs.view.xdg_toplevel.base.geometry.width, .height = fs.view.xdg_toplevel.base.geometry.height },
|
||||
.offset = .{ .x = cursor.drag.?.start.x - fs.view.scene_tree.node.x, .y = cursor.drag.?.start.y - fs.view.scene_tree.node.y },
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -196,7 +159,7 @@ fn handleButton(
|
|||
},
|
||||
else => {
|
||||
std.log.err("Invalid/Unimplemented pointer button event type", .{});
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
var passthrough = true;
|
||||
|
|
@ -209,24 +172,20 @@ fn handleButton(
|
|||
// Only make callback if a callback function exists
|
||||
if (map.options.lua_press_ref_idx > 0) {
|
||||
passthrough = map.callback(.press, .{
|
||||
.{
|
||||
.x = @as(c_int, @intFromFloat(cursor.wlr_cursor.x)),
|
||||
.y = @as(c_int, @intFromFloat(cursor.wlr_cursor.y))
|
||||
},
|
||||
.{ .x = @as(c_int, @intFromFloat(cursor.wlr_cursor.x)), .y = @as(c_int, @intFromFloat(cursor.wlr_cursor.y)) },
|
||||
});
|
||||
}
|
||||
},
|
||||
.released => {
|
||||
if (map.options.lua_press_ref_idx > 0) {
|
||||
passthrough = map.callback(.release, .{
|
||||
.{
|
||||
.x = @as(c_int, @intFromFloat(cursor.wlr_cursor.x)),
|
||||
.y = @as(c_int, @intFromFloat(cursor.wlr_cursor.y))
|
||||
},
|
||||
.{ .x = @as(c_int, @intFromFloat(cursor.wlr_cursor.x)), .y = @as(c_int, @intFromFloat(cursor.wlr_cursor.y)) },
|
||||
});
|
||||
}
|
||||
},
|
||||
else => { unreachable; }
|
||||
else => {
|
||||
unreachable;
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -237,19 +196,13 @@ fn handleButton(
|
|||
}
|
||||
}
|
||||
|
||||
fn handleHoldBegin(
|
||||
listener: *wl.Listener(*wlr.Pointer.event.HoldBegin),
|
||||
event: *wlr.Pointer.event.HoldBegin
|
||||
) void {
|
||||
fn handleHoldBegin(listener: *wl.Listener(*wlr.Pointer.event.HoldBegin), event: *wlr.Pointer.event.HoldBegin) void {
|
||||
_ = listener;
|
||||
_ = event;
|
||||
std.log.err("Unimplemented cursor start hold", .{});
|
||||
}
|
||||
|
||||
fn handleHoldEnd(
|
||||
listener: *wl.Listener(*wlr.Pointer.event.HoldEnd),
|
||||
event: *wlr.Pointer.event.HoldEnd
|
||||
) void {
|
||||
fn handleHoldEnd(listener: *wl.Listener(*wlr.Pointer.event.HoldEnd), event: *wlr.Pointer.event.HoldEnd) void {
|
||||
_ = listener;
|
||||
_ = event;
|
||||
std.log.err("Unimplemented cursor end hold", .{});
|
||||
|
|
|
|||
|
|
@ -31,15 +31,10 @@ fn printNode(node: *wlr.SceneNode, depth: usize) void {
|
|||
const type_name = switch (node.type) {
|
||||
.tree => "TREE",
|
||||
.rect => "RECT",
|
||||
.buffer => "BUFFER"
|
||||
.buffer => "BUFFER",
|
||||
};
|
||||
|
||||
writer.print("{s} @ ({d}, {d}) enabled={}", .{
|
||||
type_name,
|
||||
node.x,
|
||||
node.y,
|
||||
node.enabled
|
||||
}) catch unreachable;
|
||||
writer.print("{s} @ ({d}, {d}) enabled={}", .{ type_name, node.x, node.y, node.enabled }) catch unreachable;
|
||||
|
||||
// Add associated data if present
|
||||
if (node.data) |data| {
|
||||
|
|
@ -84,7 +79,7 @@ fn printNode(node: *wlr.SceneNode, depth: usize) void {
|
|||
if (namespace.len > 0) {
|
||||
writer.print(" namespace=\"{s}\"", .{namespace}) catch unreachable;
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -99,9 +99,7 @@ fn handleKey(listener: *wl.Listener(*wlr.Keyboard.event.Key), event: *wlr.Keyboa
|
|||
}
|
||||
}
|
||||
|
||||
if (handled and keyboard.wlr_keyboard.repeat_info.delay > 0) {
|
||||
|
||||
}
|
||||
if (handled and keyboard.wlr_keyboard.repeat_info.delay > 0) {}
|
||||
|
||||
if (!handled) {
|
||||
server.seat.wlr_seat.setKeyboard(&server.seat.keyboard_group.wlr_group.keyboard);
|
||||
|
|
@ -109,11 +107,7 @@ fn handleKey(listener: *wl.Listener(*wlr.Keyboard.event.Key), event: *wlr.Keyboa
|
|||
}
|
||||
}
|
||||
|
||||
pub fn keypress(
|
||||
modifiers: wlr.Keyboard.ModifierMask,
|
||||
sym: xkb.Keysym,
|
||||
state: wl.Keyboard.KeyState
|
||||
) bool {
|
||||
pub fn keypress(modifiers: wlr.Keyboard.ModifierMask, sym: xkb.Keysym, state: wl.Keyboard.KeyState) bool {
|
||||
if (server.keymaps.get(Keymap.hash(modifiers, sym))) |map| {
|
||||
if (state == .pressed and map.options.lua_press_ref_idx > 0) {
|
||||
map.callback(false);
|
||||
|
|
|
|||
|
|
@ -45,7 +45,8 @@ fn handleRepeat(data: ?*KeyboardGroup) c_int {
|
|||
if (data.?.repeat_source == null) return 0;
|
||||
|
||||
if (data == null or data.?.keysyms == null or data.?.modifiers == null or
|
||||
data.?.wlr_group.keyboard.repeat_info.rate <= 0) {
|
||||
data.?.wlr_group.keyboard.repeat_info.rate <= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ pub fn init(wlr_layer_surface: *wlr.LayerSurfaceV1) *LayerSurface {
|
|||
.output = undefined,
|
||||
.wlr_layer_surface = wlr_layer_surface,
|
||||
.scene_layer_surface = undefined,
|
||||
.scene_node_data = .{ .layer_surface = self }
|
||||
.scene_node_data = .{ .layer_surface = self },
|
||||
};
|
||||
|
||||
if (wlr_layer_surface.output.?.data == null) {
|
||||
|
|
@ -49,7 +49,7 @@ pub fn init(wlr_layer_surface: *wlr.LayerSurfaceV1) *LayerSurface {
|
|||
else => {
|
||||
std.log.err("New layer surface of unidentified type", .{});
|
||||
unreachable;
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -78,26 +78,17 @@ pub fn deinit(self: *LayerSurface) void {
|
|||
pub fn allowKeyboard(self: *LayerSurface) void {
|
||||
const keyboard_interactive = self.wlr_layer_surface.current.keyboard_interactive;
|
||||
if (keyboard_interactive == .exclusive or keyboard_interactive == .on_demand) {
|
||||
server.seat.wlr_seat.keyboardNotifyEnter(
|
||||
self.wlr_layer_surface.surface,
|
||||
&server.seat.keyboard_group.wlr_group.keyboard.keycodes,
|
||||
&server.seat.keyboard_group.wlr_group.keyboard.modifiers
|
||||
);
|
||||
server.seat.wlr_seat.keyboardNotifyEnter(self.wlr_layer_surface.surface, &server.seat.keyboard_group.wlr_group.keyboard.keycodes, &server.seat.keyboard_group.wlr_group.keyboard.modifiers);
|
||||
}
|
||||
}
|
||||
|
||||
// --------- LayerSurface event handlers ---------
|
||||
fn handleDestroy(
|
||||
listener: *wl.Listener(*wlr.LayerSurfaceV1),
|
||||
_: *wlr.LayerSurfaceV1
|
||||
) void {
|
||||
fn handleDestroy(listener: *wl.Listener(*wlr.LayerSurfaceV1), _: *wlr.LayerSurfaceV1) void {
|
||||
const layer: *LayerSurface = @fieldParentPtr("destroy", listener);
|
||||
layer.deinit();
|
||||
}
|
||||
|
||||
fn handleMap(
|
||||
listener: *wl.Listener(void)
|
||||
) void {
|
||||
fn handleMap(listener: *wl.Listener(void)) void {
|
||||
const layer_suraface: *LayerSurface = @fieldParentPtr("map", listener);
|
||||
std.log.debug("layer surface mapped", .{});
|
||||
layer_suraface.output.arrangeLayers();
|
||||
|
|
@ -120,10 +111,7 @@ fn handleUnmap(listener: *wl.Listener(void)) void {
|
|||
layer_surface.deinit();
|
||||
}
|
||||
|
||||
fn handleCommit(
|
||||
listener: *wl.Listener(*wlr.Surface),
|
||||
_: *wlr.Surface
|
||||
) void {
|
||||
fn handleCommit(listener: *wl.Listener(*wlr.Surface), _: *wlr.Surface) void {
|
||||
const layer_surface: *LayerSurface = @fieldParentPtr("commit", listener);
|
||||
|
||||
if (!layer_surface.wlr_layer_surface.initial_commit) return;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ layers: struct {
|
|||
content: *wlr.SceneTree,
|
||||
top: *wlr.SceneTree,
|
||||
fullscreen: *wlr.SceneTree,
|
||||
overlay: *wlr.SceneTree
|
||||
overlay: *wlr.SceneTree,
|
||||
},
|
||||
|
||||
layer_scene_node_data: struct {
|
||||
|
|
@ -42,14 +42,13 @@ layer_scene_node_data: struct {
|
|||
content: SceneNodeData,
|
||||
top: SceneNodeData,
|
||||
fullscreen: SceneNodeData,
|
||||
overlay: SceneNodeData
|
||||
overlay: SceneNodeData,
|
||||
},
|
||||
|
||||
frame: wl.Listener(*wlr.Output) = .init(handleFrame),
|
||||
request_state: wl.Listener(*wlr.Output.event.RequestState) = .init(handleRequestState),
|
||||
destroy: wl.Listener(*wlr.Output) = .init(handleDestroy),
|
||||
|
||||
|
||||
// The wlr.Output should be destroyed by the caller on failure to trigger cleanup.
|
||||
pub fn init(wlr_output: *wlr.Output) ?*Output {
|
||||
errdefer Utils.oomPanic();
|
||||
|
|
@ -62,6 +61,7 @@ pub fn init(wlr_output: *wlr.Output) ?*Output {
|
|||
.wlr_output = wlr_output,
|
||||
.tree = try server.root.scene.tree.createSceneTree(),
|
||||
.fullscreen = null,
|
||||
|
||||
.layers = .{
|
||||
.background = try self.tree.createSceneTree(),
|
||||
.bottom = try self.tree.createSceneTree(),
|
||||
|
|
@ -70,14 +70,16 @@ pub fn init(wlr_output: *wlr.Output) ?*Output {
|
|||
.fullscreen = try self.tree.createSceneTree(),
|
||||
.overlay = try self.tree.createSceneTree(),
|
||||
},
|
||||
|
||||
.layer_scene_node_data = .{
|
||||
.background = .{ .output_layer = self.layers.background },
|
||||
.bottom = .{ .output_layer = self.layers.bottom },
|
||||
.content = .{ .output_layer = self.layers.content },
|
||||
.top = .{ .output_layer = self.layers.top },
|
||||
.fullscreen = .{ .output_layer = self.layers.fullscreen },
|
||||
.overlay = .{ .output_layer = self.layers.overlay }
|
||||
.overlay = .{ .output_layer = self.layers.overlay },
|
||||
},
|
||||
|
||||
.scene_output = try server.root.scene.createSceneOutput(wlr_output),
|
||||
.scene_node_data = SceneNodeData{ .output = self },
|
||||
.state = wlr.Output.State.init()
|
||||
|
|
@ -178,15 +180,12 @@ pub fn configureLayers(self: *Output) void {
|
|||
const scene_node_data: *SceneNodeData = @ptrCast(@alignCast(node.data.?));
|
||||
switch (scene_node_data.*) {
|
||||
.layer_surface => {
|
||||
_ = scene_node_data.layer_surface.wlr_layer_surface.configured(
|
||||
@intCast(output_box.width),
|
||||
@intCast(output_box.height)
|
||||
);
|
||||
_ = scene_node_data.layer_surface.wlr_layer_surface.configured(@intCast(output_box.width), @intCast(output_box.height));
|
||||
},
|
||||
else => {
|
||||
std.log.err("Something other than a layer surface found in layer surface scene trees", .{});
|
||||
unreachable;
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -203,14 +202,7 @@ pub fn surfaceAt(self: *Output, lx: f64, ly: f64) ?SurfaceAtResult {
|
|||
var sx: f64 = undefined;
|
||||
var sy: f64 = undefined;
|
||||
|
||||
const layers = [_]*wlr.SceneTree{
|
||||
self.layers.top,
|
||||
self.layers.overlay,
|
||||
self.layers.fullscreen,
|
||||
self.layers.content,
|
||||
self.layers.bottom,
|
||||
self.layers.background
|
||||
};
|
||||
const layers = [_]*wlr.SceneTree{ self.layers.top, self.layers.overlay, self.layers.fullscreen, self.layers.content, self.layers.bottom, self.layers.background };
|
||||
|
||||
for (layers) |layer| {
|
||||
const node = layer.node.at(lx, ly, &sx, &sy);
|
||||
|
|
@ -250,7 +242,7 @@ pub fn surfaceAt(self: *Output, lx: f64, ly: f64) ?SurfaceAtResult {
|
|||
.sy = sy,
|
||||
};
|
||||
},
|
||||
else => continue
|
||||
else => continue,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -286,10 +278,7 @@ fn handleRequestState(
|
|||
server.events.exec("OutputStateChange", .{});
|
||||
}
|
||||
|
||||
fn handleFrame(
|
||||
_: *wl.Listener(*wlr.Output),
|
||||
wlr_output: *wlr.Output
|
||||
) void {
|
||||
fn handleFrame(_: *wl.Listener(*wlr.Output), wlr_output: *wlr.Output) void {
|
||||
const scene_output = server.root.scene.getSceneOutput(wlr_output);
|
||||
|
||||
if (scene_output == null) {
|
||||
|
|
@ -304,10 +293,7 @@ fn handleFrame(
|
|||
scene_output.?.sendFrameDone(&now);
|
||||
}
|
||||
|
||||
fn handleDestroy(
|
||||
listener: *wl.Listener(*wlr.Output),
|
||||
_: *wlr.Output
|
||||
) void {
|
||||
fn handleDestroy(listener: *wl.Listener(*wlr.Output), _: *wlr.Output) void {
|
||||
std.log.debug("Handling destroy", .{});
|
||||
const output: *Output = @fieldParentPtr("destroy", listener);
|
||||
|
||||
|
|
@ -343,7 +329,7 @@ pub fn arrangeLayers(self: *Output) void {
|
|||
|
||||
const layer_surface: *LayerSurface = switch (scene_node_data.*) {
|
||||
.layer_surface => @fieldParentPtr("scene_node_data", scene_node_data),
|
||||
else => continue
|
||||
else => continue,
|
||||
};
|
||||
|
||||
if (!layer_surface.wlr_layer_surface.initialized) continue;
|
||||
|
|
|
|||
|
|
@ -75,7 +75,9 @@ remote: *RemoteLua,
|
|||
return;
|
||||
};
|
||||
|
||||
L.protectedCall(.{ .results = zlua.mult_return, }) catch {
|
||||
L.protectedCall(.{
|
||||
.results = zlua.mult_return,
|
||||
}) catch {
|
||||
catchLuaFail(remote);
|
||||
L.pop(1);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
/// The root of Mezzaluna is, you guessed it, the root of many of the systems mez needs:
|
||||
|
||||
const Root = @This();
|
||||
|
||||
const std = @import("std");
|
||||
|
|
@ -61,7 +60,7 @@ pub fn deinit(self: *Root) void {
|
|||
else => {
|
||||
std.log.debug("The root has a child that is not an output", .{});
|
||||
unreachable;
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,10 +5,4 @@ const LayerSurface = @import("LayerSurface.zig");
|
|||
const Output = @import("Output.zig");
|
||||
const Root = @import("Root.zig");
|
||||
|
||||
pub const SceneNodeData = union(enum) {
|
||||
view: *View,
|
||||
layer_surface: *LayerSurface,
|
||||
output: *Output,
|
||||
output_layer: *wlr.SceneTree,
|
||||
root: *Root
|
||||
};
|
||||
pub const SceneNodeData = union(enum) { view: *View, layer_surface: *LayerSurface, output: *Output, output_layer: *wlr.SceneTree, root: *Root };
|
||||
|
|
|
|||
13
src/Seat.zig
13
src/Seat.zig
|
|
@ -115,10 +115,10 @@ pub fn focusSurface(self: *Seat, to_focus: ?FocusData) void {
|
|||
},
|
||||
.view => |*view| {
|
||||
if (!view.*.fullscreen) return;
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
} else if (current_focus == .view and current_focus.view.fullscreen) {
|
||||
return;
|
||||
|
|
@ -131,17 +131,12 @@ pub fn focusSurface(self: *Seat, to_focus: ?FocusData) void {
|
|||
if (wlr.XdgSurface.tryFromWlrSurface(current_surface)) |xdg_surface| {
|
||||
_ = xdg_surface.role_data.toplevel.?.setActivated(false);
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (to_focus != null) {
|
||||
server.seat.wlr_seat.keyboardNotifyEnter(
|
||||
surface.?,
|
||||
&server.seat.keyboard_group.wlr_group.keyboard.keycodes,
|
||||
&server.seat.keyboard_group.wlr_group.keyboard.modifiers
|
||||
);
|
||||
server.seat.wlr_seat.keyboardNotifyEnter(surface.?, &server.seat.keyboard_group.wlr_group.keyboard.keycodes, &server.seat.keyboard_group.wlr_group.keyboard.modifiers);
|
||||
if (to_focus.? != .layer_surface) {
|
||||
if (to_focus.? == .view) to_focus.?.view.focused = true;
|
||||
if (wlr.XdgSurface.tryFromWlrSurface(surface.?)) |xdg_surface| {
|
||||
|
|
|
|||
|
|
@ -167,18 +167,12 @@ pub fn deinit(self: *Server) noreturn {
|
|||
}
|
||||
|
||||
// --------- Backend event handlers ---------
|
||||
fn handleNewInput(
|
||||
_: *wl.Listener(*wlr.InputDevice),
|
||||
device: *wlr.InputDevice
|
||||
) void {
|
||||
fn handleNewInput(_: *wl.Listener(*wlr.InputDevice), device: *wlr.InputDevice) void {
|
||||
switch (device.type) {
|
||||
.keyboard => _ = Keyboard.init(device),
|
||||
.pointer => server.cursor.wlr_cursor.attachInputDevice(device),
|
||||
else => {
|
||||
std.log.err(
|
||||
"New input request for input that is not a keyboard or pointer: {s}",
|
||||
.{device.name orelse "(null)"}
|
||||
);
|
||||
std.log.err("New input request for input that is not a keyboard or pointer: {s}", .{device.name orelse "(null)"});
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -189,24 +183,15 @@ fn handleNewInput(
|
|||
});
|
||||
}
|
||||
|
||||
fn handleNewOutput(
|
||||
_: *wl.Listener(*wlr.Output),
|
||||
wlr_output: *wlr.Output
|
||||
) void {
|
||||
fn handleNewOutput(_: *wl.Listener(*wlr.Output), wlr_output: *wlr.Output) void {
|
||||
_ = Output.init(wlr_output);
|
||||
}
|
||||
|
||||
fn handleNewXdgToplevel(
|
||||
_: *wl.Listener(*wlr.XdgToplevel),
|
||||
xdg_toplevel: *wlr.XdgToplevel
|
||||
) void {
|
||||
fn handleNewXdgToplevel(_: *wl.Listener(*wlr.XdgToplevel), xdg_toplevel: *wlr.XdgToplevel) void {
|
||||
_ = View.init(xdg_toplevel);
|
||||
}
|
||||
|
||||
fn handleNewXdgToplevelDecoration(
|
||||
_: *wl.Listener(*wlr.XdgToplevelDecorationV1),
|
||||
decoration: *wlr.XdgToplevelDecorationV1
|
||||
) void {
|
||||
fn handleNewXdgToplevelDecoration(_: *wl.Listener(*wlr.XdgToplevelDecorationV1), decoration: *wlr.XdgToplevelDecorationV1) void {
|
||||
if (server.root.viewById(@intFromPtr(decoration.toplevel))) |view| {
|
||||
view.xdg_toplevel_decoration = decoration;
|
||||
}
|
||||
|
|
@ -216,10 +201,7 @@ fn handleNewXdgPopup(_: *wl.Listener(*wlr.XdgPopup), _: *wlr.XdgPopup) void {
|
|||
std.log.debug("Unimplemented Server.handleNewXdgPopup\n", .{});
|
||||
}
|
||||
|
||||
fn handleNewLayerSurface(
|
||||
_: *wl.Listener(*wlr.LayerSurfaceV1),
|
||||
layer_surface: *wlr.LayerSurfaceV1
|
||||
) void {
|
||||
fn handleNewLayerSurface(_: *wl.Listener(*wlr.LayerSurfaceV1), layer_surface: *wlr.LayerSurfaceV1) void {
|
||||
std.log.debug("requested layer shell\n", .{});
|
||||
if (layer_surface.output == null) {
|
||||
if (server.seat.focused_output == null) {
|
||||
|
|
|
|||
34
src/View.zig
34
src/View.zig
|
|
@ -68,15 +68,13 @@ pub fn init(xdg_toplevel: *wlr.XdgToplevel) *View {
|
|||
.id = @intFromPtr(xdg_toplevel),
|
||||
.output = null,
|
||||
.geometry = .{ .width = 0, .height = 0, .x = 0, .y = 0 },
|
||||
|
||||
.xdg_toplevel = xdg_toplevel,
|
||||
.scene_tree = undefined,
|
||||
.surface_tree = undefined,
|
||||
.xdg_toplevel_decoration = null,
|
||||
.borders = undefined,
|
||||
.border_width = 0,
|
||||
|
||||
.scene_node_data = .{ .view = self }
|
||||
.scene_node_data = .{ .view = self },
|
||||
};
|
||||
|
||||
// Add new Toplevel to root of the tree
|
||||
|
|
@ -263,7 +261,9 @@ fn handleCommit(listener: *wl.Listener(*wlr.Surface), _: *wlr.Surface) void {
|
|||
// 5 is the XDG_TOPLEVEL_WM_CAPABILITIES_SINCE_VERSION, I'm just not sure where it is in the bindings
|
||||
if (view.xdg_toplevel.base.client.shell.version >= 5) {
|
||||
// the client should know that it can only fullscreen, nothing else
|
||||
_ = view.xdg_toplevel.setWmCapabilities(.{ .fullscreen = true, });
|
||||
_ = view.xdg_toplevel.setWmCapabilities(.{
|
||||
.fullscreen = true,
|
||||
});
|
||||
}
|
||||
|
||||
// before committing we tell the client that we'll handle the decorations
|
||||
|
|
@ -285,18 +285,12 @@ fn handleNewPopup(listener: *wl.Listener(*wlr.XdgPopup), xdg_popup: *wlr.XdgPopu
|
|||
_ = Popup.init(xdg_popup, view.scene_tree);
|
||||
}
|
||||
|
||||
fn handleRequestMove(
|
||||
listener: *wl.Listener(*wlr.XdgToplevel.event.Move),
|
||||
_: *wlr.XdgToplevel.event.Move
|
||||
) void {
|
||||
fn handleRequestMove(listener: *wl.Listener(*wlr.XdgToplevel.event.Move), _: *wlr.XdgToplevel.event.Move) void {
|
||||
const view: *View = @fieldParentPtr("request_move", listener);
|
||||
server.events.exec("ViewRequestMove", .{view.id});
|
||||
}
|
||||
|
||||
fn handleRequestResize(
|
||||
listener: *wl.Listener(*wlr.XdgToplevel.event.Resize),
|
||||
_: *wlr.XdgToplevel.event.Resize
|
||||
) void {
|
||||
fn handleRequestResize(listener: *wl.Listener(*wlr.XdgToplevel.event.Resize), _: *wlr.XdgToplevel.event.Resize) void {
|
||||
const view: *View = @fieldParentPtr("request_resize", listener);
|
||||
server.events.exec("ViewRequestResize", .{view.id});
|
||||
}
|
||||
|
|
@ -310,32 +304,24 @@ fn handleAckConfigure(
|
|||
std.log.err("Unimplemented ack configure", .{});
|
||||
}
|
||||
|
||||
fn handleRequestFullscreen(
|
||||
listener: *wl.Listener(void)
|
||||
) void {
|
||||
fn handleRequestFullscreen(listener: *wl.Listener(void)) void {
|
||||
const view: *View = @fieldParentPtr("request_fullscreen", listener);
|
||||
server.events.exec("ViewRequestFullscreen", .{view.id});
|
||||
}
|
||||
|
||||
fn handleRequestMinimize(
|
||||
listener: *wl.Listener(void)
|
||||
) void {
|
||||
fn handleRequestMinimize(listener: *wl.Listener(void)) void {
|
||||
const view: *View = @fieldParentPtr("request_minimize", listener);
|
||||
server.events.exec("ViewRequestMinimize", .{view.id});
|
||||
std.log.debug("request_minimize unimplemented", .{});
|
||||
}
|
||||
|
||||
fn handleSetAppId(
|
||||
listener: *wl.Listener(void)
|
||||
) void {
|
||||
fn handleSetAppId(listener: *wl.Listener(void)) void {
|
||||
const view: *View = @fieldParentPtr("set_app_id", listener);
|
||||
server.events.exec("ViewAppIdUpdate", .{view.id});
|
||||
std.log.debug("request_set_app_id unimplemented", .{});
|
||||
}
|
||||
|
||||
fn handleSetTitle(
|
||||
listener: *wl.Listener(void)
|
||||
) void {
|
||||
fn handleSetTitle(listener: *wl.Listener(void)) void {
|
||||
const view: *View = @fieldParentPtr("set_title", listener);
|
||||
server.events.exec("ViewTitleUpdate", .{view.id});
|
||||
std.log.debug("request_set_title unimplemented", .{});
|
||||
|
|
|
|||
|
|
@ -148,7 +148,10 @@ pub fn openLibs(self: *zlua.Lua) void {
|
|||
}
|
||||
}
|
||||
|
||||
pub const Config = struct { str: ?[]const u8, enabled: bool, };
|
||||
pub const Config = struct {
|
||||
str: ?[]const u8,
|
||||
enabled: bool,
|
||||
};
|
||||
pub fn init(self: *Lua, cfg: Config) !void {
|
||||
self.state = try zlua.Lua.init(gpa);
|
||||
errdefer self.state.deinit();
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ fn output_id_err(L: *zlua.Lua) noreturn {
|
|||
}
|
||||
|
||||
/// ---@alias output_id integer
|
||||
|
||||
/// ---Get the ids for all available outputs
|
||||
/// ---@return output_id[]?
|
||||
pub fn get_all_ids(L: *zlua.Lua) i32 {
|
||||
|
|
|
|||
|
|
@ -51,7 +51,6 @@ pub fn get_all_ids(L: *zlua.Lua) i32 {
|
|||
var view_it = layer.children.iterator(.forward);
|
||||
|
||||
while (view_it.next()) |v| {
|
||||
|
||||
if (v.data == null) {
|
||||
std.log.err("Unassigned arbitrary data in scene graph", .{});
|
||||
unreachable;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ pub fn callback(self: *const Mousemap, state: MousemapState, args: anytype) bool
|
|||
const lua_ref_idx = switch (state) {
|
||||
.press => self.options.lua_press_ref_idx,
|
||||
.release => self.options.lua_release_ref_idx,
|
||||
.drag => self.options.lua_drag_ref_idx
|
||||
.drag => self.options.lua_drag_ref_idx,
|
||||
};
|
||||
|
||||
const t = Lua.state.rawGetIndex(zlua.registry_index, lua_ref_idx);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue