From 2fa765bbd53f2b07eba8012e350cdea8b8afe13c Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 1 May 2021 18:22:29 +0200 Subject: [PATCH] LibGUI: Add getter/setter for GUI::Window modified state This state lives in WindowServer and has no local copy in the client process for now. This may turn out to be a performance issue, and if it does we can easily cache it. --- Userland/Libraries/LibGUI/Window.cpp | 14 ++++++++++++++ Userland/Libraries/LibGUI/Window.h | 5 ++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibGUI/Window.cpp b/Userland/Libraries/LibGUI/Window.cpp index bd59e41f12..87cfcedb3f 100644 --- a/Userland/Libraries/LibGUI/Window.cpp +++ b/Userland/Libraries/LibGUI/Window.cpp @@ -1084,4 +1084,18 @@ void Window::set_menubar(RefPtr menubar) } } +bool Window::is_modified() const +{ + if (!m_window_id) + return false; + return WindowServerConnection::the().send_sync(m_window_id)->modified(); +} + +void Window::set_modified(bool modified) +{ + if (!m_window_id) + return; + WindowServerConnection::the().post_message(Messages::WindowServer::SetWindowModified(m_window_id, modified)); +} + } diff --git a/Userland/Libraries/LibGUI/Window.h b/Userland/Libraries/LibGUI/Window.h index f8c765f468..20b0a642dd 100644 --- a/Userland/Libraries/LibGUI/Window.h +++ b/Userland/Libraries/LibGUI/Window.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020, Andreas Kling + * Copyright (c) 2018-2021, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ @@ -29,6 +29,9 @@ public: static Window* from_window_id(int); + bool is_modified() const; + void set_modified(bool); + bool is_modal() const { return m_modal; } void set_modal(bool);