Focus an existing LOOT window on launch.

This is easiest if the LOOT window has a fixed title, so don't display
the current game there. This is OK, because there's no need to
differentiate between several windows, and the current game is displayed
in much larger type in the header bar just below.
This commit is contained in:
Oliver Hamlet
2015-02-01 15:24:32 +00:00
parent 15959c271d
commit 36a4e42140
3 changed files with 8 additions and 29 deletions
+5 -23
View File
@@ -119,11 +119,6 @@ namespace loot {
return true;
}
else if (request == "getGameData") {
BOOST_LOG_TRIVIAL(info) << "Setting LOOT window title bar text to include game name: " << g_app_state.CurrentGame().Name();
#ifdef _WIN32
HWND handle = browser->GetHost()->GetWindowHandle();
SetWindowText(handle, ToWinWide("LOOT: " + g_app_state.CurrentGame().Name()).c_str());
#endif
return CefPostTask(TID_FILE, base::Bind(&Handler::GetGameData, base::Unretained(this), frame, callback));
}
else if (request == "cancelFind") {
@@ -214,11 +209,6 @@ namespace loot {
// Has one arg, which is the folder name of the new game.
g_app_state.ChangeGame(request["args"][0].as<string>());
BOOST_LOG_TRIVIAL(info) << "Setting LOOT window title bar text to include game name: " << g_app_state.CurrentGame().Name();
#ifdef _WIN32
HWND handle = browser->GetHost()->GetWindowHandle();
SetWindowText(handle, ToWinWide("LOOT: " + g_app_state.CurrentGame().Name()).c_str());
#endif
CefPostTask(TID_FILE, base::Bind(&Handler::GetGameData, base::Unretained(this), frame, callback));
}
catch (loot::error &e) {
@@ -1072,25 +1062,13 @@ namespace loot {
return browser_side_router_->OnProcessMessageReceived(browser, source_process, message);
}
// CefDisplayHandler methods
//--------------------------
void LootHandler::OnTitleChange(CefRefPtr<CefBrowser> browser,
const CefString& title) {
assert(CefCurrentlyOn(TID_UI));
#ifdef _WIN32
HWND handle = browser->GetHost()->GetWindowHandle();
SetWindowText(handle, ToWinWide(title).c_str());
#endif
}
// CefLifeSpanHandler methods
//---------------------------
void LootHandler::OnAfterCreated(CefRefPtr<CefBrowser> browser) {
assert(CefCurrentlyOn(TID_UI));
#ifdef _WIN32
// Set the title bar icon.
HWND hWnd = browser->GetHost()->GetWindowHandle();
HANDLE hIcon = LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(MAINICON), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
@@ -1098,6 +1076,10 @@ namespace loot {
SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LPARAM)hIconSm);
// Set the window title.
SetWindowText(hWnd, L"LOOT");
#endif
// Set window size & position.
YAML::Node settings = g_app_state.GetSettings();
-5
View File
@@ -102,11 +102,6 @@ namespace loot {
CefProcessId source_process,
CefRefPtr<CefProcessMessage> message) OVERRIDE;
// CefDisplayHandler methods
//--------------------------
virtual void OnTitleChange(CefRefPtr<CefBrowser> browser,
const CefString& title) OVERRIDE;
// CefLifeSpanHandler methods
//---------------------------
virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) OVERRIDE;
+3 -1
View File
@@ -86,7 +86,9 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmd
HANDLE hMutex = ::OpenMutex(MUTEX_ALL_ACCESS, FALSE, L"LOOT.Shell.Instance");
if (hMutex != NULL) {
// An instance of LOOT is already running, so quit.
// An instance of LOOT is already running, so focus its window then quit.
HWND hWnd = ::FindWindow(NULL, L"LOOT");
::SetForegroundWindow(hWnd);
return 0;
}
else {