From 50ba484893e9ab251187adf925da688ff74fc052 Mon Sep 17 00:00:00 2001
From: zilmar <zilmar@pj64-emu.com>
Date: Thu, 29 Nov 2012 08:22:06 +1100
Subject: [PATCH] Clean up code related to making window focus on run

---
 Source/Project64/N64 System/N64 Class.cpp          |  2 ++
 Source/Project64/User Interface/Gui Class.cpp      | 11 ++++++++---
 Source/Project64/User Interface/Gui Class.h        | 14 +++++++-------
 .../Project64/User Interface/Rom Browser Class.cpp |  3 +--
 4 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/Source/Project64/N64 System/N64 Class.cpp b/Source/Project64/N64 System/N64 Class.cpp
index ebbfd416e..f15d4d293 100644
--- a/Source/Project64/N64 System/N64 Class.cpp	
+++ b/Source/Project64/N64 System/N64 Class.cpp	
@@ -809,6 +809,8 @@ void CN64System::ExecuteSyncCPU ()
 	m_SyncCPU = new CN64System(&SyncPlugins, true);
 	m_Recomp = new CRecompiler(m_Profile,m_EndEmulation);
 
+	g_Notify->BringToTop();
+
 	SetActiveSystem();
 	if (m_SyncCPU->SetActiveSystem())
 	{
diff --git a/Source/Project64/User Interface/Gui Class.cpp b/Source/Project64/User Interface/Gui Class.cpp
index 25c8c241d..d7c367785 100644
--- a/Source/Project64/User Interface/Gui Class.cpp	
+++ b/Source/Project64/User Interface/Gui Class.cpp	
@@ -391,8 +391,8 @@ void CMainGui::SetWindowMenu (CBaseMenu * Menu) {
 	}
 }
 
-void CMainGui::RefreshMenu (void) {
-	CGuard Guard(m_CS);
+void CMainGui::RefreshMenu (void)
+{
 	if (!m_Menu) { return; }
 	m_Menu->ResetMenu();
 }
@@ -712,7 +712,12 @@ DWORD CALLBACK CMainGui::MainGui_Proc (WND_HANDLE hWnd, DWORD uMsg, DWORD wParam
 			while (ShowCursor(TRUE) < 0) { Sleep(0); }
 		}
 		break;
-	case WM_MAKE_FOCUS:  SetFocus((HWND)hWnd); break;
+	case WM_MAKE_FOCUS:
+		{
+			CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class");
+			_this->BringToTop();
+		}
+		break;
 	case WM_BORWSER_TOP:
 		{
 			CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class");
diff --git a/Source/Project64/User Interface/Gui Class.h b/Source/Project64/User Interface/Gui Class.h
index 049d088dc..661d8f925 100644
--- a/Source/Project64/User Interface/Gui Class.h	
+++ b/Source/Project64/User Interface/Gui Class.h	
@@ -6,6 +6,13 @@ class CN64System;
 class CNotification;
 class CriticalSection;
 
+enum { 
+	WM_HIDE_CUROSR   = WM_USER + 10,
+	WM_MAKE_FOCUS    = WM_USER + 17,
+	WM_INIATE_PLUGIN = WM_USER + 18,
+	WM_BORWSER_TOP   = WM_USER + 40,
+};
+
 class CMainGui :
 	public CRomBrowser,
 	private CGuiSettings
@@ -18,13 +25,6 @@ class CMainGui :
 		
 	enum { StatusBarID = 400 };
 	
-	enum { 
-		WM_HIDE_CUROSR   = WM_USER + 10,
-		WM_MAKE_FOCUS    = WM_USER + 17,
-		WM_INIATE_PLUGIN = WM_USER + 18,
-		WM_BORWSER_TOP   = WM_USER + 40,
-	};
-
 	WND_HANDLE  m_hMainWindow, m_hStatusWnd;
 	bool        m_hacked;
 	const bool  m_bMainWindow;
diff --git a/Source/Project64/User Interface/Rom Browser Class.cpp b/Source/Project64/User Interface/Rom Browser Class.cpp
index 6693b7098..1726881d6 100644
--- a/Source/Project64/User Interface/Rom Browser Class.cpp	
+++ b/Source/Project64/User Interface/Rom Browser Class.cpp	
@@ -1640,8 +1640,7 @@ void CRomBrowser::HideRomList (void) {
 	//Make the main window visible again
 	ShowWindow((HWND)m_MainWindow,SW_SHOW);
 	BringWindowToTop((HWND)m_MainWindow);
-	PostMessage((HWND)m_MainWindow, WM_USER + 17, 0,0 );
-
+	PostMessage((HWND)m_MainWindow, WM_MAKE_FOCUS, 0,0 );
 }
 
 bool CRomBrowser::RomDirNeedsRefresh ( void )