blob: 69e7a27ba56f80d664a14fe8cc0b427f4060ee50 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
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
|