From 1c31427e7ecf3178ecf55fd1a893de8459192db4 Mon Sep 17 00:00:00 2001 From: dooglus Date: Tue, 27 Nov 2007 01:16:48 +0000 Subject: [PATCH] Fix 1836848: if the window positions and sizes seem to be corrupted, give them sensible values to prevent them being created offscreen. git-svn-id: http://svn.voria.com/code@1167 1f10aa63-cdf2-0310-b900-c93c546f37ac --- synfig-studio/trunk/src/gtkmm/dialogsettings.cpp | 12 ++++++++++++ synfig-studio/trunk/src/gtkmm/dockmanager.cpp | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/synfig-studio/trunk/src/gtkmm/dialogsettings.cpp b/synfig-studio/trunk/src/gtkmm/dialogsettings.cpp index c11ef4e..e325dd9 100644 --- a/synfig-studio/trunk/src/gtkmm/dialogsettings.cpp +++ b/synfig-studio/trunk/src/gtkmm/dialogsettings.cpp @@ -31,6 +31,7 @@ #include "dialogsettings.h" #include +#include #include "general.h" @@ -116,6 +117,9 @@ DialogSettings::get_value(const synfig::String& key, synfig::String& value)const bool DialogSettings::set_value(const synfig::String& key,const synfig::String& value) { + int screen_w(Gdk::screen_width()); + int screen_h(Gdk::screen_height()); + if(value.empty()) return false; @@ -124,6 +128,10 @@ DialogSettings::set_value(const synfig::String& key,const synfig::String& value) int x,y; if(!strscanf(value,"%d %d",&x, &y)) return false; + + if (x > screen_w) x = screen_w - 150; if (x < 0) x = 0; + if (y > screen_h) y = screen_h - 150; if (y < 0) y = 0; + window->move(x,y); return true; } @@ -132,6 +140,10 @@ DialogSettings::set_value(const synfig::String& key,const synfig::String& value) int x,y; if(!strscanf(value,"%d %d",&x, &y)) return false; + + if (x > screen_w) x = 150; if (x < 0) x = 0; + if (y > screen_h) y = 150; if (y < 0) y = 0; + window->set_default_size(x,y); return true; } diff --git a/synfig-studio/trunk/src/gtkmm/dockmanager.cpp b/synfig-studio/trunk/src/gtkmm/dockmanager.cpp index 0da07eb..7b5e204 100644 --- a/synfig-studio/trunk/src/gtkmm/dockmanager.cpp +++ b/synfig-studio/trunk/src/gtkmm/dockmanager.cpp @@ -145,6 +145,8 @@ public: int size; if(!strscanf(value_,"%d",&size)) break; + if (size > SCALE_FACTOR) size = SCALE_FACTOR - 150; + if (size < 0) size = 0; size=size*screen_h/SCALE_FACTOR; // prevent errors like this, by allowing space for at least the dockable's icon: @@ -172,6 +174,8 @@ public: int x,y; if(!strscanf(value,"%d %d",&x, &y)) return false; + if (x > SCALE_FACTOR) x = SCALE_FACTOR - 150; if (x < 0) x = 0; + if (y > SCALE_FACTOR) y = SCALE_FACTOR - 150; if (y < 0) y = 0; x=x*screen_w/SCALE_FACTOR; y=y*screen_h/SCALE_FACTOR; dock_dialog.move(x,y); @@ -182,6 +186,8 @@ public: int x,y; if(!strscanf(value,"%d %d",&x, &y)) return false; + if (x > SCALE_FACTOR) x = 150; if (x < 0) x = 0; + if (y > SCALE_FACTOR) y = 150; if (y < 0) y = 0; x=x*screen_w/SCALE_FACTOR; y=y*screen_h/SCALE_FACTOR; dock_dialog.set_default_size(x,y); -- 2.7.4