diff options
author | thankyouverycool <66646555+thankyouverycool@users.noreply.github.com> | 2022-08-25 14:03:49 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-08-26 12:48:05 +0200 |
commit | d815f659cc382656e11e9d28aeb4a2bbcf1e9f85 (patch) | |
tree | 830eebe6aee38c579eb2d4a04e5143154ff94b7b | |
parent | 18b111b802751226559ac6e530fbede8104e47c1 (diff) | |
download | serenity-d815f659cc382656e11e9d28aeb4a2bbcf1e9f85.zip |
LibGUI+Taskbar+WindowServer: Prevent minimization when blocked
This was intentionally enabled with WindowModes as a new Taskbar
convenience, but on second thought, it doesn't add up visually.
Taskbar buttons show blockers' context menus when available,
which is a bit confusing when the window isn't visible. The
modeless window's disabled context menu options and inactive title
bar also contradict the button. So, this patch reenables the
restriction for now. Blocking modals you don't want to answer to
immediately can still be tucked away on another workspace.
7 files changed, 18 insertions, 8 deletions
diff --git a/Userland/Libraries/LibGUI/ConnectionToWindowManagerServer.cpp b/Userland/Libraries/LibGUI/ConnectionToWindowManagerServer.cpp index 1d1c6a7291..d6b0cd9148 100644 --- a/Userland/Libraries/LibGUI/ConnectionToWindowManagerServer.cpp +++ b/Userland/Libraries/LibGUI/ConnectionToWindowManagerServer.cpp @@ -19,11 +19,11 @@ ConnectionToWindowManagerServer& ConnectionToWindowManagerServer::the() } void ConnectionToWindowManagerServer::window_state_changed(i32 wm_id, i32 client_id, i32 window_id, - u32 workspace_row, u32 workspace_column, bool is_active, bool is_minimized, bool is_frameless, + u32 workspace_row, u32 workspace_column, bool is_active, bool is_blocked, bool is_minimized, bool is_frameless, i32 window_type, String const& title, Gfx::IntRect const& rect, Optional<i32> const& progress) { if (auto* window = Window::from_window_id(wm_id)) - Core::EventLoop::current().post_event(*window, make<WMWindowStateChangedEvent>(client_id, window_id, title, rect, workspace_row, workspace_column, is_active, static_cast<WindowType>(window_type), is_minimized, is_frameless, progress)); + Core::EventLoop::current().post_event(*window, make<WMWindowStateChangedEvent>(client_id, window_id, title, rect, workspace_row, workspace_column, is_active, is_blocked, static_cast<WindowType>(window_type), is_minimized, is_frameless, progress)); } void ConnectionToWindowManagerServer::applet_area_size_changed(i32 wm_id, Gfx::IntSize const& size) diff --git a/Userland/Libraries/LibGUI/ConnectionToWindowManagerServer.h b/Userland/Libraries/LibGUI/ConnectionToWindowManagerServer.h index 375efcad69..5721ecef00 100644 --- a/Userland/Libraries/LibGUI/ConnectionToWindowManagerServer.h +++ b/Userland/Libraries/LibGUI/ConnectionToWindowManagerServer.h @@ -28,7 +28,7 @@ private: } virtual void window_removed(i32, i32, i32) override; - virtual void window_state_changed(i32, i32, i32, u32, u32, bool, bool, bool, i32, String const&, Gfx::IntRect const&, Optional<i32> const&) override; + virtual void window_state_changed(i32, i32, i32, u32, u32, bool, bool, bool, bool, i32, String const&, Gfx::IntRect const&, Optional<i32> const&) override; virtual void window_icon_bitmap_changed(i32, i32, i32, Gfx::ShareableBitmap const&) override; virtual void window_rect_changed(i32, i32, i32, Gfx::IntRect const&) override; virtual void applet_area_size_changed(i32, Gfx::IntSize const&) override; diff --git a/Userland/Libraries/LibGUI/Event.h b/Userland/Libraries/LibGUI/Event.h index 6dea72cd17..a3366122ef 100644 --- a/Userland/Libraries/LibGUI/Event.h +++ b/Userland/Libraries/LibGUI/Event.h @@ -164,7 +164,7 @@ public: class WMWindowStateChangedEvent : public WMEvent { public: - WMWindowStateChangedEvent(int client_id, int window_id, StringView title, Gfx::IntRect const& rect, unsigned workspace_row, unsigned workspace_column, bool is_active, WindowType window_type, bool is_minimized, bool is_frameless, Optional<int> progress) + WMWindowStateChangedEvent(int client_id, int window_id, StringView title, Gfx::IntRect const& rect, unsigned workspace_row, unsigned workspace_column, bool is_active, bool is_blocked, WindowType window_type, bool is_minimized, bool is_frameless, Optional<int> progress) : WMEvent(Event::Type::WM_WindowStateChanged, client_id, window_id) , m_title(title) , m_rect(rect) @@ -172,6 +172,7 @@ public: , m_workspace_row(workspace_row) , m_workspace_column(workspace_column) , m_active(is_active) + , m_blocked(is_blocked) , m_minimized(is_minimized) , m_frameless(is_frameless) , m_progress(progress) @@ -181,6 +182,7 @@ public: String const& title() const { return m_title; } Gfx::IntRect const& rect() const { return m_rect; } bool is_active() const { return m_active; } + bool is_blocked() const { return m_blocked; } WindowType window_type() const { return m_window_type; } bool is_minimized() const { return m_minimized; } bool is_frameless() const { return m_frameless; } @@ -195,6 +197,7 @@ private: unsigned m_workspace_row; unsigned m_workspace_column; bool m_active; + bool m_blocked; bool m_minimized; bool m_frameless; Optional<int> m_progress; diff --git a/Userland/Services/Taskbar/TaskbarWindow.cpp b/Userland/Services/Taskbar/TaskbarWindow.cpp index 1e3c8d0867..f79c8e2892 100644 --- a/Userland/Services/Taskbar/TaskbarWindow.cpp +++ b/Userland/Services/Taskbar/TaskbarWindow.cpp @@ -156,7 +156,7 @@ void TaskbarWindow::add_window_button(::Window& window, WindowIdentifier const& button->on_click = [window = &window, identifier](auto) { if (window->is_minimized() || !window->is_active()) GUI::ConnectionToWindowManagerServer::the().async_set_active_window(identifier.client_id(), identifier.window_id()); - else + else if (!window->is_blocked()) GUI::ConnectionToWindowManagerServer::the().async_set_window_minimized(identifier.client_id(), identifier.window_id(), true); }; } @@ -263,12 +263,13 @@ void TaskbarWindow::wm_event(GUI::WMEvent& event) case GUI::Event::WM_WindowStateChanged: { auto& changed_event = static_cast<GUI::WMWindowStateChangedEvent&>(event); if constexpr (EVENT_DEBUG) { - dbgln("WM_WindowStateChanged: client_id={}, window_id={}, title={}, rect={}, is_active={}, is_minimized={}", + dbgln("WM_WindowStateChanged: client_id={}, window_id={}, title={}, rect={}, is_active={}, is_blocked={}, is_minimized={}", changed_event.client_id(), changed_event.window_id(), changed_event.title(), changed_event.rect(), changed_event.is_active(), + changed_event.is_blocked(), changed_event.is_minimized()); } if (changed_event.window_type() != GUI::WindowType::Normal || changed_event.is_frameless()) { @@ -280,6 +281,7 @@ void TaskbarWindow::wm_event(GUI::WMEvent& event) window.set_title(changed_event.title()); window.set_rect(changed_event.rect()); window.set_active(changed_event.is_active()); + window.set_blocked(changed_event.is_blocked()); window.set_minimized(changed_event.is_minimized()); window.set_progress(changed_event.progress()); window.set_workspace(changed_event.workspace_row(), changed_event.workspace_column()); diff --git a/Userland/Services/Taskbar/WindowList.h b/Userland/Services/Taskbar/WindowList.h index dc725abbd2..617c69f4d5 100644 --- a/Userland/Services/Taskbar/WindowList.h +++ b/Userland/Services/Taskbar/WindowList.h @@ -39,6 +39,9 @@ public: void set_active(bool active) { m_active = active; } bool is_active() const { return m_active; } + void set_blocked(bool blocked) { m_blocked = blocked; } + bool is_blocked() const { return m_blocked; } + void set_minimized(bool minimized) { m_minimized = minimized; } bool is_minimized() const { return m_minimized; } @@ -72,6 +75,7 @@ private: unsigned m_workspace_row { 0 }; unsigned m_workspace_column { 0 }; bool m_active { false }; + bool m_blocked { false }; bool m_minimized { false }; Optional<int> m_progress; }; diff --git a/Userland/Services/WindowServer/WindowManager.cpp b/Userland/Services/WindowServer/WindowManager.cpp index 9f85e33507..1fed7611c2 100644 --- a/Userland/Services/WindowServer/WindowManager.cpp +++ b/Userland/Services/WindowServer/WindowManager.cpp @@ -432,6 +432,7 @@ void WindowManager::tell_wm_about_window(WMConnectionFromClient& conn, Window& w Window* modeless = window.modeless_ancestor(); if (!modeless) return; + bool is_blocked = modeless->blocking_modal_window(); auto is_active = for_each_window_in_modal_chain(*modeless, [&](auto& w) { if (w.is_active()) return IterationDecision::Break; @@ -439,7 +440,7 @@ void WindowManager::tell_wm_about_window(WMConnectionFromClient& conn, Window& w }); auto& window_stack = is_stationary_window_type(modeless->type()) ? current_window_stack() : modeless->window_stack(); - conn.async_window_state_changed(conn.window_id(), modeless->client_id(), modeless->window_id(), window_stack.row(), window_stack.column(), is_active, modeless->is_minimized(), modeless->is_frameless(), (i32)modeless->type(), modeless->computed_title(), modeless->rect(), modeless->progress()); + conn.async_window_state_changed(conn.window_id(), modeless->client_id(), modeless->window_id(), window_stack.row(), window_stack.column(), is_active, is_blocked, modeless->is_minimized(), modeless->is_frameless(), (i32)modeless->type(), modeless->computed_title(), modeless->rect(), modeless->progress()); } void WindowManager::tell_wm_about_window_rect(WMConnectionFromClient& conn, Window& window) diff --git a/Userland/Services/WindowServer/WindowManagerClient.ipc b/Userland/Services/WindowServer/WindowManagerClient.ipc index 709b99c908..8697ca95c1 100644 --- a/Userland/Services/WindowServer/WindowManagerClient.ipc +++ b/Userland/Services/WindowServer/WindowManagerClient.ipc @@ -3,7 +3,7 @@ endpoint WindowManagerClient { window_removed(i32 wm_id, i32 client_id, i32 window_id) =| - window_state_changed(i32 wm_id, i32 client_id, i32 window_id, u32 workspace_row, u32 workspace_column, bool is_active, bool is_minimized, bool is_frameless, i32 window_type, [UTF8] String title, Gfx::IntRect rect, Optional<i32> progress) =| + window_state_changed(i32 wm_id, i32 client_id, i32 window_id, u32 workspace_row, u32 workspace_column, bool is_active, bool is_blocking, bool is_minimized, bool is_frameless, i32 window_type, [UTF8] String title, Gfx::IntRect rect, Optional<i32> progress) =| window_icon_bitmap_changed(i32 wm_id, i32 client_id, i32 window_id, Gfx::ShareableBitmap bitmap) =| window_rect_changed(i32 wm_id, i32 client_id, i32 window_id, Gfx::IntRect rect) =| applet_area_size_changed(i32 wm_id, Gfx::IntSize size) =| |