diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-02-12 11:53:45 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-02-12 11:53:45 +0100 |
commit | c61f9eba61a7ec49e74026bf9c78a4e09ff1d4e3 (patch) | |
tree | 5412c6bd73b473b4841fdd3346c8dae37faa295a | |
parent | 111589a5581d4bddce84ccb1ea7587b03dd55d98 (diff) | |
download | serenity-c61f9eba61a7ec49e74026bf9c78a4e09ff1d4e3.zip |
WindowServer: Add a WSWindowType enum.
So far there's only Normal and Menu. Maybe we'll need more later.
-rw-r--r-- | WindowServer/WSWindow.cpp | 2 | ||||
-rw-r--r-- | WindowServer/WSWindow.h | 4 | ||||
-rw-r--r-- | WindowServer/WSWindowManager.cpp | 2 | ||||
-rw-r--r-- | WindowServer/WSWindowManager.h | 3 | ||||
-rw-r--r-- | WindowServer/WSWindowType.h | 7 |
5 files changed, 15 insertions, 3 deletions
diff --git a/WindowServer/WSWindow.cpp b/WindowServer/WSWindow.cpp index 476eb3c884..5323cef724 100644 --- a/WindowServer/WSWindow.cpp +++ b/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()) diff --git a/WindowServer/WSWindow.h b/WindowServer/WSWindow.h index 9d6f9f1016..ea124e5de7 100644 --- a/WindowServer/WSWindow.h +++ b/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 }; diff --git a/WindowServer/WSWindowManager.cpp b/WindowServer/WSWindowManager.cpp index e4dee4443b..1aff70694e 100644 --- a/WindowServer/WSWindowManager.cpp +++ b/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; } diff --git a/WindowServer/WSWindowManager.h b/WindowServer/WSWindowManager.h index 3a3adb2ecd..3b93877281 100644 --- a/WindowServer/WSWindowManager.h +++ b/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); diff --git a/WindowServer/WSWindowType.h b/WindowServer/WSWindowType.h new file mode 100644 index 0000000000..afd2b8a13f --- /dev/null +++ b/WindowServer/WSWindowType.h @@ -0,0 +1,7 @@ +#pragma once + +enum class WSWindowType { + Invalid = 0, + Normal, + Menu +}; |