21 #include "../../SDL_internal.h" 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;
53 pixmap = X11_XCreateBitmapFromData(display, DefaultRootWindow(display),
56 x11_empty_cursor = X11_XCreatePixmapCursor(display, pixmap, pixmap,
57 &color, &color, 0, 0);
58 X11_XFreePixmap(display, pixmap);
61 return x11_empty_cursor;
65 X11_DestroyEmptyCursor(
void)
67 if (x11_empty_cursor != None) {
68 X11_XFreeCursor(GetDisplay(), x11_empty_cursor);
69 x11_empty_cursor = None;
74 X11_CreateDefaultCursor()
89 #if SDL_VIDEO_DRIVER_X11_XCURSOR 93 Display *display = GetDisplay();
97 image = X11_XcursorImageCreate(surface->
w, surface->
h);
110 cursor = X11_XcursorImageLoadCursor(display, image);
112 X11_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;
189 data_pixmap = X11_XCreateBitmapFromData(display, DefaultRootWindow(display),
191 surface->
w, surface->
h);
192 mask_pixmap = X11_XCreateBitmapFromData(display, DefaultRootWindow(display),
194 surface->
w, surface->
h);
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);
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 = X11_XCreateFontCursor(GetDisplay(), shape);
272 Cursor x11_cursor = (Cursor)cursor->
driverdata;
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();
298 for (window = video->
windows; window; window = window->
next) {
300 if (x11_cursor != None) {
301 X11_XDefineCursor(display, data->
xwindow, x11_cursor);
303 X11_XUndefineCursor(display, data->
xwindow);
312 WarpMouseInternal(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);
322 X11_WarpMouse(
SDL_Window * window,
int x,
int y)
325 WarpMouseInternal(data->
xwindow, x, y);
329 X11_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);
371 X11_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();
SDL_Mouse * SDL_GetMouse(void)
int(* ShowCursor)(SDL_Cursor *cursor)
GLint GLint GLint GLint GLint x
int(* SetRelativeMouseMode)(SDL_bool enabled)
struct wl_display * display
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
A collection of pixels used in software blitting.
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 local skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Uint32(* GetGlobalMouseState)(int *x, int *y)
void X11_InitMouse(_THIS)
SDL_bool global_mouse_changed
GLfloat GLfloat GLfloat alpha
void * SDL_GetDisplayDriverData(int displayIndex)
SDL_Point global_mouse_position
#define SDL_GetNumVideoDisplays
int(* CaptureMouse)(SDL_Window *window)
SDL_Cursor *(* CreateCursor)(SDL_Surface *surface, int hot_x, int hot_y)
EGLConfig struct EGLClientPixmapHI * pixmap
SDL_SystemCursor
Cursor types for SDL_CreateSystemCursor().
GLint GLint GLint GLint GLint GLint y
void SDL_SetDefaultCursor(SDL_Cursor *cursor)
void X11_QuitMouse(_THIS)
int(* WarpMouseGlobal)(int x, int y)
GLenum GLenum GLsizei const GLuint GLboolean enabled
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)
void(* FreeCursor)(SDL_Cursor *cursor)
#define SDL_assert(condition)
#define SDL_OutOfMemory()
EGLSurface EGLNativeWindowType * window
Uint32 global_mouse_buttons
The type used to identify a window.
void(* WarpMouse)(SDL_Window *window, int x, int y)
SDL_VideoDevice * SDL_GetVideoDevice(void)
SDL_Cursor *(* CreateSystemCursor)(SDL_SystemCursor id)
#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