WindowServer: Implement partial window resizing
This patch adds support for client side resizing, so clients can request the server to resize their windows. WindowServer will respond with resize event when and if the resizing is complete.
This commit is contained in:
@@ -163,9 +163,11 @@ namespace LibGUI
|
||||
WindowSetPosition,
|
||||
WindowSetAttributes,
|
||||
WindowSetMouseCapture,
|
||||
WindowSetSize,
|
||||
|
||||
DestroyWindowEvent,
|
||||
CloseWindowEvent,
|
||||
ResizeWindowEvent,
|
||||
KeyEvent,
|
||||
MouseButtonEvent,
|
||||
MouseMoveEvent,
|
||||
@@ -182,13 +184,6 @@ namespace LibGUI
|
||||
BAN::String, title
|
||||
);
|
||||
|
||||
DEFINE_PACKET(
|
||||
WindowCreateResponse,
|
||||
uint32_t, width,
|
||||
uint32_t, height,
|
||||
long, smo_key
|
||||
);
|
||||
|
||||
DEFINE_PACKET(
|
||||
WindowInvalidate,
|
||||
uint32_t, x,
|
||||
@@ -220,6 +215,12 @@ namespace LibGUI
|
||||
bool, captured
|
||||
);
|
||||
|
||||
DEFINE_PACKET(
|
||||
WindowSetSize,
|
||||
uint32_t, width,
|
||||
uint32_t, height
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
namespace EventPacket
|
||||
@@ -233,6 +234,13 @@ namespace LibGUI
|
||||
CloseWindowEvent
|
||||
);
|
||||
|
||||
DEFINE_PACKET(
|
||||
ResizeWindowEvent,
|
||||
uint32_t, width,
|
||||
uint32_t, height,
|
||||
long, smo_key
|
||||
);
|
||||
|
||||
DEFINE_PACKET_EXTRA(
|
||||
KeyEvent,
|
||||
using event_t = LibInput::KeyEvent,
|
||||
|
||||
@@ -67,12 +67,17 @@ namespace LibGUI
|
||||
Attributes get_attributes() const { return m_attributes; }
|
||||
void set_attributes(Attributes attributes);
|
||||
|
||||
// send resize request to window server
|
||||
// actual resize is only done after resize callback is called
|
||||
void request_resize(uint32_t width, uint32_t height);
|
||||
|
||||
uint32_t width() const { return m_width; }
|
||||
uint32_t height() const { return m_height; }
|
||||
|
||||
void poll_events();
|
||||
void set_socket_error_callback(BAN::Function<void()> callback) { m_socket_error_callback = callback; }
|
||||
void set_close_window_event_callback(BAN::Function<void()> callback) { m_close_window_event_callback = callback; }
|
||||
void set_resize_window_event_callback(BAN::Function<void()> callback) { m_resize_window_event_callback = callback; }
|
||||
void set_key_event_callback(BAN::Function<void(EventPacket::KeyEvent::event_t)> callback) { m_key_event_callback = callback; }
|
||||
void set_mouse_button_event_callback(BAN::Function<void(EventPacket::MouseButtonEvent::event_t)> callback) { m_mouse_button_event_callback = callback; }
|
||||
void set_mouse_move_event_callback(BAN::Function<void(EventPacket::MouseMoveEvent::event_t)> callback) { m_mouse_move_event_callback = callback; }
|
||||
@@ -81,33 +86,32 @@ namespace LibGUI
|
||||
int server_fd() const { return m_server_fd; }
|
||||
|
||||
private:
|
||||
Window(int server_fd, uint32_t* framebuffer_smo, BAN::Vector<uint32_t>&& framebuffer, uint32_t width, uint32_t height)
|
||||
Window(int server_fd)
|
||||
: m_server_fd(server_fd)
|
||||
, m_framebuffer(framebuffer)
|
||||
, m_framebuffer_smo(framebuffer_smo)
|
||||
, m_width(width)
|
||||
, m_height(height)
|
||||
{ }
|
||||
|
||||
bool clamp_to_framebuffer(int32_t& x, int32_t& y, uint32_t& width, uint32_t& height) const;
|
||||
|
||||
void on_socket_error(BAN::StringView function);
|
||||
void clear();
|
||||
void cleanup();
|
||||
|
||||
BAN::ErrorOr<void> handle_resize_event(const EventPacket::ResizeWindowEvent&);
|
||||
|
||||
private:
|
||||
int m_server_fd;
|
||||
const int m_server_fd;
|
||||
|
||||
bool m_handling_socket_error { false };
|
||||
|
||||
Attributes m_attributes;
|
||||
|
||||
BAN::Vector<uint32_t> m_framebuffer;
|
||||
uint32_t* m_framebuffer_smo;
|
||||
uint32_t m_width;
|
||||
uint32_t m_height;
|
||||
uint32_t* m_framebuffer_smo { nullptr };
|
||||
uint32_t m_width { 0 };
|
||||
uint32_t m_height { 0 };
|
||||
|
||||
BAN::Function<void()> m_socket_error_callback;
|
||||
BAN::Function<void()> m_close_window_event_callback;
|
||||
BAN::Function<void()> m_resize_window_event_callback;
|
||||
BAN::Function<void(EventPacket::KeyEvent::event_t)> m_key_event_callback;
|
||||
BAN::Function<void(EventPacket::MouseButtonEvent::event_t)> m_mouse_button_event_callback;
|
||||
BAN::Function<void(EventPacket::MouseMoveEvent::event_t)> m_mouse_move_event_callback;
|
||||
|
||||
Reference in New Issue
Block a user