summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2012-02-28 06:04:56 (GMT)
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2012-02-28 08:16:10 (GMT)
commitee3e3e4b3cac49dc6bcb42e0078ae160674bd7eb (patch)
tree6af3d82dd91e9cc090ae36a0a8e04d6dc4f0236c
parent7e31b614c6ce73f13b7300ca9f532290293f6b02 (diff)
Update to wayland API changesHEADmaster
-rw-r--r--src/video/wayland/SDL_waylandevents.c89
-rw-r--r--src/video/wayland/SDL_waylandopengl.c1
-rw-r--r--src/video/wayland/SDL_waylandvideo.c42
-rw-r--r--src/video/wayland/SDL_waylandwindow.c17
-rw-r--r--src/video/wayland/SDL_waylandwindow.h1
5 files changed, 110 insertions, 40 deletions
diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c
index a0ac634..bff8d9e 100644
--- a/src/video/wayland/SDL_waylandevents.c
+++ b/src/video/wayland/SDL_waylandevents.c
@@ -31,7 +31,7 @@
#include "SDL_waylandevents_c.h"
#include "SDL_waylandwindow.h"
-#include <X11/extensions/XKBcommon.h>
+#include <xkbcommon/xkbcommon.h>
#include <linux/input.h>
#include "../../events/scancodes_xfree86.h"
@@ -98,15 +98,16 @@ Wayland_PumpEvents(_THIS)
static void
window_handle_motion(void *data, struct wl_input_device *input_device,
- uint32_t time,
- int32_t x, int32_t y, int32_t sx, int32_t sy)
+ uint32_t time, int32_t sx, int32_t sy)
{
struct SDL_WaylandInput *input = data;
SDL_WaylandWindow *window = input->pointer_focus;
//int location, pointer = POINTER_LEFT_PTR;
- input->x = x;
- input->y = y;
+ /* We dont and shouldnt know them */
+ input->x = 0;
+ input->y = 0;
+
input->sx = sx;
input->sy = sy;
SDL_SendMouseMotion(window->sdlwindow, 0, sx, sy);
@@ -152,7 +153,6 @@ keysym_to_utf8(uint32_t sym)
{
char *text = NULL;
uint32_t inbuf[2];
- unsigned ucs4;
inbuf[0] = X11_KeySymToUcs4(sym);
if (inbuf[0] == 0)
@@ -204,10 +204,10 @@ window_handle_key(void *data, struct wl_input_device *input_device,
}
static void
-window_handle_pointer_focus(void *data,
+window_handle_pointer_enter(void *data,
struct wl_input_device *input_device,
uint32_t time, struct wl_surface *surface,
- int32_t x, int32_t y, int32_t sx, int32_t sy)
+ int32_t sx, int32_t sy)
{
struct SDL_WaylandInput *input = data;
SDL_WaylandWindow *window;
@@ -221,6 +221,7 @@ window_handle_pointer_focus(void *data,
set_pointer_image(input, time, pointer);*/
} else {
+ /* FIXME: reached? */
SDL_SetMouseFocus(NULL);
input->pointer_focus = NULL;
//input->current_pointer_image = POINTER_UNSET;
@@ -228,7 +229,18 @@ window_handle_pointer_focus(void *data,
}
static void
-window_handle_keyboard_focus(void *data,
+window_handle_pointer_leave(void *data,
+ struct wl_input_device *input_device,
+ uint32_t time, struct wl_surface *surface)
+{
+ struct SDL_WaylandInput *input = data;
+
+ SDL_SetMouseFocus(NULL);
+ input->pointer_focus = NULL;
+}
+
+static void
+window_handle_keyboard_enter(void *data,
struct wl_input_device *input_device,
uint32_t time,
struct wl_surface *surface,
@@ -260,13 +272,65 @@ window_handle_keyboard_focus(void *data,
}
}
+static void
+window_handle_keyboard_leave(void *data,
+ struct wl_input_device *input_device,
+ uint32_t time,
+ struct wl_surface *surface)
+{
+ struct SDL_WaylandInput *input = data;
+
+ input->keyboard_focus = NULL;
+ SDL_SetKeyboardFocus(NULL);
+}
+
+static void
+input_handle_touch_down(void *data,
+ struct wl_input_device *wl_input_device,
+ uint32_t time, struct wl_surface *surface,
+ int32_t id, int32_t x, int32_t y)
+{
+}
+
+static void
+input_handle_touch_up(void *data,
+ struct wl_input_device *wl_input_device,
+ uint32_t time, int32_t id)
+{
+}
+
+static void
+input_handle_touch_motion(void *data,
+ struct wl_input_device *wl_input_device,
+ uint32_t time, int32_t id, int32_t x, int32_t y)
+{
+}
+
+static void
+input_handle_touch_frame(void *data,
+ struct wl_input_device *wl_input_device)
+{
+}
+
+static void
+input_handle_touch_cancel(void *data,
+ struct wl_input_device *wl_input_device)
+{
+}
static const struct wl_input_device_listener input_device_listener = {
window_handle_motion,
window_handle_button,
window_handle_key,
- window_handle_pointer_focus,
- window_handle_keyboard_focus,
+ window_handle_pointer_enter,
+ window_handle_pointer_leave,
+ window_handle_keyboard_enter,
+ window_handle_keyboard_leave,
+ input_handle_touch_down,
+ input_handle_touch_up,
+ input_handle_touch_motion,
+ input_handle_touch_frame,
+ input_handle_touch_cancel,
};
void
@@ -280,7 +344,8 @@ Wayland_display_add_input(SDL_WaylandData *d, uint32_t id)
memset(input, 0, sizeof *input);
input->display = d;
- input->input_device = wl_input_device_create(d->display, id, 1);
+ input->input_device =
+ wl_display_bind(d->display, id, &wl_input_device_interface);
input->pointer_focus = NULL;
input->keyboard_focus = NULL;
diff --git a/src/video/wayland/SDL_waylandopengl.c b/src/video/wayland/SDL_waylandopengl.c
index b6b7199..43ca914 100644
--- a/src/video/wayland/SDL_waylandopengl.c
+++ b/src/video/wayland/SDL_waylandopengl.c
@@ -24,6 +24,7 @@
#include "SDL_waylandopengl.h"
#include "SDL_waylandwindow.h"
+#include "SDL_waylandevents_c.h"
#include <dlfcn.h>
void
diff --git a/src/video/wayland/SDL_waylandvideo.c b/src/video/wayland/SDL_waylandvideo.c
index f88a0c1..1caaf7a 100644
--- a/src/video/wayland/SDL_waylandvideo.c
+++ b/src/video/wayland/SDL_waylandvideo.c
@@ -120,32 +120,39 @@ static void
display_handle_geometry(void *data,
struct wl_output *output,
int32_t x, int32_t y,
- int32_t width, int32_t height)
+ int physical_width,
+ int physical_height,
+ int subpixel,
+ const char *make,
+ const char *model)
+
{
SDL_WaylandData *d = data;
d->screen_allocation.x = x;
d->screen_allocation.y = y;
- d->screen_allocation.width = width;
- d->screen_allocation.height = height;
}
-
-static const struct wl_output_listener output_listener = {
- display_handle_geometry,
-};
-
static void
-handle_configure(void *data, struct wl_shell *shell,
- uint32_t time, uint32_t edges,
- struct wl_surface *surface,
- int32_t width, int32_t height)
+display_handle_mode(void *data,
+ struct wl_output *wl_output,
+ uint32_t flags,
+ int width,
+ int height,
+ int refresh)
{
+ SDL_WaylandData *d = data;
+ if (flags & WL_OUTPUT_MODE_CURRENT) {
+ d->screen_allocation.width = width;
+ d->screen_allocation.height = height;
+ }
}
-static const struct wl_shell_listener shell_listener = {
- handle_configure,
+
+static const struct wl_output_listener output_listener = {
+ display_handle_geometry,
+ display_handle_mode
};
static void
@@ -155,15 +162,14 @@ display_handle_global(struct wl_display *display, uint32_t id,
SDL_WaylandData *d = data;
if (strcmp(interface, "wl_compositor") == 0) {
- d->compositor = wl_compositor_create(display, id, 1);
+ d->compositor = wl_display_bind(display, id, &wl_compositor_interface);
} else if (strcmp(interface, "wl_output") == 0) {
- d->output = wl_output_create(display, id, 1);
+ d->output = wl_display_bind(display, id, &wl_output_interface);
wl_output_add_listener(d->output, &output_listener, d);
} else if (strcmp(interface, "wl_input_device") == 0) {
Wayland_display_add_input(d, id);
} else if (strcmp(interface, "wl_shell") == 0) {
- d->shell = wl_shell_create(display, id, 1);
- wl_shell_add_listener(d->shell, &shell_listener, d);
+ d->shell = wl_display_bind(display, id, &wl_shell_interface);
}
}
diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c
index a9e71f0..f2f2597 100644
--- a/src/video/wayland/SDL_waylandwindow.c
+++ b/src/video/wayland/SDL_waylandwindow.c
@@ -33,9 +33,11 @@ void Wayland_ShowWindow(_THIS, SDL_Window * window)
printf("sow window: %d,%d\n", window->w, window->h);
if (window->flags & SDL_WINDOW_FULLSCREEN)
- wl_surface_map_fullscreen(wind->surface);
+ wl_shell_surface_set_fullscreen(wind->shell_surface,
+ WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
+ 0, NULL);
else
- wl_surface_map_toplevel(wind->surface);
+ wl_shell_surface_set_toplevel(wind->shell_surface);
/*
wl_surface_map(wind->surface,
window->x, window->y,
@@ -49,8 +51,6 @@ void Wayland_ShowWindow(_THIS, SDL_Window * window)
int Wayland_CreateWindow(_THIS, SDL_Window * window)
{
SDL_WaylandWindow *data;
- struct wl_visual *visual;
- int i;
SDL_WaylandData *c;
data = malloc(sizeof *data);
@@ -78,13 +78,11 @@ int Wayland_CreateWindow(_THIS, SDL_Window * window)
data->surface =
wl_compositor_create_surface(c->compositor);
wl_surface_set_user_data(data->surface, data);
+ data->shell_surface = wl_shell_get_shell_surface(c->shell,
+ data->surface);
- if (_this->gl_config.alpha_size == 0)
- visual = wl_display_get_rgb_visual(c->display);
- else
- visual = wl_display_get_premultiplied_argb_visual(c->display);
data->egl_window = wl_egl_window_create(data->surface,
- window->w, window->h, visual);
+ window->w, window->h);
data->esurf =
eglCreateWindowSurface(c->edpy, c->econf,
data->egl_window, NULL);
@@ -107,7 +105,6 @@ void Wayland_DestroyWindow(_THIS, SDL_Window * window)
SDL_WaylandWindow *wind = (SDL_WaylandWindow *) window->driverdata;
window->driverdata = NULL;
- int i;
if (data) {
eglDestroySurface(data->edpy, wind->esurf);
diff --git a/src/video/wayland/SDL_waylandwindow.h b/src/video/wayland/SDL_waylandwindow.h
index af197e9..296439d 100644
--- a/src/video/wayland/SDL_waylandwindow.h
+++ b/src/video/wayland/SDL_waylandwindow.h
@@ -34,6 +34,7 @@ typedef struct
SDL_Window *sdlwindow;
SDL_WaylandData *waylandData;
struct wl_surface *surface;
+ struct wl_shell_surface *shell_surface;
struct wl_egl_window *egl_window;
EGLSurface esurf;