diff --git a/rtgui/editwindow.cc b/rtgui/editwindow.cc index d4e3191d2..dfad07740 100644 --- a/rtgui/editwindow.cc +++ b/rtgui/editwindow.cc @@ -44,36 +44,6 @@ EditWindow* EditWindow::getInstance(RTWindow* p) }; static EditWindowInstance instance_(p); - if(!instance_.editWnd.is_maximized()) { - 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(); - meowMonitor = p->get_screen()->get_monitor_at_window(wnd) == 0 ? 1 : 0; - } - } - Gdk::Rectangle lMonitorRect; - instance_.editWnd.get_screen()->get_monitor_geometry(meowMonitor, lMonitorRect); - instance_.editWnd.move(lMonitorRect.get_x(), lMonitorRect.get_y()); - - if(!options.meowFullScreen) { - instance_.editWnd.maximize(); - instance_.editWnd.setFullScreen(false); - } else { - instance_.editWnd.fullscreen(); - instance_.editWnd.setFullScreen(true); - } - - instance_.editWnd.show_all (); - } - - if(Gdk::Screen::get_default()->get_n_monitors() == 1) { - // when using MEOW mode on a single monitor we need to present the secondary window. - // If we don't it will stay in background when opening 2nd, 3rd... editor, which is annoying - instance_.editWnd.present(); - } return &instance_.editWnd; } @@ -93,6 +63,8 @@ EditWindow::EditWindow (RTWindow* p) : parent(p) , isFullscreen(false) set_title_decorated(""); set_modal(false); set_resizable(true); + set_default_size(options.meowWidth, options.meowHeight); + //set_parent(*parent); property_destroy_with_parent().set_value(false); //signal_window_state_event().connect( sigc::mem_fun(*this, &EditWindow::on_window_state_event) ); @@ -107,6 +79,30 @@ EditWindow::EditWindow (RTWindow* p) : parent(p) , isFullscreen(false) mainBox->pack_start (*mainNB); add (*mainBox); + + if(!is_maximized()) { + 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(); + meowMonitor = p->get_screen()->get_monitor_at_window(wnd) == 0 ? 1 : 0; + } + } + Gdk::Rectangle lMonitorRect; + get_screen()->get_monitor_geometry(meowMonitor, lMonitorRect); + move(lMonitorRect.get_x(), lMonitorRect.get_y()); + + maximize(); + show_all (); + if(!options.meowFullScreen) { + setFullScreen(false); + } else { + fullscreen(); + setFullScreen(true); + } + } } void EditWindow::on_realize () @@ -116,6 +112,15 @@ void EditWindow::on_realize () editWindowCursorManager.init (get_window()); } +bool EditWindow::on_configure_event(GdkEventConfigure* event) +{ + if (!is_maximized() && get_realized() && is_visible()) { + get_size(options.meowWidth, options.meowHeight); + } + + return Gtk::Widget::on_configure_event(event); +} + /* HOMBRE: Disabling this since it's maximized when opened anyway. * Someday, the EditorWindow migh save it own position and state, so it'll have to be uncommented bool EditWindow::on_window_state_event(GdkEventWindowState* event) @@ -210,6 +215,14 @@ bool EditWindow::selectEditorPanel(const std::string &name) return false; } +void EditWindow::toFront () +{ + // when using MEOW mode on a single monitor we need to present the secondary window. + // If we don't it will stay in background when opening 2nd, 3rd... editor, which is annoying + // It will also deiconify the window + present(); +} + bool EditWindow::keyPressed (GdkEventKey* event) { bool ctrl = event->state & GDK_CONTROL_MASK; @@ -237,22 +250,61 @@ bool EditWindow::keyPressed (GdkEventKey* event) void EditWindow::toggleFullscreen () { isFullscreen ? unfullscreen() : fullscreen(); - isFullscreen = !isFullscreen; + options.meowFullScreen = isFullscreen = !isFullscreen; } bool EditWindow::on_delete_event(GdkEventAny* event) { - // Check if any editor is still processing, and do NOT quit if so. Otherwise crashes and inconsistent caches - bool isProcessing = false; - for ( std::set ::iterator iter = filesEdited.begin(); iter != filesEdited.end() && !isProcessing; ++iter ) { + if (!closeOpenEditors()) { + return true; + } + + if(isMultiDisplayEnabled()) { + options.meowMonitor = get_screen()->get_monitor_at_window(get_window()); + } + + hide(); + unmaximize(); + + return false; +} + +bool EditWindow::isProcessing () +{ + for ( std::set ::iterator iter = filesEdited.begin(); iter != filesEdited.end(); ++iter ) { if (epanels[*iter]->getIsProcessing()) { - isProcessing = true; + return true; } } - if (isProcessing) { - return true; + return false; +} + +bool EditWindow::closeOpenEditors() +{ + // Check if any editor is still processing, and do NOT quit if so. Otherwise crashes and inconsistent caches + if (isProcessing()) { + return false; + } + + if (epanels.size()) { + int page = mainNB->get_current_page(); + Gtk::Widget *w = mainNB->get_nth_page(page); + bool optionsWritten = false; + + for (std::map::iterator i = epanels.begin(); i != epanels.end(); ++i) { + if (i->second == w) { + i->second->writeOptions(); + optionsWritten = true; + } + } + + if (!optionsWritten) { + // fallback solution: save the options of the first editor panel + std::map::iterator i = epanels.begin(); + i->second->writeOptions(); + } } for ( std::set ::iterator iter = filesEdited.begin(); iter != filesEdited.end(); ++iter ) { @@ -260,20 +312,10 @@ bool EditWindow::on_delete_event(GdkEventAny* event) } epanels.clear(); - filesEdited.clear(); parent->fpanel->refreshEditedState (filesEdited); - if(isMultiDisplayEnabled()) { - options.meowMonitor = get_screen()->get_monitor_at_window(get_window()); - } - - options.meowFullScreen = isFullscreen; - - hide(); - unmaximize(); - - return false; + return true; } void EditWindow::set_title_decorated(Glib::ustring fname) diff --git a/rtgui/editwindow.h b/rtgui/editwindow.h index c53636130..5f51bf672 100644 --- a/rtgui/editwindow.h +++ b/rtgui/editwindow.h @@ -47,8 +47,12 @@ public: void addEditorPanel (EditorPanel* ep, const std::string &name); void remEditorPanel (EditorPanel* ep); bool selectEditorPanel(const std::string &name); + bool closeOpenEditors(); + bool isProcessing(); + void toFront(); bool keyPressed (GdkEventKey* event); + bool on_configure_event(GdkEventConfigure* event); bool on_delete_event(GdkEventAny* event); //bool on_window_state_event(GdkEventWindowState* event); void on_mainNB_switch_page(Gtk::Widget* page, guint page_num); diff --git a/rtgui/history.cc b/rtgui/history.cc index 8e7adfab7..72c61b678 100644 --- a/rtgui/history.cc +++ b/rtgui/history.cc @@ -54,7 +54,6 @@ History::History (bool bookmarkSupport) : historyVPaned(nullptr), blistener(null hTreeView->set_hscroll_policy(Gtk::SCROLL_MINIMUM); hTreeView->set_vscroll_policy(Gtk::SCROLL_NATURAL); hTreeView->set_size_request(80, -1); - hTreeView->set_resize_mode(Gtk::RESIZE_QUEUE); Gtk::CellRendererText *changecrt = Gtk::manage (new Gtk::CellRendererText()); changecrt->property_ellipsize() = Pango::ELLIPSIZE_END; diff --git a/rtgui/options.cc b/rtgui/options.cc index 53f0492bd..2255f3573 100644 --- a/rtgui/options.cc +++ b/rtgui/options.cc @@ -297,6 +297,8 @@ void Options::setDefaults () windowMaximized = true; meowMonitor = -1; meowFullScreen = false; + meowWidth = 1200; + meowHeight = 680; saveAsDialogWidth = 920; saveAsDialogHeight = 680; savesParamsAtExit = true; @@ -1268,6 +1270,14 @@ int Options::readFromFile (Glib::ustring fname) meowFullScreen = keyFile.get_boolean ("GUI", "MeowFullScreen"); } + if (keyFile.has_key ("GUI", "MeowWidth")) { + meowWidth = keyFile.get_integer ("GUI", "MeowWidth"); + } + + if (keyFile.has_key ("GUI", "MeowHeight")) { + meowHeight = keyFile.get_integer ("GUI", "MeowHeight"); + } + if (keyFile.has_key ("GUI", "WindowMaximized")) { windowMaximized = keyFile.get_boolean ("GUI", "WindowMaximized"); } @@ -2021,6 +2031,8 @@ int Options::saveToFile (Glib::ustring fname) keyFile.set_integer ("GUI", "WindowY", windowY); keyFile.set_integer ("GUI", "MeowMonitor", meowMonitor); keyFile.set_boolean ("GUI", "MeowFullScreen", meowFullScreen); + keyFile.set_integer ("GUI", "MeowWidth", meowWidth); + keyFile.set_integer ("GUI", "MeowHeight", meowHeight); keyFile.set_boolean ("GUI", "WindowMaximized", windowMaximized); keyFile.set_integer ("GUI", "DetailWindowWidth", detailWindowWidth); keyFile.set_integer ("GUI", "DetailWindowHeight", detailWindowHeight); diff --git a/rtgui/options.h b/rtgui/options.h index 429bc7671..0d86e8dc6 100644 --- a/rtgui/options.h +++ b/rtgui/options.h @@ -132,13 +132,15 @@ public: bool browserDirPanelOpened; bool editorFilmStripOpened; int historyPanelWidth; - int windowWidth; - int windowHeight; - int meowMonitor; - bool meowFullScreen; int windowX; int windowY; + int windowWidth; + int windowHeight; bool windowMaximized; + int meowMonitor; + bool meowFullScreen; + int meowWidth; + int meowHeight; int detailWindowWidth; int detailWindowHeight; int dirBrowserWidth; diff --git a/rtgui/rtwindow.cc b/rtgui/rtwindow.cc index a94fafa36..13ee0271e 100644 --- a/rtgui/rtwindow.cc +++ b/rtgui/rtwindow.cc @@ -124,7 +124,6 @@ RTWindow::RTWindow () set_title_decorated(""); set_resizable(true); - set_resize_mode(Gtk::ResizeMode::RESIZE_QUEUE); set_decorated(true); set_default_size(options.windowWidth, options.windowHeight); set_modal(false); @@ -339,12 +338,21 @@ void RTWindow::on_realize () } } +bool RTWindow::on_configure_event(GdkEventConfigure* event) +{ + if (!is_maximized() && is_visible()) { + get_size(options.windowWidth, options.windowHeight); + get_position (options.windowX, options.windowY); + } + + return Gtk::Widget::on_configure_event(event); +} + bool RTWindow::on_window_state_event(GdkEventWindowState* event) { if (event->changed_mask & GDK_WINDOW_STATE_MAXIMIZED) { options.windowMaximized = event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED; } - return Gtk::Widget::on_window_state_event(event); } @@ -385,6 +393,7 @@ void RTWindow::addEditorPanel (EditorPanel* ep, const std::string &name) EditWindow * wndEdit = EditWindow::getInstance(this); wndEdit->show(); wndEdit->addEditorPanel(ep, name); + wndEdit->toFront(); } else { ep->setParent (this); ep->setParentWindow(this); @@ -462,6 +471,7 @@ bool RTWindow::selectEditorPanel(const std::string &name) if (wndEdit->selectEditorPanel(name)) { set_title_decorated(name); + wndEdit->toFront(); return true; } } else { @@ -585,9 +595,17 @@ bool RTWindow::on_delete_event(GdkEventAny* event) // Check if any editor is still processing, and do NOT quit if so. Otherwise crashes and inconsistent caches bool isProcessing = false; + EditWindow* editWindow = nullptr; + if (isSingleTabMode() || simpleEditor) { isProcessing = epanel->getIsProcessing(); + } else if (options.multiDisplayMode > 0) { + editWindow = EditWindow::getInstance(this); + + if (editWindow->isProcessing ()) { + return true; + } } else { int pageCount = mainNB->get_n_pages(); @@ -613,10 +631,14 @@ bool RTWindow::on_delete_event(GdkEventAny* event) if ((isSingleTabMode() || simpleEditor) && epanel->isRealized()) { epanel->saveProfile(); epanel->writeOptions (); - } else { + } + else { + if (options.multiDisplayMode > 0) { + editWindow->closeOpenEditors (); + } // Storing the options of the last EditorPanel before Gtk destroys everything // Look at the active panel first, if any, otherwise look at the first one (sorted on the filename) - if (epanels.size()) { + else if (epanels.size()) { int page = mainNB->get_current_page(); Gtk::Widget *w = mainNB->get_nth_page(page); bool optionsWritten = false; @@ -826,7 +848,7 @@ void RTWindow::set_title_decorated(Glib::ustring fname) set_title(versionStr + subtitle); } -void RTWindow::CloseOpenEditors() +void RTWindow::closeOpenEditors() { std::map::const_iterator itr; itr = epanels.begin(); @@ -850,7 +872,7 @@ bool RTWindow::isEditorPanel(guint pageNum) void RTWindow::setEditorMode(bool tabbedUI) { MoveFileBrowserToMain(); - CloseOpenEditors(); + closeOpenEditors(); SetMainCurrent(); if(tabbedUI) { diff --git a/rtgui/rtwindow.h b/rtgui/rtwindow.h index a57f7b4a3..faad5f849 100644 --- a/rtgui/rtwindow.h +++ b/rtgui/rtwindow.h @@ -80,6 +80,7 @@ public: void addBatchQueueJobs (std::vector &entries); bool keyPressed (GdkEventKey* event); + bool on_configure_event(GdkEventConfigure* event); bool on_delete_event(GdkEventAny* event); bool on_window_state_event(GdkEventWindowState* event); void on_mainNB_switch_page(Gtk::Widget* widget, guint page_num); @@ -115,7 +116,7 @@ public: return is_fullscreen; } void set_title_decorated(Glib::ustring fname); - void CloseOpenEditors(); + void closeOpenEditors(); void setEditorMode(bool tabbedUI); void createSetmEditor(); };