@@ -134,6 +134,7 @@ static EM_BOOL EmscriptenFullscreenChangeCallback(int eventType, const Emscripte
134
134
// static EM_BOOL EmscriptenWindowResizedCallback(int eventType, const EmscriptenUiEvent *event, void *userData);
135
135
static EM_BOOL EmscriptenResizeCallback (int eventType , const EmscriptenUiEvent * event , void * userData );
136
136
static EM_BOOL EmscriptenFocusCallback (int eventType , const EmscriptenFocusEvent * focusEvent , void * userData );
137
+ static EM_BOOL EmscriptenVisibilityChangeCallback (int eventType , const EmscriptenVisibilityChangeEvent * visibilityChangeEvent , void * userData );
137
138
138
139
// Emscripten input callback events
139
140
static EM_BOOL EmscriptenMouseMoveCallback (int eventType , const EmscriptenMouseEvent * mouseEvent , void * userData );
@@ -1383,6 +1384,10 @@ int InitPlatform(void)
1383
1384
// Support focus events
1384
1385
emscripten_set_blur_callback (GetCanvasId (), platform .handle , 1 , EmscriptenFocusCallback );
1385
1386
emscripten_set_focus_callback (GetCanvasId (), platform .handle , 1 , EmscriptenFocusCallback );
1387
+
1388
+ // Support visibility events
1389
+ emscripten_set_visibilitychange_callback (NULL , 1 , EmscriptenVisibilityChangeCallback );
1390
+
1386
1391
//----------------------------------------------------------------------------
1387
1392
1388
1393
// Initialize timing system
@@ -1758,6 +1763,13 @@ static EM_BOOL EmscriptenFocusCallback(int eventType, const EmscriptenFocusEvent
1758
1763
return consumed ;
1759
1764
}
1760
1765
1766
+ static EM_BOOL EmscriptenVisibilityChangeCallback (int eventType , const EmscriptenVisibilityChangeEvent * visibilityChangeEvent , void * userData )
1767
+ {
1768
+ if (visibilityChangeEvent -> hidden ) CORE .Window .flags |= FLAG_WINDOW_HIDDEN ; // The window was hidden
1769
+ else CORE .Window .flags &= ~FLAG_WINDOW_HIDDEN ; // The window was restored
1770
+ return 1 ; // The event was consumed by the callback handler
1771
+ }
1772
+
1761
1773
// Register touch input events
1762
1774
static EM_BOOL EmscriptenTouchCallback (int eventType , const EmscriptenTouchEvent * touchEvent , void * userData )
1763
1775
{
0 commit comments