| 1 | /* | 
|---|
| 2 | * synergy -- mouse and keyboard sharing utility | 
|---|
| 3 | * Copyright (C) 2003 Chris Schoeneman | 
|---|
| 4 | * Copyright (C) 2006 Knut St. Osmundsen | 
|---|
| 5 | * | 
|---|
| 6 | * This package is free software; you can redistribute it and/or | 
|---|
| 7 | * modify it under the terms of the GNU General Public License | 
|---|
| 8 | * found in the file COPYING that should have accompanied this file. | 
|---|
| 9 | * | 
|---|
| 10 | * This package is distributed in the hope that it will be useful, | 
|---|
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
| 13 | * GNU General Public License for more details. | 
|---|
| 14 | */ | 
|---|
| 15 |  | 
|---|
| 16 | #ifndef CARCHTASKBARWINDOWS_H | 
|---|
| 17 | #define CARCHTASKBARWINDOWS_H | 
|---|
| 18 |  | 
|---|
| 19 | #define WIN32_LEAN_AND_MEAN | 
|---|
| 20 |  | 
|---|
| 21 | #include "IArchTaskBar.h" | 
|---|
| 22 | #include "IArchMultithread.h" | 
|---|
| 23 | #include "stdmap.h" | 
|---|
| 24 | #include "stdvector.h" | 
|---|
| 25 | #define INCL_BASE | 
|---|
| 26 | #define INCL_PM | 
|---|
| 27 | #define INCL_ERRORS | 
|---|
| 28 | #include <os2emx.h> | 
|---|
| 29 |  | 
|---|
| 30 | #define ARCH_TASKBAR CArchTaskBarOS2 | 
|---|
| 31 |  | 
|---|
| 32 | //! Win32 implementation of IArchTaskBar | 
|---|
| 33 | class CArchTaskBarOS2 : public IArchTaskBar { | 
|---|
| 34 | public: | 
|---|
| 35 | CArchTaskBarOS2(void*); | 
|---|
| 36 | virtual ~CArchTaskBarOS2(); | 
|---|
| 37 |  | 
|---|
| 38 | //! Add a dialog window | 
|---|
| 39 | /*! | 
|---|
| 40 | Tell the task bar event loop about a dialog.  Win32 annoyingly | 
|---|
| 41 | requires messages destined for modeless dialog boxes to be | 
|---|
| 42 | dispatched differently than other messages. | 
|---|
| 43 | */ | 
|---|
| 44 | static void                     addDialog(HWND); | 
|---|
| 45 |  | 
|---|
| 46 | //! Remove a dialog window | 
|---|
| 47 | /*! | 
|---|
| 48 | Remove a dialog window added via \c addDialog(). | 
|---|
| 49 | */ | 
|---|
| 50 | static void                     removeDialog(HWND); | 
|---|
| 51 |  | 
|---|
| 52 | // IArchTaskBar overrides | 
|---|
| 53 | virtual void            addReceiver(IArchTaskBarReceiver*); | 
|---|
| 54 | virtual void            removeReceiver(IArchTaskBarReceiver*); | 
|---|
| 55 | virtual void            updateReceiver(IArchTaskBarReceiver*); | 
|---|
| 56 |  | 
|---|
| 57 | private: | 
|---|
| 58 | class CReceiverInfo { | 
|---|
| 59 | public: | 
|---|
| 60 | ULONG                   m_id; | 
|---|
| 61 | }; | 
|---|
| 62 |  | 
|---|
| 63 | typedef std::map<IArchTaskBarReceiver*, CReceiverInfo> CReceiverToInfoMap; | 
|---|
| 64 | typedef std::map<ULONG, CReceiverToInfoMap::iterator> CIDToReceiverMap; | 
|---|
| 65 | typedef std::vector<ULONG> CIDStack; | 
|---|
| 66 | typedef std::map<HWND, bool> CDialogs; | 
|---|
| 67 |  | 
|---|
| 68 | ULONG                           getNextID(); | 
|---|
| 69 | void                            recycleID(ULONG); | 
|---|
| 70 |  | 
|---|
| 71 | void                            addIcon(ULONG); | 
|---|
| 72 | void                            removeIcon(ULONG); | 
|---|
| 73 | void                            updateIcon(ULONG); | 
|---|
| 74 | void                            addAllIcons(); | 
|---|
| 75 | void                            removeAllIcons(); | 
|---|
| 76 | void                            modifyIconNoLock(CReceiverToInfoMap::const_iterator, | 
|---|
| 77 | ULONG taskBarMessage); | 
|---|
| 78 | void                            removeIconNoLock(ULONG id); | 
|---|
| 79 | void                            handleIconMessage(IArchTaskBarReceiver*, MPARAM); | 
|---|
| 80 |  | 
|---|
| 81 | bool                            processDialogs(PQMSG); | 
|---|
| 82 | MRESULT                         wndProc(HWND, ULONG, MPARAM, MPARAM); | 
|---|
| 83 | static MRESULT EXPENTRY         staticWndProc(HWND, ULONG, MPARAM, MPARAM); | 
|---|
| 84 | void                            threadMainLoop(); | 
|---|
| 85 | static void*            threadEntry(void*); | 
|---|
| 86 |  | 
|---|
| 87 | private: | 
|---|
| 88 | static CArchTaskBarOS2* s_instance; | 
|---|
| 89 |  | 
|---|
| 90 | // multithread data | 
|---|
| 91 | CArchMutex                      m_mutex; | 
|---|
| 92 | CArchCond                       m_condVar; | 
|---|
| 93 | bool                            m_ready; | 
|---|
| 94 | int                                     m_result; | 
|---|
| 95 | CArchThread                     m_thread; | 
|---|
| 96 |  | 
|---|
| 97 | // child thread data | 
|---|
| 98 | HWND                            m_hwnd; | 
|---|
| 99 | ULONG                           m_taskBarRestart; | 
|---|
| 100 |  | 
|---|
| 101 | // shared data | 
|---|
| 102 | CReceiverToInfoMap      m_receivers; | 
|---|
| 103 | CIDToReceiverMap        m_idTable; | 
|---|
| 104 | CIDStack                        m_oldIDs; | 
|---|
| 105 | ULONG                           m_nextID; | 
|---|
| 106 |  | 
|---|
| 107 | // dialogs | 
|---|
| 108 | CDialogs                        m_dialogs; | 
|---|
| 109 | CDialogs                        m_addedDialogs; | 
|---|
| 110 | }; | 
|---|
| 111 |  | 
|---|
| 112 | #endif | 
|---|