diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-07-02 07:22:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-02 07:22:05 +0200 |
commit | 2da65347a0034d439e6d90b734517998ee011fc4 (patch) | |
tree | 5f3176229d9fd28d46498622eafd6ed98ec36036 | |
parent | b11da7b703931b0ade8181c5bae5e4b0a1c0b4d7 (diff) | |
parent | 0b7bc83fe3b110b0650f3285d92a7fb3b9816df1 (diff) |
Merge pull request #40030 from reduz/timeout-for-focusout-x11
Add a focus out timeout for X11 so less events of this type are received
-rw-r--r-- | platform/linuxbsd/display_server_x11.cpp | 14 | ||||
-rw-r--r-- | platform/linuxbsd/display_server_x11.h | 1 |
2 files changed, 11 insertions, 4 deletions
diff --git a/platform/linuxbsd/display_server_x11.cpp b/platform/linuxbsd/display_server_x11.cpp index cb4b0d745b..827d0361b9 100644 --- a/platform/linuxbsd/display_server_x11.cpp +++ b/platform/linuxbsd/display_server_x11.cpp @@ -2349,11 +2349,17 @@ void DisplayServerX11::process_events() { } if (!focus_found) { - if (OS::get_singleton()->get_main_loop()) { - OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_APPLICATION_FOCUS_OUT); - } + uint64_t delta = OS::get_singleton()->get_ticks_msec() - time_since_no_focus; - app_focused = false; + if (delta > 250) { + //X11 can go between windows and have no focus for a while, when creating them or something else. Use this as safety to avoid unnecesary focus in/outs. + if (OS::get_singleton()->get_main_loop()) { + OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_APPLICATION_FOCUS_OUT); + } + app_focused = false; + } + } else { + time_since_no_focus = OS::get_singleton()->get_ticks_msec(); } } diff --git a/platform/linuxbsd/display_server_x11.h b/platform/linuxbsd/display_server_x11.h index 3d0b2c7e8a..b5d2ea1c63 100644 --- a/platform/linuxbsd/display_server_x11.h +++ b/platform/linuxbsd/display_server_x11.h @@ -167,6 +167,7 @@ class DisplayServerX11 : public DisplayServer { int last_click_button_index; uint32_t last_button_state; bool app_focused = false; + uint64_t time_since_no_focus = 0; struct { int opcode; |