[PATCH v2 5/6] server: Don't emulate rawinput mouse events if native exist.

Derek Lesho dereklesho52 at gmail.com
Tue Jul 23 11:16:21 CDT 2019


Well, while it is certainly possible to use actual rawinput for sending
keyboard events and mouse presses, I don't see much of an incentive to.
With mouse motion, the DE is bypassed so mouse acceleration and sensitivity
are bypassed (just like on windows), but I don't think DE's modify keyboard
events or mouse presses in any meaningful way.

Plus, the fewer code paths we have doing the same thing the better I think.

On Tue, Jul 23, 2019 at 4:08 AM Rémi Bernon <rbernon at codeweavers.com> wrote:

> On Sat, 2019-06-29 at 22:26 -0400, Derek Lesho wrote:
> > Signed-off-by: Derek Lesho <dereklesho52 at Gmail.com>
> > ---
> >  server/protocol.def |  2 +
> >  server/queue.c      | 99 ++++++++++++++++++++++++++-------------------
> >  2 files changed, 59 insertions(+), 42 deletions(-)
> >
> > diff --git a/server/protocol.def b/server/protocol.def
> > index 3a6a202f49..9703b49154 100644
> > --- a/server/protocol.def
> > +++ b/server/protocol.def
> > @@ -358,6 +358,8 @@ typedef union
> >      } hw;
> >  } hw_input_t;
> >
> > +#define RIM_ENABLE_NATIVE_MOUSE_MOVE   0x0800
> > +#define RIM_ENABLE_NATIVE_MOUSE_PRESS  0x1000
> >  typedef union
> >  {
> >      int type;
> > diff --git a/server/queue.c b/server/queue.c
> > index 35cfcecff5..41c26d8fa0 100644
> > --- a/server/queue.c
> > +++ b/server/queue.c
> > @@ -1599,6 +1599,9 @@ static int send_hook_ll_message( struct desktop
> *desktop, struct message *hardwa
> >      return 1;
> >  }
> >
> > +int emulate_raw_mouse_move = 1;
> > +int emulate_raw_mouse_press = 1;
> > +
> >  /* queue a hardware message for a mouse event */
> >  static int queue_mouse_message( struct desktop *desktop, user_handle_t
> win, const hw_input_t *input,
> >                                  unsigned int origin, struct msg_queue
> *sender )
> > @@ -1666,53 +1669,59 @@ static int queue_mouse_message( struct desktop
> *desktop, user_handle_t win, cons
> >
> >      if ((device = current->process->rawinput_mouse))
> >      {
> > -        if (!(msg = alloc_hardware_message( input->mouse.info, source,
> time ))) return 0;
> > -        msg_data = msg->data;
> > +        if ( (emulate_raw_mouse_press && flags & ~MOUSEEVENTF_MOVE) ||
> (emulate_raw_mouse_move && flags & MOUSEEVENTF_MOVE) )
> > +        {
> > +            if (!(msg = alloc_hardware_message( input->mouse.info,
> source, time ))) return 0;
> > +            msg_data = msg->data;
> >
> > -        msg->win       = device->target;
> > -        msg->msg       = WM_INPUT;
> > -        msg->wparam    = RIM_INPUT;
> > -        msg->lparam    = 0;
> > +            msg->win       = device->target;
> > +            msg->msg       = WM_INPUT;
> > +            msg->wparam    = RIM_INPUT;
> > +            msg->lparam    = 0;
> >
> > -        msg_data->flags               = 0;
> > -        msg_data->rawinput.type       = RIM_TYPEMOUSE;
> > -        msg_data->rawinput.mouse.x    = x - desktop->cursor.x;
> > -        msg_data->rawinput.mouse.y    = y - desktop->cursor.y;
> > -        msg_data->rawinput.mouse.button_flags = 0;
> > -        msg_data->rawinput.mouse.button_data = 0;
> > +            msg_data->flags               = 0;
> > +            msg_data->rawinput.type       = RIM_TYPEMOUSE;
> > +            msg_data->rawinput.mouse.x    = emulate_raw_mouse_move ? x
> - desktop->cursor.x : 0;
> > +            msg_data->rawinput.mouse.y    = emulate_raw_mouse_move ? y
> - desktop->cursor.y : 0;
> > +            msg_data->rawinput.mouse.button_flags = 0;
> > +            msg_data->rawinput.mouse.button_data = 0;
> >
> > -        for (i = 1; i < ARRAY_SIZE(raw_button_flags); ++i)
> > -        {
> > -            if (flags & (1 << i))
> > -                msg_data->rawinput.mouse.button_flags |=
> raw_button_flags[i];
> > -        }
> > +            if (emulate_raw_mouse_press)
> > +            {
> > +                for (i = 1; i < ARRAY_SIZE(raw_button_flags); ++i)
> > +                {
> > +                    if (flags & (1 << i))
> > +                        msg_data->rawinput.mouse.button_flags |=
> raw_button_flags[i];
> > +                }
> >
> > -        if (flags & MOUSEEVENTF_WHEEL)
> > -        {
> > -            msg_data->rawinput.mouse.button_flags |= RI_MOUSE_WHEEL;
> > -            msg_data->rawinput.mouse.button_data   = input->mouse.data;
> > -        }
> > -        if (flags & MOUSEEVENTF_HWHEEL)
> > -        {
> > -            msg_data->rawinput.mouse.button_flags |=
> RI_MOUSE_HORIZONTAL_WHEEL;
> > -            msg_data->rawinput.mouse.button_data   = input->mouse.data;
> > -        }
> > -        if (flags & MOUSEEVENTF_XDOWN)
> > -        {
> > -            if (input->mouse.data == XBUTTON1)
> > -                msg_data->rawinput.mouse.button_flags |=
> RI_MOUSE_BUTTON_4_DOWN;
> > -            else if (input->mouse.data == XBUTTON2)
> > -                msg_data->rawinput.mouse.button_flags |=
> RI_MOUSE_BUTTON_5_DOWN;
> > -        }
> > -        if (flags & MOUSEEVENTF_XUP)
> > -        {
> > -            if (input->mouse.data == XBUTTON1)
> > -                msg_data->rawinput.mouse.button_flags |=
> RI_MOUSE_BUTTON_4_UP;
> > -            else if (input->mouse.data == XBUTTON2)
> > -                msg_data->rawinput.mouse.button_flags |=
> RI_MOUSE_BUTTON_5_UP;
> > -        }
> > +                if (flags & MOUSEEVENTF_WHEEL)
> > +                {
> > +                    msg_data->rawinput.mouse.button_flags |=
> RI_MOUSE_WHEEL;
> > +                    msg_data->rawinput.mouse.button_data   =
> input->mouse.data;
> > +                }
> > +                if (flags & MOUSEEVENTF_HWHEEL)
> > +                {
> > +                    msg_data->rawinput.mouse.button_flags |=
> RI_MOUSE_HORIZONTAL_WHEEL;
> > +                    msg_data->rawinput.mouse.button_data   =
> input->mouse.data;
> > +                }
> > +                if (flags & MOUSEEVENTF_XDOWN)
> > +                {
> > +                    if (input->mouse.data == XBUTTON1)
> > +                        msg_data->rawinput.mouse.button_flags |=
> RI_MOUSE_BUTTON_4_DOWN;
> > +                    else if (input->mouse.data == XBUTTON2)
> > +                        msg_data->rawinput.mouse.button_flags |=
> RI_MOUSE_BUTTON_5_DOWN;
> > +                }
> > +                if (flags & MOUSEEVENTF_XUP)
> > +                {
> > +                    if (input->mouse.data == XBUTTON1)
> > +                        msg_data->rawinput.mouse.button_flags |=
> RI_MOUSE_BUTTON_4_UP;
> > +                    else if (input->mouse.data == XBUTTON2)
> > +                        msg_data->rawinput.mouse.button_flags |=
> RI_MOUSE_BUTTON_5_UP;
> > +                }
> > +            }
> >
> > -        queue_hardware_message( desktop, msg, 0 );
> > +            queue_hardware_message( desktop, msg, 0 );
> > +        }
> >
> >          if (device->flags & RIDEV_NOLEGACY)
> >              return FALSE;
> > @@ -2455,6 +2464,12 @@ DECL_HANDLER(send_rawinput_message)
> >              queue_hardware_message( desktop, msg, 0 );
> >          }
> >          break;
> > +    case RIM_ENABLE_NATIVE_MOUSE_MOVE:
> > +        emulate_raw_mouse_move = 0;
> > +        break;
> > +    case RIM_ENABLE_NATIVE_MOUSE_PRESS:
> > +        emulate_raw_mouse_press = 0;
> > +        break;
> >      default:
> >          set_error( STATUS_INVALID_PARAMETER );
> >      }
>
> Don't you think we could simplify that by using only one
> emulate_raw_input flag? Are there any platforms where only some of the
> raw input events are received?
>
> Also the flag could probably be cleared on the first direct raw input
> request received instead of requiring private flag values, and an empty
> raw input event could be sent right after the initialization if we
> still want to be informed early on.
> --
> Rémi Bernon <rbernon at codeweavers.com>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20190723/9fa787b4/attachment-0001.html>


More information about the wine-devel mailing list