Fix some more problems in MEOW mode, #3957
This commit is contained in:
@@ -32,7 +32,7 @@ bool EditWindow::isMultiDisplayEnabled()
|
||||
}
|
||||
|
||||
// Should only be created once, auto-creates window on correct display
|
||||
EditWindow* EditWindow::getInstance(RTWindow* p)
|
||||
EditWindow* EditWindow::getInstance(RTWindow* p, bool restore)
|
||||
{
|
||||
struct EditWindowInstance
|
||||
{
|
||||
@@ -44,11 +44,13 @@ EditWindow* EditWindow::getInstance(RTWindow* p)
|
||||
};
|
||||
|
||||
static EditWindowInstance instance_(p);
|
||||
|
||||
if(restore) {
|
||||
instance_.editWnd.restoreWindow();
|
||||
}
|
||||
return &instance_.editWnd;
|
||||
}
|
||||
|
||||
EditWindow::EditWindow (RTWindow* p) : parent(p) , isFullscreen(false)
|
||||
EditWindow::EditWindow (RTWindow* p) : parent(p) , isFullscreen(false), isClosed(true)
|
||||
{
|
||||
|
||||
Glib::ustring fName = "rt-logo-tiny.png";
|
||||
@@ -64,10 +66,8 @@ EditWindow::EditWindow (RTWindow* p) : parent(p) , isFullscreen(false)
|
||||
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) );
|
||||
|
||||
mainNB = Gtk::manage (new Gtk::Notebook ());
|
||||
mainNB->set_scrollable (true);
|
||||
@@ -80,29 +80,45 @@ EditWindow::EditWindow (RTWindow* p) : parent(p) , isFullscreen(false)
|
||||
|
||||
add (*mainBox);
|
||||
|
||||
if(!is_maximized()) {
|
||||
}
|
||||
|
||||
void EditWindow::restoreWindow() {
|
||||
|
||||
if(isClosed) {
|
||||
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;
|
||||
const Glib::RefPtr< Gdk::Window >& wnd = parent->get_window();
|
||||
meowMonitor = parent->get_screen()->get_monitor_at_window(wnd) == 0 ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
Gdk::Rectangle lMonitorRect;
|
||||
get_screen()->get_monitor_geometry(meowMonitor, lMonitorRect);
|
||||
if(options.meowMaximized) {
|
||||
move(lMonitorRect.get_x(), lMonitorRect.get_y());
|
||||
|
||||
maximize();
|
||||
show_all ();
|
||||
if(!options.meowFullScreen) {
|
||||
setFullScreen(false);
|
||||
} else {
|
||||
resize(options.meowWidth, options.meowHeight);
|
||||
if(options.meowX <= lMonitorRect.get_x() + lMonitorRect.get_width() && options.meowY <= lMonitorRect.get_y() + lMonitorRect.get_height()) {
|
||||
move(options.meowX, options.meowY);
|
||||
} else {
|
||||
move(lMonitorRect.get_x(), lMonitorRect.get_y());
|
||||
}
|
||||
}
|
||||
show_all();
|
||||
|
||||
isFullscreen = options.meowFullScreen;
|
||||
|
||||
if(isFullscreen) {
|
||||
fullscreen();
|
||||
setFullScreen(true);
|
||||
}
|
||||
|
||||
isClosed = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void EditWindow::on_realize ()
|
||||
@@ -114,9 +130,13 @@ void EditWindow::on_realize ()
|
||||
|
||||
bool EditWindow::on_configure_event(GdkEventConfigure* event)
|
||||
{
|
||||
if (!is_maximized() && get_realized() && is_visible()) {
|
||||
if (get_realized() && is_visible()) {
|
||||
if(!is_maximized()) {
|
||||
get_position(options.meowX, options.meowY);
|
||||
get_size(options.meowWidth, options.meowHeight);
|
||||
}
|
||||
options.meowMaximized = is_maximized();
|
||||
}
|
||||
|
||||
return Gtk::Widget::on_configure_event(event);
|
||||
}
|
||||
@@ -220,7 +240,9 @@ 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
|
||||
if(!isMultiDisplayEnabled()) {
|
||||
present();
|
||||
}
|
||||
}
|
||||
|
||||
bool EditWindow::keyPressed (GdkEventKey* event)
|
||||
@@ -253,6 +275,18 @@ void EditWindow::toggleFullscreen ()
|
||||
options.meowFullScreen = isFullscreen = !isFullscreen;
|
||||
}
|
||||
|
||||
void EditWindow::writeOptions() {
|
||||
|
||||
if(is_visible()) {
|
||||
if(isMultiDisplayEnabled()) {
|
||||
options.meowMonitor = get_screen()->get_monitor_at_window(get_window());
|
||||
}
|
||||
|
||||
options.meowMaximized = is_maximized();
|
||||
get_position(options.meowX, options.meowY);
|
||||
get_size(options.meowWidth,options.meowHeight);
|
||||
}
|
||||
}
|
||||
bool EditWindow::on_delete_event(GdkEventAny* event)
|
||||
{
|
||||
|
||||
@@ -260,12 +294,9 @@ bool EditWindow::on_delete_event(GdkEventAny* event)
|
||||
return true;
|
||||
}
|
||||
|
||||
if(isMultiDisplayEnabled()) {
|
||||
options.meowMonitor = get_screen()->get_monitor_at_window(get_window());
|
||||
}
|
||||
|
||||
writeOptions();
|
||||
hide();
|
||||
unmaximize();
|
||||
isClosed = true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@@ -33,17 +33,20 @@ private:
|
||||
std::map<Glib::ustring, EditorPanel*> epanels;
|
||||
|
||||
bool isFullscreen;
|
||||
bool isClosed;
|
||||
void toggleFullscreen ();
|
||||
void restoreWindow();
|
||||
|
||||
public:
|
||||
// Check if the system has more than one display and option is set
|
||||
static bool isMultiDisplayEnabled();
|
||||
|
||||
// Should only be created once, auto-creates window on correct display
|
||||
static EditWindow* getInstance(RTWindow* p);
|
||||
static EditWindow* getInstance(RTWindow* p, bool restore = true);
|
||||
|
||||
explicit EditWindow (RTWindow* p);
|
||||
|
||||
void writeOptions();
|
||||
void addEditorPanel (EditorPanel* ep, const std::string &name);
|
||||
void remEditorPanel (EditorPanel* ep);
|
||||
bool selectEditorPanel(const std::string &name);
|
||||
@@ -57,8 +60,6 @@ public:
|
||||
//bool on_window_state_event(GdkEventWindowState* event);
|
||||
void on_mainNB_switch_page(Gtk::Widget* page, guint page_num);
|
||||
void set_title_decorated(Glib::ustring fname);
|
||||
void setFullScreen (bool fullScreen) { isFullscreen = fullScreen; }
|
||||
|
||||
void on_realize ();
|
||||
};
|
||||
|
||||
|
@@ -297,8 +297,11 @@ void Options::setDefaults ()
|
||||
windowMaximized = true;
|
||||
meowMonitor = -1;
|
||||
meowFullScreen = false;
|
||||
meowMaximized = true;
|
||||
meowWidth = 1200;
|
||||
meowHeight = 680;
|
||||
meowX = 0;
|
||||
meowY = 0;
|
||||
saveAsDialogWidth = 920;
|
||||
saveAsDialogHeight = 680;
|
||||
savesParamsAtExit = true;
|
||||
@@ -1270,6 +1273,10 @@ int Options::readFromFile (Glib::ustring fname)
|
||||
meowFullScreen = keyFile.get_boolean ("GUI", "MeowFullScreen");
|
||||
}
|
||||
|
||||
if (keyFile.has_key ("GUI", "MeowMaximized")) {
|
||||
meowMaximized = keyFile.get_boolean ("GUI", "MeowMaximized");
|
||||
}
|
||||
|
||||
if (keyFile.has_key ("GUI", "MeowWidth")) {
|
||||
meowWidth = keyFile.get_integer ("GUI", "MeowWidth");
|
||||
}
|
||||
@@ -1278,6 +1285,14 @@ int Options::readFromFile (Glib::ustring fname)
|
||||
meowHeight = keyFile.get_integer ("GUI", "MeowHeight");
|
||||
}
|
||||
|
||||
if (keyFile.has_key ("GUI", "MeowX")) {
|
||||
meowX = keyFile.get_integer ("GUI", "MeowX");
|
||||
}
|
||||
|
||||
if (keyFile.has_key ("GUI", "MeowY")) {
|
||||
meowY = keyFile.get_integer ("GUI", "MeowY");
|
||||
}
|
||||
|
||||
if (keyFile.has_key ("GUI", "WindowMaximized")) {
|
||||
windowMaximized = keyFile.get_boolean ("GUI", "WindowMaximized");
|
||||
}
|
||||
@@ -2031,8 +2046,11 @@ 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_boolean ("GUI", "MeowMaximized", meowMaximized);
|
||||
keyFile.set_integer ("GUI", "MeowWidth", meowWidth);
|
||||
keyFile.set_integer ("GUI", "MeowHeight", meowHeight);
|
||||
keyFile.set_integer ("GUI", "MeowX", meowX);
|
||||
keyFile.set_integer ("GUI", "MeowY", meowY);
|
||||
keyFile.set_boolean ("GUI", "WindowMaximized", windowMaximized);
|
||||
keyFile.set_integer ("GUI", "DetailWindowWidth", detailWindowWidth);
|
||||
keyFile.set_integer ("GUI", "DetailWindowHeight", detailWindowHeight);
|
||||
|
@@ -139,8 +139,11 @@ public:
|
||||
bool windowMaximized;
|
||||
int meowMonitor;
|
||||
bool meowFullScreen;
|
||||
bool meowMaximized;
|
||||
int meowWidth;
|
||||
int meowHeight;
|
||||
int meowX;
|
||||
int meowY;
|
||||
int detailWindowWidth;
|
||||
int detailWindowHeight;
|
||||
int dirBrowserWidth;
|
||||
|
@@ -601,7 +601,7 @@ bool RTWindow::on_delete_event(GdkEventAny* event)
|
||||
if (isSingleTabMode() || simpleEditor) {
|
||||
isProcessing = epanel->getIsProcessing();
|
||||
} else if (options.multiDisplayMode > 0) {
|
||||
editWindow = EditWindow::getInstance(this);
|
||||
editWindow = EditWindow::getInstance(this, false);
|
||||
|
||||
if (editWindow->isProcessing ()) {
|
||||
return true;
|
||||
@@ -634,7 +634,8 @@ bool RTWindow::on_delete_event(GdkEventAny* event)
|
||||
}
|
||||
else {
|
||||
if (options.multiDisplayMode > 0) {
|
||||
editWindow->closeOpenEditors ();
|
||||
editWindow->closeOpenEditors();
|
||||
editWindow->writeOptions();
|
||||
}
|
||||
// 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)
|
||||
|
Reference in New Issue
Block a user