From 037ef68a4339cfb0c4a53f90bbc6f5cd8d7f0502 Mon Sep 17 00:00:00 2001 From: Alan Griffiths Date: Tue, 21 Nov 2023 18:15:01 +0000 Subject: [PATCH] [Xwayland] improve handling of CLion subsidiary windows (#3145) * When trees are "collected", indirect children should be included * Better handling of CLion's first level of menus * Fix #3107 too --- src/miral/basic_window_manager.cpp | 15 ++++++--------- src/miral/basic_window_manager.h | 4 ++-- .../frontend_xwayland/xwayland_surface.cpp | 16 +++++++++++----- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/miral/basic_window_manager.cpp b/src/miral/basic_window_manager.cpp index 66cfe788a01..71a77a53824 100644 --- a/src/miral/basic_window_manager.cpp +++ b/src/miral/basic_window_manager.cpp @@ -942,29 +942,26 @@ auto miral::BasicWindowManager::active_application_zone() -> Zone return active_display_area()->application_zone; } -auto miral::BasicWindowManager::for_each_window_in_info( - WindowInfo const& info, - std::function func -) -> void +void miral::BasicWindowManager::for_each_descendent_in(WindowInfo const& info, std::function func) { - std::function const iterate_children = + std::function const iterate_descendents = [&](WindowInfo const& info) { for (auto const& child : info.children()) { - func(child); + for_each_descendent_in(info_for(child), func); } }; func(info.window()); - iterate_children(info); + iterate_descendents(info); } auto miral::BasicWindowManager::collect_windows(const miral::WindowInfo &info) -> SurfaceSet { SurfaceSet windows; - for_each_window_in_info(info, [&](Window const& window) + for_each_descendent_in(info, [&](Window const& window) { windows.insert(window); }); @@ -980,7 +977,7 @@ void miral::BasicWindowManager::raise_tree(Window const& root) raise_tree(parent); std::vector raised_windows; - for_each_window_in_info(info, [&](Window const& window) + for_each_descendent_in(info, [&](Window const& window) { raised_windows.push_back(window); }); diff --git a/src/miral/basic_window_manager.h b/src/miral/basic_window_manager.h index 8ffc84814f2..68f1d29c31e 100644 --- a/src/miral/basic_window_manager.h +++ b/src/miral/basic_window_manager.h @@ -326,8 +326,8 @@ class BasicWindowManager : public virtual mir::shell::WindowManager, /// Updates the application zones of all display areas and moves attached windows as needed void update_application_zones_and_attached_windows(); - /// Iterates each child window of the provided WindowInfo - void for_each_window_in_info(WindowInfo const& info, std::function func); + /// Iterates each descendent window (including current) of the provided WindowInfo + void for_each_descendent_in(WindowInfo const& info, std::function func); /// Gathers windows provided WindowInfo auto collect_windows(WindowInfo const& info) -> SurfaceSet; }; diff --git a/src/server/frontend_xwayland/xwayland_surface.cpp b/src/server/frontend_xwayland/xwayland_surface.cpp index e211e59348b..379c81cc519 100644 --- a/src/server/frontend_xwayland/xwayland_surface.cpp +++ b/src/server/frontend_xwayland/xwayland_surface.cpp @@ -210,11 +210,17 @@ auto wm_window_type_to_mir_window_type( } else if (wm_type == connection->_NET_WM_WINDOW_TYPE_POPUP_MENU || wm_type == connection->_NET_WM_WINDOW_TYPE_DROPDOWN_MENU || - wm_type == connection->_NET_WM_WINDOW_TYPE_COMBO || - wm_type == connection->_NET_WM_WINDOW_TYPE_TOOLTIP || + wm_type == connection->_NET_WM_WINDOW_TYPE_COMBO) + { + return mir_window_type_menu; + } + else if (wm_type == connection->_NET_WM_WINDOW_TYPE_DIALOG) + { + return override_redirect ? mir_window_type_menu : mir_window_type_dialog; + } + else if (wm_type == connection->_NET_WM_WINDOW_TYPE_TOOLTIP || wm_type == connection->_NET_WM_WINDOW_TYPE_NOTIFICATION || - wm_type == connection->_NET_WM_WINDOW_TYPE_DND || - wm_type == connection->_NET_WM_WINDOW_TYPE_DIALOG) + wm_type == connection->_NET_WM_WINDOW_TYPE_DND) { return mir_window_type_tip; } @@ -231,7 +237,7 @@ auto wm_window_type_to_mir_window_type( // be taken as _NET_WM_WINDOW_TYPE_NORMAL." if (is_transient_for && !override_redirect) { - return mir_window_type_tip; + return mir_window_type_menu; } else {