Merge lp:~brandontschaefer/libsdl/update-mir-new-abi-api into lp:ubuntu/wily/libsdl2

Proposed by Brandon Schaefer on 2015-11-03
Status: Work in progress
Proposed branch: lp:~brandontschaefer/libsdl/update-mir-new-abi-api
Merge into: lp:ubuntu/wily/libsdl2
Diff against target: 1209 lines (+1189/-0)
3 files modified
debian/changelog (+6/-0)
debian/patches/mir_new_abi_api.diff (+1182/-0)
debian/patches/series (+1/-0)
To merge this branch: bzr merge lp:~brandontschaefer/libsdl/update-mir-new-abi-api
Reviewer Review Type Date Requested Status
Ubuntu Sponsors Team 2015-11-04 Pending
Ubuntu branches 2015-11-03 Pending
Review via email: mp+276578@code.launchpad.net

Commit Message

Updates the mir video driver to mir 0.15 and greater. Works with 0.17 (as well as 0.18 trunk mir).

Description of the Change

Didnt see a xenial branch yet (but looks like the sdl2 branch in xenial is just a copy of the wily branch).

Updates the mir video driver to mir 0.15 and greater. Works with 0.17 (as well as 0.18 trunk mir).

Waiting to merge these changes to upstream SDL2 until 16.04 is released since SDL2 upstream only follows the LTS.

PPA with these changes (SDL2):
https://launchpad.net/~mir-team/+archive/ubuntu/staging/+packages

To post a comment you must log in.

Unmerged revisions

17. By Brandon Schaefer on 2015-11-03

