forked from quickshell/quickshell
core/window: ensure items are polished before setting window visible
Hacks around a bug in layouts that commonly results in popups being wrongly sized for at least a frame.
This commit is contained in:
parent
db23c0264a
commit
497c9c4e50
3 changed files with 15 additions and 1 deletions
|
@ -37,7 +37,7 @@ qt_add_library(quickshell-core STATIC
|
||||||
set_source_files_properties(main.cpp PROPERTIES COMPILE_DEFINITIONS GIT_REVISION="${GIT_REVISION}")
|
set_source_files_properties(main.cpp PROPERTIES COMPILE_DEFINITIONS GIT_REVISION="${GIT_REVISION}")
|
||||||
qt_add_qml_module(quickshell-core URI Quickshell VERSION 0.1)
|
qt_add_qml_module(quickshell-core URI Quickshell VERSION 0.1)
|
||||||
|
|
||||||
target_link_libraries(quickshell-core PRIVATE ${QT_DEPS})
|
target_link_libraries(quickshell-core PRIVATE ${QT_DEPS} Qt6::QuickPrivate)
|
||||||
qs_pch(quickshell-core)
|
qs_pch(quickshell-core)
|
||||||
|
|
||||||
target_link_libraries(quickshell PRIVATE quickshell-coreplugin)
|
target_link_libraries(quickshell PRIVATE quickshell-coreplugin)
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <qtmetamacros.h>
|
#include <qtmetamacros.h>
|
||||||
#include <qtypes.h>
|
#include <qtypes.h>
|
||||||
#include <qwindow.h>
|
#include <qwindow.h>
|
||||||
|
#include <private/qquickwindow_p.h>
|
||||||
|
|
||||||
#include "generation.hpp"
|
#include "generation.hpp"
|
||||||
#include "qmlglobal.hpp"
|
#include "qmlglobal.hpp"
|
||||||
|
@ -182,6 +183,7 @@ void ProxyWindowBase::setVisibleDirect(bool visible) {
|
||||||
|
|
||||||
if (visible) {
|
if (visible) {
|
||||||
this->createWindow();
|
this->createWindow();
|
||||||
|
this->polishItems();
|
||||||
this->window->setVisible(true);
|
this->window->setVisible(true);
|
||||||
emit this->backerVisibilityChanged();
|
emit this->backerVisibilityChanged();
|
||||||
} else {
|
} else {
|
||||||
|
@ -192,11 +194,22 @@ void ProxyWindowBase::setVisibleDirect(bool visible) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (this->window != nullptr) {
|
} else if (this->window != nullptr) {
|
||||||
|
if (visible) this->polishItems();
|
||||||
this->window->setVisible(visible);
|
this->window->setVisible(visible);
|
||||||
emit this->backerVisibilityChanged();
|
emit this->backerVisibilityChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProxyWindowBase::polishItems() {
|
||||||
|
// Due to QTBUG-126704, layouts in invisible windows don't update their dimensions.
|
||||||
|
// Usually this isn't an issue, but it is when the size of a window is based on the size
|
||||||
|
// of its content, and that content is in a layout.
|
||||||
|
//
|
||||||
|
// This hack manually polishes the item tree right before showing the window so it will
|
||||||
|
// always be created with the correct size.
|
||||||
|
QQuickWindowPrivate::get(this->window)->polishItems();
|
||||||
|
}
|
||||||
|
|
||||||
qint32 ProxyWindowBase::x() const {
|
qint32 ProxyWindowBase::x() const {
|
||||||
if (this->window == nullptr) return 0;
|
if (this->window == nullptr) return 0;
|
||||||
else return this->window->x();
|
else return this->window->x();
|
||||||
|
|
|
@ -133,5 +133,6 @@ protected:
|
||||||
bool reloadComplete = false;
|
bool reloadComplete = false;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void polishItems();
|
||||||
void updateMask();
|
void updateMask();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue