Merge pull request 'Implement tags' (#4) from tag-implementation into main
Reviewed-on: https://codeberg.org/bwbuhse/beansprout/pulls/4
This commit is contained in:
commit
726d346015
6 changed files with 242 additions and 110 deletions
|
|
@ -5,3 +5,11 @@ SPDX-License-Identifier: EUPL-1.2
|
|||
-->
|
||||
|
||||
# beansprout wm
|
||||
|
||||
|
||||
## TODOs
|
||||
[ ] Support multiple outputs
|
||||
[ ] Support multiple seats
|
||||
[ ] Support floating windows
|
||||
[ ] Support wallpapers
|
||||
[ ] Support a bar
|
||||
|
|
|
|||
|
|
@ -13,10 +13,17 @@ height: i32 = 0,
|
|||
x: i32 = 0,
|
||||
y: i32 = 0,
|
||||
|
||||
/// Tags are 32-bit bitfield. A window can be active on one(?) or more tags.
|
||||
tags: u32 = 0x0001,
|
||||
|
||||
pending_manage: PendingManage = .{},
|
||||
|
||||
link: wl.list.Link,
|
||||
|
||||
pub const PendingManage = struct {
|
||||
tags: ?u32 = null,
|
||||
};
|
||||
|
||||
pub fn create(context: *Context, river_output_v1: *river.OutputV1) !*Output {
|
||||
var output = try utils.allocator.create(Output);
|
||||
errdefer output.destroy();
|
||||
|
|
@ -49,7 +56,8 @@ fn outputListener(river_output_v1: *river.OutputV1, event: river.OutputV1.Event,
|
|||
output.height = ev.height;
|
||||
},
|
||||
.position => |ev| {
|
||||
// TODO - CONFIG: Allow setting output position (do I even need to do this?)
|
||||
// TODO - CONFIG: Allow setting output position (do I even need to
|
||||
// do this, or do I just get told what the position is?)
|
||||
output.x = ev.x;
|
||||
output.y = ev.y;
|
||||
},
|
||||
|
|
@ -57,7 +65,11 @@ fn outputListener(river_output_v1: *river.OutputV1, event: river.OutputV1.Event,
|
|||
}
|
||||
|
||||
pub fn manage(output: *Output) void {
|
||||
_ = output;
|
||||
defer output.pending_manage = .{};
|
||||
|
||||
if (output.pending_manage.tags) |tags| {
|
||||
output.tags = tags;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn render(output: *Output) void {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,11 @@ fullscreen: bool = false,
|
|||
maximized: bool = false,
|
||||
|
||||
tags: u32 = 0x0001,
|
||||
output: ?*Output,
|
||||
// output: ?*Output,
|
||||
|
||||
// XXX: Do I really even need to store `show`?
|
||||
// I think I only would if I was trying not to send extraneous requests.
|
||||
show: bool = true,
|
||||
|
||||
initialized: bool = false,
|
||||
|
||||
|
|
@ -28,6 +32,10 @@ pending_manage: PendingManage = .{},
|
|||
/// State consumed in render() phase, reset at end of render().
|
||||
pending_render: PendingRender = .{},
|
||||
|
||||
/// Used to put Windows into a list in
|
||||
/// WindowManager.calculatePriamryStackLayout()
|
||||
active_list_node: DoublyLinkedList.Node = .{},
|
||||
|
||||
link: wl.list.Link,
|
||||
|
||||
pub const PendingManage = struct {
|
||||
|
|
@ -36,6 +44,9 @@ pub const PendingManage = struct {
|
|||
|
||||
fullscreen: ?bool = null,
|
||||
maximized: ?bool = null,
|
||||
|
||||
tags: ?u32 = null,
|
||||
// output: ?*Output = null,
|
||||
};
|
||||
|
||||
pub const PendingRender = struct {
|
||||
|
|
@ -43,9 +54,11 @@ pub const PendingRender = struct {
|
|||
y: ?i32 = null,
|
||||
|
||||
focused: ?bool = null,
|
||||
|
||||
show: ?bool = null,
|
||||
};
|
||||
|
||||
pub fn create(context: *Context, river_window_v1: *river.WindowV1, output: ?*Output) !*Window {
|
||||
pub fn create(context: *Context, river_window_v1: *river.WindowV1, output: *Output) !*Window {
|
||||
var window = try utils.allocator.create(Window);
|
||||
errdefer window.destroy();
|
||||
|
||||
|
|
@ -53,16 +66,11 @@ pub fn create(context: *Context, river_window_v1: *river.WindowV1, output: ?*Out
|
|||
.context = context,
|
||||
.river_window_v1 = river_window_v1,
|
||||
.river_node_v1 = river_window_v1.getNode() catch @panic("Failed to get node"),
|
||||
.output = output,
|
||||
// .output = output,
|
||||
.tags = if (output.tags != 0) output.tags else 0x0001,
|
||||
.link = undefined, // Handled by the wl.list
|
||||
};
|
||||
|
||||
if (output) |out| {
|
||||
window.tags = if (out.tags != 0) out.tags else 0x0001;
|
||||
} else {
|
||||
window.tags = 0x0001;
|
||||
}
|
||||
|
||||
window.river_window_v1.setListener(*Window, windowListener, window);
|
||||
|
||||
return window;
|
||||
|
|
@ -119,6 +127,7 @@ fn windowListener(river_window_v1: *river.WindowV1, event: river.WindowV1.Event,
|
|||
|
||||
pub fn manage(window: *Window) void {
|
||||
if (!window.initialized) {
|
||||
// Only happens once per Window
|
||||
@branchHint(.unlikely);
|
||||
window.initialized = true;
|
||||
|
||||
|
|
@ -130,7 +139,7 @@ pub fn manage(window: *Window) void {
|
|||
window.river_window_v1.setTiled(.{ .top = true, .bottom = true, .left = true, .right = true });
|
||||
}
|
||||
|
||||
// Any new state since the last manage event
|
||||
// Updating state since the last manage event
|
||||
defer window.pending_manage = .{};
|
||||
const pending_manage = window.pending_manage;
|
||||
// Layout (pre-computed by WindowManager.calculatePrimaryStackLayout())
|
||||
|
|
@ -141,7 +150,6 @@ pub fn manage(window: *Window) void {
|
|||
window.river_window_v1.proposeDimensions(new_width, new_height);
|
||||
}
|
||||
}
|
||||
|
||||
// Fullscreen and maximize operations
|
||||
if (pending_manage.fullscreen) |fullscreen| {
|
||||
window.fullscreen = fullscreen;
|
||||
|
|
@ -162,6 +170,10 @@ pub fn manage(window: *Window) void {
|
|||
window.river_window_v1.informUnmaximized();
|
||||
}
|
||||
}
|
||||
// New tags
|
||||
if (pending_manage.tags) |tags| {
|
||||
window.tags = tags;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn render(window: *Window) void {
|
||||
|
|
@ -192,6 +204,19 @@ pub fn render(window: *Window) void {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Show or hide the Window
|
||||
if (window.pending_render.show) |show| {
|
||||
if (show) {
|
||||
if (!window.show) {
|
||||
window.river_window_v1.show();
|
||||
}
|
||||
} else {
|
||||
if (window.show) {
|
||||
window.river_window_v1.hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn applyBorders(window: *Window, color: utils.RiverColor) void {
|
||||
|
|
@ -202,6 +227,7 @@ fn applyBorders(window: *Window, color: utils.RiverColor) void {
|
|||
|
||||
const std = @import("std");
|
||||
const assert = std.debug.assert;
|
||||
const DoublyLinkedList = std.DoublyLinkedList;
|
||||
|
||||
const wayland = @import("wayland");
|
||||
const wl = wayland.client.wl;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ const MIN_RIVER_SEAT_V1_VERSION: u2 = 3;
|
|||
|
||||
context: *Context,
|
||||
|
||||
window_manager_v1: *river.WindowManagerV1,
|
||||
river_window_manager_v1: *river.WindowManagerV1,
|
||||
|
||||
seats: wl.list.Head(Seat, .link),
|
||||
outputs: wl.list.Head(Output, .link),
|
||||
|
|
@ -24,7 +24,7 @@ pub fn create(context: *Context, window_manager_v1: *river.WindowManagerV1) !*Wi
|
|||
|
||||
wm.* = .{
|
||||
.context = context,
|
||||
.window_manager_v1 = window_manager_v1,
|
||||
.river_window_manager_v1 = window_manager_v1,
|
||||
.seats = undefined, // we will initialize these shortly
|
||||
.outputs = undefined,
|
||||
.windows = undefined,
|
||||
|
|
@ -34,28 +34,32 @@ pub fn create(context: *Context, window_manager_v1: *river.WindowManagerV1) !*Wi
|
|||
wm.outputs.init();
|
||||
wm.windows.init();
|
||||
|
||||
wm.window_manager_v1.setListener(*WindowManager, windowManagerV1Listener, wm);
|
||||
wm.river_window_manager_v1.setListener(*WindowManager, windowManagerV1Listener, wm);
|
||||
|
||||
return wm;
|
||||
}
|
||||
|
||||
pub fn destroy(wm: *WindowManager) void {
|
||||
var window_it = wm.windows.iterator(.forward);
|
||||
while (window_it.next()) |window| {
|
||||
window.link.remove();
|
||||
window.destroy();
|
||||
{
|
||||
var it = wm.windows.safeIterator(.forward);
|
||||
while (it.next()) |window| {
|
||||
window.link.remove();
|
||||
window.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
var output_it = wm.outputs.iterator(.forward);
|
||||
while (output_it.next()) |output| {
|
||||
output.link.remove();
|
||||
output.destroy();
|
||||
{
|
||||
var it = wm.outputs.safeIterator(.forward);
|
||||
while (it.next()) |output| {
|
||||
output.link.remove();
|
||||
output.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
var seat_it = wm.seats.iterator(.forward);
|
||||
while (seat_it.next()) |seat| {
|
||||
seat.link.remove();
|
||||
seat.destroy();
|
||||
{
|
||||
var it = wm.seats.safeIterator(.forward);
|
||||
while (it.next()) |seat| {
|
||||
seat.link.remove();
|
||||
seat.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
utils.allocator.destroy(wm);
|
||||
|
|
@ -89,20 +93,37 @@ pub fn getPrevWindow(wm: *WindowManager, current: *Window) ?*Window {
|
|||
/// - Single window: maximized
|
||||
/// - Multiple windows: stack (45% left, vertically tiled), primary (55% right)
|
||||
fn calculatePrimaryStackLayout(wm: *WindowManager) void {
|
||||
const count = wm.window_count;
|
||||
if (count == 0) return;
|
||||
|
||||
// TODO: Support multiple outputs
|
||||
const output = wm.outputs.first() orelse return;
|
||||
|
||||
// Get a list of active windows
|
||||
var active_list: DoublyLinkedList = .{};
|
||||
var active_count: u31 = 0;
|
||||
var it = wm.windows.iterator(.forward);
|
||||
while (it.next()) |window| {
|
||||
if (output.tags & window.tags != 0x0000) {
|
||||
active_list.append(&window.active_list_node);
|
||||
active_count += 1;
|
||||
window.pending_render.show = true;
|
||||
} else {
|
||||
window.pending_render.show = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (active_count == 0) return;
|
||||
|
||||
// Output dimensions come as i32 from the protocol, convert to u31 for window dimensions
|
||||
// since they can't be negative.
|
||||
const output_width: u31 = @intCast(output.width);
|
||||
const output_height: u31 = @intCast(output.height);
|
||||
const output_x = output.x;
|
||||
const output_y = output.y;
|
||||
|
||||
var index: u8 = 0;
|
||||
var it = wm.windows.iterator(.forward);
|
||||
while (it.next()) |window| {
|
||||
if (count == 1) {
|
||||
// Iterate through the active windows and apply the tags
|
||||
var i: u31 = 0;
|
||||
while (active_list.popFirst()) |node| : (i += 1) {
|
||||
const window: *Window = @fieldParentPtr("active_list_node", node);
|
||||
if (active_count == 1) {
|
||||
// Single window: maximize
|
||||
window.pending_render.x = output_x;
|
||||
window.pending_render.y = output_y;
|
||||
|
|
@ -114,11 +135,11 @@ fn calculatePrimaryStackLayout(wm: *WindowManager) void {
|
|||
// TODO: Support multiple windows in primary stack
|
||||
const primary_width: u31 = @intFromFloat(@as(f32, @floatFromInt(output_width)) * PRIMARY_RATIO);
|
||||
const stack_width: u31 = output_width - primary_width;
|
||||
const stack_count = count - 1;
|
||||
const stack_count = active_count - 1;
|
||||
const stack_height: u31 = @divFloor(output_height, stack_count);
|
||||
window.pending_manage.maximized = false;
|
||||
|
||||
if (index == 0) {
|
||||
if (i == 0) {
|
||||
// Primary window (first window) - right side
|
||||
window.pending_render.x = output_x + @as(i32, stack_width);
|
||||
window.pending_render.y = output_y;
|
||||
|
|
@ -126,12 +147,12 @@ fn calculatePrimaryStackLayout(wm: *WindowManager) void {
|
|||
window.pending_manage.height = output_height;
|
||||
} else {
|
||||
// Stack window(s) - left side
|
||||
const stack_index = index - 1;
|
||||
const stack_index = i - 1;
|
||||
window.pending_render.x = output_x;
|
||||
window.pending_render.y = output_y + @as(i32, stack_index) * @as(i32, stack_height);
|
||||
window.pending_manage.width = stack_width;
|
||||
// Last stack window gets remaining height to avoid gaps from integer division
|
||||
if (index == count - 1) {
|
||||
if (i == active_count - 1) {
|
||||
window.pending_manage.height = output_height - stack_index * stack_height;
|
||||
} else {
|
||||
window.pending_manage.height = stack_height;
|
||||
|
|
@ -142,83 +163,104 @@ fn calculatePrimaryStackLayout(wm: *WindowManager) void {
|
|||
// Borders are automatically disabled when a window is fullscreened so we don't
|
||||
// have to worry about that.
|
||||
const border_width = wm.context.config.border_width;
|
||||
// We use .? because we know we set the windows height, width, x, and y above
|
||||
window.pending_manage.height.? -= 2 * border_width;
|
||||
window.pending_manage.width.? -= 2 * border_width;
|
||||
window.pending_render.x.? += border_width;
|
||||
window.pending_render.y.? += border_width;
|
||||
|
||||
index += 1;
|
||||
}
|
||||
|
||||
// Make sure we went through the whole list
|
||||
assert(active_list.first == null);
|
||||
}
|
||||
|
||||
fn manage_start(wm: *WindowManager) void {
|
||||
const river_window_manager_v1 = wm.river_window_manager_v1;
|
||||
const context = wm.context;
|
||||
if (!context.initialized) {
|
||||
// This code (should) only be run once while initializing the WM, so let's
|
||||
// mark it as cold.
|
||||
@branchHint(.cold);
|
||||
context.initialized = true;
|
||||
|
||||
const seat = wm.seats.first() orelse @panic("Failed to get seat");
|
||||
const river_seat_v1 = seat.river_seat_v1;
|
||||
context.xkb_bindings.addBinding(river_seat_v1, xkbcommon.Keysym.t, .{ .mod4 = true }, .{ .spawn = &.{"foot"} });
|
||||
context.xkb_bindings.addBinding(river_seat_v1, xkbcommon.Keysym.j, .{ .mod4 = true }, .focus_next);
|
||||
context.xkb_bindings.addBinding(river_seat_v1, xkbcommon.Keysym.k, .{ .mod4 = true }, .focus_prev);
|
||||
context.xkb_bindings.addBinding(river_seat_v1, xkbcommon.Keysym.f, .{ .mod4 = true }, .toggle_fullscreen);
|
||||
context.xkb_bindings.addBinding(river_seat_v1, xkbcommon.Keysym.q, .{ .mod4 = true, .shift = true }, .close_window);
|
||||
context.xkb_bindings.addBinding(river_seat_v1, xkbcommon.Keysym.e, .{ .mod4 = true, .shift = true }, .exit);
|
||||
|
||||
// Tag bindings
|
||||
comptime var i: u8 = 1;
|
||||
comptime var buffer: [1]u8 = undefined;
|
||||
inline while (i <= 9) : (i += 1) {
|
||||
const tags: u32 = 1 << (i - 1);
|
||||
buffer[0] = i + '0';
|
||||
context.xkb_bindings.addBinding(river_seat_v1, @field(xkbcommon.Keysym, &buffer), .{ .mod4 = true }, .{ .set_output_tags = tags });
|
||||
context.xkb_bindings.addBinding(river_seat_v1, @field(xkbcommon.Keysym, &buffer), .{ .mod4 = true, .shift = true }, .{ .set_window_tags = tags });
|
||||
context.xkb_bindings.addBinding(river_seat_v1, @field(xkbcommon.Keysym, &buffer), .{ .mod4 = true, .ctrl = true }, .{ .toggle_output_tags = tags });
|
||||
context.xkb_bindings.addBinding(river_seat_v1, @field(xkbcommon.Keysym, &buffer), .{ .mod4 = true, .shift = true, .ctrl = true }, .{ .toggle_window_tags = tags });
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
var it = wm.outputs.iterator(.forward);
|
||||
while (it.next()) |output| {
|
||||
output.manage();
|
||||
}
|
||||
}
|
||||
{
|
||||
// Calculate layout before managing windows
|
||||
wm.calculatePrimaryStackLayout();
|
||||
var it = wm.windows.iterator(.forward);
|
||||
while (it.next()) |window| {
|
||||
window.manage();
|
||||
}
|
||||
}
|
||||
{
|
||||
var it = wm.seats.iterator(.forward);
|
||||
while (it.next()) |seat| {
|
||||
seat.manage();
|
||||
}
|
||||
}
|
||||
river_window_manager_v1.manageFinish();
|
||||
}
|
||||
|
||||
fn render_start(wm: *WindowManager) void {
|
||||
const river_window_manager_v1 = wm.river_window_manager_v1;
|
||||
{
|
||||
var it = wm.seats.iterator(.forward);
|
||||
while (it.next()) |seat| {
|
||||
seat.render();
|
||||
}
|
||||
}
|
||||
{
|
||||
var it = wm.outputs.iterator(.forward);
|
||||
while (it.next()) |output| {
|
||||
output.render();
|
||||
}
|
||||
}
|
||||
{
|
||||
var it = wm.windows.iterator(.forward);
|
||||
while (it.next()) |window| {
|
||||
window.render();
|
||||
}
|
||||
}
|
||||
river_window_manager_v1.renderFinish();
|
||||
}
|
||||
|
||||
fn windowManagerV1Listener(window_manager_v1: *river.WindowManagerV1, event: river.WindowManagerV1.Event, wm: *WindowManager) void {
|
||||
assert(wm.window_manager_v1 == window_manager_v1);
|
||||
assert(wm.river_window_manager_v1 == window_manager_v1);
|
||||
const context = wm.context;
|
||||
switch (event) {
|
||||
.unavailable => {
|
||||
log.err("Window manager unavailable (some other wm instance is running). Exiting", .{});
|
||||
std.posix.exit(1);
|
||||
},
|
||||
.manage_start => {
|
||||
if (!context.initialized) {
|
||||
// This code (should) only be run once while initializing the WM, so let's
|
||||
// mark it as cold.
|
||||
@branchHint(.cold);
|
||||
context.initialized = true;
|
||||
|
||||
const seat = wm.seats.first() orelse @panic("Failed to get seat");
|
||||
const river_seat_v1 = seat.river_seat_v1;
|
||||
context.xkb_bindings.addBinding(river_seat_v1, xkbcommon.Keysym.t, .{ .mod4 = true }, .{ .spawn = &.{"foot"} });
|
||||
context.xkb_bindings.addBinding(river_seat_v1, xkbcommon.Keysym.j, .{ .mod4 = true }, .focus_next);
|
||||
context.xkb_bindings.addBinding(river_seat_v1, xkbcommon.Keysym.k, .{ .mod4 = true }, .focus_prev);
|
||||
context.xkb_bindings.addBinding(river_seat_v1, xkbcommon.Keysym.f, .{ .mod4 = true }, .fullscreen);
|
||||
context.xkb_bindings.addBinding(river_seat_v1, xkbcommon.Keysym.q, .{ .mod4 = true, .shift = true }, .close_window);
|
||||
context.xkb_bindings.addBinding(river_seat_v1, xkbcommon.Keysym.e, .{ .mod4 = true, .shift = true }, .exit);
|
||||
}
|
||||
|
||||
{
|
||||
var it = wm.outputs.iterator(.forward);
|
||||
while (it.next()) |output| {
|
||||
output.manage();
|
||||
}
|
||||
}
|
||||
// Calculate layout before managing windows
|
||||
wm.calculatePrimaryStackLayout();
|
||||
{
|
||||
var it = wm.windows.iterator(.forward);
|
||||
while (it.next()) |window| {
|
||||
window.manage();
|
||||
}
|
||||
}
|
||||
{
|
||||
var it = wm.seats.iterator(.forward);
|
||||
while (it.next()) |seat| {
|
||||
seat.manage();
|
||||
}
|
||||
}
|
||||
window_manager_v1.manageFinish();
|
||||
},
|
||||
.render_start => {
|
||||
{
|
||||
var it = wm.seats.iterator(.forward);
|
||||
while (it.next()) |seat| {
|
||||
seat.render();
|
||||
}
|
||||
}
|
||||
{
|
||||
var it = wm.outputs.iterator(.forward);
|
||||
while (it.next()) |output| {
|
||||
output.render();
|
||||
}
|
||||
}
|
||||
{
|
||||
var it = wm.windows.iterator(.forward);
|
||||
while (it.next()) |window| {
|
||||
window.render();
|
||||
}
|
||||
}
|
||||
window_manager_v1.renderFinish();
|
||||
},
|
||||
.manage_start => wm.manage_start(),
|
||||
.render_start => wm.render_start(),
|
||||
.output => |ev| {
|
||||
log.debug("initializing new wl_output: {d}", .{ev.id.getId()});
|
||||
// TODO: Support multi-output
|
||||
|
|
@ -238,6 +280,7 @@ fn windowManagerV1Listener(window_manager_v1: *river.WindowManagerV1, event: riv
|
|||
wm.seats.append(seat);
|
||||
},
|
||||
.window => |ev| {
|
||||
// TODO: Support multiple seats
|
||||
const seat = wm.seats.first() orelse @panic("Failed to get seat");
|
||||
// TODO: Support multiple outputs
|
||||
const output = wm.outputs.first() orelse @panic("Failed to get output");
|
||||
|
|
@ -258,6 +301,7 @@ fn windowManagerV1Listener(window_manager_v1: *river.WindowManagerV1, event: riv
|
|||
|
||||
const std = @import("std");
|
||||
const assert = std.debug.assert;
|
||||
const DoublyLinkedList = std.DoublyLinkedList;
|
||||
|
||||
const wayland = @import("wayland");
|
||||
const wl = wayland.client.wl;
|
||||
|
|
|
|||
|
|
@ -8,9 +8,17 @@ pub const Command = union(enum) {
|
|||
spawn: []const []const u8,
|
||||
focus_next,
|
||||
focus_prev,
|
||||
fullscreen,
|
||||
toggle_fullscreen,
|
||||
close_window,
|
||||
exit,
|
||||
// Tag management
|
||||
set_output_tags: u32,
|
||||
set_window_tags: u32,
|
||||
toggle_output_tags: u32,
|
||||
toggle_window_tags: u32,
|
||||
spawn_tagmask: u32,
|
||||
focus_previous_tags,
|
||||
send_to_previous_tags,
|
||||
};
|
||||
|
||||
const XkbBinding = struct {
|
||||
|
|
@ -40,8 +48,8 @@ const XkbBinding = struct {
|
|||
utils.allocator.destroy(xkb_binding);
|
||||
}
|
||||
|
||||
fn xkbBindingListener(xkb_binding_v1: *river.XkbBindingV1, event: river.XkbBindingV1.Event, xkb_binding: *XkbBinding) void {
|
||||
assert(xkb_binding.xkb_binding_v1 == xkb_binding_v1);
|
||||
fn xkbBindingListener(river_xkb_binding_v1: *river.XkbBindingV1, event: river.XkbBindingV1.Event, xkb_binding: *XkbBinding) void {
|
||||
assert(xkb_binding.xkb_binding_v1 == river_xkb_binding_v1);
|
||||
switch (event) {
|
||||
.pressed => {
|
||||
xkb_binding.executeCommand();
|
||||
|
|
@ -94,7 +102,7 @@ const XkbBinding = struct {
|
|||
}
|
||||
// context.wm.window_manager_v1.manageDirty();
|
||||
},
|
||||
.fullscreen => {
|
||||
.toggle_fullscreen => {
|
||||
const seat = context.wm.seats.first() orelse return;
|
||||
const window = seat.focused orelse return;
|
||||
window.pending_manage.fullscreen = !window.fullscreen;
|
||||
|
|
@ -110,6 +118,38 @@ const XkbBinding = struct {
|
|||
// TODO: Disabled while I'm working with river within river :P
|
||||
// _ = std.process.Child.init(&.{"killall river"}, std.heap.c_allocator);
|
||||
},
|
||||
.set_output_tags => |tags| {
|
||||
// TODO: Support multiple outputs
|
||||
const output = context.wm.outputs.first() orelse return;
|
||||
output.pending_manage.tags = tags;
|
||||
context.wm.river_window_manager_v1.manageDirty();
|
||||
},
|
||||
.set_window_tags => |tags| {
|
||||
const seat = context.wm.seats.first() orelse return;
|
||||
// TODO: I don't think pending_focus should ever be set at this point?
|
||||
// const window = seat.pending_manage.pending_focus orelse seat.focused;
|
||||
const window = seat.focused orelse return;
|
||||
window.pending_manage.tags = tags;
|
||||
context.wm.river_window_manager_v1.manageDirty();
|
||||
},
|
||||
.toggle_output_tags => |tags| {
|
||||
const output = context.wm.outputs.first() orelse return;
|
||||
const old_tags = output.pending_manage.tags orelse output.tags;
|
||||
output.pending_manage.tags = old_tags ^ tags;
|
||||
context.wm.river_window_manager_v1.manageDirty();
|
||||
},
|
||||
.toggle_window_tags => |tags| {
|
||||
const seat = context.wm.seats.first() orelse return;
|
||||
// TODO: I don't think pending_focus should ever be set at this point?
|
||||
// const window = seat.pending_manage.pending_focus orelse seat.focused;
|
||||
const window = seat.focused orelse return;
|
||||
const old_tags = window.pending_manage.tags orelse window.tags;
|
||||
window.pending_manage.tags = old_tags ^ tags;
|
||||
context.wm.river_window_manager_v1.manageDirty();
|
||||
},
|
||||
.spawn_tagmask, .focus_previous_tags, .send_to_previous_tags => {
|
||||
@panic("Unimplemented");
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -136,7 +176,7 @@ pub fn create(context: *Context, xkb_bindings_v1: *river.XkbBindingsV1) !*XkbBin
|
|||
}
|
||||
|
||||
pub fn destroy(xkb_bindings: *XkbBindings) void {
|
||||
var it = xkb_bindings.bindings.iterator(.forward);
|
||||
var it = xkb_bindings.bindings.safeIterator(.forward);
|
||||
while (it.next()) |binding| {
|
||||
binding.link.remove();
|
||||
binding.xkb_binding_v1.destroy();
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
//
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// Allocator used by the program. We use the c_allocator since we interact with C code
|
||||
// via zig-wayland (and, in the future as of 2026-01-26, other libraries, too).
|
||||
pub const allocator = std.heap.c_allocator;
|
||||
|
||||
pub const RiverColor = struct {
|
||||
|
|
@ -71,7 +73,7 @@ pub fn interfaceNotAdvertised(comptime WaylandGlobal: type) noreturn {
|
|||
std.posix.exit(1);
|
||||
}
|
||||
|
||||
/// Report that the given WaylandGlobal was advertised but the support version was too low exit the program
|
||||
/// Report that the given WaylandGlobal was advertised but the support version was too low and exit the program
|
||||
pub fn versionNotSupported(comptime WaylandGlobal: type, have_version: u32, need_version: u32) noreturn {
|
||||
log.err("The compositor only advertised {s} version {d} but version {d} is required. Exiting", .{ WaylandGlobal.interface.name, have_version, need_version });
|
||||
std.posix.exit(1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue