2zw

2zw - X11 Windowmanager

Files | Log | Commits | Refs | README


TODO

Size: 1697 bytes

# TODO
- add EWMH 
- add toggle float - > default is not float, pressing mod4 + space should toggle float window
- handle dialoge windows properly
- RandR can be improved.

fn handleFloatingWindows() void {
    var node = list.first;
    while (node) |n| : (node = n.next) {
        if (n.data.is_floating) {
            var attrs: C.XWindowAttributes = undefined;
            _ = C.XGetWindowAttributes(display, n.data.w, &attrs);
            
            // Check if window needs to be positioned (new or off-screen)
            const needs_positioning = 
                attrs.x <= 0 || 
                attrs.y <= 0 || 
                attrs.x >= @intCast(screen_w) || 
                attrs.y >= @intCast(screen_h) ||
                // Also reposition windows that are too large for the screen
                attrs.width > screen_w || 
                attrs.height > screen_h;
                
            if (needs_positioning) {
                // Calculate dimensions - limit to 2/3 of screen size
                const width = @min(attrs.width, @as(c_int, @intCast(@divTrunc(screen_w * 2, 3))));
                const height = @min(attrs.height, @as(c_int, @intCast(@divTrunc(screen_h * 2, 3))));
                
                // Center the window
                const x = @divTrunc(@as(c_int, @intCast(screen_w)) - width, 2);
                const y = @divTrunc(@as(c_int, @intCast(screen_h)) - height, 2);
                
                _ = C.XMoveResizeWindow(display, n.data.w, x, y, @intCast(width), @intCast(height));
            }
            
            // Ensure the window is on top of tiled windows
            _ = C.XRaiseWindow(display, n.data.w);
        }
    }
}