[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

svn path=/branches/shell-experiments/; revision=63304
This commit is contained in:
David Quintana 2014-05-15 13:23:06 +00:00
parent 753d2916b8
commit 9d30009eb1
7 changed files with 269 additions and 47 deletions

View file

@ -934,10 +934,10 @@ static VOID
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 @@ TaskSwitchWnd_CheckActivateTaskItem(IN OUT PTASK_SWITCH_WND This,
return;
}
if (ActiveTaskItem != NULL)
if (CurrentTaskItem != NULL)
{
PTASK_GROUP ActiveTaskGroup;
PTASK_GROUP CurrentTaskGroup;
if (ActiveTaskItem == TaskItem)
if (CurrentTaskItem == TaskItem)
return;
ActiveTaskGroup = ActiveTaskItem->Group;
CurrentTaskGroup = CurrentTaskItem->Group;
if (This->IsGroupingEnabled &&
ActiveTaskGroup != NULL &&
ActiveTaskGroup->IsCollapsed)
CurrentTaskGroup != NULL &&
CurrentTaskGroup->IsCollapsed)
{
if (ActiveTaskGroup == TaskGroup)
if (CurrentTaskGroup == TaskGroup)
return;
/* FIXME */
@ -971,10 +971,9 @@ TaskSwitchWnd_CheckActivateTaskItem(IN OUT PTASK_SWITCH_WND This,
else
{
This->ActiveTaskItem = NULL;
if (ActiveTaskItem->Index >= 0)
if (CurrentTaskItem->Index >= 0)
{
TaskSwitchWnd_UpdateTaskItemButton(This,
ActiveTaskItem);
TaskSwitchWnd_UpdateTaskItemButton(This, CurrentTaskItem);
}
}
}
@ -983,8 +982,11 @@ TaskSwitchWnd_CheckActivateTaskItem(IN OUT PTASK_SWITCH_WND This,
if (TaskItem != NULL && TaskItem->Index >= 0)
{
TaskSwitchWnd_UpdateTaskItemButton(This,
TaskItem);
TaskSwitchWnd_UpdateTaskItemButton(This, TaskItem);
}
else if (TaskItem == NULL)
{
DbgPrint("Active TaskItem now NULL\n");
}
}
@ -1031,6 +1033,9 @@ TaskSwitchWnd_AddTask(IN OUT PTASK_SWITCH_WND This,
{
PTASK_ITEM TaskItem;
if (!IsWindow(hWnd) || ITrayWindow_IsSpecialHWND(This->Tray, hWnd))
return FALSE;
TaskItem = TaskSwitchWnd_FindTaskItem(This,
hWnd);
if (TaskItem == NULL)
@ -1066,8 +1071,7 @@ TaskSwitchWnd_ActivateTaskItem(IN OUT PTASK_SWITCH_WND This,
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 @@ TaskSwitchWnd_ActivateTask(IN OUT PTASK_SWITCH_WND This,
{
PTASK_ITEM TaskItem;
if (!hWnd)
{
return TaskSwitchWnd_ActivateTaskItem(This, NULL);
}
TaskItem = TaskSwitchWnd_FindTaskItem(This,
hWnd);
if (TaskItem == NULL)
@ -1091,8 +1100,7 @@ TaskSwitchWnd_ActivateTask(IN OUT PTASK_SWITCH_WND This,
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 @@ TaskSwitchWnd_EnumWindowsProc(IN HWND hWnd,
/* 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 @@ TaskSwitchWnd_HandleShellHookMsg(IN OUT PTASK_SWITCH_WND This,
break;
case HSHELL_WINDOWCREATED:
TaskSwitchWnd_AddTask(This,
Ret = TaskSwitchWnd_AddTask(This,
(HWND)lParam);
Ret = TRUE;
break;
case HSHELL_WINDOWDESTROYED:
/* The window still exists! Delay destroying it a bit */
TaskSwitchWnd_DeleteTask(This,
(HWND)lParam);
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 @@ TaskSwitchWnd_HandleShellHookMsg(IN OUT PTASK_SWITCH_WND This,
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 @@ TaskSwitchWnd_HandleTaskItemClick(IN OUT PTASK_SWITCH_WND This,
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 @@ TaskSwitchWnd_HandleTaskItemClick(IN OUT PTASK_SWITCH_WND This,
WM_SYSCOMMAND,
SC_RESTORE,
0);
DbgPrint("Valid button clicked. App window Restored.\n");
}
SetForegroundWindow(TaskItem->hWnd);
DbgPrint("Valid button clicked. App window Activated.\n");
}
}
}

View file

@ -144,7 +144,7 @@ class CBandSite :
public:
DECLARE_REGISTRY_RESOURCEID(IDR_BANDSITE)
DECLARE_NOT_AGGREGATABLE(CBandSite)
DECLARE_AGGREGATABLE(CBandSite)
DECLARE_PROTECT_FINAL_CONSTRUCT()
};

View file

@ -294,8 +294,13 @@ BOOL WINAPI RegisterShellHook(
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;
}
/*************************************************************************

View file

@ -194,6 +194,205 @@ public:
};
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 @@ public:
hResult = E_OUTOFMEMORY;
newInstance = NULL;
ATLTRY(newInstance = new T1())
ATLTRY(newInstance = new T1(pv))
if (newInstance != NULL)
{
newInstance->SetVoid(pv);
@ -254,7 +453,7 @@ class CComCreator2
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 @@ public: \
#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: \

View file

@ -2428,7 +2428,10 @@ co_UserCreateWindowEx(CREATESTRUCTW* Cs,
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);
}

View file

@ -1881,7 +1881,10 @@ co_WinPosSetWindowPos(
}
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 );

View file

@ -1988,7 +1988,7 @@ UINT MenuDrawMenuBar( HDC hDC, LPRECT lprect, HWND hwnd,
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);