mirror of https://github.com/godotengine/godot
Add a focus out timeout for X11 to less events of this type are received
This commit is contained in:
parent
0a8dbe7f75
commit
0b7bc83fe3
|
|
@ -2349,11 +2349,17 @@ void DisplayServerX11::process_events() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!focus_found) {
|
if (!focus_found) {
|
||||||
if (OS::get_singleton()->get_main_loop()) {
|
uint64_t delta = OS::get_singleton()->get_ticks_msec() - time_since_no_focus;
|
||||||
OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_APPLICATION_FOCUS_OUT);
|
|
||||||
}
|
|
||||||
|
|
||||||
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -167,6 +167,7 @@ class DisplayServerX11 : public DisplayServer {
|
||||||
int last_click_button_index;
|
int last_click_button_index;
|
||||||
uint32_t last_button_state;
|
uint32_t last_button_state;
|
||||||
bool app_focused = false;
|
bool app_focused = false;
|
||||||
|
uint64_t time_since_no_focus = 0;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
int opcode;
|
int opcode;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue