mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 23:27:35 +00:00
WindowServer: Add Window "modified" state
This will be used to track which windows contain some kind of unsaved data that the user may want some help remembering to save. :^)
This commit is contained in:
parent
5c385d06e8
commit
492464f4c1
5 changed files with 41 additions and 1 deletions
|
@ -903,4 +903,26 @@ OwnPtr<Messages::WindowServer::GetScreenBitmapResponse> ClientConnection::handle
|
||||||
return make<Messages::WindowServer::GetScreenBitmapResponse>(bitmap.to_shareable_bitmap());
|
return make<Messages::WindowServer::GetScreenBitmapResponse>(bitmap.to_shareable_bitmap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OwnPtr<Messages::WindowServer::IsWindowModifiedResponse> ClientConnection::handle(Messages::WindowServer::IsWindowModified const& message)
|
||||||
|
{
|
||||||
|
auto it = m_windows.find(message.window_id());
|
||||||
|
if (it == m_windows.end()) {
|
||||||
|
did_misbehave("IsWindowModified: Bad window ID");
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
auto& window = *it->value;
|
||||||
|
return make<Messages::WindowServer::IsWindowModifiedResponse>(window.is_modified());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClientConnection::handle(Messages::WindowServer::SetWindowModified const& message)
|
||||||
|
{
|
||||||
|
auto it = m_windows.find(message.window_id());
|
||||||
|
if (it == m_windows.end()) {
|
||||||
|
did_misbehave("SetWindowModified: Bad window ID");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto& window = *it->value;
|
||||||
|
window.set_modified(message.modified());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -146,6 +146,8 @@ private:
|
||||||
virtual OwnPtr<Messages::WindowServer::GetScreenBitmapResponse> handle(const Messages::WindowServer::GetScreenBitmap&) override;
|
virtual OwnPtr<Messages::WindowServer::GetScreenBitmapResponse> handle(const Messages::WindowServer::GetScreenBitmap&) override;
|
||||||
virtual OwnPtr<Messages::WindowServer::SetDoubleClickSpeedResponse> handle(const Messages::WindowServer::SetDoubleClickSpeed&) override;
|
virtual OwnPtr<Messages::WindowServer::SetDoubleClickSpeedResponse> handle(const Messages::WindowServer::SetDoubleClickSpeed&) override;
|
||||||
virtual OwnPtr<Messages::WindowServer::GetDoubleClickSpeedResponse> handle(const Messages::WindowServer::GetDoubleClickSpeed&) override;
|
virtual OwnPtr<Messages::WindowServer::GetDoubleClickSpeedResponse> handle(const Messages::WindowServer::GetDoubleClickSpeed&) override;
|
||||||
|
virtual void handle(Messages::WindowServer::SetWindowModified const&) override;
|
||||||
|
virtual OwnPtr<Messages::WindowServer::IsWindowModifiedResponse> handle(Messages::WindowServer::IsWindowModified const&) override;
|
||||||
|
|
||||||
Window* window_from_id(i32 window_id);
|
Window* window_from_id(i32 window_id);
|
||||||
|
|
||||||
|
|
|
@ -992,4 +992,13 @@ void Window::invalidate_menubar()
|
||||||
frame().invalidate();
|
frame().invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Window::set_modified(bool modified)
|
||||||
|
{
|
||||||
|
if (m_modified == modified)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_modified = modified;
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,9 @@ public:
|
||||||
Window(Core::Object&, WindowType);
|
Window(Core::Object&, WindowType);
|
||||||
virtual ~Window() override;
|
virtual ~Window() override;
|
||||||
|
|
||||||
|
bool is_modified() const { return m_modified; }
|
||||||
|
void set_modified(bool);
|
||||||
|
|
||||||
void popup_window_menu(const Gfx::IntPoint&, WindowMenuDefaultAction);
|
void popup_window_menu(const Gfx::IntPoint&, WindowMenuDefaultAction);
|
||||||
void handle_window_menu_action(WindowMenuAction);
|
void handle_window_menu_action(WindowMenuAction);
|
||||||
void window_menu_activate_default();
|
void window_menu_activate_default();
|
||||||
|
@ -397,6 +400,7 @@ private:
|
||||||
int m_minimize_animation_step { -1 };
|
int m_minimize_animation_step { -1 };
|
||||||
int m_progress { -1 };
|
int m_progress { -1 };
|
||||||
bool m_should_show_menubar { true };
|
bool m_should_show_menubar { true };
|
||||||
|
bool m_modified { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,9 @@ endpoint WindowServer
|
||||||
|
|
||||||
SetWindowProgress(i32 window_id, i32 progress) =|
|
SetWindowProgress(i32 window_id, i32 progress) =|
|
||||||
|
|
||||||
|
SetWindowModified(i32 window_id, bool modified) =|
|
||||||
|
IsWindowModified(i32 window_id) => (bool modified)
|
||||||
|
|
||||||
SetWindowRect(i32 window_id, Gfx::IntRect rect) => (Gfx::IntRect rect)
|
SetWindowRect(i32 window_id, Gfx::IntRect rect) => (Gfx::IntRect rect)
|
||||||
GetWindowRect(i32 window_id) => (Gfx::IntRect rect)
|
GetWindowRect(i32 window_id) => (Gfx::IntRect rect)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue