mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:57:36 +00:00
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:
parent
ae4ac524ad
commit
3fa0b6cd92
4 changed files with 16 additions and 8 deletions
|
@ -151,6 +151,7 @@ void WSWindow::set_maximized(bool maximized)
|
||||||
} else {
|
} else {
|
||||||
set_rect(m_unmaximized_rect);
|
set_rect(m_unmaximized_rect);
|
||||||
}
|
}
|
||||||
|
m_frame.did_set_maximized({}, maximized);
|
||||||
WSEventLoop::the().post_event(*this, make<WSResizeEvent>(old_rect, m_rect));
|
WSEventLoop::the().post_event(*this, make<WSResizeEvent>(old_rect, m_rect));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,10 +96,11 @@ WSWindowFrame::WSWindowFrame(WSWindow& window)
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if (window.is_resizable()) {
|
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());
|
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&) {
|
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
|
Rect WSWindowFrame::title_bar_rect() const
|
||||||
{
|
{
|
||||||
return { 3, 3, m_window.width(), window_titlebar_height };
|
return { 3, 3, m_window.width(), window_titlebar_height };
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <AK/Badge.h>
|
||||||
#include <AK/OwnPtr.h>
|
#include <AK/OwnPtr.h>
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
|
|
||||||
|
@ -24,7 +25,10 @@ public:
|
||||||
Rect title_bar_icon_rect() const;
|
Rect title_bar_icon_rect() const;
|
||||||
Rect title_bar_text_rect() const;
|
Rect title_bar_text_rect() const;
|
||||||
|
|
||||||
|
void did_set_maximized(Badge<WSWindow>, bool);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WSWindow& m_window;
|
WSWindow& m_window;
|
||||||
Vector<OwnPtr<WSButton>> m_buttons;
|
Vector<OwnPtr<WSButton>> m_buttons;
|
||||||
|
WSButton* m_maximize_button { nullptr };
|
||||||
};
|
};
|
||||||
|
|
|
@ -501,11 +501,7 @@ bool WSWindowManager::process_ongoing_window_drag(WSMouseEvent& event, WSWindow*
|
||||||
#if defined(DOUBLECLICK_DEBUG)
|
#if defined(DOUBLECLICK_DEBUG)
|
||||||
dbgprintf("[WM] Click up became doubleclick!\n");
|
dbgprintf("[WM] Click up became doubleclick!\n");
|
||||||
#endif
|
#endif
|
||||||
if (m_drag_window->is_maximized()) {
|
m_drag_window->set_maximized(!m_drag_window->is_maximized());
|
||||||
m_drag_window->set_maximized(false);
|
|
||||||
} else {
|
|
||||||
m_drag_window->set_maximized(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_drag_window = nullptr;
|
m_drag_window = nullptr;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue