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