Implement HTML5 cancel/ok button swap on Windows.
Platform is detected on init via the `navigator.platform` string.
This commit is contained in:
parent
3e96ba220e
commit
0b286a287c
|
@ -831,6 +831,17 @@ DisplayServer *DisplayServerJavaScript::create_func(const String &p_rendering_dr
|
||||||
DisplayServerJavaScript::DisplayServerJavaScript(const String &p_rendering_driver, WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) {
|
DisplayServerJavaScript::DisplayServerJavaScript(const String &p_rendering_driver, WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) {
|
||||||
r_error = OK; // Always succeeds for now.
|
r_error = OK; // Always succeeds for now.
|
||||||
|
|
||||||
|
/* clang-format off */
|
||||||
|
swap_cancel_ok = EM_ASM_INT({
|
||||||
|
const win = (['Windows', 'Win64', 'Win32', 'WinCE']);
|
||||||
|
const plat = navigator.platform || "";
|
||||||
|
if (win.indexOf(plat) !== -1) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}) == 1;
|
||||||
|
/* clang-format on */
|
||||||
|
|
||||||
RasterizerDummy::make_current(); // TODO GLES2 in Godot 4.0... or webgpu?
|
RasterizerDummy::make_current(); // TODO GLES2 in Godot 4.0... or webgpu?
|
||||||
#if 0
|
#if 0
|
||||||
EmscriptenWebGLContextAttributes attributes;
|
EmscriptenWebGLContextAttributes attributes;
|
||||||
|
@ -1183,6 +1194,10 @@ int DisplayServerJavaScript::get_current_video_driver() const {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DisplayServerJavaScript::get_swap_cancel_ok() {
|
||||||
|
return swap_cancel_ok;
|
||||||
|
}
|
||||||
|
|
||||||
void DisplayServerJavaScript::swap_buffers() {
|
void DisplayServerJavaScript::swap_buffers() {
|
||||||
//emscripten_webgl_commit_frame();
|
//emscripten_webgl_commit_frame();
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,8 @@ class DisplayServerJavaScript : public DisplayServer {
|
||||||
int last_width = 0;
|
int last_width = 0;
|
||||||
int last_height = 0;
|
int last_height = 0;
|
||||||
|
|
||||||
|
bool swap_cancel_ok = false;
|
||||||
|
|
||||||
// utilities
|
// utilities
|
||||||
static Point2 compute_position_in_canvas(int p_x, int p_y);
|
static Point2 compute_position_in_canvas(int p_x, int p_y);
|
||||||
static void focus_canvas();
|
static void focus_canvas();
|
||||||
|
@ -195,6 +197,7 @@ public:
|
||||||
virtual void set_icon(const Ref<Image> &p_icon);
|
virtual void set_icon(const Ref<Image> &p_icon);
|
||||||
|
|
||||||
// others
|
// others
|
||||||
|
virtual bool get_swap_cancel_ok();
|
||||||
virtual void swap_buffers();
|
virtual void swap_buffers();
|
||||||
|
|
||||||
static void register_javascript_driver();
|
static void register_javascript_driver();
|
||||||
|
|
Loading…
Reference in New Issue