21 #include "../../SDL_internal.h"
23 #if SDL_VIDEO_DRIVER_X11
25 #include <X11/cursorfont.h>
29 #include "../../events/SDL_mouse_c.h"
33 static Cursor x11_empty_cursor = None;
42 X11_CreateEmptyCursor()
44 if (x11_empty_cursor == None) {
45 Display *display = GetDisplay();
52 pixmap = X11_XCreateBitmapFromData(display, DefaultRootWindow(display),
55 x11_empty_cursor = X11_XCreatePixmapCursor(display,
pixmap,
pixmap,
57 X11_XFreePixmap(display,
pixmap);
60 return x11_empty_cursor;
64 X11_DestroyEmptyCursor(
void)
66 if (x11_empty_cursor != None) {
67 X11_XFreeCursor(GetDisplay(), x11_empty_cursor);
68 x11_empty_cursor = None;
73 X11_CreateDefaultCursor()
88 #if SDL_VIDEO_DRIVER_X11_XCURSOR
92 Display *display = GetDisplay();
109 cursor = X11_XcursorImageLoadCursor(display,
image);
111 X11_XcursorImageDestroy(
image);
120 Display *display = GetDisplay();
124 Uint8 *data_bits, *mask_bits;
125 Pixmap data_pixmap, mask_pixmap;
127 unsigned int rfg, gfg, bfg, rbg, gbg, bbg, fgBits, bgBits;
128 unsigned int width_bytes = ((
surface->w + 7) & ~7) / 8;
146 rfg = gfg = bfg = rbg = gbg = bbg = fgBits = bgBits = 0;
151 int red = (*
ptr >> 16) & 0xff;
155 mask_bits[
y * width_bytes +
x / 8] |= (0x01 << (
x % 8));
162 data_bits[
y * width_bytes +
x / 8] |= (0x01 << (
x % 8));
175 fg.red = rfg * 257 / fgBits;
176 fg.green = gfg * 257 / fgBits;
177 fg.blue = bfg * 257 / fgBits;
179 else fg.red = fg.green = fg.blue = 0;
182 bg.red = rbg * 257 / bgBits;
183 bg.green = gbg * 257 / bgBits;
184 bg.blue = bbg * 257 / bgBits;
186 else bg.red = bg.green = bg.blue = 0;
188 data_pixmap = X11_XCreateBitmapFromData(display, DefaultRootWindow(display),
191 mask_pixmap = X11_XCreateBitmapFromData(display, DefaultRootWindow(display),
194 cursor = X11_XCreatePixmapCursor(display, data_pixmap, mask_pixmap,
195 &fg, &bg,
hot_x, hot_y);
196 X11_XFreePixmap(display, data_pixmap);
197 X11_XFreePixmap(display, mask_pixmap);
209 Cursor x11_cursor = None;
211 #if SDL_VIDEO_DRIVER_X11_XCURSOR
212 if (SDL_X11_HAVE_XCURSOR) {
213 x11_cursor = X11_CreateXCursorCursor(
surface,
hot_x, hot_y);
216 if (x11_cursor == None) {
217 x11_cursor = X11_CreatePixmapCursor(
surface,
hot_x, hot_y);
258 x11_cursor = X11_XCreateFontCursor(GetDisplay(), shape);
273 if (x11_cursor != None) {
274 X11_XFreeCursor(GetDisplay(), x11_cursor);
282 Cursor x11_cursor = 0;
287 x11_cursor = X11_CreateEmptyCursor();
293 Display *display = GetDisplay();
299 if (x11_cursor != None) {
300 X11_XDefineCursor(display,
data->xwindow, x11_cursor);
302 X11_XUndefineCursor(display,
data->xwindow);
311 WarpMouseInternal(Window xwindow,
const int x,
const int y)
314 Display *display = videodata->
display;
315 X11_XWarpPointer(display, None, xwindow, 0, 0, 0, 0,
x,
y);
316 X11_XSync(display, False);
324 WarpMouseInternal(
data->xwindow,
x,
y);
328 X11_WarpMouseGlobal(
int x,
int y)
330 WarpMouseInternal(DefaultRootWindow(GetDisplay()),
x,
y);
337 #if SDL_VIDEO_DRIVER_X11_XINPUT2
349 Display *display = GetDisplay();
353 const unsigned int mask = ButtonPressMask | ButtonReleaseMask | PointerMotionMask | FocusChangeMask;
354 const int rc = X11_XGrabPointer(display,
data->xwindow, False,
355 mask, GrabModeAsync, GrabModeAsync,
356 None, None, CurrentTime);
357 if (rc != GrabSuccess) {
361 X11_XUngrabPointer(display, CurrentTime);
364 X11_XSync(display, False);
370 X11_GetGlobalMouseState(
int *
x,
int *
y)
373 Display *display = GetDisplay();
379 #if !SDL_VIDEO_DRIVER_X11_XINPUT2
386 for (
i = 0;
i < num_screens;
i++) {
390 int rootx, rooty, winx, winy;
392 if (X11_XQueryPointer(display, RootWindow(display,
data->screen), &root, &child, &rootx, &rooty, &winx, &winy, &
mask)) {
393 XWindowAttributes root_attrs;
402 X11_XGetWindowAttributes(display, root, &root_attrs);
442 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
SDL_Mouse * SDL_GetMouse(void)
void SDL_SetDefaultCursor(SDL_Cursor *cursor)
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
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d ®2 endm macro vzip8 reg2 vzip d d ®2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld[DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld if[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
set set set set set set set set set set set set set set set set set set set set *set set set macro pixldst op &r &cond WK op &r &cond WK op &r &cond WK else op &m &cond &ia op &r &cond WK else op &m &cond &ia elseif elseif else error unsupported base if elseif elseif else error unsupported unaligned pixldst unaligned endm macro pixst base base else pixldst base endif endm macro PF ptr
int(* SetRelativeMouseMode)(SDL_bool enabled)
void(* WarpMouse)(SDL_Window *window, int x, int y)
SDL_Cursor *(* CreateCursor)(SDL_Surface *surface, int hot_x, int hot_y)
void(* FreeCursor)(SDL_Cursor *cursor)
int(* ShowCursor)(SDL_Cursor *cursor)
int(* WarpMouseGlobal)(int x, int y)
SDL_Cursor *(* CreateSystemCursor)(SDL_SystemCursor id)
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.