mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-24 05:25:13 +00:00
LibGUI+WindowServer: Allow applets to retrieve their location
MenuApplet windows can now call rect_in_menubar to return their location in the MenuBar.
This commit is contained in:
parent
030f4150b8
commit
c50f258b7a
Notes:
sideshowbarker
2024-07-19 04:37:24 +09:00
Author: https://github.com/thankyouverycool Commit: https://github.com/SerenityOS/serenity/commit/c50f258b7a9 Pull-request: https://github.com/SerenityOS/serenity/pull/2875 Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/benit8
5 changed files with 21 additions and 0 deletions
|
@ -177,6 +177,12 @@ String Window::title() const
|
|||
return WindowServerConnection::the().send_sync<Messages::WindowServer::GetWindowTitle>(m_window_id)->title();
|
||||
}
|
||||
|
||||
Gfx::IntRect Window::rect_in_menubar() const
|
||||
{
|
||||
ASSERT(m_window_type == WindowType::MenuApplet);
|
||||
return WindowServerConnection::the().send_sync<Messages::WindowServer::GetWindowRectInMenubar>(m_window_id)->rect();
|
||||
}
|
||||
|
||||
Gfx::IntRect Window::rect() const
|
||||
{
|
||||
if (!is_visible())
|
||||
|
|
|
@ -107,6 +107,7 @@ public:
|
|||
int height() const { return rect().height(); }
|
||||
|
||||
Gfx::IntRect rect() const;
|
||||
Gfx::IntRect rect_in_menubar() const;
|
||||
Gfx::IntSize size() const { return rect().size(); }
|
||||
void set_rect(const Gfx::IntRect&);
|
||||
void set_rect(int x, int y, int width, int height) { set_rect({ x, y, width, height }); }
|
||||
|
|
|
@ -424,6 +424,17 @@ OwnPtr<Messages::WindowServer::GetWindowRectResponse> ClientConnection::handle(c
|
|||
return make<Messages::WindowServer::GetWindowRectResponse>(it->value->rect());
|
||||
}
|
||||
|
||||
OwnPtr<Messages::WindowServer::GetWindowRectInMenubarResponse> ClientConnection::handle(const Messages::WindowServer::GetWindowRectInMenubar& message)
|
||||
{
|
||||
int window_id = message.window_id();
|
||||
auto it = m_windows.find(window_id);
|
||||
if (it == m_windows.end()) {
|
||||
did_misbehave("GetWindowRectInMenubar: Bad window ID");
|
||||
return nullptr;
|
||||
}
|
||||
return make<Messages::WindowServer::GetWindowRectInMenubarResponse>(it->value->rect_in_menubar());
|
||||
}
|
||||
|
||||
Window* ClientConnection::window_from_id(i32 window_id)
|
||||
{
|
||||
auto it = m_windows.find(window_id);
|
||||
|
|
|
@ -109,6 +109,7 @@ private:
|
|||
virtual OwnPtr<Messages::WindowServer::IsMaximizedResponse> handle(const Messages::WindowServer::IsMaximized&) override;
|
||||
virtual OwnPtr<Messages::WindowServer::SetWindowRectResponse> handle(const Messages::WindowServer::SetWindowRect&) override;
|
||||
virtual OwnPtr<Messages::WindowServer::GetWindowRectResponse> handle(const Messages::WindowServer::GetWindowRect&) override;
|
||||
virtual OwnPtr<Messages::WindowServer::GetWindowRectInMenubarResponse> handle(const Messages::WindowServer::GetWindowRectInMenubar&) override;
|
||||
virtual void handle(const Messages::WindowServer::InvalidateRect&) override;
|
||||
virtual void handle(const Messages::WindowServer::DidFinishPainting&) override;
|
||||
virtual OwnPtr<Messages::WindowServer::SetGlobalCursorTrackingResponse> handle(const Messages::WindowServer::SetGlobalCursorTracking&) override;
|
||||
|
|
|
@ -56,6 +56,8 @@ endpoint WindowServer = 2
|
|||
SetWindowRect(i32 window_id, Gfx::IntRect rect) => (Gfx::IntRect rect)
|
||||
GetWindowRect(i32 window_id) => (Gfx::IntRect rect)
|
||||
|
||||
GetWindowRectInMenubar(i32 window_id) => (Gfx::IntRect rect)
|
||||
|
||||
IsMaximized(i32 window_id) => (bool maximized)
|
||||
|
||||
InvalidateRect(i32 window_id, Vector<Gfx::IntRect> rects, bool ignore_occlusion) =|
|
||||
|
|
Loading…
Add table
Reference in a new issue