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.
This commit is contained in:
Andreas Kling 2019-06-02 15:35:00 +02:00
parent ae4ac524ad
commit 3fa0b6cd92
Notes: sideshowbarker 2024-07-19 13:46:07 +09:00
4 changed files with 16 additions and 8 deletions

View file

@ -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));
}

View file

@ -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 };

View file

@ -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 };
};

View file

@ -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;