# HG changeset patch # User Torsten # Date 1403031065 -7200 # Node ID 41980d0a5fd2f0edf83f1bd3737fc9030434630a # Parent b43157d085baebc22cdad2938e775fefb419010e center the community news window on the screen not on the desktop (bug #42567) * main-window.cc (display_community_news): calculate the position of the news window with respect to the screen of the main window, not with respect to the desktop, which may consist of several screens diff -r b43157d085ba -r 41980d0a5fd2 libgui/src/main-window.cc --- a/libgui/src/main-window.cc Mon Jun 16 20:41:19 2014 +0200 +++ b/libgui/src/main-window.cc Tue Jun 17 20:51:05 2014 +0200 @@ -556,9 +556,16 @@ community_news_window->setLayout (vlayout); community_news_window->setWindowTitle (tr ("Octave Community News")); - community_news_window->resize (640, 480); - int win_x = QApplication::desktop ()->width (); - int win_y = QApplication::desktop ()->height (); + + // center the window on the screen where octave is running + QDesktopWidget *m_desktop = QApplication::desktop (); + int screen = m_desktop->screenNumber (this); // screen of the main window + QRect screen_geo = m_desktop->availableGeometry (screen); + int win_x = screen_geo.width (); // width of the screen + int win_y = screen_geo.height (); // height of the screen + int news_x = std::min (640, win_x-80); // desired width of news window + int news_y = std::min (480, win_y-80); // desired height of news window + community_news_window->resize (news_x, news_y); // set size and center community_news_window->move ((win_x - community_news_window->width ())/2, (win_y - community_news_window->height ())/2); }