Question about KMainWindow::parseGeometry

John Ratke jratke at comcast.net
Tue Oct 28 03:54:56 GMT 2003


Does anyone know why KMainWindow will parse the "-geometry" command line 
argument ignoring widths when first constructed, but will take width 
into account when KMainWindow::restoreWindowSize is called?

Also, a part of the code in parseGeometry looks suspect.

    int x, y;
    int w, h;
    int m = XParseGeometry( kapp->geometryArgument().latin1(), &x, &y, 
(unsigned int*)&w, (unsigned int*)&h);
    if (parsewidth) {
        QSize minSize = minimumSize();
        QSize maxSize = maximumSize();
        if ( (m & WidthValue) == 0 )
            w = width();
        if ( (m & HeightValue) == 0 )
            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 {
        if ( parsewidth && (m & XValue) == 0 )
            x = geometry().x();
        if ( parsewidth && (m & YValue) == 0 )
            y = geometry().y();
        if ( (m & XNegative) )
            x = KApplication::desktop()->width()  + x - w;
        if ( (m & YNegative) )
            y = KApplication::desktop()->height() + y - h;
        move(x, y);
    }


In the else case, since == has higher precidence than &&, I take that 
first if statement to read:  if there is no X value and parsewidth is 
true, then set x = geometry().x();

But parsewidth will always be false there.


Thanks,

-John






More information about the kde-core-devel mailing list