浏览代码

WindowServer: Disable the global menubar while a modal window is active.

This makes it much harder to screw with an application while it's showing
a modal window, and matches what some other systems are doing. :^)
Andreas Kling 6 年之前
父节点
当前提交
6eb4ace6e8

+ 3 - 0
Servers/WindowServer/WSMenuManager.cpp

@@ -104,6 +104,9 @@ void WSMenuManager::refresh()
 
 void WSMenuManager::event(CEvent& event)
 {
+    if (WSWindowManager::the().active_window_is_modal())
+        return CObject::event(event);
+
     if (event.type() == WSEvent::MouseMove || event.type() == WSEvent::MouseUp || event.type() == WSEvent::MouseDown || event.type() == WSEvent::MouseWheel) {
         auto& mouse_event = static_cast<WSMouseEvent&>(event);
         WSWindowManager::the().for_each_active_menubar_menu([&](WSMenu& menu) {

+ 3 - 1
Servers/WindowServer/WSWindowManager.cpp

@@ -681,10 +681,12 @@ void WSWindowManager::process_mouse_event(WSMouseEvent& event, WSWindow*& hovere
         deliver_mouse_event(*window, translated_event);
     }
 
-    if (menubar_rect().contains(event.position())) {
+    // FIXME: Now that the menubar has a dedicated window, is this special-casing really necessary?
+    if (!active_window_is_modal() && menubar_rect().contains(event.position())) {
         m_menu_manager.event(event);
         return;
     }
+
     if (m_current_menu && m_current_menu->menu_window()) {
         auto& window = *m_current_menu->menu_window();
         bool event_is_inside_current_menu = window.rect().contains(event.position());

+ 1 - 2
Servers/WindowServer/WSWindowManager.h

@@ -67,6 +67,7 @@ public:
 
     WSWindow* active_window() { return m_active_window.ptr(); }
     const WSClientConnection* active_client() const;
+    bool active_window_is_modal() const { return m_active_window && m_active_window->is_modal(); }
 
     WSWindow* highlight_window() { return m_highlight_window.ptr(); }
     void set_highlight_window(WSWindow*);
@@ -150,8 +151,6 @@ private:
     void deliver_mouse_event(WSWindow& window, WSMouseEvent& event);
     bool process_ongoing_window_resize(const WSMouseEvent&, WSWindow*& hovered_window);
     bool process_ongoing_window_drag(WSMouseEvent&, WSWindow*& hovered_window);
-    void handle_menu_mouse_event(WSMenu&, const WSMouseEvent&);
-    void handle_close_button_mouse_event(WSWindow&, const WSMouseEvent&);
     void start_window_drag(WSWindow&, const WSMouseEvent&);
     void handle_client_request(const WSAPIClientRequest&);
     void set_hovered_window(WSWindow*);