1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:28:12 +00:00

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. :^)
This commit is contained in:
Andreas Kling 2019-07-21 10:23:21 +02:00
parent 98b569a702
commit 6eb4ace6e8
3 changed files with 7 additions and 3 deletions

View file

@ -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) {

View file

@ -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());

View file

@ -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*);