river-layout: create and implement protocol
Replace the current layout mechanism based on passing args to a child process and parsing it's stdout with a new wayland protocol. This much more robust and allows for more featureful layout generators. Co-authored-by: Isaac Freund <ifreund@ifreund.xyz>
This commit is contained in:
committed by
Isaac Freund
parent
df3e993013
commit
f72656b72e
@ -35,36 +35,6 @@ pub fn borderWidth(
|
||||
server.root.startTransaction();
|
||||
}
|
||||
|
||||
pub fn viewPadding(
|
||||
allocator: *std.mem.Allocator,
|
||||
seat: *Seat,
|
||||
args: []const []const u8,
|
||||
out: *?[]const u8,
|
||||
) Error!void {
|
||||
if (args.len < 2) return Error.NotEnoughArguments;
|
||||
if (args.len > 2) return Error.TooManyArguments;
|
||||
|
||||
const server = seat.input_manager.server;
|
||||
server.config.view_padding = try std.fmt.parseInt(u32, args[1], 10);
|
||||
server.root.arrangeAll();
|
||||
server.root.startTransaction();
|
||||
}
|
||||
|
||||
pub fn outerPadding(
|
||||
allocator: *std.mem.Allocator,
|
||||
seat: *Seat,
|
||||
args: []const []const u8,
|
||||
out: *?[]const u8,
|
||||
) Error!void {
|
||||
if (args.len < 2) return Error.NotEnoughArguments;
|
||||
if (args.len > 2) return Error.TooManyArguments;
|
||||
|
||||
const server = seat.input_manager.server;
|
||||
server.config.outer_padding = try std.fmt.parseInt(u32, args[1], 10);
|
||||
server.root.arrangeAll();
|
||||
server.root.startTransaction();
|
||||
}
|
||||
|
||||
pub fn backgroundColor(
|
||||
allocator: *std.mem.Allocator,
|
||||
seat: *Seat,
|
||||
|
@ -1,38 +0,0 @@
|
||||
// This file is part of river, a dynamic tiling wayland compositor.
|
||||
//
|
||||
// Copyright 2020 The River Developers
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
const std = @import("std");
|
||||
|
||||
const util = @import("../util.zig");
|
||||
|
||||
const Error = @import("../command.zig").Error;
|
||||
const Seat = @import("../Seat.zig");
|
||||
|
||||
pub fn layout(
|
||||
allocator: *std.mem.Allocator,
|
||||
seat: *Seat,
|
||||
args: []const []const u8,
|
||||
out: *?[]const u8,
|
||||
) Error!void {
|
||||
if (args.len < 2) return Error.NotEnoughArguments;
|
||||
|
||||
util.gpa.free(seat.focused_output.layout);
|
||||
seat.focused_output.layout = try std.mem.join(util.gpa, " ", args[1..]);
|
||||
|
||||
seat.focused_output.arrangeViews();
|
||||
seat.input_manager.server.root.startTransaction();
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
// This file is part of river, a dynamic tiling wayland compositor.
|
||||
//
|
||||
// Copyright 2020 The River Developers
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
const std = @import("std");
|
||||
|
||||
const Error = @import("../command.zig").Error;
|
||||
const Seat = @import("../Seat.zig");
|
||||
|
||||
/// Modify the number of main views
|
||||
pub fn modMainCount(
|
||||
allocator: *std.mem.Allocator,
|
||||
seat: *Seat,
|
||||
args: []const []const u8,
|
||||
out: *?[]const u8,
|
||||
) Error!void {
|
||||
if (args.len < 2) return Error.NotEnoughArguments;
|
||||
if (args.len > 2) return Error.TooManyArguments;
|
||||
|
||||
const delta = try std.fmt.parseInt(i32, args[1], 10);
|
||||
const output = seat.focused_output;
|
||||
output.main_count = @intCast(u32, std.math.max(0, @intCast(i32, output.main_count) + delta));
|
||||
output.arrangeViews();
|
||||
output.root.startTransaction();
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
// This file is part of river, a dynamic tiling wayland compositor.
|
||||
//
|
||||
// Copyright 2020 The River Developers
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
const std = @import("std");
|
||||
|
||||
const Error = @import("../command.zig").Error;
|
||||
const Seat = @import("../Seat.zig");
|
||||
|
||||
/// Modify the percent of the width of the screen that the main views occupy.
|
||||
pub fn modMainFactor(
|
||||
allocator: *std.mem.Allocator,
|
||||
seat: *Seat,
|
||||
args: []const []const u8,
|
||||
out: *?[]const u8,
|
||||
) Error!void {
|
||||
if (args.len < 2) return Error.NotEnoughArguments;
|
||||
if (args.len > 2) return Error.TooManyArguments;
|
||||
|
||||
const delta = try std.fmt.parseFloat(f64, args[1]);
|
||||
const output = seat.focused_output;
|
||||
const new_main_factor = std.math.min(std.math.max(output.main_factor + delta, 0.05), 0.95);
|
||||
if (new_main_factor != output.main_factor) {
|
||||
output.main_factor = new_main_factor;
|
||||
output.arrangeViews();
|
||||
output.root.startTransaction();
|
||||
}
|
||||
}
|
@ -134,8 +134,13 @@ pub fn resize(
|
||||
}
|
||||
|
||||
fn apply(view: *View) void {
|
||||
// Set the view to floating but keep the position and dimensions
|
||||
view.pending.float = true;
|
||||
// Set the view to floating but keep the position and dimensions, if their
|
||||
// dimensions are set by a layout client. If however the views are
|
||||
// unarranged, leave them as non-floating so the next active layout can
|
||||
// affect them.
|
||||
if (view.output.current.layout != null)
|
||||
view.pending.float = true;
|
||||
|
||||
view.float_box = view.pending.box;
|
||||
|
||||
view.applyPending();
|
||||
|
@ -33,6 +33,12 @@ pub fn toggleFloat(
|
||||
if (seat.focused == .view) {
|
||||
const view = seat.focused.view;
|
||||
|
||||
// If views are unarranged, don't allow changing the views float status.
|
||||
// It would just lead to confusing because this state would not be
|
||||
// visible immediately, only after a layout is connected.
|
||||
if (view.output.current.layout == null)
|
||||
return;
|
||||
|
||||
// Don't float fullscreen views
|
||||
if (view.pending.fullscreen) return;
|
||||
|
||||
|
Reference in New Issue
Block a user