mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 18:02:05 -05:00
WindowServer+LibGUI: Allow changing a window's base size and increment
Previously it was only possible to change these window attributes when creating a new window. This patch adds an IPC message that allows you to change them at runtime.
This commit is contained in:
parent
d0f5b43c2e
commit
ab6f694905
5 changed files with 38 additions and 2 deletions
|
@ -670,4 +670,22 @@ Action* Window::action_for_key_event(const KeyEvent& event)
|
||||||
return found_action;
|
return found_action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Window::set_base_size(const Gfx::Size& base_size)
|
||||||
|
{
|
||||||
|
if (m_base_size == base_size)
|
||||||
|
return;
|
||||||
|
m_base_size = base_size;
|
||||||
|
if (m_window_id)
|
||||||
|
WindowServerConnection::the().send_sync<Messages::WindowServer::SetWindowBaseSizeAndSizeIncrement>(m_window_id, m_base_size, m_size_increment);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Window::set_size_increment(const Gfx::Size& size_increment)
|
||||||
|
{
|
||||||
|
if (m_size_increment == size_increment)
|
||||||
|
return;
|
||||||
|
m_size_increment = size_increment;
|
||||||
|
if (m_window_id)
|
||||||
|
WindowServerConnection::the().send_sync<Messages::WindowServer::SetWindowBaseSizeAndSizeIncrement>(m_window_id, m_base_size, m_size_increment);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,9 +148,9 @@ public:
|
||||||
Gfx::Bitmap* back_bitmap() { return m_back_bitmap.ptr(); }
|
Gfx::Bitmap* back_bitmap() { return m_back_bitmap.ptr(); }
|
||||||
|
|
||||||
Gfx::Size size_increment() const { return m_size_increment; }
|
Gfx::Size size_increment() const { return m_size_increment; }
|
||||||
void set_size_increment(const Gfx::Size& increment) { m_size_increment = increment; }
|
void set_size_increment(const Gfx::Size&);
|
||||||
Gfx::Size base_size() const { return m_base_size; }
|
Gfx::Size base_size() const { return m_base_size; }
|
||||||
void set_base_size(const Gfx::Size& size) { m_base_size = size; }
|
void set_base_size(const Gfx::Size&);
|
||||||
|
|
||||||
void set_override_cursor(StandardCursor);
|
void set_override_cursor(StandardCursor);
|
||||||
|
|
||||||
|
|
|
@ -714,4 +714,19 @@ void ClientConnection::deboost()
|
||||||
perror("deboost: set_process_boost");
|
perror("deboost: set_process_boost");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OwnPtr<Messages::WindowServer::SetWindowBaseSizeAndSizeIncrementResponse> ClientConnection::handle(const Messages::WindowServer::SetWindowBaseSizeAndSizeIncrement& message)
|
||||||
|
{
|
||||||
|
auto it = m_windows.find(message.window_id());
|
||||||
|
if (it == m_windows.end()) {
|
||||||
|
did_misbehave("SetWindowBaseSizeAndSizeIncrementResponse: Bad window ID");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto& window = *it->value;
|
||||||
|
window.set_base_size(message.base_size());
|
||||||
|
window.set_size_increment(message.size_increment());
|
||||||
|
|
||||||
|
return make<Messages::WindowServer::SetWindowBaseSizeAndSizeIncrementResponse>();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,6 +116,7 @@ private:
|
||||||
virtual OwnPtr<Messages::WindowServer::StartDragResponse> handle(const Messages::WindowServer::StartDrag&) override;
|
virtual OwnPtr<Messages::WindowServer::StartDragResponse> handle(const Messages::WindowServer::StartDrag&) override;
|
||||||
virtual OwnPtr<Messages::WindowServer::SetSystemMenuResponse> handle(const Messages::WindowServer::SetSystemMenu&) override;
|
virtual OwnPtr<Messages::WindowServer::SetSystemMenuResponse> handle(const Messages::WindowServer::SetSystemMenu&) override;
|
||||||
virtual OwnPtr<Messages::WindowServer::SetSystemThemeResponse> handle(const Messages::WindowServer::SetSystemTheme&) override;
|
virtual OwnPtr<Messages::WindowServer::SetSystemThemeResponse> handle(const Messages::WindowServer::SetSystemTheme&) override;
|
||||||
|
virtual OwnPtr<Messages::WindowServer::SetWindowBaseSizeAndSizeIncrementResponse> handle(const Messages::WindowServer::SetWindowBaseSizeAndSizeIncrement&) override;
|
||||||
|
|
||||||
HashMap<int, NonnullRefPtr<Window>> m_windows;
|
HashMap<int, NonnullRefPtr<Window>> m_windows;
|
||||||
HashMap<int, NonnullOwnPtr<MenuBar>> m_menubars;
|
HashMap<int, NonnullOwnPtr<MenuBar>> m_menubars;
|
||||||
|
|
|
@ -83,4 +83,6 @@ endpoint WindowServer = 2
|
||||||
StartDrag(String text, String data_type, String data, i32 bitmap_id, Gfx::Size bitmap_size) => (bool started)
|
StartDrag(String text, String data_type, String data, i32 bitmap_id, Gfx::Size bitmap_size) => (bool started)
|
||||||
|
|
||||||
SetSystemTheme(String theme_path, String theme_name) => (bool success)
|
SetSystemTheme(String theme_path, String theme_name) => (bool success)
|
||||||
|
|
||||||
|
SetWindowBaseSizeAndSizeIncrement(i32 window_id, Gfx::Size base_size, Gfx::Size size_increment) => ()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue