1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:07:34 +00:00

LibGUI+WindowServer: Introduce WindowModes

Previously, Windows only understood blocking modality: Windows were
either modal, i.e., in a blocking state, or not. Windows could also
be set as Accessories or ToolWindows, attributes which technically
applied modes to their parents but were implemented ad hoc. This patch
redefines these modal effects as WindowModes and sets up some helpers.
This will let us simplify a lot of modal logic in the upcoming patches
and make it easier to build new modal effects in the future.

Windows can now set 1 of 5 modes before reification:
-Modeless:	No modal effect; begins a new modal chain
-Passive:	Window joins its modal chain but has no effect
-RenderAbove:	Window renders above its parent
-CaptureInput:	Window captures the active input role from its parent
-Blocking:	Window blocks all interaction with its modal chain

States like fullscreen and tiling are dynamic and don't alter behavior
in modal chains, so they aren't included.
This commit is contained in:
thankyouverycool 2022-08-18 11:00:08 -04:00 committed by Andreas Kling
parent 609391b46e
commit 589572cfa4
15 changed files with 91 additions and 63 deletions

View file

@ -17,6 +17,7 @@
#include <WindowServer/Menubar.h>
#include <WindowServer/Screen.h>
#include <WindowServer/WindowFrame.h>
#include <WindowServer/WindowMode.h>
#include <WindowServer/WindowType.h>
namespace WindowServer {
@ -141,8 +142,6 @@ public:
WindowFrame& frame() { return m_frame; }
WindowFrame const& frame() const { return m_frame; }
Window* blocking_modal_window();
ConnectionFromClient* client() { return m_client; }
ConnectionFromClient const* client() const { return m_client; }
@ -182,8 +181,13 @@ public:
bool is_visible() const { return m_visible; }
void set_visible(bool);
bool is_modal() const;
bool is_modal_dont_unparent() const { return m_modal && m_parent_window; }
bool is_modal() const { return m_mode != WindowMode::Modeless; }
bool is_passive() { return m_mode == WindowMode::Passive; }
bool is_blocking() const { return m_mode == WindowMode::Blocking; }
Window* blocking_modal_window();
WindowMode mode() const { return m_mode; }
Window* modeless_ancestor();
Gfx::IntRect rect() const { return m_rect; }
@ -381,7 +385,7 @@ public:
bool is_stealable_by_client(i32 client_id) const { return m_stealable_by_client_ids.contains_slow(client_id); }
private:
Window(ConnectionFromClient&, WindowType, int window_id, bool modal, bool minimizable, bool closeable, bool frameless, bool resizable, bool fullscreen, bool accessory, Window* parent_window = nullptr);
Window(ConnectionFromClient&, WindowType, WindowMode, int window_id, bool minimizable, bool closeable, bool frameless, bool resizable, bool fullscreen, bool accessory, Window* parent_window = nullptr);
Window(Core::Object&, WindowType);
virtual void event(Core::Event&) override;
@ -412,10 +416,10 @@ private:
Gfx::DisjointRectSet m_transparency_wallpaper_rects;
HashMap<Window*, Gfx::DisjointRectSet> m_affected_transparency_rects;
WindowType m_type { WindowType::Normal };
WindowMode m_mode { WindowMode::Modeless };
bool m_automatic_cursor_tracking_enabled { false };
bool m_visible { true };
bool m_has_alpha_channel { false };
bool m_modal { false };
bool m_minimizable { false };
bool m_closeable { false };
bool m_frameless { false };