Author: dquintana
Date: Thu May 15 13:23:06 2014
New Revision: 63304
URL:
http://svn.reactos.org/svn/reactos?rev=63304&view=rev
Log:
[EXPLORER-NEW]
* Fix handling of taskbar items.
* Filter out the desktop and taskbar from the button list.
* Fixes minimizing from the taskbar in Windows (something else is preventing it from
working in ros).
[NTUSER]
* Improve filtering of windows before calling HSHELL_WINDOWCREATED.
[USER32]
* Menus are supposed to be WS_EX_TOOLWINDOW so they don't show up in the taskbar.
[ATL]
[BROWSEUI]
[SHELL32]
* Include ATL aggregation patch by Huw (Frontier) (with Amine's changes).
CORE-8175
Modified:
branches/shell-experiments/base/shell/explorer-new/taskswnd.c
branches/shell-experiments/dll/win32/browseui/bandsite.h
branches/shell-experiments/dll/win32/shell32/shellord.cpp
branches/shell-experiments/lib/atl/atlcom.h
branches/shell-experiments/win32ss/user/ntuser/window.c
branches/shell-experiments/win32ss/user/ntuser/winpos.c
branches/shell-experiments/win32ss/user/user32/windows/menu.c
Modified: branches/shell-experiments/base/shell/explorer-new/taskswnd.c
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/ex…
==============================================================================
--- branches/shell-experiments/base/shell/explorer-new/taskswnd.c [iso-8859-1] (original)
+++ branches/shell-experiments/base/shell/explorer-new/taskswnd.c [iso-8859-1] Thu May 15
13:23:06 2014
@@ -934,10 +934,10 @@
TaskSwitchWnd_CheckActivateTaskItem(IN OUT PTASK_SWITCH_WND This,
IN OUT PTASK_ITEM TaskItem)
{
- PTASK_ITEM ActiveTaskItem;
+ PTASK_ITEM CurrentTaskItem;
PTASK_GROUP TaskGroup = NULL;
- ActiveTaskItem = This->ActiveTaskItem;
+ CurrentTaskItem = This->ActiveTaskItem;
if (TaskItem != NULL)
TaskGroup = TaskItem->Group;
@@ -950,20 +950,20 @@
return;
}
- if (ActiveTaskItem != NULL)
- {
- PTASK_GROUP ActiveTaskGroup;
-
- if (ActiveTaskItem == TaskItem)
+ if (CurrentTaskItem != NULL)
+ {
+ PTASK_GROUP CurrentTaskGroup;
+
+ if (CurrentTaskItem == TaskItem)
return;
- ActiveTaskGroup = ActiveTaskItem->Group;
+ CurrentTaskGroup = CurrentTaskItem->Group;
if (This->IsGroupingEnabled &&
- ActiveTaskGroup != NULL &&
- ActiveTaskGroup->IsCollapsed)
- {
- if (ActiveTaskGroup == TaskGroup)
+ CurrentTaskGroup != NULL &&
+ CurrentTaskGroup->IsCollapsed)
+ {
+ if (CurrentTaskGroup == TaskGroup)
return;
/* FIXME */
@@ -971,10 +971,9 @@
else
{
This->ActiveTaskItem = NULL;
- if (ActiveTaskItem->Index >= 0)
- {
- TaskSwitchWnd_UpdateTaskItemButton(This,
- ActiveTaskItem);
+ if (CurrentTaskItem->Index >= 0)
+ {
+ TaskSwitchWnd_UpdateTaskItemButton(This, CurrentTaskItem);
}
}
}
@@ -983,8 +982,11 @@
if (TaskItem != NULL && TaskItem->Index >= 0)
{
- TaskSwitchWnd_UpdateTaskItemButton(This,
- TaskItem);
+ TaskSwitchWnd_UpdateTaskItemButton(This, TaskItem);
+ }
+ else if (TaskItem == NULL)
+ {
+ DbgPrint("Active TaskItem now NULL\n");
}
}
@@ -1030,6 +1032,9 @@
IN HWND hWnd)
{
PTASK_ITEM TaskItem;
+
+ if (!IsWindow(hWnd) || ITrayWindow_IsSpecialHWND(This->Tray, hWnd))
+ return FALSE;
TaskItem = TaskSwitchWnd_FindTaskItem(This,
hWnd);
@@ -1066,8 +1071,7 @@
DbgPrint("Activate window 0x%p on button %d\n", TaskItem->hWnd,
TaskItem->Index);
}
- TaskSwitchWnd_CheckActivateTaskItem(This,
- TaskItem);
+ TaskSwitchWnd_CheckActivateTaskItem(This, TaskItem);
return FALSE;
}
@@ -1078,6 +1082,11 @@
{
PTASK_ITEM TaskItem;
+ if (!hWnd)
+ {
+ return TaskSwitchWnd_ActivateTaskItem(This, NULL);
+ }
+
TaskItem = TaskSwitchWnd_FindTaskItem(This,
hWnd);
if (TaskItem == NULL)
@@ -1091,8 +1100,7 @@
DbgPrint("Activate window 0x%p, could not find task\n", hWnd);
}
- return TaskSwitchWnd_ActivateTaskItem(This,
- TaskItem);
+ return TaskSwitchWnd_ActivateTaskItem(This, TaskItem);
}
static BOOL
@@ -1361,14 +1369,12 @@
/* Only show windows that still exist and are visible and none of explorer's
special windows (such as the desktop or the tray window) */
if (IsWindow(hWnd) && IsWindowVisible(hWnd) &&
- !ITrayWindow_IsSpecialHWND(This->Tray,
- hWnd))
- {
+ !ITrayWindow_IsSpecialHWND(This->Tray, hWnd))
+ {
+ DWORD exStyle = GetWindowLong(hWnd, GWL_EXSTYLE);
/* Don't list popup windows and also no tool windows */
- if (GetWindow(hWnd,
- GW_OWNER) == NULL &&
- !(GetWindowLong(hWnd,
- GWL_EXSTYLE) & WS_EX_TOOLWINDOW))
+ if ((GetWindow(hWnd, GW_OWNER) == NULL || exStyle & WS_EX_APPWINDOW)
&&
+ !(exStyle & WS_EX_TOOLWINDOW))
{
TaskSwitchWnd_AddTask(This,
hWnd);
@@ -1592,28 +1598,23 @@
break;
case HSHELL_WINDOWCREATED:
- TaskSwitchWnd_AddTask(This,
+ Ret = TaskSwitchWnd_AddTask(This,
(HWND)lParam);
+ break;
+
+ case HSHELL_WINDOWDESTROYED:
+ /* The window still exists! Delay destroying it a bit */
+ TaskSwitchWnd_DeleteTask(This, (HWND)lParam);
Ret = TRUE;
break;
- case HSHELL_WINDOWDESTROYED:
- /* The window still exists! Delay destroying it a bit */
- TaskSwitchWnd_DeleteTask(This,
- (HWND)lParam);
- Ret = TRUE;
- break;
-
- case HSHELL_ACTIVATESHELLWINDOW:
- goto UnhandledShellMessage;
-
case HSHELL_RUDEAPPACTIVATED:
- goto UnhandledShellMessage;
-
case HSHELL_WINDOWACTIVATED:
- TaskSwitchWnd_ActivateTask(This,
- (HWND)lParam);
- Ret = TRUE;
+ if (lParam)
+ {
+ TaskSwitchWnd_ActivateTask(This, (HWND) lParam);
+ Ret = TRUE;
+ }
break;
case HSHELL_GETMINRECT:
@@ -1635,6 +1636,7 @@
PostMessage(ITrayWindow_GetHWND(This->Tray), TWM_OPENSTARTMENU,0, 0);
break;
+ case HSHELL_ACTIVATESHELLWINDOW:
case HSHELL_LANGUAGE:
case HSHELL_SYSMENU:
case HSHELL_ENDTASK:
@@ -1708,12 +1710,20 @@
bIsMinimized = IsIconic(TaskItem->hWnd);
bIsActive = (TaskItem == This->ActiveTaskItem);
+ DbgPrint("Active TaskItem %p, selected TaskItem %p\n",
This->ActiveTaskItem, TaskItem);
+ if (This->ActiveTaskItem)
+ DbgPrint("Active TaskItem hWnd=%p, TaskItem hWnd %p\n",
This->ActiveTaskItem->hWnd, TaskItem->hWnd);
+
+ DbgPrint("Valid button clicked. HWND=%p, IsMinimized=%s,
IsActive=%s...\n",
+ TaskItem->hWnd, bIsMinimized ? "Yes" : "No", bIsActive
? "Yes" : "No");
+
if (!bIsMinimized && bIsActive)
{
PostMessage(TaskItem->hWnd,
WM_SYSCOMMAND,
SC_MINIMIZE,
0);
+ DbgPrint("Valid button clicked. App window Minimized.\n");
}
else
{
@@ -1723,9 +1733,11 @@
WM_SYSCOMMAND,
SC_RESTORE,
0);
+ DbgPrint("Valid button clicked. App window Restored.\n");
}
SetForegroundWindow(TaskItem->hWnd);
+ DbgPrint("Valid button clicked. App window Activated.\n");
}
}
}
Modified: branches/shell-experiments/dll/win32/browseui/bandsite.h
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/dll/win32/bro…
==============================================================================
--- branches/shell-experiments/dll/win32/browseui/bandsite.h [iso-8859-1] (original)
+++ branches/shell-experiments/dll/win32/browseui/bandsite.h [iso-8859-1] Thu May 15
13:23:06 2014
@@ -144,7 +144,7 @@
public:
DECLARE_REGISTRY_RESOURCEID(IDR_BANDSITE)
- DECLARE_NOT_AGGREGATABLE(CBandSite)
+ DECLARE_AGGREGATABLE(CBandSite)
DECLARE_PROTECT_FINAL_CONSTRUCT()
};
Modified: branches/shell-experiments/dll/win32/shell32/shellord.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/dll/win32/she…
==============================================================================
--- branches/shell-experiments/dll/win32/shell32/shellord.cpp [iso-8859-1] (original)
+++ branches/shell-experiments/dll/win32/shell32/shellord.cpp [iso-8859-1] Thu May 15
13:23:06 2014
@@ -294,8 +294,13 @@
HWND hWnd,
DWORD dwType)
{
- FIXME("(%p,0x%08x):stub.\n",hWnd, dwType);
- return TRUE;
+ if (dwType == 3)
+ return RegisterShellHookWindow(hWnd);
+ else if (dwType == 0)
+ return DeregisterShellHookWindow(hWnd);
+
+ ERR("Unsupported argument");
+ return FALSE;
}
/*************************************************************************
Modified: branches/shell-experiments/lib/atl/atlcom.h
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/lib/atl/atlco…
==============================================================================
--- branches/shell-experiments/lib/atl/atlcom.h [iso-8859-1] (original)
+++ branches/shell-experiments/lib/atl/atlcom.h [iso-8859-1] Thu May 15 13:23:06 2014
@@ -194,6 +194,205 @@
};
+template <class Base>
+class CComContainedObject : public Base
+{
+public:
+ IUnknown* m_pUnkOuter;
+ CComContainedObject(void * pv = NULL) : m_pUnkOuter(static_cast<IUnknown*>(pv))
+ {
+ }
+
+ STDMETHOD_(ULONG, AddRef)()
+ {
+ return m_pUnkOuter->AddRef();
+ }
+
+ STDMETHOD_(ULONG, Release)()
+ {
+ return m_pUnkOuter->Release();
+ }
+
+ STDMETHOD(QueryInterface)(REFIID iid, void **ppvObject)
+ {
+ return m_pUnkOuter->QueryInterface(iid, ppvObject);
+ }
+
+ IUnknown* GetControllingUnknown()
+ {
+ return m_pUnkOuter;
+ }
+};
+
+template <class contained>
+class CComAggObject : public contained
+{
+public:
+ CComContainedObject<contained> m_contained;
+
+ CComAggObject(void * pv = NULL) : m_contained(static_cast<contained*>(pv))
+ {
+ _pAtlModule->Lock();
+ }
+
+ virtual ~CComAggObject()
+ {
+ this->FinalRelease();
+ _pAtlModule->Unlock();
+ }
+
+ HRESULT FinalConstruct()
+ {
+ return m_contained.FinalConstruct();
+ }
+ void FinalRelease()
+ {
+ m_contained.FinalRelease();
+ }
+
+ STDMETHOD_(ULONG, AddRef)()
+ {
+ return this->InternalAddRef();
+ }
+
+ STDMETHOD_(ULONG, Release)()
+ {
+ ULONG newRefCount;
+ newRefCount = this->InternalRelease();
+ if (newRefCount == 0)
+ delete this;
+ return newRefCount;
+ }
+
+ STDMETHOD(QueryInterface)(REFIID iid, void **ppvObject)
+ {
+ if (ppvObject == NULL)
+ return E_POINTER;
+ if (iid == IID_IUnknown)
+ *ppvObject = reinterpret_cast<void*>(this);
+ else
+ return m_contained._InternalQueryInterface(iid, ppvObject);
+ return S_OK;
+ }
+
+ static HRESULT WINAPI CreateInstance(IUnknown * punkOuter,
CComAggObject<contained> **pp)
+ {
+ CComAggObject<contained> *newInstance;
+ HRESULT hResult;
+
+ ATLASSERT(pp != NULL);
+ if (pp == NULL)
+ return E_POINTER;
+
+ hResult = E_OUTOFMEMORY;
+ newInstance = NULL;
+ ATLTRY(newInstance = new CComAggObject<contained>(punkOuter))
+ if (newInstance != NULL)
+ {
+ newInstance->SetVoid(NULL);
+ newInstance->InternalFinalConstructAddRef();
+ hResult = newInstance->_AtlInitialConstruct();
+ if (SUCCEEDED(hResult))
+ hResult = newInstance->FinalConstruct();
+ if (SUCCEEDED(hResult))
+ hResult = newInstance->_AtlFinalConstruct();
+ newInstance->InternalFinalConstructRelease();
+ if (hResult != S_OK)
+ {
+ delete newInstance;
+ newInstance = NULL;
+ }
+ }
+ *pp = newInstance;
+ return hResult;
+ }
+};
+
+template <class contained>
+class CComPolyObject : public contained
+{
+public:
+ CComContainedObject<contained> m_contained;
+
+ CComPolyObject(void * pv = NULL)
+ : m_contained(pv ? static_cast<contained*>(pv) : this)
+ {
+ _pAtlModule->Lock();
+ }
+
+ virtual ~CComPolyObject()
+ {
+ this->FinalRelease();
+ _pAtlModule->Unlock();
+ }
+
+ HRESULT FinalConstruct()
+ {
+ return m_contained.FinalConstruct();
+ }
+ void FinalRelease()
+ {
+ m_contained.FinalRelease();
+ }
+
+ STDMETHOD_(ULONG, AddRef)()
+ {
+ return this->InternalAddRef();
+ }
+
+ STDMETHOD_(ULONG, Release)()
+ {
+ ULONG newRefCount;
+ newRefCount = this->InternalRelease();
+ if (newRefCount == 0)
+ delete this;
+ return newRefCount;
+ }
+
+ STDMETHOD(QueryInterface)(REFIID iid, void **ppvObject)
+ {
+ if (ppvObject == NULL)
+ return E_POINTER;
+ if (iid == IID_IUnknown)
+ *ppvObject = reinterpret_cast<void*>(this);
+ else
+ return m_contained._InternalQueryInterface(iid, ppvObject);
+ return S_OK;
+ }
+
+ static HRESULT WINAPI CreateInstance(IUnknown * punkOuter,
CComPolyObject<contained> **pp)
+ {
+ CComPolyObject<contained> *newInstance;
+ HRESULT hResult;
+
+ ATLASSERT(pp != NULL);
+ if (pp == NULL)
+ return E_POINTER;
+
+ hResult = E_OUTOFMEMORY;
+ newInstance = NULL;
+ ATLTRY(newInstance = new CComPolyObject<contained>(punkOuter))
+ if (newInstance != NULL)
+ {
+ newInstance->SetVoid(NULL);
+ newInstance->InternalFinalConstructAddRef();
+ hResult = newInstance->_AtlInitialConstruct();
+ if (SUCCEEDED(hResult))
+ hResult = newInstance->FinalConstruct();
+ if (SUCCEEDED(hResult))
+ hResult = newInstance->_AtlFinalConstruct();
+ newInstance->InternalFinalConstructRelease();
+ if (hResult != S_OK)
+ {
+ delete newInstance;
+ newInstance = NULL;
+ }
+ }
+ *pp = newInstance;
+ return hResult;
+ }
+};
+
template <HRESULT hResult>
class CComFailCreator
{
@@ -225,7 +424,7 @@
hResult = E_OUTOFMEMORY;
newInstance = NULL;
- ATLTRY(newInstance = new T1())
+ ATLTRY(newInstance = new T1(pv))
if (newInstance != NULL)
{
newInstance->SetVoid(pv);
@@ -254,7 +453,7 @@
public:
static HRESULT WINAPI CreateInstance(void *pv, REFIID riid, LPVOID *ppv)
{
- ATLASSERT(ppv != NULL && ppv != NULL);
+ ATLASSERT(ppv != NULL && riid != NULL);
if (pv == NULL)
return T1::CreateInstance(NULL, riid, ppv);
@@ -370,15 +569,15 @@
#define DECLARE_AGGREGATABLE(x) \
public: \
- typedef CComCreator2<CComCreator<CComObject<x> >,
CComCreator<CComAggObject<x> > > _CreatorClass;
+ typedef ATL::CComCreator2<ATL::CComCreator<ATL::CComObject<x> >,
ATL::CComCreator<ATL::CComAggObject<x> > > _CreatorClass;
#define DECLARE_ONLY_AGGREGATABLE(x) \
public: \
- typedef CComCreator2<CComFailCreator<E_FAIL>,
CComCreator<CComAggObject<x> > > _CreatorClass;
+ typedef ATL::CComCreator2<ATL::CComFailCreator<E_FAIL>,
ATL::CComCreator<ATL::CComAggObject<x> > > _CreatorClass;
#define DECLARE_POLY_AGGREGATABLE(x) \
public: \
- typedef CComCreator<CComPolyObject<x> > _CreatorClass;
+ typedef ATL::CComCreator<ATL::CComPolyObject<x> > _CreatorClass;
#define DECLARE_GET_CONTROLLING_UNKNOWN() \
public: \
Modified: branches/shell-experiments/win32ss/user/ntuser/window.c
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/win32ss/user/…
==============================================================================
--- branches/shell-experiments/win32ss/user/ntuser/window.c [iso-8859-1] (original)
+++ branches/shell-experiments/win32ss/user/ntuser/window.c [iso-8859-1] Thu May 15
13:23:06 2014
@@ -2428,7 +2428,10 @@
IntSendParentNotify(Window, WM_CREATE);
/* Notify the shell that a new window was created */
- if ((!hWndParent) && (!hWndOwner))
+ if ((!hWndParent) && (!hWndOwner) &&
+ Window->spwndOwner == NULL &&
+ !(Window->ExStyle & WS_EX_TOOLWINDOW) ||
+ (Window->ExStyle & WS_EX_APPWINDOW))
{
co_IntShellHookNotify(HSHELL_WINDOWCREATED, (WPARAM)hWnd, 0);
}
Modified: branches/shell-experiments/win32ss/user/ntuser/winpos.c
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/win32ss/user/…
==============================================================================
--- branches/shell-experiments/win32ss/user/ntuser/winpos.c [iso-8859-1] (original)
+++ branches/shell-experiments/win32ss/user/ntuser/winpos.c [iso-8859-1] Thu May 15
13:23:06 2014
@@ -1881,7 +1881,10 @@
}
else if (WinPos.flags & SWP_SHOWWINDOW)
{
- if (Window->spwndParent == UserGetDesktopWindow())
+ if (Window->spwndParent == UserGetDesktopWindow() &&
+ Window->spwndOwner == NULL &&
+ !(Window->ExStyle & WS_EX_TOOLWINDOW) ||
+ (Window->ExStyle & WS_EX_APPWINDOW))
co_IntShellHookNotify(HSHELL_WINDOWCREATED, (WPARAM)Window->head.h, 0);
Window->style |= WS_VISIBLE; //IntSetStyle( Window, WS_VISIBLE, 0 );
Modified: branches/shell-experiments/win32ss/user/user32/windows/menu.c
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/win32ss/user/…
==============================================================================
--- branches/shell-experiments/win32ss/user/user32/windows/menu.c [iso-8859-1] (original)
+++ branches/shell-experiments/win32ss/user/user32/windows/menu.c [iso-8859-1] Thu May 15
13:23:06 2014
@@ -1988,7 +1988,7 @@
static BOOL MENU_InitPopup( HWND hwndOwner, HMENU hmenu, UINT flags )
{
MENU *menu;
- DWORD ex_style = 0;
+ DWORD ex_style = WS_EX_TOOLWINDOW;
ROSMENUINFO MenuInfo;
TRACE("owner=%p hmenu=%p\n", hwndOwner, hmenu);