From 60f49ae5a272b737a944065e4199c8b2c8eec8b1 Mon Sep 17 00:00:00 2001 From: Zhiyi Zhang Date: Wed, 14 Apr 2021 16:03:31 +0800 Subject: window: Only unmaximize when the window is already maximized. When handling a ClientMessage event that removes _NET_WM_STATE_MAXIMIZED_HORZ or _NET_WM_STATE_MAXIMIZED_VERT from _NET_WM_STATE, marco always restore the window rectangle to the saved rectangle. So if an application window is already unmaximized and the application sends such a ClientMessage event, marco will reset the window rectangle regardless. EWMH doesn't specify what must be done when handling such events. It seems best to avoid restoring window rectangles like other window managers in this case. Fix a related bug: https://bugs.winehq.org/show_bug.cgi?id=50381 This revert a change introduced by 6219f8e8bcaeefb9185a3c3f5f20de4e2fa8f18f. Signed-off-by: Zhiyi Zhang --- src/core/window.c | 124 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 64 insertions(+), 60 deletions(-) diff --git a/src/core/window.c b/src/core/window.c index 9338d736..11b764bc 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -2771,77 +2771,81 @@ meta_window_unmaximize (MetaWindow *window, window->tile_mode = META_TILE_NONE; window->tiled = FALSE; - /* Only do something if the window isn't already maximized in the + /* Only do something if the window is already maximized in the * given direction(s). */ - MetaRectangle target_rect; + if ((unmaximize_horizontally && window->maximized_horizontally) || + (unmaximize_vertically && window->maximized_vertically)) + { + MetaRectangle target_rect; - meta_topic (META_DEBUG_WINDOW_OPS, - "Unmaximizing %s%s\n", - window->desc, - unmaximize_horizontally && unmaximize_vertically ? "" : - unmaximize_horizontally ? " horizontally" : - unmaximize_vertically ? " vertically" : "BUGGGGG"); + meta_topic (META_DEBUG_WINDOW_OPS, + "Unmaximizing %s%s\n", + window->desc, + unmaximize_horizontally && unmaximize_vertically ? "" : + unmaximize_horizontally ? " horizontally" : + unmaximize_vertically ? " vertically" : "BUGGGGG"); - window->maximized_horizontally = - window->maximized_horizontally && !unmaximize_horizontally; - window->maximized_vertically = - window->maximized_vertically && !unmaximize_vertically; + window->maximized_horizontally = + window->maximized_horizontally && !unmaximize_horizontally; + window->maximized_vertically = + window->maximized_vertically && !unmaximize_vertically; - /* Unmaximize to the saved_rect position in the direction(s) - * being unmaximized. - */ - meta_window_get_client_root_coords (window, &target_rect); - if (unmaximize_horizontally) - { - target_rect.x = window->saved_rect.x; - target_rect.width = window->saved_rect.width; - } - if (unmaximize_vertically) - { - target_rect.y = window->saved_rect.y; - target_rect.height = window->saved_rect.height; - } + /* Unmaximize to the saved_rect position in the direction(s) + * being unmaximized. + */ + meta_window_get_client_root_coords (window, &target_rect); + if (unmaximize_horizontally) + { + target_rect.x = window->saved_rect.x; + target_rect.width = window->saved_rect.width; + } + if (unmaximize_vertically) + { + target_rect.y = window->saved_rect.y; + target_rect.height = window->saved_rect.height; + } - /* Window's size hints may have changed while maximized, making - * saved_rect invalid. #329152 - */ - ensure_size_hints_satisfied (&target_rect, &window->size_hints); + /* Window's size hints may have changed while maximized, making + * saved_rect invalid. #329152 + */ + ensure_size_hints_satisfied (&target_rect, &window->size_hints); - meta_window_move_resize (window, - FALSE, - target_rect.x, - target_rect.y, - target_rect.width, - target_rect.height); + meta_window_move_resize (window, + FALSE, + target_rect.x, + target_rect.y, + target_rect.width, + target_rect.height); - /* Make sure user_rect is current. - */ - force_save_user_window_placement (window); - - /* When we unmaximize, if we're doing a mouse move also we could - * get the window suddenly jumping to the upper left corner of - * the workspace, since that's where it was when the grab op - * started. So we need to update the grab state. We have to do - * it after the actual operation, as the window may have been moved - * by constraints. - */ - if (meta_grab_op_is_moving (window->display->grab_op) && - window->display->grab_window == window) - { - window->display->grab_anchor_window_pos = window->user_rect; - } + /* Make sure user_rect is current. + */ + force_save_user_window_placement (window); - if (window->display->grab_wireframe_active) - { - window->display->grab_wireframe_rect = target_rect; - } + /* When we unmaximize, if we're doing a mouse move also we could + * get the window suddenly jumping to the upper left corner of + * the workspace, since that's where it was when the grab op + * started. So we need to update the grab state. We have to do + * it after the actual operation, as the window may have been moved + * by constraints. + */ + if (meta_grab_op_is_moving (window->display->grab_op) && + window->display->grab_window == window) + { + window->display->grab_anchor_window_pos = window->user_rect; + } - recalc_window_features (window); - set_allowed_actions_hint (window); - set_net_wm_state (window); + if (window->display->grab_wireframe_active) + { + window->display->grab_wireframe_rect = target_rect; + } - meta_compositor_unmaximize_window (window->display->compositor, window); + recalc_window_features (window); + set_allowed_actions_hint (window); + set_net_wm_state (window); + + meta_compositor_unmaximize_window (window->display->compositor, window); + } } void -- cgit v1.2.1