Re: [PATCH 1/3] Add wayland support

2012-08-25 Thread Alexander Preisinger
Sorry I didn't send it to the mailing list.

2012/8/24 Pekka Paalanen ppaala...@gmail.com:
 On Fri, 24 Aug 2012 08:08:22 +0200
 Alexander Preisinger alexander.preisin...@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
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org

[PATCH 1/3] Add wayland support

2012-08-24 Thread Alexander Preisinger
Implements shared routines for initialising wayland and keyboard/pointer input.
Indepentend from the video output.
---
 libvo/wl_common.c | 634 ++
 libvo/wl_common.h | 131 +++
 2 files changed, 765 insertions(+)
 create mode 100644 libvo/wl_common.c
 create mode 100644 libvo/wl_common.h

diff --git a/libvo/wl_common.c b/libvo/wl_common.c
new file mode 100644
index 000..e271e5d
--- /dev/null
+++ b/libvo/wl_common.c
@@ -0,0 +1,634 @@
+/*
+ * This file is part of MPlayer.
+ *
+ * MPlayer is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MPlayer is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with MPlayer; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include stdio.h
+#include stdlib.h
+#include math.h
+#include inttypes.h
+#include limits.h
+#include assert.h
+
+#include unistd.h
+#include sys/mman.h
+#include sys/timerfd.h
+
+#include config.h
+#include bstr.h
+#include options.h
+#include mp_msg.h
+#include mp_fifo.h
+#include libavutil/common.h
+#include talloc.h
+
+#include wl_common.h
+
+#include video_out.h
+#include aspect.h
+#include geometry.h
+#include osdep/timer.h
+
+#include subopt-helper.h
+
+#include input/input.h
+#include input/keycodes.h
+
+#ifdef CONFIG_GL_WAYLAND
+#include wayland-egl.h
+#endif
+
+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;
+}
+
+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;
+}
+
+const struct wl_output_listener output_listener = {
+output_handle_geometry,
+output_handle_mode
+};
+
+/* KEY LOOKUP */
+static const struct mp_keymap keymap[] = {
+// special keys
+{XKB_KEY_Pause, KEY_PAUSE}, {XKB_KEY_Escape, KEY_ESC},
+{XKB_KEY_BackSpace, KEY_BS}, {XKB_KEY_Tab, KEY_TAB},
+{XKB_KEY_Return, KEY_ENTER}, {XKB_KEY_Menu, KEY_MENU},
+{XKB_KEY_Print, KEY_PRINT},
+
+// cursor keys
+{XKB_KEY_Left, KEY_LEFT}, {XKB_KEY_Right, KEY_RIGHT},
+{XKB_KEY_Up, KEY_UP}, {XKB_KEY_Down, KEY_DOWN},
+
+// navigation block
+{XKB_KEY_Insert, KEY_INSERT}, {XKB_KEY_Delete, KEY_DELETE},
+{XKB_KEY_Home, KEY_HOME}, {XKB_KEY_End, KEY_END},
+{XKB_KEY_Page_Up, KEY_PAGE_UP}, {XKB_KEY_Page_Down, KEY_PAGE_DOWN},
+
+// F-keys
+{XKB_KEY_F1, KEY_F+1}, {XKB_KEY_F2, KEY_F+2}, {XKB_KEY_F3, KEY_F+3},
+{XKB_KEY_F4, KEY_F+4}, {XKB_KEY_F5, KEY_F+5}, {XKB_KEY_F6, KEY_F+6},
+{XKB_KEY_F7, KEY_F+7}, {XKB_KEY_F8, KEY_F+8}, {XKB_KEY_F9, KEY_F+9},
+{XKB_KEY_F10, KEY_F+10}, {XKB_KEY_F11, KEY_F+11}, {XKB_KEY_F12, KEY_F+12},
+
+// numpad independent of numlock
+{XKB_KEY_KP_Subtract, '-'}, {XKB_KEY_KP_Add, '+'},
+{XKB_KEY_KP_Multiply, '*'}, {XKB_KEY_KP_Divide, '/'},
+{XKB_KEY_KP_Enter, KEY_KPENTER},
+
+// numpad with numlock
+{XKB_KEY_KP_0, KEY_KP0}, {XKB_KEY_KP_1, KEY_KP1}, {XKB_KEY_KP_2, KEY_KP2},
+{XKB_KEY_KP_3, KEY_KP3}, {XKB_KEY_KP_4, KEY_KP4}, {XKB_KEY_KP_5, KEY_KP5},
+{XKB_KEY_KP_6, KEY_KP6}, {XKB_KEY_KP_7, KEY_KP7}, {XKB_KEY_KP_8, KEY_KP8},
+{XKB_KEY_KP_9, KEY_KP9}, {XKB_KEY_KP_Decimal, KEY_KPDEC},
+{XKB_KEY_KP_Separator, KEY_KPDEC},
+
+// numpad without numlock
+{XKB_KEY_KP_Insert, KEY_KPINS}, {XKB_KEY_KP_End, KEY_KP1},
+

Re: [PATCH 1/3] Add wayland support

2012-08-24 Thread Pekka Paalanen
On Fri, 24 Aug 2012 08:08:22 +0200
Alexander Preisinger alexander.preisin...@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.

 ---
  libvo/wl_common.c | 634 
 ++
  libvo/wl_common.h | 131 +++
  2 files changed, 765 insertions(+)
  create mode 100644 libvo/wl_common.c
  create mode 100644 libvo/wl_common.h
 
 diff --git a/libvo/wl_common.c b/libvo/wl_common.c
 new file mode 100644
 index 000..e271e5d
 --- /dev/null
 +++ b/libvo/wl_common.c
 @@ -0,0 +1,634 @@
 +/*
 + * This file is part of MPlayer.
 + *
 + * MPlayer is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
 + * the Free Software Foundation; either version 2 of the License, or
 + * (at your option) any later version.
 + *
 + * MPlayer is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + *
 + * You should have received a copy of the GNU General Public License along
 + * with MPlayer; if not, write to the Free Software Foundation, Inc.,
 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 + */
 +
 +#include stdio.h
 +#include stdlib.h
 +#include math.h
 +#include inttypes.h
 +#include limits.h
 +#include assert.h
 +
 +#include unistd.h
 +#include sys/mman.h
 +#include sys/timerfd.h
 +
 +#include config.h
 +#include bstr.h
 +#include options.h
 +#include mp_msg.h
 +#include mp_fifo.h
 +#include libavutil/common.h
 +#include talloc.h
 +
 +#include wl_common.h
 +
 +#include video_out.h
 +#include aspect.h
 +#include geometry.h
 +#include osdep/timer.h
 +
 +#include subopt-helper.h
 +
 +#include input/input.h
 +#include input/keycodes.h
 +
 +#ifdef CONFIG_GL_WAYLAND
 +#include wayland-egl.h
 +#endif
 +
 +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,