]> gitweb.factorcode.org Git - factor.git/commitdiff
ui.*: make active? an integer 0-100
authorBjörn Lindqvist <bjourne@gmail.com>
Tue, 27 Oct 2015 18:00:28 +0000 (19:00 +0100)
committerBjörn Lindqvist <bjourne@gmail.com>
Tue, 27 Oct 2015 18:00:28 +0000 (19:00 +0100)
A UI backend can delay setting active? to 100 until the windows actually
is visible. That way, some redundant redraws that happen when the window
isn't visible is supressed. It makes the Windows and GTK UI startup a
little faster.

basis/ui/backend/cocoa/cocoa.factor
basis/ui/backend/gtk/gtk-docs.factor
basis/ui/backend/gtk/gtk.factor
basis/ui/backend/windows/windows.factor
basis/ui/backend/x11/x11.factor
basis/ui/gadgets/worlds/worlds-docs.factor
basis/ui/gadgets/worlds/worlds.factor
basis/ui/ui.factor

index 7835c50d51d5ab176606da828c517c44923ecf60..55b34331929f37b3c56591abf413f50aeba136dc 100644 (file)
@@ -143,7 +143,8 @@ M:: cocoa-ui-backend (open-window) ( world -- )
     world window save-position
     window install-window-delegate
     view window <window-handle> world handle<<
