aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/hle/service/am/window_system.h
diff options
context:
space:
mode:
authoryuzubot <[email protected]>2024-03-04 13:02:54 +0000
committeryuzubot <[email protected]>2024-03-04 13:02:54 +0000
commit537296095ab24eddcb196b5ef98004f91de9c8c2 (patch)
treee75e9e2441dc3f8657cc42f2daaae08737949c2b /src/core/hle/service/am/window_system.h
parent2ddac7b02b660bbc7bdfe4fef240699df6d52e64 (diff)
downloadyuzu-mainline-master.tar.gz
yuzu-mainline-master.zip
"Merge Tagged PR 13018"HEADmaster
Diffstat (limited to 'src/core/hle/service/am/window_system.h')
-rw-r--r--src/core/hle/service/am/window_system.h83
1 files changed, 83 insertions, 0 deletions
diff --git a/src/core/hle/service/am/window_system.h b/src/core/hle/service/am/window_system.h
new file mode 100644
index 000000000..69e7a27ba
--- /dev/null
+++ b/src/core/hle/service/am/window_system.h
@@ -0,0 +1,83 @@
+// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include <map>
+#include <memory>
+#include <mutex>
+
+#include "common/common_types.h"
+
+namespace Core {
+class System;
+}
+
+namespace Service::AM {
+
+struct Applet;
+class EventObserver;
+
+enum class ButtonPressDuration {
+ ShortPressing,
+ MiddlePressing,
+ LongPressing,
+};
+
+class WindowSystem {
+public:
+ explicit WindowSystem(Core::System& system);
+ ~WindowSystem();
+
+public:
+ void SetEventObserver(EventObserver* event_observer);
+ void Update();
+
+public:
+ void TrackApplet(std::shared_ptr<Applet> applet, bool is_application);
+ std::shared_ptr<Applet> GetByAppletResourceUserId(u64 aruid);
+ std::shared_ptr<Applet> GetMainApplet();
+
+public:
+ void RequestHomeMenuToGetForeground();
+ void RequestApplicationToGetForeground();
+ void RequestLockHomeMenuIntoForeground();
+ void RequestUnlockHomeMenuIntoForeground();
+ void RequestAppletVisibilityState(Applet& applet, bool visible);
+
+public:
+ void OnOperationModeChanged();
+ void OnExitRequested();
+ void OnHomeButtonPressed(ButtonPressDuration type);
+ void OnCaptureButtonPressed(ButtonPressDuration type) {}
+ void OnPowerButtonPressed(ButtonPressDuration type) {}
+
+private:
+ void PruneTerminatedAppletsLocked();
+ bool LockHomeMenuIntoForegroundLocked();
+ void TerminateChildAppletsLocked(Applet* applet);
+ void UpdateAppletStateLocked(Applet* applet, bool is_foreground);
+
+private:
+ // System reference.
+ Core::System& m_system;
+
+ // Event observer.
+ EventObserver* m_event_observer{};
+
+ // Lock.
+ std::mutex m_lock{};
+
+ // Home menu state.
+ bool m_home_menu_foreground_locked{};
+ Applet* m_foreground_requested_applet{};
+
+ // Foreground roots.
+ Applet* m_home_menu{};
+ Applet* m_application{};
+
+ // Applet map by aruid.
+ std::map<u64, std::shared_ptr<Applet>> m_applets{};
+};
+
+} // namespace Service::AM