render: floating as normal, focused views on top

This means that floating views can be (partially) obscured by normal
views if they are low in the stack, and that the "full" layout will
work a little nicer as the focused view is always the top rendered.
This commit is contained in:
Isaac Freund 2020-06-11 00:09:42 +02:00
parent 1b7c1c7b2c
commit ff219c7d8d
No known key found for this signature in database
GPG key ID: 86DED400DDFD7A11

View file

@ -39,6 +39,7 @@ 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);
@ -64,20 +65,26 @@ pub fn renderOutput(output: *Output) void {
var it = ViewStack(View).reverseIterator(output.views.last, output.current_focused_tags); var 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;
} }
// Floating views are rendered on top of normal views
if (view.floating) { // Focused views are rendered on top of normal views, skip them for now
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 true;
} else false) {
continue; continue;
} }
renderView(output.*, view, &now); renderView(output.*, view, &now);
renderBorders(output.*, view, &now); renderBorders(output.*, view, &now);
} }
// Render floating views // Render focused views
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;
@ -86,7 +93,12 @@ pub fn renderOutput(output: *Output) void {
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;
} }
if (!view.floating) {
// 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; continue;
} }
renderView(output.*, view, &now); renderView(output.*, view, &now);