[EXPLORER]

* Remove internal IStartMenuSite interface that didn't serve any purpose.
* Stop using global instances of some core classes.

svn path=/trunk/; revision=65703
This commit is contained in:
Giannis Adamopoulos
2014-12-17 12:44:58 +00:00
parent 2d5024bcae
commit 59dee0fd6f
5 changed files with 49 additions and 82 deletions
+16 -21
View File
@@ -23,7 +23,6 @@
class CDesktopThread
{
HANDLE m_hEvent;
HANDLE m_hDesktop;
CComPtr<ITrayWindow> m_Tray;
DWORD DesktopThreadProc()
@@ -65,12 +64,11 @@ class CDesktopThread
public:
CDesktopThread() :
m_hEvent(NULL),
m_hDesktop(NULL),
m_Tray(NULL)
{
}
HANDLE Initialize(IN OUT ITrayWindow *pTray)
HRESULT Initialize(IN OUT ITrayWindow *pTray)
{
HANDLE hThread;
HANDLE Handles[2];
@@ -79,13 +77,13 @@ public:
m_hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
if (!m_hEvent)
return NULL;
return E_FAIL;
hThread = CreateThread(NULL, 0, s_DesktopThreadProc, (PVOID)this, 0, NULL);
if (!hThread)
{
CloseHandle(m_hEvent);
return NULL;
return E_FAIL;
}
Handles[0] = hThread;
@@ -107,36 +105,33 @@ public:
CloseHandle(hThread);
CloseHandle(m_hEvent);
// FIXME: Never assigned, will always return default value (NULL).
return m_hDesktop;
return S_OK;
}
void Destroy()
{
return;
}
} * g_pDesktopWindowInstance;
};
HANDLE
DesktopCreateWindow(IN OUT ITrayWindow *Tray)
{
if (!g_pDesktopWindowInstance)
{
g_pDesktopWindowInstance = new CDesktopThread();
}
if (!g_pDesktopWindowInstance)
return NULL;
CDesktopThread* pDesktopThread = new CDesktopThread();
return g_pDesktopWindowInstance->Initialize(Tray);
HRESULT hres = pDesktopThread->Initialize(Tray);
if(FAILED_UNEXPECTEDLY(hres))
{
delete pDesktopThread;
return NULL;
}
return pDesktopThread;
}
VOID
DesktopDestroyShellWindow(IN HANDLE hDesktop)
{
if (g_pDesktopWindowInstance)
{
g_pDesktopWindowInstance->Destroy();
}
CDesktopThread* pDesktopThread = reinterpret_cast<CDesktopThread*>(hDesktop);
pDesktopThread->Destroy();
}
+6 -29
View File
@@ -296,36 +296,12 @@ OUT HWND *phWndTaskSwitch);
HRESULT StartMenuBtnCtxMenuCreator(ITrayWindow * TrayWnd, IN HWND hWndOwner, IContextMenu ** ppCtxMenu);
#define INTERFACE IStartMenuSite
DECLARE_INTERFACE_(IStartMenuSite, IUnknown)
{
/*** IUnknown methods ***/
STDMETHOD_(HRESULT, QueryInterface) (THIS_ REFIID riid, void** ppvObject) PURE;
STDMETHOD_(ULONG, AddRef) (THIS) PURE;
STDMETHOD_(ULONG, Release) (THIS) PURE;
/*** IStartMenuSite ***/
};
#undef INTERFACE
#if defined(COBJMACROS)
/*** IUnknown methods ***/
#define IStartMenuSite_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IStartMenuSite_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IStartMenuSite_Release(p) (p)->lpVtbl->Release(p)
/*** IStartMenuSite methods ***/
#endif
IMenuPopup*
CreateStartMenu(IN ITrayWindow *Tray,
OUT IMenuBand **ppMenuBand,
IN HBITMAP hbmBanner OPTIONAL,
IN BOOL bSmallIcons);
HRESULT
UpdateStartMenu(IN OUT IMenuPopup *pMenuPopup,
IN HBITMAP hbmBanner OPTIONAL,
IN BOOL bSmallIcons);
/*
* startmnusite.cpp
*/
@@ -350,6 +326,8 @@ CreateStartMenuSite(IN OUT ITrayWindow *Tray, const IID & riid, PVOID * ppv);
#define NTNWM_REALIGN (0x1)
class CTrayNotifyWnd;
BOOL
RegisterTrayNotifyWndClass(VOID);
@@ -357,15 +335,14 @@ VOID
UnregisterTrayNotifyWndClass(VOID);
HWND
CreateTrayNotifyWnd(IN OUT ITrayWindow *TrayWindow,
IN BOOL bHideClock);
CreateTrayNotifyWnd(IN OUT ITrayWindow *TrayWindow, IN BOOL bHideClock, CTrayNotifyWnd** ppTrayNotify);
VOID
TrayNotify_NotifyMsg(IN WPARAM wParam,
TrayNotify_NotifyMsg(CTrayNotifyWnd* pTrayNotify, IN WPARAM wParam,
IN LPARAM lParam);
BOOL
TrayNotify_GetClockRect(OUT PRECT rcClock);
TrayNotify_GetClockRect(CTrayNotifyWnd* pTrayNotify, OUT PRECT rcClock);
/*
* taskswnd.c
@@ -385,7 +362,7 @@ CreateTaskSwitchWnd(IN HWND hWndParent,
IN OUT ITrayWindow *Tray);
HRESULT
Tray_OnStartMenuDismissed();
Tray_OnStartMenuDismissed(ITrayWindow* Tray);
HRESULT
IsSameObject(IN IUnknown *punk1, IN IUnknown *punk2);
+1 -6
View File
@@ -20,14 +20,9 @@
#include "precomp.h"
/*****************************************************************************
** IStartMenuSite ***********************************************************
*****************************************************************************/
class CStartMenuSite :
public CComCoClass<CStartMenuSite>,
public CComObjectRootEx<CComMultiThreadModelNoCS>,
public IStartMenuSite,
public IServiceProvider,
public ITrayPriv,
public IOleCommandTarget,
@@ -364,7 +359,7 @@ public:
{
if (!fSet)
{
return Tray_OnStartMenuDismissed();
return Tray_OnStartMenuDismissed(m_Tray);
}
return S_OK;
+8 -9
View File
@@ -1561,25 +1561,24 @@ public:
}
};
static CTrayNotifyWnd * g_Instance;
HWND CreateTrayNotifyWnd(IN OUT ITrayWindow *Tray, BOOL bHideClock)
HWND CreateTrayNotifyWnd(IN OUT ITrayWindow *Tray, BOOL bHideClock, CTrayNotifyWnd** ppinstance)
{
CTrayNotifyWnd * pTrayNotify = new CTrayNotifyWnd();
// TODO: Destroy after the window is destroyed
g_Instance = new CTrayNotifyWnd();
*ppinstance = pTrayNotify;
return g_Instance->_Init(Tray, bHideClock);
return pTrayNotify->_Init(Tray, bHideClock);
}
VOID
TrayNotify_NotifyMsg(WPARAM wParam, LPARAM lParam)
TrayNotify_NotifyMsg(CTrayNotifyWnd* pTrayNotify, WPARAM wParam, LPARAM lParam)
{
BOOL bDummy;
g_Instance->NotifyMsg(0, wParam, lParam, bDummy);
pTrayNotify->NotifyMsg(0, wParam, lParam, bDummy);
}
BOOL
TrayNotify_GetClockRect(OUT PRECT rcClock)
TrayNotify_GetClockRect(CTrayNotifyWnd* pTrayNotify, OUT PRECT rcClock)
{
return g_Instance->GetClockRect(rcClock);
return pTrayNotify->GetClockRect(rcClock);
}
+18 -17
View File
@@ -371,6 +371,8 @@ class CTrayWindow :
HWND m_TaskSwitch;
HWND m_TrayNotify;
CTrayNotifyWnd* m_TrayNotifyInstance;
DWORD m_Position;
HMONITOR m_Monitor;
HMONITOR m_PreviousMonitor;
@@ -1524,7 +1526,7 @@ ChangePos:
SetWindowTheme(m_Rebar, L"TaskBar", NULL);
/* Create the tray notification window */
m_TrayNotify = CreateTrayNotifyWnd(this, HideClock);
m_TrayNotify = CreateTrayNotifyWnd(this, HideClock, &m_TrayNotifyInstance);
if (UpdateNonClientMetrics())
{
@@ -2170,7 +2172,7 @@ ChangePos:
{
if (m_TrayNotify)
{
TrayNotify_NotifyMsg(wParam, lParam);
TrayNotify_NotifyMsg(m_TrayNotifyInstance, wParam, lParam);
}
return TRUE;
}
@@ -2541,7 +2543,7 @@ HandleTrayContextMenu:
/* We should forward mouse messages to child windows here.
Right now, this is only clock double-click */
RECT rcClock;
if (TrayNotify_GetClockRect(&rcClock))
if (TrayNotify_GetClockRect(m_TrayNotifyInstance, &rcClock))
{
POINT ptClick;
ptClick.x = MAKEPOINTS(lParam).x;
@@ -3091,15 +3093,6 @@ HRESULT TrayWindowCtxMenuCreator(ITrayWindow * TrayWnd, IN HWND hWndOwner, ICont
return S_OK;
}
CTrayWindow * g_TrayWindow;
HRESULT
Tray_OnStartMenuDismissed()
{
return g_TrayWindow->RaiseStartButton();
}
HRESULT CreateTrayWindow(ITrayWindow ** ppTray)
{
CComPtr<CTrayWindow> Tray = new CComObject<CTrayWindow>();
@@ -3108,19 +3101,27 @@ HRESULT CreateTrayWindow(ITrayWindow ** ppTray)
Tray->_Init();
Tray->Open();
g_TrayWindow = Tray;
*ppTray = (ITrayWindow *) Tray;
return S_OK;
}
VOID TrayProcessMessages(ITrayWindow *)
HRESULT
Tray_OnStartMenuDismissed(ITrayWindow* Tray)
{
g_TrayWindow->TrayProcessMessages();
CTrayWindow * TrayWindow = static_cast<CTrayWindow *>(Tray);
return TrayWindow->RaiseStartButton();
}
VOID TrayMessageLoop(ITrayWindow *)
VOID TrayProcessMessages(ITrayWindow *Tray)
{
g_TrayWindow->TrayMessageLoop();
CTrayWindow * TrayWindow = static_cast<CTrayWindow *>(Tray);
TrayWindow->TrayProcessMessages();
}
VOID TrayMessageLoop(ITrayWindow *Tray)
{
CTrayWindow * TrayWindow = static_cast<CTrayWindow *>(Tray);
TrayWindow->TrayMessageLoop();
}