-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClientConnectionFullScreen.cpp
More file actions
executable file
·103 lines (96 loc) · 3.63 KB
/
Copy pathClientConnectionFullScreen.cpp
File metadata and controls
executable file
·103 lines (96 loc) · 3.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// The VNC system is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
//
// If the source code for the VNC system is not available from the place
// whence you received this file, check http://www.orl.co.uk/vnc or contact
// the authors on vnc@orl.co.uk for information on obtaining it.
// Many thanks to Greg Hewgill <greg@hewgill.com> for providing the basis for
// the full-screen mode.
#include "stdhdrs.h"
#include "vncviewer.h"
#include "ClientConnection.h"
// Parameters for scrolling in full screen mode
#define BUMPSCROLLBORDER 4
#define BUMPSCROLLAMOUNTX 16
#define BUMPSCROLLAMOUNTY 4
void ClientConnection::SetFullScreenMode(bool enable)
{
LONG style = GetWindowLong(m_hwnd, GWL_STYLE);
m_fullScreenMode = enable;
if (enable) {
ShowWindow(m_hwnd, SW_MAXIMIZE);
style = GetWindowLong(m_hwnd, GWL_STYLE);
style &= ~(WS_DLGFRAME | WS_THICKFRAME);
SetWindowLong(m_hwnd, GWL_STYLE, style);
int cx = GetSystemMetrics(SM_CXSCREEN);
int cy = GetSystemMetrics(SM_CYSCREEN);
SetWindowPos(m_hwnd, HWND_TOPMOST, -1, -1, cx+3, cy+3, SWP_FRAMECHANGED);
CheckMenuItem(GetSystemMenu(m_hwnd, FALSE), ID_FULLSCREEN, MF_BYCOMMAND|MF_CHECKED);
// A bit crude here - we can skip the prompt on a registry setting.
// We'll do this properly later.
HKEY hRegKey;
DWORD skipprompt = 0;
if ( RegCreateKey(HKEY_CURRENT_USER, SETTINGS_KEY_NAME, &hRegKey) != ERROR_SUCCESS ) {
hRegKey = NULL;
} else {
DWORD skippromptsize = sizeof(skipprompt);
DWORD valtype;
if ( RegQueryValueEx( hRegKey, "SkipFullScreenPrompt", NULL, &valtype,
(LPBYTE) &skipprompt, &skippromptsize) != ERROR_SUCCESS) {
skipprompt = 0;
}
RegCloseKey(hRegKey);
}
if (!skipprompt)
MessageBox(m_hwnd,
_T("To exit from full-screen mode, use Ctrl-Esc Esc and then\r\n"
"right-click on the vncviewer taskbar icon to see the menu."),
_T("VNCviewer full-screen mode"),
MB_OK | MB_ICONINFORMATION );
} else {
style |= WS_DLGFRAME | WS_THICKFRAME;
SetWindowLong(m_hwnd, GWL_STYLE, style);
SetWindowPos(m_hwnd, HWND_NOTOPMOST, 0,0,100,100, SWP_NOMOVE | SWP_NOSIZE);
ShowWindow(m_hwnd, SW_NORMAL);
CheckMenuItem(GetSystemMenu(m_hwnd, FALSE), ID_FULLSCREEN, MF_BYCOMMAND|MF_UNCHECKED);
}
}
bool ClientConnection::BumpScroll(int x, int y)
{
int dx = 0;
int dy = 0;
int rightborder = GetSystemMetrics(SM_CXSCREEN)-BUMPSCROLLBORDER;
int bottomborder = GetSystemMetrics(SM_CYSCREEN)-BUMPSCROLLBORDER;
if (x < BUMPSCROLLBORDER)
dx = -BUMPSCROLLAMOUNTX;
if (x >= rightborder)
dx = +BUMPSCROLLAMOUNTX;
if (y < BUMPSCROLLBORDER)
dy = -BUMPSCROLLAMOUNTY;
if (y >= bottomborder)
dy = +BUMPSCROLLAMOUNTY;
if (dx || dy) {
if (ScrollScreen(dx,dy)) {
// If we haven't physically moved the cursor, artificially
// generate another mouse event so we keep scrolling.
POINT p;
GetCursorPos(&p);
if (p.x == x && p.y == y)
SetCursorPos(x,y);
return true;
}
}
return false;
}