From 2283ee78b57b4cd1f78d4c409b6d113cecbefac9 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Wed, 15 Apr 2020 17:59:46 +0200 Subject: Track the focused output of seats --- src/seat.zig | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/seat.zig') diff --git a/src/seat.zig b/src/seat.zig index 34cdbfa..d694970 100644 --- a/src/seat.zig +++ b/src/seat.zig @@ -2,9 +2,10 @@ const std = @import("std"); const c = @import("c.zig"); const Cursor = @import("cursor.zig").Cursor; -const Log = @import("log.zig").Log; const InputManager = @import("input_manager.zig").InputManager; const Keyboard = @import("keyboard.zig").Keyboard; +const Log = @import("log.zig").Log; +const Output = @import("output.zig").Output; const View = @import("view.zig").View; const ViewStack = @import("view_stack.zig").ViewStack; @@ -20,6 +21,9 @@ pub const Seat = struct { /// Mulitple keyboards are handled separately keyboards: std.TailQueue(Keyboard), + /// Currently focused output, may be the noop output if no + focused_output: *Output, + /// Currently focused view if any focused_view: ?*View, @@ -39,6 +43,8 @@ pub const Seat = struct { self.keyboards = std.TailQueue(Keyboard).init(); + self.focused_output = &self.input_manager.server.root.noop_output; + self.focused_view = null; self.focus_stack.init(); @@ -54,11 +60,15 @@ pub const Seat = struct { var view = _view; // If view is null or not currently visible - if (if (view) |v| v.current_tags & v.output.current_focused_tags == 0 else true) { + if (if (view) |v| + v.output != self.focused_output or + v.current_tags & self.focused_output.current_focused_tags == 0 + else + true) { // Set view to the first currently visible view in the focus stack if any view = if (ViewStack(*View).iterator( self.focus_stack.first, - self.input_manager.server.root.focusedOutput().current_focused_tags, + self.focused_output.current_focused_tags, ).next()) |node| node.view else null; } -- cgit v1.2.3