aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/seatop_resize_floating.c
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-03-02 02:29:28 -0500
committerLibravatar Drew DeVault <sir@cmpwn.com>2019-03-04 12:50:47 -0500
commita3b9f2dcfa649d9141f7bbb39e5eb951560eef72 (patch)
treefe8e29aed212a23fbdb66237170f5e4b4d79c139 /sway/input/seatop_resize_floating.c
parentMinor fix of code duplication. (diff)
downloadsway-a3b9f2dcfa649d9141f7bbb39e5eb951560eef72.tar.gz
sway-a3b9f2dcfa649d9141f7bbb39e5eb951560eef72.tar.zst
sway-a3b9f2dcfa649d9141f7bbb39e5eb951560eef72.zip
floating_maximum_size: change default behavior
This changes the way zero (which is the default) is interpreted for both the width and height of `floating_maximum_size`. It now refers to the width and height of the entire output layout, which matches i3's behavior. This also removes duplicated code to calculate the floating constraints in three files. Before this, `container_init_floating` used two-thirds of the workspace width/height as the max and the entire workspace width/height was used everywhere else. Now, all callers use a single function `floating_calculate_constraints`.
Diffstat (limited to 'sway/input/seatop_resize_floating.c')
-rw-r--r--sway/input/seatop_resize_floating.c37
1 files changed, 1 insertions, 36 deletions
diff --git a/sway/input/seatop_resize_floating.c b/sway/input/seatop_resize_floating.c
index bf6c7ab4..18c6db73 100644
--- a/sway/input/seatop_resize_floating.c
+++ b/sway/input/seatop_resize_floating.c
@@ -17,41 +17,6 @@ struct seatop_resize_floating_event {
17 double ref_con_lx, ref_con_ly; // container's x/y at start of op 17 double ref_con_lx, ref_con_ly; // container's x/y at start of op
18}; 18};
19 19
20static void calculate_floating_constraints(struct sway_container *con,
21 int *min_width, int *max_width, int *min_height, int *max_height) {
22 if (config->floating_minimum_width == -1) { // no minimum
23 *min_width = 0;
24 } else if (config->floating_minimum_width == 0) { // automatic
25 *min_width = 75;
26 } else {
27 *min_width = config->floating_minimum_width;
28 }
29
30 if (config->floating_minimum_height == -1) { // no minimum
31 *min_height = 0;
32 } else if (config->floating_minimum_height == 0) { // automatic
33 *min_height = 50;
34 } else {
35 *min_height = config->floating_minimum_height;
36 }
37
38 if (config->floating_maximum_width == -1) { // no maximum
39 *max_width = INT_MAX;
40 } else if (config->floating_maximum_width == 0) { // automatic
41 *max_width = con->workspace->width;
42 } else {
43 *max_width = config->floating_maximum_width;
44 }
45
46 if (config->floating_maximum_height == -1) { // no maximum
47 *max_height = INT_MAX;
48 } else if (config->floating_maximum_height == 0) { // automatic
49 *max_height = con->workspace->height;
50 } else {
51 *max_height = config->floating_maximum_height;
52 }
53}
54
55static void handle_motion(struct sway_seat *seat, uint32_t time_msec) { 20static void handle_motion(struct sway_seat *seat, uint32_t time_msec) {
56 struct seatop_resize_floating_event *e = seat->seatop_data; 21 struct seatop_resize_floating_event *e = seat->seatop_data;
57 struct sway_container *con = e->con; 22 struct sway_container *con = e->con;
@@ -85,7 +50,7 @@ static void handle_motion(struct sway_seat *seat, uint32_t time_msec) {
85 double width = e->ref_width + grow_width; 50 double width = e->ref_width + grow_width;
86 double height = e->ref_height + grow_height; 51 double height = e->ref_height + grow_height;
87 int min_width, max_width, min_height, max_height; 52 int min_width, max_width, min_height, max_height;
88 calculate_floating_constraints(con, &min_width, &max_width, 53 floating_calculate_constraints(&min_width, &max_width,
89 &min_height, &max_height); 54 &min_height, &max_height);
90 width = fmax(min_width, fmin(width, max_width)); 55 width = fmax(min_width, fmin(width, max_width));
91 height = fmax(min_height, fmin(height, max_height)); 56 height = fmax(min_height, fmin(height, max_height));