Ver Fonte

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.
thankyouverycool há 2 anos atrás
pai
commit
d815f659cc

+ 2 - 2
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)

+ 1 - 1
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;

+ 4 - 1
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;

+ 4 - 2
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());

+ 4 - 0
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;
 };

+ 2 - 1
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)

+ 1 - 1
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) =|