xref: /OK3568_Linux_fs/external/xserver/hw/xwin/wintaskbar.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun   Permission is hereby granted, free of charge, to any person obtaining a
3*4882a593Smuzhiyun   copy of this software and associated documentation files (the "Software"),
4*4882a593Smuzhiyun   to deal in the Software without restriction, including without limitation
5*4882a593Smuzhiyun   the rights to use, copy, modify, merge, publish, distribute, sublicense,
6*4882a593Smuzhiyun   and/or sell copies of the Software, and to permit persons to whom the
7*4882a593Smuzhiyun   Software is furnished to do so, subject to the following conditions:
8*4882a593Smuzhiyun 
9*4882a593Smuzhiyun   The above copyright notice and this permission notice (including the next
10*4882a593Smuzhiyun   paragraph) shall be included in all copies or substantial portions of the
11*4882a593Smuzhiyun   Software.
12*4882a593Smuzhiyun 
13*4882a593Smuzhiyun   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14*4882a593Smuzhiyun   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15*4882a593Smuzhiyun   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
16*4882a593Smuzhiyun   THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17*4882a593Smuzhiyun   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18*4882a593Smuzhiyun   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19*4882a593Smuzhiyun   DEALINGS IN THE SOFTWARE.
20*4882a593Smuzhiyun */
21*4882a593Smuzhiyun 
22*4882a593Smuzhiyun #ifdef HAVE_XWIN_CONFIG_H
23*4882a593Smuzhiyun #include <xwin-config.h>
24*4882a593Smuzhiyun #endif
25*4882a593Smuzhiyun 
26*4882a593Smuzhiyun #include "win.h"
27*4882a593Smuzhiyun #include "winwindow.h"
28*4882a593Smuzhiyun 
29*4882a593Smuzhiyun const GUID CLSID_TaskbarList = {0x56fdf344,0xfd6d,0x11d0,{0x95,0x8a,0x0,0x60,0x97,0xc9,0xa0,0x90}};
30*4882a593Smuzhiyun const GUID IID_ITaskbarList =  {0x56fdf342,0xfd6d,0x11d0,{0x95,0x8a,0x0,0x60,0x97,0xc9,0xa0,0x90}};
31*4882a593Smuzhiyun 
32*4882a593Smuzhiyun #ifdef INTERFACE
33*4882a593Smuzhiyun #undef INTERFACE
34*4882a593Smuzhiyun #endif
35*4882a593Smuzhiyun 
36*4882a593Smuzhiyun #define INTERFACE ITaskbarList
DECLARE_INTERFACE_(ITaskbarList,IUnknown)37*4882a593Smuzhiyun DECLARE_INTERFACE_(ITaskbarList, IUnknown)
38*4882a593Smuzhiyun {
39*4882a593Smuzhiyun   /* IUnknown methods */
40*4882a593Smuzhiyun   STDMETHOD(QueryInterface) (THIS_ REFIID riid, void **ppv) PURE;
41*4882a593Smuzhiyun   STDMETHOD_(ULONG, AddRef) (THIS) PURE;
42*4882a593Smuzhiyun   STDMETHOD_(ULONG, Release) (THIS) PURE;
43*4882a593Smuzhiyun 
44*4882a593Smuzhiyun   /* ITaskbarList methods */
45*4882a593Smuzhiyun   STDMETHOD(HrInit) (THIS) PURE;
46*4882a593Smuzhiyun   STDMETHOD(AddTab) (THIS_ HWND hWnd) PURE;
47*4882a593Smuzhiyun   STDMETHOD(DeleteTab) (THIS_ HWND hWnd) PURE;
48*4882a593Smuzhiyun   STDMETHOD(ActivateTab) (THIS_ HWND hWnd) PURE;
49*4882a593Smuzhiyun   STDMETHOD(SetActiveAlt) (THIS_ HWND hWnd) PURE;
50*4882a593Smuzhiyun };
51*4882a593Smuzhiyun #undef INTERFACE
52*4882a593Smuzhiyun 
53*4882a593Smuzhiyun /*
54*4882a593Smuzhiyun    The stuff above needs to be in win32api headers, not defined here,
55*4882a593Smuzhiyun    or at least generated from the MIDL :-)
56*4882a593Smuzhiyun */
57*4882a593Smuzhiyun 
58*4882a593Smuzhiyun /*
59*4882a593Smuzhiyun   This is unnecessarily heavyweight, we could just call CoInitialize() once at
60*4882a593Smuzhiyun    startup and CoUninitialize() once at shutdown
61*4882a593Smuzhiyun */
62*4882a593Smuzhiyun 
63*4882a593Smuzhiyun /*
64*4882a593Smuzhiyun   The documentation for ITaskbarList::AddTab says that we are responsible for
65*4882a593Smuzhiyun    deleting the tab ourselves when the window is deleted, but that doesn't actually
66*4882a593Smuzhiyun    seem to be the case
67*4882a593Smuzhiyun */
68*4882a593Smuzhiyun 
winShowWindowOnTaskbar(HWND hWnd,Bool show)69*4882a593Smuzhiyun void winShowWindowOnTaskbar(HWND hWnd, Bool show)
70*4882a593Smuzhiyun {
71*4882a593Smuzhiyun   ITaskbarList* pTaskbarList = NULL;
72*4882a593Smuzhiyun 
73*4882a593Smuzhiyun   if (SUCCEEDED(CoInitialize(NULL)))
74*4882a593Smuzhiyun     {
75*4882a593Smuzhiyun       if (SUCCEEDED(CoCreateInstance((const CLSID *)&CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, (const IID *)&IID_ITaskbarList, (void**)&pTaskbarList)))
76*4882a593Smuzhiyun         {
77*4882a593Smuzhiyun           if (SUCCEEDED(pTaskbarList->lpVtbl->HrInit(pTaskbarList)))
78*4882a593Smuzhiyun             {
79*4882a593Smuzhiyun               if (show)
80*4882a593Smuzhiyun                 {
81*4882a593Smuzhiyun                   pTaskbarList->lpVtbl->AddTab(pTaskbarList,hWnd);
82*4882a593Smuzhiyun                 }
83*4882a593Smuzhiyun               else
84*4882a593Smuzhiyun                 {
85*4882a593Smuzhiyun                   pTaskbarList->lpVtbl->DeleteTab(pTaskbarList,hWnd);
86*4882a593Smuzhiyun                 }
87*4882a593Smuzhiyun             }
88*4882a593Smuzhiyun           pTaskbarList->lpVtbl->Release(pTaskbarList);
89*4882a593Smuzhiyun         }
90*4882a593Smuzhiyun       CoUninitialize();
91*4882a593Smuzhiyun     }
92*4882a593Smuzhiyun }
93