Просмотр исходного кода

LibGUI: Make sure combobox list windows can't be moved

This is done by adding a new window type (Popup) and using it for the
combobox list window. Other incorrect uses of the Tooltip window type
have also been updated to use the new window type.
Gunnar Beutner 2 лет назад
Родитель
Сommit
288c46dbdc

+ 1 - 2
Userland/DevTools/HackStudio/Locator.cpp

@@ -146,8 +146,7 @@ Locator::Locator(Core::Object* parent)
     };
 
     m_popup_window = GUI::Window::construct(parent);
-    // FIXME: This is obviously not a tooltip window, but it's the closest thing to what we want atm.
-    m_popup_window->set_window_type(GUI::WindowType::Tooltip);
+    m_popup_window->set_window_type(GUI::WindowType::Popup);
     m_popup_window->set_rect(0, 0, 500, 200);
 
     m_suggestion_view = m_popup_window->set_main_widget<GUI::TableView>();

+ 1 - 1
Userland/Libraries/LibGUI/AutocompleteProvider.cpp

@@ -88,7 +88,7 @@ AutocompleteBox::AutocompleteBox(TextEditor& editor)
     : m_editor(editor)
 {
     m_popup_window = GUI::Window::construct(m_editor->window());
-    m_popup_window->set_window_type(GUI::WindowType::Tooltip);
+    m_popup_window->set_window_type(GUI::WindowType::Popup);
     m_popup_window->set_rect(0, 0, 175, 25);
 
     auto& main_widget = m_popup_window->set_main_widget<GUI::Widget>();

+ 1 - 0
Userland/Libraries/LibGUI/ComboBox.cpp

@@ -113,6 +113,7 @@ ComboBox::ComboBox()
     };
 
     m_list_window = add<Window>(window());
+    m_list_window->set_window_type(GUI::WindowType::Popup);
     m_list_window->set_frameless(true);
     m_list_window->set_window_mode(WindowMode::CaptureInput);
     m_list_window->on_active_input_change = [this](bool is_active_input) {

+ 1 - 0
Userland/Services/WindowServer/WindowManager.cpp

@@ -1421,6 +1421,7 @@ Gfx::IntRect WindowManager::arena_rect_for_type(Screen& screen, WindowType type)
     case WindowType::Tooltip:
     case WindowType::Applet:
     case WindowType::Notification:
+    case WindowType::Popup:
         return screen.rect();
     default:
         VERIFY_NOT_REACHED();

+ 5 - 0
Userland/Services/WindowServer/WindowManager.h

@@ -302,6 +302,7 @@ public:
         switch (window_type) {
         case WindowType::Normal:
         case WindowType::Tooltip:
+        case WindowType::Popup:
             return false;
         default:
             return true;
@@ -512,6 +513,8 @@ inline IterationDecision WindowManager::for_each_visible_window_from_back_to_fro
         return IterationDecision::Break;
     if (for_each_window.template operator()<WindowType::Tooltip>() == IterationDecision::Break)
         return IterationDecision::Break;
+    if (for_each_window.template operator()<WindowType::Popup>() == IterationDecision::Break)
+        return IterationDecision::Break;
     if (for_each_window.template operator()<WindowType::Menu>() == IterationDecision::Break)
         return IterationDecision::Break;
     return for_each_window.template operator()<WindowType::WindowSwitcher>();
@@ -541,6 +544,8 @@ inline IterationDecision WindowManager::for_each_visible_window_from_front_to_ba
         return IterationDecision::Break;
     if (for_each_window.template operator()<WindowType::Tooltip>() == IterationDecision::Break)
         return IterationDecision::Break;
+    if (for_each_window.template operator()<WindowType::Popup>() == IterationDecision::Break)
+        return IterationDecision::Break;
     if (for_each_window.template operator()<WindowType::Notification>() == IterationDecision::Break)
         return IterationDecision::Break;
     if (for_each_window.template operator()<WindowType::AppletArea>() == IterationDecision::Break)

+ 1 - 0
Userland/Services/WindowServer/WindowType.h

@@ -19,6 +19,7 @@ enum class WindowType {
     Notification,
     Desktop,
     AppletArea,
+    Popup,
     _Count
 };