mirror of
https://github.com/MezzalunaWM/Mezzaluna.git
synced 2026-03-07 19:49:53 -05:00
basic data retrieval output api and some more view api
This commit is contained in:
parent
d4ab71fb35
commit
d34db37589
11 changed files with 272 additions and 72 deletions
|
|
@ -10,3 +10,8 @@ insert_final_newline = true
|
||||||
indent_style = space
|
indent_style = space
|
||||||
indent_size = 2
|
indent_size = 2
|
||||||
trim_trailing_whitespace = true
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[*.lua]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
|
||||||
|
|
@ -10,16 +10,11 @@ end
|
||||||
mez.path.config = mez.fs.joinpath(env_conf, "mez", "init.lua")
|
mez.path.config = mez.fs.joinpath(env_conf, "mez", "init.lua")
|
||||||
package.path = package.path..";"..mez.fs.joinpath(env_conf, "mez", "lua", "?.lua")
|
package.path = package.path..";"..mez.fs.joinpath(env_conf, "mez", "lua", "?.lua")
|
||||||
|
|
||||||
-- this is an example
|
|
||||||
mez.input.add_keymap("alt", "a", {
|
|
||||||
press = function()
|
|
||||||
print("hello from my keymap")
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
||||||
mez.input.add_keymap("alt", "Return", {
|
mez.input.add_keymap("alt", "Return", {
|
||||||
press = function()
|
press = function()
|
||||||
mez.api.spawn("foot")
|
-- foot doesnt resize on uneven columns
|
||||||
|
-- this means alacritty is just better (period)
|
||||||
|
mez.api.spawn("alacritty")
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -36,35 +31,27 @@ mez.input.add_keymap("alt", "q", {
|
||||||
})
|
})
|
||||||
|
|
||||||
mez.input.add_keymap("alt", "v", {
|
mez.input.add_keymap("alt", "v", {
|
||||||
press = function ()
|
press = function ()
|
||||||
local view = mez.view.get_focused_id()
|
local id = mez.view.get_focused_id()
|
||||||
mez.view.set_position(view, 100, 100)
|
|
||||||
mez.view.set_size(view, 100, 100)
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
||||||
mez.input.add_keymap("alt", "v", {
|
local details = mez.view.get_details(id);
|
||||||
press = function ()
|
print(details.title);
|
||||||
local view = mez.view.get_focused_id()
|
print(details.app_id);
|
||||||
mez.view.set_position(view, 100, 100)
|
end
|
||||||
mez.view.set_size(view, 100, 100)
|
|
||||||
end
|
|
||||||
})
|
})
|
||||||
|
|
||||||
mez.input.add_keymap("alt", "Tab", {
|
mez.input.add_keymap("alt", "Tab", {
|
||||||
press = function ()
|
press = function ()
|
||||||
print("alt+tab")
|
local focused = mez.view.get_focused_id()
|
||||||
|
local all = mez.view.get_all_ids()
|
||||||
|
|
||||||
local focused = mez.view.get_focused_id()
|
for _, id in ipairs(all) do
|
||||||
local all = mez.view.get_all_ids()
|
if id ~= focused then
|
||||||
|
mez.view.set_focused(id)
|
||||||
for _, id in ipairs(all) do
|
return
|
||||||
if id ~= focused then
|
end
|
||||||
mez.view.set_focused(id)
|
end
|
||||||
return
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
})
|
})
|
||||||
|
|
||||||
for i = 1, 12 do
|
for i = 1, 12 do
|
||||||
|
|
@ -73,9 +60,22 @@ for i = 1, 12 do
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
mez.input.add_keymap("alt", "t", {
|
||||||
|
press = function() tiler() end
|
||||||
|
})
|
||||||
|
|
||||||
|
local tiler = function ()
|
||||||
|
local all = mez.view.get_all_ids()
|
||||||
|
|
||||||
|
for i, id in ipairs(all) do
|
||||||
|
mez.view.set_position(id, (1920 / #all) * (i - 1), 0)
|
||||||
|
mez.view.set_size(id, 1920 / #all, 1080)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
mez.hook.add("ViewMapPre", {
|
mez.hook.add("ViewMapPre", {
|
||||||
callback = function(v)
|
callback = function(v)
|
||||||
mez.view.set_size(v, 1000, 1000)
|
tiler()
|
||||||
mez.view.set_focused(v)
|
mez.view.set_focused(v)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@ pub fn spawn(L: *zlua.Lua) i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
L.checkType(1, .string);
|
L.checkType(1, .string);
|
||||||
std.log.debug("GOT HERE", .{});
|
|
||||||
|
|
||||||
const cmd = L.toString(1) catch {
|
const cmd = L.toString(1) catch {
|
||||||
L.raiseErrorStr("Lua error check your config", .{});
|
L.raiseErrorStr("Lua error check your config", .{});
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ const Input = @import("input.zig");
|
||||||
const Api = @import("api.zig");
|
const Api = @import("api.zig");
|
||||||
const Hook = @import("hook.zig");
|
const Hook = @import("hook.zig");
|
||||||
const View = @import("view.zig");
|
const View = @import("view.zig");
|
||||||
|
const Output = @import("output.zig");
|
||||||
|
|
||||||
const gpa = std.heap.c_allocator;
|
const gpa = std.heap.c_allocator;
|
||||||
|
|
||||||
|
|
@ -81,6 +82,11 @@ pub fn init(self: *Lua) !void {
|
||||||
self.state.newLib(view_funcs);
|
self.state.newLib(view_funcs);
|
||||||
self.state.setField(-2, "view");
|
self.state.setField(-2, "view");
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
const output_funcs = zlua.fnRegsFromType(Output);
|
||||||
|
self.state.newLib(output_funcs);
|
||||||
|
self.state.setField(-2, "output");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
loadRuntimeDir(self) catch |err| {
|
loadRuntimeDir(self) catch |err| {
|
||||||
|
|
|
||||||
137
src/lua/output.zig
Normal file
137
src/lua/output.zig
Normal file
|
|
@ -0,0 +1,137 @@
|
||||||
|
const std = @import("std");
|
||||||
|
const zlua = @import("zlua");
|
||||||
|
const wlr = @import("wlroots");
|
||||||
|
|
||||||
|
const Output = @import("../output.zig");
|
||||||
|
|
||||||
|
const gpa = std.heap.c_allocator;
|
||||||
|
const server = &@import("../main.zig").server;
|
||||||
|
|
||||||
|
pub fn get_all_ids(L: *zlua.Lua) i32 {
|
||||||
|
var it = server.root.scene.outputs.iterator(.forward);
|
||||||
|
var index: usize = 1;
|
||||||
|
|
||||||
|
L.newTable();
|
||||||
|
|
||||||
|
while(it.next()) |scene_output| : (index += 1) {
|
||||||
|
if(scene_output.output.data == null) continue;
|
||||||
|
|
||||||
|
const output = @as(*Output, @ptrCast(@alignCast(scene_output.output.data.?)));
|
||||||
|
|
||||||
|
L.pushInteger(@intCast(index));
|
||||||
|
L.pushInteger(@intCast(output.id));
|
||||||
|
L.setTable(-3);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_focused_id(L: *zlua.Lua) i32 {
|
||||||
|
if(server.seat.focused_output) |output| {
|
||||||
|
L.pushInteger(@intCast(output.id));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_rate(L: *zlua.Lua) i32 {
|
||||||
|
const nargs: i32 = L.getTop();
|
||||||
|
|
||||||
|
if(nargs != 1) {
|
||||||
|
L.raiseErrorStr("Expected 1 argument, found", .{nargs});
|
||||||
|
}
|
||||||
|
|
||||||
|
L.checkType(1, .number);
|
||||||
|
|
||||||
|
const output_id: u64 = @as(u64, @intCast(L.toInteger(1) catch {
|
||||||
|
L.raiseErrorStr("Arg is not convertable to an int", .{});
|
||||||
|
}));
|
||||||
|
|
||||||
|
if(server.root.outputById(output_id)) |output| {
|
||||||
|
L.pushInteger(@intCast(output.wlr_output.refresh));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_resolution(L: *zlua.Lua) i32 {
|
||||||
|
const nargs: i32 = L.getTop();
|
||||||
|
|
||||||
|
if(nargs != 1) {
|
||||||
|
L.raiseErrorStr("Expected 1 argument, found", .{nargs});
|
||||||
|
}
|
||||||
|
|
||||||
|
L.checkType(1, .number);
|
||||||
|
|
||||||
|
const output_id: u64 = @as(u64, @intCast(L.toInteger(1) catch {
|
||||||
|
L.raiseErrorStr("Arg is not convertable to an int", .{});
|
||||||
|
}));
|
||||||
|
|
||||||
|
if(server.root.outputById(output_id)) |output| {
|
||||||
|
L.newTable();
|
||||||
|
|
||||||
|
_ = L.pushString("width");
|
||||||
|
L.pushInteger(@intCast(output.wlr_output.width));
|
||||||
|
L.setTable(-3);
|
||||||
|
|
||||||
|
_ = L.pushString("height");
|
||||||
|
L.pushInteger(@intCast(output.wlr_output.height));
|
||||||
|
L.setTable(-3);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_details(L: *zlua.Lua) i32 {
|
||||||
|
const nargs: i32 = L.getTop();
|
||||||
|
|
||||||
|
if(nargs != 1) {
|
||||||
|
L.raiseErrorStr("Expected 1 argument, found", .{nargs});
|
||||||
|
}
|
||||||
|
|
||||||
|
L.checkType(1, .number);
|
||||||
|
|
||||||
|
const output_id: u64 = @as(u64, @intCast(L.toInteger(1) catch {
|
||||||
|
L.raiseErrorStr("Arg is not convertable to an int", .{});
|
||||||
|
}));
|
||||||
|
|
||||||
|
if(server.root.outputById(output_id)) |output| {
|
||||||
|
L.newTable();
|
||||||
|
|
||||||
|
if(output.wlr_output.description) |detail| {
|
||||||
|
_ = L.pushString("description");
|
||||||
|
_ = L.pushString(std.mem.span(detail));
|
||||||
|
L.setTable(-3);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(output.wlr_output.model) |detail| {
|
||||||
|
_ = L.pushString("model");
|
||||||
|
_ = L.pushString(std.mem.span(detail));
|
||||||
|
L.setTable(-3);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(output.wlr_output.make) |detail| {
|
||||||
|
_ = L.pushString("make");
|
||||||
|
_ = L.pushString(std.mem.span(detail));
|
||||||
|
L.setTable(-3);
|
||||||
|
}
|
||||||
|
|
||||||
|
_ = L.pushString("name");
|
||||||
|
_ = L.pushString(std.mem.span(output.wlr_output.name));
|
||||||
|
L.setTable(-3);
|
||||||
|
|
||||||
|
if(output.wlr_output.serial) |detail| {
|
||||||
|
_ = L.pushString("serial");
|
||||||
|
_ = L.pushString(std.mem.span(detail));
|
||||||
|
L.setTable(-3);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
@ -21,7 +21,7 @@ pub fn get_all_ids(L: *zlua.Lua) i32 {
|
||||||
|
|
||||||
L.pushInteger(@intCast(index));
|
L.pushInteger(@intCast(index));
|
||||||
L.pushInteger(@intCast(view.id));
|
L.pushInteger(@intCast(view.id));
|
||||||
L.setTable(1);
|
L.setTable(-3);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
@ -39,8 +39,6 @@ pub fn get_focused_id(L: *zlua.Lua) i32 {
|
||||||
pub fn set_position(L: *zlua.Lua) i32 {
|
pub fn set_position(L: *zlua.Lua) i32 {
|
||||||
const nargs: i32 = L.getTop();
|
const nargs: i32 = L.getTop();
|
||||||
|
|
||||||
std.log.debug("Starting view reposition", .{});
|
|
||||||
|
|
||||||
if (nargs != 3) {
|
if (nargs != 3) {
|
||||||
L.raiseErrorStr("Expected 3 arguments, found {d}", .{nargs});
|
L.raiseErrorStr("Expected 3 arguments, found {d}", .{nargs});
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -50,9 +48,9 @@ pub fn set_position(L: *zlua.Lua) i32 {
|
||||||
L.checkType(@intCast(i), .number);
|
L.checkType(@intCast(i), .number);
|
||||||
}
|
}
|
||||||
|
|
||||||
const view_id: u64 = @as(u64, @intCast(L.toInteger(1) catch unreachable));
|
const view_id: u64 = @as(u64, @intCast(L.toInteger(1) catch { L.raiseErrorStr("Arg is not convertable to an int", .{}); }));
|
||||||
const x: i32 = @as(i32, @intCast(L.toInteger(2) catch unreachable));
|
const x: i32 = @as(i32, @intFromFloat(L.toNumber(2) catch { L.raiseErrorStr("Arg is not convertable to an int", .{}); }));
|
||||||
const y: i32 = @as(i32, @intCast(L.toInteger(3) catch unreachable));
|
const y: i32 = @as(i32, @intFromFloat(L.toNumber(3) catch { L.raiseErrorStr("Arg is not convertable to an int", .{}); }));
|
||||||
|
|
||||||
const view = server.root.viewById(view_id);
|
const view = server.root.viewById(view_id);
|
||||||
if(view == null) {
|
if(view == null) {
|
||||||
|
|
@ -77,9 +75,9 @@ pub fn set_size(L: *zlua.Lua) i32 {
|
||||||
L.checkType(@intCast(i), .number);
|
L.checkType(@intCast(i), .number);
|
||||||
}
|
}
|
||||||
|
|
||||||
const view_id: u64 = @as(u64, @intCast(L.toInteger(1) catch unreachable));
|
const view_id: u64 = @as(u64, @intCast(L.toInteger(1) catch { L.raiseErrorStr("Arg is not convertable to an int", .{}); }));
|
||||||
const width: i32 = @as(i32, @intCast(L.toInteger(2) catch unreachable));
|
const width: i32 = @as(i32, @intFromFloat(L.toNumber(2) catch { L.raiseErrorStr("Arg is not convertable to an int", .{}); }));
|
||||||
const height: i32 = @as(i32, @intCast(L.toInteger(3) catch unreachable));
|
const height: i32 = @as(i32, @intFromFloat(L.toNumber(3) catch { L.raiseErrorStr("Arg is not convertable to an int", .{}); }));
|
||||||
|
|
||||||
const view = server.root.viewById(view_id);
|
const view = server.root.viewById(view_id);
|
||||||
if(view == null) {
|
if(view == null) {
|
||||||
|
|
@ -102,7 +100,7 @@ pub fn set_focused(L: *zlua.Lua) i32 {
|
||||||
|
|
||||||
L.checkType(1, .number);
|
L.checkType(1, .number);
|
||||||
|
|
||||||
const view_id: u64 = @intCast(L.toInteger(1) catch unreachable);
|
const view_id: u64 = @as(u64, @intCast(L.toInteger(1) catch { L.raiseErrorStr("Arg is not convertable to an int", .{}); }));
|
||||||
|
|
||||||
const view = server.root.viewById(view_id);
|
const view = server.root.viewById(view_id);
|
||||||
if(view == null) {
|
if(view == null) {
|
||||||
|
|
@ -114,3 +112,36 @@ pub fn set_focused(L: *zlua.Lua) i32 {
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_details(L: *zlua.Lua) i32 {
|
||||||
|
const nargs: i32 = L.getTop();
|
||||||
|
|
||||||
|
if(nargs != 1) {
|
||||||
|
L.raiseErrorStr("Expected 1 arguments, found {d}", .{nargs});
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
L.checkType(1, .number);
|
||||||
|
|
||||||
|
const view_id: u64 = @as(u64, @intCast(L.toInteger(1) catch { L.raiseErrorStr("Arg is not convertable to an int", .{}); }));
|
||||||
|
|
||||||
|
if(server.root.viewById(view_id)) |view| {
|
||||||
|
L.newTable();
|
||||||
|
|
||||||
|
if(view.xdg_toplevel.title) |detail| {
|
||||||
|
_ = L.pushString("title");
|
||||||
|
_ = L.pushString(std.mem.span(detail));
|
||||||
|
L.setTable(-3);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(view.xdg_toplevel.app_id) |detail| {
|
||||||
|
_ = L.pushString("app_id");
|
||||||
|
_ = L.pushString(std.mem.span(detail));
|
||||||
|
L.setTable(-3);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ const gpa = std.heap.c_allocator;
|
||||||
const server = &@import("main.zig").server;
|
const server = &@import("main.zig").server;
|
||||||
|
|
||||||
focused: bool,
|
focused: bool,
|
||||||
|
id: u64,
|
||||||
|
|
||||||
wlr_output: *wlr.Output,
|
wlr_output: *wlr.Output,
|
||||||
state: wlr.Output.State,
|
state: wlr.Output.State,
|
||||||
|
|
@ -24,61 +25,73 @@ destroy: wl.Listener(*wlr.Output) = .init(handleDestroy),
|
||||||
pub fn init(wlr_output: *wlr.Output) ?*Output {
|
pub fn init(wlr_output: *wlr.Output) ?*Output {
|
||||||
errdefer Utils.oomPanic();
|
errdefer Utils.oomPanic();
|
||||||
|
|
||||||
const output = try gpa.create(Output);
|
const self = try gpa.create(Output);
|
||||||
|
|
||||||
output.* = .{
|
self.* = .{
|
||||||
.focused = false,
|
.focused = false,
|
||||||
|
.id = @intFromPtr(wlr_output),
|
||||||
.wlr_output = wlr_output,
|
.wlr_output = wlr_output,
|
||||||
.scene_output = try server.root.scene.createSceneOutput(wlr_output),
|
.scene_output = try server.root.scene.createSceneOutput(wlr_output),
|
||||||
.state = wlr.Output.State.init()
|
.state = wlr.Output.State.init()
|
||||||
};
|
};
|
||||||
|
|
||||||
wlr_output.events.frame.add(&output.frame);
|
wlr_output.events.frame.add(&self.frame);
|
||||||
wlr_output.events.request_state.add(&output.request_state);
|
wlr_output.events.request_state.add(&self.request_state);
|
||||||
wlr_output.events.destroy.add(&output.destroy);
|
wlr_output.events.destroy.add(&self.destroy);
|
||||||
|
|
||||||
errdefer deinit(output);
|
errdefer deinit(self);
|
||||||
|
|
||||||
if(!wlr_output.initRender(server.allocator, server.renderer)) {
|
if(!wlr_output.initRender(server.allocator, server.renderer)) {
|
||||||
std.log.err("Unable to start output {s}", .{wlr_output.name});
|
std.log.err("Unable to start output {s}", .{wlr_output.name});
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
output.state.setEnabled(true);
|
self.state.setEnabled(true);
|
||||||
|
|
||||||
if (wlr_output.preferredMode()) |mode| {
|
if (wlr_output.preferredMode()) |mode| {
|
||||||
output.state.setMode(mode);
|
self.state.setMode(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!wlr_output.commitState(&output.state)) {
|
if(!wlr_output.commitState(&self.state)) {
|
||||||
std.log.err("Unable to commit state to output {s}", .{wlr_output.name});
|
std.log.err("Unable to commit state to output {s}", .{wlr_output.name});
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
server.root.addOutput(output);
|
const layout_output = try server.root.output_layout.addAuto(self.wlr_output);
|
||||||
|
server.root.scene_output_layout.addOutput(layout_output, self.scene_output);
|
||||||
|
self.setFocused();
|
||||||
|
|
||||||
return output;
|
wlr_output.data = self;
|
||||||
|
|
||||||
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn deinit(output: *Output) void {
|
pub fn deinit(self: *Output) void {
|
||||||
output.frame.link.remove();
|
self.frame.link.remove();
|
||||||
output.request_state.link.remove();
|
self.request_state.link.remove();
|
||||||
output.destroy.remove();
|
self.destroy.link.remove();
|
||||||
|
|
||||||
output.state.finish();
|
self.state.finish();
|
||||||
|
|
||||||
output.wlr_output.destroy();
|
self.wlr_output.destroy();
|
||||||
|
|
||||||
gpa.free(output);
|
gpa.destroy(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn setFocused(self: *Output) void {
|
||||||
|
if(server.seat.focused_output) |prev_output| {
|
||||||
|
prev_output.focused = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
server.seat.focused_output = self;
|
||||||
|
self.focused = true;
|
||||||
|
}
|
||||||
|
|
||||||
// --------- WlrOutput Event Handlers ---------
|
// --------- WlrOutput Event Handlers ---------
|
||||||
fn handleRequestState(
|
fn handleRequestState(
|
||||||
listener: *wl.Listener(*wlr.Output.event.RequestState),
|
listener: *wl.Listener(*wlr.Output.event.RequestState),
|
||||||
event: *wlr.Output.event.RequestState,
|
event: *wlr.Output.event.RequestState,
|
||||||
) void {
|
) void {
|
||||||
std.log.debug("Handling request state", .{});
|
|
||||||
const output: *Output = @fieldParentPtr("request_state", listener);
|
const output: *Output = @fieldParentPtr("request_state", listener);
|
||||||
|
|
||||||
if (!output.wlr_output.commitState(event.state)) {
|
if (!output.wlr_output.commitState(event.state)) {
|
||||||
|
|
|
||||||
16
src/root.zig
16
src/root.zig
|
|
@ -67,11 +67,17 @@ pub fn viewById(self: *Root, id: u64) ?*View {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn addOutput(self: *Root, new_output: *Output) void {
|
pub fn outputById(self: *Root, id: u64) ?*Output {
|
||||||
errdefer Utils.oomPanic();
|
var it = self.scene.outputs.iterator(.forward);
|
||||||
const layout_output = try self.output_layout.addAuto(new_output.wlr_output);
|
|
||||||
self.scene_output_layout.addOutput(layout_output, new_output.scene_output);
|
while(it.next()) |scene_output| {
|
||||||
server.seat.focusOutput(new_output);
|
if(scene_output.output.data == null) continue;
|
||||||
|
|
||||||
|
const output: *Output = @as(*Output, @ptrCast(@alignCast(scene_output.output.data.?)));
|
||||||
|
if(output.id == id) return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ViewAtResult = struct {
|
const ViewAtResult = struct {
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ pub fn deinit(self: *Seat) void {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn focusOutput(self: *Seat, output: *Output) void {
|
pub fn focusOutput(self: *Seat, output: *Output) void {
|
||||||
if(self.focused_output) |prev_output| {
|
if(server.seat.focused_output) |prev_output| {
|
||||||
prev_output.focused = false;
|
prev_output.focused = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,6 @@ pub fn callback(self: *const Hook, args: anytype) void {
|
||||||
i = k;
|
i = k;
|
||||||
}
|
}
|
||||||
|
|
||||||
Lua.state.protectedCall(.{ .args = i }) catch {
|
Lua.state.protectedCall(.{ .args = i }) catch { };
|
||||||
};
|
|
||||||
Lua.state.pop(-1);
|
Lua.state.pop(-1);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -157,6 +157,8 @@ fn handleUnmap(listener: *wl.Listener(void)) void {
|
||||||
const view: *View = @fieldParentPtr("unmap", listener);
|
const view: *View = @fieldParentPtr("unmap", listener);
|
||||||
std.log.debug("Unmapping view '{s}'", .{view.xdg_toplevel.title orelse "(unnamed)"});
|
std.log.debug("Unmapping view '{s}'", .{view.xdg_toplevel.title orelse "(unnamed)"});
|
||||||
|
|
||||||
|
server.events.exec("ViewUnmapPre", .{view.id});
|
||||||
|
|
||||||
view.request_fullscreen.link.remove();
|
view.request_fullscreen.link.remove();
|
||||||
view.request_move.link.remove();
|
view.request_move.link.remove();
|
||||||
view.request_resize.link.remove();
|
view.request_resize.link.remove();
|
||||||
|
|
@ -167,6 +169,8 @@ fn handleUnmap(listener: *wl.Listener(void)) void {
|
||||||
// view.ack_configure.link.remove();
|
// view.ack_configure.link.remove();
|
||||||
|
|
||||||
view.mapped = false;
|
view.mapped = false;
|
||||||
|
|
||||||
|
server.events.exec("ViewUnmapPost", .{view.id});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handleDestroy(listener: *wl.Listener(void)) void {
|
fn handleDestroy(listener: *wl.Listener(void)) void {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue