mirror of
https://github.com/moonlight-stream/moonlight-chrome.git
synced 2025-08-16 16:16:44 +00:00
Reduce usage of g_Instance
This commit is contained in:
parent
62df62f857
commit
be7f316c50
@ -30,7 +30,7 @@ void MoonlightInstance::DidLockMouse(int32_t result) {
|
||||
if (m_MouseLocked) {
|
||||
// Request an IDR frame to dump the frame queue that may have
|
||||
// built up from the GL pipeline being stalled.
|
||||
g_Instance->m_RequestIdrFrame = true;
|
||||
m_RequestIdrFrame = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,7 +75,7 @@ bool MoonlightInstance::HandleInputEvent(const pp::InputEvent& event) {
|
||||
case PP_INPUTEVENT_TYPE_MOUSEDOWN: {
|
||||
// Lock the mouse cursor when the user clicks on the stream
|
||||
if (!m_MouseLocked) {
|
||||
g_Instance->LockMouse(g_Instance->m_CallbackFactory.NewCallback(&MoonlightInstance::DidLockMouse));
|
||||
LockMouse(m_CallbackFactory.NewCallback(&MoonlightInstance::DidLockMouse));
|
||||
|
||||
// Assume it worked until we get a callback telling us otherwise
|
||||
m_MouseLocked = true;
|
||||
@ -173,7 +173,7 @@ bool MoonlightInstance::HandleInputEvent(const pp::InputEvent& event) {
|
||||
|
||||
// Check if all modifiers are up now
|
||||
if (m_WaitingForAllModifiersUp && m_KeyModifiers == 0) {
|
||||
g_Instance->UnlockMouse();
|
||||
UnlockMouse();
|
||||
m_MouseLocked = false;
|
||||
m_WaitingForAllModifiersUp = false;
|
||||
}
|
||||
|
19
main.cpp
19
main.cpp
@ -31,29 +31,30 @@ class MoonlightModule : public pp::Module {
|
||||
void MoonlightInstance::OnConnectionStarted(uint32_t unused) {
|
||||
// Tell the front end
|
||||
pp::Var response("Connection Established");
|
||||
g_Instance->PostMessage(response);
|
||||
PostMessage(response);
|
||||
|
||||
// Start receiving input events
|
||||
g_Instance->RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE);
|
||||
g_Instance->RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_WHEEL | PP_INPUTEVENT_CLASS_KEYBOARD);
|
||||
RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE);
|
||||
RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_WHEEL | PP_INPUTEVENT_CLASS_KEYBOARD);
|
||||
}
|
||||
|
||||
void MoonlightInstance::OnConnectionStopped(uint32_t error) {
|
||||
// Not running anymore
|
||||
g_Instance->m_Running = false;
|
||||
m_Running = false;
|
||||
|
||||
// Stop receiving input events
|
||||
g_Instance->ClearInputEventRequest(PP_INPUTEVENT_CLASS_MOUSE | PP_INPUTEVENT_CLASS_WHEEL | PP_INPUTEVENT_CLASS_KEYBOARD);
|
||||
ClearInputEventRequest(PP_INPUTEVENT_CLASS_MOUSE | PP_INPUTEVENT_CLASS_WHEEL | PP_INPUTEVENT_CLASS_KEYBOARD);
|
||||
|
||||
// Unlock the mouse
|
||||
g_Instance->UnlockMouse();
|
||||
UnlockMouse();
|
||||
|
||||
// Join threads
|
||||
pthread_join(g_Instance->m_ConnectionThread, NULL);
|
||||
pthread_join(g_Instance->m_GamepadThread, NULL);
|
||||
pthread_join(m_ConnectionThread, NULL);
|
||||
pthread_join(m_GamepadThread, NULL);
|
||||
|
||||
// Notify the JS code that the stream has ended
|
||||
pp::Var response(MSG_STREAM_TERMINATED);
|
||||
g_Instance->PostMessage(response);
|
||||
PostMessage(response);
|
||||
}
|
||||
|
||||
void MoonlightInstance::StopConnection() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user