summaryrefslogtreecommitdiff
path: root/platform/javascript
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-07-10 13:33:11 +0200
committerGitHub <noreply@github.com>2019-07-10 13:33:11 +0200
commit3e40827050d68679da44388ad87d97ae5665ab30 (patch)
tree559722c321ae4a5663eb121b768e5ce67d93b4ef /platform/javascript
parent6b6911cf11c279fc5133ffcb578e63168248af0d (diff)
parenta9a0d0fb15cc5e028dbf8dab8b46d3dc197c4678 (diff)
Merge pull request #30465 from guilhermefelipecgs/cursor_blinking
Fix cursor blinking in integrated GPUs
Diffstat (limited to 'platform/javascript')
-rw-r--r--platform/javascript/os_javascript.cpp17
-rw-r--r--platform/javascript/os_javascript.h1
2 files changed, 18 insertions, 0 deletions
diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp
index d96ffc3a55..5363cd4af7 100644
--- a/platform/javascript/os_javascript.cpp
+++ b/platform/javascript/os_javascript.cpp
@@ -448,6 +448,18 @@ void OS_JavaScript::set_cursor_shape(CursorShape p_shape) {
void OS_JavaScript::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) {
if (p_cursor.is_valid()) {
+
+ Map<CursorShape, Vector<Variant> >::Element *cursor_c = cursors_cache.find(p_shape);
+
+ if (cursor_c) {
+ if (cursor_c->get()[0] == p_cursor && cursor_c->get()[1] == p_hotspot) {
+ set_cursor_shape(p_shape);
+ return;
+ }
+
+ cursors_cache.erase(p_shape);
+ }
+
Ref<Texture> texture = p_cursor;
Ref<AtlasTexture> atlas_texture = p_cursor;
Ref<Image> image;
@@ -551,6 +563,11 @@ void OS_JavaScript::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_s
cursors[p_shape] = url;
+ Vector<Variant> params;
+ params.push_back(p_cursor);
+ params.push_back(p_hotspot);
+ cursors_cache.insert(p_shape, params);
+
} else if (cursors[p_shape] != "") {
/* clang-format off */
EM_ASM({
diff --git a/platform/javascript/os_javascript.h b/platform/javascript/os_javascript.h
index 9635465c0d..10676c49f7 100644
--- a/platform/javascript/os_javascript.h
+++ b/platform/javascript/os_javascript.h
@@ -52,6 +52,7 @@ class OS_JavaScript : public OS_Unix {
Ref<InputEventKey> deferred_key_event;
CursorShape cursor_shape;
String cursors[CURSOR_MAX];
+ Map<CursorShape, Vector<Variant> > cursors_cache;
Point2 touches[32];
Point2i last_click_pos;