diff options
| author | Leon Henrik Plickat <leonhenrik.plickat@stud.uni-goettingen.de> | 2022-07-15 01:11:26 +0200 |
|---|---|---|
| committer | Leon Henrik Plickat <leonhenrik.plickat@stud.uni-goettingen.de> | 2022-08-11 15:22:07 +0200 |
| commit | 765a3f4aff78945889bbcf05fd01a38f5f80bdf1 (patch) | |
| tree | d747baa0a95001a3b7d02290eec875f0ca5cda8d | |
| parent | 1a9cba2aa91a1ab4085aa5670644ee9349d0595a (diff) | |
| download | river-765a3f4aff78945889bbcf05fd01a38f5f80bdf1.tar.gz river-765a3f4aff78945889bbcf05fd01a38f5f80bdf1.tar.xz | |
river: keep floating views within bounds when sending to output
| -rw-r--r-- | river/View.zig | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/river/View.zig b/river/View.zig index d344638..272d384 100644 --- a/river/View.zig +++ b/river/View.zig @@ -283,8 +283,33 @@ pub fn sendToOutput(self: *Self, destination_output: *Output) void { self.foreign_toplevel_handle.?.outputEnter(destination_output.wlr_output); } + self.output = destination_output; + const dimensions = destination_output.getEffectiveResolution(); + + if (self.pending.float) { + // Adapt dimensions of view to new output. Only necessary when floating, + // because for tiled views the output will be rearranged, taking care + // of this. + if (self.pending.fullscreen) self.pending.box = self.post_fullscreen_box; + const border_width = if (self.draw_borders) @intCast(i32, server.config.border_width) else 0; + self.pending.box.width = math.min( + self.pending.box.width, + @intCast(i32, dimensions.width) - (2 * border_width), + ); + self.pending.box.height = math.min( + self.pending.box.height, + @intCast(i32, dimensions.height) - (2 * border_width), + ); + + // Adjust position of view so that it is fully inside the target output. + self.move(0, 0); + } + if (self.pending.fullscreen) { - const dimensions = destination_output.getEffectiveResolution(); + // If the view is floating, we need to set the post_fullscreen_box, as + // that is still set for the previous output. + if (self.pending.float) self.post_fullscreen_box = self.pending.box; + self.pending.box = .{ .x = 0, .y = 0, @@ -292,7 +317,6 @@ pub fn sendToOutput(self: *Self, destination_output: *Output) void { .height = dimensions.height, }; } - self.output = destination_output; } fn sendEnter(self: *Self, output: *Output) void { |
