21 #include "../../SDL_internal.h" 23 #if SDL_VIDEO_DRIVER_X11 25 #include <sys/types.h> 30 #include <fcitx/frontend.h> 35 #include "../../core/unix/SDL_poll.h" 36 #include "../../events/SDL_events_c.h" 37 #include "../../events/SDL_mouse_c.h" 38 #include "../../events/SDL_touch_c.h" 49 #ifndef _NET_WM_MOVERESIZE_SIZE_TOPLEFT 50 #define _NET_WM_MOVERESIZE_SIZE_TOPLEFT 0 53 #ifndef _NET_WM_MOVERESIZE_SIZE_TOP 54 #define _NET_WM_MOVERESIZE_SIZE_TOP 1 57 #ifndef _NET_WM_MOVERESIZE_SIZE_TOPRIGHT 58 #define _NET_WM_MOVERESIZE_SIZE_TOPRIGHT 2 61 #ifndef _NET_WM_MOVERESIZE_SIZE_RIGHT 62 #define _NET_WM_MOVERESIZE_SIZE_RIGHT 3 65 #ifndef _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT 66 #define _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT 4 69 #ifndef _NET_WM_MOVERESIZE_SIZE_BOTTOM 70 #define _NET_WM_MOVERESIZE_SIZE_BOTTOM 5 73 #ifndef _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT 74 #define _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT 6 77 #ifndef _NET_WM_MOVERESIZE_SIZE_LEFT 78 #define _NET_WM_MOVERESIZE_SIZE_LEFT 7 81 #ifndef _NET_WM_MOVERESIZE_MOVE 82 #define _NET_WM_MOVERESIZE_MOVE 8 94 static void X11_ReadProperty(SDL_x11Prop *
p, Display *disp, Window
w, Atom prop)
96 unsigned char *ret=
NULL;
100 unsigned long bytes_left;
104 if (ret != 0) X11_XFree(ret);
105 X11_XGetWindowProperty(disp, w, prop, 0, bytes_fetch, False, AnyPropertyType, &type, &fmt, &count, &bytes_left, &ret);
106 bytes_fetch += bytes_left;
107 }
while (bytes_left != 0);
117 static Atom X11_PickTarget(Display *disp, Atom list[],
int list_count)
122 for (i=0; i < list_count && request == None; i++) {
123 name = X11_XGetAtomName(disp, list[i]);
134 static Atom X11_PickTargetFromAtoms(Display *disp, Atom a0, Atom a1, Atom a2)
138 if (a0 != None) atom[count++] = a0;
139 if (a1 != None) atom[count++] = a1;
140 if (a2 != None) atom[count++] = a2;
141 return X11_PickTarget(disp, atom, count);
144 struct KeyRepeatCheckData
150 static Bool X11_KeyRepeatCheckIfEvent(Display *display, XEvent *chkev,
153 struct KeyRepeatCheckData *
d = (
struct KeyRepeatCheckData *) arg;
154 if (chkev->type == KeyPress &&
155 chkev->xkey.keycode == d->event->xkey.keycode &&
156 chkev->xkey.time - d->event->xkey.time < 2)
164 static SDL_bool X11_KeyRepeat(Display *display, XEvent *
event)
167 struct KeyRepeatCheckData d;
170 if (X11_XPending(display))
171 X11_XCheckIfEvent(display, &dummyev, X11_KeyRepeatCheckIfEvent,
177 X11_IsWheelEvent(Display * display,XEvent * event,
int * xticks,
int * yticks)
184 switch (event->xbutton.button) {
185 case 4: *yticks = 1;
return SDL_TRUE;
186 case 5: *yticks = -1;
return SDL_TRUE;
187 case 6: *xticks = 1;
return SDL_TRUE;
188 case 7: *xticks = -1;
return SDL_TRUE;
207 static int X11_URIDecode(
char *
buf,
int len) {
210 if (buf ==
NULL || len < 0) {
217 for (ri = 0, wi = 0, di = 0; ri < len && wi <
len; ri += 1) {
220 if (buf[ri] ==
'%') {
229 }
else if (di == 1 || di == 2) {
231 char isa = buf[ri] >=
'a' && buf[ri] <=
'f';
232 char isA = buf[ri] >=
'A' && buf[ri] <=
'F';
233 char isn = buf[ri] >=
'0' && buf[ri] <=
'9';
234 if (!(isa || isA || isn)) {
237 for (sri = ri - di; sri <= ri; sri += 1) {
252 decode |= (buf[ri] + off) << (2 - di) * 4;
270 static char* X11_URIToLocal(
char* uri) {
274 if (memcmp(uri,
"file:/",6) == 0) uri += 6;
275 else if (strstr(uri,
":/") !=
NULL)
return file;
277 local = uri[0] !=
'/' || (uri[0] !=
'\0' && uri[1] ==
'/');
280 if (!local && uri[0] ==
'/' && uri[2] !=
'/') {
281 char* hostname_end = strchr(uri+1,
'/');
282 if (hostname_end !=
NULL) {
283 char hostname[ 257 ];
284 if (gethostname(hostname, 255) == 0) {
285 hostname[ 256 ] =
'\0';
286 if (memcmp(uri+1, hostname, hostname_end - (uri+1)) == 0) {
287 uri = hostname_end + 1;
296 X11_URIDecode(file, 0);
306 #if SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS 307 static void X11_HandleGenericEvent(
SDL_VideoData *videodata, XEvent *xev)
311 if (X11_XGetEventData(videodata->
display, cookie)) {
313 X11_XFreeEventData(videodata->
display, cookie);
319 X11_GetNumLockModifierMask(
_THIS)
322 Display *display = viddata->
display;
323 unsigned num_mask = 0;
325 XModifierKeymap *xmods;
328 xmods = X11_XGetModifierMapping(display);
329 n = xmods->max_keypermod;
330 for(i = 3; i < 8; i++) {
331 for(
j = 0;
j <
n;
j++) {
332 KeyCode kc = xmods->modifiermap[i * n +
j];
339 X11_XFreeModifiermap(xmods);
345 X11_ReconcileKeyboardState(
_THIS)
348 Display *display = viddata->
display;
354 const Uint8 *keyboardState;
356 X11_XQueryKeymap(display, keys);
359 if (X11_XQueryPointer(display, DefaultRootWindow(display), &junk_window, &junk_window, &x, &
y, &x, &
y, &
mask)) {
365 for (keycode = 0; keycode < 256; ++keycode) {
367 SDL_bool x11KeyPressed = (keys[keycode / 8] & (1 << (keycode % 8))) != 0;
370 if (x11KeyPressed && !sdlKeyPressed) {
372 }
else if (!x11KeyPressed && sdlKeyPressed) {
383 printf(
"window %p: Dispatching FocusIn\n", data);
386 X11_ReconcileKeyboardState(
_this);
387 #ifdef X_HAVE_UTF8_STRING 389 X11_XSetICFocus(data->
ic);
401 printf(
"window %p: Dispatching FocusOut\n", data);
410 #ifdef X_HAVE_UTF8_STRING 412 X11_XUnsetICFocus(data->
ic);
439 Display *display = viddata->
display;
443 X11_XUngrabPointer(display, 0L);
446 evt.xclient.type = ClientMessage;
447 evt.xclient.window = data->
xwindow;
448 evt.xclient.message_type = X11_XInternAtom(display,
"_NET_WM_MOVERESIZE", True);
449 evt.xclient.format = 32;
450 evt.xclient.data.l[0] =
window->x + point->
x;
451 evt.xclient.data.l[1] =
window->y + point->
y;
452 evt.xclient.data.l[2] = _NET_WM_MOVERESIZE_MOVE;
453 evt.xclient.data.l[3] = Button1;
454 evt.xclient.data.l[4] = 0;
455 X11_XSendEvent(display, DefaultRootWindow(display), False, SubstructureRedirectMask | SubstructureNotifyMask, &evt);
457 X11_XSync(display, 0);
465 Display *display = viddata->
display;
468 if (direction < _NET_WM_MOVERESIZE_SIZE_TOPLEFT || direction > _NET_WM_MOVERESIZE_SIZE_LEFT)
472 X11_XUngrabPointer(display, 0L);
475 evt.xclient.type = ClientMessage;
476 evt.xclient.window = data->
xwindow;
477 evt.xclient.message_type = X11_XInternAtom(display,
"_NET_WM_MOVERESIZE", True);
478 evt.xclient.format = 32;
479 evt.xclient.data.l[0] =
window->x + point->
x;
480 evt.xclient.data.l[1] =
window->y + point->
y;
481 evt.xclient.data.l[2] = direction;
482 evt.xclient.data.l[3] = Button1;
483 evt.xclient.data.l[4] = 0;
484 X11_XSendEvent(display, DefaultRootWindow(display), False, SubstructureRedirectMask | SubstructureNotifyMask, &evt);
486 X11_XSync(display, 0);
495 const SDL_Point point = { xev->xbutton.
x, xev->xbutton.y };
497 static const int directions[] = {
498 _NET_WM_MOVERESIZE_SIZE_TOPLEFT, _NET_WM_MOVERESIZE_SIZE_TOP,
499 _NET_WM_MOVERESIZE_SIZE_TOPRIGHT, _NET_WM_MOVERESIZE_SIZE_RIGHT,
500 _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT, _NET_WM_MOVERESIZE_SIZE_BOTTOM,
501 _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT, _NET_WM_MOVERESIZE_SIZE_LEFT
506 InitiateWindowMove(
_this, data, &point);
528 X11_UpdateUserTime(
SDL_WindowData *data,
const unsigned long latest)
530 if (latest && (latest != data->
user_time)) {
532 Display *display = videodata->
display;
534 XA_CARDINAL, 32, PropModeReplace,
535 (
const unsigned char *) &latest, 1);
537 printf(
"window %p: updating _NET_WM_USER_TIME to %lu\n", data, latest);
544 X11_HandleClipboardEvent(
_THIS,
const XEvent *xevent)
547 Display *display = videodata->
display;
552 switch (xevent->type) {
554 case SelectionRequest: {
555 const XSelectionRequestEvent *req = &xevent->xselectionrequest;
558 unsigned long nbytes;
559 unsigned long overflow;
560 unsigned char *seln_data;
563 printf(
"window CLIPBOARD: SelectionRequest (requestor = %ld, target = %ld)\n",
564 req->requestor, req->target);
568 sevent.xany.type = SelectionNotify;
569 sevent.xselection.selection = req->selection;
570 sevent.xselection.target = None;
571 sevent.xselection.property = None;
572 sevent.xselection.requestor = req->requestor;
573 sevent.xselection.time = req->time;
578 if (X11_XGetWindowProperty(display, DefaultRootWindow(display),
580 &sevent.xselection.target, &seln_format, &nbytes,
581 &overflow, &seln_data) == Success) {
583 Atom XA_TARGETS = X11_XInternAtom(display,
"TARGETS", 0);
584 if (sevent.xselection.target == req->target) {
585 X11_XChangeProperty(display, req->requestor, req->property,
586 sevent.xselection.target, seln_format, PropModeReplace,
588 sevent.xselection.property = req->property;
589 }
else if (XA_TARGETS == req->target) {
590 Atom SupportedFormats[] = { XA_TARGETS, sevent.xselection.target };
591 X11_XChangeProperty(display, req->requestor, req->property,
592 XA_ATOM, 32, PropModeReplace,
593 (
unsigned char*)SupportedFormats,
595 sevent.xselection.property = req->property;
596 sevent.xselection.target = XA_TARGETS;
598 X11_XFree(seln_data);
600 X11_XSendEvent(display, req->requestor, False, 0, &sevent);
601 X11_XSync(display, False);
605 case SelectionNotify: {
607 printf(
"window CLIPBOARD: SelectionNotify (requestor = %ld, target = %ld)\n",
608 xevent->xselection.requestor, xevent->xselection.target);
614 case SelectionClear: {
616 Atom XA_CLIPBOARD = X11_XInternAtom(display,
"CLIPBOARD", 0);
619 printf(
"window CLIPBOARD: SelectionClear (requestor = %ld, target = %ld)\n",
620 xevent->xselection.requestor, xevent->xselection.target);
623 if (xevent->xselectionclear.selection == XA_PRIMARY ||
624 (XA_CLIPBOARD != None && xevent->xselectionclear.selection == XA_CLIPBOARD)) {
634 X11_DispatchEvent(
_THIS)
641 KeyCode orig_keycode;
642 XClientMessageEvent
m;
651 X11_XNextEvent(display, &xevent);
656 orig_event_type = xevent.type;
657 if (orig_event_type == KeyPress || orig_event_type == KeyRelease) {
658 orig_keycode = xevent.xkey.keycode;
664 if (X11_XFilterEvent(&xevent, None) == True) {
666 printf(
"Filtered event type = %d display = %d window = %d\n",
667 xevent.type, xevent.xany.display, xevent.xany.window);
673 #if defined(HAVE_IBUS_IBUS_H) || defined(HAVE_FCITX_FRONTEND_H) 678 if (orig_event_type == KeyPress) {
694 wmmsg.
msg.
x11.event = xevent;
698 #if SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS 699 if(xevent.type == GenericEvent) {
700 X11_HandleGenericEvent(videodata, &xevent);
706 printf(
"type = %d display = %d window = %d\n",
707 xevent.type, xevent.xany.display, xevent.xany.window);
712 X11_HandleClipboardEvent(
_this, &xevent);
728 if (xevent.type == KeymapNotify) {
732 }
else if (xevent.type == MappingNotify) {
734 const int request = xevent.xmapping.request;
737 printf(
"window %p: MappingNotify!\n", data);
739 if ((request == MappingKeyboard) || (request == MappingModifier)) {
740 X11_XRefreshKeyboardMapping(&xevent.xmapping);
749 switch (xevent.type) {
755 printf(
"window %p: EnterNotify! (%d,%d,%d)\n", data,
758 xevent.xcrossing.mode);
759 if (xevent.xcrossing.mode == NotifyGrab)
760 printf(
"Mode: NotifyGrab\n");
761 if (xevent.xcrossing.mode == NotifyUngrab)
762 printf(
"Mode: NotifyUngrab\n");
766 mouse->
last_x = xevent.xcrossing.x;
767 mouse->
last_y = xevent.xcrossing.y;
777 printf(
"window %p: LeaveNotify! (%d,%d,%d)\n", data,
780 xevent.xcrossing.mode);
781 if (xevent.xcrossing.mode == NotifyGrab)
782 printf(
"Mode: NotifyGrab\n");
783 if (xevent.xcrossing.mode == NotifyUngrab)
784 printf(
"Mode: NotifyUngrab\n");
790 if (xevent.xcrossing.mode != NotifyGrab &&
791 xevent.xcrossing.mode != NotifyUngrab &&
792 xevent.xcrossing.detail != NotifyInferior) {
800 if (xevent.xfocus.mode == NotifyGrab || xevent.xfocus.mode == NotifyUngrab) {
803 printf(
"window %p: FocusIn (NotifyGrab/NotifyUngrab, ignoring)\n", data);
808 if (xevent.xfocus.detail == NotifyInferior) {
810 printf(
"window %p: FocusIn (NotifierInferior, ignoring)\n", data);
815 printf(
"window %p: FocusIn!\n", data);
821 X11_DispatchFocusIn(
_this, data);
834 if (xevent.xfocus.mode == NotifyGrab || xevent.xfocus.mode == NotifyUngrab) {
837 printf(
"window %p: FocusOut (NotifyGrab/NotifyUngrab, ignoring)\n", data);
841 if (xevent.xfocus.detail == NotifyInferior) {
844 printf(
"window %p: FocusOut (NotifierInferior, ignoring)\n", data);
849 printf(
"window %p: FocusOut!\n", data);
855 X11_DispatchFocusOut(
_this, data);
867 KeyCode keycode = xevent.xkey.keycode;
868 KeySym keysym = NoSymbol;
874 printf(
"window %p: KeyPress (X11 keycode = 0x%X)\n", data, xevent.xkey.keycode);
878 int min_keycode, max_keycode;
879 X11_XDisplayKeycodes(display, &min_keycode, &max_keycode);
882 "The key you just pressed is not recognized by SDL. To help get this fixed, please report this to the SDL forums/mailing list <https://discourse.libsdl.org/> X11 KeyCode %d (%d), X11 KeySym 0x%lX (%s).\n",
883 keycode, keycode - min_keycode, keysym,
884 X11_XKeysymToString(keysym));
889 #ifdef X_HAVE_UTF8_STRING 891 X11_Xutf8LookupString(data->
ic, &xevent.xkey, text,
sizeof(text),
894 X11_XLookupString(&xevent.xkey, text,
sizeof(text), &keysym,
NULL);
897 X11_XLookupString(&xevent.xkey, text,
sizeof(text), &keysym,
NULL);
905 if (!handled_by_ime) {
915 X11_UpdateUserTime(data, xevent.xkey.time);
921 KeyCode keycode = xevent.xkey.keycode;
922 KeySym keysym = NoSymbol;
927 printf(
"window %p: KeyRelease (X11 keycode = 0x%X)\n", data, xevent.xkey.keycode);
931 int min_keycode, max_keycode;
932 X11_XDisplayKeycodes(display, &min_keycode, &max_keycode);
935 "The key you just pressed is not recognized by SDL. To help get this fixed, please report this to the SDL forums/mailing list <https://discourse.libsdl.org/> X11 KeyCode %d (%d), X11 KeySym 0x%lX (%s).\n",
936 keycode, keycode - min_keycode, keysym,
937 X11_XKeysymToString(keysym));
942 X11_XLookupString(&xevent.xkey, text,
sizeof(text), &keysym,
NULL);
949 if (X11_KeyRepeat(display, &xevent)) {
960 printf(
"window %p: UnmapNotify!\n", data);
962 X11_DispatchUnmapNotify(data);
969 printf(
"window %p: MapNotify!\n", data);
971 X11_DispatchMapNotify(data);
976 case ConfigureNotify:{
978 printf(
"window %p: ConfigureNotify! (position: %d,%d, size: %dx%d)\n", data,
979 xevent.xconfigure.x, xevent.xconfigure.y,
980 xevent.xconfigure.width, xevent.xconfigure.height);
983 if (!xevent.xconfigure.send_event) {
984 unsigned int NumChildren;
985 Window ChildReturn, Root, Parent;
988 X11_XQueryTree(data->
videodata->
display, xevent.xconfigure.window, &Root, &Parent, &Children, &NumChildren);
989 X11_XTranslateCoordinates(xevent.xconfigure.display,
990 Parent, DefaultRootWindow(xevent.xconfigure.display),
991 xevent.xconfigure.x, xevent.xconfigure.y,
992 &xevent.xconfigure.x, &xevent.xconfigure.y,
999 xevent.xconfigure.x, xevent.xconfigure.y);
1010 xevent.xconfigure.width,
1011 xevent.xconfigure.height);
1018 case ClientMessage:{
1020 static int xdnd_version=0;
1022 if (xevent.xclient.message_type == videodata->
XdndEnter) {
1024 SDL_bool use_list = xevent.xclient.data.l[1] & 1;
1026 xdnd_version = (xevent.xclient.data.l[1] >> 24);
1027 #ifdef DEBUG_XEVENTS 1028 printf(
"XID of source window : %ld\n", data->
xdnd_source);
1029 printf(
"Protocol version to use : %d\n", xdnd_version);
1030 printf(
"More then 3 data types : %d\n", (
int) use_list);
1038 data->
xdnd_req = X11_PickTarget(display, (Atom*)p.data, p.count);
1042 data->
xdnd_req = X11_PickTargetFromAtoms(display, xevent.xclient.data.l[2], xevent.xclient.data.l[3], xevent.xclient.data.l[4]);
1045 else if (xevent.xclient.message_type == videodata->
XdndPosition) {
1047 #ifdef DEBUG_XEVENTS 1049 if(xdnd_version >= 2) {
1050 act = xevent.xclient.data.l[4];
1052 printf(
"Action requested by user is : %s\n", X11_XGetAtomName(display , act));
1057 memset(&
m, 0,
sizeof(XClientMessageEvent));
1058 m.type = ClientMessage;
1059 m.display = xevent.xclient.display;
1060 m.window = xevent.xclient.data.l[0];
1069 X11_XSendEvent(display, xevent.xclient.data.l[0], False, NoEventMask, (XEvent*)&
m);
1070 X11_XFlush(display);
1072 else if(xevent.xclient.message_type == videodata->
XdndDrop) {
1075 memset(&
m, 0,
sizeof(XClientMessageEvent));
1076 m.type = ClientMessage;
1077 m.display = xevent.xclient.display;
1078 m.window = xevent.xclient.data.l[0];
1084 X11_XSendEvent(display, xevent.xclient.data.l[0], False, NoEventMask, (XEvent*)&
m);
1087 if(xdnd_version >= 1) {
1094 else if ((xevent.xclient.message_type == videodata->
WM_PROTOCOLS) &&
1095 (xevent.xclient.format == 32) &&
1096 (xevent.xclient.data.l[0] == videodata->
_NET_WM_PING)) {
1097 Window root = DefaultRootWindow(display);
1099 #ifdef DEBUG_XEVENTS 1100 printf(
"window %p: _NET_WM_PING\n", data);
1102 xevent.xclient.window = root;
1103 X11_XSendEvent(display, root, False, SubstructureRedirectMask | SubstructureNotifyMask, &xevent);
1107 else if ((xevent.xclient.message_type == videodata->
WM_PROTOCOLS) &&
1108 (xevent.xclient.format == 32) &&
1111 #ifdef DEBUG_XEVENTS 1112 printf(
"window %p: WM_DELETE_WINDOW\n", data);
1117 else if ((xevent.xclient.message_type == videodata->
WM_PROTOCOLS) &&
1118 (xevent.xclient.format == 32) &&
1121 #ifdef DEBUG_XEVENTS 1122 printf(
"window %p: WM_TAKE_FOCUS\n", data);
1132 #ifdef DEBUG_XEVENTS 1133 printf(
"window %p: Expose (count = %d)\n", data, xevent.xexpose.count);
1143 printf(
"window %p: X11 motion: %d,%d\n", data, xevent.xmotion.x, xevent.xmotion.y);
1152 int xticks = 0, yticks = 0;
1153 #ifdef DEBUG_XEVENTS 1154 printf(
"window %p: ButtonPress (X11 button = %d)\n", data, xevent.xbutton.button);
1156 if (X11_IsWheelEvent(display,&xevent,&xticks, &yticks)) {
1160 int button = xevent.xbutton.button;
1161 if(button == Button1) {
1162 if (ProcessHitTest(
_this, data, &xevent)) {
1167 else if(button > 7) {
1173 const int X11_FOCUS_CLICK_TIMEOUT = 10;
1179 if (!ignore_click) {
1183 X11_UpdateUserTime(data, xevent.xbutton.time);
1187 case ButtonRelease:{
1188 int button = xevent.xbutton.button;
1190 int xticks = 0, yticks = 0;
1191 #ifdef DEBUG_XEVENTS 1192 printf(
"window %p: ButtonRelease (X11 button = %d)\n", data, xevent.xbutton.button);
1194 if (!X11_IsWheelEvent(display, &xevent, &xticks, &yticks)) {
1204 case PropertyNotify:{
1205 #ifdef DEBUG_XEVENTS 1206 unsigned char *propdata;
1207 int status, real_format;
1209 unsigned long items_read, items_left;
1211 char *name = X11_XGetAtomName(display, xevent.xproperty.atom);
1213 printf(
"window %p: PropertyNotify: %s %s time=%lu\n", data, name, (xevent.xproperty.state == PropertyDelete) ?
"deleted" :
"changed", xevent.xproperty.time);
1217 status = X11_XGetWindowProperty(display, data->
xwindow, xevent.xproperty.atom, 0L, 8192L, False, AnyPropertyType, &real_type, &real_format, &items_read, &items_left, &propdata);
1218 if (status == Success && items_read > 0) {
1219 if (real_type == XA_INTEGER) {
1220 int *
values = (
int *)propdata;
1223 for (i = 0; i < items_read; i++) {
1224 printf(
" %d", values[i]);
1227 }
else if (real_type == XA_CARDINAL) {
1228 if (real_format == 32) {
1232 for (i = 0; i < items_read; i++) {
1233 printf(
" %d", values[i]);
1236 }
else if (real_format == 16) {
1240 for (i = 0; i < items_read; i++) {
1241 printf(
" %d", values[i]);
1244 }
else if (real_format == 8) {
1248 for (i = 0; i < items_read; i++) {
1249 printf(
" %d", values[i]);
1253 }
else if (real_type == XA_STRING ||
1255 printf(
"{ \"%s\" }\n", propdata);
1256 }
else if (real_type == XA_ATOM) {
1257 Atom *atoms = (Atom *)propdata;
1260 for (i = 0; i < items_read; i++) {
1261 char *atomname = X11_XGetAtomName(display, atoms[i]);
1263 printf(
" %s", atomname);
1264 X11_XFree(atomname);
1269 char *atomname = X11_XGetAtomName(display, real_type);
1270 printf(
"Unknown type: %ld (%s)\n", real_type, atomname ? atomname :
"UNKNOWN");
1272 X11_XFree(atomname);
1276 if (status == Success) {
1277 X11_XFree(propdata);
1289 data->
user_time = xevent.xproperty.time;
1302 if (flags & SDL_WINDOW_HIDDEN) {
1303 X11_DispatchUnmapNotify(data);
1305 X11_DispatchMapNotify(data);
1310 if (flags & SDL_WINDOW_MAXIMIZED) {
1328 unsigned long nitems, bytes_after;
1329 unsigned char *property;
1330 if (X11_XGetWindowProperty(display, data->
xwindow, videodata->
_NET_FRAME_EXTENTS, 0, 16, 0, XA_CARDINAL, &type, &format, &nitems, &bytes_after, &property) == Success) {
1331 if (type != None && nitems == 4) {
1334 data->
border_top = (int) ((
long*)property)[2];
1337 X11_XFree(property);
1339 #ifdef DEBUG_XEVENTS 1347 case SelectionNotify: {
1348 Atom
target = xevent.xselection.target;
1349 #ifdef DEBUG_XEVENTS 1350 printf(
"window %p: SelectionNotify (requestor = %ld, target = %ld)\n", data,
1351 xevent.xselection.requestor, xevent.xselection.target);
1356 X11_ReadProperty(&p, display, data->
xwindow, videodata->
PRIMARY);
1358 if (p.format == 8) {
1360 char* name = X11_XGetAtomName(display, target);
1361 char *token = strtok((
char *) p.data,
"\r\n");
1362 while (token !=
NULL) {
1365 }
else if (
SDL_strcmp(
"text/uri-list", name)==0) {
1366 char *fn = X11_URIToLocal(token);
1371 token = strtok(
NULL,
"\r\n");
1379 m.type = ClientMessage;
1380 m.display = display;
1387 X11_XSendEvent(display, data->
xdnd_source, False, NoEventMask, (XEvent*)&
m);
1389 X11_XSync(display, False);
1395 #ifdef DEBUG_XEVENTS 1396 printf(
"window %p: Unhandled event %d\n", data, xevent.type);
1404 X11_HandleFocusChanges(
_THIS)
1416 X11_DispatchFocusIn(
_this, data);
1418 X11_DispatchFocusOut(
_this, data);
1428 X11_Pending(Display * display)
1431 X11_XFlush(display);
1432 if (X11_XEventsQueued(display, QueuedAlready)) {
1438 return (X11_XPending(display));
1461 X11_XResetScreenSaver(data->
display);
1464 SDL_DBus_ScreensaverTickle();
1472 while (X11_Pending(data->
display)) {
1473 X11_DispatchEvent(
_this);
1483 X11_HandleFocusChanges(
_this);
1490 #if SDL_VIDEO_DRIVER_X11_XSCRNSAVER 1493 int major_version, minor_version;
1502 SDL_DBus_ScreensaverTickle();
1506 #if SDL_VIDEO_DRIVER_X11_XSCRNSAVER 1507 if (SDL_X11_HAVE_XSS) {
1509 if (!X11_XScreenSaverQueryExtension(data->
display, &dummy, &dummy) ||
1510 !X11_XScreenSaverQueryVersion(data->
display,
1511 &major_version, &minor_version) ||
1512 major_version < 1 || (major_version == 1 && minor_version < 1)) {
1517 X11_XResetScreenSaver(data->
display);
void SDL_IME_SetFocus(SDL_bool focused)
void X11_PumpEvents(_THIS)
SDL_Mouse * SDL_GetMouse(void)
int SDL_IOReady(int fd, SDL_bool forWrite, int timeoutMS)
void SDL_SetKeyboardFocus(SDL_Window *window)
Uint32 X11_GetNetWMState(_THIS, Window xwindow)
GLint GLint GLint GLint GLint x
SDL_bool relative_mode_warp
GLuint GLuint GLsizei count
int SDL_SendDropFile(SDL_Window *window, const char *file)
struct wl_display * display
The structure that defines a point.
void SDL_IME_UpdateTextRect(SDL_Rect *rect)
SDL_WindowData ** windowlist
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
int SDL_SendWindowEvent(SDL_Window *window, Uint8 windowevent, int data1, int data2)
void SDL_SetMouseFocus(SDL_Window *window)
#define SDL_GetKeyboardFocus
union SDL_SysWMmsg::@16 msg
SDL_bool selection_waiting
int SDL_SendDropComplete(SDL_Window *window)
int SDL_SendSysWMEvent(SDL_SysWMmsg *message)
GLuint const GLchar * name
int SDL_SendKeyboardKey(Uint8 state, SDL_Scancode scancode)
#define SDL_GetHintBoolean
#define SDL_VERSION(x)
Macro to determine SDL version program was compiled against.
static SDL_VideoDevice * _this
SDL_HitTestResult
Possible return values from the SDL_HitTest callback.
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
GLenum GLsizei GLsizei GLint * values
Uint32 screensaver_activity
Uint32 pending_focus_time
int SDL_SendDropText(SDL_Window *window, const char *text)
#define SDL_GetEventState(type)
#define SDL_GetKeyboardState
void X11_SuspendScreenSaver(_THIS)
KeySym X11_KeyCodeToSym(_THIS, KeyCode, unsigned char group)
int SDL_SendMouseMotion(SDL_Window *window, SDL_MouseID mouseID, int relative, int x, int y)
Uint32 SDL_GetTicks(void)
Get the number of milliseconds since the SDL library initialization.
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 ** d
struct SDL_VideoData * videodata
int SDL_SendClipboardUpdate(void)
int SDL_SendKeyboardText(const char *text)
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 in j)
GLubyte GLubyte GLubyte GLubyte w
GLint GLint GLint GLint GLint GLint y
void X11_UpdateKeymap(_THIS)
GLenum GLuint GLenum GLsizei const GLchar * buf
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 SDL_IME_PumpEvents()
void SDL_ToggleModState(const SDL_Keymod modstate, const SDL_bool toggle)
#define SDL_assert(condition)
int SDL_SendMouseWheel(SDL_Window *window, SDL_MouseID mouseID, float x, float y, SDL_MouseWheelDirection direction)
Atom X11_GetSDLCutBufferClipboardType(Display *display)
static char text[MAX_TEXT_LENGTH]
struct SDL_SysWMmsg::@16::@17 x11
int SDL_SendKeymapChangedEvent(void)
EGLSurface EGLNativeWindowType * window
#define PENDING_FOCUS_TIME
The type used to identify a window.
XConfigureEvent last_xconfigure
GLuint GLuint GLsizei GLenum type
SDL_bool suspend_screensaver
#define SDL_arraysize(array)
Uint32 last_focus_event_time
#define SDL_TEXTINPUTEVENT_TEXT_SIZE
Uint32 last_mode_change_deadline
#define SDL_TICKS_PASSED(A, B)
Compare SDL ticks values, and return true if A has passed B.
#define SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH
Allow mouse click events when clicking to focus an SDL window.
PendingFocusEnum pending_focus
int SDL_SendMouseButton(SDL_Window *window, SDL_MouseID mouseID, Uint8 state, Uint8 button)
SDL_Scancode
The SDL keyboard scancode representation.
SDL_bool SDL_IME_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint32 itype)