Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
cb3b7237
Commit
cb3b7237
authored
Dec 15, 2011
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
user32: Cache the global key state to avoid performance issues in applications…
user32: Cache the global key state to avoid performance issues in applications that poll constantly.
parent
5a30e318
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
23 additions
and
1 deletion
+23
-1
hook.c
dlls/user32/hook.c
+4
-0
input.c
dlls/user32/input.c
+10
-0
message.c
dlls/user32/message.c
+4
-0
user_main.c
dlls/user32/user_main.c
+1
-0
user_private.h
dlls/user32/user_private.h
+3
-1
winstation.c
dlls/user32/winstation.c
+1
-0
No files found.
dlls/user32/hook.c
View file @
cb3b7237
...
...
@@ -385,6 +385,10 @@ static LRESULT call_hook( struct hook_info *info, INT code, WPARAM wparam, LPARA
thread_info
->
hook_unicode
=
prev_unicode
;
}
}
if
(
info
->
id
==
WH_KEYBOARD_LL
||
info
->
id
==
WH_MOUSE_LL
)
get_user_thread_info
()
->
key_state_time
=
0
;
/* force refreshing the key state cache */
return
ret
;
}
...
...
dlls/user32/input.c
View file @
cb3b7237
...
...
@@ -374,21 +374,31 @@ HWND WINAPI GetCapture(void)
*/
SHORT
WINAPI
DECLSPEC_HOTPATCH
GetAsyncKeyState
(
INT
key
)
{
struct
user_thread_info
*
thread_info
=
get_user_thread_info
();
SHORT
ret
;
if
(
key
<
0
||
key
>=
256
)
return
0
;
if
((
ret
=
USER_Driver
->
pGetAsyncKeyState
(
key
))
==
-
1
)
{
if
(
thread_info
->
key_state
)
{
if
(
GetTickCount
()
-
thread_info
->
key_state_time
<
50
)
return
(
thread_info
->
key_state
[
key
]
&
0x80
)
?
0x8000
:
0
;
}
else
thread_info
->
key_state
=
HeapAlloc
(
GetProcessHeap
(),
0
,
256
);
ret
=
0
;
SERVER_START_REQ
(
get_key_state
)
{
req
->
tid
=
0
;
req
->
key
=
key
;
if
(
thread_info
->
key_state
)
wine_server_set_reply
(
req
,
thread_info
->
key_state
,
256
);
if
(
!
wine_server_call
(
req
))
{
if
(
reply
->
state
&
0x40
)
ret
|=
0x0001
;
if
(
reply
->
state
&
0x80
)
ret
|=
0x8000
;
thread_info
->
key_state_time
=
GetTickCount
();
}
}
SERVER_END_REQ
;
...
...
dlls/user32/message.c
View file @
cb3b7237
...
...
@@ -3112,6 +3112,7 @@ static BOOL send_message( struct send_message_info *info, DWORD_PTR *res_ptr, BO
*/
NTSTATUS
send_hardware_message
(
HWND
hwnd
,
const
INPUT
*
input
,
UINT
flags
)
{
struct
user_thread_info
*
thread_info
=
get_user_thread_info
();
struct
send_message_info
info
;
NTSTATUS
ret
;
BOOL
wait
;
...
...
@@ -3149,11 +3150,14 @@ NTSTATUS send_hardware_message( HWND hwnd, const INPUT *input, UINT flags )
req
->
input
.
hw
.
lparam
=
MAKELONG
(
input
->
u
.
hi
.
wParamL
,
input
->
u
.
hi
.
wParamH
);
break
;
}
if
(
thread_info
->
key_state
)
wine_server_set_reply
(
req
,
thread_info
->
key_state
,
256
);
ret
=
wine_server_call
(
req
);
wait
=
reply
->
wait
;
}
SERVER_END_REQ
;
if
(
!
ret
&&
thread_info
->
key_state
)
thread_info
->
key_state_time
=
GetTickCount
();
if
(
wait
)
{
LRESULT
ignored
;
...
...
dlls/user32/user_main.c
View file @
cb3b7237
...
...
@@ -312,6 +312,7 @@ static void thread_detach(void)
if
(
thread_info
->
msg_window
)
WIN_DestroyThreadWindows
(
thread_info
->
msg_window
);
CloseHandle
(
thread_info
->
server_queue
);
HeapFree
(
GetProcessHeap
(),
0
,
thread_info
->
wmchar_data
);
HeapFree
(
GetProcessHeap
(),
0
,
thread_info
->
key_state
);
exiting_thread_id
=
0
;
}
...
...
dlls/user32/user_private.h
View file @
cb3b7237
...
...
@@ -176,10 +176,12 @@ struct user_thread_info
DWORD
GetMessagePosVal
;
/* Value for GetMessagePos */
ULONG_PTR
GetMessageExtraInfoVal
;
/* Value for GetMessageExtraInfo */
UINT
active_hooks
;
/* Bitmap of active hooks */
UINT
key_state_time
;
/* Time of last key state refresh */
BYTE
*
key_state
;
/* Cache of global key state */
HWND
top_window
;
/* Desktop window */
HWND
msg_window
;
/* HWND_MESSAGE parent window */
ULONG
pad
[
11
];
/* Available for more data */
ULONG
pad
[
9
];
/* Available for more data */
};
struct
hook_extra_info
...
...
dlls/user32/winstation.c
View file @
cb3b7237
...
...
@@ -401,6 +401,7 @@ BOOL WINAPI SetThreadDesktop( HDESK handle )
struct
user_thread_info
*
thread_info
=
get_user_thread_info
();
thread_info
->
top_window
=
0
;
thread_info
->
msg_window
=
0
;
thread_info
->
key_state_time
=
0
;
}
return
ret
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment