Constantin Kaplinsky | 729598c | 2006-05-25 05:12:25 +0000 | [diff] [blame^] | 1 | /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. |
| 2 | * |
| 3 | * This is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License as published by |
| 5 | * the Free Software Foundation; either version 2 of the License, or |
| 6 | * (at your option) any later version. |
| 7 | * |
| 8 | * This software is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this software; if not, write to the Free Software |
| 15 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
| 16 | * USA. |
| 17 | */ |
| 18 | |
| 19 | // -=- WMHooks.h |
| 20 | |
| 21 | #ifndef __RFB_WIN32_WM_HOOKS_H__ |
| 22 | #define __RFB_WIN32_WM_HOOKS_H__ |
| 23 | |
| 24 | #include <windows.h> |
| 25 | #include <rfb/UpdateTracker.h> |
| 26 | #include <rdr/Exception.h> |
| 27 | #include <rfb_win32/Win32Util.h> |
| 28 | |
| 29 | namespace rfb { |
| 30 | |
| 31 | namespace win32 { |
| 32 | |
| 33 | // -=- WMHooks |
| 34 | // Uses the wm_hooks DLL to intercept window messages, to get _hints_ as |
| 35 | // to what may have changed on-screen. Updates are notified via a Win32 |
| 36 | // event, and retrieved using the getUpdates method, which is thread-safe. |
| 37 | class WMHooks { |
| 38 | public: |
| 39 | WMHooks(); |
| 40 | ~WMHooks(); |
| 41 | |
| 42 | // Specify the event object to notify. Starts the hook subsystem if it is |
| 43 | // not already active, and returns false if the hooks fail to start. |
| 44 | bool setEvent(HANDLE updateEvent); |
| 45 | |
| 46 | // Copies any new updates to the UpdateTracker. Returns true if new updates |
| 47 | // were added, false otherwise. |
| 48 | bool getUpdates(UpdateTracker* ut); |
| 49 | |
| 50 | // Determine whether the hooks DLL is installed on the system |
| 51 | static bool areAvailable(); |
| 52 | |
| 53 | #ifdef _DEBUG |
| 54 | // Get notifications of any messages in the given range, to any hooked window |
| 55 | void setDiagnosticRange(UINT min, UINT max); |
| 56 | #endif |
| 57 | |
| 58 | // * INTERNAL NOTIFICATION FUNCTION * |
| 59 | void NotifyHooksRegion(const Region& r); |
| 60 | protected: |
| 61 | HANDLE updateEvent; |
| 62 | bool updatesReady; |
| 63 | SimpleUpdateTracker updates; |
| 64 | }; |
| 65 | |
| 66 | // -=- Support for filtering out local input events while remote connections are |
| 67 | // active. Implemented using SetWindowsHookEx for portability. |
| 68 | class WMBlockInput { |
| 69 | public: |
| 70 | WMBlockInput(); |
| 71 | ~WMBlockInput(); |
| 72 | bool blockInputs(bool block); |
| 73 | protected: |
| 74 | bool active; |
| 75 | }; |
| 76 | |
| 77 | // - Legacy cursor handling support |
| 78 | class WMCursorHooks { |
| 79 | public: |
| 80 | WMCursorHooks(); |
| 81 | ~WMCursorHooks(); |
| 82 | |
| 83 | bool start(); |
| 84 | |
| 85 | HCURSOR getCursor() const; |
| 86 | }; |
| 87 | |
| 88 | }; |
| 89 | |
| 90 | }; |
| 91 | |
| 92 | #endif // __RFB_WIN32_WM_HOOKS_H__ |