Open MEOW window on the screen it was closed last time if possible

This commit is contained in:
heckflosse
2017-07-12 22:29:48 +02:00
parent 56eaeca01c
commit 35fbd7f830
3 changed files with 23 additions and 6 deletions

View File

@@ -28,7 +28,7 @@
// Check if the system has more than one display and option is set // Check if the system has more than one display and option is set
bool EditWindow::isMultiDisplayEnabled() bool EditWindow::isMultiDisplayEnabled()
{ {
return options.multiDisplayMode > 0 && Gdk::Screen::get_default()->get_n_monitors () > 1; return options.multiDisplayMode > 0 && Gdk::Screen::get_default()->get_n_monitors() > 1;
} }
// Should only be created once, auto-creates window on correct display // Should only be created once, auto-creates window on correct display
@@ -40,12 +40,17 @@ EditWindow* EditWindow::getInstance(RTWindow* p)
explicit EditWindowInstance(RTWindow* p) : editWnd(p) explicit EditWindowInstance(RTWindow* p) : editWnd(p)
{ {
// Determine the other display and maximize the window on that int meowMonitor = 0;
if(isMultiDisplayEnabled()) {
if(options.meowMonitor >= 0) { // use display from last session if available
meowMonitor = std::min(options.meowMonitor, Gdk::Screen::get_default()->get_n_monitors());
} else { // Determine the other display
const Glib::RefPtr< Gdk::Window >& wnd = p->get_window(); const Glib::RefPtr< Gdk::Window >& wnd = p->get_window();
int monNo = p->get_screen()->get_monitor_at_window (wnd); meowMonitor = p->get_screen()->get_monitor_at_window(wnd) == 0 ? 1 : 0;
}
}
Gdk::Rectangle lMonitorRect; Gdk::Rectangle lMonitorRect;
editWnd.get_screen()->get_monitor_geometry(isMultiDisplayEnabled() ? (monNo == 0 ? 1 : 0) : monNo, lMonitorRect); editWnd.get_screen()->get_monitor_geometry(meowMonitor, lMonitorRect);
editWnd.move(lMonitorRect.get_x(), lMonitorRect.get_y()); editWnd.move(lMonitorRect.get_x(), lMonitorRect.get_y());
editWnd.maximize(); editWnd.maximize();
} }
@@ -245,7 +250,12 @@ bool EditWindow::on_delete_event(GdkEventAny* event)
filesEdited.clear(); filesEdited.clear();
parent->fpanel->refreshEditedState (filesEdited); parent->fpanel->refreshEditedState (filesEdited);
if(isMultiDisplayEnabled()) {
options.meowMonitor = get_screen()->get_monitor_at_window (get_window());
}
hide (); hide ();
return false; return false;
} }

View File

@@ -295,6 +295,7 @@ void Options::setDefaults ()
windowX = 0; windowX = 0;
windowY = 0; windowY = 0;
windowMaximized = true; windowMaximized = true;
meowMonitor = -1;
saveAsDialogWidth = 920; saveAsDialogWidth = 920;
saveAsDialogHeight = 680; saveAsDialogHeight = 680;
savesParamsAtExit = true; savesParamsAtExit = true;
@@ -1258,6 +1259,10 @@ int Options::readFromFile (Glib::ustring fname)
windowY = keyFile.get_integer ("GUI", "WindowY"); windowY = keyFile.get_integer ("GUI", "WindowY");
} }
if (keyFile.has_key ("GUI", "MeowMonitor")) {
windowMaximized = keyFile.get_integer ("GUI", "MeowMonitor");
}
if (keyFile.has_key ("GUI", "WindowMaximized")) { if (keyFile.has_key ("GUI", "WindowMaximized")) {
windowMaximized = keyFile.get_boolean ("GUI", "WindowMaximized"); windowMaximized = keyFile.get_boolean ("GUI", "WindowMaximized");
} }
@@ -2009,6 +2014,7 @@ int Options::saveToFile (Glib::ustring fname)
keyFile.set_integer ("GUI", "WindowHeight", windowHeight); keyFile.set_integer ("GUI", "WindowHeight", windowHeight);
keyFile.set_integer ("GUI", "WindowX", windowX); keyFile.set_integer ("GUI", "WindowX", windowX);
keyFile.set_integer ("GUI", "WindowY", windowY); keyFile.set_integer ("GUI", "WindowY", windowY);
keyFile.set_integer ("GUI", "MeowMonitor", meowMonitor);
keyFile.set_boolean ("GUI", "WindowMaximized", windowMaximized); keyFile.set_boolean ("GUI", "WindowMaximized", windowMaximized);
keyFile.set_integer ("GUI", "DetailWindowWidth", detailWindowWidth); keyFile.set_integer ("GUI", "DetailWindowWidth", detailWindowWidth);
keyFile.set_integer ("GUI", "DetailWindowHeight", detailWindowHeight); keyFile.set_integer ("GUI", "DetailWindowHeight", detailWindowHeight);

View File

@@ -134,6 +134,7 @@ public:
int historyPanelWidth; int historyPanelWidth;
int windowWidth; int windowWidth;
int windowHeight; int windowHeight;
int meowMonitor;
int windowX; int windowX;
int windowY; int windowY;
bool windowMaximized; bool windowMaximized;