You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-07 12:30:27 +00:00
[HTML5] Implement window blur in JS library.
Removes more emscripten HTML5 library dependencies.
This commit is contained in:
@@ -528,10 +528,8 @@ void DisplayServerJavaScript::virtual_keyboard_hide() {
|
|||||||
godot_js_display_vk_hide();
|
godot_js_display_vk_hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Window blur callback
|
void DisplayServerJavaScript::window_blur_callback() {
|
||||||
EM_BOOL DisplayServerJavaScript::blur_callback(int p_event_type, const EmscriptenFocusEvent *p_event, void *p_user_data) {
|
|
||||||
Input::get_singleton()->release_pressed_events();
|
Input::get_singleton()->release_pressed_events();
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gamepad
|
// Gamepad
|
||||||
@@ -716,28 +714,13 @@ DisplayServerJavaScript::DisplayServerJavaScript(const String &p_rendering_drive
|
|||||||
video_driver_index = p_video_driver;
|
video_driver_index = p_video_driver;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
EMSCRIPTEN_RESULT result;
|
|
||||||
#define EM_CHECK(ev) \
|
|
||||||
if (result != EMSCRIPTEN_RESULT_SUCCESS) \
|
|
||||||
ERR_PRINT("Error while setting " #ev " callback: Code " + itos(result));
|
|
||||||
#define SET_EM_CALLBACK(target, ev, cb) \
|
|
||||||
result = emscripten_set_##ev##_callback(target, nullptr, true, &cb); \
|
|
||||||
EM_CHECK(ev)
|
|
||||||
#define SET_EM_WINDOW_CALLBACK(ev, cb) \
|
|
||||||
result = emscripten_set_##ev##_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, nullptr, false, &cb); \
|
|
||||||
EM_CHECK(ev)
|
|
||||||
// These callbacks from Emscripten's html5.h suffice to access most
|
|
||||||
// JavaScript APIs.
|
|
||||||
SET_EM_WINDOW_CALLBACK(blur, blur_callback)
|
|
||||||
#undef SET_EM_CALLBACK
|
|
||||||
#undef EM_CHECK
|
|
||||||
|
|
||||||
godot_js_display_mouse_button_cb(&DisplayServerJavaScript::mouse_button_callback);
|
godot_js_display_mouse_button_cb(&DisplayServerJavaScript::mouse_button_callback);
|
||||||
godot_js_display_mouse_move_cb(&DisplayServerJavaScript::mouse_move_callback);
|
godot_js_display_mouse_move_cb(&DisplayServerJavaScript::mouse_move_callback);
|
||||||
godot_js_display_mouse_wheel_cb(&DisplayServerJavaScript::mouse_wheel_callback);
|
godot_js_display_mouse_wheel_cb(&DisplayServerJavaScript::mouse_wheel_callback);
|
||||||
godot_js_display_touch_cb(&DisplayServerJavaScript::touch_callback, touch_event.identifier, touch_event.coords);
|
godot_js_display_touch_cb(&DisplayServerJavaScript::touch_callback, touch_event.identifier, touch_event.coords);
|
||||||
godot_js_display_key_cb(&DisplayServerJavaScript::key_callback, key_event.code, key_event.key);
|
godot_js_display_key_cb(&DisplayServerJavaScript::key_callback, key_event.code, key_event.key);
|
||||||
godot_js_display_fullscreen_cb(&DisplayServerJavaScript::fullscreen_change_callback);
|
godot_js_display_fullscreen_cb(&DisplayServerJavaScript::fullscreen_change_callback);
|
||||||
|
godot_js_display_window_blur_cb(&window_blur_callback);
|
||||||
godot_js_display_notification_cb(&send_window_event_callback,
|
godot_js_display_notification_cb(&send_window_event_callback,
|
||||||
WINDOW_EVENT_MOUSE_ENTER,
|
WINDOW_EVENT_MOUSE_ENTER,
|
||||||
WINDOW_EVENT_MOUSE_EXIT,
|
WINDOW_EVENT_MOUSE_EXIT,
|
||||||
|
|||||||
@@ -85,9 +85,6 @@ private:
|
|||||||
static void touch_callback(int p_type, int p_count);
|
static void touch_callback(int p_type, int p_count);
|
||||||
static void key_callback(int p_pressed, int p_repeat, int p_modifiers);
|
static void key_callback(int p_pressed, int p_repeat, int p_modifiers);
|
||||||
static void vk_input_text_callback(const char *p_text, int p_cursor);
|
static void vk_input_text_callback(const char *p_text, int p_cursor);
|
||||||
|
|
||||||
static EM_BOOL blur_callback(int p_event_type, const EmscriptenFocusEvent *p_event, void *p_user_data);
|
|
||||||
|
|
||||||
static void gamepad_callback(int p_index, int p_connected, const char *p_id, const char *p_guid);
|
static void gamepad_callback(int p_index, int p_connected, const char *p_id, const char *p_guid);
|
||||||
void process_joypads();
|
void process_joypads();
|
||||||
|
|
||||||
@@ -97,6 +94,7 @@ private:
|
|||||||
static void _dispatch_input_event(const Ref<InputEvent> &p_event);
|
static void _dispatch_input_event(const Ref<InputEvent> &p_event);
|
||||||
|
|
||||||
static void request_quit_callback();
|
static void request_quit_callback();
|
||||||
|
static void window_blur_callback();
|
||||||
static void update_clipboard_callback(const char *p_text);
|
static void update_clipboard_callback(const char *p_text);
|
||||||
static void send_window_event_callback(int p_notification);
|
static void send_window_event_callback(int p_notification);
|
||||||
static void drop_files_js_callback(char **p_filev, int p_filec);
|
static void drop_files_js_callback(char **p_filev, int p_filec);
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ extern void godot_js_display_mouse_wheel_cb(int (*p_callback)(double p_delta_x,
|
|||||||
extern void godot_js_display_touch_cb(void (*p_callback)(int p_type, int p_count), uint32_t *r_identifiers, double *r_coords);
|
extern void godot_js_display_touch_cb(void (*p_callback)(int p_type, int p_count), uint32_t *r_identifiers, double *r_coords);
|
||||||
extern void godot_js_display_key_cb(void (*p_callback)(int p_type, int p_repeat, int p_modifiers), char r_code[32], char r_key[32]);
|
extern void godot_js_display_key_cb(void (*p_callback)(int p_type, int p_repeat, int p_modifiers), char r_code[32], char r_key[32]);
|
||||||
extern void godot_js_display_fullscreen_cb(void (*p_callback)(int p_fullscreen));
|
extern void godot_js_display_fullscreen_cb(void (*p_callback)(int p_fullscreen));
|
||||||
|
extern void godot_js_display_window_blur_cb(void (*p_callback)());
|
||||||
extern void godot_js_display_notification_cb(void (*p_callback)(int p_notification), int p_enter, int p_exit, int p_in, int p_out);
|
extern void godot_js_display_notification_cb(void (*p_callback)(int p_notification), int p_enter, int p_exit, int p_in, int p_out);
|
||||||
extern void godot_js_display_paste_cb(void (*p_callback)(const char *p_text));
|
extern void godot_js_display_paste_cb(void (*p_callback)(const char *p_text));
|
||||||
extern void godot_js_display_drop_files_cb(void (*p_callback)(char **p_filev, int p_filec));
|
extern void godot_js_display_drop_files_cb(void (*p_callback)(char **p_filev, int p_filec));
|
||||||
|
|||||||
@@ -867,6 +867,14 @@ const GodotDisplay = {
|
|||||||
GodotDisplayListeners.add(document, 'webkitfullscreenchange', change_cb, false);
|
GodotDisplayListeners.add(document, 'webkitfullscreenchange', change_cb, false);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
godot_js_display_window_blur_cb__sig: 'vi',
|
||||||
|
godot_js_display_window_blur_cb: function (callback) {
|
||||||
|
const func = GodotRuntime.get_func(callback);
|
||||||
|
GodotDisplayListeners.add(window, 'blur', function () {
|
||||||
|
func();
|
||||||
|
}, false);
|
||||||
|
},
|
||||||
|
|
||||||
godot_js_display_notification_cb__sig: 'viiiii',
|
godot_js_display_notification_cb__sig: 'viiiii',
|
||||||
godot_js_display_notification_cb: function (callback, p_enter, p_exit, p_in, p_out) {
|
godot_js_display_notification_cb: function (callback, p_enter, p_exit, p_in, p_out) {
|
||||||
const canvas = GodotConfig.canvas;
|
const canvas = GodotConfig.canvas;
|
||||||
|
|||||||
Reference in New Issue
Block a user