📄 clientconnection.h
字号:
// DC is locked if necessary.
#ifndef UNDER_CE
// Normally this is an inline call to a GDI method.
inline void FillSolidRect(RECT *pRect, COLORREF color) {
COLORREF oldbgcol = SetBkColor(m_hBitmapDC, color);
// This is the call MFC uses for FillSolidRect. Who am I to argue?
::ExtTextOut(m_hBitmapDC, 0, 0, ETO_OPAQUE, pRect, NULL, 0, NULL);
};
#else
// Under WinCE this is a manual insert into a pixmap,
// and is a little too complicated for an inline.
void FillSolidRect(RECT *pRect, COLORREF color);
#endif // UNDER_CE
inline void FillSolidRect(int x, int y, int w, int h, COLORREF color) {
RECT r;
r.left = x; r.right = x + w;
r.top = y; r.bottom = y + h;
FillSolidRect(&r, color);
};
// how many other windows are owned by this process?
unsigned int CountProcessOtherWindows();
// Buffer for network operations
void CheckBufferSize(int bufsize);
char *m_netbuf;
int m_netbufsize;
omni_mutex m_bufferMutex,
m_bitmapdcMutex, m_clipMutex,
m_readMutex, m_writeMutex, m_sockMutex,
m_cursorMutex;
// Buffer for zlib decompression.
void CheckZlibBufferSize(int bufsize);
unsigned char *m_zlibbuf;
int m_zlibbufsize;
// zlib decompression state
bool m_decompStreamInited;
z_stream m_decompStream;
z_stream m_decompStreamRaw;
z_stream m_decompStreamEncoded;
// Variables used by tight encoding:
// Separate buffer for tight-compressed data.
char m_tightbuf[TIGHT_ZLIB_BUFFER_SIZE];
// Four independent compression streams for zlib library.
z_stream m_tightZlibStream[4];
bool m_tightZlibStreamActive[4];
// Tight filter stuff. Should be initialized by filter initialization code.
tightFilterFunc m_tightCurrentFilter;
bool m_tightCutZeros;
int m_tightRectWidth, m_tightRectColors;
COLORREF m_tightPalette[256];
CARD8 m_tightPrevRow[2048*3*sizeof(CARD16)];
// Bitmap for local copy of screen, and DC for writing to it.
HBITMAP m_hBitmap;
HDC m_hBitmapDC;
HPALETTE m_hPalette;
#ifdef UNDER_CE
// Under WinCE this points to the DIB pixels.
BYTE* m_bits;
#endif
// Keyboard mapper
KeyMap m_keymap;
// RFB settings
VNCOptions m_opts;
// Protocol capabilities
CapsContainer m_tunnelCaps; // known tunneling/encryption methods
CapsContainer m_authCaps; // known authentication schemes
CapsContainer m_serverMsgCaps; // known non-standard server messages
CapsContainer m_clientMsgCaps; // known non-standard client messages
CapsContainer m_encodingCaps; // known encodings besides Raw
TCHAR *m_desktopName;
unsigned char m_encPasswd[8];
int m_authScheme;
rfbServerInitMsg m_si;
rfbPixelFormat m_myFormat, m_pendingFormat;
// protocol version in use.
int m_minorVersion;
bool m_tightVncProtocol;
bool m_threadStarted, m_running;
// mid-connection format change requested
bool m_pendingFormatChange;
// Display connection info;
void ShowConnInfo();
// Window may be scrollable - these control the scroll position
int m_hScrollPos, m_hScrollMax, m_vScrollPos, m_vScrollMax;
// The size of the current client area
int m_cliwidth, m_cliheight;
// The size of a window needed to hold entire screen without scrollbars
int m_fullwinwidth, m_fullwinheight;
int m_winwidth, m_winheight;
// The size of the CE CommandBar
int m_barheight;
// Dormant basically means minimized; updates will not be requested
// while dormant.
void SetDormant(bool newstate);
bool m_dormant;
// The number of bytes required to hold at least one pixel.
unsigned int m_minPixelBytes;
// Next window in clipboard chain
HWND m_hwndNextViewer;
bool m_initialClipboardSeen;
// Are we waiting on a timer for emulating three buttons?
bool m_waitingOnEmulateTimer;
// Or are we emulating the middle button now?
bool m_emulatingMiddleButton;
// Emulate 3 buttons mouse timer:
UINT m_emulate3ButtonsTimer;
// Buttons pressed, waiting for timer in emulating 3 buttons:
DWORD m_emulateKeyFlags;
int m_emulateButtonPressedX;
int m_emulateButtonPressedY;
};
// Some handy classes for temporary GDI object selection
// These select objects when constructed and automatically release them when destructed.
class ObjectSelector {
public:
ObjectSelector(HDC hdc, HGDIOBJ hobj) { m_hdc = hdc; m_hOldObj = SelectObject(hdc, hobj); }
~ObjectSelector() { m_hOldObj = SelectObject(m_hdc, m_hOldObj); }
HGDIOBJ m_hOldObj;
HDC m_hdc;
};
class PaletteSelector {
public:
PaletteSelector(HDC hdc, HPALETTE hpal) {
m_hdc = hdc;
m_hOldPal = SelectPalette(hdc, hpal, FALSE);
RealizePalette(hdc);
}
~PaletteSelector() {
m_hOldPal = SelectPalette(m_hdc, m_hOldPal, FALSE);
RealizePalette(m_hdc);
}
HPALETTE m_hOldPal;
HDC m_hdc;
};
class TempDC {
public:
TempDC(HWND hwnd) { m_hdc = GetDC(hwnd); m_hwnd = hwnd; }
~TempDC() { ReleaseDC(m_hwnd, m_hdc); }
operator HDC() {return m_hdc;};
HDC m_hdc;
HWND m_hwnd;
};
// Colour decoding utility functions
// Define rs,rm, bs,bm, gs & gm before using, eg with the following:
#define SETUP_COLOR_SHORTCUTS \
CARD8 rs = m_myFormat.redShift; CARD16 rm = m_myFormat.redMax; \
CARD8 gs = m_myFormat.greenShift; CARD16 gm = m_myFormat.greenMax; \
CARD8 bs = m_myFormat.blueShift; CARD16 bm = m_myFormat.blueMax; \
// read a pixel from the given address, and return a color value
#define COLOR_FROM_PIXEL8_ADDRESS(p) (PALETTERGB( \
(int) (((*(CARD8 *)(p) >> rs) & rm) * 255 / rm), \
(int) (((*(CARD8 *)(p) >> gs) & gm) * 255 / gm), \
(int) (((*(CARD8 *)(p) >> bs) & bm) * 255 / bm) ))
#define COLOR_FROM_PIXEL16_ADDRESS(p) (PALETTERGB( \
(int) ((( *(CARD16 *)(p) >> rs) & rm) * 255 / rm), \
(int) ((( *(CARD16 *)(p) >> gs) & gm) * 255 / gm), \
(int) ((( *(CARD16 *)(p) >> bs) & bm) * 255 / bm) ))
#define COLOR_FROM_PIXEL24_ADDRESS(p) (PALETTERGB( \
(int) (((CARD8 *)(p))[0]), \
(int) (((CARD8 *)(p))[1]), \
(int) (((CARD8 *)(p))[2]) ))
#define COLOR_FROM_PIXEL32_ADDRESS(p) (PALETTERGB( \
(int) ((( *(CARD32 *)(p) >> rs) & rm) * 255 / rm), \
(int) ((( *(CARD32 *)(p) >> gs) & gm) * 255 / gm), \
(int) ((( *(CARD32 *)(p) >> bs) & bm) * 255 / bm) ))
// The following may be faster if you already have a pixel value of the appropriate size
#define COLOR_FROM_PIXEL8(p) (PALETTERGB( \
(int) (((p >> rs) & rm) * 255 / rm), \
(int) (((p >> gs) & gm) * 255 / gm), \
(int) (((p >> bs) & bm) * 255 / bm) ))
#define COLOR_FROM_PIXEL16(p) (PALETTERGB( \
(int) ((( p >> rs) & rm) * 255 / rm), \
(int) ((( p >> gs) & gm) * 255 / gm), \
(int) ((( p >> bs) & bm) * 255 / bm) ))
#define COLOR_FROM_PIXEL32(p) (PALETTERGB( \
(int) (((p >> rs) & rm) * 255 / rm), \
(int) (((p >> gs) & gm) * 255 / gm), \
(int) (((p >> bs) & bm) * 255 / bm) ))
#ifdef UNDER_CE
#define SETPIXEL(b,x,y,c) SetPixel((b),(x),(y),(c))
#else
#define SETPIXEL(b,x,y,c) SetPixelV((b),(x),(y),(c))
#endif
#define SETPIXELS(buffer, bpp, x, y, w, h) \
{ \
CARD##bpp *p = (CARD##bpp *) buffer; \
register CARD##bpp pix; \
for (int k = y; k < y+h; k++) { \
for (int j = x; j < x+w; j++) { \
pix = *p; \
SETPIXEL(m_hBitmapDC, j,k, COLOR_FROM_PIXEL##bpp##(pix)); \
p++; \
} \
} \
}
#define SETPIXELS_NOCONV(buffer, x, y, w, h) \
{ \
CARD32 *p = (CARD32 *) buffer; \
for (int k = y; k < y+h; k++) { \
for (int j = x; j < x+w; j++) { \
SETPIXEL(m_hBitmapDC, j,k, *p); \
p++; \
} \
} \
}
#endif // CLIENTCONNECTION_H__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -