21#include "../../SDL_internal.h"
23#if SDL_VIDEO_DRIVER_X11
25#include <X11/cursorfont.h>
30#include "../../events/SDL_mouse_c.h"
34static Cursor x11_empty_cursor = None;
43X11_CreateEmptyCursor()
45 if (x11_empty_cursor == None) {
46 Display *display = GetDisplay();
53 pixmap = X11_XCreateBitmapFromData(display, DefaultRootWindow(display),
56 x11_empty_cursor = X11_XCreatePixmapCursor(display,
pixmap,
pixmap,
58 X11_XFreePixmap(display,
pixmap);
61 return x11_empty_cursor;
65X11_DestroyEmptyCursor(
void)
67 if (x11_empty_cursor != None) {
68 X11_XFreeCursor(GetDisplay(), x11_empty_cursor);
69 x11_empty_cursor = None;
74X11_CreateDefaultCursor()
89#if SDL_VIDEO_DRIVER_X11_XCURSOR
93 Display *display = GetDisplay();
110 cursor = X11_XcursorImageLoadCursor(display,
image);
112 X11_XcursorImageDestroy(
image);
121 Display *display = GetDisplay();
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;
147 rfg = gfg = bfg = rbg = gbg = bbg = fgBits = bgBits = 0;
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));
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;
189 data_pixmap = X11_XCreateBitmapFromData(display, DefaultRootWindow(display),
192 mask_pixmap = X11_XCreateBitmapFromData(display, DefaultRootWindow(display),
195 cursor = X11_XCreatePixmapCursor(display, data_pixmap, mask_pixmap,
196 &fg, &bg,
hot_x, hot_y);
197 X11_XFreePixmap(display, data_pixmap);
198 X11_XFreePixmap(display, mask_pixmap);
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 = X11_XCreateFontCursor(GetDisplay(), shape);
274 if (x11_cursor != None) {
275 X11_XFreeCursor(GetDisplay(), x11_cursor);
283 Cursor x11_cursor = 0;
288 x11_cursor = X11_CreateEmptyCursor();
294 Display *display = GetDisplay();
300 if (x11_cursor != None) {
301 X11_XDefineCursor(display,
data->xwindow, x11_cursor);
303 X11_XUndefineCursor(display,
data->xwindow);
312WarpMouseInternal(Window xwindow,
const int x,
const int y)
315 Display *display = videodata->
display;
316 X11_XWarpPointer(display, None, xwindow, 0, 0, 0, 0,
x,
y);
317 X11_XSync(display, False);
325 WarpMouseInternal(
data->xwindow,
x,
y);
329X11_WarpMouseGlobal(
int x,
int y)
331 WarpMouseInternal(DefaultRootWindow(GetDisplay()),
x,
y);
338#if SDL_VIDEO_DRIVER_X11_XINPUT2
350 Display *display = GetDisplay();
354 const unsigned int mask = ButtonPressMask | ButtonReleaseMask | PointerMotionMask | FocusChangeMask;
355 const int rc = X11_XGrabPointer(display,
data->xwindow, False,
356 mask, GrabModeAsync, GrabModeAsync,
357 None, None, CurrentTime);
358 if (rc != GrabSuccess) {
362 X11_XUngrabPointer(display, CurrentTime);
365 X11_XSync(display, False);
371X11_GetGlobalMouseState(
int *
x,
int *
y)
374 Display *display = GetDisplay();
380#if !SDL_VIDEO_DRIVER_X11_XINPUT2
387 for (
i = 0;
i < num_screens;
i++) {
391 int rootx, rooty, winx, winy;
393 if (X11_XQueryPointer(display, RootWindow(display,
data->screen), &root, &child, &rootx, &rooty, &winx, &winy, &
mask)) {
394 XWindowAttributes root_attrs;
403 X11_XGetWindowAttributes(display, root, &root_attrs);
443 X11_DestroyEmptyCursor();
#define SDL_assert(condition)
#define SDL_GetNumVideoDisplays
#define SDL_OutOfMemory()
#define SDL_Unsupported()
int uint32_t uint32_t uint32_t uint32_t uint32_t int drmModeModeInfoPtr mode int uint32_t uint32_t uint32_t uint32_t int32_t hot_x
void SDL_SetDefaultCursor(SDL_Cursor *cursor)
SDL_Mouse * SDL_GetMouse(void)
SDL_SystemCursor
Cursor types for SDL_CreateSystemCursor().
@ SDL_SYSTEM_CURSOR_SIZENS
@ SDL_SYSTEM_CURSOR_ARROW
@ SDL_SYSTEM_CURSOR_SIZENWSE
@ SDL_SYSTEM_CURSOR_SIZENESW
@ SDL_SYSTEM_CURSOR_IBEAM
@ SDL_SYSTEM_CURSOR_WAITARROW
@ SDL_SYSTEM_CURSOR_SIZEALL
@ SDL_SYSTEM_CURSOR_SIZEWE
@ SDL_SYSTEM_CURSOR_CROSSHAIR
GLint GLint GLint GLint GLint GLint y
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLint GLint GLint GLint GLint x
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLfloat GLfloat GLfloat alpha
@ SDL_PIXELFORMAT_ARGB8888
void * SDL_GetDisplayDriverData(int displayIndex)
SDL_VideoDevice * SDL_GetVideoDevice(void)
void X11_QuitMouse(_THIS)
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 in i)
EGLSurface EGLNativeWindowType * window
EGLConfig struct EGLClientPixmapHI * pixmap
int(* SetRelativeMouseMode)(SDL_bool enabled)
void(* WarpMouse)(SDL_Window *window, int x, int y)
void(* FreeCursor)(SDL_Cursor *cursor)
int(* ShowCursor)(SDL_Cursor *cursor)
SDL_Cursor *(* CreateSystemCursor)(SDL_SystemCursor id)
int(* WarpMouseGlobal)(int x, int y)
SDL_Cursor *(* CreateCursor)(SDL_Surface *surface, int hot_x, int hot_y)
Uint32(* GetGlobalMouseState)(int *x, int *y)
int(* CaptureMouse)(SDL_Window *window)
A collection of pixels used in software blitting.
Uint32 global_mouse_buttons
struct wl_display * display
SDL_bool global_mouse_changed
SDL_Point global_mouse_position
The type used to identify a window.