From 0cfc80c1b6a4f0d0d29d423184c7adb8d69a7922 Mon Sep 17 00:00:00 2001 From: koekeishiya Date: Sat, 14 Nov 2020 22:35:08 +0100 Subject: [PATCH] #661 report proper error message when trying to use absolute resizing on a managed window --- CHANGELOG.md | 1 + src/message.c | 2 ++ src/window_manager.c | 6 ++++-- src/window_manager.h | 1 + 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e548a28d..fbeb6d27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - Windows that do not report a title at all should be treated as having the empty string as its title [#707](https://github.com/koekeishiya/yabai/issues/707) - Allow *SPACE_SEL* to be used instead of *mission-control index* when specifying config options for a specific space [#705](https://github.com/koekeishiya/yabai/issues/705) - Native fullscreen transitions would freeze on macOS Mojave due to internal API differences between macOS version [#690](https://github.com/koekeishiya/yabai/issues/690) +- Report proper error message when trying to use absolute resizing on a managed window [#661](https://github.com/koekeishiya/yabai/issues/661) ## [3.3.4] - 2020-11-14 ### Changed diff --git a/src/message.c b/src/message.c index 203c1b55..86012506 100644 --- a/src/message.c +++ b/src/message.c @@ -1665,6 +1665,8 @@ static void handle_domain_window(FILE *rsp, struct token domain, char *message) daemon_fail(rsp, "cannot locate bsp node for the managed window.\n"); } else if (result == WINDOW_OP_ERROR_INVALID_DST_NODE) { daemon_fail(rsp, "cannot locate a bsp node fence.\n"); + } else if (result == WINDOW_OP_ERROR_INVALID_OPERATION) { + daemon_fail(rsp, "cannot use absolute resizing on a managed window.\n"); } } else { daemon_fail(rsp, "unknown value '%.*s' given to command '%.*s' for domain '%.*s'\n", value.length, value.text, command.length, command.text, domain.length, domain.text); diff --git a/src/window_manager.c b/src/window_manager.c index bc98a154..f52970f2 100644 --- a/src/window_manager.c +++ b/src/window_manager.c @@ -368,12 +368,14 @@ enum window_op_error window_manager_resize_window_relative(struct window_manager { struct view *view = window_manager_find_managed_window(wm, window); if (view) { - struct window_node *x_fence = NULL; - struct window_node *y_fence = NULL; + if (direction == HANDLE_ABS) return WINDOW_OP_ERROR_INVALID_OPERATION; struct window_node *node = view_find_window_node(view, window->id); if (!node) return WINDOW_OP_ERROR_INVALID_SRC_NODE; + struct window_node *x_fence = NULL; + struct window_node *y_fence = NULL; + if (direction & HANDLE_TOP) x_fence = window_node_fence(node, DIR_NORTH); if (direction & HANDLE_BOTTOM) x_fence = window_node_fence(node, DIR_SOUTH); if (direction & HANDLE_LEFT) y_fence = window_node_fence(node, DIR_WEST); diff --git a/src/window_manager.h b/src/window_manager.h index c098dfde..c05b212d 100644 --- a/src/window_manager.h +++ b/src/window_manager.h @@ -29,6 +29,7 @@ enum window_op_error WINDOW_OP_ERROR_INVALID_SRC_NODE, WINDOW_OP_ERROR_INVALID_DST_VIEW, WINDOW_OP_ERROR_INVALID_DST_NODE, + WINDOW_OP_ERROR_INVALID_OPERATION, WINDOW_OP_ERROR_SAME_WINDOW, WINDOW_OP_ERROR_CANT_MINIMIZE, WINDOW_OP_ERROR_ALREADY_MINIMIZED,