mirror of
https://github.com/libretro/ppsspp.git
synced 2025-01-23 17:45:04 +00:00
Make the emuthread idle when minimized on Windows.
This commit is contained in:
parent
38609f3e6b
commit
3cdf53732b
@ -47,6 +47,7 @@ static event m_hInactiveEvent;
|
||||
static recursive_mutex m_hInactiveMutex;
|
||||
static bool singleStepPending = false;
|
||||
static std::set<Core_ShutdownFunc> shutdownFuncs;
|
||||
static bool windowHidden = false;
|
||||
|
||||
#ifdef _WIN32
|
||||
InputState input_state;
|
||||
@ -54,6 +55,11 @@ InputState input_state;
|
||||
extern InputState input_state;
|
||||
#endif
|
||||
|
||||
void Core_NotifyWindowHidden(bool hidden) {
|
||||
windowHidden = hidden;
|
||||
// TODO: Wait until we can react?
|
||||
}
|
||||
|
||||
void Core_ListenShutdown(Core_ShutdownFunc func) {
|
||||
shutdownFuncs.insert(func);
|
||||
}
|
||||
@ -143,20 +149,24 @@ static inline void UpdateRunLoop() {
|
||||
|
||||
void Core_RunLoop() {
|
||||
while ((GetUIState() != UISTATE_INGAME || !PSP_IsInited()) && GetUIState() != UISTATE_EXIT) {
|
||||
time_update();
|
||||
|
||||
#if defined(USING_WIN_UI)
|
||||
time_update();
|
||||
double startTime = time_now_d();
|
||||
UpdateRunLoop();
|
||||
if (!windowHidden) {
|
||||
UpdateRunLoop();
|
||||
}
|
||||
|
||||
// Simple throttling to not burn the GPU in the menu.
|
||||
time_update();
|
||||
double diffTime = time_now_d() - startTime;
|
||||
int sleepTime = (int) (1000000.0 / 60.0) - (int) (diffTime * 1000000.0);
|
||||
int sleepTime = (int)(1000000.0 / 60.0) - (int)(diffTime * 1000000.0);
|
||||
if (sleepTime > 0)
|
||||
Sleep(sleepTime / 1000);
|
||||
GL_SwapBuffers();
|
||||
if (!windowHidden) {
|
||||
GL_SwapBuffers();
|
||||
}
|
||||
#else
|
||||
time_update();
|
||||
UpdateRunLoop();
|
||||
#endif
|
||||
}
|
||||
|
@ -42,3 +42,7 @@ void Core_WaitInactive();
|
||||
void Core_WaitInactive(int milliseconds);
|
||||
|
||||
void UpdateScreenScale(int width, int height);
|
||||
|
||||
// Don't run the core when minimized etc.
|
||||
void Core_NotifyWindowHidden(bool hidden);
|
||||
|
||||
|
@ -244,6 +244,7 @@ namespace MainWindow {
|
||||
}
|
||||
|
||||
void SetWindowSize(int zoom) {
|
||||
AssertCurrentThreadName("Main");
|
||||
RECT rc, rcOuter;
|
||||
GetWindowRectAtResolution(480 * (int)zoom, 272 * (int)zoom, rc, rcOuter);
|
||||
MoveWindow(hwndMain, rcOuter.left, rcOuter.top, rcOuter.right - rcOuter.left, rcOuter.bottom - rcOuter.top, TRUE);
|
||||
@ -913,8 +914,19 @@ namespace MainWindow {
|
||||
|
||||
switch (message) {
|
||||
case WM_SIZE:
|
||||
SavePosition();
|
||||
ResizeDisplay();
|
||||
switch (wParam) {
|
||||
case SIZE_MAXIMIZED:
|
||||
case SIZE_RESTORED:
|
||||
Core_NotifyWindowHidden(false);
|
||||
SavePosition();
|
||||
ResizeDisplay();
|
||||
break;
|
||||
case SIZE_MINIMIZED:
|
||||
Core_NotifyWindowHidden(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_GETMINMAXINFO:
|
||||
|
Loading…
x
Reference in New Issue
Block a user