* Update mir video driver from 0.13 to mir 0.15+

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2015-01-26 14:45:28 +0000
3+++ debian/changelog 2015-11-03 18:01:14 +0000
4@@ -1,3 +1,9 @@
5+libsdl2 (2.0.2+dfsg1-6ubuntu3) xenial; urgency=medium
6+
7+ * Update mir video driver from 0.13 to mir 0.15+
8+
9+ -- Brandon Schaefer <brandontschaefer@gmail.com> Tue, 03 Nov 2015 09:53:53 -0800
10+
11 libsdl2 (2.0.2+dfsg1-6ubuntu2) vivid; urgency=medium
12
13 * Rebuild against libmirclient.so.8. (Closes: #1402753)
14
15=== added file 'debian/patches/mir_new_abi_api.diff'
16--- debian/patches/mir_new_abi_api.diff 1970-01-01 00:00:00 +0000
17+++ debian/patches/mir_new_abi_api.diff 2015-11-03 18:01:14 +0000
18@@ -0,0 +1,1182 @@
19+--- a/configure.in
20++++ b/configure.in
21+@@ -1256,7 +1256,18 @@
22+ if $PKG_CONFIG --exists mirclient egl xkbcommon ; then
23+ MIR_CFLAGS=`$PKG_CONFIG --cflags mirclient egl xkbcommon`
24+ MIR_LIBS=`$PKG_CONFIG --libs mirclient egl xkbcommon`
25++ save_CFLAGS="$CFLAGS"
26++ CFLAGS="$save_CFLAGS $MIR_CFLAGS"
27++
28++ dnl This will disable Mir on Ubuntu < 15.04 (Mir should be 0.14 at this point)
29++ AC_TRY_COMPILE([
30++ #include <mir_toolkit/mir_client_library.h>
31++ ],[
32++ MirPointerButton button = mir_pointer_button_primary;
33++ ],[
34+ video_mir=yes
35++ ])
36++ CFLAGS="$save_CFLAGS"
37+ fi
38+ fi
39+ AC_MSG_RESULT($video_mir)
40+--- a/src/video/mir/SDL_mirdyn.c
41++++ b/src/video/mir/SDL_mirdyn.c
42+@@ -84,9 +84,11 @@
43+ /* Define all the function pointers and wrappers... */
44+ #define SDL_MIR_MODULE(modname) int SDL_MIR_HAVE_##modname = 0;
45+ #define SDL_MIR_SYM(rc,fn,params) SDL_DYNMIRFN_##fn MIR_##fn = NULL;
46++#define SDL_MIR_SYM_CONST(type,name) SDL_DYMMIRCONST_##name MIR_##name = NULL;
47+ #include "SDL_mirsym.h"
48+ #undef SDL_MIR_MODULE
49+ #undef SDL_MIR_SYM
50++#undef SDL_MIR_SYM_CONST
51+
52+ static int mir_load_refcount = 0;
53+
54+@@ -103,9 +105,11 @@
55+ /* set all the function pointers to NULL. */
56+ #define SDL_MIR_MODULE(modname) SDL_MIR_HAVE_##modname = 0;
57+ #define SDL_MIR_SYM(rc,fn,params) MIR_##fn = NULL;
58++#define SDL_MIR_SYM_CONST(type,name) MIR_##name = NULL;
59+ #include "SDL_mirsym.h"
60+ #undef SDL_MIR_MODULE
61+ #undef SDL_MIR_SYM
62++#undef SDL_MIR_SYM_CONST
63+
64+
65+ #ifdef SDL_VIDEO_DRIVER_MIR_DYNAMIC
66+@@ -139,15 +143,19 @@
67+
68+ #define SDL_MIR_MODULE(modname) SDL_MIR_HAVE_##modname = 1; /* default yes */
69+ #define SDL_MIR_SYM(rc,fn,params)
70++#define SDL_MIR_SYM_CONST(type,name)
71+ #include "SDL_mirsym.h"
72+ #undef SDL_MIR_MODULE
73+ #undef SDL_MIR_SYM
74++#undef SDL_MIR_SYM_CONST
75+
76+ #define SDL_MIR_MODULE(modname) thismod = &SDL_MIR_HAVE_##modname;
77+ #define SDL_MIR_SYM(rc,fn,params) MIR_##fn = (SDL_DYNMIRFN_##fn) MIR_GetSym(#fn,thismod);
78++#define SDL_MIR_SYM_CONST(type,name) MIR_##name = *(SDL_DYMMIRCONST_##name*) MIR_GetSym(#name,thismod);
79+ #include "SDL_mirsym.h"
80+ #undef SDL_MIR_MODULE
81+ #undef SDL_MIR_SYM
82++#undef SDL_MIR_SYM_CONST
83+
84+ if ((SDL_MIR_HAVE_MIR_CLIENT) && (SDL_MIR_HAVE_XKBCOMMON)) {
85+ /* all required symbols loaded. */
86+@@ -162,9 +170,11 @@
87+
88+ #define SDL_MIR_MODULE(modname) SDL_MIR_HAVE_##modname = 1; /* default yes */
89+ #define SDL_MIR_SYM(rc,fn,params) MIR_##fn = fn;
90++#define SDL_MIR_SYM_CONST(type,name) MIR_##name = name;
91+ #include "SDL_mirsym.h"
92+ #undef SDL_MIR_MODULE
93+ #undef SDL_MIR_SYM
94++#undef SDL_MIR_SYM_CONST
95+
96+ #endif
97+ }
98+--- a/src/video/mir/SDL_mirdyn.h
99++++ b/src/video/mir/SDL_mirdyn.h
100+@@ -40,9 +40,13 @@
101+ #define SDL_MIR_SYM(rc,fn,params) \
102+ typedef rc (*SDL_DYNMIRFN_##fn) params; \
103+ extern SDL_DYNMIRFN_##fn MIR_##fn;
104++#define SDL_MIR_SYM_CONST(type, name) \
105++ typedef type SDL_DYMMIRCONST_##name; \
106++ extern SDL_DYMMIRCONST_##name MIR_##name;
107+ #include "SDL_mirsym.h"
108+ #undef SDL_MIR_MODULE
109+ #undef SDL_MIR_SYM
110++#undef SDL_MIR_SYM_CONST
111+
112+ #ifdef __cplusplus
113+ }
114+--- a/src/video/mir/SDL_mirevents.c
115++++ b/src/video/mir/SDL_mirevents.c
116+@@ -58,7 +58,7 @@
117+ {
118+ SDL_Window* keyboard_window = SDL_GetKeyboardFocus();
119+
120+- if (keyboard_window != sdl_window)
121++ if (sdl_window && keyboard_window != sdl_window)
122+ SDL_SetKeyboardFocus(sdl_window);
123+ }
124+
125+@@ -68,51 +68,66 @@
126+ a single key press produces a character.
127+ */
128+ static void
129+-HandleKeyEvent(MirKeyEvent const ev, SDL_Window* window)
130++HandleKeyEvent(MirKeyboardEvent const* key_event, SDL_Window* window)
131+ {
132+- uint32_t scancode = SDL_SCANCODE_UNKNOWN;
133+- Uint8 key_state = ev.action == mir_key_action_up ? SDL_RELEASED : SDL_PRESSED;
134++ xkb_keysym_t key_code;
135++ Uint8 key_state;
136++ int event_scancode;
137++ uint32_t sdl_scancode = SDL_SCANCODE_UNKNOWN;
138++
139++ MirKeyboardAction action = MIR_mir_keyboard_event_action(key_event);
140++
141++ key_state = SDL_PRESSED;
142++ key_code = MIR_mir_keyboard_event_key_code(key_event);
143++ event_scancode = MIR_mir_keyboard_event_scan_code(key_event);
144++
145++ if (action == mir_keyboard_action_up)
146++ key_state = SDL_RELEASED;
147+
148+ CheckKeyboardFocus(window);
149+
150+- if (ev.scan_code < SDL_arraysize(xfree86_scancode_table2))
151+- scancode = xfree86_scancode_table2[ev.scan_code];
152++ if (event_scancode < SDL_arraysize(xfree86_scancode_table2))
153++ sdl_scancode = xfree86_scancode_table2[event_scancode];
154+
155+- if (scancode != SDL_SCANCODE_UNKNOWN)
156+- SDL_SendKeyboardKey(key_state, scancode);
157++ if (sdl_scancode != SDL_SCANCODE_UNKNOWN)
158++ SDL_SendKeyboardKey(key_state, sdl_scancode);
159+
160+ if (key_state == SDL_PRESSED)
161+- HandleKeyText(ev.key_code);
162++ HandleKeyText(key_code);
163+ }
164+
165+ static void
166+-HandleMouseButton(SDL_Window* sdl_window, Uint8 state, MirMotionButton button_state)
167++HandleMouseButton(SDL_Window* sdl_window, Uint8 state, MirPointerEvent const* pointer)
168+ {
169+- static uint32_t last_sdl_button;
170+- uint32_t sdl_button;
171++ int i;
172++ uint32_t sdl_button = SDL_BUTTON_LEFT;
173++ MirPointerButton button_state = mir_pointer_button_primary;
174++
175++ for (i = mir_pointer_button_primary; i <= mir_pointer_button_forward; i++) {
176++ if (MIR_mir_pointer_event_button_state(pointer, i))
177++ button_state = i;
178++ }
179+
180+ switch (button_state) {
181+- case mir_motion_button_primary:
182++ case mir_pointer_button_primary:
183+ sdl_button = SDL_BUTTON_LEFT;
184+ break;
185+- case mir_motion_button_secondary:
186++ case mir_pointer_button_secondary:
187+ sdl_button = SDL_BUTTON_RIGHT;
188+ break;
189+- case mir_motion_button_tertiary:
190++ case mir_pointer_button_tertiary:
191+ sdl_button = SDL_BUTTON_MIDDLE;
192+ break;
193+- case mir_motion_button_forward:
194++ case mir_pointer_button_forward:
195+ sdl_button = SDL_BUTTON_X1;
196+ break;
197+- case mir_motion_button_back:
198++ case mir_pointer_button_back:
199+ sdl_button = SDL_BUTTON_X2;
200+ break;
201+ default:
202+- sdl_button = last_sdl_button;
203+ break;
204+ }
205+
206+- last_sdl_button = sdl_button;
207+ SDL_SendMouseButton(sdl_window, 0, state, sdl_button);
208+ }
209+
210+@@ -148,104 +163,127 @@
211+ }
212+
213+ static void
214+-HandleTouchEvent(MirMotionEvent const motion, int cord_index, SDL_Window* sdl_window)
215++HandleTouchEvent(MirTouchEvent const* touch, int device_id, SDL_Window* sdl_window)
216+ {
217+- int device_id = motion.device_id;
218+- int id = motion.pointer_coordinates[cord_index].id;
219++ int i, point_count;
220++ point_count = MIR_mir_touch_event_point_count(touch);
221+
222+- int width = sdl_window->w;
223+- int height = sdl_window->h;
224+- float x = motion.pointer_coordinates[cord_index].x;
225+- float y = motion.pointer_coordinates[cord_index].y;
226+-
227+- float n_x = x / width;
228+- float n_y = y / height;
229+- float pressure = motion.pointer_coordinates[cord_index].pressure;
230+-
231+- AddTouchDevice(motion.device_id);
232+-
233+- switch (motion.action) {
234+- case mir_motion_action_down:
235+- case mir_motion_action_pointer_down:
236+- HandleTouchPress(device_id, id, SDL_TRUE, n_x, n_y, pressure);
237+- break;
238+- case mir_motion_action_up:
239+- case mir_motion_action_pointer_up:
240+- HandleTouchPress(device_id, id, SDL_FALSE, n_x, n_y, pressure);
241+- break;
242+- case mir_motion_action_hover_move:
243+- case mir_motion_action_move:
244+- HandleTouchMotion(device_id, id, n_x, n_y, pressure);
245+- break;
246+- default:
247+- break;
248++ for (i = 0; i < point_count; i++) {
249++ int id = MIR_mir_touch_event_id(touch, i);
250++
251++ int width = sdl_window->w;
252++ int height = sdl_window->h;
253++
254++ float x = MIR_mir_touch_event_axis_value(touch, i, mir_touch_axis_x);
255++ float y = MIR_mir_touch_event_axis_value(touch, i, mir_touch_axis_y);
256++
257++ float n_x = x / width;
258++ float n_y = y / height;
259++
260++ float pressure = MIR_mir_touch_event_axis_value(touch, i, mir_touch_axis_pressure);
261++
262++ AddTouchDevice(device_id);
263++
264++ switch (MIR_mir_touch_event_action(touch, i)) {
265++ case mir_touch_action_up:
266++ HandleTouchPress(device_id, id, SDL_TRUE, n_x, n_y, pressure);
267++ break;
268++ case mir_touch_action_down:
269++ HandleTouchPress(device_id, id, SDL_FALSE, n_x, n_y, pressure);
270++ break;
271++ case mir_touch_action_change:
272++ HandleTouchMotion(device_id, id, n_x, n_y, pressure);
273++ break;
274++ }
275+ }
276+ }
277+
278+ static void
279+-HandleMouseEvent(MirMotionEvent const motion, int cord_index, SDL_Window* sdl_window)
280++HandleMouseEvent(MirPointerEvent const* pointer, SDL_Window* sdl_window)
281+ {
282+ SDL_SetMouseFocus(sdl_window);
283+
284+- switch (motion.action) {
285+- case mir_motion_action_down:
286+- case mir_motion_action_pointer_down:
287+- HandleMouseButton(sdl_window, SDL_PRESSED, motion.button_state);
288+- break;
289+- case mir_motion_action_up:
290+- case mir_motion_action_pointer_up:
291+- HandleMouseButton(sdl_window, SDL_RELEASED, motion.button_state);
292+- break;
293+- case mir_motion_action_hover_move:
294+- case mir_motion_action_move:
295+- HandleMouseMotion(sdl_window,
296+- motion.pointer_coordinates[cord_index].x,
297+- motion.pointer_coordinates[cord_index].y);
298++ switch (MIR_mir_pointer_event_action(pointer)) {
299++ case mir_pointer_action_button_down:
300++ HandleMouseButton(sdl_window, SDL_PRESSED, pointer);
301++ break;
302++ case mir_pointer_action_button_up:
303++ HandleMouseButton(sdl_window, SDL_RELEASED, pointer);
304++ break;
305++ case mir_pointer_action_motion: {
306++ int x, y;
307++ int hscroll, vscroll;
308++ SDL_Mouse* mouse = SDL_GetMouse();
309++ x = MIR_mir_pointer_event_axis_value(pointer, mir_pointer_axis_x);
310++ y = MIR_mir_pointer_event_axis_value(pointer, mir_pointer_axis_y);
311++ hscroll = MIR_mir_pointer_event_axis_value(pointer, mir_pointer_axis_hscroll);
312++ vscroll = MIR_mir_pointer_event_axis_value(pointer, mir_pointer_axis_vscroll);
313++
314++ if (mouse && (mouse->x != x || mouse->y != y))
315++ HandleMouseMotion(sdl_window, x, y);
316++ if (vscroll != 0 || hscroll != 0)
317++ HandleMouseScroll(sdl_window, hscroll, vscroll);
318++ }
319+ break;
320+- case mir_motion_action_outside:
321++ case mir_pointer_action_leave:
322+ SDL_SetMouseFocus(NULL);
323+ break;
324+- case mir_motion_action_scroll:
325+- HandleMouseScroll(sdl_window,
326+- motion.pointer_coordinates[cord_index].hscroll,
327+- motion.pointer_coordinates[cord_index].vscroll);
328+- break;
329+- case mir_motion_action_cancel:
330+- case mir_motion_action_hover_enter:
331+- case mir_motion_action_hover_exit:
332+- break;
333++ case mir_pointer_action_enter:
334+ default:
335+ break;
336+ }
337+ }
338+
339+ static void
340+-HandleMotionEvent(MirMotionEvent const motion, SDL_Window* sdl_window)
341++MIR_HandleInput(MirInputEvent const* input_event, SDL_Window* window)
342+ {
343+- int cord_index;
344+- for (cord_index = 0; cord_index < motion.pointer_count; cord_index++) {
345+- if (motion.pointer_coordinates[cord_index].tool_type == mir_motion_tool_type_finger) {
346+- HandleTouchEvent(motion, cord_index, sdl_window);
347+- }
348+- else {
349+- HandleMouseEvent(motion, cord_index, sdl_window);
350+- }
351++ switch (MIR_mir_input_event_get_type(input_event)) {
352++ case (mir_input_event_type_key):
353++ HandleKeyEvent(MIR_mir_input_event_get_keyboard_event(input_event), window);
354++ break;
355++ case (mir_input_event_type_pointer):
356++ HandleMouseEvent(MIR_mir_input_event_get_pointer_event(input_event), window);
357++ break;
358++ case (mir_input_event_type_touch):
359++ HandleTouchEvent(MIR_mir_input_event_get_touch_event(input_event),
360++ MIR_mir_input_event_get_device_id(input_event),
361++ window);
362++ break;
363++ default:
364++ break;
365+ }
366+ }
367+
368++static void
369++MIR_HandleResize(MirResizeEvent const* resize_event, SDL_Window* window)
370++{
371++ int new_w = MIR_mir_resize_event_get_width (resize_event);
372++ int new_h = MIR_mir_resize_event_get_height(resize_event);
373++
374++ int old_w = window->w;
375++ int old_h = window->h;
376++
377++ if (new_w != old_w || new_h != old_h)
378++ SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, new_w, new_h);
379++}
380++
381+ void
382+-MIR_HandleInput(MirSurface* surface, MirEvent const* ev, void* context)
383++MIR_HandleEvent(MirSurface* surface, MirEvent const* ev, void* context)
384+ {
385+- SDL_Window* window = (SDL_Window*)context;
386+- switch (ev->type) {
387+- case (mir_event_type_key):
388+- HandleKeyEvent(ev->key, window);
389+- break;
390+- case (mir_event_type_motion):
391+- HandleMotionEvent(ev->motion, window);
392+- break;
393+- default:
394+- break;
395++ MirEventType event_type = MIR_mir_event_get_type(ev);
396++ SDL_Window* window = (SDL_Window*)context;
397++
398++ if (window) {
399++ switch (event_type) {
400++ case (mir_event_type_input):
401++ MIR_HandleInput(MIR_mir_event_get_input_event(ev), window);
402++ break;
403++ case (mir_event_type_resize):
404++ MIR_HandleResize(MIR_mir_event_get_resize_event(ev), window);
405++ break;
406++ default:
407++ break;
408++ }
409+ }
410+ }
411+
412+--- a/src/video/mir/SDL_mirevents.h
413++++ b/src/video/mir/SDL_mirevents.h
414+@@ -29,7 +29,7 @@
415+ #include <mir_toolkit/mir_client_library.h>
416+
417+ extern void
418+-MIR_HandleInput(MirSurface* surface, MirEvent const* ev, void* context);
419++MIR_HandleEvent(MirSurface* surface, MirEvent const* ev, void* context);
420+
421+ #endif /* _SDL_mirevents_h */
422+
423+--- a/src/video/mir/SDL_mirframebuffer.c
424++++ b/src/video/mir/SDL_mirframebuffer.c
425+@@ -39,7 +39,11 @@
426+ SDL_PIXELFORMAT_BGR888, /* mir_pixel_format_xbgr_8888 */
427+ SDL_PIXELFORMAT_ARGB8888, /* mir_pixel_format_argb_8888 */
428+ SDL_PIXELFORMAT_RGB888, /* mir_pixel_format_xrgb_8888 */
429+- SDL_PIXELFORMAT_BGR24 /* mir_pixel_format_bgr_888 */
430++ SDL_PIXELFORMAT_BGR24, /* mir_pixel_format_bgr_888 */
431++ SDL_PIXELFORMAT_RGB24, /* mir_pixel_format_rgb_888 */
432++ SDL_PIXELFORMAT_RGB565, /* mir_pixel_format_rgb_565 */
433++ SDL_PIXELFORMAT_RGBA5551, /* mir_pixel_format_rgba_5551 */
434++ SDL_PIXELFORMAT_RGBA4444 /* mir_pixel_format_rgba_4444 */
435+ };
436+
437+ Uint32
438+@@ -75,12 +79,6 @@
439+ if (*pixels == NULL)
440+ return SDL_OutOfMemory();
441+
442+- mir_window->surface = MIR_mir_connection_create_surface_sync(mir_data->connection, &surfaceparm);
443+- if (!MIR_mir_surface_is_valid(mir_window->surface)) {
444+- const char* error = MIR_mir_surface_get_error_message(mir_window->surface);
445+- return SDL_SetError("Failed to created a mir surface: %s", error);
446+- }
447+-
448+ return 0;
449+ }
450+
451+@@ -91,12 +89,14 @@
452+ MIR_Window* mir_window = window->driverdata;
453+
454+ MirGraphicsRegion region;
455++ MirBufferStream* bs;
456+ int i, j, x, y, w, h, start;
457+ int bytes_per_pixel, bytes_per_row, s_stride, d_stride;
458+ char* s_dest;
459+ char* pixels;
460+
461+- MIR_mir_surface_get_graphics_region(mir_window->surface, &region);
462++ bs = MIR_mir_surface_get_buffer_stream(mir_window->surface);
463++ MIR_mir_buffer_stream_get_graphics_region(bs, &region);
464+
465+ s_dest = region.vaddr;
466+ pixels = (char*)window->surface->pixels;
467+@@ -144,7 +144,7 @@
468+ }
469+ }
470+
471+- MIR_mir_surface_swap_buffers_sync(mir_window->surface);
472++ MIR_mir_buffer_stream_swap_buffers_sync(bs);
473+
474+ return 0;
475+ }
476+--- a/src/video/mir/SDL_mirmouse.c
477++++ b/src/video/mir/SDL_mirmouse.c
478+@@ -27,13 +27,22 @@
479+
480+ #if SDL_VIDEO_DRIVER_MIR
481+
482+-#include "SDL_mirmouse.h"
483+-
484+ #include "../../events/SDL_mouse_c.h"
485++#include "../SDL_sysvideo.h"
486+ #include "SDL_assert.h"
487+
488+ #include "SDL_mirdyn.h"
489+
490++#include "SDL_mirvideo.h"
491++#include "SDL_mirmouse.h"
492++#include "SDL_mirwindow.h"
493++
494++typedef struct
495++{
496++ MirCursorConfiguration* conf;
497++ MirBufferStream* stream;
498++} MIR_Cursor;
499++
500+ static SDL_Cursor*
501+ MIR_CreateDefaultCursor()
502+ {
503+@@ -41,6 +50,16 @@
504+
505+ cursor = SDL_calloc(1, sizeof(SDL_Cursor));
506+ if (cursor) {
507++
508++ MIR_Cursor* mir_cursor = SDL_calloc(1, sizeof(MIR_Cursor));
509++ if (mir_cursor) {
510++ mir_cursor->conf = NULL;
511++ mir_cursor->stream = NULL;
512++ cursor->driverdata = mir_cursor;
513++ }
514++ else {
515++ SDL_OutOfMemory();
516++ }
517+ }
518+ else {
519+ SDL_OutOfMemory();
520+@@ -49,58 +68,169 @@
521+ return cursor;
522+ }
523+
524++static void
525++CopySurfacePixelsToMirStream(SDL_Surface* surface, MirBufferStream* stream)
526++{
527++ char* dest, *pixels;
528++ int i, s_w, s_h, r_stride, p_stride, bytes_per_pixel, bytes_per_row;
529++
530++ MirGraphicsRegion region;
531++ MIR_mir_buffer_stream_get_graphics_region(stream, &region);
532++
533++ s_w = surface->w;
534++ s_h = surface->h;
535++
536++ bytes_per_pixel = surface->format->BytesPerPixel;
537++ bytes_per_row = bytes_per_pixel * s_w;
538++
539++ dest = region.vaddr;
540++ pixels = (char*)surface->pixels;
541++
542++ r_stride = region.stride;
543++ p_stride = surface->pitch;
544++
545++ for (i = 0; i < s_h; i++)
546++ {
547++ memcpy(dest, pixels, bytes_per_row);
548++ dest += r_stride;
549++ pixels += p_stride;
550++ }
551++}
552++
553+ static SDL_Cursor*
554+-MIR_CreateCursor(SDL_Surface* sruface, int hot_x, int hot_y)
555++MIR_CreateCursor(SDL_Surface* surface, int hot_x, int hot_y)
556+ {
557+- return MIR_CreateDefaultCursor();
558++ MirCursorConfiguration* conf;
559++ MirSurfaceParameters params;
560++ MirBufferStream* stream;
561++
562++ int s_w = surface->w;
563++ int s_h = surface->h;
564++
565++ MIR_Data* mir_data = (MIR_Data*)SDL_GetVideoDevice()->driverdata;
566++ MIR_Window* mir_window = mir_data->current_window;
567++ SDL_Cursor* cursor = MIR_CreateDefaultCursor();
568++ MIR_Cursor* mir_cursor = (MIR_Cursor*)cursor->driverdata;
569++
570++ MIR_mir_surface_get_parameters(mir_window->surface, &params);
571++
572++ stream = MIR_mir_connection_create_buffer_stream_sync(mir_data->connection,
573++ s_w, s_h, params.pixel_format,
574++ mir_buffer_usage_software);
575++
576++ conf = MIR_mir_cursor_configuration_from_buffer_stream(stream, hot_x, hot_y);
577++
578++ CopySurfacePixelsToMirStream(surface, stream);
579++
580++ mir_cursor->conf = conf;
581++ mir_cursor->stream = stream;
582++
583++ return cursor;
584+ }
585+
586+ static SDL_Cursor*
587+ MIR_CreateSystemCursor(SDL_SystemCursor id)
588+ {
589++ char const* cursor_name = NULL;
590++ MirCursorConfiguration* conf;
591++ SDL_Cursor* cursor = MIR_CreateDefaultCursor();
592++
593+ switch(id) {
594+ case SDL_SYSTEM_CURSOR_ARROW:
595++ cursor_name = MIR_mir_arrow_cursor_name;
596+ break;
597+ case SDL_SYSTEM_CURSOR_IBEAM:
598++ cursor_name = MIR_mir_caret_cursor_name;
599+ break;
600+ case SDL_SYSTEM_CURSOR_WAIT:
601++ cursor_name = MIR_mir_busy_cursor_name;
602+ break;
603+ case SDL_SYSTEM_CURSOR_CROSSHAIR:
604++ /* Unsupported */
605++ cursor_name = MIR_mir_arrow_cursor_name;
606+ break;
607+ case SDL_SYSTEM_CURSOR_WAITARROW:
608++ cursor_name = MIR_mir_busy_cursor_name;
609+ break;
610+ case SDL_SYSTEM_CURSOR_SIZENWSE:
611++ cursor_name = MIR_mir_omnidirectional_resize_cursor_name;
612+ break;
613+ case SDL_SYSTEM_CURSOR_SIZENESW:
614++ cursor_name = MIR_mir_omnidirectional_resize_cursor_name;
615+ break;
616+ case SDL_SYSTEM_CURSOR_SIZEWE:
617++ cursor_name = MIR_mir_horizontal_resize_cursor_name;
618+ break;
619+ case SDL_SYSTEM_CURSOR_SIZENS:
620++ cursor_name = MIR_mir_vertical_resize_cursor_name;
621+ break;
622+ case SDL_SYSTEM_CURSOR_SIZEALL:
623++ cursor_name = MIR_mir_omnidirectional_resize_cursor_name;
624+ break;
625+ case SDL_SYSTEM_CURSOR_NO:
626++ /* Unsupported */
627++ cursor_name = MIR_mir_closed_hand_cursor_name;
628+ break;
629+ case SDL_SYSTEM_CURSOR_HAND:
630++ cursor_name = MIR_mir_open_hand_cursor_name;
631+ break;
632+ default:
633+ SDL_assert(0);
634+ return NULL;
635+ }
636+
637+- return MIR_CreateDefaultCursor();
638++ conf = MIR_mir_cursor_configuration_from_name(cursor_name);
639++
640++ cursor->driverdata = conf;
641++
642++ return cursor;
643+ }
644+
645+ static void
646+ MIR_FreeCursor(SDL_Cursor* cursor)
647+ {
648+- if (cursor)
649+- SDL_free(cursor);
650++ if (cursor) {
651++
652++ if (cursor->driverdata) {
653++ MIR_Cursor* mir_cursor = (MIR_Cursor*)cursor->driverdata;
654++
655++ if (mir_cursor->conf)
656++ MIR_mir_cursor_configuration_destroy(mir_cursor->conf);
657++ if (mir_cursor->stream)
658++ MIR_mir_buffer_stream_release_sync(mir_cursor->stream);
659++
660++ SDL_free(mir_cursor);
661++ }
662++
663++ SDL_free(cursor);
664++ }
665+ }
666+
667+ static int
668+ MIR_ShowCursor(SDL_Cursor* cursor)
669+ {
670++ if (cursor && cursor->driverdata) {
671++ MIR_Data* mir_data = (MIR_Data*)SDL_GetVideoDevice()->driverdata;
672++ MIR_Window* mir_window = mir_data->current_window;
673++
674++ if (mir_window && MIR_mir_surface_is_valid(mir_window->surface)) {
675++ MIR_Cursor* mir_cursor = (MIR_Cursor*)cursor->driverdata;
676++
677++ if (mir_cursor->conf) {
678++ MIR_mir_wait_for(MIR_mir_surface_configure_cursor(mir_window->surface, mir_cursor->conf));
679++ }
680++
681++ if (mir_cursor->stream) {
682++ /* FIXME Bug https://bugs.launchpad.net/mir/+bug/1477285
683++ Requires a triple buffer swap to get the cursor buffer on top! (since mir is tripled buffered)
684++ */
685++ MIR_mir_buffer_stream_swap_buffers_sync(mir_cursor->stream);
686++ MIR_mir_buffer_stream_swap_buffers_sync(mir_cursor->stream);
687++ MIR_mir_buffer_stream_swap_buffers_sync(mir_cursor->stream);
688++ }
689++ }
690++ }
691++
692+ return 0;
693+ }
694+
695+--- a/src/video/mir/SDL_mirsym.h
696++++ b/src/video/mir/SDL_mirsym.h
697+@@ -23,23 +23,72 @@
698+
699+ SDL_MIR_MODULE(MIR_CLIENT)
700+ SDL_MIR_SYM(MirDisplayConfiguration*,mir_connection_create_display_config,(MirConnection *connection))
701+-SDL_MIR_SYM(MirSurface *,mir_connection_create_surface_sync,(MirConnection *connection, MirSurfaceParameters const *params))
702++SDL_MIR_SYM(MirSurface *,mir_surface_create_sync,(MirSurfaceSpec* spec))
703++SDL_MIR_SYM(MirEGLNativeWindowType,mir_buffer_stream_get_egl_native_window,(MirBufferStream *surface))
704++SDL_MIR_SYM(void,mir_buffer_stream_get_graphics_region,(MirBufferStream *stream, MirGraphicsRegion *graphics_region))
705++SDL_MIR_SYM(void,mir_buffer_stream_swap_buffers_sync,(MirBufferStream *stream))
706++SDL_MIR_SYM(void,mir_surface_set_event_handler,(MirSurface *surface, mir_surface_event_callback callback, void* context))
707++SDL_MIR_SYM(MirSurfaceSpec*,mir_connection_create_spec_for_normal_surface,(MirConnection *connection, int width, int height, MirPixelFormat format))
708++SDL_MIR_SYM(MirSurfaceSpec*,mir_connection_create_spec_for_changes,(MirConnection *connection))
709++SDL_MIR_SYM(void,mir_surface_spec_set_buffer_usage,(MirSurfaceSpec *spec, MirBufferUsage usage))
710++SDL_MIR_SYM(void,mir_surface_spec_set_name,(MirSurfaceSpec *spec, char const *name))
711++SDL_MIR_SYM(void,mir_surface_spec_release,(MirSurfaceSpec *spec))
712++SDL_MIR_SYM(void,mir_surface_spec_set_width,(MirSurfaceSpec *spec, unsigned width))
713++SDL_MIR_SYM(void,mir_surface_spec_set_height,(MirSurfaceSpec *spec, unsigned height))
714++SDL_MIR_SYM(void,mir_surface_spec_set_min_width,(MirSurfaceSpec *spec, unsigned min_width))
715++SDL_MIR_SYM(void,mir_surface_spec_set_min_height,(MirSurfaceSpec *spec, unsigned min_height))
716++SDL_MIR_SYM(void,mir_surface_spec_set_max_width,(MirSurfaceSpec *spec, unsigned max_width))
717++SDL_MIR_SYM(void,mir_surface_spec_set_max_height,(MirSurfaceSpec *spec, unsigned max_height))
718++SDL_MIR_SYM(void,mir_surface_spec_set_type,(MirSurfaceSpec *spec, MirSurfaceType type))
719++SDL_MIR_SYM(void,mir_surface_spec_set_state,(MirSurfaceSpec *spec, MirSurfaceState state))
720++SDL_MIR_SYM(void,mir_surface_apply_spec,(MirSurface *surface, MirSurfaceSpec *spec))
721++SDL_MIR_SYM(void,mir_surface_get_parameters,(MirSurface *surface, MirSurfaceParameters *params))
722++SDL_MIR_SYM(MirBufferStream*,mir_surface_get_buffer_stream,(MirSurface *surface))
723++SDL_MIR_SYM(MirCursorConfiguration*,mir_cursor_configuration_from_buffer_stream,(MirBufferStream* stream, int hot_x, int hot_y))
724++SDL_MIR_SYM(MirBufferStream*,mir_connection_create_buffer_stream_sync,(MirConnection *connection, int w, int h, MirPixelFormat format, MirBufferUsage usage))
725++SDL_MIR_SYM(MirKeyboardAction,mir_keyboard_event_action,(MirKeyboardEvent const *event))
726++SDL_MIR_SYM(xkb_keysym_t,mir_keyboard_event_key_code,(MirKeyboardEvent const *event))
727++SDL_MIR_SYM(int,mir_keyboard_event_scan_code,(MirKeyboardEvent const *event))
728++SDL_MIR_SYM(bool,mir_pointer_event_button_state,(MirPointerEvent const *event, MirPointerButton button))
729++SDL_MIR_SYM(MirInputDeviceId,mir_input_event_get_device_id,(MirInputEvent const* ev))
730++SDL_MIR_SYM(MirTouchId,mir_touch_event_id,(MirTouchEvent const *event, size_t touch_index))
731++SDL_MIR_SYM(float,mir_touch_event_axis_value,(MirTouchEvent const *event, size_t touch_index, MirTouchAxis axis))
732++SDL_MIR_SYM(MirTouchAction,mir_touch_event_action,(MirTouchEvent const *event, size_t touch_index))
733++SDL_MIR_SYM(MirPointerAction,mir_pointer_event_action,(MirPointerEvent const *event))
734++SDL_MIR_SYM(float,mir_pointer_event_axis_value,(MirPointerEvent const *event, MirPointerAxis))
735++SDL_MIR_SYM(MirEventType,mir_event_get_type,(MirEvent const *event))
736++SDL_MIR_SYM(MirInputEventType,mir_input_event_get_type,(MirInputEvent const *event))
737++SDL_MIR_SYM(MirInputEvent const*,mir_event_get_input_event,(MirEvent const *event))
738++SDL_MIR_SYM(MirResizeEvent const*,mir_event_get_resize_event,(MirEvent const *event))
739++SDL_MIR_SYM(MirKeyboardEvent const*,mir_input_event_get_keyboard_event,(MirInputEvent const *event))
740++SDL_MIR_SYM(MirPointerEvent const*,mir_input_event_get_pointer_event,(MirInputEvent const *event))
741++SDL_MIR_SYM(MirTouchEvent const*,mir_input_event_get_touch_event,(MirInputEvent const *event))
742++SDL_MIR_SYM(unsigned int,mir_touch_event_point_count,(MirTouchEvent const *event))
743+ SDL_MIR_SYM(void,mir_connection_get_available_surface_formats,(MirConnection* connection, MirPixelFormat* formats, unsigned const int format_size, unsigned int *num_valid_formats))
744+ SDL_MIR_SYM(MirEGLNativeDisplayType,mir_connection_get_egl_native_display,(MirConnection *connection))
745+-SDL_MIR_SYM(MirBool,mir_connection_is_valid,(MirConnection *connection))
746++SDL_MIR_SYM(bool,mir_connection_is_valid,(MirConnection *connection))
747+ SDL_MIR_SYM(void,mir_connection_release,(MirConnection *connection))
748+ SDL_MIR_SYM(MirConnection *,mir_connect_sync,(char const *server, char const *app_name))
749+ SDL_MIR_SYM(void,mir_display_config_destroy,(MirDisplayConfiguration* display_configuration))
750+-SDL_MIR_SYM(MirEGLNativeWindowType,mir_surface_get_egl_native_window,(MirSurface *surface))
751+ SDL_MIR_SYM(char const *,mir_surface_get_error_message,(MirSurface *surface))
752+-SDL_MIR_SYM(void,mir_surface_get_graphics_region,(MirSurface *surface, MirGraphicsRegion *graphics_region))
753+-SDL_MIR_SYM(void,mir_surface_get_parameters,(MirSurface *surface, MirSurfaceParameters *parameters))
754+-SDL_MIR_SYM(MirBool,mir_surface_is_valid,(MirSurface *surface))
755++SDL_MIR_SYM(bool,mir_surface_is_valid,(MirSurface *surface))
756+ SDL_MIR_SYM(void,mir_surface_release_sync,(MirSurface *surface))
757+-SDL_MIR_SYM(void,mir_surface_set_event_handler,(MirSurface *surface, MirEventDelegate const *event_handler))
758+-SDL_MIR_SYM(MirWaitHandle*,mir_surface_set_type,(MirSurface *surface, MirSurfaceType type))
759+-SDL_MIR_SYM(MirWaitHandle*,mir_surface_set_state,(MirSurface *surface, MirSurfaceState state))
760+-SDL_MIR_SYM(void,mir_surface_swap_buffers_sync,(MirSurface *surface))
761++SDL_MIR_SYM(void,mir_buffer_stream_release_sync,(MirBufferStream *stream))
762++SDL_MIR_SYM(MirCursorConfiguration*,mir_cursor_configuration_from_name,(char const* cursor_name))
763++SDL_MIR_SYM(MirWaitHandle*,mir_surface_configure_cursor,(MirSurface* surface, MirCursorConfiguration const* conf))
764++SDL_MIR_SYM(void,mir_cursor_configuration_destroy,(MirCursorConfiguration* conf))
765++SDL_MIR_SYM(void,mir_wait_for,(MirWaitHandle* handle))
766++SDL_MIR_SYM(int,mir_resize_event_get_width,(MirResizeEvent const* resize_event))
767++SDL_MIR_SYM(int,mir_resize_event_get_height,(MirResizeEvent const* resize_event))
768++
769++SDL_MIR_SYM_CONST(char const*,mir_omnidirectional_resize_cursor_name)
770++SDL_MIR_SYM_CONST(char const*,mir_busy_cursor_name)
771++SDL_MIR_SYM_CONST(char const*,mir_arrow_cursor_name)
772++SDL_MIR_SYM_CONST(char const*,mir_caret_cursor_name)
773++SDL_MIR_SYM_CONST(char const*,mir_vertical_resize_cursor_name)
774++SDL_MIR_SYM_CONST(char const*,mir_horizontal_resize_cursor_name)
775++SDL_MIR_SYM_CONST(char const*,mir_open_hand_cursor_name)
776++SDL_MIR_SYM_CONST(char const*,mir_closed_hand_cursor_name)
777+
778+ SDL_MIR_MODULE(XKBCOMMON)
779+ SDL_MIR_SYM(int,xkb_keysym_to_utf8,(xkb_keysym_t keysym, char *buffer, size_t size))
780+--- a/src/video/mir/SDL_mirvideo.c
781++++ b/src/video/mir/SDL_mirvideo.c
782+@@ -27,13 +27,13 @@
783+
784+ #if SDL_VIDEO_DRIVER_MIR
785+
786++#include "SDL_mirwindow.h"
787+ #include "SDL_video.h"
788+
789+ #include "SDL_mirframebuffer.h"
790+ #include "SDL_mirmouse.h"
791+ #include "SDL_miropengl.h"
792+ #include "SDL_mirvideo.h"
793+-#include "SDL_mirwindow.h"
794+
795+ #include "SDL_mirdyn.h"
796+
797+@@ -146,29 +146,29 @@
798+ device->GL_GetProcAddress = MIR_GL_GetProcAddress;
799+
800+ /* mirwindow */
801+- device->CreateWindow = MIR_CreateWindow;
802+- device->DestroyWindow = MIR_DestroyWindow;
803+- device->GetWindowWMInfo = MIR_GetWindowWMInfo;
804+- device->SetWindowFullscreen = MIR_SetWindowFullscreen;
805+- device->MaximizeWindow = MIR_MaximizeWindow;
806+- device->MinimizeWindow = MIR_MinimizeWindow;
807+- device->RestoreWindow = MIR_RestoreWindow;
808++ device->CreateWindow = MIR_CreateWindow;
809++ device->DestroyWindow = MIR_DestroyWindow;
810++ device->GetWindowWMInfo = MIR_GetWindowWMInfo;
811++ device->SetWindowFullscreen = MIR_SetWindowFullscreen;
812++ device->MaximizeWindow = MIR_MaximizeWindow;
813++ device->MinimizeWindow = MIR_MinimizeWindow;
814++ device->RestoreWindow = MIR_RestoreWindow;
815++ device->ShowWindow = MIR_RestoreWindow;
816++ device->HideWindow = MIR_HideWindow;
817++ device->SetWindowSize = MIR_SetWindowSize;
818++ device->SetWindowMinimumSize = MIR_SetWindowMinimumSize;
819++ device->SetWindowMaximumSize = MIR_SetWindowMaximumSize;
820++ device->SetWindowTitle = MIR_SetWindowTitle;
821+
822+ device->CreateWindowFrom = NULL;
823+- device->SetWindowTitle = NULL;
824+ device->SetWindowIcon = NULL;
825+- device->SetWindowPosition = NULL;
826+- device->SetWindowSize = NULL;
827+- device->SetWindowMinimumSize = NULL;
828+- device->SetWindowMaximumSize = NULL;
829+- device->ShowWindow = NULL;
830+- device->HideWindow = NULL;
831+ device->RaiseWindow = NULL;
832+ device->SetWindowBordered = NULL;
833+ device->SetWindowGammaRamp = NULL;
834+ device->GetWindowGammaRamp = NULL;
835+ device->SetWindowGrab = NULL;
836+ device->OnWindowEnter = NULL;
837++ device->SetWindowPosition = NULL;
838+
839+ /* mirframebuffer */
840+ device->CreateWindowFramebuffer = MIR_CreateWindowFramebuffer;
841+@@ -272,8 +272,9 @@
842+ {
843+ MIR_Data* mir_data = _this->driverdata;
844+
845+- mir_data->connection = MIR_mir_connect_sync(NULL, __PRETTY_FUNCTION__);
846+- mir_data->software = SDL_FALSE;
847++ mir_data->connection = MIR_mir_connect_sync(NULL, __PRETTY_FUNCTION__);
848++ mir_data->current_window = NULL;
849++ mir_data->software = SDL_FALSE;
850+
851+ if (!MIR_mir_connection_is_valid(mir_data->connection))
852+ return SDL_SetError("Failed to connect to the Mir Server");
853+--- a/src/video/mir/SDL_mirvideo.h
854++++ b/src/video/mir/SDL_mirvideo.h
855+@@ -29,11 +29,13 @@
856+ #include <EGL/egl.h>
857+ #include <mir_toolkit/mir_client_library.h>
858+
859++typedef struct MIR_Window MIR_Window;
860++
861+ typedef struct
862+ {
863+ MirConnection* connection;
864+- SDL_bool software;
865+-
866++ MIR_Window* current_window;
867++ SDL_bool software;
868+ } MIR_Data;
869+
870+ #endif /* _SDL_mirvideo_h_ */
871+--- a/src/video/mir/SDL_mirwindow.c
872++++ b/src/video/mir/SDL_mirwindow.c
873+@@ -77,21 +77,10 @@
874+ {
875+ MIR_Window* mir_window;
876+ MIR_Data* mir_data;
877++ MirPixelFormat pixel_format;
878++ MirBufferUsage buffer_usage;
879+
880+- MirSurfaceParameters surfaceparm =
881+- {
882+- .name = "MirSurface",
883+- .width = window->w,
884+- .height = window->h,
885+- .pixel_format = mir_pixel_format_invalid,
886+- .buffer_usage = mir_buffer_usage_hardware,
887+- .output_id = mir_display_output_id_invalid
888+- };
889+-
890+- MirEventDelegate delegate = {
891+- MIR_HandleInput,
892+- window
893+- };
894++ MirSurfaceSpec* spec;
895+
896+ mir_window = SDL_calloc(1, sizeof(MIR_Window));
897+ if (!mir_window)
898+@@ -100,9 +89,6 @@
899+ mir_data = _this->driverdata;
900+ window->driverdata = mir_window;
901+
902+- if (mir_data->software)
903+- surfaceparm.buffer_usage = mir_buffer_usage_software;
904+-
905+ if (window->x == SDL_WINDOWPOS_UNDEFINED)
906+ window->x = 0;
907+
908+@@ -112,12 +98,28 @@
909+ mir_window->mir_data = mir_data;
910+ mir_window->sdl_window = window;
911+
912+- surfaceparm.pixel_format = FindValidPixelFormat(mir_data);
913+- if (surfaceparm.pixel_format == mir_pixel_format_invalid) {
914++ pixel_format = FindValidPixelFormat(mir_data);
915++ if (pixel_format == mir_pixel_format_invalid) {
916+ return SDL_SetError("Failed to find a valid pixel format.");
917+ }
918+
919+- mir_window->surface = MIR_mir_connection_create_surface_sync(mir_data->connection, &surfaceparm);
920++ buffer_usage = mir_buffer_usage_hardware;
921++ if (mir_data->software)
922++ buffer_usage = mir_buffer_usage_software;
923++
924++ spec = MIR_mir_connection_create_spec_for_normal_surface(mir_data->connection,
925++ window->w,
926++ window->h,
927++ pixel_format);
928++
929++ MIR_mir_surface_spec_set_buffer_usage(spec, buffer_usage);
930++ MIR_mir_surface_spec_set_name(spec, "Mir surface");
931++
932++ mir_window->surface = MIR_mir_surface_create_sync(spec);
933++ MIR_mir_surface_set_event_handler(mir_window->surface, MIR_HandleEvent, window);
934++
935++ MIR_mir_surface_spec_release(spec);
936++
937+ if (!MIR_mir_surface_is_valid(mir_window->surface)) {
938+ const char* error = MIR_mir_surface_get_error_message(mir_window->surface);
939+ return SDL_SetError("Failed to created a mir surface: %s", error);
940+@@ -125,7 +127,8 @@
941+
942+ if (window->flags & SDL_WINDOW_OPENGL) {
943+ EGLNativeWindowType egl_native_window =
944+- (EGLNativeWindowType)MIR_mir_surface_get_egl_native_window(mir_window->surface);
945++ (EGLNativeWindowType)MIR_mir_buffer_stream_get_egl_native_window(
946++ MIR_mir_surface_get_buffer_stream(mir_window->surface));
947+
948+ mir_window->egl_surface = SDL_EGL_CreateSurface(_this, egl_native_window);
949+
950+@@ -138,7 +141,7 @@
951+ mir_window->egl_surface = EGL_NO_SURFACE;
952+ }
953+
954+- MIR_mir_surface_set_event_handler(mir_window->surface, &delegate);
955++ mir_data->current_window = mir_window;
956+
957+ return 0;
958+ }
959+@@ -146,13 +149,15 @@
960+ void
961+ MIR_DestroyWindow(_THIS, SDL_Window* window)
962+ {
963+- MIR_Data* mir_data = _this->driverdata;
964++ MIR_Data* mir_data = _this->driverdata;
965+ MIR_Window* mir_window = window->driverdata;
966+
967+ if (mir_data) {
968+ SDL_EGL_DestroySurface(_this, mir_window->egl_surface);
969+ MIR_mir_surface_release_sync(mir_window->surface);
970+
971++ mir_data->current_window = NULL;
972++
973+ SDL_free(mir_window);
974+ }
975+ window->driverdata = NULL;
976+@@ -180,49 +185,166 @@
977+ SDL_VideoDisplay* display,
978+ SDL_bool fullscreen)
979+ {
980++ MIR_Data* mir_data = _this->driverdata;
981+ MIR_Window* mir_window = window->driverdata;
982++ MirSurfaceSpec* spec;
983++ MirSurfaceState state;
984+
985+ if (IsSurfaceValid(mir_window) < 0)
986+ return;
987+
988+ if (fullscreen) {
989+- MIR_mir_surface_set_state(mir_window->surface, mir_surface_state_fullscreen);
990++ state = mir_surface_state_fullscreen;
991+ } else {
992+- MIR_mir_surface_set_state(mir_window->surface, mir_surface_state_restored);
993++ state = mir_surface_state_restored;
994+ }
995++
996++ spec = MIR_mir_connection_create_spec_for_changes(mir_data->connection);
997++ MIR_mir_surface_spec_set_state(spec, state);
998++
999++ MIR_mir_surface_apply_spec(mir_window->surface, spec);
1000++ MIR_mir_surface_spec_release(spec);
1001+ }
1002+
1003+ void
1004+ MIR_MaximizeWindow(_THIS, SDL_Window* window)
1005+ {
1006++ MIR_Data* mir_data = _this->driverdata;
1007+ MIR_Window* mir_window = window->driverdata;
1008++ MirSurfaceSpec* spec;
1009+
1010+ if (IsSurfaceValid(mir_window) < 0)
1011+ return;
1012+
1013+- MIR_mir_surface_set_state(mir_window->surface, mir_surface_state_maximized);
1014++ spec = MIR_mir_connection_create_spec_for_changes(mir_data->connection);
1015++ MIR_mir_surface_spec_set_state(spec, mir_surface_state_maximized);
1016++
1017++ MIR_mir_surface_apply_spec(mir_window->surface, spec);
1018++ MIR_mir_surface_spec_release(spec);
1019+ }
1020+
1021+ void
1022+ MIR_MinimizeWindow(_THIS, SDL_Window* window)
1023+ {
1024++ MIR_Data* mir_data = _this->driverdata;
1025+ MIR_Window* mir_window = window->driverdata;
1026++ MirSurfaceSpec* spec;
1027+
1028+ if (IsSurfaceValid(mir_window) < 0)
1029+ return;
1030+
1031+- MIR_mir_surface_set_state(mir_window->surface, mir_surface_state_minimized);
1032++ spec = MIR_mir_connection_create_spec_for_changes(mir_data->connection);
1033++ MIR_mir_surface_spec_set_state(spec, mir_surface_state_minimized);
1034++
1035++ MIR_mir_surface_apply_spec(mir_window->surface, spec);
1036++ MIR_mir_surface_spec_release(spec);
1037+ }
1038+
1039+ void
1040+ MIR_RestoreWindow(_THIS, SDL_Window * window)
1041+ {
1042++ MIR_Data* mir_data = _this->driverdata;
1043++ MIR_Window* mir_window = window->driverdata;
1044++ MirSurfaceSpec* spec;
1045++
1046++ if (IsSurfaceValid(mir_window) < 0)
1047++ return;
1048++
1049++ spec = MIR_mir_connection_create_spec_for_changes(mir_data->connection);
1050++ MIR_mir_surface_spec_set_state(spec, mir_surface_state_restored);
1051++
1052++ MIR_mir_surface_apply_spec(mir_window->surface, spec);
1053++ MIR_mir_surface_spec_release(spec);
1054++}
1055++
1056++void
1057++MIR_HideWindow(_THIS, SDL_Window* window)
1058++{
1059++ MIR_Data* mir_data = _this->driverdata;
1060++ MIR_Window* mir_window = window->driverdata;
1061++ MirSurfaceSpec* spec;
1062++
1063++ if (IsSurfaceValid(mir_window) < 0)
1064++ return;
1065++
1066++ spec = MIR_mir_connection_create_spec_for_changes(mir_data->connection);
1067++ MIR_mir_surface_spec_set_state(spec, mir_surface_state_hidden);
1068++
1069++ MIR_mir_surface_apply_spec(mir_window->surface, spec);
1070++ MIR_mir_surface_spec_release(spec);
1071++}
1072++
1073++void
1074++MIR_SetWindowSize(_THIS, SDL_Window* window)
1075++{
1076++ MIR_Data* mir_data = _this->driverdata;
1077++ MIR_Window* mir_window = window->driverdata;
1078++ MirSurfaceSpec* spec;
1079++
1080++ if (IsSurfaceValid(mir_window) < 0)
1081++ return;
1082++
1083++ /* You cannot set the x/y of a mir window! So only update w/h */
1084++ spec = MIR_mir_connection_create_spec_for_changes(mir_data->connection);
1085++ MIR_mir_surface_spec_set_width (spec, window->w);
1086++ MIR_mir_surface_spec_set_height(spec, window->h);
1087++
1088++ MIR_mir_surface_apply_spec(mir_window->surface, spec);
1089++ MIR_mir_surface_spec_release(spec);
1090++}
1091++
1092++void
1093++MIR_SetWindowMinimumSize(_THIS, SDL_Window* window)
1094++{
1095++ MIR_Data* mir_data = _this->driverdata;
1096++ MIR_Window* mir_window = window->driverdata;
1097++ MirSurfaceSpec* spec;
1098++
1099++ if (IsSurfaceValid(mir_window) < 0)
1100++ return;
1101++
1102++ spec = MIR_mir_connection_create_spec_for_changes(mir_data->connection);
1103++ MIR_mir_surface_spec_set_min_width (spec, window->min_w);
1104++ MIR_mir_surface_spec_set_min_height(spec, window->min_h);
1105++
1106++ MIR_mir_surface_apply_spec(mir_window->surface, spec);
1107++ MIR_mir_surface_spec_release(spec);
1108++}
1109++
1110++void
1111++MIR_SetWindowMaximumSize(_THIS, SDL_Window* window)
1112++{
1113++ MIR_Data* mir_data = _this->driverdata;
1114++ MIR_Window* mir_window = window->driverdata;
1115++ MirSurfaceSpec* spec;
1116++
1117++ if (IsSurfaceValid(mir_window) < 0)
1118++ return;
1119++
1120++ spec = MIR_mir_connection_create_spec_for_changes(mir_data->connection);
1121++ MIR_mir_surface_spec_set_max_width (spec, window->max_w);
1122++ MIR_mir_surface_spec_set_max_height(spec, window->max_h);
1123++
1124++ MIR_mir_surface_apply_spec(mir_window->surface, spec);
1125++ MIR_mir_surface_spec_release(spec);
1126++}
1127++
1128++void
1129++MIR_SetWindowTitle(_THIS, SDL_Window* window)
1130++{
1131++ MIR_Data* mir_data = _this->driverdata;
1132+ MIR_Window* mir_window = window->driverdata;
1133++ char const* title = window->title ? window->title : "";
1134++ MirSurfaceSpec* spec;
1135+
1136+ if (IsSurfaceValid(mir_window) < 0)
1137+ return;
1138+
1139+- MIR_mir_surface_set_state(mir_window->surface, mir_surface_state_restored);
1140++ spec = MIR_mir_connection_create_spec_for_changes(mir_data->connection);
1141++ MIR_mir_surface_spec_set_name(spec, title);
1142++
1143++ MIR_mir_surface_apply_spec(mir_window->surface, spec);
1144++ MIR_mir_surface_spec_release(spec);
1145+ }
1146+
1147+ #endif /* SDL_VIDEO_DRIVER_MIR */
1148+--- a/src/video/mir/SDL_mirwindow.h
1149++++ b/src/video/mir/SDL_mirwindow.h
1150+@@ -1,6 +1,6 @@
1151+ /*
1152+ Simple DirectMedia Layer
1153+- Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
1154++ Copyright (C) 1997-2015 Sam Lantinga <slouken@libsdl.org>
1155+
1156+ This software is provided 'as-is', without any express or implied
1157+ warranty. In no event will the authors be held liable for any damages
1158+@@ -31,13 +31,13 @@
1159+
1160+ #include "SDL_mirvideo.h"
1161+
1162+-typedef struct {
1163++struct MIR_Window {
1164+ SDL_Window* sdl_window;
1165+- MIR_Data* mir_data;
1166++ MIR_Data* mir_data;
1167+
1168+ MirSurface* surface;
1169+- EGLSurface egl_surface;
1170+-} MIR_Window;
1171++ EGLSurface egl_surface;
1172++};
1173+
1174+
1175+ extern int
1176+@@ -60,9 +60,24 @@
1177+ extern void
1178+ MIR_RestoreWindow(_THIS, SDL_Window* window);
1179+
1180++extern void
1181++MIR_HideWindow(_THIS, SDL_Window* window);
1182++
1183+ extern SDL_bool
1184+ MIR_GetWindowWMInfo(_THIS, SDL_Window* window, SDL_SysWMinfo* info);
1185+
1186++extern void
1187++MIR_SetWindowSize(_THIS, SDL_Window* window);
1188++
1189++extern void
1190++MIR_SetWindowMinimumSize(_THIS, SDL_Window* window);
1191++
1192++extern void
1193++MIR_SetWindowMaximumSize(_THIS, SDL_Window* window);
1194++
1195++extern void
1196++MIR_SetWindowTitle(_THIS, SDL_Window* window);
1197++
1198+ #endif /* _SDL_mirwindow */
1199+
1200+ /* vi: set ts=4 sw=4 expandtab: */
1201
1202=== modified file 'debian/patches/series'
1203--- debian/patches/series 2015-01-26 14:45:28 +0000
1204+++ debian/patches/series 2015-11-03 18:01:14 +0000
1205@@ -3,3 +3,4 @@
1206 fix_joystick_misc_axes.diff
1207 mir_forward_declaration_syswm.diff
1208 mir_upstream_patch.diff
1209+mir_new_abi_api.diff

Subscribers

People subscribed via source and target branches