blob: 4713b41663043d9819564b2a28fcb6ff9ca3ac68 [file] [log] [blame]
Constantin Kaplinsky0a1eca12006-04-16 07:28:14 +00001/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
2 *
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +00003 * 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
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +000024#include <windows.h>
25#include <rfb/UpdateTracker.h>
26#include <rdr/Exception.h>
Constantin Kaplinsky0a1eca12006-04-16 07:28:14 +000027#include <rfb_win32/Win32Util.h>
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +000028
29namespace rfb {
30
31 namespace win32 {
32
Constantin Kaplinsky0a1eca12006-04-16 07:28:14 +000033 // -=- 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 {
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +000038 public:
39 WMHooks();
40 ~WMHooks();
41
Constantin Kaplinsky0a1eca12006-04-16 07:28:14 +000042 // 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);
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +000045
Constantin Kaplinsky0a1eca12006-04-16 07:28:14 +000046 // 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();
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +000052
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
Constantin Kaplinsky0a1eca12006-04-16 07:28:14 +000058 // * INTERNAL NOTIFICATION FUNCTION *
59 void NotifyHooksRegion(const Region& r);
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +000060 protected:
Constantin Kaplinsky0a1eca12006-04-16 07:28:14 +000061 HANDLE updateEvent;
62 bool updatesReady;
63 SimpleUpdateTracker updates;
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +000064 };
65
Constantin Kaplinsky0a1eca12006-04-16 07:28:14 +000066 // -=- Support for filtering out local input events while remote connections are
67 // active. Implemented using SetWindowsHookEx for portability.
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +000068 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__