diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2012-02-28 07:04:56 +0100 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2012-02-28 09:16:10 +0100 |
commit | ee3e3e4b3cac49dc6bcb42e0078ae160674bd7eb (patch) | |
tree | 6af3d82dd91e9cc090ae36a0a8e04d6dc4f0236c | |
parent | 7e31b614c6ce73f13b7300ca9f532290293f6b02 (diff) |
-rw-r--r-- | src/video/wayland/SDL_waylandevents.c | 89 | ||||
-rw-r--r-- | src/video/wayland/SDL_waylandopengl.c | 1 | ||||
-rw-r--r-- | src/video/wayland/SDL_waylandvideo.c | 42 | ||||
-rw-r--r-- | src/video/wayland/SDL_waylandwindow.c | 17 | ||||
-rw-r--r-- | src/video/wayland/SDL_waylandwindow.h | 1 |
5 files changed, 110 insertions, 40 deletions
diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c index a0ac6349..bff8d9e2 100644 --- a/src/video/wayland/SDL_waylandevents.c +++ b/src/video/wayland/SDL_waylandevents.c @@ -28,13 +28,13 @@ #include "../../events/SDL_events_c.h" #include "SDL_waylandvideo.h" #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" typedef uint32_t KeySym; #include "../x11/imKStoUCS.h" @@ -95,21 +95,22 @@ Wayland_PumpEvents(_THIS) wl_display_iterate(d->display, WL_DISPLAY_READABLE); } while (retval > 0); } 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); //location = get_pointer_location(window, input->sx, input->sy); //set_pointer_image(input, time, pointer); @@ -149,13 +150,12 @@ window_handle_button(void *data, static char * keysym_to_utf8(uint32_t sym) { char *text = NULL; uint32_t inbuf[2]; - unsigned ucs4; inbuf[0] = X11_KeySymToUcs4(sym); if (inbuf[0] == 0) return NULL; inbuf[1] = 0; @@ -201,16 +201,16 @@ window_handle_key(void *data, struct wl_input_device *input_device, input->modifiers |= d->xkb->map->modmap[code]; else input->modifiers &= ~d->xkb->map->modmap[code]; } 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; /*int pointer;*/ if (surface) { @@ -218,20 +218,32 @@ window_handle_pointer_focus(void *data, window = input->pointer_focus; SDL_SetMouseFocus(window->sdlwindow); /*pointer = POINTER_LEFT_PTR; set_pointer_image(input, time, pointer);*/ } else { + /* FIXME: reached? */ SDL_SetMouseFocus(NULL); input->pointer_focus = NULL; //input->current_pointer_image = POINTER_UNSET; } } 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, struct wl_array *keys) { struct SDL_WaylandInput *input = data; @@ -257,19 +269,71 @@ window_handle_keyboard_focus(void *data, SDL_SetKeyboardFocus(window->sdlwindow); }else{ SDL_SetKeyboardFocus(NULL); } } +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 Wayland_display_add_input(SDL_WaylandData *d, uint32_t id) { struct SDL_WaylandInput *input; @@ -277,13 +341,14 @@ Wayland_display_add_input(SDL_WaylandData *d, uint32_t id) input = malloc(sizeof *input); if (input == NULL) return; 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; wl_input_device_add_listener(input->input_device, &input_device_listener, input); wl_input_device_set_user_data(input->input_device, input); diff --git a/src/video/wayland/SDL_waylandopengl.c b/src/video/wayland/SDL_waylandopengl.c index b6b7199f..43ca9146 100644 --- a/src/video/wayland/SDL_waylandopengl.c +++ b/src/video/wayland/SDL_waylandopengl.c @@ -21,12 +21,13 @@ */ #include "SDL_config.h" #include "SDL_waylandopengl.h" #include "SDL_waylandwindow.h" +#include "SDL_waylandevents_c.h" #include <dlfcn.h> void Wayland_GL_SwapWindow(_THIS, SDL_Window * window) { SDL_WaylandWindow *wind = (SDL_WaylandWindow *) window->driverdata; diff --git a/src/video/wayland/SDL_waylandvideo.c b/src/video/wayland/SDL_waylandvideo.c index f88a0c1d..1caaf7a8 100644 --- a/src/video/wayland/SDL_waylandvideo.c +++ b/src/video/wayland/SDL_waylandvideo.c @@ -117,56 +117,62 @@ VideoBootStrap Wayland_bootstrap = { }; 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 display_handle_global(struct wl_display *display, uint32_t id, const char *interface, uint32_t version, void *data) { 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); } } static int update_event_mask(uint32_t mask, void *data) diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c index a9e71f08..f2f25979 100644 --- a/src/video/wayland/SDL_waylandwindow.c +++ b/src/video/wayland/SDL_waylandwindow.c @@ -30,15 +30,17 @@ void Wayland_ShowWindow(_THIS, SDL_Window * window) { SDL_WaylandWindow *wind = (SDL_WaylandWindow*) window->driverdata; 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, window->w, window->h); */ @@ -46,14 +48,12 @@ 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); if (data == NULL) return 0; @@ -75,19 +75,17 @@ int Wayland_CreateWindow(_THIS, SDL_Window * window) data->waylandData = c; data->sdlwindow = 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); if (data->esurf == EGL_NO_SURFACE) { SDL_SetError("failed to create a window surface\n"); @@ -104,13 +102,12 @@ int Wayland_CreateWindow(_THIS, SDL_Window * window) void Wayland_DestroyWindow(_THIS, SDL_Window * window) { SDL_WaylandData *data = (SDL_WaylandData *) _this->driverdata; SDL_WaylandWindow *wind = (SDL_WaylandWindow *) window->driverdata; window->driverdata = NULL; - int i; if (data) { eglDestroySurface(data->edpy, wind->esurf); wl_egl_window_destroy(wind->egl_window); wl_surface_destroy(wind->surface); SDL_free(wind); diff --git a/src/video/wayland/SDL_waylandwindow.h b/src/video/wayland/SDL_waylandwindow.h index af197e91..296439dc 100644 --- a/src/video/wayland/SDL_waylandwindow.h +++ b/src/video/wayland/SDL_waylandwindow.h @@ -31,12 +31,13 @@ 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; struct SDL_WaylandInput *keyboard_device; } SDL_WaylandWindow; |