Browse Source

WindowServer: Add a WSWindowType enum.

So far there's only Normal and Menu. Maybe we'll need more later.
Andreas Kling 6 years ago
parent
commit
c61f9eba61

+ 2 - 0
WindowServer/WSWindow.cpp

@@ -6,6 +6,7 @@
 
 WSWindow::WSWindow(WSMenu& menu)
     : m_lock("WSWindow (menu)")
+    , m_type(WSWindowType::Menu)
     , m_menu(&menu)
 {
     WSWindowManager::the().add_window(*this);
@@ -13,6 +14,7 @@ WSWindow::WSWindow(WSMenu& menu)
 
 WSWindow::WSWindow(Process& process, int window_id)
     : m_lock("WSWindow (normal)")
+    , m_type(WSWindowType::Normal)
     , m_process(&process)
     , m_window_id(window_id)
     , m_pid(process.pid())

+ 3 - 1
WindowServer/WSWindow.h

@@ -8,6 +8,7 @@
 #include <AK/Badge.h>
 #include <Kernel/Process.h>
 #include "WSMessageReceiver.h"
+#include <WindowServer/WSWindowType.h>
 
 class Process;
 class WSMenu;
@@ -19,7 +20,7 @@ public:
     explicit WSWindow(WSMenu&);
     virtual ~WSWindow() override;
 
-    bool is_menu() const { return m_menu; }
+    WSWindowType type() const { return m_type; }
     int window_id() const { return m_window_id; }
 
     String title() const { return m_title; }
@@ -72,6 +73,7 @@ private:
     Lock m_lock;
     String m_title;
     Rect m_rect;
+    WSWindowType m_type { WSWindowType::Normal };
     bool m_is_being_dragged { false };
     bool m_global_cursor_tracking_enabled { false };
     bool m_visible { true };

+ 1 - 1
WindowServer/WSWindowManager.cpp

@@ -259,7 +259,7 @@ void WSWindowManager::paint_window_frame(WSWindow& window)
     LOCKER(m_lock);
     //printf("[WM] paint_window_frame {%p}, rect: %d,%d %dx%d\n", &window, window.rect().x(), window.rect().y(), window.rect().width(), window.rect().height());
 
-    if (window.is_menu()) {
+    if (window.type() == WSWindowType::Menu) {
         m_back_painter->draw_rect(window.rect().inflated(2, 2), Color::LightGray);
         return;
     }

+ 2 - 1
WindowServer/WSWindowManager.h

@@ -10,6 +10,7 @@
 #include <AK/HashMap.h>
 #include "WSMessageReceiver.h"
 #include "WSMenuBar.h"
+#include <WindowServer/WSWindowType.h>
 
 class WSScreen;
 class WSMenuBar;
@@ -75,7 +76,7 @@ private:
     void handle_close_button_mouse_event(WSWindow&, WSMouseEvent&);
 
     void set_active_window(WSWindow*);
-
+    template<typename Callback> void for_each_visible_window_of_type(WSWindowType, Callback);
     template<typename Callback> void for_each_active_menubar_menu(Callback);
     void close_current_menu();
     WSMenu& create_menu(String&& name);

+ 7 - 0
WindowServer/WSWindowType.h

@@ -0,0 +1,7 @@
+#pragma once
+
+enum class WSWindowType {
+    Invalid = 0,
+    Normal,
+    Menu
+};