code: simplify view rendering
This commit is contained in:
		@ -56,7 +56,7 @@ wlr_surface: ?*c.wlr_surface,
 | 
				
			|||||||
/// If the view is floating or not
 | 
					/// If the view is floating or not
 | 
				
			||||||
floating: bool,
 | 
					floating: bool,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// True if the view is currentlt focused by at lease one seat
 | 
					/// True if the view is currently focused by at least one seat
 | 
				
			||||||
focused: bool,
 | 
					focused: bool,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// The current output-relative coordinates and dimensions of the view
 | 
					/// The current output-relative coordinates and dimensions of the view
 | 
				
			||||||
 | 
				
			|||||||
@ -39,7 +39,6 @@ const SurfaceRenderData = struct {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
pub fn renderOutput(output: *Output) void {
 | 
					pub fn renderOutput(output: *Output) void {
 | 
				
			||||||
    const wlr_renderer = output.getRenderer();
 | 
					    const wlr_renderer = output.getRenderer();
 | 
				
			||||||
    const input_manager = output.root.server.input_manager;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var now: c.timespec = undefined;
 | 
					    var now: c.timespec = undefined;
 | 
				
			||||||
    _ = c.clock_gettime(c.CLOCK_MONOTONIC, &now);
 | 
					    _ = c.clock_gettime(c.CLOCK_MONOTONIC, &now);
 | 
				
			||||||
@ -68,17 +67,10 @@ pub fn renderOutput(output: *Output) void {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        // This check prevents a race condition when a frame is requested
 | 
					        // This check prevents a race condition when a frame is requested
 | 
				
			||||||
        // between mapping of a view and the first configure being handled.
 | 
					        // between mapping of a view and the first configure being handled.
 | 
				
			||||||
        if (view.current_box.width == 0 or view.current_box.height == 0) {
 | 
					        if (view.current_box.width == 0 or view.current_box.height == 0) continue;
 | 
				
			||||||
            continue;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Focused views are rendered on top of normal views, skip them for now
 | 
					        // Focused views are rendered on top of normal views, skip them for now
 | 
				
			||||||
        var seat_it = input_manager.seats.first;
 | 
					        if (view.focused) continue;
 | 
				
			||||||
        if (while (seat_it) |seat_node| : (seat_it = seat_node.next) {
 | 
					 | 
				
			||||||
            if (seat_node.data.focused_view == view) break true;
 | 
					 | 
				
			||||||
        } else false) {
 | 
					 | 
				
			||||||
            continue;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        renderView(output.*, view, &now);
 | 
					        renderView(output.*, view, &now);
 | 
				
			||||||
        renderBorders(output.*, view, &now);
 | 
					        renderBorders(output.*, view, &now);
 | 
				
			||||||
@ -88,19 +80,14 @@ pub fn renderOutput(output: *Output) void {
 | 
				
			|||||||
    it = ViewStack(View).reverseIterator(output.views.last, output.current_focused_tags);
 | 
					    it = ViewStack(View).reverseIterator(output.views.last, output.current_focused_tags);
 | 
				
			||||||
    while (it.next()) |node| {
 | 
					    while (it.next()) |node| {
 | 
				
			||||||
        const view = &node.view;
 | 
					        const view = &node.view;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // This check prevents a race condition when a frame is requested
 | 
					        // This check prevents a race condition when a frame is requested
 | 
				
			||||||
        // between mapping of a view and the first configure being handled.
 | 
					        // between mapping of a view and the first configure being handled.
 | 
				
			||||||
        if (view.current_box.width == 0 or view.current_box.height == 0) {
 | 
					        if (view.current_box.width == 0 or view.current_box.height == 0) continue;
 | 
				
			||||||
            continue;
 | 
					
 | 
				
			||||||
        }
 | 
					        // Skip unfocused views since we already rendered them
 | 
				
			||||||
 | 
					        if (!view.focused) continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Skip unfocused views
 | 
					 | 
				
			||||||
        var seat_it = input_manager.seats.first;
 | 
					 | 
				
			||||||
        if (while (seat_it) |seat_node| : (seat_it = seat_node.next) {
 | 
					 | 
				
			||||||
            if (seat_node.data.focused_view == view) break false;
 | 
					 | 
				
			||||||
        } else true) {
 | 
					 | 
				
			||||||
            continue;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        renderView(output.*, view, &now);
 | 
					        renderView(output.*, view, &now);
 | 
				
			||||||
        renderBorders(output.*, view, &now);
 | 
					        renderBorders(output.*, view, &now);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user