瀏覽代碼

Support `IsWindowHidden()` on web.

pull/4789/head
Mario Nachbaur 1 月之前
父節點
當前提交
6e8004ac11
共有 1 個文件被更改,包括 12 次插入0 次删除
  1. +12
    -0
      src/platforms/rcore_web.c

+ 12
- 0
src/platforms/rcore_web.c 查看文件

@ -134,6 +134,7 @@ static EM_BOOL EmscriptenFullscreenChangeCallback(int eventType, const Emscripte
// static EM_BOOL EmscriptenWindowResizedCallback(int eventType, const EmscriptenUiEvent *event, void *userData);
static EM_BOOL EmscriptenResizeCallback(int eventType, const EmscriptenUiEvent *event, void *userData);
static EM_BOOL EmscriptenFocusCallback(int eventType, const EmscriptenFocusEvent *focusEvent, void *userData);
static EM_BOOL EmscriptenVisibilityChangeCallback(int eventType, const EmscriptenVisibilityChangeEvent *visibilityChangeEvent, void *userData);
// Emscripten input callback events
static EM_BOOL EmscriptenMouseMoveCallback(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData);
@ -1383,6 +1384,10 @@ int InitPlatform(void)
// Support focus events
emscripten_set_blur_callback(GetCanvasId(), platform.handle, 1, EmscriptenFocusCallback);
emscripten_set_focus_callback(GetCanvasId(), platform.handle, 1, EmscriptenFocusCallback);
// Support visibility events
emscripten_set_visibilitychange_callback(NULL, 1, EmscriptenVisibilityChangeCallback);
//----------------------------------------------------------------------------
// Initialize timing system
@ -1758,6 +1763,13 @@ static EM_BOOL EmscriptenFocusCallback(int eventType, const EmscriptenFocusEvent
return consumed;
}
static EM_BOOL EmscriptenVisibilityChangeCallback(int eventType, const EmscriptenVisibilityChangeEvent *visibilityChangeEvent, void *userData)
{
if (visibilityChangeEvent->hidden) CORE.Window.flags |= FLAG_WINDOW_HIDDEN; // The window was hidden
else CORE.Window.flags &= ~FLAG_WINDOW_HIDDEN; // The window was restored
return 1; // The event was consumed by the callback handler
}
// Register touch input events
static EM_BOOL EmscriptenTouchCallback(int eventType, const EmscriptenTouchEvent *touchEvent, void *userData)
{

||||||
x
 
000:0
Loading…
取消
儲存