mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
Windows: Refactor console positioning, moving the code out of EmuThread.cpp
This commit is contained in:
1 parent
1c918729d0
commit
fdf186e43b
4 files changed
+28
-14
No files matched your search
@@ -250,6 +250,7 @@ enum SystemProperty {
|
||||
SYSPROP_INSTALLER_NAME, // Useful on Android to check if we were installed from the play store.
|
||||
};
|
||||
|
||||
// NOTE: Unlike requests or UIMessage, these are synchronous!
|
||||
enum class SystemNotification {
|
||||
UI,
|
||||
MEM_VIEW,
|
||||
@@ -273,6 +274,8 @@ enum class SystemNotification {
|
||||
AUDIO_MODE_CHANGED,
|
||||
APP_SWITCH_MODE_CHANGED,
|
||||
PAD_STATE_CHANGED,
|
||||
CONFIG_LOADED,
|
||||
BEFORE_CONFIG_SAVE_ON_EXIT,
|
||||
};
|
||||
|
||||
// I guess it's not super great architecturally to centralize this, since it's not general - but same with a lot of
|
||||
|
||||
@@ -575,6 +575,7 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
|
||||
// Note that if we don't have storage permission here, loading the config will
|
||||
// fail and it will be set to the default. Later, we load again when we get permission.
|
||||
g_Config.Load();
|
||||
System_Notify(SystemNotification::CONFIG_LOADED);
|
||||
#endif
|
||||
|
||||
const char *fileToLog = nullptr;
|
||||
@@ -1708,6 +1709,8 @@ void NativeShutdown() {
|
||||
g_screenManager = nullptr;
|
||||
}
|
||||
|
||||
System_Notify(SystemNotification::BEFORE_CONFIG_SAVE_ON_EXIT);
|
||||
|
||||
g_Config.Save("NativeShutdown");
|
||||
|
||||
g_i18nrepo.LogMissingKeys();
|
||||
|
||||
@@ -54,9 +54,6 @@ static GraphicsContext *g_graphicsContext;
|
||||
|
||||
void MainThreadFunc();
|
||||
|
||||
// On most other platforms, we let the "main" thread become the render thread and
|
||||
// start a separate emu thread from that, if needed. Should probably switch to that
|
||||
// to make it the same on all platforms.
|
||||
void MainThread_Start(bool separateEmuThread) {
|
||||
useEmuThread = separateEmuThread;
|
||||
mainThread = std::thread(&MainThreadFunc);
|
||||
@@ -152,11 +149,6 @@ void MainThreadFunc() {
|
||||
// We'll start up a separate thread we'll call Emu
|
||||
SetCurrentThreadName(useEmuThread ? "RenderThread" : "EmuThread");
|
||||
|
||||
const HWND console = GetConsoleWindow();
|
||||
if (console && g_Config.iConsoleWindowX != -1 && g_Config.iConsoleWindowY != -1) {
|
||||
SetWindowPos(console, NULL, g_Config.iConsoleWindowX, g_Config.iConsoleWindowY, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
|
||||
}
|
||||
|
||||
System_SetWindowTitle("");
|
||||
|
||||
// We convert command line arguments to UTF-8 immediately.
|
||||
@@ -319,12 +311,6 @@ void MainThreadFunc() {
|
||||
delete g_graphicsContext;
|
||||
g_graphicsContext = nullptr;
|
||||
|
||||
RECT rc;
|
||||
if (console && GetWindowRect(console, &rc) && !IsIconic(console)) {
|
||||
g_Config.iConsoleWindowX = rc.left;
|
||||
g_Config.iConsoleWindowY = rc.top;
|
||||
}
|
||||
|
||||
NativeShutdown();
|
||||
|
||||
PostMessage(MainWindow::GetHWND(), MainWindow::WM_USER_UPDATE_UI, 0, 0);
|
||||
|
||||
@@ -594,6 +594,21 @@ void System_Notify(SystemNotification notification) {
|
||||
case SystemNotification::APP_SWITCH_MODE_CHANGED:
|
||||
case SystemNotification::UI_STATE_CHANGED:
|
||||
break;
|
||||
case SystemNotification::CONFIG_LOADED:
|
||||
{
|
||||
// This is too early to move the console into position - hasn't been allocated yet.
|
||||
break;
|
||||
}
|
||||
case SystemNotification::BEFORE_CONFIG_SAVE_ON_EXIT:
|
||||
{
|
||||
RECT rc{};
|
||||
const HWND console = GetConsoleWindow();
|
||||
if (console && GetWindowRect(console, &rc) && !IsIconic(console)) {
|
||||
g_Config.iConsoleWindowX = rc.left;
|
||||
g_Config.iConsoleWindowY = rc.top;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1088,6 +1103,7 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin
|
||||
// if it's not loaded here first.
|
||||
g_Config.SetSearchPath(GetSysDirectory(DIRECTORY_SYSTEM));
|
||||
g_Config.Load(configFilename.c_str(), controlsConfigFilename.c_str());
|
||||
System_Notify(SystemNotification::CONFIG_LOADED);
|
||||
|
||||
bool debugLogLevel = false;
|
||||
|
||||
@@ -1170,6 +1186,12 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin
|
||||
// - It should be possible to log to a file without showing the console.
|
||||
g_logManager.GetConsoleListener()->Init(showLog, 150, 120);
|
||||
|
||||
// Move the console into position.
|
||||
const HWND console = GetConsoleWindow();
|
||||
if (console && g_Config.iConsoleWindowX != -1 && g_Config.iConsoleWindowY != -1) {
|
||||
SetWindowPos(console, NULL, g_Config.iConsoleWindowX, g_Config.iConsoleWindowY, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
|
||||
}
|
||||
|
||||
if (debugLogLevel) {
|
||||
g_logManager.SetAllLogLevels(LogLevel::LDEBUG);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user