mirror of
https://github.com/WiVRn/WiVRn.git
synced 2026-11-21 09:31:33 -08:00
Stop sending mDNS queries when the application loses focus
This commit is contained in:
1 parent
1e1d51cc04
commit
2d44bba88b
4 files changed
+22
-5
No files matched your search
@@ -1327,6 +1327,9 @@ void application::session_state_changed(XrSessionState new_state, XrTime timesta
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (std::shared_ptr<scene> s = current_scene())
|
||||
s->on_session_state_changed(new_state);
|
||||
}
|
||||
|
||||
void application::interaction_profile_changed()
|
||||
@@ -1372,11 +1375,11 @@ void application::interaction_profile_changed()
|
||||
}
|
||||
}
|
||||
|
||||
if (current_scene())
|
||||
if (std::shared_ptr<scene> s = current_scene())
|
||||
{
|
||||
spdlog::info("Actions for current scene ({}):", current_scene()->current_meta.name);
|
||||
s->on_interaction_profile_changed();
|
||||
|
||||
for(auto& [name, action_and_type]: current_scene()->current_meta.actions_by_name)
|
||||
for(auto& [name, action_and_type]: s->current_meta.actions_by_name)
|
||||
{
|
||||
auto [action, type] = action_and_type;
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
#ifdef __ANDROID__
|
||||
#include <android_native_app_glue.h>
|
||||
#endif
|
||||
@@ -27,6 +26,7 @@
|
||||
#include "xr/xr.h"
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <filesystem>
|
||||
#include <mutex>
|
||||
#include <unordered_set>
|
||||
|
||||
+14
-1
@@ -404,6 +404,14 @@ static glm::mat4 view_matrix(XrPosef pose)
|
||||
|
||||
void scenes::lobby::update_server_list()
|
||||
{
|
||||
if (application::is_focused() && !discover)
|
||||
discover.emplace();
|
||||
else if (!application::is_focused() && discover)
|
||||
discover.reset();
|
||||
|
||||
if (!discover)
|
||||
return;
|
||||
|
||||
std::vector<wivrn_discover::service> discovered_services = discover->get_services();
|
||||
|
||||
// TODO: only if discovered_services changed
|
||||
@@ -599,7 +607,6 @@ void scenes::lobby::render(XrTime predicted_display_time, bool should_render)
|
||||
|
||||
void scenes::lobby::on_focused()
|
||||
{
|
||||
discover.emplace(discover_service);
|
||||
move_gui_first_time = true;
|
||||
|
||||
auto views = system.view_configuration_views(viewconfig);
|
||||
@@ -681,6 +688,12 @@ void scenes::lobby::on_unfocused()
|
||||
swapchain_imgui.reset();
|
||||
}
|
||||
|
||||
void scenes::lobby::on_session_state_changed(XrSessionState state)
|
||||
{
|
||||
if (state == XR_SESSION_STATE_STOPPING)
|
||||
discover.reset();
|
||||
}
|
||||
|
||||
scene::meta& scenes::lobby::get_meta_scene()
|
||||
{
|
||||
static meta m{
|
||||
|
||||
@@ -131,6 +131,7 @@ public:
|
||||
void render(XrTime predicted_display_time, bool should_render) override;
|
||||
void on_unfocused() override;
|
||||
void on_focused() override;
|
||||
void on_session_state_changed(XrSessionState state) override;
|
||||
|
||||
static meta& get_meta_scene();
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user