Bugfix: fix duplicate return value for 'resize' command

(upstream git commit 83dc5d5cb6c71d365cd79b376fcb073e9120144d)

floating_fix_coordinates: properly deal with negative positions
(upstream git commit 74510c59c7db676f1228d054791e1e37456f6660)

randr: fix a crash when the current output cannot be determined
(upstream git commit e867fd810516431f06af0799c90c0f833bf61219)

randr: properly fix floating coordinates when disabling outputs
(upstream git commit d57d51da6d040e8572159332224615f232c4645a)
This commit is contained in:
dcoppa 2012-08-08 14:33:25 +00:00
parent 7aba82966d
commit f09c9b963e
5 changed files with 198 additions and 11 deletions

View File

@ -1,9 +1,9 @@
# $OpenBSD: Makefile,v 1.41 2012/07/16 14:38:22 dcoppa Exp $
# $OpenBSD: Makefile,v 1.42 2012/08/08 14:33:25 dcoppa Exp $
COMMENT = improved dynamic tiling window manager
DISTNAME = i3-4.2
REVISION = 8
REVISION = 9
CATEGORIES = x11
EXTRACT_SUFX = .tar.bz2

View File

@ -1,5 +1,2 @@
MD5 (i3-4.2.tar.bz2) = Ebfl7N2Dc0GXjHI0HLiQxg==
RMD160 (i3-4.2.tar.bz2) = QxIhIcfIZbetB8aKCQ3Es+swe3A=
SHA1 (i3-4.2.tar.bz2) = nWuLAd1dU+5RRW9vjfB3PzVd5fA=
SHA256 (i3-4.2.tar.bz2) = 4CyDKCDokipE50TlVSlPhYDC+OIYxcECnlLxveBIcys=
SIZE (i3-4.2.tar.bz2) = 758109

View File

@ -1,4 +1,4 @@
$OpenBSD: patch-src_commands_c,v 1.1 2012/05/28 13:37:50 dcoppa Exp $
$OpenBSD: patch-src_commands_c,v 1.2 2012/08/08 14:33:25 dcoppa Exp $
From b88ab981fd0a5725ed886a9f9788a5b1e721534c Mon Sep 17 00:00:00 2001
From: Ondrej Grover <ondrej.grover@gmail.com>
@ -12,6 +12,11 @@ found
also removed the obsolete tree_render() in favor of setting
cmd_output->needs_tree_render to true
From 83dc5d5cb6c71d365cd79b376fcb073e9120144d Mon Sep 17 00:00:00 2001
From: Michael Stapelberg <michael@stapelberg.de>
Date: Sun, 22 Jul 2012 19:25:38 +0000
Subject: Bugfix: Fix duplicate return value for 'resize' command
From 4eab046e8fa40535d1a2ad80533915983ef0ee7e Mon Sep 17 00:00:00 2001
From: Fernando Tarla Cardoso Lemos <fernandotcl@gmail.com>
Date: Sat, 21 Apr 2012 19:34:25 +0000
@ -22,7 +27,7 @@ we wouldn't allow the user to focus it. We already allow this when
focusing a workspace, for example.
--- src/commands.c.orig Wed Apr 25 23:21:25 2012
+++ src/commands.c Mon May 28 13:50:28 2012
+++ src/commands.c Wed Aug 8 16:02:40 2012
@@ -65,6 +65,28 @@ static Output *get_output_from_string(Output *current_
return output;
}
@ -52,7 +57,105 @@ focusing a workspace, for example.
// This code is commented out because we might recycle it for popping up error
// messages on parser errors.
#if 0
@@ -752,12 +774,19 @@ void cmd_workspace_number(I3_CMD, char *which) {
@@ -458,7 +480,7 @@ static void cmd_resize_floating(I3_CMD, char *way, cha
}
}
-static void cmd_resize_tiling_direction(I3_CMD, char *way, char *direction, int ppt) {
+static bool cmd_resize_tiling_direction(I3_CMD, char *way, char *direction, int ppt) {
LOG("tiling resize\n");
/* get the appropriate current container (skip stacked/tabbed cons) */
Con *current = focused;
@@ -491,7 +513,7 @@ static void cmd_resize_tiling_direction(I3_CMD, char *
LOG("You cannot resize in that direction. Your focus is in a %s split container currently.\n",
(orientation == HORIZ ? "horizontal" : "vertical"));
cmd_output->json_output = sstrdup("{\"sucess\": false}");
- return;
+ return false;
}
if (strcmp(direction, "up") == 0 || strcmp(direction, "left") == 0) {
@@ -502,7 +524,7 @@ static void cmd_resize_tiling_direction(I3_CMD, char *
if (other == TAILQ_END(workspaces)) {
LOG("No other container in this direction found, cannot resize.\n");
cmd_output->json_output = sstrdup("{\"sucess\": false}");
- return;
+ return false;
}
LOG("other->percent = %f\n", other->percent);
LOG("current->percent before = %f\n", current->percent);
@@ -525,9 +547,11 @@ static void cmd_resize_tiling_direction(I3_CMD, char *
} else {
LOG("Not resizing, already at minimum size\n");
}
+
+ return true;
}
-static void cmd_resize_tiling_width_height(I3_CMD, char *way, char *direction, int ppt) {
+static bool cmd_resize_tiling_width_height(I3_CMD, char *way, char *direction, int ppt) {
LOG("width/height resize\n");
/* get the appropriate current container (skip stacked/tabbed cons) */
Con *current = focused;
@@ -559,13 +583,13 @@ static void cmd_resize_tiling_width_height(I3_CMD, cha
LOG("You cannot resize in that direction. Your focus is in a %s split container currently.\n",
(orientation == HORIZ ? "horizontal" : "vertical"));
cmd_output->json_output = sstrdup("{\"sucess\": false}");
- return;
+ return false;
}
if (children == 1) {
LOG("This is the only container, cannot resize.\n");
cmd_output->json_output = sstrdup("{\"sucess\": false}");
- return;
+ return false;
}
/* Ensure all the other children have a percentage set. */
@@ -588,13 +612,13 @@ static void cmd_resize_tiling_width_height(I3_CMD, cha
if (!definitelyGreaterThan(child->percent - subtract_percent, 0.05, DBL_EPSILON)) {
LOG("Not resizing, already at minimum size (child %p would end up with a size of %.f\n", child, child->percent - subtract_percent);
cmd_output->json_output = sstrdup("{\"sucess\": false}");
- return;
+ return false;
}
}
if (!definitelyGreaterThan(new_current_percent, 0.05, DBL_EPSILON)) {
LOG("Not resizing, already at minimum size\n");
cmd_output->json_output = sstrdup("{\"sucess\": false}");
- return;
+ return false;
}
current->percent += ((double)ppt / 100.0);
@@ -606,6 +630,8 @@ static void cmd_resize_tiling_width_height(I3_CMD, cha
child->percent -= subtract_percent;
LOG("child->percent after (%p) = %f\n", child, child->percent);
}
+
+ return true;
}
/*
@@ -628,9 +654,13 @@ void cmd_resize(I3_CMD, char *way, char *direction, ch
cmd_resize_floating(current_match, cmd_output, way, direction, floating_con, px);
} else {
if (strcmp(direction, "width") == 0 ||
- strcmp(direction, "height") == 0)
- cmd_resize_tiling_width_height(current_match, cmd_output, way, direction, ppt);
- else cmd_resize_tiling_direction(current_match, cmd_output, way, direction, ppt);
+ strcmp(direction, "height") == 0) {
+ if (!cmd_resize_tiling_width_height(current_match, cmd_output, way, direction, ppt))
+ return;
+ } else {
+ if (!cmd_resize_tiling_direction(current_match, cmd_output, way, direction, ppt))
+ return;
+ }
}
cmd_output->needs_tree_render = true;
@@ -752,12 +782,19 @@ void cmd_workspace_number(I3_CMD, char *which) {
child->num == parsed_num);
if (!workspace) {
@ -74,7 +177,7 @@ focusing a workspace, for example.
workspace_show(workspace);
cmd_output->needs_tree_render = true;
@@ -789,20 +818,8 @@ void cmd_workspace_name(I3_CMD, char *name) {
@@ -789,20 +826,8 @@ void cmd_workspace_name(I3_CMD, char *name) {
}
DLOG("should switch to workspace %s\n", name);
@ -97,7 +200,7 @@ focusing a workspace, for example.
workspace_show_by_name(name);
cmd_output->needs_tree_render = true;
@@ -1196,16 +1213,7 @@ void cmd_focus_level(I3_CMD, char *level) {
@@ -1196,16 +1221,7 @@ void cmd_focus_level(I3_CMD, char *level) {
*/
void cmd_focus(I3_CMD) {
DLOG("current_match = %p\n", current_match);
@ -114,7 +217,7 @@ focusing a workspace, for example.
if (match_is_empty(current_match)) {
ELOG("You have to specify which window/container should be focused.\n");
ELOG("Example: [class=\"urxvt\" title=\"irssi\"] focus\n");
@@ -1217,12 +1225,24 @@ void cmd_focus(I3_CMD) {
@@ -1217,12 +1233,24 @@ void cmd_focus(I3_CMD) {
}
int count = 0;

View File

@ -0,0 +1,41 @@
$OpenBSD: patch-src_floating_c,v 1.12 2012/08/08 14:33:25 dcoppa Exp $
From 74510c59c7db676f1228d054791e1e37456f6660 Mon Sep 17 00:00:00 2001
From: Michael Stapelberg <michael@stapelberg.de>
Date: Sat, 04 Aug 2012 13:33:50 +0000
Subject: floating_fix_coordinates: properly deal with negative positions
--- src/floating.c.orig Wed Apr 25 23:21:25 2012
+++ src/floating.c Wed Aug 8 15:39:37 2012
@@ -607,19 +607,24 @@ void floating_reposition(Con *con, Rect newrect) {
*
*/
void floating_fix_coordinates(Con *con, Rect *old_rect, Rect *new_rect) {
- DLOG("Fixing coordinates of floating window %p\n", con);
+ DLOG("Fixing coordinates of floating window %p (rect (%d, %d), %d x %d)\n",
+ con, con->rect.x, con->rect.y, con->rect.width, con->rect.height);
+ DLOG("old_rect = (%d, %d), %d x %d\n",
+ old_rect->x, old_rect->y, old_rect->width, old_rect->height);
+ DLOG("new_rect = (%d, %d), %d x %d\n",
+ new_rect->x, new_rect->y, new_rect->width, new_rect->height);
/* First we get the x/y coordinates relative to the x/y coordinates
* of the output on which the window is on */
- uint32_t rel_x = (con->rect.x - old_rect->x);
- uint32_t rel_y = (con->rect.y - old_rect->y);
+ int32_t rel_x = (con->rect.x - old_rect->x);
+ int32_t rel_y = (con->rect.y - old_rect->y);
/* Then we calculate a fraction, for example 0.63 for a window
* which is at y = 1212 of a 1920 px high output */
- double fraction_x = ((double)rel_x / old_rect->width);
- double fraction_y = ((double)rel_y / old_rect->height);
+ double fraction_x = ((double)rel_x / (int32_t)old_rect->width);
+ double fraction_y = ((double)rel_y / (int32_t)old_rect->height);
DLOG("rel_x = %d, rel_y = %d, fraction_x = %f, fraction_y = %f, output->w = %d, output->h = %d\n",
rel_x, rel_y, fraction_x, fraction_y, old_rect->width, old_rect->height);
- con->rect.x = new_rect->x + (fraction_x * new_rect->width);
- con->rect.y = new_rect->y + (fraction_y * new_rect->height);
+ con->rect.x = (int32_t)new_rect->x + (fraction_x * (int32_t)new_rect->width);
+ con->rect.y = (int32_t)new_rect->y + (fraction_y * (int32_t)new_rect->height);
DLOG("Resulting coordinates: x = %d, y = %d\n", con->rect.x, con->rect.y);
}

View File

@ -0,0 +1,46 @@
$OpenBSD: patch-src_randr_c,v 1.9 2012/08/08 14:33:25 dcoppa Exp $
From e36674c5b8389ff93537fdc9ad32d23bd7add61d Mon Sep 17 00:00:00 2001
From: Michael Stapelberg <michael@stapelberg.de>
Date: Sat, 04 Aug 2012 13:19:11 +0000
Subject: Fix a crash when the current output cannot be determined
From d57d51da6d040e8572159332224615f232c4645a Mon Sep 17 00:00:00 2001
From: Michael Stapelberg <michael@stapelberg.de>
Date: Sat, 04 Aug 2012 13:21:16 +0000
Subject: Bugfix: Properly fix floating coordinates when disabling outputs
Since the content containers are not yet updated (they will be when
rendering), we need to use the output containers.s rects instead.
--- src/randr.c.orig Wed Apr 25 23:21:25 2012
+++ src/randr.c Wed Aug 8 15:36:52 2012
@@ -359,6 +359,19 @@ void init_ws_for_output(Output *output, Con *content)
workspace_show(previous);
}
+ /* Render the output on which the workspace was to get correct Rects.
+ * Then, we need to work with the "content" container, since we cannot
+ * be sure that the workspace itself was rendered at all (in case it's
+ * invisible, it won't be rendered). */
+ render_con(workspace_out, false);
+ Con *ws_out_content = output_get_content(workspace_out);
+
+ Con *floating_con;
+ TAILQ_FOREACH(floating_con, &(workspace->floating_head), floating_windows)
+ /* NB: We use output->con here because content is not yet rendered,
+ * so it has a rect of {0, 0, 0, 0}. */
+ floating_fix_coordinates(floating_con, &(ws_out_content->rect), &(output->con->rect));
+
con_detach(workspace);
con_attach(workspace, content, false);
@@ -682,7 +695,7 @@ void randr_query_outputs(void) {
DLOG("Fixing the coordinates of floating containers\n");
Con *floating_con;
TAILQ_FOREACH(floating_con, &(current->floating_head), floating_windows)
- floating_fix_coordinates(floating_con, &(old_content->rect), &(first_content->rect));
+ floating_fix_coordinates(floating_con, &(output->con->rect), &(first->con->rect));
DLOG("Done, next\n");
}
DLOG("re-attached all workspaces\n");