Re-add default positioning for Widgets.
Center widgets on the screen in show_sys() in case they are top levels that have not been moved yet. This was previously done in platform-specific code on Window creation. Change-Id: I191f20c0105ed3f27274c6505852b212d400b395 Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>bb10
parent
89b192a082
commit
d43a01e149
|
|
@ -424,6 +424,19 @@ void QWidget::activateWindow()
|
|||
windowHandle()->requestActivateWindow();
|
||||
}
|
||||
|
||||
// Position top level windows at the center, avoid showing
|
||||
// Windows at the default 0,0 position excluding the frame.
|
||||
static inline QRect positionTopLevelWindow(QRect geometry, const QScreen *screen)
|
||||
{
|
||||
if (screen && geometry.x() == 0 && geometry.y() == 0) {
|
||||
const QRect availableGeometry = screen->availableGeometry();
|
||||
if (availableGeometry.width() > geometry.width()
|
||||
&& availableGeometry.height() > geometry.height())
|
||||
geometry.moveCenter(availableGeometry.center());
|
||||
}
|
||||
return geometry;
|
||||
}
|
||||
|
||||
void QWidgetPrivate::show_sys()
|
||||
{
|
||||
Q_Q(QWidget);
|
||||
|
|
@ -441,7 +454,10 @@ void QWidgetPrivate::show_sys()
|
|||
QWindow *window = q->windowHandle();
|
||||
if (window) {
|
||||
QRect geomRect = q->geometry();
|
||||
if (!q->isWindow()) {
|
||||
if (q->isWindow()) {
|
||||
if (!q->testAttribute(Qt::WA_Moved))
|
||||
geomRect = positionTopLevelWindow(geomRect, window->screen());
|
||||
} else {
|
||||
QPoint topLeftOfWindow = q->mapTo(q->nativeParentWidget(),QPoint());
|
||||
geomRect.moveTopLeft(topLeftOfWindow);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue