river-layout: update to v3
- Remove advertise_view and advertise_done events. Using the information provided by these for any purpose would make the layout far less predictable. Futhermore, in the months this has been available for use, to my knowledge nobody has actually used it for anything useful. - Replace the set/mod layout value events with a single user_command event. This simplifies the protocol and is more flexible for clients. - Add a layout_name argument to the commit request. This name is an arbitrary, user-facing string that might, for example, be displayed by a status bar. This was present in early drafts of the protocol, but was removed in favor of river-options. Since river-options itself has since been removed and this feature is nice to have, re-add it. - Rename main factor to main ratio in rivertile. The "factor" name was just legacy from dwm, "ratio" is much more accurate.
This commit is contained in:
@ -36,12 +36,12 @@ const LayoutDemand = @import("LayoutDemand.zig");
|
||||
|
||||
const log = std.log.scoped(.layout);
|
||||
|
||||
layout: *river.LayoutV2,
|
||||
layout: *river.LayoutV3,
|
||||
namespace: []const u8,
|
||||
output: *Output,
|
||||
|
||||
pub fn create(client: *wl.Client, version: u32, id: u32, output: *Output, namespace: []const u8) !void {
|
||||
const layout = try river.LayoutV2.create(client, version, id);
|
||||
const layout = try river.LayoutV3.create(client, version, id);
|
||||
|
||||
if (namespaceInUse(namespace, output, client)) {
|
||||
layout.sendNamespaceInUse();
|
||||
@ -92,7 +92,7 @@ fn namespaceInUse(namespace: []const u8, output: *Output, client: *wl.Client) bo
|
||||
|
||||
/// This exists to handle layouts that have been rendered inert (due to the
|
||||
/// namespace already being in use) until the client destroys them.
|
||||
fn handleRequestInert(layout: *river.LayoutV2, request: river.LayoutV2.Request, _: ?*c_void) void {
|
||||
fn handleRequestInert(layout: *river.LayoutV3, request: river.LayoutV3.Request, _: ?*c_void) void {
|
||||
if (request == .destroy) layout.destroy();
|
||||
}
|
||||
|
||||
@ -108,28 +108,19 @@ pub fn startLayoutDemand(self: *Self, views: u32) void {
|
||||
log.err("failed starting layout demand", .{});
|
||||
return;
|
||||
};
|
||||
const serial = self.output.layout_demand.?.serial;
|
||||
|
||||
// Then we let the client know that we require a layout
|
||||
self.layout.sendLayoutDemand(
|
||||
views,
|
||||
self.output.usable_box.width,
|
||||
self.output.usable_box.height,
|
||||
self.output.pending.tags,
|
||||
serial,
|
||||
self.output.layout_demand.?.serial,
|
||||
);
|
||||
|
||||
// And finally we advertise all visible views
|
||||
var it = ViewStack(View).iter(self.output.views.first, .forward, self.output.pending.tags, Output.arrangeFilter);
|
||||
while (it.next()) |view| {
|
||||
self.layout.sendAdvertiseView(view.pending.tags, view.getAppId(), serial);
|
||||
}
|
||||
self.layout.sendAdvertiseDone(serial);
|
||||
|
||||
server.root.trackLayoutDemands();
|
||||
}
|
||||
|
||||
fn handleRequest(layout: *river.LayoutV2, request: river.LayoutV2.Request, self: *Self) void {
|
||||
fn handleRequest(layout: *river.LayoutV3, request: river.LayoutV3.Request, self: *Self) void {
|
||||
switch (request) {
|
||||
.destroy => layout.destroy(),
|
||||
|
||||
@ -168,7 +159,7 @@ fn handleRequest(layout: *river.LayoutV2, request: river.LayoutV2.Request, self:
|
||||
}
|
||||
}
|
||||
|
||||
fn handleDestroy(layout: *river.LayoutV2, self: *Self) void {
|
||||
fn handleDestroy(layout: *river.LayoutV3, self: *Self) void {
|
||||
self.destroy();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user