~ubuntu-branches/debian/lenny/italc/lenny

« back to all changes in this revision

Viewing changes to ica/win32/src/vncDesktop.h

  • Committer: Bazaar Package Importer
  • Author(s): Patrick Winnertz
  • Date: 2008-06-17 13:46:54 UTC
  • mfrom: (1.2.1 upstream) (4.1.1 gutsy)
  • Revision ID: james.westby@ubuntu.com-20080617134654-cl0gi4u524cv1ici
Tags: 1:1.0.9~rc3-1
* Package new upstream version
  - upstream ported the code to qt4.4 (Closes: #481974)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//  Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.
 
2
//
 
3
//  This file is part of the VNC system.
 
4
//
 
5
//  The VNC system is free software; you can redistribute it and/or modify
 
6
//  it under the terms of the GNU General Public License as published by
 
7
//  the Free Software Foundation; either version 2 of the License, or
 
8
//  (at your option) any later version.
 
9
//
 
10
//  This program 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
//  You should have received a copy of the GNU General Public License
 
16
//  along with this program; if not, write to the Free Software
 
17
//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
 
18
//  USA.
 
19
//
 
20
// TightVNC distribution homepage on the Web: http://www.tightvnc.com/
 
21
//
 
22
// If the source code for the VNC system is not available from the place 
 
23
// whence you received this file, check http://www.uk.research.att.com/vnc or contact
 
24
// the authors on vnc@uk.research.att.com for information on obtaining it.
 
25
 
 
26
 
 
27
// vncDesktop object
 
28
 
 
29
// The vncDesktop object handles retrieval of data from the
 
30
// display buffer.  It also uses the RFBLib DLL to supply
 
31
// information on mouse movements and screen updates to
 
32
// the server
 
33
 
 
34
class vncDesktop;
 
35
 
 
36
#if !defined(_WINVNC_VNCDESKTOP)
 
37
#define _WINVNC_VNCDESKTOP
 
38
#pragma once
 
39
 
 
40
// Include files
 
41
#include "stdhdrs.h"
 
42
 
 
43
#include "vncServer.h"
 
44
#include "vncRegion.h"
 
45
#include "RectList.h"
 
46
#include "translate.h"
 
47
#include <omnithread.h>
 
48
#include "VideoDriver.h"
 
49
 
 
50
// Constants
 
51
extern const UINT RFB_SCREEN_UPDATE;
 
52
extern const UINT RFB_COPYRECT_UPDATE;
 
53
extern const UINT RFB_MOUSE_UPDATE;
 
54
extern const char szDesktopSink[];
 
55
 
 
56
#define MAX_REG_ENTRY_LEN             (80)
 
57
 
 
58
// Class definition
 
59
 
 
60
class vncDesktop
 
61
{
 
62
 
 
63
// Fields
 
64
public:
 
65
 
 
66
// Methods
 
67
public:
 
68
        // Make the desktop thread & window proc friends
 
69
        friend class vncDesktopThread;
 
70
        friend LRESULT CALLBACK DesktopWndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp);
 
71
 
 
72
        // Create/Destroy methods
 
73
        vncDesktop();
 
74
        ~vncDesktop();
 
75
 
 
76
        BOOL Init(vncServer *pSrv);
 
77
 
 
78
        // Hooking stuff
 
79
        void TryActivateHooks();
 
80
        BOOL DriverActive() { return m_videodriver != NULL; }
 
81
 
 
82
        // Routine to signal a vncServer to trigger an update
 
83
        void RequestUpdate();
 
84
 
 
85
        // Screen translation, capture, info
 
86
        void FillDisplayInfo(rfbServerInitMsg *scrInfo);
 
87
        void SetLocalInputDisableHook(BOOL enable);
 
88
        void SetLocalInputPriorityHook(BOOL enable);
 
89
        void CaptureScreen(const RECT &UpdateArea, BYTE *scrBuff);
 
90
        void CaptureScreenFromAdapterGeneral(RECT UpdateArea, BYTE *scrBuff);
 
91
        void CaptureScreenFromMirage(RECT UpdateArea, BYTE *scrBuff);
 
92
        int ScreenBuffSize();
 
93
        HWND Window() { return m_hwnd; }
 
94
 
 
95
        // Mouse related
 
96
        void CaptureMouse(BYTE *scrBuff, UINT scrBuffSize);
 
97
 
 
98
        void CaptureMouseRect();
 
99
        BOOL GetRichCursorData(BYTE *databuf, HCURSOR hcursor, int width, int height);
 
100
        RECT MouseRect();
 
101
        void SetCursor(HCURSOR cursor);
 
102
        HCURSOR GetCursor() { return m_hcursor; }
 
103
 
 
104
// created for debug purposes. not used in normal builds.
 
105
        bool bDbgDumpSurfBuffers(const RECT &rcl);
 
106
 
 
107
        // Clipboard manipulation
 
108
        static void ConvertClipText(char *dst, const char *src);
 
109
        void SetClipText(LPSTR text);
 
110
 
 
111
        // Method to obtain the DIBsection buffer if fast blits are enabled
 
112
        // If they're disabled, it'll return NULL
 
113
        inline BYTE *MainBuffer() {     return m_mainbuff; }
 
114
        inline RECT MainBufferRect() {  return m_bmrect; }
 
115
        void CopyRect(RECT const& dest, POINT source);
 
116
 
 
117
        BOOL                    m_initialClipBoardSeen;
 
118
 
 
119
        // Implementation
 
120
protected:
 
121
 
 
122
        // Routines to hook and unhook us
 
123
        BOOL Startup();
 
124
        BOOL Shutdown();
 
125
        void ActivateHooks();
 
126
        void ShutdownHooks();
 
127
 
 
128
        // Init routines called by the child thread
 
129
        BOOL InitDesktop();
 
130
        void KillScreenSaver();
 
131
 
 
132
        RECT GetSourceRect();
 
133
        BOOL GetSourceDisplayRect(RECT &rdisp_rect);
 
134
        static BOOL IsMultiMonDesktop();
 
135
 
 
136
        void ChangeResNow();
 
137
        void SetupDisplayForConnection();
 
138
        void ResetDisplayToNormal();
 
139
 
 
140
        BOOL InitBitmap();
 
141
        BOOL InitWindow();
 
142
        BOOL ThunkBitmapInfo();
 
143
        BOOL SetPixFormat();
 
144
        BOOL SetPixShifts();
 
145
        BOOL InitHooks();
 
146
        BOOL SetPalette();
 
147
 
 
148
        void CopyToBuffer(RECT rect, BYTE *scrBuff);
 
149
        void CopyToBuffer(RECT rect, BYTE *scrBuff, const BYTE *SourceBuff);
 
150
        void CopyRectToBuffer(RECT dest, POINT source);
 
151
        void CalcCopyRects();
 
152
        
 
153
        // Routine to attempt enabling optimised DIBsection blits
 
154
        BOOL CreateBuffers();
 
155
 
 
156
        // Convert a bit mask eg. 00111000 to max=7, shift=3
 
157
        static void MaskToMaxAndShift(DWORD mask, CARD16 &max, CARD8 &shift);
 
158
        
 
159
        // Enabling & disabling clipboard handling
 
160
        void SetClipboardActive(BOOL active) {m_clipboard_active = active;};
 
161
 
 
162
        // Detecting updates
 
163
        BOOL CheckUpdates();
 
164
        void SetPollingTimer();
 
165
        void SetPollingFlag(BOOL set) { m_polling_flag = set; }
 
166
        BOOL GetPollingFlag() { return m_polling_flag; }
 
167
        void PerformPolling();
 
168
        void PollWindow(HWND hwnd);
 
169
        void PollArea(const RECT &rect);
 
170
        void CheckRects(vncRegion &rgn, rectlist &rects);
 
171
        void GetChangedRegion_Normal(vncRegion &rgn, const RECT &rect);
 
172
        void GetChangedRegion_Dummy(vncRegion &rgn, const RECT &rect);
 
173
 
 
174
        void GetChangedRegion(vncRegion &rgn, const RECT &rect)
 
175
        {
 
176
#if 1
 
177
                GetChangedRegion_Normal(rgn, rect);
 
178
#else
 
179
                GetChangedRegion_Dummy(rgn, rect);
 
180
#endif
 
181
        }
 
182
 
 
183
        void UpdateChangedRect(vncRegion &rgn, const RECT &rect);
 
184
        void UpdateChangedSubRect(vncRegion &rgn, const RECT &rect);
 
185
 
 
186
        // Blank screen feature
 
187
        void UpdateBlankScreenTimer();
 
188
        void BlankScreen(BOOL set);
 
189
 
 
190
        // Timer identifiers (the third one is not used in any real timer)
 
191
        enum TimerID {
 
192
                TIMER_POLL = 1,
 
193
                TIMER_BLANK_SCREEN = 2,
 
194
                TIMER_RESTORE_SCREEN = 3
 
195
        };
 
196
 
 
197
        // Video driver stuff
 
198
        BOOL InitVideoDriver();
 
199
        void ShutdownVideoDriver();
 
200
 
 
201
        // DATA
 
202
 
 
203
        // Generally useful stuff
 
204
        vncServer               *m_server;
 
205
        omni_thread     *m_thread;
 
206
        HWND                    m_hwnd;
 
207
        BOOL                    m_polling_flag;
 
208
        UINT                    m_timer_polling;
 
209
        UINT                    m_timer_blank_screen;
 
210
        HWND                    m_hnextviewer;
 
211
        BOOL                    m_clipboard_active;
 
212
        BOOL                    m_hooks_active;
 
213
        BOOL                    m_hooks_may_change;
 
214
 
 
215
        // Video driver stuff
 
216
        vncVideoDriver  *m_videodriver;
 
217
 
 
218
        // device contexts for memory and the screen
 
219
        HDC                             m_hmemdc;
 
220
        HDC                             m_hrootdc;
 
221
 
 
222
        // New and old bitmaps
 
223
        HBITMAP                 m_membitmap;
 
224
        omni_mutex              m_bitbltlock;
 
225
 
 
226
// frame buffer relative to the entire (virtual) desktop.
 
227
// NOTE: non-zero offsets possible
 
228
        RECT                    m_bmrect;
 
229
 
 
230
        struct _BMInfo {
 
231
                BOOL                    truecolour;
 
232
                BITMAPINFO              bmi;
 
233
                // Colormap info - comes straight after BITMAPINFO - **HACK**
 
234
                RGBQUAD                 cmap[256];
 
235
        } m_bminfo;
 
236
 
 
237
        // Screen info
 
238
        rfbServerInitMsg        m_scrinfo;
 
239
 
 
240
        // These are the red, green & blue masks for a pixel
 
241
        DWORD                   m_rMask, m_gMask, m_bMask;
 
242
 
 
243
        // This is always handy to have
 
244
        int                             m_bytesPerRow;
 
245
 
 
246
        // Handle of the default cursor
 
247
        HCURSOR                 m_hcursor;
 
248
        // Handle of the basic arrow cursor
 
249
        HCURSOR                 m_hdefcursor;
 
250
        // The current mouse position
 
251
        RECT                    m_cursorpos;
 
252
 
 
253
        // Boolean flag to indicate when the display resolution has changed
 
254
        BOOL                    m_displaychanged;
 
255
 
 
256
        // Extra vars used for the DIBsection optimisation
 
257
        VOID                    *m_DIBbits;
 
258
        BYTE                    *m_mainbuff;
 
259
        BYTE                    *m_backbuff;
 
260
        BOOL                    m_freemainbuff;
 
261
        BOOL                    m_formatmunged;
 
262
 
 
263
// DevMode alteration
 
264
        DEVMODE                 *m_lpAlternateDevMode; // *** used for res changes - Jeremy Peaks
 
265
        long                    origPelsWidth; // *** To set the original resolution
 
266
        long                    origPelsHeight; // *** - Jeremy Peaks
 
267
        
 
268
        vncRegion               m_changed_rgn;
 
269
        BOOL                    m_copyrect_set;
 
270
        RECT                    m_copyrect_rect;
 
271
        POINT                   m_copyrect_src;
 
272
 
 
273
        static const int m_pollingOrder[32];
 
274
        static int              m_pollingStep;
 
275
};
 
276
 
 
277
#endif // _WINVNC_VNCDESKTOP