135c4bbdfSmrg/*
235c4bbdfSmrg  Permission is hereby granted, free of charge, to any person obtaining a
335c4bbdfSmrg  copy of this software and associated documentation files (the "Software"),
435c4bbdfSmrg  to deal in the Software without restriction, including without limitation
535c4bbdfSmrg  the rights to use, copy, modify, merge, publish, distribute, sublicense,
635c4bbdfSmrg  and/or sell copies of the Software, and to permit persons to whom the
735c4bbdfSmrg  Software is furnished to do so, subject to the following conditions:
835c4bbdfSmrg
935c4bbdfSmrg  The above copyright notice and this permission notice (including the next
1035c4bbdfSmrg  paragraph) shall be included in all copies or substantial portions of the
1135c4bbdfSmrg  Software.
1235c4bbdfSmrg
1335c4bbdfSmrg  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1435c4bbdfSmrg  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1535c4bbdfSmrg  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
1635c4bbdfSmrg  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1735c4bbdfSmrg  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
1835c4bbdfSmrg  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
1935c4bbdfSmrg  DEALINGS IN THE SOFTWARE.
2035c4bbdfSmrg*/
2135c4bbdfSmrg
2235c4bbdfSmrg#ifdef HAVE_XWIN_CONFIG_H
2335c4bbdfSmrg#include <xwin-config.h>
2435c4bbdfSmrg#endif
2535c4bbdfSmrg
2635c4bbdfSmrg#include "win.h"
2735c4bbdfSmrg#include "winwindow.h"
2835c4bbdfSmrg
2935c4bbdfSmrgconst GUID CLSID_TaskbarList = {0x56fdf344,0xfd6d,0x11d0,{0x95,0x8a,0x0,0x60,0x97,0xc9,0xa0,0x90}};
3035c4bbdfSmrgconst GUID IID_ITaskbarList =  {0x56fdf342,0xfd6d,0x11d0,{0x95,0x8a,0x0,0x60,0x97,0xc9,0xa0,0x90}};
3135c4bbdfSmrg
3235c4bbdfSmrg#ifdef INTERFACE
3335c4bbdfSmrg#undef INTERFACE
3435c4bbdfSmrg#endif
3535c4bbdfSmrg
3635c4bbdfSmrg#define INTERFACE ITaskbarList
3735c4bbdfSmrgDECLARE_INTERFACE_(ITaskbarList, IUnknown)
3835c4bbdfSmrg{
3935c4bbdfSmrg  /* IUnknown methods */
4035c4bbdfSmrg  STDMETHOD(QueryInterface) (THIS_ REFIID riid, void **ppv) PURE;
4135c4bbdfSmrg  STDMETHOD_(ULONG, AddRef) (THIS) PURE;
4235c4bbdfSmrg  STDMETHOD_(ULONG, Release) (THIS) PURE;
4335c4bbdfSmrg
4435c4bbdfSmrg  /* ITaskbarList methods */
4535c4bbdfSmrg  STDMETHOD(HrInit) (THIS) PURE;
4635c4bbdfSmrg  STDMETHOD(AddTab) (THIS_ HWND hWnd) PURE;
4735c4bbdfSmrg  STDMETHOD(DeleteTab) (THIS_ HWND hWnd) PURE;
4835c4bbdfSmrg  STDMETHOD(ActivateTab) (THIS_ HWND hWnd) PURE;
4935c4bbdfSmrg  STDMETHOD(SetActiveAlt) (THIS_ HWND hWnd) PURE;
5035c4bbdfSmrg};
5135c4bbdfSmrg#undef INTERFACE
5235c4bbdfSmrg
5335c4bbdfSmrg/*
5435c4bbdfSmrg   The stuff above needs to be in win32api headers, not defined here,
5535c4bbdfSmrg   or at least generated from the MIDL :-)
5635c4bbdfSmrg*/
5735c4bbdfSmrg
5835c4bbdfSmrg/*
5935c4bbdfSmrg  This is unnecessarily heavyweight, we could just call CoInitialize() once at
6035c4bbdfSmrg   startup and CoUninitialize() once at shutdown
6135c4bbdfSmrg*/
6235c4bbdfSmrg
6335c4bbdfSmrg/*
6435c4bbdfSmrg  The documentation for ITaskbarList::AddTab says that we are responsible for
6535c4bbdfSmrg   deleting the tab ourselves when the window is deleted, but that doesn't actually
6635c4bbdfSmrg   seem to be the case
6735c4bbdfSmrg*/
6835c4bbdfSmrg
691b5d61b8Smrgvoid winShowWindowOnTaskbar(HWND hWnd, Bool show)
7035c4bbdfSmrg{
7135c4bbdfSmrg  ITaskbarList* pTaskbarList = NULL;
7235c4bbdfSmrg
7335c4bbdfSmrg  if (SUCCEEDED(CoInitialize(NULL)))
7435c4bbdfSmrg    {
7535c4bbdfSmrg      if (SUCCEEDED(CoCreateInstance((const CLSID *)&CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, (const IID *)&IID_ITaskbarList, (void**)&pTaskbarList)))
7635c4bbdfSmrg        {
7735c4bbdfSmrg          if (SUCCEEDED(pTaskbarList->lpVtbl->HrInit(pTaskbarList)))
7835c4bbdfSmrg            {
7935c4bbdfSmrg              if (show)
8035c4bbdfSmrg                {
8135c4bbdfSmrg                  pTaskbarList->lpVtbl->AddTab(pTaskbarList,hWnd);
8235c4bbdfSmrg                }
8335c4bbdfSmrg              else
8435c4bbdfSmrg                {
8535c4bbdfSmrg                  pTaskbarList->lpVtbl->DeleteTab(pTaskbarList,hWnd);
8635c4bbdfSmrg                }
8735c4bbdfSmrg            }
8835c4bbdfSmrg          pTaskbarList->lpVtbl->Release(pTaskbarList);
8935c4bbdfSmrg        }
9035c4bbdfSmrg      CoUninitialize();
9135c4bbdfSmrg    }
9235c4bbdfSmrg}
93