ui.*: make active? an integer 0-100
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.db4
parent
73893693d3
commit
7bc1009973
|
@ -143,7 +143,8 @@ M:: cocoa-ui-backend (open-window) ( world -- )
|
||||||
world window save-position
|
world window save-position
|
||||||
window install-window-delegate
|
window install-window-delegate
|
||||||
view window <window-handle> world handle<<
|
view window <window-handle> world handle<<
|
||||||
window f -> makeKeyAndOrderFront: ;
|
window f -> makeKeyAndOrderFront:
|
||||||
|
100 window active?<< ;
|
||||||
|
|
||||||
M: cocoa-ui-backend (close-window) ( handle -- )
|
M: cocoa-ui-backend (close-window) ( handle -- )
|
||||||
[
|
[
|
||||||
|
|
|
@ -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
|
IN: ui.backend.gtk
|
||||||
|
|
||||||
HELP: configure-im
|
HELP: configure-im
|
||||||
{ $values { "win" GtkWindow } { "im" GtkIMContext } }
|
{ $values { "win" GtkWindow } { "im" GtkIMContext } }
|
||||||
{ $description "Configures the input methods of the window. Must only be run after the window has been realized." }
|
{ $description "Configures the input methods of the window. Must only be run after the window has been realized." }
|
||||||
{ $see-also gtk_widget_realize } ;
|
{ $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." } ;
|
||||||
|
|
|
@ -257,20 +257,27 @@ CONSTANT: action-key-codes
|
||||||
2drop window relayout t ;
|
2drop window relayout t ;
|
||||||
|
|
||||||
: on-configure ( win event user-data -- ? )
|
: on-configure ( win event user-data -- ? )
|
||||||
drop [ window ] [ GdkEventConfigure memory>struct ] bi*
|
drop swap window dup active?>> 50 >= [
|
||||||
[ event-loc >>window-loc ] [ event-dim >>dim ] bi
|
100 >>active? swap GdkEventConfigure memory>struct
|
||||||
relayout-1 f ;
|
[ event-loc >>window-loc ] [ event-dim >>dim ] bi
|
||||||
|
relayout-1
|
||||||
|
] [ 2drop ] if f ;
|
||||||
|
|
||||||
: on-delete ( win event user-data -- ? )
|
: on-delete ( win event user-data -- ? )
|
||||||
2drop window ungraft t ;
|
2drop window ungraft t ;
|
||||||
|
|
||||||
|
: on-map ( win event user-data -- ? )
|
||||||
|
2drop window 50 >>active? drop t ;
|
||||||
|
|
||||||
:: connect-win-state-signals ( win -- )
|
:: connect-win-state-signals ( win -- )
|
||||||
win "expose-event" [ on-expose yield ]
|
win "expose-event" [ on-expose yield ]
|
||||||
GtkWidget:expose-event connect-signal
|
GtkWidget:expose-event connect-signal
|
||||||
win "configure-event" [ on-configure yield ]
|
win "configure-event" [ on-configure yield ]
|
||||||
GtkWidget:configure-event connect-signal
|
GtkWidget:configure-event connect-signal
|
||||||
win "delete-event" [ on-delete yield ]
|
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
|
! Input methods
|
||||||
|
|
||||||
|
|
|
@ -271,7 +271,7 @@ CONSTANT: window-control>ex-style
|
||||||
: handle-wm-paint ( hWnd uMsg wParam lParam -- )
|
: handle-wm-paint ( hWnd uMsg wParam lParam -- )
|
||||||
! wParam and lParam are unused
|
! wParam and lParam are unused
|
||||||
! only paint if width/height both > 0
|
! 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 -- )
|
: handle-wm-size ( hWnd uMsg wParam lParam -- )
|
||||||
2nip
|
2nip
|
||||||
|
@ -411,9 +411,9 @@ CONSTANT: exclude-keys-wm-char
|
||||||
|
|
||||||
: handle-wm-syscommand ( hWnd uMsg wParam lParam -- n )
|
: handle-wm-syscommand ( hWnd uMsg wParam lParam -- n )
|
||||||
{
|
{
|
||||||
{ [ over SC_MINIMIZE = ] [ f set-window-active ] }
|
{ [ over SC_MINIMIZE = ] [ 0 set-window-active ] }
|
||||||
{ [ over SC_RESTORE = ] [ t set-window-active ] }
|
{ [ over SC_RESTORE = ] [ 100 set-window-active ] }
|
||||||
{ [ over SC_MAXIMIZE = ] [ t set-window-active ] }
|
{ [ over SC_MAXIMIZE = ] [ 100 set-window-active ] }
|
||||||
{ [ dup alpha? ] [ 4drop 0 ] }
|
{ [ dup alpha? ] [ 4drop 0 ] }
|
||||||
{ [ t ] [ DefWindowProc ] }
|
{ [ t ] [ DefWindowProc ] }
|
||||||
} cond ;
|
} cond ;
|
||||||
|
|
|
@ -57,6 +57,7 @@ M: world expose-event nip relayout ;
|
||||||
|
|
||||||
M: world configure-event
|
M: world configure-event
|
||||||
swap [ event-loc >>window-loc ] [ event-dim >>dim ] bi
|
swap [ event-loc >>window-loc ] [ event-dim >>dim ] bi
|
||||||
|
100 >>active?
|
||||||
! In case dimensions didn't change
|
! In case dimensions didn't change
|
||||||
relayout-1 ;
|
relayout-1 ;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
USING: ui.gadgets ui.render ui.text ui.text.private
|
USING: destructors help.markup help.syntax math models strings
|
||||||
ui.gestures ui.backend help.markup help.syntax
|
ui.backend ui.gadgets ui.gestures ui.render ;
|
||||||
models opengl sequences strings destructors ;
|
|
||||||
IN: ui.gadgets.worlds
|
IN: ui.gadgets.worlds
|
||||||
|
|
||||||
HELP: user-input
|
HELP: user-input
|
||||||
|
@ -47,19 +46,52 @@ HELP: focus-path
|
||||||
|
|
||||||
HELP: world
|
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:"
|
{ $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
|
{ $table
|
||||||
{ { $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 "active?" }
|
||||||
{ { $slot "title" } " - a string to be displayed in the title bar of the native window containing the world." }
|
{ "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 "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." }
|
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
{ $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>
|
HELP: <world>
|
||||||
|
|
|
@ -118,7 +118,7 @@ M: world request-focus-on ( child gadget -- )
|
||||||
: new-world ( class -- world )
|
: new-world ( class -- world )
|
||||||
vertical swap new-track
|
vertical swap new-track
|
||||||
t >>root?
|
t >>root?
|
||||||
f >>active?
|
0 >>active?
|
||||||
{ 0 0 } >>window-loc
|
{ 0 0 } >>window-loc
|
||||||
f >>grab-input?
|
f >>grab-input?
|
||||||
V{ } clone >>window-resources
|
V{ } clone >>window-resources
|
||||||
|
@ -177,7 +177,7 @@ M: world resize-world drop ;
|
||||||
M: world dim<<
|
M: world dim<<
|
||||||
[ call-next-method ]
|
[ call-next-method ]
|
||||||
[
|
[
|
||||||
dup active?>> [
|
dup active?>> 100 = [
|
||||||
dup handle>>
|
dup handle>>
|
||||||
[ [ set-gl-context ] [ resize-world ] bi ]
|
[ [ set-gl-context ] [ resize-world ] bi ]
|
||||||
[ drop ] if
|
[ drop ] if
|
||||||
|
@ -199,7 +199,7 @@ M: world draw-world*
|
||||||
: draw-world? ( world -- ? )
|
: draw-world? ( world -- ? )
|
||||||
! We don't draw deactivated worlds, or those with 0 size.
|
! We don't draw deactivated worlds, or those with 0 size.
|
||||||
! On Windows, the latter case results in GL errors.
|
! 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 ;
|
TUPLE: world-error error world ;
|
||||||
|
|
||||||
|
@ -219,7 +219,7 @@ ui-error-hook [ [ rethrow ] ] initialize
|
||||||
dup [ draw-world* ] with-gl-context
|
dup [ draw-world* ] with-gl-context
|
||||||
flush-layout-cache-hook get call( -- )
|
flush-layout-cache-hook get call( -- )
|
||||||
] [
|
] [
|
||||||
swap f >>active? <world-error> ui-error
|
swap 0 >>active? <world-error> ui-error
|
||||||
] recover
|
] recover
|
||||||
] with-variable
|
] with-variable
|
||||||
] [ drop ] if ;
|
] [ drop ] if ;
|
||||||
|
|
|
@ -64,7 +64,6 @@ SYMBOL: ui-windows
|
||||||
[ [ title>> ] keep set-title ]
|
[ [ title>> ] keep set-title ]
|
||||||
[ begin-world ]
|
[ begin-world ]
|
||||||
[ resize-world ]
|
[ resize-world ]
|
||||||
[ t >>active? drop ]
|
|
||||||
[ request-focus ]
|
[ request-focus ]
|
||||||
} cleave ;
|
} cleave ;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue