소스 검색

Fix `IsWindowFocused()` on web. (#4640)

pull/4644/head
Mario Nachbaur 3 주 전
committed by GitHub
부모
커밋
7ecc47d12e
No known key found for this signature in database GPG 키 ID: B5690EEEBB952194
1개의 변경된 파일17개의 추가작업 그리고 0개의 파일을 삭제
  1. +17
    -0
      src/platforms/rcore_web.c

+ 17
- 0
src/platforms/rcore_web.c 파일 보기

@ -133,6 +133,7 @@ static void CursorEnterCallback(GLFWwindow *window, int enter);
static EM_BOOL EmscriptenFullscreenChangeCallback(int eventType, const EmscriptenFullscreenChangeEvent *event, void *userData);
// 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);
// Emscripten input callback events
static EM_BOOL EmscriptenMouseMoveCallback(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData);
@ -1369,6 +1370,10 @@ int InitPlatform(void)
// Support gamepad events (not provided by GLFW3 on emscripten)
emscripten_set_gamepadconnected_callback(NULL, 1, EmscriptenGamepadCallback);
emscripten_set_gamepaddisconnected_callback(NULL, 1, EmscriptenGamepadCallback);
// Support focus events
emscripten_set_blur_callback("#canvas", platform.handle, 1, EmscriptenFocusCallback);
emscripten_set_focus_callback("#canvas", platform.handle, 1, EmscriptenFocusCallback);
//----------------------------------------------------------------------------
// Initialize timing system
@ -1732,6 +1737,18 @@ static EM_BOOL EmscriptenGamepadCallback(int eventType, const EmscriptenGamepadE
return 1; // The event was consumed by the callback handler
}
static EM_BOOL EmscriptenFocusCallback(int eventType, const EmscriptenFocusEvent *focusEvent, void *userData)
{
EM_BOOL consumed = 1;
switch (eventType)
{
case EMSCRIPTEN_EVENT_BLUR: WindowFocusCallback(userData, 0); break;
case EMSCRIPTEN_EVENT_FOCUS: WindowFocusCallback(userData, 1); break;
default: consumed = 0; break;
}
return consumed;
}
// Register touch input events
static EM_BOOL EmscriptenTouchCallback(int eventType, const EmscriptenTouchEvent *touchEvent, void *userData)
{

불러오는 중...
취소
저장