diff --git a/src/gui/handler.cpp b/src/gui/handler.cpp index bf2842ac..738b1eaf 100644 --- a/src/gui/handler.cpp +++ b/src/gui/handler.cpp @@ -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()); - 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 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 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(); diff --git a/src/gui/handler.h b/src/gui/handler.h index e782099b..af0631f2 100644 --- a/src/gui/handler.h +++ b/src/gui/handler.h @@ -102,11 +102,6 @@ namespace loot { CefProcessId source_process, CefRefPtr message) OVERRIDE; - // CefDisplayHandler methods - //-------------------------- - virtual void OnTitleChange(CefRefPtr browser, - const CefString& title) OVERRIDE; - // CefLifeSpanHandler methods //--------------------------- virtual void OnAfterCreated(CefRefPtr browser) OVERRIDE; diff --git a/src/gui/main_win.cpp b/src/gui/main_win.cpp index e1060176..fe988e56 100644 --- a/src/gui/main_win.cpp +++ b/src/gui/main_win.cpp @@ -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 {