diff --git a/src/Viewer/GraphicsWindowQt5.cpp b/src/Viewer/GraphicsWindowQt5.cpp index eaadf30b7..ea1f650ce 100644 --- a/src/Viewer/GraphicsWindowQt5.cpp +++ b/src/Viewer/GraphicsWindowQt5.cpp @@ -409,7 +409,15 @@ bool GraphicsWindowQt5::init( Qt::WindowFlags f ) if ( _ownsWidget ) { _window->setTitle( _traits->windowName.c_str() ); - _window->setPosition( _traits->x, _traits->y ); + + // to get OS-dependant default positioning of the window (which is desirable), + // we must take care to only set the position if explicitly requested. + // hence we set X & Y to these marker values by default. + // And hence only set position if both are valid. + if ((_traits->x != std::numeric_limits::max()) && (_traits->y != std::numeric_limits::max())) { + _window->setPosition( _traits->x, _traits->y ); + } + QSize sz(_traits->width, _traits->height); if ( !_traits->supportsResize ) { _window->setMinimumSize( sz ); @@ -419,6 +427,8 @@ bool GraphicsWindowQt5::init( Qt::WindowFlags f ) } if (windowData->createFullscreen) { + // this doesn't seem to actually work, so we + // check the flag again in realizeImplementation() _window->setWindowState(Qt::WindowFullScreen); } } diff --git a/src/Viewer/WindowBuilder.cxx b/src/Viewer/WindowBuilder.cxx index 42ac30ac3..f4d3c3365 100644 --- a/src/Viewer/WindowBuilder.cxx +++ b/src/Viewer/WindowBuilder.cxx @@ -24,6 +24,7 @@ #include
#include +#include #if defined(SG_MAC) #include @@ -112,8 +113,10 @@ void WindowBuilder::makeDefaultTraits(bool stencil) traits->supportsResize = true; traits->width = fgGetInt("/sim/startup/xsize"); traits->height = fgGetInt("/sim/startup/ysize"); - traits->x = 50; - traits->y = 50; + + // these are marker values to tell GraphicsWindowQt5 to use default x/y + traits->x = std::numeric_limits::max(); + traits->y = std::numeric_limits::max(); #else SG_LOG(SG_VIEW,SG_ALERT,"requested Qt GraphicsWindow in non-Qt build"); #endif