[PATCH 1/3] Add wayland support
Alexander Preisinger
alexander.preisinger at gmail.com
Sat Aug 25 00:20:53 PDT 2012
Sorry I didn't send it to the mailing list.
2012/8/24 Pekka Paalanen <ppaalanen at gmail.com>:
> On Fri, 24 Aug 2012 08:08:22 +0200
> Alexander Preisinger <alexander.preisinger at gmail.com> wrote:
>
>> Implements shared routines for initialising wayland and keyboard/pointer input.
>> Indepentend from the video output.
>
> Hi,
>
> I have some wayland protocol related comments below, inline.
>
>> +static void create_display (struct wl_priv *wl);
>> +static void create_window (struct wl_priv *wl, int width, int height);
>> +
>> +/* SHELL SURFACE LISTENER */
>> +static void ssurface_handle_ping (void *data,
>> + struct wl_shell_surface *shell_surface, uint32_t serial)
>> +{
>> + wl_shell_surface_pong(shell_surface, serial);
>> +}
>> +
>> +static void ssurface_handle_configure (void *data,
>> + struct wl_shell_surface *shell_surface,
>> + uint32_t edges, int32_t width, int32_t height)
>> +{
>> +}
>> +
>> +static void ssurface_handle_popup_done (void *data,
>> + struct wl_shell_surface *shell_surface)
>> +{
>> +}
>> +
>> +const struct wl_shell_surface_listener shell_surface_listener = {
>> + ssurface_handle_ping,
>> + ssurface_handle_configure,
>> + ssurface_handle_popup_done
>> +};
>> +
>> +/* OUTPUT LISTENER */
>> +static void output_handle_geometry (void *data, struct wl_output *wl_output,
>> + int32_t x, int32_t y, int32_t physical_width, int32_t physical_height,
>> + int32_t subpixel, const char *make, const char *model,
>> + int32_t transform)
>> +{
>> + struct vo_wl_display *d = data;
>> +
>> + d->pos_x = x;
>> + d->pos_y = y;
>
> What are these x and y used for? They are leftovers from the global
> coordinate system removal, and I don't think they should be used at all.
>
> Doesn't mplayer use the physical dimensions for anything?
>
> Later you would also want to take care of the transform, so that for a
> rotated output, you can render a rotated image so that Weston is not
> forced to rotate it. That would be especially useful for fullscreen
> output, where weston might be able to scan out your image without
> compositing it first.
>
>> +}
>> +
>> +static void output_handle_mode (void *data, struct wl_output *wl_output,
>> + uint32_t flags, int32_t width, int32_t height, int32_t refresh)
>> +{
>> + struct vo_wl_display *d = data;
>> +
>> + d->output_height = height;
>> + d->output_width = width;
>> + d->mode_received = 1;
>
> You will get a mode event for every possible video mode an output *may*
> have. If you want the current mode, you need to pick the one which has
> "current" flag set. Note, that the x11 backend of Weston does not
> advertise more than one mode, but the DRM backend does.
>
> I think this event is also sent, when the output mode is changed... or
> at least when the default mode is changed, not sure if it is emitted
> for fullscreen switches.
>
>> +}
>> +
>> +const struct wl_output_listener output_listener = {
>> + output_handle_geometry,
>> + output_handle_mode
>> +};
>
>> +/* POINTER LISTENER */
>> +static void pointer_handle_enter(void *data, struct wl_pointer *pointer,
>> + uint32_t serial, struct wl_surface *surface,
>> + wl_fixed_t sx_w, wl_fixed_t sy_w)
>> +{
>
> I think you should set a cursor here, or set a NULL cursor if you want
> to hide it. Otherwise you probably get whatever cursor another client
> set earlier.
>
>> +}
>> +
>> +static void pointer_handle_leave(void *data, struct wl_pointer *pointer,
>> + uint32_t serial, struct wl_surface *surface)
>> +{
>> +}
>> +
>> +static void pointer_handle_motion(void *data, struct wl_pointer *pointer,
>> + uint32_t time, wl_fixed_t sx_w, wl_fixed_t sy_w)
>> +{
>> +}
>> +
>> +static void pointer_handle_button(void *data, struct wl_pointer *pointer,
>> + uint32_t serial, uint32_t time, uint32_t button, uint32_t state)
>> +{
>> + struct wl_priv *wl = data;
>> +
>> + mplayer_put_key(wl->vo->key_fifo, MOUSE_BTN0 + (button - BTN_LEFT) |
>> + ((state == WL_POINTER_BUTTON_STATE_PRESSED) ? MP_KEY_DOWN : 0));
>> +}
>> +
>> +static void pointer_handle_axis(void *data, struct wl_pointer *pointer,
>> + uint32_t time, uint32_t axis, wl_fixed_t value)
>> +{
>> + struct wl_priv *wl = data;
>> +
>> + if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL) {
>> + if (value > 0)
>> + mplayer_put_key(wl->vo->key_fifo, MOUSE_BTN3);
>> + if (value < 0)
>> + mplayer_put_key(wl->vo->key_fifo, MOUSE_BTN4);
>> + }
>
> I wonder if you should use the value to determine, how many
> "emulated button clicks" to give to mplayer.
I changed most of it according to your suggestions, but for this I think
I should do more testing. Because when using the scroll wheel or touchpad it
seek forward too fast.
Thank you for your time.
>> +}
>> +
>> +static const struct wl_pointer_listener pointer_listener = {
>> + pointer_handle_enter,
>> + pointer_handle_leave,
>> + pointer_handle_motion,
>> + pointer_handle_button,
>> + pointer_handle_axis,
>> +};
>
>
> Thanks,
> pq
More information about the wayland-devel
mailing list