tony / oxwm

Branch: c7ee21b
Switch branches/tags
master
Iziram feature : set default layout c7ee21b 2026-03-05
712 lines · 23.5 KB Raw Blame History
1 const std = @import("std");
2
3 const client_mod = @import("../client.zig");
4 const config_mod = @import("../config/config.zig");
5 const lua = @import("../config/lua.zig");
6 const core = @import("core.zig");
7 const tiling = @import("../layouts/tiling.zig");
8 const monitor_mod = @import("../monitor.zig");
9 const wm_mod = @import("wm.zig");
10 const xlib = @import("../x11/xlib.zig");
11
12 const Client = client_mod.Client;
13 const Monitor = monitor_mod.Monitor;
14 const WindowManager = wm_mod.WindowManager;
15
16 const snap_distance: i32 = 32;
17
18 pub fn spawnChildSetup(wm: *WindowManager) void {
19 _ = std.c.setsid();
20 if (wm.x11_fd >= 0) std.posix.close(@intCast(wm.x11_fd));
21 const sigchld_handler = std.posix.Sigaction{
22 .handler = .{ .handler = std.posix.SIG.DFL },
23 .mask = std.mem.zeroes(std.posix.sigset_t),
24 .flags = 0,
25 };
26 std.posix.sigaction(std.posix.SIG.CHLD, &sigchld_handler, null);
27 }
28
29 pub fn spawnCommand(wm: *WindowManager, cmd: []const u8) void {
30 std.debug.print("running cmd: {s}\n", .{cmd});
31 const pid = std.posix.fork() catch return;
32 if (pid == 0) {
33 spawnChildSetup(wm);
34 var cmd_buf: [1024]u8 = undefined;
35 if (cmd.len >= cmd_buf.len) {
36 std.posix.exit(1);
37 }
38 @memcpy(cmd_buf[0..cmd.len], cmd);
39 cmd_buf[cmd.len] = 0;
40 const argv = [_:null]?[*:0]const u8{ "sh", "-c", @ptrCast(&cmd_buf) };
41 _ = std.posix.execvpeZ("sh", &argv, std.c.environ) catch {};
42 std.posix.exit(1);
43 }
44 }
45
46 pub fn spawnTerminal(wm: *WindowManager) void {
47 const pid = std.posix.fork() catch return;
48 if (pid == 0) {
49 spawnChildSetup(wm);
50 var term_buf: [256]u8 = undefined;
51 const terminal = wm.config.terminal;
52 if (terminal.len >= term_buf.len) {
53 std.posix.exit(1);
54 }
55 @memcpy(term_buf[0..terminal.len], terminal);
56 term_buf[terminal.len] = 0;
57 const term_ptr: [*:0]const u8 = @ptrCast(&term_buf);
58 const argv = [_:null]?[*:0]const u8{term_ptr};
59 _ = std.posix.execvpeZ(term_ptr, &argv, std.c.environ) catch {};
60 std.posix.exit(1);
61 }
62 }
63
64 pub fn movestack(direction: i32, wm: *WindowManager) void {
65 const monitor = wm.selected_monitor orelse return;
66 const current = monitor.sel orelse return;
67
68 if (current.is_floating) {
69 return;
70 }
71
72 var target: ?*Client = null;
73
74 if (direction > 0) {
75 target = current.next;
76 while (target) |client| {
77 if (client_mod.isVisible(client) and !client.is_floating) {
78 break;
79 }
80 target = client.next;
81 }
82 if (target == null) {
83 target = monitor.clients;
84 while (target) |client| {
85 if (client == current) {
86 break;
87 }
88 if (client_mod.isVisible(client) and !client.is_floating) {
89 break;
90 }
91 target = client.next;
92 }
93 }
94 } else {
95 var prev: ?*Client = null;
96 var iter = monitor.clients;
97 while (iter) |client| {
98 if (client == current) {
99 break;
100 }
101 if (client_mod.isVisible(client) and !client.is_floating) {
102 prev = client;
103 }
104 iter = client.next;
105 }
106 if (prev == null) {
107 iter = current.next;
108 while (iter) |client| {
109 if (client_mod.isVisible(client) and !client.is_floating) {
110 prev = client;
111 }
112 iter = client.next;
113 }
114 }
115 target = prev;
116 }
117
118 if (target) |swap_client| {
119 if (swap_client != current) {
120 client_mod.swapClients(current, swap_client);
121 core.arrange(monitor, wm);
122 core.focus(current, wm);
123 }
124 }
125 }
126
127 pub fn toggleView(tag_mask: u32, wm: *WindowManager) void {
128 const monitor = wm.selected_monitor orelse return;
129 const new_tags = monitor.tagset[monitor.sel_tags] ^ tag_mask;
130 if (new_tags != 0) {
131 monitor.tagset[monitor.sel_tags] = new_tags;
132
133 if (new_tags == ~@as(u32, 0)) {
134 monitor.pertag.prevtag = monitor.pertag.curtag;
135 monitor.pertag.curtag = 0;
136 }
137
138 if ((new_tags & (@as(u32, 1) << @intCast(monitor.pertag.curtag -| 1))) == 0) {
139 monitor.pertag.prevtag = monitor.pertag.curtag;
140 var i: u32 = 0;
141 while (i < 9) : (i += 1) {
142 if ((new_tags & (@as(u32, 1) << @intCast(i))) != 0) break;
143 }
144 monitor.pertag.curtag = i + 1;
145 }
146
147 monitor.nmaster = monitor.pertag.nmasters[monitor.pertag.curtag];
148 monitor.mfact = monitor.pertag.mfacts[monitor.pertag.curtag];
149 monitor.sel_lt = monitor.pertag.sellts[monitor.pertag.curtag];
150
151 core.focusTopClient(monitor, wm);
152 core.arrange(monitor, wm);
153 wm.invalidateBars();
154 }
155 }
156
157 pub fn toggleClientTag(tag_mask: u32, wm: *WindowManager) void {
158 const monitor = wm.selected_monitor orelse return;
159 const client = monitor.sel orelse return;
160 const new_tags = client.tags ^ tag_mask;
161 if (new_tags != 0) {
162 client.tags = new_tags;
163 core.focusTopClient(monitor, wm);
164 core.arrange(monitor, wm);
165 wm.invalidateBars();
166 }
167 }
168
169 pub fn toggleGaps(wm: *WindowManager) void {
170 const monitor = wm.selected_monitor orelse return;
171 if (monitor.gap_inner_h == 0) {
172 monitor.gap_inner_h = wm.config.gap_inner_h;
173 monitor.gap_inner_v = wm.config.gap_inner_v;
174 monitor.gap_outer_h = wm.config.gap_outer_h;
175 monitor.gap_outer_v = wm.config.gap_outer_v;
176 } else {
177 monitor.gap_inner_h = 0;
178 monitor.gap_inner_v = 0;
179 monitor.gap_outer_h = 0;
180 monitor.gap_outer_v = 0;
181 }
182 core.arrange(monitor, wm);
183 }
184
185 pub fn killFocused(wm: *WindowManager) void {
186 const selected = wm.selected_monitor orelse return;
187 const client = selected.sel orelse return;
188 std.debug.print("killing window: 0x{x}\n", .{client.window});
189
190 if (!core.sendEvent(client, wm.atoms.wm_delete, wm)) {
191 _ = xlib.XGrabServer(wm.display.handle);
192 _ = xlib.XKillClient(wm.display.handle, client.window);
193 _ = xlib.XSync(wm.display.handle, xlib.False);
194 _ = xlib.XUngrabServer(wm.display.handle);
195 }
196 }
197
198 pub fn toggleFullscreen(wm: *WindowManager) void {
199 const selected = wm.selected_monitor orelse return;
200 const client = selected.sel orelse return;
201 core.setFullscreen(client, !client.is_fullscreen, wm);
202 }
203
204 pub fn viewAdjacentTag(direction: i32, wm: *WindowManager) void {
205 const monitor = wm.selected_monitor orelse return;
206 const current_tag = monitor.pertag.curtag;
207 var new_tag: i32 = @intCast(current_tag);
208
209 new_tag += direction;
210 if (new_tag < 1) new_tag = 9;
211 if (new_tag > 9) new_tag = 1;
212
213 const tag_mask: u32 = @as(u32, 1) << @intCast(new_tag - 1);
214 core.view(tag_mask, wm);
215 }
216
217 pub fn viewAdjacentNonemptyTag(direction: i32, wm: *WindowManager) void {
218 const monitor = wm.selected_monitor orelse return;
219 const current_tag = monitor.pertag.curtag;
220 var new_tag: i32 = @intCast(current_tag);
221
222 var attempts: i32 = 0;
223 while (attempts < 9) : (attempts += 1) {
224 new_tag += direction;
225 if (new_tag < 1) new_tag = 9;
226 if (new_tag > 9) new_tag = 1;
227
228 const tag_mask: u32 = @as(u32, 1) << @intCast(new_tag - 1);
229 if (core.hasClientsOnTag(monitor, tag_mask)) {
230 core.view(tag_mask, wm);
231 return;
232 }
233 }
234 }
235
236 pub fn tagClient(tag_mask: u32, wm: *WindowManager) void {
237 const monitor = wm.selected_monitor orelse return;
238 const client = monitor.sel orelse return;
239 if (tag_mask == 0) {
240 return;
241 }
242 client.tags = tag_mask;
243 core.focusTopClient(monitor, wm);
244 core.arrange(monitor, wm);
245 wm.invalidateBars();
246 std.debug.print("tag_client: window=0x{x} tag_mask={d}\n", .{ client.window, tag_mask });
247 }
248
249 pub fn focusstack(direction: i32, wm: *WindowManager) void {
250 const monitor = wm.selected_monitor orelse return;
251 const current = monitor.sel orelse return;
252
253 var next_client: ?*Client = null;
254
255 if (direction > 0) {
256 next_client = current.next;
257 while (next_client) |client| {
258 if (client_mod.isVisible(client)) {
259 break;
260 }
261 next_client = client.next;
262 }
263 if (next_client == null) {
264 next_client = monitor.clients;
265 while (next_client) |client| {
266 if (client_mod.isVisible(client)) {
267 break;
268 }
269 next_client = client.next;
270 }
271 }
272 } else {
273 var prev: ?*Client = null;
274 var iter = monitor.clients;
275 while (iter) |client| {
276 if (client == current) {
277 break;
278 }
279 if (client_mod.isVisible(client)) {
280 prev = client;
281 }
282 iter = client.next;
283 }
284 if (prev == null) {
285 iter = current.next;
286 while (iter) |client| {
287 if (client_mod.isVisible(client)) {
288 prev = client;
289 }
290 iter = client.next;
291 }
292 }
293 next_client = prev;
294 }
295
296 if (next_client) |client| {
297 core.focus(client, wm);
298 if (client.monitor) |client_monitor| {
299 core.restack(client_monitor, wm);
300 }
301 }
302 }
303
304 pub fn toggleFloating(wm: *WindowManager) void {
305 const monitor = wm.selected_monitor orelse return;
306 const client = monitor.sel orelse return;
307
308 if (client.is_fullscreen) {
309 return;
310 }
311
312 client.is_floating = !client.is_floating;
313
314 if (client.is_floating) {
315 tiling.resize(client, client.x, client.y, client.width, client.height, false);
316 }
317
318 core.arrange(monitor, wm);
319 std.debug.print("toggle_floating: window=0x{x} floating={}\n", .{ client.window, client.is_floating });
320 }
321
322 pub fn incnmaster(delta: i32, wm: *WindowManager) void {
323 const monitor = wm.selected_monitor orelse return;
324 const new_val = @max(0, monitor.nmaster + delta);
325 monitor.nmaster = new_val;
326 monitor.pertag.nmasters[monitor.pertag.curtag] = new_val;
327 core.arrange(monitor, wm);
328 std.debug.print("incnmaster: nmaster={d}\n", .{monitor.nmaster});
329 }
330
331 pub fn setmfact(delta: f32, wm: *WindowManager) void {
332 const monitor = wm.selected_monitor orelse return;
333 const new_mfact = monitor.mfact + delta;
334 if (new_mfact < 0.05 or new_mfact > 0.95) {
335 return;
336 }
337 monitor.mfact = new_mfact;
338 monitor.pertag.mfacts[monitor.pertag.curtag] = new_mfact;
339 core.arrange(monitor, wm);
340 std.debug.print("setmfact: mfact={d:.2}\n", .{monitor.mfact});
341 }
342
343 pub fn cycleLayout(wm: *WindowManager) void {
344 const monitor = wm.selected_monitor orelse return;
345 const new_lt = (monitor.sel_lt + 1) % @as(u32, @intCast(std.meta.fields(config_mod.Layouts).len));
346 monitor.sel_lt = new_lt;
347 monitor.pertag.sellts[monitor.pertag.curtag] = new_lt;
348 if (new_lt != @intFromEnum(config_mod.Layouts.scrolling)) {
349 monitor.scroll_offset = 0;
350 }
351 core.arrange(monitor, wm);
352 wm.invalidateBars();
353 if (monitor.lt[@as(usize, monitor.sel_lt)]) |layout| {
354 std.debug.print("cycle_layout: {s}\n", .{layout.symbol});
355 }
356 }
357
358 pub fn setLayout(layout_name: ?[]const u8, wm: *WindowManager) void {
359 const monitor = wm.selected_monitor orelse return;
360 const name = layout_name orelse return;
361 const new_lt: u32 = if (std.meta.stringToEnum(config_mod.Layouts, name)) |value|
362 @intFromEnum(value)
363 else {
364 std.debug.print("set_layout: unknown layout '{s}'\n", .{name});
365 return;
366 };
367 monitor.sel_lt = new_lt;
368 monitor.pertag.sellts[monitor.pertag.curtag] = new_lt;
369 if (new_lt != @intFromEnum(config_mod.Layouts.scrolling)) {
370 monitor.scroll_offset = 0;
371 }
372 core.arrange(monitor, wm);
373 wm.invalidateBars();
374 if (monitor.lt[@as(usize, monitor.sel_lt)]) |layout| {
375 std.debug.print("set_layout: {s}\n", .{layout.symbol});
376 }
377 }
378
379 pub fn setLayoutIndex(index: u32, wm: *WindowManager) void {
380 const monitor = wm.selected_monitor orelse return;
381 const lt_index = index % @as(u32, @intCast(std.meta.fields(config_mod.Layouts).len));
382 monitor.sel_lt = lt_index;
383 monitor.pertag.sellts[monitor.pertag.curtag] = lt_index;
384 if (lt_index != @intFromEnum(config_mod.Layouts.scrolling)) {
385 monitor.scroll_offset = 0;
386 }
387 core.arrange(monitor, wm);
388 wm.invalidateBars();
389 if (monitor.lt[@as(usize, monitor.sel_lt)]) |layout| {
390 std.debug.print("set_layout_index: {s}\n", .{layout.symbol});
391 }
392 }
393
394 pub fn focusmon(direction: i32, wm: *WindowManager) void {
395 const selmon = wm.selected_monitor orelse return;
396 const target = monitor_mod.dirToMonitor(wm, direction) orelse return;
397 if (target == selmon) {
398 return;
399 }
400 core.unfocusClient(selmon.sel, false, wm);
401 wm.selected_monitor = target;
402 core.focus(null, wm);
403 std.debug.print("focusmon: monitor {d}\n", .{target.num});
404 }
405
406 pub fn sendmon(direction: i32, wm: *WindowManager) void {
407 const source_monitor = wm.selected_monitor orelse return;
408 const client = source_monitor.sel orelse return;
409 const target = monitor_mod.dirToMonitor(wm, direction) orelse return;
410
411 if (target == source_monitor) {
412 return;
413 }
414
415 client_mod.detach(client);
416 client_mod.detachStack(client);
417 client.monitor = target;
418 client.tags = target.tagset[target.sel_tags];
419 client_mod.attachAside(client);
420 client_mod.attachStack(client);
421
422 core.focusTopClient(source_monitor, wm);
423 core.arrange(source_monitor, wm);
424 core.arrange(target, wm);
425
426 std.debug.print("sendmon: window=0x{x} to monitor {d}\n", .{ client.window, target.num });
427 }
428
429 pub fn snapX(client: *Client, new_x: i32, monitor: *Monitor) i32 {
430 const client_width = client.width + 2 * client.border_width;
431 if (@abs(monitor.win_x - new_x) < snap_distance) {
432 return monitor.win_x;
433 } else if (@abs((monitor.win_x + monitor.win_w) - (new_x + client_width)) < snap_distance) {
434 return monitor.win_x + monitor.win_w - client_width;
435 }
436 return new_x;
437 }
438
439 pub fn snapY(client: *Client, new_y: i32, monitor: *Monitor) i32 {
440 const client_height = client.height + 2 * client.border_width;
441 if (@abs(monitor.win_y - new_y) < snap_distance) {
442 return monitor.win_y;
443 } else if (@abs((monitor.win_y + monitor.win_h) - (new_y + client_height)) < snap_distance) {
444 return monitor.win_y + monitor.win_h - client_height;
445 }
446 return new_y;
447 }
448
449 pub fn movemouse(wm: *WindowManager) void {
450 const monitor = wm.selected_monitor orelse return;
451 const client = monitor.sel orelse return;
452
453 if (client.is_fullscreen) {
454 return;
455 }
456
457 core.restack(monitor, wm);
458
459 const was_floating = client.is_floating;
460 if (!client.is_floating) {
461 client.is_floating = true;
462 }
463
464 var root_x: c_int = undefined;
465 var root_y: c_int = undefined;
466 var dummy_win: xlib.Window = undefined;
467 var dummy_int: c_int = undefined;
468 var dummy_uint: c_uint = undefined;
469
470 _ = xlib.XQueryPointer(wm.display.handle, wm.display.root, &dummy_win, &dummy_win, &root_x, &root_y, &dummy_int, &dummy_int, &dummy_uint);
471
472 const grab_result = xlib.XGrabPointer(
473 wm.display.handle,
474 wm.display.root,
475 xlib.False,
476 xlib.ButtonPressMask | xlib.ButtonReleaseMask | xlib.PointerMotionMask,
477 xlib.GrabModeAsync,
478 xlib.GrabModeAsync,
479 xlib.None,
480 wm.cursors.move,
481 xlib.CurrentTime,
482 );
483
484 if (grab_result != xlib.GrabSuccess) {
485 return;
486 }
487
488 const start_x = client.x;
489 const start_y = client.y;
490 const pointer_start_x = root_x;
491 const pointer_start_y = root_y;
492 var last_time: c_ulong = 0;
493
494 var event: xlib.XEvent = undefined;
495 var done = false;
496
497 while (!done) {
498 _ = xlib.XNextEvent(wm.display.handle, &event);
499
500 switch (event.type) {
501 xlib.MotionNotify => {
502 const motion = &event.xmotion;
503 if ((motion.time - last_time) < (1000 / 60)) {
504 continue;
505 }
506 last_time = motion.time;
507 const delta_x = motion.x_root - pointer_start_x;
508 const delta_y = motion.y_root - pointer_start_y;
509 var new_x = start_x + delta_x;
510 var new_y = start_y + delta_y;
511 if (client.monitor) |client_monitor| {
512 new_x = snapX(client, new_x, client_monitor);
513 new_y = snapY(client, new_y, client_monitor);
514 }
515 tiling.resize(client, new_x, new_y, client.width, client.height, true);
516 },
517 xlib.ButtonRelease => {
518 done = true;
519 },
520 else => {},
521 }
522 }
523
524 _ = xlib.XUngrabPointer(wm.display.handle, xlib.CurrentTime);
525
526 const new_mon = monitor_mod.rectToMonitor(wm, client.x, client.y, client.width, client.height);
527 if (new_mon != null and new_mon != monitor) {
528 client_mod.detach(client);
529 client_mod.detachStack(client);
530 client.monitor = new_mon;
531 client.tags = new_mon.?.tagset[new_mon.?.sel_tags];
532 client_mod.attachAside(client);
533 client_mod.attachStack(client);
534 wm.selected_monitor = new_mon;
535 core.focus(client, wm);
536 core.arrange(monitor, wm);
537 core.arrange(new_mon.?, wm);
538 } else {
539 core.arrange(monitor, wm);
540 }
541
542 if (wm.config.auto_tile and !was_floating) {
543 const drop_monitor = client.monitor orelse return;
544 const center_x = client.x + @divTrunc(client.width, 2);
545 const center_y = client.y + @divTrunc(client.height, 2);
546
547 if (client_mod.tiledWindowAt(client, drop_monitor, center_x, center_y)) |target| {
548 client_mod.insertBefore(client, target);
549 }
550
551 client.is_floating = false;
552 core.arrange(drop_monitor, wm);
553 }
554 }
555
556 pub fn resizemouse(wm: *WindowManager) void {
557 const monitor = wm.selected_monitor orelse return;
558 const client = monitor.sel orelse return;
559
560 if (client.is_fullscreen) {
561 return;
562 }
563
564 core.restack(monitor, wm);
565
566 if (!client.is_floating) {
567 client.is_floating = true;
568 }
569
570 const grab_result = xlib.XGrabPointer(
571 wm.display.handle,
572 wm.display.root,
573 xlib.False,
574 xlib.ButtonPressMask | xlib.ButtonReleaseMask | xlib.PointerMotionMask,
575 xlib.GrabModeAsync,
576 xlib.GrabModeAsync,
577 xlib.None,
578 wm.cursors.resize,
579 xlib.CurrentTime,
580 );
581
582 if (grab_result != xlib.GrabSuccess) {
583 return;
584 }
585
586 _ = xlib.XWarpPointer(wm.display.handle, xlib.None, client.window, 0, 0, 0, 0, client.width + client.border_width - 1, client.height + client.border_width - 1);
587
588 var event: xlib.XEvent = undefined;
589 var done = false;
590 var last_time: c_ulong = 0;
591
592 while (!done) {
593 _ = xlib.XNextEvent(wm.display.handle, &event);
594
595 switch (event.type) {
596 xlib.MotionNotify => {
597 const motion = &event.xmotion;
598 if ((motion.time - last_time) < (1000 / 60)) {
599 continue;
600 }
601 last_time = motion.time;
602 var new_width = @max(1, motion.x_root - client.x - 2 * client.border_width + 1);
603 var new_height = @max(1, motion.y_root - client.y - 2 * client.border_width + 1);
604 if (client.monitor) |client_monitor| {
605 const client_right = client.x + new_width + 2 * client.border_width;
606 const client_bottom = client.y + new_height + 2 * client.border_width;
607 const mon_right = client_monitor.win_x + client_monitor.win_w;
608 const mon_bottom = client_monitor.win_y + client_monitor.win_h;
609 if (@abs(mon_right - client_right) < snap_distance) {
610 new_width = @max(1, mon_right - client.x - 2 * client.border_width);
611 }
612 if (@abs(mon_bottom - client_bottom) < snap_distance) {
613 new_height = @max(1, mon_bottom - client.y - 2 * client.border_width);
614 }
615 }
616 tiling.resize(client, client.x, client.y, new_width, new_height, true);
617 },
618 xlib.ButtonRelease => {
619 done = true;
620 },
621 else => {},
622 }
623 }
624
625 _ = xlib.XUngrabPointer(wm.display.handle, xlib.CurrentTime);
626 core.arrange(monitor, wm);
627 }
628
629 /// Config-loading callback for wm.reloadConfig().
630 /// Re-initialises Lua and loads the config file (or falls back to defaults).
631 pub fn reloadLoadConfig(wm: *WindowManager) void {
632 lua.deinit();
633 _ = lua.init(&wm.config);
634
635 const loaded = if (wm.config_path) |path|
636 lua.loadFile(path)
637 else
638 lua.loadConfig();
639
640 if (loaded) {
641 if (wm.config_path) |path| {
642 std.debug.print("reloaded config from {s}\n", .{path});
643 } else {
644 std.debug.print("reloaded config from ~/.config/oxwm/config.lua\n", .{});
645 }
646 } else {
647 std.debug.print("reload failed, restoring defaults\n", .{});
648 config_mod.initializeDefaultConfig(&wm.config);
649 }
650 }
651
652 pub fn executeAction(action: config_mod.Action, int_arg: i32, str_arg: ?[]const u8, wm: *WindowManager) void {
653 switch (action) {
654 .spawn_terminal => spawnTerminal(wm),
655 .spawn => {
656 if (str_arg) |cmd| spawnCommand(wm, cmd);
657 },
658 .kill_client => killFocused(wm),
659 .quit => {
660 std.debug.print("quit keybind pressed\n", .{});
661 wm.running = false;
662 },
663 .reload_config => wm.reloadConfig(reloadLoadConfig),
664 .restart => wm.reloadConfig(reloadLoadConfig),
665 .show_keybinds => {
666 if (wm.overlay) |overlay| {
667 const mon = wm.selected_monitor orelse wm.monitors;
668 if (mon) |m| {
669 overlay.toggle(m.mon_x, m.mon_y, m.mon_w, m.mon_h, &wm.config);
670 }
671 }
672 },
673 .focus_next => focusstack(1, wm),
674 .focus_prev => focusstack(-1, wm),
675 .move_next => movestack(1, wm),
676 .move_prev => movestack(-1, wm),
677 .resize_master => setmfact(@as(f32, @floatFromInt(int_arg)) / 1000.0, wm),
678 .inc_master => incnmaster(1, wm),
679 .dec_master => incnmaster(-1, wm),
680 .toggle_floating => toggleFloating(wm),
681 .toggle_fullscreen => toggleFullscreen(wm),
682 .toggle_gaps => toggleGaps(wm),
683 .cycle_layout => cycleLayout(wm),
684 .set_layout => setLayout(str_arg, wm),
685 .set_layout_tiling => setLayoutIndex(0, wm),
686 .set_layout_floating => setLayoutIndex(2, wm),
687 .view_tag => {
688 const tag_mask: u32 = @as(u32, 1) << @intCast(int_arg);
689 core.view(tag_mask, wm);
690 },
691 .view_next_tag => viewAdjacentTag(1, wm),
692 .view_prev_tag => viewAdjacentTag(-1, wm),
693 .view_next_nonempty_tag => viewAdjacentNonemptyTag(1, wm),
694 .view_prev_nonempty_tag => viewAdjacentNonemptyTag(-1, wm),
695 .move_to_tag => {
696 const tag_mask: u32 = @as(u32, 1) << @intCast(int_arg);
697 tagClient(tag_mask, wm);
698 },
699 .toggle_view_tag => {
700 const tag_mask: u32 = @as(u32, 1) << @intCast(int_arg);
701 toggleView(tag_mask, wm);
702 },
703 .toggle_tag => {
704 const tag_mask: u32 = @as(u32, 1) << @intCast(int_arg);
705 toggleClientTag(tag_mask, wm);
706 },
707 .focus_monitor => focusmon(int_arg, wm),
708 .send_to_monitor => sendmon(int_arg, wm),
709 .scroll_left => core.scrollLayout(-1, wm),
710 .scroll_right => core.scrollLayout(1, wm),
711 }
712 }