-    window f -> makeKeyAndOrderFront: ;
+    window f -> makeKeyAndOrderFront:
+    100 window active?<< ;
 
 M: cocoa-ui-backend (close-window) ( handle -- )
     [
index 1b2753e29a69096b78e58e6bb683478a95818e2d..32d962ffeb4d06ce207731ad9809b7915a662044 100644 (file)
@@ -1,7 +1,16 @@
-USING: gtk.ffi help.markup help.syntax ;
+USING: alien gdk.ffi gtk.ffi help.markup help.syntax kernel ;
 IN: ui.backend.gtk
 
 HELP: configure-im
 { $values { "win" GtkWindow } { "im" GtkIMContext } }
 { $description "Configures the input methods of the window. Must only be run after the window has been realized." }
 { $see-also gtk_widget_realize } ;
+
+HELP: on-configure
+{ $values
+  { "win" alien }
+  { "event" alien }
+  { "user-data" alien }
+  { "?" boolean }
+}
+{ $description "Handles a configure event (" { $link GdkEventConfigure } " sent from the windowing system. The world is activated if it isn't already and a map event has been received. Then it is relayouted." } ;
index b26eebb475ef7c2c599970c94e5921f37ab17231..0263840425000151b3e4074f47a99894d9600582 100644 (file)
@@ -257,20 +257,27 @@ CONSTANT: action-key-codes
     2drop window relayout t ;
 
 : on-configure ( win event user-data -- ? )
-    drop [ window ] [ GdkEventConfigure memory>struct ] bi*
-    [ event-loc >>window-loc ] [ event-dim >>dim ] bi
-    relayout-1 f ;
+    drop swap window dup active?>> 50 >= [
+        100 >>active? swap GdkEventConfigure memory>struct
+        [ event-loc >>window-loc ] [ event-dim >>dim ] bi
+        relayout-1
+    ] [ 2drop ] if f ;
 
 : on-delete ( win event user-data -- ? )
     2drop window ungraft t ;
 
+: on-map ( win event user-data -- ? )
+    2drop window 50 >>active? drop t ;
+
 :: connect-win-state-signals ( win -- )
     win "expose-event" [ on-expose yield ]
     GtkWidget:expose-event connect-signal
     win "configure-event" [ on-configure yield ]
     GtkWidget:configure-event connect-signal
     win "delete-event" [ on-delete yield ]
-    GtkWidget:delete-event connect-signal ;
+    GtkWidget:delete-event connect-signal
+    win "map-event" [ on-map yield ]
+    GtkWidget:map-event connect-signal ;
 
 ! Input methods
 
index 0209f7f5b0afad98f1e109c4ec3955a8929857b0..11afc7947b6d77a9c72aa275e4b7321d115a41c0 100755 (executable)
@@ -271,7 +271,7 @@ CONSTANT: window-control>ex-style
 : handle-wm-paint ( hWnd uMsg wParam lParam -- )
     ! wParam and lParam are unused
     ! only paint if width/height both > 0
-    3drop window relayout-1 yield ;
+    3drop window 100 >>active? relayout-1 yield ;
 
 : handle-wm-size ( hWnd uMsg wParam lParam -- )
     2nip
@@ -411,9 +411,9 @@ CONSTANT: exclude-keys-wm-char
 
 : handle-wm-syscommand ( hWnd uMsg wParam lParam -- n )
     {
-        { [ over SC_MINIMIZE = ] [ f set-window-active ] }
-        { [ over SC_RESTORE = ] [ t set-window-active ] }
-        { [ over SC_MAXIMIZE = ] [ t set-window-active ] }
+        { [ over SC_MINIMIZE = ] [ 0 set-window-active ] }
+        { [ over SC_RESTORE = ] [ 100 set-window-active ] }
+        { [ over SC_MAXIMIZE = ] [ 100 set-window-active ] }
         { [ dup alpha? ] [ 4drop 0 ] }
         { [ t ] [ DefWindowProc ] }
     } cond ;
index e030d2d4189dd24fda5d2129840408702df349af..ef22ab9cfc6f45b1e60c53525b822e6d4982626c 100644 (file)
@@ -57,6 +57,7 @@ M: world expose-event nip relayout ;
 
 M: world configure-event
     swap [ event-loc >>window-loc ] [ event-dim >>dim ] bi
+    100 >>active?
     ! In case dimensions didn't change
     relayout-1 ;
 
index 4c1fc3b9645caf478dc7b252ec0677782899785e..c92fc98fa61f24e94fd87434cea1f8df3315273a 100644 (file)
@@ -1,6 +1,5 @@
-USING: ui.gadgets ui.render ui.text ui.text.private
-ui.gestures ui.backend help.markup help.syntax
-models opengl sequences strings destructors ;
+USING: destructors help.markup help.syntax math models strings
+ui.backend ui.gadgets ui.gestures ui.render ;
 IN: ui.gadgets.worlds
 
 HELP: user-input
@@ -47,19 +46,52 @@ HELP: focus-path
 
 HELP: world
 { $class-description "A gadget which appears at the top of the gadget hieararchy, and in turn may be displayed in a native window. Worlds have the following slots:"
-    { $list
-        { { $slot "active?" } " - if set to " { $link f } ", the world will not be drawn. This slot is set to " { $link f } " if an error is thrown while drawing the world; this prevents multiple debugger windows from being shown." }
-        { { $slot "layers" } " - a sequence of glass panes in front of the primary gadget, used to implement behaviors such as popup menus which are hidden when the mouse is clicked outside the menu. See " { $link "ui.gadgets.glass" } "." }
-        { { $slot "title" } " - a string to be displayed in the title bar of the native window containing the world." }
-        { { $slot "status" } " - a " { $link model } " holding a string to be displayed in the world's status bar." }
-        { { $slot "status-owner" } " - the gadget that displayed the most recent status message." }
-        { { $slot "focus" } " - the current owner of the keyboard focus in the world." }
-        { { $slot "focused?" } " - a boolean indicating if the native window containing the world has keyboard focus." }
-        { { $slot "grab-input?" } " - if set to " { $link t } ", the world will hide the mouse cursor and disable normal mouse input while focused. Use " { $link grab-input } " and " { $link ungrab-input } " to change this setting." }
-        { { $slot "handle" } " - a backend-specific native handle representing the native window containing the world, or " { $link f } " if the world is not grafted." }
-        { { $slot "window-loc" } " - the on-screen location of the native window containing the world. The co-ordinate system here is backend-specific." }
-        { { $slot "window-controls" } " - the set of " { $link "ui.gadgets.worlds-window-controls" } " with which the world window was created." }
+  { $table
+    {
+        { $slot "active?" }
+        { "an " { $link integer } " initially set to 0. The active " { $link ui-backend } " increases the value in steps up to 100 while the native window containing the world is being initialized but not yet visible on the screen. The world is only redrawn when the value is 100 which prevents redundant redraws from happening during initialization. The slot is set to 0 if an error is thrown while drawing the world; this prevents multiple debugger windows from being shown." }
     }
+    {
+        { $slot "layers" }
+        { "a sequence of glass panes in front of the primary gadget, used to implement behaviors such as popup menus which are hidden when the mouse is clicked outside the menu. See " { $link "ui.gadgets.glass" } "." }
+    }
+    {
+        { $slot "title" }
+        { "a string to be displayed in the title bar of the native window containing the world." }
+    }
+    {
+        { $slot "status" }
+        { "a " { $link model } " holding a string to be displayed in the world's status bar." }
+    }
+    {
+        { $slot "status-owner" }
+        { "the gadget that displayed the most recent status message." }
+    }
+    {
+        { $slot "focus" }
+        { "the current owner of the keyboard focus in the world." }
+    }
+    {
+        { $slot "focused?" }
+        { "a boolean indicating if the native window containing the world has keyboard focus." }
+    }
+    {
+        { $slot "grab-input?" }
+        { "if set to " { $link t } ", the world will hide the mouse cursor and disable normal mouse input while focused. Use " { $link grab-input } " and " { $link ungrab-input } " to change this setting." }
+    }
+    {
+        { $slot "handle" }
+        { "a backend-specific native handle representing the native window containing the world, or " { $link f } " if the world is not grafted." }
+    }
+    {
+        { $slot "window-loc" }
+        { "the on-screen location of the native window containing the world. The co-ordinate system here is backend-specific." }
+    }
+    {
+        { $slot "window-controls" }
+        { "the set of " { $link "ui.gadgets.worlds-window-controls" } " with which the world window was created." }
+    }
+  }
 } ;
 
 HELP: <world>
index 5cf40ee32935ea7d93b25f8e1b6f1df43ead33a2..43366603be8252c975a4ec368d7d1cc6d406082d 100644 (file)
@@ -118,7 +118,7 @@ M: world request-focus-on ( child gadget -- )
 : new-world ( class -- world )
     vertical swap new-track
         t >>root?
-        f >>active?
+        0 >>active?
         { 0 0 } >>window-loc
         f >>grab-input?
         V{ } clone >>window-resources
@@ -177,7 +177,7 @@ M: world resize-world drop ;
 M: world dim<<
     [ call-next-method ]
     [
-        dup active?>> [
+        dup active?>> 100 = [
             dup handle>>
             [ [ set-gl-context ] [ resize-world ] bi ]
             [ drop ] if
@@ -199,7 +199,7 @@ M: world draw-world*
 : draw-world? ( world -- ? )
     ! We don't draw deactivated worlds, or those with 0 size.
     ! On Windows, the latter case results in GL errors.
-    { [ active?>> ] [ handle>> ] [ dim>> [ 0 > ] all? ] } 1&& ;
+    { [ active?>> 100 = ] [ handle>> ] [ dim>> [ 0 > ] all? ] } 1&& ;
 
 TUPLE: world-error error world ;
 
@@ -219,7 +219,7 @@ ui-error-hook [ [ rethrow ] ] initialize
                 dup [ draw-world* ] with-gl-context
                 flush-layout-cache-hook get call( -- )
             ] [
-                swap f >>active? <world-error> ui-error
+                swap 0 >>active? <world-error> ui-error
             ] recover
         ] with-variable
     ] [ drop ] if ;
index 1a45ba95ba578c5142c204b83dae83f116ff997d..dbbe7e7e1964ec24c32ad98eb6e000ca32b3f647 100644 (file)
@@ -64,7 +64,6 @@ SYMBOL: ui-windows
         [ [ title>> ] keep set-title ]
         [ begin-world ]
         [ resize-world ]
-        [ t >>active? drop ]
         [ request-focus ]
     } cleave ;