Windows QPA: Implement QPlatformWindow::initialize()
Move the code that sends geometry change events from
QWindowsIntegration::createPlatformWindow() to
QWindowsWindow::initialize(), using the obtained geometry
from the creation context. Drop the check for window flags
since they are not changed.
Complements change 4c855a9f9f
Task-number: QTBUG-61977
Change-Id: I0c23abefc45110cc4bf11e10d65dc7ddbb9d20d5
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
214fc32981
commit
deb7f9a7c3
@ -405,9 +405,11 @@ QList<int> QWindowsContext::possibleKeys(const QKeyEvent *e) const
|
||||
return d->m_keyMapper.possibleKeys(e);
|
||||
}
|
||||
|
||||
void QWindowsContext::setWindowCreationContext(const QSharedPointer<QWindowCreationContext> &ctx)
|
||||
QSharedPointer<QWindowCreationContext> QWindowsContext::setWindowCreationContext(const QSharedPointer<QWindowCreationContext> &ctx)
|
||||
{
|
||||
const QSharedPointer<QWindowCreationContext> old = d->m_creationContext;
|
||||
d->m_creationContext = ctx;
|
||||
return old;
|
||||
}
|
||||
|
||||
QSharedPointer<QWindowCreationContext> QWindowsContext::windowCreationContext() const
|
||||
|
@ -196,7 +196,7 @@ public:
|
||||
QWindow *keyGrabber() const;
|
||||
void setKeyGrabber(QWindow *hwnd);
|
||||
|
||||
void setWindowCreationContext(const QSharedPointer<QWindowCreationContext> &ctx);
|
||||
QSharedPointer<QWindowCreationContext> setWindowCreationContext(const QSharedPointer<QWindowCreationContext> &ctx);
|
||||
QSharedPointer<QWindowCreationContext> windowCreationContext() const;
|
||||
|
||||
void setTabletAbsoluteRange(int a);
|
||||
|
@ -344,21 +344,6 @@ QPlatformWindow *QWindowsIntegration::createPlatformWindow(QWindow *window) cons
|
||||
if (QWindowsMenuBar *menuBarToBeInstalled = QWindowsMenuBar::menuBarOf(window))
|
||||
menuBarToBeInstalled->install(result);
|
||||
|
||||
if (requested.flags != obtained.flags)
|
||||
window->setFlags(obtained.flags);
|
||||
// Trigger geometry change (unless it has a special state in which case setWindowState()
|
||||
// will send the message) and screen change signals of QWindow.
|
||||
if ((obtained.flags & Qt::Desktop) != Qt::Desktop) {
|
||||
const Qt::WindowState state = window->windowState();
|
||||
if (state != Qt::WindowMaximized && state != Qt::WindowFullScreen
|
||||
&& requested.geometry != obtained.geometry) {
|
||||
QWindowSystemInterface::handleGeometryChange(window, obtained.geometry);
|
||||
}
|
||||
QPlatformScreen *screen = result->screenForGeometry(obtained.geometry);
|
||||
if (screen && result->screen() != screen)
|
||||
QWindowSystemInterface::handleWindowScreenChanged(window, screen->screen());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -76,6 +76,8 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
typedef QSharedPointer<QWindowCreationContext> QWindowCreationContextPtr;
|
||||
|
||||
enum {
|
||||
defaultWindowWidth = 160,
|
||||
defaultWindowHeight = 160
|
||||
@ -621,8 +623,6 @@ void WindowCreationData::fromWindow(const QWindow *w, const Qt::WindowFlags flag
|
||||
QWindowsWindowData
|
||||
WindowCreationData::create(const QWindow *w, const WindowData &data, QString title) const
|
||||
{
|
||||
typedef QSharedPointer<QWindowCreationContext> QWindowCreationContextPtr;
|
||||
|
||||
WindowData result;
|
||||
result.flags = flags;
|
||||
|
||||
@ -1070,8 +1070,6 @@ QWindowsWindow::QWindowsWindow(QWindow *aWindow, const QWindowsWindowData &data)
|
||||
, m_vkSurface(0)
|
||||
#endif
|
||||
{
|
||||
// Clear the creation context as the window can be found in QWindowsContext's map.
|
||||
QWindowsContext::instance()->setWindowCreationContext(QSharedPointer<QWindowCreationContext>());
|
||||
QWindowsContext::instance()->addWindow(m_data.hwnd, this);
|
||||
const Qt::WindowType type = aWindow->type();
|
||||
if (type == Qt::Desktop)
|
||||
@ -1112,6 +1110,27 @@ QWindowsWindow::~QWindowsWindow()
|
||||
destroyIcon();
|
||||
}
|
||||
|
||||
void QWindowsWindow::initialize()
|
||||
{
|
||||
// Clear the creation context as the window can be found in QWindowsContext's map.
|
||||
QWindowCreationContextPtr creationContext =
|
||||
QWindowsContext::instance()->setWindowCreationContext(QWindowCreationContextPtr());
|
||||
|
||||
// Trigger geometry change (unless it has a special state in which case setWindowState()
|
||||
// will send the message) and screen change signals of QWindow.
|
||||
QWindow *w = window();
|
||||
if (w->type() != Qt::Desktop) {
|
||||
const Qt::WindowState state = w->windowState();
|
||||
if (state != Qt::WindowMaximized && state != Qt::WindowFullScreen
|
||||
&& creationContext->requestedGeometry != creationContext->obtainedGeometry) {
|
||||
QWindowSystemInterface::handleGeometryChange(w, creationContext->obtainedGeometry);
|
||||
}
|
||||
QPlatformScreen *obtainedScreen = screenForGeometry(creationContext->obtainedGeometry);
|
||||
if (obtainedScreen && screen() != obtainedScreen)
|
||||
QWindowSystemInterface::handleWindowScreenChanged(w, obtainedScreen->screen());
|
||||
}
|
||||
}
|
||||
|
||||
void QWindowsWindow::fireExpose(const QRegion ®ion, bool force)
|
||||
{
|
||||
if (region.isEmpty() && !force)
|
||||
|
@ -221,6 +221,8 @@ public:
|
||||
QWindowsWindow(QWindow *window, const QWindowsWindowData &data);
|
||||
~QWindowsWindow();
|
||||
|
||||
void initialize() override;
|
||||
|
||||
using QPlatformWindow::screenForGeometry;
|
||||
|
||||
QSurfaceFormat format() const override { return m_format; }
|
||||
|
Loading…
Reference in New Issue
Block a user