aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsaac Freund <ifreund@ifreund.xyz>2020-04-08 17:43:00 +0200
committerIsaac Freund <ifreund@ifreund.xyz>2020-04-08 17:43:00 +0200
commitb2fbdf2d87e21c724d82eb59ef7f5dae26b39c7e (patch)
tree7e443d4538337bce3425d6afb458c4fb33e569b2
parentdd480ca567b68ac59d9b37f0fae0e0ec8d2b1001 (diff)
downloadriver-b2fbdf2d87e21c724d82eb59ef7f5dae26b39c7e.tar.gz
river-b2fbdf2d87e21c724d82eb59ef7f5dae26b39c7e.tar.xz
Add keybind to close views
-rw-r--r--src/command.zig7
-rw-r--r--src/config.zig2
-rw-r--r--src/view.zig7
3 files changed, 16 insertions, 0 deletions
diff --git a/src/command.zig b/src/command.zig
index add31ea..7aac7f6 100644
--- a/src/command.zig
+++ b/src/command.zig
@@ -111,3 +111,10 @@ pub fn spawn(server: *Server, arg: Arg) void {
const child = std.ChildProcess.init(&argv, std.heap.c_allocator) catch unreachable;
std.ChildProcess.spawn(child) catch unreachable;
}
+
+/// Close the focused view, if any.
+pub fn close(server: *Server, arg: Arg) void {
+ if (server.root.focused_view) |view| {
+ view.close();
+ }
+}
diff --git a/src/config.zig b/src/config.zig
index 7e70778..1434f07 100644
--- a/src/config.zig
+++ b/src/config.zig
@@ -75,5 +75,7 @@ pub const Config = struct {
try self.keybinds.append(Keybind{ .keysym = c.XKB_KEY_0, .modifiers = mod, .command = command.focusTags, .arg = .{ .uint = 0xFFFFFFFF } });
try self.keybinds.append(Keybind{ .keysym = c.XKB_KEY_0, .modifiers = mod | c.WLR_MODIFIER_SHIFT, .command = command.setFocusedViewTags, .arg = .{ .uint = 0xFFFFFFFF } });
+
+ try self.keybinds.append(Keybind{ .keysym = c.XKB_KEY_q, .modifiers = mod, .command = command.close, .arg = .{ .none = {} } });
}
};
diff --git a/src/view.zig b/src/view.zig
index 17a0621..71a00f2 100644
--- a/src/view.zig
+++ b/src/view.zig
@@ -126,6 +126,13 @@ pub const View = struct {
}
}
+ /// Send a close event to the view's client
+ pub fn close(self: Self) void {
+ // Note: we don't call arrange() here as it will be called
+ // automatically when the view is unmapped.
+ c.wlr_xdg_toplevel_send_close(self.wlr_xdg_surface);
+ }
+
fn handleMap(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
// Called when the surface is mapped, or ready to display on-screen.
const view = @fieldParentPtr(View, "listen_map", listener.?);