Author: gadamopoulos
Date: Wed Dec 17 12:44:58 2014
New Revision: 65703

URL: http://svn.reactos.org/svn/reactos?rev=65703&view=rev
Log:
[EXPLORER]
* Remove internal IStartMenuSite interface that didn't serve any purpose.
* Stop using global instances of some core classes.

Modified:
    trunk/reactos/base/shell/explorer/desktop.cpp
    trunk/reactos/base/shell/explorer/precomp.h
    trunk/reactos/base/shell/explorer/startmnusite.cpp
    trunk/reactos/base/shell/explorer/trayntfy.cpp
    trunk/reactos/base/shell/explorer/traywnd.cpp

Modified: trunk/reactos/base/shell/explorer/desktop.cpp
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer/desktop.cpp?rev=65703&r1=65702&r2=65703&view=diff
==============================================================================
--- trunk/reactos/base/shell/explorer/desktop.cpp       [iso-8859-1] (original)
+++ trunk/reactos/base/shell/explorer/desktop.cpp       [iso-8859-1] Wed Dec 17 
12:44:58 2014
@@ -23,7 +23,6 @@
 class CDesktopThread
 {
     HANDLE m_hEvent;
-    HANDLE m_hDesktop;
     CComPtr<ITrayWindow> m_Tray;
 
     DWORD DesktopThreadProc()
@@ -65,12 +64,11 @@
 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 @@
 
         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 @@
         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)
+    CDesktopThread* pDesktopThread = new CDesktopThread();
+
+    HRESULT hres = pDesktopThread->Initialize(Tray);
+    if(FAILED_UNEXPECTEDLY(hres))
     {
-        g_pDesktopWindowInstance = new CDesktopThread();
+        delete pDesktopThread;
+        return NULL;
     }
-    
-    if (!g_pDesktopWindowInstance)
-        return NULL;
 
-    return g_pDesktopWindowInstance->Initialize(Tray);
+    return pDesktopThread;
 }
 
 VOID
 DesktopDestroyShellWindow(IN HANDLE hDesktop)
 {
-    if (g_pDesktopWindowInstance)
-    {
-        g_pDesktopWindowInstance->Destroy();
-    }
+    CDesktopThread* pDesktopThread = 
reinterpret_cast<CDesktopThread*>(hDesktop);
+    pDesktopThread->Destroy();
 }

Modified: trunk/reactos/base/shell/explorer/precomp.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer/precomp.h?rev=65703&r1=65702&r2=65703&view=diff
==============================================================================
--- trunk/reactos/base/shell/explorer/precomp.h [iso-8859-1] (original)
+++ trunk/reactos/base/shell/explorer/precomp.h [iso-8859-1] Wed Dec 17 
12:44:58 2014
@@ -296,33 +296,9 @@
 
 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);
 
@@ -350,6 +326,8 @@
 
 #define NTNWM_REALIGN   (0x1)
 
+class CTrayNotifyWnd;
+
 BOOL
 RegisterTrayNotifyWndClass(VOID);
 
@@ -357,15 +335,14 @@
 UnregisterTrayNotifyWndClass(VOID);
 
 HWND
-CreateTrayNotifyWnd(IN OUT ITrayWindow *TrayWindow,
-IN BOOL bHideClock);
-
-VOID
-TrayNotify_NotifyMsg(IN WPARAM wParam,
+CreateTrayNotifyWnd(IN OUT ITrayWindow *TrayWindow, IN BOOL bHideClock, 
CTrayNotifyWnd** ppTrayNotify);
+
+VOID
+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 @@
 IN OUT ITrayWindow *Tray);
 
 HRESULT
-Tray_OnStartMenuDismissed();
+Tray_OnStartMenuDismissed(ITrayWindow* Tray);
 
 HRESULT
 IsSameObject(IN IUnknown *punk1, IN IUnknown *punk2);

Modified: trunk/reactos/base/shell/explorer/startmnusite.cpp
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer/startmnusite.cpp?rev=65703&r1=65702&r2=65703&view=diff
==============================================================================
--- trunk/reactos/base/shell/explorer/startmnusite.cpp  [iso-8859-1] (original)
+++ trunk/reactos/base/shell/explorer/startmnusite.cpp  [iso-8859-1] Wed Dec 17 
12:44:58 2014
@@ -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 @@
     {
         if (!fSet)
         {
-            return Tray_OnStartMenuDismissed();
+            return Tray_OnStartMenuDismissed(m_Tray);
         }
 
         return S_OK;

Modified: trunk/reactos/base/shell/explorer/trayntfy.cpp
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer/trayntfy.cpp?rev=65703&r1=65702&r2=65703&view=diff
==============================================================================
--- trunk/reactos/base/shell/explorer/trayntfy.cpp      [iso-8859-1] (original)
+++ trunk/reactos/base/shell/explorer/trayntfy.cpp      [iso-8859-1] Wed Dec 17 
12:44:58 2014
@@ -1561,25 +1561,24 @@
     }
 };
 
-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();
-
-    return g_Instance->_Init(Tray, bHideClock);
+    *ppinstance = pTrayNotify;
+
+    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);
 }

Modified: trunk/reactos/base/shell/explorer/traywnd.cpp
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer/traywnd.cpp?rev=65703&r1=65702&r2=65703&view=diff
==============================================================================
--- trunk/reactos/base/shell/explorer/traywnd.cpp       [iso-8859-1] (original)
+++ trunk/reactos/base/shell/explorer/traywnd.cpp       [iso-8859-1] Wed Dec 17 
12:44:58 2014
@@ -370,6 +370,8 @@
     HWND m_Rebar;
     HWND m_TaskSwitch;
     HWND m_TrayNotify;
+
+    CTrayNotifyWnd* m_TrayNotifyInstance;
 
     DWORD    m_Position;
     HMONITOR m_Monitor;
@@ -1524,7 +1526,7 @@
         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 @@
     {
         if (m_TrayNotify)
         {
-            TrayNotify_NotifyMsg(wParam, lParam);
+            TrayNotify_NotifyMsg(m_TrayNotifyInstance, wParam, lParam);
         }
         return TRUE;
     }
@@ -2541,7 +2543,7 @@
         /* 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 @@
     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 @@
 
     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();
+}


Reply via email to