23 #if SDL_VIDEO_DRIVER_X11
25 #include <X11/cursorfont.h>
30 #include "../../events/SDL_mouse_c.h"
34 static Cursor x11_empty_cursor = None;
43 X11_CreateEmptyCursor()
45 if (x11_empty_cursor == None) {
46 Display *
display = GetDisplay();
52 color.red = color.green = color.blue = 0;
57 &color, &color, 0, 0);
58 XFreePixmap(display, pixmap);
61 return x11_empty_cursor;
65 X11_DestroyEmptyCursor(
void)
67 if (x11_empty_cursor != None) {
69 x11_empty_cursor = None;
74 X11_CreateDefaultCursor()
89 #if SDL_VIDEO_DRIVER_X11_XCURSOR
93 Display *display = GetDisplay();
97 image = XcursorImageCreate(surface->
w, surface->
h);
110 cursor = XcursorImageLoadCursor(display, image);
112 XcursorImageDestroy(image);
119 X11_CreatePixmapCursor(
SDL_Surface * surface,
int hot_x,
int hot_y)
121 Display *display = GetDisplay();
123 Cursor cursor = None;
125 Uint8 *data_bits, *mask_bits;
126 Pixmap data_pixmap, mask_pixmap;
128 unsigned int rfg, gfg, bfg, rbg, gbg, bbg, fgBits, bgBits;
129 unsigned int width_bytes = ((surface->
w + 7) & ~7) / 8;
131 data_bits =
SDL_calloc(1, surface->
h * width_bytes);
137 mask_bits =
SDL_calloc(1, surface->
h * width_bytes);
147 rfg = gfg = bfg = rbg = gbg = bbg = fgBits = bgBits = 0;
148 for (y = 0; y < surface->
h; ++
y) {
150 for (x = 0; x < surface->
w; ++
x) {
151 int alpha = (*ptr >> 24) & 0xff;
152 int red = (*ptr >> 16) & 0xff;
153 int green = (*ptr >> 8) & 0xff;
154 int blue = (*ptr >> 0) & 0xff;
156 mask_bits[y * width_bytes + x / 8] |= (0x01 << (x % 8));
158 if ((red + green + blue) > 0x40) {
163 data_bits[y * width_bytes + x / 8] |= (0x01 << (x % 8));
176 fg.red = rfg * 257 / fgBits;
177 fg.green = gfg * 257 / fgBits;
178 fg.blue = bfg * 257 / fgBits;
180 else fg.red = fg.green = fg.blue = 0;
183 bg.red = rbg * 257 / bgBits;
184 bg.green = gbg * 257 / bgBits;
185 bg.blue = bbg * 257 / bgBits;
187 else bg.red = bg.green = bg.blue = 0;
191 surface->
w, surface->
h);
194 surface->
w, surface->
h);
196 &fg, &bg, hot_x, hot_y);
197 XFreePixmap(display, data_pixmap);
198 XFreePixmap(display, mask_pixmap);
204 X11_CreateCursor(
SDL_Surface * surface,
int hot_x,
int hot_y)
210 Cursor x11_cursor = None;
212 #if SDL_VIDEO_DRIVER_X11_XCURSOR
213 if (SDL_X11_HAVE_XCURSOR) {
214 x11_cursor = X11_CreateXCursorCursor(surface, hot_x, hot_y);
217 if (x11_cursor == None) {
218 x11_cursor = X11_CreatePixmapCursor(surface, hot_x, hot_y);
259 x11_cursor = XCreateFontCursor(GetDisplay(), shape);
272 Cursor x11_cursor = (Cursor)cursor->
driverdata;
274 if (x11_cursor != None) {
283 Cursor x11_cursor = 0;
288 x11_cursor = X11_CreateEmptyCursor();
294 Display *display = GetDisplay();
298 for (window = video->
windows; window; window = window->
next) {
300 if (x11_cursor != None) {
312 X11_WarpMouse(
SDL_Window * window,
int x,
int y)
318 XSync(display, False);
324 #if SDL_VIDEO_DRIVER_X11_XINPUT2
351 X11_DestroyEmptyCursor();
SDL_Mouse * SDL_GetMouse(void)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int int int return Display Window Cursor return Display Window return Display Drawable GC int int unsigned int unsigned int return Display Drawable GC int int _Xconst char int return Display Drawable GC int int unsigned int unsigned int return Display return Display Cursor return Display GC return XModifierKeymap return char Display Window int return Display return Display Atom return Display Window XWindowAttributes return Display Window return Display XEvent Bool(*) XPointer return Display Window Bool unsigned int int int Window Cursor Time return Display Window int return KeySym return Display _Xconst char Bool return Display _Xconst char return XKeyEvent char int KeySym XComposeStatus return Display int int int XVisualInfo return Display Window int int return _Xconst char return Display XEvent return Display Drawable GC XImage int int int int unsigned int unsigned int return Display Window Window Window int int int int unsigned int return Display Window Window int int return Display Window unsigned int unsigned int return Display Window Bool long XEvent return Display GC unsigned long return Display Window int Time return Display Window Window return Display Window unsigned long return Display Window XSizeHints Display Colormap XColor int return char int XTextProperty return XFontStruct _Xconst char int int int int XCharStruct return Display Window return Display Time return Display Colormap retur XWarpPointer)
DECLSPEC void *SDLCALL SDL_calloc(size_t nmemb, size_t size)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int int int return Display Window Cursor return Display Window return Display Drawable GC int int unsigned int unsigned int return Display Drawable GC int int _Xconst char int return Display Drawable GC int int unsigned int unsigned int retur XFlush)
GLenum GLsizei const GLuint GLboolean enabled
A collection of pixels used in software blitting.
DECLSPEC void SDLCALL SDL_free(void *mem)
void X11_InitMouse(_THIS)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int int int retur XDefineCursor)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int retur XCreatePixmapCursor)
uint32_t Uint32
An unsigned 32-bit integer type.
void(* FreeCursor)(SDL_Cursor *cursor)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int int int return Display Window Cursor return Display Window return Display Drawable GC int int unsigned int unsigned int return Display Drawable GC int int _Xconst char int return Display Drawable GC int int unsigned int unsigned int return Display return Display Cursor return Display GC return XModifierKeymap return char Display Window int return Display return Display Atom return Display Window XWindowAttributes return Display Window return Display XEvent Bool(*) XPointer return Display Window Bool unsigned int int int Window Cursor Time return Display Window int return KeySym return Display _Xconst char Bool return Display _Xconst char return XKeyEvent char int KeySym XComposeStatus return Display int int int XVisualInfo return Display Window int int return _Xconst char return Display XEvent return Display Drawable GC XImage int int int int unsigned int unsigned int return Display Window Window Window int int int int unsigned int return Display Window Window int int return Display Window unsigned int unsigned int return Display Window Bool long XEvent return Display GC unsigned long return Display Window int Time return Display Window Window return Display Window unsigned long return Display Window XSizeHints Display Colormap XColor int return char int XTextProperty return XFontStruct _Xconst char int int int int XCharStruct retur XUndefineCursor)
SDL_Cursor *(* CreateCursor)(SDL_Surface *surface, int hot_x, int hot_y)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
struct SDL_VideoData * videodata
int(* ShowCursor)(SDL_Cursor *cursor)
SDL_SystemCursor
Cursor types for SDL_CreateSystemCursor.
int(* SetRelativeMouseMode)(SDL_bool enabled)
GLclampf GLclampf GLclampf alpha
void SDL_SetDefaultCursor(SDL_Cursor *cursor)
void X11_QuitMouse(_THIS)
#define SDL_assert(condition)
EGLSurface EGLint EGLint y
#define SDL_OutOfMemory()
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display retur XCreateBitmapFromData)
EGLConfig struct EGLClientPixmapHI * pixmap
DECLSPEC void *SDLCALL SDL_memcpy(void *dst, const void *src, size_t len)
uint8_t Uint8
An unsigned 8-bit integer type.
SDL_VideoDevice * SDL_GetVideoDevice(void)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int int int return Display Window Cursor return Display Window return Display Drawable GC int int unsigned int unsigned int return Display Drawable GC int int _Xconst char int return Display Drawable GC int int unsigned int unsigned int return Display retur XFreeCursor)
#define SDL_Unsupported()
SDL_Cursor *(* CreateSystemCursor)(SDL_SystemCursor id)
void(* WarpMouse)(SDL_Window *window, int x, int y)