diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-06-02 15:35:00 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-06-02 15:35:00 +0200 |
commit | 3fa0b6cd9239d5cf5804be963ef177129d28e72e (patch) | |
tree | c33279dad4aed4f890abe76b48a3deb0400d3f4d | |
parent | ae4ac524adcb751242823414f702d0c9976c88cc (diff) | |
download | serenity-3fa0b6cd9239d5cf5804be963ef177129d28e72e.zip |
WindowServer: Always update the maximize button icon when we should.
We were only updating it in the WSButton callback, not when changing the
maximized state by calling WSWindow::set_maximized().
Fixes #119.
-rw-r--r-- | Servers/WindowServer/WSWindow.cpp | 1 | ||||
-rw-r--r-- | Servers/WindowServer/WSWindowFrame.cpp | 13 | ||||
-rw-r--r-- | Servers/WindowServer/WSWindowFrame.h | 4 | ||||
-rw-r--r-- | Servers/WindowServer/WSWindowManager.cpp | 6 |
4 files changed, 16 insertions, 8 deletions
diff --git a/Servers/WindowServer/WSWindow.cpp b/Servers/WindowServer/WSWindow.cpp index a6a85ff79b..927929bc45 100644 --- a/Servers/WindowServer/WSWindow.cpp +++ b/Servers/WindowServer/WSWindow.cpp @@ -151,6 +151,7 @@ void WSWindow::set_maximized(bool maximized) } else { set_rect(m_unmaximized_rect); } + m_frame.did_set_maximized({}, maximized); WSEventLoop::the().post_event(*this, make<WSResizeEvent>(old_rect, m_rect)); } diff --git a/Servers/WindowServer/WSWindowFrame.cpp b/Servers/WindowServer/WSWindowFrame.cpp index d73112bc5d..bc44c9b448 100644 --- a/Servers/WindowServer/WSWindowFrame.cpp +++ b/Servers/WindowServer/WSWindowFrame.cpp @@ -96,10 +96,11 @@ WSWindowFrame::WSWindowFrame(WSWindow& window) })); if (window.is_resizable()) { - m_buttons.append(make<WSButton>(*this, *s_maximize_button_bitmap, [this] (auto& button) { + auto button = make<WSButton>(*this, *s_maximize_button_bitmap, [this] (auto&) { m_window.set_maximized(!m_window.is_maximized()); - button.set_bitmap(m_window.is_maximized() ? *s_unmaximize_button_bitmap : *s_maximize_button_bitmap); - })); + }); + m_maximize_button = button.ptr(); + m_buttons.append(move(button)); } m_buttons.append(make<WSButton>(*this, *s_minimize_button_bitmap, [this] (auto&) { @@ -111,6 +112,12 @@ WSWindowFrame::~WSWindowFrame() { } +void WSWindowFrame::did_set_maximized(Badge<WSWindow>, bool maximized) +{ + ASSERT(m_maximize_button); + m_maximize_button->set_bitmap(maximized ? *s_unmaximize_button_bitmap : *s_maximize_button_bitmap); +} + Rect WSWindowFrame::title_bar_rect() const { return { 3, 3, m_window.width(), window_titlebar_height }; diff --git a/Servers/WindowServer/WSWindowFrame.h b/Servers/WindowServer/WSWindowFrame.h index c004446870..dde43deae9 100644 --- a/Servers/WindowServer/WSWindowFrame.h +++ b/Servers/WindowServer/WSWindowFrame.h @@ -1,5 +1,6 @@ #pragma once +#include <AK/Badge.h> #include <AK/OwnPtr.h> #include <AK/Vector.h> @@ -24,7 +25,10 @@ public: Rect title_bar_icon_rect() const; Rect title_bar_text_rect() const; + void did_set_maximized(Badge<WSWindow>, bool); + private: WSWindow& m_window; Vector<OwnPtr<WSButton>> m_buttons; + WSButton* m_maximize_button { nullptr }; }; diff --git a/Servers/WindowServer/WSWindowManager.cpp b/Servers/WindowServer/WSWindowManager.cpp index 1c8f594f13..fd30376df0 100644 --- a/Servers/WindowServer/WSWindowManager.cpp +++ b/Servers/WindowServer/WSWindowManager.cpp @@ -501,11 +501,7 @@ bool WSWindowManager::process_ongoing_window_drag(WSMouseEvent& event, WSWindow* #if defined(DOUBLECLICK_DEBUG) dbgprintf("[WM] Click up became doubleclick!\n"); #endif - if (m_drag_window->is_maximized()) { - m_drag_window->set_maximized(false); - } else { - m_drag_window->set_maximized(true); - } + m_drag_window->set_maximized(!m_drag_window->is_maximized()); } } m_drag_window = nullptr; |