diff options
| author | Isaac Freund <ifreund@ifreund.xyz> | 2020-05-11 23:43:04 +0200 |
|---|---|---|
| committer | Isaac Freund <ifreund@ifreund.xyz> | 2020-05-11 23:43:04 +0200 |
| commit | 5bec8f4fcb361d3c7527d367bc66c0810e3c91d9 (patch) | |
| tree | d75a4ea10140d854efbd8d2c4d9f7654c9b15c78 /src/View.zig | |
| parent | b2f172e91b2d75b0b2af02621ab302afce3a94d6 (diff) | |
| download | river-5bec8f4fcb361d3c7527d367bc66c0810e3c91d9.tar.gz river-5bec8f4fcb361d3c7527d367bc66c0810e3c91d9.tar.xz | |
Only store mapped views in the view stack
Diffstat (limited to 'src/View.zig')
| -rw-r--r-- | src/View.zig | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/View.zig b/src/View.zig index 32924b4..8ab32cc 100644 --- a/src/View.zig +++ b/src/View.zig @@ -105,7 +105,7 @@ pub fn init( } else unreachable; } -pub fn deinit(self: *Self) void { +pub fn deinit(self: Self) void { if (self.stashed_buffer) |buffer| { c.wlr_buffer_unref(buffer); } @@ -227,6 +227,10 @@ pub fn surfaceAt(self: Self, ox: f64, oy: f64, sx: *f64, sy: *f64) ?*c.wlr_surfa pub fn map(self: *Self) void { const root = self.output.root; + // Add the view to the stack of its output + const node = @fieldParentPtr(ViewStack(Self).Node, "view", self); + self.output.views.push(node); + // Focus the newly mapped view. Note: if a seat is focusing a different output // it will continue to do so. var it = root.server.input_manager.seats.first; @@ -252,5 +256,16 @@ pub fn unmap(self: *Self) void { seat.handleViewUnmap(self); } + // Remove the view from its output's stack + const node = @fieldParentPtr(ViewStack(Self).Node, "view", self); + self.output.views.remove(node); + root.arrange(); } + +/// Destory the view and free the ViewStack node holding it. +pub fn destroy(self: *const Self) void { + self.deinit(); + const node = @fieldParentPtr(ViewStack(Self).Node, "view", self); + self.output.root.server.allocator.destroy(node); +} |
