[PATCH] compositor-x11: convert (some) of X11 buttons to linux input

Kristian Høgsberg krh at bitplanet.net
Thu Dec 8 10:27:20 PST 2011


On Thu, Dec 8, 2011 at 10:16 AM, Pekka Paalanen <ppaalanen at gmail.com> wrote:
> On Thu,  8 Dec 2011 17:03:17 +0200
> Tiago Vignatti <vignatti at freedesktop.org> wrote:
>
>> From: Tiago Vignatti <tiago.vignatti at intel.com>
>>
>> Signed-off-by: Tiago Vignatti <tiago.vignatti at intel.com>
>
> Reviewed-by: Pekka Paalanen <ppaalanen at gmail.com>
>
> For the record, this patch:
> - emits booboo instead of some arbitrary button events for wheel
>  rotation, so wheel on x11 backend will need more fixing.
> - on the x11 backend, swaps the middle and right mouse buttons, so that
>  it will be same as with the drm backend.

Right, I committed the patch but edited it to just not send events for
scroll wheels for now.  We have a good idea for how we want input to
evolve, and I'll send that document to the list soon.  One of the
changes is that we're adding an "axis" event, that can carry
information such as scroll wheel motion.  However, I'm a little
reluctant to start changing it incrementally, as each step will break
all clients, so for now we'll just throw scroll events away.

Kristian

>> ---
>>  compositor/compositor-x11.c |   31 +++++++++++++++++++++++++++++--
>>  1 files changed, 29 insertions(+), 2 deletions(-)
>>
>> diff --git a/compositor/compositor-x11.c b/compositor/compositor-x11.c
>> index 544d7e2..870d57a 100644
>> --- a/compositor/compositor-x11.c
>> +++ b/compositor/compositor-x11.c
>> @@ -453,6 +453,31 @@ x11_compositor_find_output(struct x11_compositor
>> *c, xcb_window_t window) return NULL;
>>  }
>>
>> +/*
>> + * x11_to_rawinput - convert X11 button detail to linux input
>> + */
>> +static int
>> +x11_to_rawinput(int detail)
>> +{
>> +     switch (detail) {
>> +     case 1:
>> +             return BTN_LEFT;
>> +     case 2:
>> +             return BTN_MIDDLE;
>> +     case 3:
>> +             return BTN_RIGHT;
>> +     case 4:
>> +     case 5:
>> +             /* X11 sends wheel button up and down respectively
>> as 4 and 5.
>> +              * But linux input treats as REL_WHEEL, therefore
>> not button
>> +              * type at all. If we care about them we have to
>> implement a
>> +              * different logic and forward as notify_motion.  */
>> +             return -2;
>> +     }
>> +
>> +     return -1;
>> +}
>> +
>>  static int
>>  x11_compositor_next_event(struct x11_compositor *c,
>>                         xcb_generic_event_t **event, uint32_t mask)
>> @@ -556,13 +581,15 @@ x11_compositor_handle_event(int fd, uint32_t
>> mask, void *data) button_press = (xcb_button_press_event_t *) event;
>>                       notify_button(c->base.input_device,
>>                                     wlsc_compositor_get_time(),
>> -                                   button_press->detail +
>> BTN_LEFT - 1, 1);
>> +
>> x11_to_rawinput(button_press->detail),
>> +                                   1);
>>                       break;
>>               case XCB_BUTTON_RELEASE:
>>                       button_press = (xcb_button_press_event_t *)
>> event; notify_button(c->base.input_device,
>>                                     wlsc_compositor_get_time(),
>> -                                   button_press->detail +
>> BTN_LEFT - 1, 0);
>> +
>> x11_to_rawinput(button_press->detail),
>> +                                   0);
>>                       break;
>>
>>               case XCB_MOTION_NOTIFY:
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list