Help in patching wine to NOT filter keyboard/mouse messages

Questions about Wine on Linux
Locked
linuxs64
Newbie
Newbie
Posts: 2
Joined: Wed Sep 07, 2016 4:37 am

Help in patching wine to NOT filter keyboard/mouse messages

Post by linuxs64 »

I'm trying to send stimulated keyboard/mouse events via xdotool, to wine apps (minimized) but not getting any response, found a lead that could solve this issue.

Been trying for 3 weeks to fix this. Tried liboverride & xsendevent, but only worked for X apps, not wine. http://www.semicomplete.com/blog/tags/xsendevent

But I am not good in programming
After some research I finally found a way, you just have to patch wineserver a bit to make it pass messages to non-focused windows through. viewtopic.php?f=8&t=16781#p80200
Some info about the patch/hack, responsible for filtering keyboard messages for inactive windows in wine. viewtopic.php?f=8&t=16781#p80099

source file, /wine/server/queue.c, https://github.com/wine-mirror/wine/blo ... er/queue.c

function find_hardware_message_window

Please change to allow messages to non-focused/minimized windows, thank you. Please help.

line 1402

Code: Select all

/* find the window that should receive a given hardware message */
static user_handle_t find_hardware_message_window( struct desktop *desktop, struct thread_input *input,
                                                   struct message *msg, unsigned int *msg_code,
                                                   struct thread **thread )
{
    user_handle_t win = 0;

    *thread = NULL;
    *msg_code = msg->msg;
    if (msg->msg == WM_INPUT)
    {
        if (!(win = msg->win) && input) win = input->focus;
    }
    else if (is_keyboard_msg( msg ))
    {
        if (input && !(win = input->focus))
        {
            win = input->active;
            if (*msg_code < WM_SYSKEYDOWN) *msg_code += WM_SYSKEYDOWN - WM_KEYDOWN;
        }
    }
    else if (!input || !(win = input->capture)) /* mouse message */
    {
        if (is_window_visible( msg->win ) && !is_window_transparent( msg->win )) win = msg->win;
        else win = shallow_window_from_point( desktop, msg->x, msg->y );

        *thread = window_thread_from_point( win, msg->x, msg->y );
    }

    if (!*thread)
        *thread = get_window_thread( win );
    return win;
}

static struct rawinput_device_entry *find_rawinput_device( unsigned short usage_page, unsigned short usage )
{
    struct rawinput_device_entry *e;

    LIST_FOR_EACH_ENTRY( e, &current->process->rawinput_devices, struct rawinput_device_entry, entry )
    {
        if (e->device.usage_page != usage_page || e->device.usage != usage) continue;
        return e;
    }

    return NULL;
}

static void update_rawinput_device(const struct rawinput_device *device)
{
    struct rawinput_device_entry *e;

    if (!(e = find_rawinput_device( 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 );
}
line 1517

Code: Select all

    win = find_hardware_message_window( desktop, input, msg, &msg_code, &thread );
    if (!win || !thread)
    {
        if (input) update_input_key_state( input->desktop, input->keystate, msg );
        free_message( msg );
        return;
    }
line 1958

Code: Select all

        win = find_hardware_message_window( input->desktop, input, msg, &msg_code, &win_thread );
        if (!win || !win_thread)
        {
            /* no window at all, remove it */
            update_input_key_state( input->desktop, input->keystate, msg );
            list_remove( &msg->entry );
            free_message( msg );
            continue;
        }
markmeson
Newbie
Newbie
Posts: 3
Joined: Tue Oct 18, 2016 7:47 am

Re: Help in patching wine to NOT filter keyboard/mouse messa

Post by markmeson »

I have searched for hours trying to figure out where wine filters out these key presses but to no avail.
message.c
queue.c
request.c
and many other files .. can't find anything.
Apparently it is not filtered out until after sent as a request to the server.

Can anyone help please??
Thanks..
Locked