Commit a2395ecf authored by Rémi Bernon's avatar Rémi Bernon 💬 Committed by Alexandre Julliard
Browse files

server: Use the client provided rawinput registered device array.

parent 1587e9db
......@@ -860,29 +860,27 @@ BOOL WINAPI NtUserRegisterRawInputDevices( const RAWINPUTDEVICE *devices, UINT d
registered_devices = realloc( registered_devices, size );
if (registered_devices) for (i = 0; i < device_count; ++i) register_rawinput_device( devices + i );
pthread_mutex_unlock( &rawinput_mutex );
if (!registered_devices)
server_devices = malloc( registered_device_count * sizeof(*server_devices) );
if (server_devices) for (i = 0; i < registered_device_count; ++i)
{
SetLastError( ERROR_OUTOFMEMORY );
return FALSE;
server_devices[i].usage_page = registered_devices[i].usUsagePage;
server_devices[i].usage = registered_devices[i].usUsage;
server_devices[i].flags = registered_devices[i].dwFlags;
server_devices[i].target = wine_server_user_handle( registered_devices[i].hwndTarget );
}
if (!(server_devices = malloc( device_count * sizeof(*server_devices) ))) return FALSE;
pthread_mutex_unlock( &rawinput_mutex );
for (i = 0; i < device_count; ++i)
if (!registered_devices || !server_devices)
{
server_devices[i].usage_page = devices[i].usUsagePage;
server_devices[i].usage = devices[i].usUsage;
server_devices[i].flags = devices[i].dwFlags;
server_devices[i].target = wine_server_user_handle( devices[i].hwndTarget );
SetLastError( ERROR_OUTOFMEMORY );
return FALSE;
}
SERVER_START_REQ( update_rawinput_devices )
{
wine_server_add_data( req, server_devices, device_count * sizeof(*server_devices) );
ret = !wine_server_call( req );
ret = !wine_server_call_err( req );
}
SERVER_END_REQ;
......
......@@ -678,6 +678,8 @@ struct process *create_process( int fd, struct process *parent, unsigned int fla
process->desktop = 0;
process->token = NULL;
process->trace_data = 0;
process->rawinput_devices = NULL;
process->rawinput_device_count = 0;
process->rawinput_mouse = NULL;
process->rawinput_kbd = NULL;
memset( &process->image_info, 0, sizeof(process->image_info) );
......@@ -687,7 +689,6 @@ struct process *create_process( int fd, struct process *parent, unsigned int fla
list_init( &process->asyncs );
list_init( &process->classes );
list_init( &process->views );
list_init( &process->rawinput_devices );
process->end_time = 0;
......@@ -782,6 +783,7 @@ static void process_destroy( struct object *obj )
if (process->idle_event) release_object( process->idle_event );
if (process->id) free_ptid( process->id );
if (process->token) release_object( process->token );
free( process->rawinput_devices );
free( process->dir_cache );
free( process->image );
}
......@@ -959,8 +961,6 @@ void kill_console_processes( struct thread *renderer, int exit_code )
/* a process has been killed (i.e. its last thread died) */
static void process_killed( struct process *process )
{
struct list *ptr;
assert( list_empty( &process->thread_list ));
process->end_time = current_time;
close_process_desktop( process );
......@@ -972,12 +972,6 @@ static void process_killed( struct process *process )
process->idle_event = NULL;
assert( !process->console );
while ((ptr = list_head( &process->rawinput_devices )))
{
struct rawinput_device_entry *entry = LIST_ENTRY( ptr, struct rawinput_device_entry, entry );
list_remove( &entry->entry );
free( entry );
}
destroy_process_classes( process );
free_mapped_views( process );
free_process_user_handles( process );
......
......@@ -33,12 +33,6 @@ enum startup_state { STARTUP_IN_PROGRESS, STARTUP_DONE, STARTUP_ABORTED };
/* process structures */
struct rawinput_device_entry
{
struct list entry;
struct rawinput_device device;
};
struct process
{
struct object obj; /* object header */
......@@ -85,7 +79,8 @@ struct process
client_ptr_t ldt_copy; /* pointer to LDT copy in client addr space */
struct dir_cache *dir_cache; /* map of client-side directory cache */
unsigned int trace_data; /* opaque data used by the process tracing mechanism */
struct list rawinput_devices;/* list of registered rawinput devices */
struct rawinput_device *rawinput_devices; /* list of registered rawinput devices */
unsigned int rawinput_device_count; /* number of registered rawinput devices */
const struct rawinput_device *rawinput_mouse; /* rawinput mouse device, if any */
const struct rawinput_device *rawinput_kbd; /* rawinput keyboard device, if any */
struct list kernel_object; /* list of kernel object pointers */
......
......@@ -1532,40 +1532,19 @@ static user_handle_t find_hardware_message_window( struct desktop *desktop, stru
return win;
}
static struct rawinput_device_entry *find_rawinput_device( struct process *process, unsigned short usage_page, unsigned short usage )
static struct rawinput_device *find_rawinput_device( struct process *process, unsigned short usage_page, unsigned short usage )
{
struct rawinput_device_entry *e;
struct rawinput_device *device, *end;
LIST_FOR_EACH_ENTRY( e, &process->rawinput_devices, struct rawinput_device_entry, entry )
for (device = process->rawinput_devices, end = device + process->rawinput_device_count; device != end; device++)
{
if (e->device.usage_page != usage_page || e->device.usage != usage) continue;
return e;
if (device->usage_page != usage_page || device->usage != usage) continue;
return device;
}
return NULL;
}
static void update_rawinput_device(const struct rawinput_device *device)
{
struct rawinput_device_entry *e;
if (!(e = find_rawinput_device( current->process, device->usage_page, device->usage )))
{
if (!(e = mem_alloc( sizeof(*e) ))) return;
list_add_tail( &current->process->rawinput_devices, &e->entry );
}
if (device->flags & RIDEV_REMOVE)
{
list_remove( &e->entry );
free( e );
return;
}
e->device = *device;
e->device.target = get_user_full_handle( e->device.target );
}
static void prepend_cursor_history( int x, int y, unsigned int time, lparam_t info )
{
cursor_pos_t *pos = &cursor_history[--cursor_history_latest % ARRAY_SIZE(cursor_history)];
......@@ -1714,7 +1693,6 @@ struct rawinput_message
static int queue_rawinput_message( struct process* process, void *arg )
{
const struct rawinput_message* raw_msg = arg;
const struct rawinput_device_entry *entry;
const struct rawinput_device *device = NULL;
struct desktop *target_desktop = NULL, *desktop = NULL;
struct thread *target_thread = NULL, *foreground = NULL;
......@@ -1726,8 +1704,8 @@ static int queue_rawinput_message( struct process* process, void *arg )
device = process->rawinput_mouse;
else if (raw_msg->data.rawinput.type == RIM_TYPEKEYBOARD)
device = process->rawinput_kbd;
else if ((entry = find_rawinput_device( process, raw_msg->data.rawinput.hid.usage_page, raw_msg->data.rawinput.hid.usage )))
device = &entry->device;
else
device = find_rawinput_device( process, raw_msg->data.rawinput.hid.usage_page, raw_msg->data.rawinput.hid.usage );
if (!device) return 0;
if (raw_msg->message == WM_INPUT_DEVICE_CHANGE && !(device->flags & RIDEV_DEVNOTIFY)) return 0;
......@@ -3397,18 +3375,20 @@ DECL_HANDLER(get_rawinput_buffer)
DECL_HANDLER(update_rawinput_devices)
{
const struct rawinput_device *devices = get_req_data();
const struct rawinput_device *tmp, *devices = get_req_data();
unsigned int device_count = get_req_data_size() / sizeof (*devices);
const struct rawinput_device_entry *e;
unsigned int i;
size_t size = device_count * sizeof(*devices);
struct process *process = current->process;
for (i = 0; i < device_count; ++i)
if (!(tmp = realloc( process->rawinput_devices, size )))
{
update_rawinput_device(&devices[i]);
set_error( STATUS_NO_MEMORY );
return;
}
process->rawinput_devices = (struct rawinput_device *)tmp;
process->rawinput_device_count = device_count;
memcpy( process->rawinput_devices, devices, size );
e = find_rawinput_device( current->process, 1, 2 );
current->process->rawinput_mouse = e ? &e->device : NULL;
e = find_rawinput_device( current->process, 1, 6 );
current->process->rawinput_kbd = e ? &e->device : NULL;
process->rawinput_mouse = find_rawinput_device( process, 1, 2 );
process->rawinput_kbd = find_rawinput_device( process, 1, 6 );
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment