mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2025-01-28 22:04:43 -08:00
server-Key_State: Introduce a shadow keystate array to sync keystates only on changes.
This commit is contained in:
parent
b9ec1ed8f5
commit
fdc5f5c1dd
@ -4300,16 +4300,16 @@ fi
|
||||
# | * [#35907] Fix caps lock state issues with multiple processes
|
||||
# |
|
||||
# | Modified files:
|
||||
# | * server/queue.c
|
||||
# | * dlls/comctl32/tests/listview.c, server/queue.c
|
||||
# |
|
||||
if test "$enable_server_Key_State" -eq 1; then
|
||||
patch_apply server-Key_State/0001-server-Introduce-a-helper-function-to-update-the-thr.patch
|
||||
patch_apply server-Key_State/0002-server-Implement-locking-and-synchronization-of-keys.patch
|
||||
patch_apply server-Key_State/0003-server-Lock-thread-specific-keystate-in-set_key_stat.patch
|
||||
patch_apply server-Key_State/0003-server-Introduce-a-shadow-keystate-array-to-sync-key.patch
|
||||
(
|
||||
echo '+ { "Sebastian Lackner", "server: Introduce a helper function to update the thread_input key state.", 1 },';
|
||||
echo '+ { "Sebastian Lackner", "server: Implement locking and synchronization of keystate buffer.", 2 },';
|
||||
echo '+ { "Sebastian Lackner", "server: Lock thread specific keystate in set_key_state wineserver call.", 1 },';
|
||||
echo '+ { "Sebastian Lackner", "server: Introduce a shadow keystate array to sync keystates only on changes.", 1 },';
|
||||
) >> "$patchlist"
|
||||
fi
|
||||
|
||||
|
@ -1,18 +1,31 @@
|
||||
From 75ba790099722f2abb6fc408def81611ca93ddc0 Mon Sep 17 00:00:00 2001
|
||||
From 786c3fd3cfc26cb0eb116ca0f8d28a9640722404 Mon Sep 17 00:00:00 2001
|
||||
From: Sebastian Lackner <sebastian@fds-team.de>
|
||||
Date: Thu, 12 Mar 2015 02:56:21 +0100
|
||||
Subject: server: Implement locking and synchronization of keystate buffer.
|
||||
(rev 2)
|
||||
|
||||
---
|
||||
server/queue.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
|
||||
1 file changed, 57 insertions(+), 1 deletion(-)
|
||||
dlls/comctl32/tests/listview.c | 1 +
|
||||
server/queue.c | 58 +++++++++++++++++++++++++++++++++++++++++-
|
||||
2 files changed, 58 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c
|
||||
index 3edb25a..3ec4181 100644
|
||||
--- a/dlls/comctl32/tests/listview.c
|
||||
+++ b/dlls/comctl32/tests/listview.c
|
||||
@@ -2322,6 +2322,7 @@ static void test_multiselect(void)
|
||||
|
||||
selected_count = (int)SendMessageA(hwnd, LVM_GETSELECTEDCOUNT, 0, 0);
|
||||
|
||||
+ todo_wine
|
||||
ok((task.result == -1 ? item_count : task.result) == selected_count, "Failed multiple selection %s. There should be %d selected items (is %d)\n", task.descr, item_count, selected_count);
|
||||
|
||||
/* Set SHIFT key released */
|
||||
diff --git a/server/queue.c b/server/queue.c
|
||||
index 85c0786..f3c8c81 100644
|
||||
index 35ee532..f278861 100644
|
||||
--- a/server/queue.c
|
||||
+++ b/server/queue.c
|
||||
@@ -111,6 +111,7 @@ struct thread_input
|
||||
@@ -113,6 +113,7 @@ struct thread_input
|
||||
user_handle_t cursor; /* current cursor */
|
||||
int cursor_count; /* cursor show count */
|
||||
struct list msg_list; /* list of hardware messages */
|
||||
@ -20,7 +33,7 @@ index 85c0786..f3c8c81 100644
|
||||
unsigned char keystate[256]; /* state of each key */
|
||||
};
|
||||
|
||||
@@ -122,6 +123,7 @@ struct msg_queue
|
||||
@@ -124,6 +125,7 @@ struct msg_queue
|
||||
unsigned int wake_mask; /* wakeup mask */
|
||||
unsigned int changed_bits; /* changed wakeup bits */
|
||||
unsigned int changed_mask; /* changed wakeup mask */
|
||||
@ -28,7 +41,7 @@ index 85c0786..f3c8c81 100644
|
||||
int paint_count; /* pending paint messages count */
|
||||
int hotkey_count; /* pending hotkey messages count */
|
||||
int quit_message; /* is there a pending quit message? */
|
||||
@@ -249,6 +251,7 @@ static struct thread_input *create_thread_input( struct thread *thread )
|
||||
@@ -251,6 +253,7 @@ static struct thread_input *create_thread_input( struct thread *thread )
|
||||
input->move_size = 0;
|
||||
input->cursor = 0;
|
||||
input->cursor_count = 0;
|
||||
@ -36,7 +49,7 @@ index 85c0786..f3c8c81 100644
|
||||
list_init( &input->msg_list );
|
||||
set_caret_window( input, 0 );
|
||||
memset( input->keystate, 0, sizeof(input->keystate) );
|
||||
@@ -282,6 +285,7 @@ static struct msg_queue *create_msg_queue( struct thread *thread, struct thread_
|
||||
@@ -284,6 +287,7 @@ static struct msg_queue *create_msg_queue( struct thread *thread, struct thread_
|
||||
queue->wake_mask = 0;
|
||||
queue->changed_bits = 0;
|
||||
queue->changed_mask = 0;
|
||||
@ -44,7 +57,7 @@ index 85c0786..f3c8c81 100644
|
||||
queue->paint_count = 0;
|
||||
queue->hotkey_count = 0;
|
||||
queue->quit_message = 0;
|
||||
@@ -325,8 +329,10 @@ static int assign_thread_input( struct thread *thread, struct thread_input *new_
|
||||
@@ -327,8 +331,10 @@ static int assign_thread_input( struct thread *thread, struct thread_input *new_
|
||||
}
|
||||
if (queue->input)
|
||||
{
|
||||
@ -55,7 +68,7 @@ index 85c0786..f3c8c81 100644
|
||||
}
|
||||
queue->input = (struct thread_input *)grab_object( new_input );
|
||||
new_input->cursor_count += queue->cursor_count;
|
||||
@@ -970,6 +976,7 @@ static void msg_queue_destroy( struct object *obj )
|
||||
@@ -987,6 +993,7 @@ static void msg_queue_destroy( struct object *obj )
|
||||
free( timer );
|
||||
}
|
||||
if (queue->timeout) remove_timeout_user( queue->timeout );
|
||||
@ -63,7 +76,7 @@ index 85c0786..f3c8c81 100644
|
||||
queue->input->cursor_count -= queue->cursor_count;
|
||||
release_object( queue->input );
|
||||
if (queue->hooks) release_object( queue->hooks );
|
||||
@@ -1279,9 +1286,22 @@ static void update_key_state( struct desktop *desktop, unsigned char *keystate,
|
||||
@@ -1321,9 +1328,22 @@ static void update_key_state( struct desktop *desktop, unsigned char *keystate,
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,7 +99,7 @@ index 85c0786..f3c8c81 100644
|
||||
update_key_state( input->desktop, input->keystate, msg );
|
||||
}
|
||||
|
||||
@@ -1492,6 +1512,15 @@ static void queue_hardware_message( struct desktop *desktop, struct message *msg
|
||||
@@ -1532,6 +1552,15 @@ static void queue_hardware_message( struct desktop *desktop, struct message *msg
|
||||
else
|
||||
{
|
||||
msg->unique_id = 0; /* will be set once we return it to the app */
|
||||
@ -102,7 +115,7 @@ index 85c0786..f3c8c81 100644
|
||||
list_add_tail( &input->msg_list, &msg->entry );
|
||||
set_queue_bits( thread->queue, get_hardware_msg_bit(msg) );
|
||||
}
|
||||
@@ -2363,6 +2392,13 @@ DECL_HANDLER(get_message)
|
||||
@@ -2411,6 +2440,13 @@ DECL_HANDLER(get_message)
|
||||
queue->last_get_msg = current_time;
|
||||
if (!filter) filter = QS_ALLINPUT;
|
||||
|
||||
@ -116,7 +129,7 @@ index 85c0786..f3c8c81 100644
|
||||
/* first check for sent messages */
|
||||
if ((ptr = list_head( &queue->msg_list[SEND_MESSAGE] )))
|
||||
{
|
||||
@@ -2802,13 +2838,33 @@ DECL_HANDLER(get_key_state)
|
||||
@@ -2857,13 +2893,33 @@ DECL_HANDLER(get_key_state)
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -152,5 +165,5 @@ index 85c0786..f3c8c81 100644
|
||||
}
|
||||
|
||||
--
|
||||
2.3.2
|
||||
2.4.2
|
||||
|
||||
|
@ -0,0 +1,79 @@
|
||||
From 6cf46edbed0c41632b183064be0332387275c655 Mon Sep 17 00:00:00 2001
|
||||
From: Sebastian Lackner <sebastian@fds-team.de>
|
||||
Date: Tue, 2 Jun 2015 19:06:56 +0200
|
||||
Subject: server: Introduce a shadow keystate array to sync keystates only on
|
||||
changes.
|
||||
|
||||
---
|
||||
dlls/comctl32/tests/listview.c | 1 -
|
||||
server/queue.c | 18 ++++++++++++++++--
|
||||
2 files changed, 16 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c
|
||||
index 3ec4181..3edb25a 100644
|
||||
--- a/dlls/comctl32/tests/listview.c
|
||||
+++ b/dlls/comctl32/tests/listview.c
|
||||
@@ -2322,7 +2322,6 @@ static void test_multiselect(void)
|
||||
|
||||
selected_count = (int)SendMessageA(hwnd, LVM_GETSELECTEDCOUNT, 0, 0);
|
||||
|
||||
- todo_wine
|
||||
ok((task.result == -1 ? item_count : task.result) == selected_count, "Failed multiple selection %s. There should be %d selected items (is %d)\n", task.descr, item_count, selected_count);
|
||||
|
||||
/* Set SHIFT key released */
|
||||
diff --git a/server/queue.c b/server/queue.c
|
||||
index f278861..76fa3e3 100644
|
||||
--- a/server/queue.c
|
||||
+++ b/server/queue.c
|
||||
@@ -115,6 +115,7 @@ struct thread_input
|
||||
struct list msg_list; /* list of hardware messages */
|
||||
int lock_count; /* lock counter for keystate */
|
||||
unsigned char keystate[256]; /* state of each key */
|
||||
+ unsigned char shadow_keystate[256]; /* shadow copy of keystate */
|
||||
};
|
||||
|
||||
struct msg_queue
|
||||
@@ -257,6 +258,7 @@ static struct thread_input *create_thread_input( struct thread *thread )
|
||||
list_init( &input->msg_list );
|
||||
set_caret_window( input, 0 );
|
||||
memset( input->keystate, 0, sizeof(input->keystate) );
|
||||
+ memset( input->shadow_keystate, 0, sizeof(input->shadow_keystate) );
|
||||
|
||||
if (!(input->desktop = get_thread_desktop( thread, 0 /* FIXME: access rights */ )))
|
||||
{
|
||||
@@ -1094,7 +1096,11 @@ int attach_thread_input( struct thread *thread_from, struct thread *thread_to )
|
||||
}
|
||||
|
||||
ret = assign_thread_input( thread_from, input );
|
||||
- if (ret) memset( input->keystate, 0, sizeof(input->keystate) );
|
||||
+ if (ret)
|
||||
+ {
|
||||
+ memset( input->keystate, 0, sizeof(input->keystate) );
|
||||
+ memset( input->shadow_keystate, 0, sizeof(input->shadow_keystate) );
|
||||
+ }
|
||||
release_object( input );
|
||||
return ret;
|
||||
}
|
||||
@@ -1333,10 +1339,18 @@ static void synchronize_input_key_state( struct thread_input *input )
|
||||
{
|
||||
if (!input->lock_count)
|
||||
{
|
||||
+ unsigned char *shadow_keystate = input->shadow_keystate;
|
||||
unsigned char *keystate = input->keystate;
|
||||
unsigned int i;
|
||||
+
|
||||
for (i = 0; i < 256; i++)
|
||||
- keystate[i] = input->desktop->keystate[i] & ~0x40;
|
||||
+ {
|
||||
+ if (input->desktop->keystate[i] != shadow_keystate[i])
|
||||
+ {
|
||||
+ keystate[i] = input->desktop->keystate[i] & ~0x40;
|
||||
+ shadow_keystate[i] = input->desktop->keystate[i];
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
--
|
||||
2.4.2
|
||||
|
@ -1,34 +0,0 @@
|
||||
From 9b712bd80a30791f533cb1552660225ea7434955 Mon Sep 17 00:00:00 2001
|
||||
From: Sebastian Lackner <sebastian@fds-team.de>
|
||||
Date: Mon, 1 Jun 2015 21:05:14 +0200
|
||||
Subject: server: Lock thread specific keystate in set_key_state wineserver
|
||||
call.
|
||||
|
||||
---
|
||||
server/queue.c | 10 +++++++++-
|
||||
1 file changed, 9 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/server/queue.c b/server/queue.c
|
||||
index f278861..74e6e24 100644
|
||||
--- a/server/queue.c
|
||||
+++ b/server/queue.c
|
||||
@@ -2940,7 +2940,15 @@ DECL_HANDLER(set_key_state)
|
||||
else
|
||||
{
|
||||
if (!(thread = get_thread_from_id( req->tid ))) return;
|
||||
- if (thread->queue) memcpy( thread->queue->input->keystate, get_req_data(), size );
|
||||
+ if (thread->queue)
|
||||
+ {
|
||||
+ memcpy( thread->queue->input->keystate, get_req_data(), size );
|
||||
+ if (!thread->queue->keystate_locked)
|
||||
+ {
|
||||
+ thread->queue->input->lock_count++;
|
||||
+ thread->queue->keystate_locked = 1;
|
||||
+ }
|
||||
+ }
|
||||
if (req->async && (desktop = get_thread_desktop( thread, 0 )))
|
||||
{
|
||||
memcpy( desktop->keystate, get_req_data(), size );
|
||||
--
|
||||
2.4.2
|
||||
|
Loading…
x
Reference in New Issue
Block a user