summaryrefslogtreecommitdiff
path: root/WindowServer
diff options
context:
space:
mode:
Diffstat (limited to 'WindowServer')
-rw-r--r--WindowServer/WSAPITypes.h2
-rw-r--r--WindowServer/WSClientConnection.cpp1
-rw-r--r--WindowServer/WSMessage.h8
-rw-r--r--WindowServer/WSMessageLoop.cpp2
-rw-r--r--WindowServer/WSWindow.h8
-rw-r--r--WindowServer/WSWindowManager.cpp8
6 files changed, 27 insertions, 2 deletions
diff --git a/WindowServer/WSAPITypes.h b/WindowServer/WSAPITypes.h
index da39a9a04e..9cd0fea2d8 100644
--- a/WindowServer/WSAPITypes.h
+++ b/WindowServer/WSAPITypes.h
@@ -170,6 +170,8 @@ struct WSAPI_ClientMessage {
WSAPI_Rect rect;
bool has_alpha_channel;
float opacity;
+ WSAPI_Size base_size;
+ WSAPI_Size size_increment;
} window;
struct {
WSAPI_Size size;
diff --git a/WindowServer/WSClientConnection.cpp b/WindowServer/WSClientConnection.cpp
index 2a171a8056..b3c1271424 100644
--- a/WindowServer/WSClientConnection.cpp
+++ b/WindowServer/WSClientConnection.cpp
@@ -319,6 +319,7 @@ void WSClientConnection::handle_request(WSAPICreateWindowRequest& request)
window->set_title(request.title());
window->set_rect(request.rect());
window->set_opacity(request.opacity());
+ window->set_size_increment(request.size_increment());
m_windows.set(window_id, move(window));
WSAPI_ServerMessage response;
response.type = WSAPI_ServerMessage::Type::DidCreateWindow;
diff --git a/WindowServer/WSMessage.h b/WindowServer/WSMessage.h
index b87b0339cb..cf7a8bc319 100644
--- a/WindowServer/WSMessage.h
+++ b/WindowServer/WSMessage.h
@@ -349,12 +349,14 @@ private:
class WSAPICreateWindowRequest : public WSAPIClientRequest {
public:
- WSAPICreateWindowRequest(int client_id, const Rect& rect, const String& title, bool has_alpha_channel, float opacity)
+ WSAPICreateWindowRequest(int client_id, const Rect& rect, const String& title, bool has_alpha_channel, float opacity, const Size& base_size, const Size& size_increment)
: WSAPIClientRequest(WSMessage::APICreateWindowRequest, client_id)
, m_rect(rect)
, m_title(title)
, m_opacity(opacity)
, m_has_alpha_channel(has_alpha_channel)
+ , m_base_size(base_size)
+ , m_size_increment(size_increment)
{
}
@@ -362,12 +364,16 @@ public:
String title() const { return m_title; }
bool has_alpha_channel() const { return m_has_alpha_channel; }
float opacity() const { return m_opacity; }
+ Size size_increment() const { return m_size_increment; }
+ Size base_size() const { return m_base_size; }
private:
Rect m_rect;
String m_title;
float m_opacity { 0 };
bool m_has_alpha_channel { false };
+ Size m_size_increment;
+ Size m_base_size;
};
class WSAPIDestroyWindowRequest : public WSAPIClientRequest {
diff --git a/WindowServer/WSMessageLoop.cpp b/WindowServer/WSMessageLoop.cpp
index bbdec4fe35..15ea696fc6 100644
--- a/WindowServer/WSMessageLoop.cpp
+++ b/WindowServer/WSMessageLoop.cpp
@@ -302,7 +302,7 @@ void WSMessageLoop::on_receive_from_client(int client_id, const WSAPI_ClientMess
break;
case WSAPI_ClientMessage::Type::CreateWindow:
ASSERT(message.text_length < sizeof(message.text));
- post_message(client, make<WSAPICreateWindowRequest>(client_id, message.window.rect, String(message.text, message.text_length), message.window.has_alpha_channel, message.window.opacity));
+ post_message(client, make<WSAPICreateWindowRequest>(client_id, message.window.rect, String(message.text, message.text_length), message.window.has_alpha_channel, message.window.opacity, message.window.base_size, message.window.size_increment));
break;
case WSAPI_ClientMessage::Type::DestroyWindow:
post_message(client, make<WSAPIDestroyWindowRequest>(client_id, message.window_id));
diff --git a/WindowServer/WSWindow.h b/WindowServer/WSWindow.h
index f4d6c28b5d..15745a55a0 100644
--- a/WindowServer/WSWindow.h
+++ b/WindowServer/WSWindow.h
@@ -70,6 +70,12 @@ public:
bool has_painted_since_last_resize() const { return m_has_painted_since_last_resize; }
void set_has_painted_since_last_resize(bool b) { m_has_painted_since_last_resize = b; }
+ Size size_increment() const { return m_size_increment; }
+ void set_size_increment(const Size& increment) { m_size_increment = increment; }
+
+ Size base_size() const { return m_base_size; }
+ void set_base_size(const Size& size) { m_base_size = size; }
+
// For InlineLinkedList.
// FIXME: Maybe make a ListHashSet and then WSWindowManager can just use that.
WSWindow* m_next { nullptr };
@@ -89,4 +95,6 @@ private:
int m_window_id { -1 };
float m_opacity { 1 };
Rect m_last_lazy_resize_rect;
+ Size m_size_increment;
+ Size m_base_size;
};
diff --git a/WindowServer/WSWindowManager.cpp b/WindowServer/WSWindowManager.cpp
index 6f30461a28..1b7640cb69 100644
--- a/WindowServer/WSWindowManager.cpp
+++ b/WindowServer/WSWindowManager.cpp
@@ -548,6 +548,14 @@ void WSWindowManager::process_mouse_event(WSMouseEvent& event, WSWindow*& event_
auto new_rect = m_resize_window_original_rect;
new_rect.set_width(max(50, new_rect.width() + dx));
new_rect.set_height(max(50, new_rect.height() + dy));
+
+ if (!m_resize_window->size_increment().is_null()) {
+ int horizontal_incs = (new_rect.width() - m_resize_window->base_size().width()) / m_resize_window->size_increment().width();
+ new_rect.set_width(m_resize_window->base_size().width() + horizontal_incs * m_resize_window->size_increment().width());
+ int vertical_incs = (new_rect.height() - m_resize_window->base_size().height()) / m_resize_window->size_increment().height();
+ new_rect.set_height(m_resize_window->base_size().height() + vertical_incs * m_resize_window->size_increment().height());
+ }
+
if (m_resize_window->rect() == new_rect)
return;
#ifdef RESIZE_DEBUG