Client: Fix regression; drawing decorations of active windows as inactive
We can't trust QWindow::isActive, because it relies on focusWindow, which may be updated too late, and there might also be multiple active toplevel windows at once on Wayland. Even though Qt doesn't support multiple seats, we should still draw the decorations of active windows correctly. This implements QPlatformWindow::isActive and uses it in the decorations. Change-Id: I34d79b354e2d26694533e2319a26f24085212243 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
This commit is contained in:
parent
326ab57d25
commit
f746be7c7f
@ -132,6 +132,7 @@ QMargins QWaylandBradientDecoration::margins() const
|
|||||||
|
|
||||||
void QWaylandBradientDecoration::paint(QPaintDevice *device)
|
void QWaylandBradientDecoration::paint(QPaintDevice *device)
|
||||||
{
|
{
|
||||||
|
bool active = window()->handle()->isActive();
|
||||||
QRect surfaceRect(QPoint(), window()->frameGeometry().size());
|
QRect surfaceRect(QPoint(), window()->frameGeometry().size());
|
||||||
QRect clips[] =
|
QRect clips[] =
|
||||||
{
|
{
|
||||||
@ -183,7 +184,7 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
|
|||||||
|
|
||||||
p.save();
|
p.save();
|
||||||
p.setClipRect(titleBar);
|
p.setClipRect(titleBar);
|
||||||
p.setPen(window()->isActive() ? m_foregroundColor : m_foregroundInactiveColor);
|
p.setPen(active ? m_foregroundColor : m_foregroundInactiveColor);
|
||||||
QSizeF size = m_windowTitle.size();
|
QSizeF size = m_windowTitle.size();
|
||||||
int dx = (top.width() - size.width()) /2;
|
int dx = (top.width() - size.width()) /2;
|
||||||
int dy = (top.height()- size.height()) /2;
|
int dy = (top.height()- size.height()) /2;
|
||||||
@ -199,7 +200,7 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
|
|||||||
QRectF rect;
|
QRectF rect;
|
||||||
|
|
||||||
// Default pen
|
// Default pen
|
||||||
QPen pen(window()->isActive() ? m_foregroundColor : m_foregroundInactiveColor);
|
QPen pen(active ? m_foregroundColor : m_foregroundInactiveColor);
|
||||||
p.setPen(pen);
|
p.setPen(pen);
|
||||||
|
|
||||||
// Close button
|
// Close button
|
||||||
|
@ -413,6 +413,11 @@ void QWaylandDisplay::setLastInputDevice(QWaylandInputDevice *device, uint32_t s
|
|||||||
mLastInputWindow = win;
|
mLastInputWindow = win;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QWaylandDisplay::isWindowActivated(const QWaylandWindow *window)
|
||||||
|
{
|
||||||
|
return mActiveWindows.contains(const_cast<QWaylandWindow *>(window));
|
||||||
|
}
|
||||||
|
|
||||||
void QWaylandDisplay::handleWindowActivated(QWaylandWindow *window)
|
void QWaylandDisplay::handleWindowActivated(QWaylandWindow *window)
|
||||||
{
|
{
|
||||||
if (mActiveWindows.contains(window))
|
if (mActiveWindows.contains(window))
|
||||||
|
@ -176,6 +176,7 @@ public:
|
|||||||
QWaylandWindow *lastInputWindow() const;
|
QWaylandWindow *lastInputWindow() const;
|
||||||
void setLastInputDevice(QWaylandInputDevice *device, uint32_t serial, QWaylandWindow *window);
|
void setLastInputDevice(QWaylandInputDevice *device, uint32_t serial, QWaylandWindow *window);
|
||||||
|
|
||||||
|
bool isWindowActivated(const QWaylandWindow *window);
|
||||||
void handleWindowActivated(QWaylandWindow *window);
|
void handleWindowActivated(QWaylandWindow *window);
|
||||||
void handleWindowDeactivated(QWaylandWindow *window);
|
void handleWindowDeactivated(QWaylandWindow *window);
|
||||||
void handleKeyboardFocusChanged(QWaylandInputDevice *inputDevice);
|
void handleKeyboardFocusChanged(QWaylandInputDevice *inputDevice);
|
||||||
|
@ -943,6 +943,11 @@ bool QWaylandWindow::isExposed() const
|
|||||||
return QPlatformWindow::isExposed();
|
return QPlatformWindow::isExposed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QWaylandWindow::isActive() const
|
||||||
|
{
|
||||||
|
return mDisplay->isWindowActivated(this);
|
||||||
|
}
|
||||||
|
|
||||||
int QWaylandWindow::scale() const
|
int QWaylandWindow::scale() const
|
||||||
{
|
{
|
||||||
return mScale;
|
return mScale;
|
||||||
|
@ -146,6 +146,7 @@ public:
|
|||||||
|
|
||||||
void requestActivateWindow() override;
|
void requestActivateWindow() override;
|
||||||
bool isExposed() const override;
|
bool isExposed() const override;
|
||||||
|
bool isActive() const override;
|
||||||
void unfocus();
|
void unfocus();
|
||||||
|
|
||||||
QWaylandAbstractDecoration *decoration() const;
|
QWaylandAbstractDecoration *decoration() const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user