FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cefpython/src/subprocess/main_message_loop/util_win.cpp at cefpython58 · 2php/cefpython · GitHub
2php
cefpython
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cefpython
/
src
/
subprocess
/
main_message_loop
/
util_win.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
159 lines (144 loc) · 4.29 KB
Breadcrumbs
cefpython
/
src
/
subprocess
/
main_message_loop
/
util_win.cpp
Copy path
File metadata and controls
159 lines (144 loc) · 4.29 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
//
Copied from upstream cefclient with minor modifications.
//
Windows UNICODE API calls were converted to ANSI or commented out.
//
Copyright (c) 2015 The Chromium Embedded Framework Authors. All rights
//
reserved. Use of this source code is governed by a BSD-style license that
//
can be found in the LICENSE file.
#
include
"
util_win.h
"
#
include
"
include/base/cef_logging.h
"
void
SetUserDataPtr
(
HWND
hWnd,
void
* ptr) {
SetLastError
(
ERROR_SUCCESS
);
LONG_PTR
result = ::
SetWindowLongPtr
(
hWnd,
GWLP_USERDATA
,
reinterpret_cast
<
LONG_PTR
>(ptr));
CHECK
(result !=
0
||
GetLastError
() ==
ERROR_SUCCESS
);
}
WNDPROC
SetWndProcPtr
(
HWND
hWnd,
WNDPROC
wndProc) {
WNDPROC
old =
reinterpret_cast
<
WNDPROC
>(::
GetWindowLongPtr
(hWnd,
GWLP_WNDPROC
));
CHECK
(old !=
NULL
);
LONG_PTR
result = ::
SetWindowLongPtr
(
hWnd,
GWLP_WNDPROC
,
reinterpret_cast
<
LONG_PTR
>(wndProc));
CHECK
(result !=
0
||
GetLastError
() ==
ERROR_SUCCESS
);
return
old;
}
//
std::wstring GetResourceString(UINT id) {
//
#define MAX_LOADSTRING 100
//
TCHAR buff[MAX_LOADSTRING] = {0};
//
LoadString(::GetModuleHandle(NULL), id, buff, MAX_LOADSTRING);
//
return buff;
//
}
int
GetCefMouseModifiers
(
WPARAM
wparam) {
int
modifiers =
0
;
if
(wparam &
MK_CONTROL
)
modifiers |=
EVENTFLAG_CONTROL_DOWN
;
if
(wparam &
MK_SHIFT
)
modifiers |=
EVENTFLAG_SHIFT_DOWN
;
if
(
IsKeyDown
(
VK_MENU
))
modifiers |=
EVENTFLAG_ALT_DOWN
;
if
(wparam &
MK_LBUTTON
)
modifiers |=
EVENTFLAG_LEFT_MOUSE_BUTTON
;
if
(wparam &
MK_MBUTTON
)
modifiers |=
EVENTFLAG_MIDDLE_MOUSE_BUTTON
;
if
(wparam &
MK_RBUTTON
)
modifiers |=
EVENTFLAG_RIGHT_MOUSE_BUTTON
;
//
Low bit set from GetKeyState indicates "toggled".
if
(::
GetKeyState
(
VK_NUMLOCK
) &
1
)
modifiers |=
EVENTFLAG_NUM_LOCK_ON
;
if
(::
GetKeyState
(
VK_CAPITAL
) &
1
)
modifiers |=
EVENTFLAG_CAPS_LOCK_ON
;
return
modifiers;
}
int
GetCefKeyboardModifiers
(
WPARAM
wparam,
LPARAM
lparam) {
int
modifiers =
0
;
if
(
IsKeyDown
(
VK_SHIFT
))
modifiers |=
EVENTFLAG_SHIFT_DOWN
;
if
(
IsKeyDown
(
VK_CONTROL
))
modifiers |=
EVENTFLAG_CONTROL_DOWN
;
if
(
IsKeyDown
(
VK_MENU
))
modifiers |=
EVENTFLAG_ALT_DOWN
;
//
Low bit set from GetKeyState indicates "toggled".
if
(::
GetKeyState
(
VK_NUMLOCK
) &
1
)
modifiers |=
EVENTFLAG_NUM_LOCK_ON
;
if
(::
GetKeyState
(
VK_CAPITAL
) &
1
)
modifiers |=
EVENTFLAG_CAPS_LOCK_ON
;
switch
(wparam) {
case
VK_RETURN
:
if
((lparam >>
16
) &
KF_EXTENDED
)
modifiers |=
EVENTFLAG_IS_KEY_PAD
;
break
;
case
VK_INSERT
:
case
VK_DELETE
:
case
VK_HOME
:
case
VK_END
:
case
VK_PRIOR
:
case
VK_NEXT
:
case
VK_UP
:
case
VK_DOWN
:
case
VK_LEFT
:
case
VK_RIGHT
:
if
(!((lparam >>
16
) &
KF_EXTENDED
))
modifiers |=
EVENTFLAG_IS_KEY_PAD
;
break
;
case
VK_NUMLOCK
:
case
VK_NUMPAD0
:
case
VK_NUMPAD1
:
case
VK_NUMPAD2
:
case
VK_NUMPAD3
:
case
VK_NUMPAD4
:
case
VK_NUMPAD5
:
case
VK_NUMPAD6
:
case
VK_NUMPAD7
:
case
VK_NUMPAD8
:
case
VK_NUMPAD9
:
case
VK_DIVIDE
:
case
VK_MULTIPLY
:
case
VK_SUBTRACT
:
case
VK_ADD
:
case
VK_DECIMAL
:
case
VK_CLEAR
:
modifiers |=
EVENTFLAG_IS_KEY_PAD
;
break
;
case
VK_SHIFT
:
if
(
IsKeyDown
(
VK_LSHIFT
))
modifiers |=
EVENTFLAG_IS_LEFT
;
else
if
(
IsKeyDown
(
VK_RSHIFT
))
modifiers |=
EVENTFLAG_IS_RIGHT
;
break
;
case
VK_CONTROL
:
if
(
IsKeyDown
(
VK_LCONTROL
))
modifiers |=
EVENTFLAG_IS_LEFT
;
else
if
(
IsKeyDown
(
VK_RCONTROL
))
modifiers |=
EVENTFLAG_IS_RIGHT
;
break
;
case
VK_MENU
:
if
(
IsKeyDown
(
VK_LMENU
))
modifiers |=
EVENTFLAG_IS_LEFT
;
else
if
(
IsKeyDown
(
VK_RMENU
))
modifiers |=
EVENTFLAG_IS_RIGHT
;
break
;
case
VK_LWIN
:
modifiers |=
EVENTFLAG_IS_LEFT
;
break
;
case
VK_RWIN
:
modifiers |=
EVENTFLAG_IS_RIGHT
;
break
;
}
return
modifiers;
}
bool
IsKeyDown
(
WPARAM
wparam) {
return
(
GetKeyState
(wparam) &
0x8000
) !=
0
;
}
float
GetDeviceScaleFactor
() {
static
float
scale_factor =
1.0
;
static
bool
initialized =
false
;
if
(!initialized) {
//
This value is safe to cache for the life time of the app since the user
//
must logout to change the DPI setting. This value also applies to all
//
screens.
HDC
screen_dc = ::
GetDC
(
NULL
);
int
dpi_x =
GetDeviceCaps
(screen_dc,
LOGPIXELSX
);
scale_factor =
static_cast
<
float
>(dpi_x) /
96
.
0f
;
::ReleaseDC
(
NULL
, screen_dc);
initialized =
true
;
}
return
scale_factor;
}
Back
|
FazBrowse Home
|
New Git URL