diff -Naur trunk.orig/src/station_gui.cpp trunk/src/station_gui.cpp --- trunk.orig/src/station_gui.cpp 2011-06-27 14:08:18.945995994 -0400 +++ trunk/src/station_gui.cpp 2011-06-28 15:12:16.665996010 -0400 @@ -1467,7 +1467,7 @@ }; static const WindowDesc _select_station_desc( - WDP_AUTO, 200, 180, + WDP_CURSOR, 200, 180, WC_SELECT_STATION, WC_NONE, WDF_CONSTRUCTION, _nested_select_station_widgets, lengthof(_nested_select_station_widgets) diff -Naur trunk.orig/src/window.cpp trunk/src/window.cpp --- trunk.orig/src/window.cpp 2011-06-27 14:08:18.955996007 -0400 +++ trunk/src/window.cpp 2011-06-28 15:18:24.035996003 -0400 @@ -1254,6 +1254,22 @@ pt.y = 0; break; + case WDP_CURSOR: + if ( _cursor.pos.x < default_width / 2 ) + pt.x = 0; + else if (_cursor.pos.x + default_width / 2 > _screen.width ) + pt.x = _screen.width - default_width; + else + pt.x = _cursor.pos.x - default_width / 2; + + if ( _cursor.pos.y < default_width / 2 ) + pt.y = 0; + else if (_cursor.pos.y + default_width / 2 > _screen.height ) + pt.y = _screen.height - default_height; + else + pt.y = _cursor.pos.y - default_width / 2; + break; + default: NOT_REACHED(); } diff -Naur trunk.orig/src/window_gui.h trunk/src/window_gui.h --- trunk.orig/src/window_gui.h 2011-06-27 14:08:18.915996004 -0400 +++ trunk/src/window_gui.h 2011-06-28 15:09:56.375996006 -0400 @@ -148,6 +148,7 @@ WDP_AUTO, ///< Find a place automatically WDP_CENTER, ///< Center the window WDP_ALIGN_TOOLBAR, ///< Align toward the toolbar + WDP_CURSOR, ///< Position the window centered under the mouse and avoid getting out of the screen }; Point GetToolbarAlignedWindowPosition(int window_width);