]> gitweb.factorcode.org Git - factor.git/commitdiff
ui.backend.gtk: add auto-position for worlds with { 0 0 } in window-loc
authorAnton Gorenko <ex.rzrjck@gmail.com>
Tue, 8 Jun 2010 11:41:10 +0000 (17:41 +0600)
committerAnton Gorenko <ex.rzrjck@gmail.com>
Tue, 8 Jun 2010 11:41:10 +0000 (17:41 +0600)
basis/ui/backend/gtk/gtk.factor

index 4c533245702a34da4eb48854a9123110fc790687..9acae5e7a5a929b0a3701ba6da4e33f05afee619 100644 (file)
@@ -366,12 +366,22 @@ CONSTANT: window-controls>func-flags
         f t GDK_GL_RGBA_TYPE enum>number gtk_widget_set_gl_capability
     ] with-world-pixel-format ;
 
+: auto-position ( window loc -- )
+    dup { 0 0 } = [
+        drop dup window topmost-window =
+        GTK_WIN_POS_CENTER GTK_WIN_POS_NONE ?
+        gtk_window_set_position
+    ] [ first2 gtk_window_move ] if ;
+
 M:: gtk-ui-backend (open-window) ( world -- )
     GTK_WINDOW_TOPLEVEL gtk_window_new :> win
-    win <window-handle> world handle<<
-    world [ window-loc>> win swap first2 gtk_window_move ]
-    [ dim>> win swap first2 gtk_window_set_default_size ] bi
-
+    
+    world win [ <window-handle> >>handle drop ]
+    [ register-window ] 2bi
+    
+    win world [ window-loc>> auto-position ]
+    [ dim>> first2 gtk_window_set_default_size ] 2bi
+    
     world setup-gl drop
     
     win connect-signals
@@ -379,8 +389,6 @@ M:: gtk-ui-backend (open-window) ( world -- )
     win gtk_widget_realize
     win world window-controls>> configure-window-controls
     
-    world win register-window
-    
     win gtk_widget_show_all ;
 
 M: gtk-ui-backend (close-window) ( handle -- )