Really fix floating window border resize problems

Fixes: https://github.com/swaywm/sway/pull/5250
This commit is contained in:
Adam Kürthy 2020-05-04 02:18:39 +02:00 committed by Simon Ser
parent 2262ae60f4
commit 7a294b2668

View file

@ -7,6 +7,7 @@
#include "sway/tree/arrange.h" #include "sway/tree/arrange.h"
#include "sway/tree/view.h" #include "sway/tree/view.h"
#include "sway/tree/workspace.h" #include "sway/tree/workspace.h"
#include "sway/tree/container.h"
struct seatop_resize_floating_event { struct seatop_resize_floating_event {
struct sway_container *con; struct sway_container *con;
@ -55,29 +56,37 @@ static void handle_pointer_motion(struct sway_seat *seat, uint32_t time_msec,
grow_height = e->ref_height * max_multiplier; grow_height = e->ref_height * max_multiplier;
} }
struct sway_container_state *state = &con->current;
double border_width = 0.0;
if (con->current.border == B_NORMAL || con->current.border == B_PIXEL) {
border_width = state->border_thickness * 2;
}
double border_height = 0.0;
if (con->current.border == B_NORMAL) {
border_height += container_titlebar_height();
border_height += state->border_thickness;
} else if (con->current.border == B_PIXEL) {
border_height += state->border_thickness * 2;
}
// Determine new width/height, and accommodate for floating min/max values // Determine new width/height, and accommodate for floating min/max values
double width = e->ref_width + grow_width; double width = e->ref_width + grow_width;
double height = e->ref_height + grow_height; double height = e->ref_height + grow_height;
int min_width, max_width, min_height, max_height; int min_width, max_width, min_height, max_height;
floating_calculate_constraints(&min_width, &max_width, floating_calculate_constraints(&min_width, &max_width,
&min_height, &max_height); &min_height, &max_height);
width = fmax(min_width, fmin(width, max_width)); width = fmax(min_width + border_width, fmin(width, max_width));
height = fmax(min_height, fmin(height, max_height)); height = fmax(min_height + border_height, fmin(height, max_height));
// Apply the view's min/max size // Apply the view's min/max size
if (con->view) { if (con->view) {
double view_min_width, view_max_width, view_min_height, view_max_height; double view_min_width, view_max_width, view_min_height, view_max_height;
view_get_constraints(con->view, &view_min_width, &view_max_width, view_get_constraints(con->view, &view_min_width, &view_max_width,
&view_min_height, &view_max_height); &view_min_height, &view_max_height);
width = fmax(view_min_width, fmin(width, view_max_width)); width = fmax(view_min_width + border_width, fmin(width, view_max_width));
height = fmax(view_min_height, fmin(height, view_max_height)); height = fmax(view_min_height + border_height, fmin(height, view_max_height));
}
struct sway_container_state *state = &con->current; }
width += state->border_thickness * 2;
height += config->titlebar_border_thickness * 2;
height += container_titlebar_height();
height += config->titlebar_v_padding;
// Recalculate these, in case we hit a min/max limit // Recalculate these, in case we hit a min/max limit
grow_width = width - e->ref_width; grow_width = width - e->ref_width;