author | Brandon Schaefer <brandon.schaefer@canonical.com> |
Wed, 13 Jul 2016 07:07:08 -0700 | |
changeset 10192 | 3a5779b13f69 |
parent 10180 | 7356b2938fba |
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(); |
|
10091
9fccd3acad30
Mir: Fixed crash if allocating memory for cursor failed.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents:
10089
diff
changeset
|
62 |
SDL_free(cursor); |
9fccd3acad30
Mir: Fixed crash if allocating memory for cursor failed.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents:
10089
diff
changeset
|
63 |
cursor = NULL; |
10089 | 64 |
} |
8153
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
65 |
} |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
66 |
else { |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
67 |
SDL_OutOfMemory(); |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
68 |
} |
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 |
return cursor; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
71 |
} |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
72 |
|
10089 | 73 |
static void |
74 |
CopySurfacePixelsToMirStream(SDL_Surface* surface, MirBufferStream* stream) |
|
75 |
{ |
|
76 |
char* dest, *pixels; |
|
77 |
int i, s_w, s_h, r_stride, p_stride, bytes_per_pixel, bytes_per_row; |
|
78 |
||
79 |
MirGraphicsRegion region; |
|
80 |
MIR_mir_buffer_stream_get_graphics_region(stream, ®ion); |
|
81 |
||
82 |
s_w = surface->w; |
|
83 |
s_h = surface->h; |
|
84 |
||
85 |
bytes_per_pixel = surface->format->BytesPerPixel; |
|
86 |
bytes_per_row = bytes_per_pixel * s_w; |
|
87 |
||
88 |
dest = region.vaddr; |
|
89 |
pixels = (char*)surface->pixels; |
|
90 |
||
91 |
r_stride = region.stride; |
|
92 |
p_stride = surface->pitch; |
|
93 |
||
94 |
for (i = 0; i < s_h; i++) |
|
95 |
{ |
|
10094
fdfdae3f6039
Mir: Replaced memcpy() with SDL_memcpy().
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents:
10091
diff
changeset
|
96 |
SDL_memcpy(dest, pixels, bytes_per_row); |
10089 | 97 |
dest += r_stride; |
98 |
pixels += p_stride; |
|
99 |
} |
|
100 |
} |
|
101 |
||
8153
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
102 |
static SDL_Cursor* |
10089 | 103 |
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
|
104 |
{ |
10089 | 105 |
MirCursorConfiguration* conf; |
106 |
MirBufferStream* stream; |
|
107 |
||
108 |
int s_w = surface->w; |
|
109 |
int s_h = surface->h; |
|
110 |
||
111 |
MIR_Data* mir_data = (MIR_Data*)SDL_GetVideoDevice()->driverdata; |
|
112 |
SDL_Cursor* cursor = MIR_CreateDefaultCursor(); |
|
10091
9fccd3acad30
Mir: Fixed crash if allocating memory for cursor failed.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents:
10089
diff
changeset
|
113 |
MIR_Cursor* mir_cursor; |
9fccd3acad30
Mir: Fixed crash if allocating memory for cursor failed.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents:
10089
diff
changeset
|
114 |
|
9fccd3acad30
Mir: Fixed crash if allocating memory for cursor failed.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents:
10089
diff
changeset
|
115 |
if (!cursor) { |
9fccd3acad30
Mir: Fixed crash if allocating memory for cursor failed.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents:
10089
diff
changeset
|
116 |
return NULL; |
9fccd3acad30
Mir: Fixed crash if allocating memory for cursor failed.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents:
10089
diff
changeset
|
117 |
} |
9fccd3acad30
Mir: Fixed crash if allocating memory for cursor failed.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents:
10089
diff
changeset
|
118 |
|
9fccd3acad30
Mir: Fixed crash if allocating memory for cursor failed.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents:
10089
diff
changeset
|
119 |
mir_cursor = (MIR_Cursor*)cursor->driverdata; |
10089 | 120 |
|
121 |
stream = MIR_mir_connection_create_buffer_stream_sync(mir_data->connection, |
|
122 |
s_w, s_h, mir_data->pixel_format, |
|
123 |
mir_buffer_usage_software); |
|
124 |
||
125 |
conf = MIR_mir_cursor_configuration_from_buffer_stream(stream, hot_x, hot_y); |
|
126 |
||
127 |
CopySurfacePixelsToMirStream(surface, stream); |
|
128 |
MIR_mir_buffer_stream_swap_buffers_sync(stream); |
|
129 |
||
130 |
mir_cursor->conf = conf; |
|
131 |
mir_cursor->stream = stream; |
|
132 |
||
133 |
return cursor; |
|
8153
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
134 |
} |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
135 |
|
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
136 |
static SDL_Cursor* |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
137 |
MIR_CreateSystemCursor(SDL_SystemCursor id) |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
138 |
{ |
10089 | 139 |
char const* cursor_name = NULL; |
10192
3a5779b13f69
MIR: Fix system cursors. Been broken since custom cursor support was added!
Brandon Schaefer <brandon.schaefer@canonical.com>
parents:
10180
diff
changeset
|
140 |
SDL_Cursor* cursor = MIR_CreateDefaultCursor(); |
3a5779b13f69
MIR: Fix system cursors. Been broken since custom cursor support was added!
Brandon Schaefer <brandon.schaefer@canonical.com>
parents:
10180
diff
changeset
|
141 |
MIR_Cursor* mir_cursor = (MIR_Cursor*)cursor->driverdata; |
10089 | 142 |
|
10091
9fccd3acad30
Mir: Fixed crash if allocating memory for cursor failed.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents:
10089
diff
changeset
|
143 |
if (!cursor) { |
9fccd3acad30
Mir: Fixed crash if allocating memory for cursor failed.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents:
10089
diff
changeset
|
144 |
return NULL; |
9fccd3acad30
Mir: Fixed crash if allocating memory for cursor failed.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents:
10089
diff
changeset
|
145 |
} |
9fccd3acad30
Mir: Fixed crash if allocating memory for cursor failed.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents:
10089
diff
changeset
|
146 |
|
8153
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
147 |
switch(id) { |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
148 |
case SDL_SYSTEM_CURSOR_ARROW: |
10089 | 149 |
cursor_name = MIR_mir_arrow_cursor_name; |
8153
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
150 |
break; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
151 |
case SDL_SYSTEM_CURSOR_IBEAM: |
10089 | 152 |
cursor_name = MIR_mir_caret_cursor_name; |
8153
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
153 |
break; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
154 |
case SDL_SYSTEM_CURSOR_WAIT: |
10089 | 155 |
cursor_name = MIR_mir_busy_cursor_name; |
8153
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
156 |
break; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
157 |
case SDL_SYSTEM_CURSOR_CROSSHAIR: |
10089 | 158 |
/* Unsupported */ |
159 |
cursor_name = MIR_mir_arrow_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_WAITARROW: |
10089 | 162 |
cursor_name = MIR_mir_busy_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_SIZENWSE: |
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_SIZENESW: |
10089 | 168 |
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
|
169 |
break; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
170 |
case SDL_SYSTEM_CURSOR_SIZEWE: |
10089 | 171 |
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
|
172 |
break; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
173 |
case SDL_SYSTEM_CURSOR_SIZENS: |
10089 | 174 |
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
|
175 |
break; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
176 |
case SDL_SYSTEM_CURSOR_SIZEALL: |
10089 | 177 |
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
|
178 |
break; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
179 |
case SDL_SYSTEM_CURSOR_NO: |
10089 | 180 |
/* Unsupported */ |
181 |
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
|
182 |
break; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
183 |
case SDL_SYSTEM_CURSOR_HAND: |
10089 | 184 |
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
|
185 |
break; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
186 |
default: |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
187 |
SDL_assert(0); |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
188 |
return NULL; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
189 |
} |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
190 |
|
10192
3a5779b13f69
MIR: Fix system cursors. Been broken since custom cursor support was added!
Brandon Schaefer <brandon.schaefer@canonical.com>
parents:
10180
diff
changeset
|
191 |
mir_cursor->conf = MIR_mir_cursor_configuration_from_name(cursor_name); |
10089 | 192 |
|
193 |
return cursor; |
|
8153
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
194 |
} |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
195 |
|
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
196 |
static void |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
197 |
MIR_FreeCursor(SDL_Cursor* cursor) |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
198 |
{ |
10089 | 199 |
if (cursor) { |
200 |
||
201 |
if (cursor->driverdata) { |
|
202 |
MIR_Cursor* mir_cursor = (MIR_Cursor*)cursor->driverdata; |
|
203 |
||
204 |
if (mir_cursor->conf) |
|
205 |
MIR_mir_cursor_configuration_destroy(mir_cursor->conf); |
|
206 |
if (mir_cursor->stream) |
|
207 |
MIR_mir_buffer_stream_release_sync(mir_cursor->stream); |
|
208 |
||
209 |
SDL_free(mir_cursor); |
|
210 |
} |
|
211 |
||
212 |
SDL_free(cursor); |
|
213 |
} |
|
8153
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
214 |
} |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
215 |
|
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
216 |
static int |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
217 |
MIR_ShowCursor(SDL_Cursor* cursor) |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
218 |
{ |
10089 | 219 |
MIR_Data* mir_data = (MIR_Data*)SDL_GetVideoDevice()->driverdata; |
220 |
MIR_Window* mir_window = mir_data->current_window; |
|
221 |
||
222 |
if (cursor && cursor->driverdata) { |
|
223 |
if (mir_window && MIR_mir_surface_is_valid(mir_window->surface)) { |
|
224 |
MIR_Cursor* mir_cursor = (MIR_Cursor*)cursor->driverdata; |
|
225 |
||
226 |
if (mir_cursor->conf) { |
|
10192
3a5779b13f69
MIR: Fix system cursors. Been broken since custom cursor support was added!
Brandon Schaefer <brandon.schaefer@canonical.com>
parents:
10180
diff
changeset
|
227 |
MIR_mir_surface_configure_cursor(mir_window->surface, mir_cursor->conf); |
10089 | 228 |
} |
229 |
} |
|
230 |
} |
|
231 |
else if(mir_window && MIR_mir_surface_is_valid(mir_window->surface)) { |
|
10192
3a5779b13f69
MIR: Fix system cursors. Been broken since custom cursor support was added!
Brandon Schaefer <brandon.schaefer@canonical.com>
parents:
10180
diff
changeset
|
232 |
MIR_mir_surface_configure_cursor(mir_window->surface, NULL); |
10089 | 233 |
} |
234 |
||
8153
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
235 |
return 0; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
236 |
} |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
237 |
|
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
238 |
static void |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
239 |
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
|
240 |
{ |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
241 |
SDL_Unsupported(); |
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 |
|
9807
57b448735f48
SDL_WarpMouseGlobal() should return non-void.
Ryan C. Gordon <icculus@icculus.org>
parents:
9619
diff
changeset
|
244 |
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
|
245 |
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
|
246 |
{ |
9807
57b448735f48
SDL_WarpMouseGlobal() should return non-void.
Ryan C. Gordon <icculus@icculus.org>
parents:
9619
diff
changeset
|
247 |
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
|
248 |
} |
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
|
249 |
|
8153
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
250 |
static int |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
251 |
MIR_SetRelativeMouseMode(SDL_bool enabled) |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
252 |
{ |
10180
7356b2938fba
MIR: Support relative mouse mode
Brandon Schaefer <brandon.schaefer@canonical.com>
parents:
10094
diff
changeset
|
253 |
return 0; |
8153
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
254 |
} |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
255 |
|
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
256 |
/* 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
|
257 |
void |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
258 |
MIR_InitMouse() |
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_Mouse* mouse = SDL_GetMouse(); |
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 |
mouse->CreateCursor = MIR_CreateCursor; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
263 |
mouse->ShowCursor = MIR_ShowCursor; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
264 |
mouse->FreeCursor = MIR_FreeCursor; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
265 |
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
|
266 |
mouse->WarpMouseGlobal = MIR_WarpMouseGlobal; |
8153
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
267 |
mouse->CreateSystemCursor = MIR_CreateSystemCursor; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
268 |
mouse->SetRelativeMouseMode = MIR_SetRelativeMouseMode; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
269 |
|
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
270 |
SDL_SetDefaultCursor(MIR_CreateDefaultCursor()); |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
271 |
} |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
272 |
|
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
273 |
void |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
274 |
MIR_FiniMouse() |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
275 |
{ |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
276 |
SDL_Mouse* mouse = SDL_GetMouse(); |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
277 |
|
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
278 |
MIR_FreeCursor(mouse->def_cursor); |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
279 |
mouse->def_cursor = NULL; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
280 |
|
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
281 |
mouse->CreateCursor = NULL; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
282 |
mouse->ShowCursor = NULL; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
283 |
mouse->FreeCursor = NULL; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
284 |
mouse->WarpMouse = NULL; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
285 |
mouse->CreateSystemCursor = NULL; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
286 |
mouse->SetRelativeMouseMode = NULL; |
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
287 |
} |
8154
ea6b25de67b6
Cleaned up headers and footers on Mir code.
Ryan C. Gordon <icculus@icculus.org>
parents:
8153
diff
changeset
|
288 |
|
ea6b25de67b6
Cleaned up headers and footers on Mir code.
Ryan C. Gordon <icculus@icculus.org>
parents:
8153
diff
changeset
|
289 |
#endif /* SDL_VIDEO_DRIVER_MIR */ |
ea6b25de67b6
Cleaned up headers and footers on Mir code.
Ryan C. Gordon <icculus@icculus.org>
parents:
8153
diff
changeset
|
290 |
|
ea6b25de67b6
Cleaned up headers and footers on Mir code.
Ryan C. Gordon <icculus@icculus.org>
parents:
8153
diff
changeset
|
291 |
/* 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
|
292 |