summaryrefslogtreecommitdiff
path: root/Servers
diff options
context:
space:
mode:
authorJami Kettunen <jami.kettunen@protonmail.com>2020-01-04 13:12:02 +0200
committerAndreas Kling <awesomekling@gmail.com>2020-01-04 14:58:50 +0100
commiteab34a7de3e8b1c1bfe42e5a602ba6d502326ec1 (patch)
tree6c9aa702e47c3a0757423e5c4054d9547813a3e9 /Servers
parenta641f4d213bc957dc7ea515b925a8275332e8042 (diff)
downloadserenity-eab34a7de3e8b1c1bfe42e5a602ba6d502326ec1.zip
WindowServer+LibGUI: Implement minimizable property to windows
Diffstat (limited to 'Servers')
-rw-r--r--Servers/WindowServer/WSClientConnection.cpp2
-rw-r--r--Servers/WindowServer/WSWindow.cpp23
-rw-r--r--Servers/WindowServer/WSWindow.h11
-rw-r--r--Servers/WindowServer/WSWindowFrame.cpp10
-rw-r--r--Servers/WindowServer/WSWindowFrame.h1
-rw-r--r--Servers/WindowServer/WindowServer.ipc1
6 files changed, 40 insertions, 8 deletions
diff --git a/Servers/WindowServer/WSClientConnection.cpp b/Servers/WindowServer/WSClientConnection.cpp
index 075fd2b257..4328ce63af 100644
--- a/Servers/WindowServer/WSClientConnection.cpp
+++ b/Servers/WindowServer/WSClientConnection.cpp
@@ -394,7 +394,7 @@ OwnPtr<WindowServer::GetClipboardContentsResponse> WSClientConnection::handle(co
OwnPtr<WindowServer::CreateWindowResponse> WSClientConnection::handle(const WindowServer::CreateWindow& message)
{
int window_id = m_next_window_id++;
- auto window = WSWindow::construct(*this, (WSWindowType)message.type(), window_id, message.modal(), message.resizable(), message.fullscreen());
+ auto window = WSWindow::construct(*this, (WSWindowType)message.type(), window_id, message.modal(), message.minimizable(), message.resizable(), message.fullscreen());
window->set_has_alpha_channel(message.has_alpha_channel());
window->set_title(message.title());
if (!message.fullscreen())
diff --git a/Servers/WindowServer/WSWindow.cpp b/Servers/WindowServer/WSWindow.cpp
index 9ddb5a75a5..edafb89d8b 100644
--- a/Servers/WindowServer/WSWindow.cpp
+++ b/Servers/WindowServer/WSWindow.cpp
@@ -28,11 +28,12 @@ WSWindow::WSWindow(CObject& parent, WSWindowType type)
WSWindowManager::the().add_window(*this);
}
-WSWindow::WSWindow(WSClientConnection& client, WSWindowType window_type, int window_id, bool modal, bool resizable, bool fullscreen)
+WSWindow::WSWindow(WSClientConnection& client, WSWindowType window_type, int window_id, bool modal, bool minimizable, bool resizable, bool fullscreen)
: CObject(&client)
, m_client(&client)
, m_type(window_type)
, m_modal(modal)
+ , m_minimizable(minimizable)
, m_resizable(resizable)
, m_fullscreen(fullscreen)
, m_window_id(window_id)
@@ -102,6 +103,8 @@ void WSWindow::set_minimized(bool minimized)
{
if (m_minimized == minimized)
return;
+ if (minimized && !m_minimizable)
+ return;
m_minimized = minimized;
start_minimize_animation();
if (!minimized)
@@ -110,6 +113,14 @@ void WSWindow::set_minimized(bool minimized)
WSWindowManager::the().notify_minimization_state_changed(*this);
}
+void WSWindow::set_minimizable(bool minimizable)
+{
+ if (m_minimizable == minimizable)
+ return;
+ m_minimizable = minimizable;
+ // TODO: Hide/show (or alternatively change enabled state of) window minimize button dynamically depending on value of m_minimizable
+}
+
void WSWindow::set_opacity(float opacity)
{
if (m_opacity == opacity)
@@ -130,6 +141,8 @@ void WSWindow::set_maximized(bool maximized)
{
if (m_maximized == maximized)
return;
+ if (maximized && !is_resizable())
+ return;
m_maximized = maximized;
auto old_rect = m_rect;
if (maximized) {
@@ -142,6 +155,14 @@ void WSWindow::set_maximized(bool maximized)
CEventLoop::current().post_event(*this, make<WSResizeEvent>(old_rect, m_rect));
}
+void WSWindow::set_resizable(bool resizable)
+{
+ if (m_resizable == resizable)
+ return;
+ m_resizable = resizable;
+ // TODO: Hide/show (or alternatively change enabled state of) window maximize button dynamically depending on value of is_resizable()
+}
+
void WSWindow::event(CEvent& event)
{
if (!m_client) {
diff --git a/Servers/WindowServer/WSWindow.h b/Servers/WindowServer/WSWindow.h
index 951a11f349..cb6a53b39e 100644
--- a/Servers/WindowServer/WSWindow.h
+++ b/Servers/WindowServer/WSWindow.h
@@ -31,7 +31,7 @@ class WSWindow final : public CObject
, public InlineLinkedListNode<WSWindow> {
C_OBJECT(WSWindow)
public:
- WSWindow(WSClientConnection&, WSWindowType, int window_id, bool modal, bool resizable, bool fullscreen);
+ WSWindow(WSClientConnection&, WSWindowType, int window_id, bool modal, bool minimizable, bool resizable, bool fullscreen);
WSWindow(CObject&, WSWindowType);
virtual ~WSWindow() override;
@@ -44,6 +44,12 @@ public:
bool is_minimized() const { return m_minimized; }
void set_minimized(bool);
+ bool is_minimizable() const { return m_minimizable; }
+ void set_minimizable(bool);
+
+ bool is_resizable() const { return m_resizable && !m_fullscreen; }
+ void set_resizable(bool);
+
bool is_maximized() const { return m_maximized; }
void set_maximized(bool);
@@ -95,8 +101,6 @@ public:
bool is_modal() const { return m_modal; }
- bool is_resizable() const { return m_resizable && !m_fullscreen; }
-
Rect rect() const { return m_rect; }
void set_rect(const Rect&);
void set_rect(int x, int y, int width, int height) { set_rect({ x, y, width, height }); }
@@ -198,6 +202,7 @@ private:
bool m_visible { true };
bool m_has_alpha_channel { false };
bool m_modal { false };
+ bool m_minimizable { false };
bool m_resizable { false };
bool m_listens_to_wm_events { false };
bool m_minimized { false };
diff --git a/Servers/WindowServer/WSWindowFrame.cpp b/Servers/WindowServer/WSWindowFrame.cpp
index 3fd3ae86d6..fbfe5b1db3 100644
--- a/Servers/WindowServer/WSWindowFrame.cpp
+++ b/Servers/WindowServer/WSWindowFrame.cpp
@@ -102,9 +102,13 @@ WSWindowFrame::WSWindowFrame(WSWindow& window)
m_buttons.append(move(button));
}
- m_buttons.append(make<WSButton>(*this, *s_minimize_button_bitmap, [this](auto&) {
- m_window.set_minimized(true);
- }));
+ if (window.is_minimizable()) {
+ auto button = make<WSButton>(*this, *s_minimize_button_bitmap, [this](auto&) {
+ m_window.set_minimized(true);
+ });
+ m_minimize_button = button.ptr();
+ m_buttons.append(move(button));
+ }
}
WSWindowFrame::~WSWindowFrame()
diff --git a/Servers/WindowServer/WSWindowFrame.h b/Servers/WindowServer/WSWindowFrame.h
index 726ebc5764..e99d5349ea 100644
--- a/Servers/WindowServer/WSWindowFrame.h
+++ b/Servers/WindowServer/WSWindowFrame.h
@@ -30,4 +30,5 @@ private:
WSWindow& m_window;
NonnullOwnPtrVector<WSButton> m_buttons;
WSButton* m_maximize_button { nullptr };
+ WSButton* m_minimize_button { nullptr };
};
diff --git a/Servers/WindowServer/WindowServer.ipc b/Servers/WindowServer/WindowServer.ipc
index ae0e5972ef..da99f4067c 100644
--- a/Servers/WindowServer/WindowServer.ipc
+++ b/Servers/WindowServer/WindowServer.ipc
@@ -20,6 +20,7 @@ endpoint WindowServer = 2
Rect rect,
bool has_alpha_channel,
bool modal,
+ bool minimizable,
bool resizable,
bool fullscreen,
bool show_titlebar,