Code

Special #ifdef win32 code to enable Dialogs on Top for windows. Note the removal...
[inkscape.git] / src / ui / dialog / dialog.cpp
index 074ee0d36528bc93b353ccb545caf7178a98c544..d5708395113f2ad89f631cda5db4055c76f0645c 100644 (file)
 #include "interface.h"
 #include "verbs.h"
 
+
+#define MIN_ONSCREEN_DISTANCE 50
+
+
+
 namespace Inkscape {
 namespace UI {
 namespace Dialog {
 
-#ifndef WIN32
+//#ifndef WIN32
 static gboolean
 sp_retransientize_again (gpointer dlgPtr)
 {
@@ -43,7 +48,7 @@ sp_retransientize_again (gpointer dlgPtr)
     dlg->retransientize_suppress = false;
     return FALSE; // so that it is only called once
 }
-#endif
+//#endif
 
 static void
 sp_retransientize (Inkscape::Application *inkscape, SPDesktop *desktop, gpointer dlgPtr)
@@ -96,18 +101,16 @@ Dialog::read_geometry()
 
 //    g_print ("read %d %d %d %d\n", x, y, w, h);
 
-        if (x<0) x=0;
-        if (y<0) y=0;
-
     // If there are stored height and width values for the dialog,
     // resize the window to match; otherwise we leave it at its default
     if (w != 0 && h != 0) {
         resize (w, h);
     }
-
+    
     // If there are stored values for where the dialog should be
     // located, then restore the dialog to that position.
-    if (x != -1000 && y != -1000) {
+    // also check if (x,y) is actually onscreen with the current screen dimensions
+    if ( (x >= 0) && (y >= 0) && (x < (gdk_screen_width()-MIN_ONSCREEN_DISTANCE)) && (y < (gdk_screen_height()-MIN_ONSCREEN_DISTANCE)) ) {
         move(x, y);
     } else {
         // ...otherwise just put it in the middle of the screen
@@ -287,10 +290,18 @@ Dialog::onDesktopActivated (SPDesktop *desktop)
 {
     gint transient_policy = prefs_get_int_attribute_limited ( "options.transientpolicy", "value", 1, 0, 2);
 
-    if (!transient_policy)
+#ifdef WIN32 // FIXME: Temporary Win32 special code to enable transient dialogs
+    if (prefs_get_int_attribute ( "options.dialogsontopwin32", "value", 0))
+        transient_policy = 2;
+    else    
+        return;
+#endif        
+
+    if (!transient_policy) 
         return;
 
-#ifndef WIN32
+
+
     GtkWindow *dialog_win = GTK_WINDOW(gobj());
 
     if (retransientize_suppress) {
@@ -324,7 +335,6 @@ Dialog::onDesktopActivated (SPDesktop *desktop)
 
     // we're done, allow next retransientizing not sooner than after 120 msec
     gtk_timeout_add (120, (GtkFunction) sp_retransientize_again, (gpointer) this);
-#endif
 }