src/video/x11/SDL_x11events.c
changeset 7827 a03ec8de0426
parent 7749 6073ad385c9b
child 7838 909b0d7fe4dd
     1.1 --- a/src/video/x11/SDL_x11events.c	Thu Oct 17 20:49:30 2013 -0700
     1.2 +++ b/src/video/x11/SDL_x11events.c	Fri Oct 18 01:36:41 2013 -0400
     1.3 @@ -48,7 +48,7 @@
     1.4  } SDL_x11Prop;
     1.5  
     1.6  /* Reads property
     1.7 -   Must call XFree on results
     1.8 +   Must call X11_XFree on results
     1.9   */
    1.10  static void X11_ReadProperty(SDL_x11Prop *p, Display *disp, Window w, Atom prop)
    1.11  {
    1.12 @@ -60,8 +60,8 @@
    1.13      int bytes_fetch = 0;
    1.14  
    1.15      do {
    1.16 -        if (ret != 0) XFree(ret);
    1.17 -        XGetWindowProperty(disp, w, prop, 0, bytes_fetch, False, AnyPropertyType, &type, &fmt, &count, &bytes_left, &ret);
    1.18 +        if (ret != 0) X11_XFree(ret);
    1.19 +        X11_XGetWindowProperty(disp, w, prop, 0, bytes_fetch, False, AnyPropertyType, &type, &fmt, &count, &bytes_left, &ret);
    1.20          bytes_fetch += bytes_left;
    1.21      } while (bytes_left != 0);
    1.22  
    1.23 @@ -79,9 +79,9 @@
    1.24      char *name;
    1.25      int i;
    1.26      for (i=0; i < list_count && request == None; i++) {
    1.27 -        name = XGetAtomName(disp, list[i]);
    1.28 +        name = X11_XGetAtomName(disp, list[i]);
    1.29          if (strcmp("text/uri-list", name)==0) request = list[i];
    1.30 -        XFree(name);
    1.31 +        X11_XFree(name);
    1.32      }
    1.33      return request;
    1.34  }
    1.35 @@ -125,8 +125,8 @@
    1.36      struct KeyRepeatCheckData d;
    1.37      d.event = event;
    1.38      d.found = SDL_FALSE;
    1.39 -    if (XPending(display))
    1.40 -        XCheckIfEvent(display, &dummyev, X11_KeyRepeatCheckIfEvent,
    1.41 +    if (X11_XPending(display))
    1.42 +        X11_XCheckIfEvent(display, &dummyev, X11_KeyRepeatCheckIfEvent,
    1.43              (XPointer) &d);
    1.44      return d.found;
    1.45  }
    1.46 @@ -147,7 +147,7 @@
    1.47  static SDL_bool X11_IsWheelEvent(Display * display,XEvent * event,int * ticks)
    1.48  {
    1.49      XEvent relevent;
    1.50 -    if (XPending(display)) {
    1.51 +    if (X11_XPending(display)) {
    1.52          /* according to the xlib docs, no specific mouse wheel events exist.
    1.53             however, mouse wheel events trigger a button press and a button release
    1.54             immediately. thus, checking if the same button was released at the same
    1.55 @@ -158,7 +158,7 @@
    1.56               generated (or synthesised) immediately.
    1.57             - False negative: a wheel which, when rolled, doesn't have
    1.58               a release event generated immediately. */
    1.59 -        if (XCheckIfEvent(display, &relevent, X11_IsWheelCheckIfEvent,
    1.60 +        if (X11_XCheckIfEvent(display, &relevent, X11_IsWheelCheckIfEvent,
    1.61              (XPointer) event)) {
    1.62  
    1.63              /* by default, X11 only knows 5 buttons. on most 3 button + wheel mouse,
    1.64 @@ -217,9 +217,9 @@
    1.65  {
    1.66      /* event is a union, so cookie == &event, but this is type safe. */
    1.67      XGenericEventCookie *cookie = &event.xcookie;
    1.68 -    if (XGetEventData(videodata->display, cookie)) {
    1.69 +    if (X11_XGetEventData(videodata->display, cookie)) {
    1.70          X11_HandleXinput2Event(videodata, cookie);
    1.71 -        XFreeEventData(videodata->display, cookie);
    1.72 +        X11_XFreeEventData(videodata->display, cookie);
    1.73      }
    1.74  }
    1.75  #endif /* SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS */
    1.76 @@ -234,7 +234,7 @@
    1.77      SDL_SetKeyboardFocus(data->window);
    1.78  #ifdef X_HAVE_UTF8_STRING
    1.79      if (data->ic) {
    1.80 -        XSetICFocus(data->ic);
    1.81 +        X11_XSetICFocus(data->ic);
    1.82      }
    1.83  #endif
    1.84  }
    1.85 @@ -248,7 +248,7 @@
    1.86      SDL_SetKeyboardFocus(NULL);
    1.87  #ifdef X_HAVE_UTF8_STRING
    1.88      if (data->ic) {
    1.89 -        XUnsetICFocus(data->ic);
    1.90 +        X11_XUnsetICFocus(data->ic);
    1.91      }
    1.92  #endif
    1.93  }
    1.94 @@ -278,11 +278,11 @@
    1.95      XClientMessageEvent m;
    1.96  
    1.97      SDL_zero(xevent);           /* valgrind fix. --ryan. */
    1.98 -    XNextEvent(display, &xevent);
    1.99 +    X11_XNextEvent(display, &xevent);
   1.100  
   1.101      /* filter events catchs XIM events and sends them to the correct
   1.102         handler */
   1.103 -    if (XFilterEvent(&xevent, None) == True) {
   1.104 +    if (X11_XFilterEvent(&xevent, None) == True) {
   1.105  #if 0
   1.106          printf("Filtered event type = %d display = %d window = %d\n",
   1.107                 xevent.type, xevent.xany.display, xevent.xany.window);
   1.108 @@ -451,23 +451,23 @@
   1.109  #if 1
   1.110              if (videodata->key_layout[keycode] == SDL_SCANCODE_UNKNOWN && keycode) {
   1.111                  int min_keycode, max_keycode;
   1.112 -                XDisplayKeycodes(display, &min_keycode, &max_keycode);
   1.113 +                X11_XDisplayKeycodes(display, &min_keycode, &max_keycode);
   1.114  #if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
   1.115 -                keysym = XkbKeycodeToKeysym(display, keycode, 0, 0);
   1.116 +                keysym = X11_XkbKeycodeToKeysym(display, keycode, 0, 0);
   1.117  #else
   1.118                  keysym = XKeycodeToKeysym(display, keycode, 0);
   1.119  #endif
   1.120                  fprintf(stderr,
   1.121                          "The key you just pressed is not recognized by SDL. To help get this fixed, please report this to the SDL mailing list <sdl@libsdl.org> X11 KeyCode %d (%d), X11 KeySym 0x%lX (%s).\n",
   1.122                          keycode, keycode - min_keycode, keysym,
   1.123 -                        XKeysymToString(keysym));
   1.124 +                        X11_XKeysymToString(keysym));
   1.125              }
   1.126  #endif
   1.127              /* */
   1.128              SDL_zero(text);
   1.129  #ifdef X_HAVE_UTF8_STRING
   1.130              if (data->ic) {
   1.131 -                Xutf8LookupString(data->ic, &xevent.xkey, text, sizeof(text),
   1.132 +                X11_Xutf8LookupString(data->ic, &xevent.xkey, text, sizeof(text),
   1.133                                    &keysym, &status);
   1.134              }
   1.135  #else
   1.136 @@ -549,7 +549,7 @@
   1.137                      X11_ReadProperty(&p, display, data->xdnd_source, videodata->XdndTypeList);
   1.138                      /* pick one */
   1.139                      data->xdnd_req = X11_PickTarget(display, (Atom*)p.data, p.count);
   1.140 -                    XFree(p.data);
   1.141 +                    X11_XFree(p.data);
   1.142                  } else {
   1.143                      /* pick from list of three */
   1.144                      data->xdnd_req = X11_PickTargetFromAtoms(display, xevent.xclient.data.l[2], xevent.xclient.data.l[3], xevent.xclient.data.l[4]);
   1.145 @@ -570,8 +570,8 @@
   1.146                  m.data.l[3] = 0;
   1.147                  m.data.l[4] = videodata->XdndActionCopy; /* we only accept copying anyway */
   1.148  
   1.149 -                XSendEvent(display, xevent.xclient.data.l[0], False, NoEventMask, (XEvent*)&m);
   1.150 -                XFlush(display);
   1.151 +                X11_XSendEvent(display, xevent.xclient.data.l[0], False, NoEventMask, (XEvent*)&m);
   1.152 +                X11_XFlush(display);
   1.153              }
   1.154              else if(xevent.xclient.message_type == videodata->XdndDrop) {
   1.155                  if (data->xdnd_req == None) {
   1.156 @@ -585,13 +585,13 @@
   1.157                      m.data.l[0] = data->xwindow;
   1.158                      m.data.l[1] = 0;
   1.159                      m.data.l[2] = None; /* fail! */
   1.160 -                    XSendEvent(display, xevent.xclient.data.l[0], False, NoEventMask, (XEvent*)&m);
   1.161 +                    X11_XSendEvent(display, xevent.xclient.data.l[0], False, NoEventMask, (XEvent*)&m);
   1.162                  } else {
   1.163                      /* convert */
   1.164                      if(xdnd_version >= 1) {
   1.165 -                        XConvertSelection(display, videodata->XdndSelection, data->xdnd_req, videodata->PRIMARY, data->xwindow, xevent.xclient.data.l[2]);
   1.166 +                        X11_XConvertSelection(display, videodata->XdndSelection, data->xdnd_req, videodata->PRIMARY, data->xwindow, xevent.xclient.data.l[2]);
   1.167                      } else {
   1.168 -                        XConvertSelection(display, videodata->XdndSelection, data->xdnd_req, videodata->PRIMARY, data->xwindow, CurrentTime);
   1.169 +                        X11_XConvertSelection(display, videodata->XdndSelection, data->xdnd_req, videodata->PRIMARY, data->xwindow, CurrentTime);
   1.170                      }
   1.171                  }
   1.172              }
   1.173 @@ -604,7 +604,7 @@
   1.174                  printf("window %p: _NET_WM_PING\n", data);
   1.175  #endif
   1.176                  xevent.xclient.window = root;
   1.177 -                XSendEvent(display, root, False, SubstructureRedirectMask | SubstructureNotifyMask, &xevent);
   1.178 +                X11_XSendEvent(display, root, False, SubstructureRedirectMask | SubstructureNotifyMask, &xevent);
   1.179                  break;
   1.180              }
   1.181  
   1.182 @@ -664,13 +664,13 @@
   1.183              Atom real_type;
   1.184              unsigned long items_read, items_left, i;
   1.185  
   1.186 -            char *name = XGetAtomName(display, xevent.xproperty.atom);
   1.187 +            char *name = X11_XGetAtomName(display, xevent.xproperty.atom);
   1.188              if (name) {
   1.189                  printf("window %p: PropertyNotify: %s %s\n", data, name, (xevent.xproperty.state == PropertyDelete) ? "deleted" : "changed");
   1.190 -                XFree(name);
   1.191 +                X11_XFree(name);
   1.192              }
   1.193  
   1.194 -            status = XGetWindowProperty(display, data->xwindow, xevent.xproperty.atom, 0L, 8192L, False, AnyPropertyType, &real_type, &real_format, &items_read, &items_left, &propdata);
   1.195 +            status = X11_XGetWindowProperty(display, data->xwindow, xevent.xproperty.atom, 0L, 8192L, False, AnyPropertyType, &real_type, &real_format, &items_read, &items_left, &propdata);
   1.196              if (status == Success && items_read > 0) {
   1.197                  if (real_type == XA_INTEGER) {
   1.198                      int *values = (int *)propdata;
   1.199 @@ -714,23 +714,23 @@
   1.200  
   1.201                      printf("{");
   1.202                      for (i = 0; i < items_read; i++) {
   1.203 -                        char *name = XGetAtomName(display, atoms[i]);
   1.204 +                        char *name = X11_XGetAtomName(display, atoms[i]);
   1.205                          if (name) {
   1.206                              printf(" %s", name);
   1.207 -                            XFree(name);
   1.208 +                            X11_XFree(name);
   1.209                          }
   1.210                      }
   1.211                      printf(" }\n");
   1.212                  } else {
   1.213 -                    char *name = XGetAtomName(display, real_type);
   1.214 +                    char *name = X11_XGetAtomName(display, real_type);
   1.215                      printf("Unknown type: %ld (%s)\n", real_type, name ? name : "UNKNOWN");
   1.216                      if (name) {
   1.217 -                        XFree(name);
   1.218 +                        X11_XFree(name);
   1.219                      }
   1.220                  }
   1.221              }
   1.222              if (status == Success) {
   1.223 -                XFree(propdata);
   1.224 +                X11_XFree(propdata);
   1.225              }
   1.226  #endif /* DEBUG_XEVENTS */
   1.227  
   1.228 @@ -774,28 +774,28 @@
   1.229              sevent.xselection.property = None;
   1.230              sevent.xselection.requestor = req->requestor;
   1.231              sevent.xselection.time = req->time;
   1.232 -            if (XGetWindowProperty(display, DefaultRootWindow(display),
   1.233 +            if (X11_XGetWindowProperty(display, DefaultRootWindow(display),
   1.234                      XA_CUT_BUFFER0, 0, INT_MAX/4, False, req->target,
   1.235                      &sevent.xselection.target, &seln_format, &nbytes,
   1.236                      &overflow, &seln_data) == Success) {
   1.237 -                Atom XA_TARGETS = XInternAtom(display, "TARGETS", 0);
   1.238 +                Atom XA_TARGETS = X11_XInternAtom(display, "TARGETS", 0);
   1.239                  if (sevent.xselection.target == req->target) {
   1.240 -                    XChangeProperty(display, req->requestor, req->property,
   1.241 +                    X11_XChangeProperty(display, req->requestor, req->property,
   1.242                          sevent.xselection.target, seln_format, PropModeReplace,
   1.243                          seln_data, nbytes);
   1.244                      sevent.xselection.property = req->property;
   1.245                  } else if (XA_TARGETS == req->target) {
   1.246                      Atom SupportedFormats[] = { sevent.xselection.target, XA_TARGETS };
   1.247 -                    XChangeProperty(display, req->requestor, req->property,
   1.248 +                    X11_XChangeProperty(display, req->requestor, req->property,
   1.249                          XA_ATOM, 32, PropModeReplace,
   1.250                          (unsigned char*)SupportedFormats,
   1.251                          sizeof(SupportedFormats)/sizeof(*SupportedFormats));
   1.252                      sevent.xselection.property = req->property;
   1.253                  }
   1.254 -                XFree(seln_data);
   1.255 +                X11_XFree(seln_data);
   1.256              }
   1.257 -            XSendEvent(display, req->requestor, False, 0, &sevent);
   1.258 -            XSync(display, False);
   1.259 +            X11_XSendEvent(display, req->requestor, False, 0, &sevent);
   1.260 +            X11_XSync(display, False);
   1.261          }
   1.262          break;
   1.263  
   1.264 @@ -845,7 +845,7 @@
   1.265                      }
   1.266                  }
   1.267  
   1.268 -                XFree(p.data);
   1.269 +                X11_XFree(p.data);
   1.270  
   1.271                  /* send reply */
   1.272                  SDL_memset(&m, 0, sizeof(XClientMessageEvent));
   1.273 @@ -857,9 +857,9 @@
   1.274                  m.data.l[0] = data->xwindow;
   1.275                  m.data.l[1] = 1;
   1.276                  m.data.l[2] = videodata->XdndActionCopy;
   1.277 -                XSendEvent(display, data->xdnd_source, False, NoEventMask, (XEvent*)&m);
   1.278 +                X11_XSendEvent(display, data->xdnd_source, False, NoEventMask, (XEvent*)&m);
   1.279  
   1.280 -                XSync(display, False);
   1.281 +                X11_XSync(display, False);
   1.282  
   1.283              } else {
   1.284                  videodata->selection_waiting = SDL_FALSE;
   1.285 @@ -899,13 +899,13 @@
   1.286          }
   1.287      }
   1.288  }
   1.289 -/* Ack!  XPending() actually performs a blocking read if no events available */
   1.290 +/* Ack!  X11_XPending() actually performs a blocking read if no events available */
   1.291  static int
   1.292  X11_Pending(Display * display)
   1.293  {
   1.294      /* Flush the display connection and look to see if events are queued */
   1.295 -    XFlush(display);
   1.296 -    if (XEventsQueued(display, QueuedAlready)) {
   1.297 +    X11_XFlush(display);
   1.298 +    if (X11_XEventsQueued(display, QueuedAlready)) {
   1.299          return (1);
   1.300      }
   1.301  
   1.302 @@ -919,7 +919,7 @@
   1.303          FD_ZERO(&fdset);
   1.304          FD_SET(x11_fd, &fdset);
   1.305          if (select(x11_fd + 1, &fdset, NULL, NULL, &zero_time) == 1) {
   1.306 -            return (XPending(display));
   1.307 +            return (X11_XPending(display));
   1.308          }
   1.309      }
   1.310  
   1.311 @@ -942,7 +942,7 @@
   1.312          Uint32 now = SDL_GetTicks();
   1.313          if (!data->screensaver_activity ||
   1.314              (int) (now - data->screensaver_activity) >= 30000) {
   1.315 -            XResetScreenSaver(data->display);
   1.316 +            X11_XResetScreenSaver(data->display);
   1.317  
   1.318              #if SDL_USE_LIBDBUS
   1.319              SDL_dbus_screensaver_tickle(_this);
   1.320 @@ -971,16 +971,16 @@
   1.321      int major_version, minor_version;
   1.322  
   1.323      if (SDL_X11_HAVE_XSS) {
   1.324 -        /* XScreenSaverSuspend was introduced in MIT-SCREEN-SAVER 1.1 */
   1.325 -        if (!XScreenSaverQueryExtension(data->display, &dummy, &dummy) ||
   1.326 -            !XScreenSaverQueryVersion(data->display,
   1.327 +        /* X11_XScreenSaverSuspend was introduced in MIT-SCREEN-SAVER 1.1 */
   1.328 +        if (!X11_XScreenSaverQueryExtension(data->display, &dummy, &dummy) ||
   1.329 +            !X11_XScreenSaverQueryVersion(data->display,
   1.330                                        &major_version, &minor_version) ||
   1.331              major_version < 1 || (major_version == 1 && minor_version < 1)) {
   1.332              return;
   1.333          }
   1.334  
   1.335 -        XScreenSaverSuspend(data->display, _this->suspend_screensaver);
   1.336 -        XResetScreenSaver(data->display);
   1.337 +        X11_XScreenSaverSuspend(data->display, _this->suspend_screensaver);
   1.338 +        X11_XResetScreenSaver(data->display);
   1.339      }
   1.340  #endif
   1.341