Преглед изворни кода

Taskbar: Use WM connection for window management operations

Since WM operations are moved to a separate endpoint pair, Taskbar now
uses those to perform window management related operations.
Additionally, it now explicitly declares to WindowServer that it is a
window manager.
sin-ack пре 4 година
родитељ
комит
c8ef8d2db5

+ 10 - 5
Userland/Services/Taskbar/TaskbarButton.cpp

@@ -28,6 +28,7 @@
 #include "WindowList.h"
 #include <LibGUI/Action.h>
 #include <LibGUI/Painter.h>
+#include <LibGUI/WindowManagerServerConnection.h>
 #include <LibGUI/WindowServerConnection.h>
 #include <LibGfx/Font.h>
 #include <LibGfx/FontDatabase.h>
@@ -45,13 +46,17 @@ TaskbarButton::~TaskbarButton()
 
 void TaskbarButton::context_menu_event(GUI::ContextMenuEvent&)
 {
-    GUI::WindowServerConnection::the().post_message(Messages::WindowServer::WM_PopupWindowMenu(m_identifier.client_id(), m_identifier.window_id(), screen_relative_rect().location()));
+    GUI::WindowManagerServerConnection::the().post_message(
+        Messages::WindowManagerServer::PopupWindowMenu(
+            m_identifier.client_id(),
+            m_identifier.window_id(),
+            screen_relative_rect().location()));
 }
 
 void TaskbarButton::update_taskbar_rect()
 {
-    GUI::WindowServerConnection::the().post_message(
-        Messages::WindowServer::WM_SetWindowTaskbarRect(
+    GUI::WindowManagerServerConnection::the().post_message(
+        Messages::WindowManagerServer::SetWindowTaskbarRect(
             m_identifier.client_id(),
             m_identifier.window_id(),
             screen_relative_rect()));
@@ -59,8 +64,8 @@ void TaskbarButton::update_taskbar_rect()
 
 void TaskbarButton::clear_taskbar_rect()
 {
-    GUI::WindowServerConnection::the().post_message(
-        Messages::WindowServer::WM_SetWindowTaskbarRect(
+    GUI::WindowManagerServerConnection::the().post_message(
+        Messages::WindowManagerServer::SetWindowTaskbarRect(
             m_identifier.client_id(),
             m_identifier.window_id(),
             {}));

+ 4 - 3
Userland/Services/Taskbar/TaskbarWindow.cpp

@@ -39,6 +39,7 @@
 #include <LibGUI/Menu.h>
 #include <LibGUI/Painter.h>
 #include <LibGUI/Window.h>
+#include <LibGUI/WindowManagerServerConnection.h>
 #include <LibGUI/WindowServerConnection.h>
 #include <LibGfx/FontDatabase.h>
 #include <LibGfx/Palette.h>
@@ -182,7 +183,7 @@ void TaskbarWindow::update_applet_area()
     main_widget()->do_layout();
     Gfx::IntRect new_rect { {}, m_applet_area_size };
     new_rect.center_within(m_applet_area_container->screen_relative_rect());
-    GUI::WindowServerConnection::the().send_sync<Messages::WindowServer::WM_SetAppletAreaPosition>(new_rect.location());
+    GUI::WindowManagerServerConnection::the().send_sync<Messages::WindowManagerServer::SetAppletAreaPosition>(new_rect.location());
 }
 
 NonnullRefPtr<GUI::Button> TaskbarWindow::create_button(const WindowIdentifier& identifier)
@@ -209,9 +210,9 @@ void TaskbarWindow::add_window_button(::Window& window, const WindowIdentifier&
         // false because window is the modal window's owner (which is not
         // active)
         if (window->is_minimized() || !button->is_checked()) {
-            GUI::WindowServerConnection::the().post_message(Messages::WindowServer::WM_SetActiveWindow(identifier.client_id(), identifier.window_id()));
+            GUI::WindowManagerServerConnection::the().post_message(Messages::WindowManagerServer::SetActiveWindow(identifier.client_id(), identifier.window_id()));
         } else {
-            GUI::WindowServerConnection::the().post_message(Messages::WindowServer::WM_SetWindowMinimized(identifier.client_id(), identifier.window_id(), true));
+            GUI::WindowManagerServerConnection::the().post_message(Messages::WindowManagerServer::SetWindowMinimized(identifier.client_id(), identifier.window_id(), true));
         }
     };
 }

+ 10 - 0
Userland/Services/Taskbar/main.cpp

@@ -36,7 +36,9 @@
 #include <LibGUI/ActionGroup.h>
 #include <LibGUI/Application.h>
 #include <LibGUI/Menu.h>
+#include <LibGUI/WindowManagerServerConnection.h>
 #include <LibGUI/WindowServerConnection.h>
+#include <WindowServer/Window.h>
 #include <serenity.h>
 #include <signal.h>
 #include <spawn.h>
@@ -61,6 +63,9 @@ int main(int argc, char** argv)
             ;
     });
 
+    // We need to obtain the WM connection here as well before the pledge shortening.
+    GUI::WindowManagerServerConnection::the();
+
     if (pledge("stdio recvfd sendfd accept proc exec rpath", nullptr) < 0) {
         perror("pledge");
         return 1;
@@ -72,6 +77,11 @@ int main(int argc, char** argv)
     auto window = TaskbarWindow::construct(move(menu));
     window->show();
 
+    window->make_window_manager(
+        WindowServer::WMEventMask::WindowStateChanges
+        | WindowServer::WMEventMask::WindowRemovals
+        | WindowServer::WMEventMask::WindowIconChanges);
+
     return app->exec();
 }