author | bschaefer |
Sun, 21 Feb 2016 15:19:35 -0800 | |
changeset 10089 | 25fda20d0173 |
parent 9998 | f67cf37e9cd4 |
child 10091 | 9fccd3acad30 |
permissions | -rw-r--r-- |
8153
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
1 |
/* |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
2 |
Simple DirectMedia Layer |
9998
f67cf37e9cd4
Updated copyright to 2016
Sam Lantinga <slouken@libsdl.org>
parents:
9807
diff
changeset
|
3 |
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> |
8153
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
4 |
|
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
5 |
This software is provided 'as-is', without any express or implied |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
6 |
warranty. In no event will the authors be held liable for any damages |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
7 |
arising from the use of this software. |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
8 |
|
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
9 |
Permission is granted to anyone to use this software for any purpose, |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
10 |
including commercial applications, and to alter it and redistribute it |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
11 |
freely, subject to the following restrictions: |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
12 |
|
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
13 |
1. The origin of this software must not be misrepresented; you must not |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
14 |
claim that you wrote the original software. If you use this software |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
15 |
in a product, an acknowledgment in the product documentation would be |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
16 |
appreciated but is not required. |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
17 |
2. Altered source versions must be plainly marked as such, and must not be |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
18 |
misrepresented as being the original software. |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
19 |
3. This notice may not be removed or altered from any source distribution. |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
20 |
*/ |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
21 |
|
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
22 |
/* |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
23 |
Contributed by Brandon Schaefer, <brandon.schaefer@canonical.com> |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
24 |
*/ |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
25 |
|
8154
ea6b25de67b6
Cleaned up headers and footers on Mir code.
Ryan C. Gordon <icculus@icculus.org>
parents:
8153
diff
changeset
|
26 |
#include "../../SDL_internal.h" |
ea6b25de67b6
Cleaned up headers and footers on Mir code.
Ryan C. Gordon <icculus@icculus.org>
parents:
8153
diff
changeset
|
27 |
|
ea6b25de67b6
Cleaned up headers and footers on Mir code.
Ryan C. Gordon <icculus@icculus.org>
parents:
8153
diff
changeset
|
28 |
#if SDL_VIDEO_DRIVER_MIR |
8153
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
29 |
|
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
30 |
#include "../../events/SDL_mouse_c.h" |
10089 | 31 |
#include "../SDL_sysvideo.h" |
8153
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
32 |
#include "SDL_assert.h" |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
33 |
|
8159
427e8fdf6f69
Hooked up dynamic loading for Mir.
Ryan C. Gordon <icculus@icculus.org>
parents:
8157
diff
changeset
|
34 |
#include "SDL_mirdyn.h" |
427e8fdf6f69
Hooked up dynamic loading for Mir.
Ryan C. Gordon <icculus@icculus.org>
parents:
8157
diff
changeset
|
35 |
|
10089 | 36 |
#include "SDL_mirvideo.h" |
37 |
#include "SDL_mirmouse.h" |
|
38 |
#include "SDL_mirwindow.h" |
|
39 |
||
40 |
typedef struct |
|
41 |
{ |
|
42 |
MirCursorConfiguration* conf; |
|
43 |
MirBufferStream* stream; |
|
44 |
} MIR_Cursor; |
|
45 |
||
8153
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
46 |
static SDL_Cursor* |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
47 |
MIR_CreateDefaultCursor() |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
48 |
{ |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
49 |
SDL_Cursor* cursor; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
50 |
|
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
51 |
cursor = SDL_calloc(1, sizeof(SDL_Cursor)); |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
52 |
if (cursor) { |
10089 | 53 |
|
54 |
MIR_Cursor* mir_cursor = SDL_calloc(1, sizeof(MIR_Cursor)); |
|
55 |
if (mir_cursor) { |
|
56 |
mir_cursor->conf = NULL; |
|
57 |
mir_cursor->stream = NULL; |
|
58 |
cursor->driverdata = mir_cursor; |
|
59 |
} |
|
60 |
else { |
|
61 |
SDL_OutOfMemory(); |
|
62 |
} |
|
8153
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
63 |
} |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
64 |
else { |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
65 |
SDL_OutOfMemory(); |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
66 |
} |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
67 |
|
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
68 |
return cursor; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
69 |
} |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
70 |
|
10089 | 71 |
static void |
72 |
CopySurfacePixelsToMirStream(SDL_Surface* surface, MirBufferStream* stream) |
|
73 |
{ |
|
74 |
char* dest, *pixels; |
|
75 |
int i, s_w, s_h, r_stride, p_stride, bytes_per_pixel, bytes_per_row; |
|
76 |
||
77 |
MirGraphicsRegion region; |
|
78 |
MIR_mir_buffer_stream_get_graphics_region(stream, ®ion); |
|
79 |
||
80 |
s_w = surface->w; |
|
81 |
s_h = surface->h; |
|
82 |
||
83 |
bytes_per_pixel = surface->format->BytesPerPixel; |
|
84 |
bytes_per_row = bytes_per_pixel * s_w; |
|
85 |
||
86 |
dest = region.vaddr; |
|
87 |
pixels = (char*)surface->pixels; |
|
88 |
||
89 |
r_stride = region.stride; |
|
90 |
p_stride = surface->pitch; |
|
91 |
||
92 |
for (i = 0; i < s_h; i++) |
|
93 |
{ |
|
94 |
memcpy(dest, pixels, bytes_per_row); |
|
95 |
dest += r_stride; |
|
96 |
pixels += p_stride; |
|
97 |
} |
|
98 |
} |
|
99 |
||
8153
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
100 |
static SDL_Cursor* |
10089 | 101 |
MIR_CreateCursor(SDL_Surface* surface, int hot_x, int hot_y) |
8153
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
102 |
{ |
10089 | 103 |
MirCursorConfiguration* conf; |
104 |
MirBufferStream* stream; |
|
105 |
||
106 |
int s_w = surface->w; |
|
107 |
int s_h = surface->h; |
|
108 |
||
109 |
MIR_Data* mir_data = (MIR_Data*)SDL_GetVideoDevice()->driverdata; |
|
110 |
SDL_Cursor* cursor = MIR_CreateDefaultCursor(); |
|
111 |
MIR_Cursor* mir_cursor = (MIR_Cursor*)cursor->driverdata; |
|
112 |
||
113 |
stream = MIR_mir_connection_create_buffer_stream_sync(mir_data->connection, |
|
114 |
s_w, s_h, mir_data->pixel_format, |
|
115 |
mir_buffer_usage_software); |
|
116 |
||
117 |
conf = MIR_mir_cursor_configuration_from_buffer_stream(stream, hot_x, hot_y); |
|
118 |
||
119 |
CopySurfacePixelsToMirStream(surface, stream); |
|
120 |
MIR_mir_buffer_stream_swap_buffers_sync(stream); |
|
121 |
||
122 |
mir_cursor->conf = conf; |
|
123 |
mir_cursor->stream = stream; |
|
124 |
||
125 |
return cursor; |
|
8153
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
126 |
} |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
127 |
|
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
128 |
static SDL_Cursor* |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
129 |
MIR_CreateSystemCursor(SDL_SystemCursor id) |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
130 |
{ |
10089 | 131 |
char const* cursor_name = NULL; |
132 |
MirCursorConfiguration* conf; |
|
133 |
SDL_Cursor* cursor = MIR_CreateDefaultCursor(); |
|
134 |
||
8153
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
135 |
switch(id) { |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
136 |
case SDL_SYSTEM_CURSOR_ARROW: |
10089 | 137 |
cursor_name = MIR_mir_arrow_cursor_name; |
8153
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
138 |
break; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
139 |
case SDL_SYSTEM_CURSOR_IBEAM: |
10089 | 140 |
cursor_name = MIR_mir_caret_cursor_name; |
8153
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
141 |
break; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
142 |
case SDL_SYSTEM_CURSOR_WAIT: |
10089 | 143 |
cursor_name = MIR_mir_busy_cursor_name; |
8153
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
144 |
break; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
145 |
case SDL_SYSTEM_CURSOR_CROSSHAIR: |
10089 | 146 |
/* Unsupported */ |
147 |
cursor_name = MIR_mir_arrow_cursor_name; |
|
8153
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
148 |
break; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
149 |
case SDL_SYSTEM_CURSOR_WAITARROW: |
10089 | 150 |
cursor_name = MIR_mir_busy_cursor_name; |
8153
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
151 |
break; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
152 |
case SDL_SYSTEM_CURSOR_SIZENWSE: |
10089 | 153 |
cursor_name = MIR_mir_omnidirectional_resize_cursor_name; |
8153
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
154 |
break; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
155 |
case SDL_SYSTEM_CURSOR_SIZENESW: |
10089 | 156 |
cursor_name = MIR_mir_omnidirectional_resize_cursor_name; |
8153
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
157 |
break; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
158 |
case SDL_SYSTEM_CURSOR_SIZEWE: |
10089 | 159 |
cursor_name = MIR_mir_horizontal_resize_cursor_name; |
8153
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
160 |
break; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
161 |
case SDL_SYSTEM_CURSOR_SIZENS: |
10089 | 162 |
cursor_name = MIR_mir_vertical_resize_cursor_name; |
8153
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
163 |
break; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
164 |
case SDL_SYSTEM_CURSOR_SIZEALL: |
10089 | 165 |
cursor_name = MIR_mir_omnidirectional_resize_cursor_name; |
8153
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
166 |
break; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
167 |
case SDL_SYSTEM_CURSOR_NO: |
10089 | 168 |
/* Unsupported */ |
169 |
cursor_name = MIR_mir_closed_hand_cursor_name; |
|
8153
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
170 |
break; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
171 |
case SDL_SYSTEM_CURSOR_HAND: |
10089 | 172 |
cursor_name = MIR_mir_open_hand_cursor_name; |
8153
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
173 |
break; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
174 |
default: |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
175 |
SDL_assert(0); |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
176 |
return NULL; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
177 |
} |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
178 |
|
10089 | 179 |
conf = MIR_mir_cursor_configuration_from_name(cursor_name); |
180 |
||
181 |
cursor->driverdata = conf; |
|
182 |
||
183 |
return cursor; |
|
8153
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
184 |
} |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
185 |
|
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
186 |
static void |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
187 |
MIR_FreeCursor(SDL_Cursor* cursor) |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
188 |
{ |
10089 | 189 |
if (cursor) { |
190 |
||
191 |
if (cursor->driverdata) { |
|
192 |
MIR_Cursor* mir_cursor = (MIR_Cursor*)cursor->driverdata; |
|
193 |
||
194 |
if (mir_cursor->conf) |
|
195 |
MIR_mir_cursor_configuration_destroy(mir_cursor->conf); |
|
196 |
if (mir_cursor->stream) |
|
197 |
MIR_mir_buffer_stream_release_sync(mir_cursor->stream); |
|
198 |
||
199 |
SDL_free(mir_cursor); |
|
200 |
} |
|
201 |
||
202 |
SDL_free(cursor); |
|
203 |
} |
|
8153
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
204 |
} |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
205 |
|
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
206 |
static int |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
207 |
MIR_ShowCursor(SDL_Cursor* cursor) |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
208 |
{ |
10089 | 209 |
MIR_Data* mir_data = (MIR_Data*)SDL_GetVideoDevice()->driverdata; |
210 |
MIR_Window* mir_window = mir_data->current_window; |
|
211 |
||
212 |
if (cursor && cursor->driverdata) { |
|
213 |
if (mir_window && MIR_mir_surface_is_valid(mir_window->surface)) { |
|
214 |
MIR_Cursor* mir_cursor = (MIR_Cursor*)cursor->driverdata; |
|
215 |
||
216 |
if (mir_cursor->conf) { |
|
217 |
MIR_mir_wait_for(MIR_mir_surface_configure_cursor(mir_window->surface, mir_cursor->conf)); |
|
218 |
} |
|
219 |
} |
|
220 |
} |
|
221 |
else if(mir_window && MIR_mir_surface_is_valid(mir_window->surface)) { |
|
222 |
MIR_mir_wait_for(MIR_mir_surface_configure_cursor(mir_window->surface, NULL)); |
|
223 |
} |
|
224 |
||
8153
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
225 |
return 0; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
226 |
} |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
227 |
|
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
228 |
static void |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
229 |
MIR_WarpMouse(SDL_Window* window, int x, int y) |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
230 |
{ |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
231 |
SDL_Unsupported(); |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
232 |
} |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
233 |
|
9807
57b448735f48
SDL_WarpMouseGlobal() should return non-void.
Ryan C. Gordon <icculus@icculus.org>
parents:
9619
diff
changeset
|
234 |
static int |
8815
c6d0a457f3b2
Added an API function to warp the mouse cursor in global screen space: SDL_WarpMouseGlobal()
Sam Lantinga <slouken@libsdl.org>
parents:
8159
diff
changeset
|
235 |
MIR_WarpMouseGlobal(int x, int y) |
c6d0a457f3b2
Added an API function to warp the mouse cursor in global screen space: SDL_WarpMouseGlobal()
Sam Lantinga <slouken@libsdl.org>
parents:
8159
diff
changeset
|
236 |
{ |
9807
57b448735f48
SDL_WarpMouseGlobal() should return non-void.
Ryan C. Gordon <icculus@icculus.org>
parents:
9619
diff
changeset
|
237 |
return SDL_Unsupported(); |
8815
c6d0a457f3b2
Added an API function to warp the mouse cursor in global screen space: SDL_WarpMouseGlobal()
Sam Lantinga <slouken@libsdl.org>
parents:
8159
diff
changeset
|
238 |
} |
c6d0a457f3b2
Added an API function to warp the mouse cursor in global screen space: SDL_WarpMouseGlobal()
Sam Lantinga <slouken@libsdl.org>
parents:
8159
diff
changeset
|
239 |
|
8153
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
240 |
static int |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
241 |
MIR_SetRelativeMouseMode(SDL_bool enabled) |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
242 |
{ |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
243 |
return SDL_Unsupported(); |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
244 |
} |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
245 |
|
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
246 |
/* TODO Actually implement the cursor, need to wait for mir support */ |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
247 |
void |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
248 |
MIR_InitMouse() |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
249 |
{ |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
250 |
SDL_Mouse* mouse = SDL_GetMouse(); |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
251 |
|
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
252 |
mouse->CreateCursor = MIR_CreateCursor; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
253 |
mouse->ShowCursor = MIR_ShowCursor; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
254 |
mouse->FreeCursor = MIR_FreeCursor; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
255 |
mouse->WarpMouse = MIR_WarpMouse; |
8815
c6d0a457f3b2
Added an API function to warp the mouse cursor in global screen space: SDL_WarpMouseGlobal()
Sam Lantinga <slouken@libsdl.org>
parents:
8159
diff
changeset
|
256 |
mouse->WarpMouseGlobal = MIR_WarpMouseGlobal; |
8153
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
257 |
mouse->CreateSystemCursor = MIR_CreateSystemCursor; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
258 |
mouse->SetRelativeMouseMode = MIR_SetRelativeMouseMode; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
259 |
|
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
260 |
SDL_SetDefaultCursor(MIR_CreateDefaultCursor()); |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
261 |
} |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
262 |
|
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
263 |
void |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
264 |
MIR_FiniMouse() |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
265 |
{ |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
266 |
SDL_Mouse* mouse = SDL_GetMouse(); |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
267 |
|
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
268 |
MIR_FreeCursor(mouse->def_cursor); |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
269 |
mouse->def_cursor = NULL; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
270 |
|
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
271 |
mouse->CreateCursor = NULL; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
272 |
mouse->ShowCursor = NULL; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
273 |
mouse->FreeCursor = NULL; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
274 |
mouse->WarpMouse = NULL; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
275 |
mouse->CreateSystemCursor = NULL; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
276 |
mouse->SetRelativeMouseMode = NULL; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
277 |
} |
8154
ea6b25de67b6
Cleaned up headers and footers on Mir code.
Ryan C. Gordon <icculus@icculus.org>
parents:
8153
diff
changeset
|
278 |
|
ea6b25de67b6
Cleaned up headers and footers on Mir code.
Ryan C. Gordon <icculus@icculus.org>
parents:
8153
diff
changeset
|
279 |
#endif /* SDL_VIDEO_DRIVER_MIR */ |
ea6b25de67b6
Cleaned up headers and footers on Mir code.
Ryan C. Gordon <icculus@icculus.org>
parents:
8153
diff
changeset
|
280 |
|
ea6b25de67b6
Cleaned up headers and footers on Mir code.
Ryan C. Gordon <icculus@icculus.org>
parents:
8153
diff
changeset
|
281 |
/* vi: set ts=4 sw=4 expandtab: */ |
ea6b25de67b6
Cleaned up headers and footers on Mir code.
Ryan C. Gordon <icculus@icculus.org>
parents:
8153
diff
changeset
|
282 |