Hello, Two fixes to KMainWindow::parseGeometry().
The method takes a parameter, parsewidth, which if set makes it *only* update the size of the window. Otherwise it only updates the position. That makes no sense, an X geometry can be both position and size. This patch changes what the flag does so that if set it will only update size, otherwise it will update both position and size. This to (hopefully) keep KMainWindow::restoreWindowSize() happy. For position updates the code uses geometry().x()/y() for positive coordinates. But geometry() is not the parsed geometry string, and will be 0,0 for a new window. This causes a fun effect where only negative coordinates work. Posting here to get some feedback. If it looks ok (or you are all too busy with the 4.7 release) I'll attach it to what seems to be the main bug for this: http://bugs.kde.org/show_bug.cgi?id=165355
diff --git a/kdeui/widgets/kmainwindow.cpp b/kdeui/widgets/kmainwindow.cpp index 1d27722..7f4ce06 100644 --- a/kdeui/widgets/kmainwindow.cpp +++ b/kdeui/widgets/kmainwindow.cpp @@ -421,7 +421,7 @@ void KMainWindowPrivate::setSizeDirty() } } -void KMainWindow::parseGeometry(bool parsewidth) +void KMainWindow::parseGeometry(bool updatesizeonly) { K_D(KMainWindow); QString cmdlineGeometry; @@ -434,32 +434,36 @@ void KMainWindow::parseGeometry(bool parsewidth) Q_UNUSED(d); // fix compiler warning in release mode #if defined Q_WS_X11 - int x, y; + int nx, ny; int w, h; - int m = XParseGeometry( cmdlineGeometry.toLatin1(), &x, &y, (unsigned int*)&w, (unsigned int*)&h); - if (parsewidth) { - const QSize minSize = minimumSize(); - const QSize maxSize = maximumSize(); - if ( !(m & WidthValue) ) - w = width(); - if ( !(m & HeightValue) ) - h = height(); - w = qMin(w,maxSize.width()); - h = qMin(h,maxSize.height()); - w = qMax(w,minSize.width()); - h = qMax(h,minSize.height()); - resize(w, h); - } else { + int m = XParseGeometry( cmdlineGeometry.toLatin1(), &nx, &ny, (unsigned int *)&w, (unsigned int *)&h ); + + const QSize minSize = minimumSize(); + const QSize maxSize = maximumSize(); + if ( !(m & WidthValue) ) + w = width(); + if ( !(m & HeightValue) ) + h = height(); + w = qMin(w, maxSize.width()); + h = qMin(h, maxSize.height()); + w = qMax(w, minSize.width()); + h = qMax(h, minSize.height()); + resize(w, h); + + if ( !updatesizeonly ) { + if ( !(m & XValue) ) + nx = x(); + if ( !(m & YValue) ) + ny = y(); + + // w/h here will not include decorations for a newly created window. + // That will cause negative positions to be slightly off. if ( (m & XNegative) ) - x = KApplication::desktop()->width() + x - w; - else if ( (m & XValue) ) - x = geometry().x(); + nx = KApplication::desktop()->width() + nx - w; if ( (m & YNegative) ) - y = KApplication::desktop()->height() + y - h; - else if ( (m & YValue) ) - y = geometry().y(); + ny = KApplication::desktop()->height() + ny - h; - move(x, y); + move(nx, ny); } #endif } diff --git a/kdeui/widgets/kmainwindow.h b/kdeui/widgets/kmainwindow.h index 442ab59..07d49c0 100644 --- a/kdeui/widgets/kmainwindow.h +++ b/kdeui/widgets/kmainwindow.h @@ -633,7 +633,7 @@ protected: void restoreWindowSize( const KConfigGroup & config ); /// parse the geometry from the geometry command line argument - void parseGeometry(bool parsewidth); + void parseGeometry(bool updatesizeonly); protected Q_SLOTS: /**