Implement initial tiling layout.
For now, it's hardcoded to be a right-primary/stack layout (similar to dwm but with the primary on the right) with the primary window getting 55% of the width of the screen.
This commit is contained in:
parent
2c18946703
commit
61fd784246
2 changed files with 80 additions and 24 deletions
|
|
@ -7,6 +7,7 @@ const Window = @This();
|
|||
context: *Context,
|
||||
|
||||
window_v1: *river.WindowV1,
|
||||
node_v1: *river.NodeV1,
|
||||
|
||||
width: u31 = 0,
|
||||
height: u31 = 0,
|
||||
|
|
@ -19,12 +20,12 @@ new_x: i32 = 0,
|
|||
new_y: i32 = 0,
|
||||
|
||||
link: wl.list.Link,
|
||||
is_head: bool = false,
|
||||
|
||||
pub fn init(window: *Window, context: *Context, river_window_v1: *river.WindowV1) void {
|
||||
window.* = .{
|
||||
.context = context,
|
||||
.window_v1 = river_window_v1,
|
||||
.node_v1 = river_window_v1.getNode() catch @panic("failed to get node"),
|
||||
.link = undefined, // Handled by the wl.list
|
||||
};
|
||||
|
||||
|
|
@ -36,6 +37,8 @@ fn windowListener(river_window_v1: *river.WindowV1, event: river.WindowV1.Event,
|
|||
switch (event) {
|
||||
.closed => {
|
||||
river_window_v1.destroy();
|
||||
window.node_v1.destroy();
|
||||
window.context.wm.window_count -= 1;
|
||||
{
|
||||
var it = window.context.wm.seats.iterator(.forward);
|
||||
while (it.next()) |seat| {
|
||||
|
|
@ -63,32 +66,30 @@ fn windowListener(river_window_v1: *river.WindowV1, event: river.WindowV1.Event,
|
|||
}
|
||||
|
||||
pub fn manage(window: *Window) void {
|
||||
if (window.context.wm.outputs.length() == 0) {
|
||||
window.new_width = 0;
|
||||
window.new_height = 0;
|
||||
window.new_x = 0;
|
||||
window.new_y = 0;
|
||||
}
|
||||
// Layout has been pre-computed by WindowManager.calculatePrimaryStackLayout()
|
||||
// Apply the computed dimensions
|
||||
if (window.new_width > 0 and window.new_height > 0) {
|
||||
window.window_v1.proposeDimensions(window.new_width, window.new_height);
|
||||
|
||||
// TODO: Support multiple primaries
|
||||
// TODO: Is this a valid way to check for the window's index?
|
||||
// Use server-side decoration (no client-drawn title bars)
|
||||
window.window_v1.useSsd();
|
||||
|
||||
// TODO: Remove this -- just fullscreen for now
|
||||
if (window.width != window.context.wm.outputs.first().?.width or
|
||||
window.height != window.context.wm.outputs.first().?.height)
|
||||
{
|
||||
window.width = @intCast(window.context.wm.outputs.first().?.width);
|
||||
window.height = @intCast(window.context.wm.outputs.first().?.height);
|
||||
log.debug("setting window width={d} and height={d} {}", .{ window.width, window.height, window.is_head });
|
||||
// Inform the window about its tiled/fullscreen state
|
||||
if (window.context.wm.window_count == 1) {
|
||||
// Single window is fullscreen
|
||||
window.window_v1.setTiled(.{ .top = false, .bottom = false, .left = false, .right = false });
|
||||
window.window_v1.informFullscreen();
|
||||
} else {
|
||||
// Tiled windows - set tiled edges
|
||||
window.window_v1.informNotFullscreen();
|
||||
window.window_v1.setTiled(.{ .top = true, .bottom = true, .left = true, .right = true });
|
||||
}
|
||||
}
|
||||
window.window_v1.proposeDimensions(window.width, window.height);
|
||||
// window.window_v1.setTiled(.{ .top = true, .bottom = true, .left = true, .right = true });
|
||||
window.window_v1.informFullscreen();
|
||||
// window.window_v1.informMaximized();
|
||||
}
|
||||
|
||||
pub fn render(window: *Window) void {
|
||||
_ = window; // TODO ???
|
||||
// Set the window position using the pre-computed layout
|
||||
window.node_v1.setPosition(window.new_x, window.new_y);
|
||||
}
|
||||
|
||||
const std = @import("std");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue