src/video/x11/SDL_x11events.c
branchSDL-1.3
changeset 1668 4da1ee79c9af
parent 1662 782fd950bd46
     1.1 --- a/src/video/x11/SDL_x11events.c	Mon May 29 03:53:21 2006 +0000
     1.2 +++ b/src/video/x11/SDL_x11events.c	Mon May 29 04:04:35 2006 +0000
     1.3 @@ -55,12 +55,12 @@
     1.4  /* The translation tables from an X11 keysym to a SDL keysym */
     1.5  static SDLKey ODD_keymap[256];
     1.6  static SDLKey MISC_keymap[256];
     1.7 -SDLKey X11_TranslateKeycode (Display * display, KeyCode kc);
     1.8 +SDLKey X11_TranslateKeycode(Display * display, KeyCode kc);
     1.9  
    1.10  
    1.11  #ifdef X_HAVE_UTF8_STRING
    1.12  Uint32
    1.13 -Utf8ToUcs4 (const Uint8 * utf8)
    1.14 +Utf8ToUcs4(const Uint8 * utf8)
    1.15  {
    1.16      Uint32 c;
    1.17      int i = 1;
    1.18 @@ -184,19 +184,19 @@
    1.19     (idea shamelessly lifted from GII -- thanks guys! :)
    1.20   */
    1.21  static int
    1.22 -X11_KeyRepeat (Display * display, XEvent * event)
    1.23 +X11_KeyRepeat(Display * display, XEvent * event)
    1.24  {
    1.25      XEvent peekevent;
    1.26      int repeated;
    1.27  
    1.28      repeated = 0;
    1.29 -    if (XPending (display)) {
    1.30 -        XPeekEvent (display, &peekevent);
    1.31 +    if (XPending(display)) {
    1.32 +        XPeekEvent(display, &peekevent);
    1.33          if ((peekevent.type == KeyPress) &&
    1.34              (peekevent.xkey.keycode == event->xkey.keycode) &&
    1.35              ((peekevent.xkey.time - event->xkey.time) < 2)) {
    1.36              repeated = 1;
    1.37 -            XNextEvent (display, &peekevent);
    1.38 +            XNextEvent(display, &peekevent);
    1.39          }
    1.40      }
    1.41      return (repeated);
    1.42 @@ -210,7 +210,7 @@
    1.43  #define MOUSE_FUDGE_FACTOR	8
    1.44  
    1.45  static __inline__ int
    1.46 -X11_WarpedMotion (_THIS, XEvent * xevent)
    1.47 +X11_WarpedMotion(_THIS, XEvent * xevent)
    1.48  {
    1.49      int w, h, i;
    1.50      int deltax, deltay;
    1.51 @@ -221,33 +221,33 @@
    1.52      deltax = xevent->xmotion.x - mouse_last.x;
    1.53      deltay = xevent->xmotion.y - mouse_last.y;
    1.54  #ifdef DEBUG_MOTION
    1.55 -    printf ("Warped mouse motion: %d,%d\n", deltax, deltay);
    1.56 +    printf("Warped mouse motion: %d,%d\n", deltax, deltay);
    1.57  #endif
    1.58      mouse_last.x = xevent->xmotion.x;
    1.59      mouse_last.y = xevent->xmotion.y;
    1.60 -    posted = SDL_PrivateMouseMotion (0, 1, deltax, deltay);
    1.61 +    posted = SDL_PrivateMouseMotion(0, 1, deltax, deltay);
    1.62  
    1.63      if ((xevent->xmotion.x < MOUSE_FUDGE_FACTOR) ||
    1.64          (xevent->xmotion.x > (w - MOUSE_FUDGE_FACTOR)) ||
    1.65          (xevent->xmotion.y < MOUSE_FUDGE_FACTOR) ||
    1.66          (xevent->xmotion.y > (h - MOUSE_FUDGE_FACTOR))) {
    1.67          /* Get the events that have accumulated */
    1.68 -        while (XCheckTypedEvent (SDL_Display, MotionNotify, xevent)) {
    1.69 +        while (XCheckTypedEvent(SDL_Display, MotionNotify, xevent)) {
    1.70              deltax = xevent->xmotion.x - mouse_last.x;
    1.71              deltay = xevent->xmotion.y - mouse_last.y;
    1.72  #ifdef DEBUG_MOTION
    1.73 -            printf ("Extra mouse motion: %d,%d\n", deltax, deltay);
    1.74 +            printf("Extra mouse motion: %d,%d\n", deltax, deltay);
    1.75  #endif
    1.76              mouse_last.x = xevent->xmotion.x;
    1.77              mouse_last.y = xevent->xmotion.y;
    1.78 -            posted += SDL_PrivateMouseMotion (0, 1, deltax, deltay);
    1.79 +            posted += SDL_PrivateMouseMotion(0, 1, deltax, deltay);
    1.80          }
    1.81          mouse_last.x = w / 2;
    1.82          mouse_last.y = h / 2;
    1.83 -        XWarpPointer (SDL_Display, None, SDL_Window, 0, 0, 0, 0,
    1.84 -                      mouse_last.x, mouse_last.y);
    1.85 +        XWarpPointer(SDL_Display, None, SDL_Window, 0, 0, 0, 0,
    1.86 +                     mouse_last.x, mouse_last.y);
    1.87          for (i = 0; i < 10; ++i) {
    1.88 -            XMaskEvent (SDL_Display, PointerMotionMask, xevent);
    1.89 +            XMaskEvent(SDL_Display, PointerMotionMask, xevent);
    1.90              if ((xevent->xmotion.x >
    1.91                   (mouse_last.x - MOUSE_FUDGE_FACTOR)) &&
    1.92                  (xevent->xmotion.x <
    1.93 @@ -258,13 +258,13 @@
    1.94                  break;
    1.95              }
    1.96  #ifdef DEBUG_XEVENTS
    1.97 -            printf ("Lost mouse motion: %d,%d\n", xevent->xmotion.x,
    1.98 -                    xevent->xmotion.y);
    1.99 +            printf("Lost mouse motion: %d,%d\n", xevent->xmotion.x,
   1.100 +                   xevent->xmotion.y);
   1.101  #endif
   1.102          }
   1.103  #ifdef DEBUG_XEVENTS
   1.104          if (i == 10) {
   1.105 -            printf ("Warning: didn't detect mouse warp motion\n");
   1.106 +            printf("Warning: didn't detect mouse warp motion\n");
   1.107          }
   1.108  #endif
   1.109      }
   1.110 @@ -272,13 +272,13 @@
   1.111  }
   1.112  
   1.113  static int
   1.114 -X11_DispatchEvent (_THIS)
   1.115 +X11_DispatchEvent(_THIS)
   1.116  {
   1.117      int posted;
   1.118      XEvent xevent;
   1.119  
   1.120 -    SDL_memset (&xevent, '\0', sizeof (XEvent));        /* valgrind fix. --ryan. */
   1.121 -    XNextEvent (SDL_Display, &xevent);
   1.122 +    SDL_memset(&xevent, '\0', sizeof(XEvent));  /* valgrind fix. --ryan. */
   1.123 +    XNextEvent(SDL_Display, &xevent);
   1.124  
   1.125      posted = 0;
   1.126      switch (xevent.type) {
   1.127 @@ -287,21 +287,21 @@
   1.128      case EnterNotify:
   1.129          {
   1.130  #ifdef DEBUG_XEVENTS
   1.131 -            printf ("EnterNotify! (%d,%d)\n", xevent.xcrossing.x,
   1.132 -                    xevent.xcrossing.y);
   1.133 +            printf("EnterNotify! (%d,%d)\n", xevent.xcrossing.x,
   1.134 +                   xevent.xcrossing.y);
   1.135              if (xevent.xcrossing.mode == NotifyGrab)
   1.136 -                printf ("Mode: NotifyGrab\n");
   1.137 +                printf("Mode: NotifyGrab\n");
   1.138              if (xevent.xcrossing.mode == NotifyUngrab)
   1.139 -                printf ("Mode: NotifyUngrab\n");
   1.140 +                printf("Mode: NotifyUngrab\n");
   1.141  #endif
   1.142              if ((xevent.xcrossing.mode != NotifyGrab) &&
   1.143                  (xevent.xcrossing.mode != NotifyUngrab)) {
   1.144                  if (SDL_CurrentWindow.input_grab == SDL_GRAB_OFF) {
   1.145 -                    posted = SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS);
   1.146 +                    posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
   1.147                  }
   1.148 -                posted = SDL_PrivateMouseMotion (0, 0,
   1.149 -                                                 xevent.xcrossing.x,
   1.150 -                                                 xevent.xcrossing.y);
   1.151 +                posted = SDL_PrivateMouseMotion(0, 0,
   1.152 +                                                xevent.xcrossing.x,
   1.153 +                                                xevent.xcrossing.y);
   1.154              }
   1.155          }
   1.156          break;
   1.157 @@ -310,22 +310,22 @@
   1.158      case LeaveNotify:
   1.159          {
   1.160  #ifdef DEBUG_XEVENTS
   1.161 -            printf ("LeaveNotify! (%d,%d)\n", xevent.xcrossing.x,
   1.162 -                    xevent.xcrossing.y);
   1.163 +            printf("LeaveNotify! (%d,%d)\n", xevent.xcrossing.x,
   1.164 +                   xevent.xcrossing.y);
   1.165              if (xevent.xcrossing.mode == NotifyGrab)
   1.166 -                printf ("Mode: NotifyGrab\n");
   1.167 +                printf("Mode: NotifyGrab\n");
   1.168              if (xevent.xcrossing.mode == NotifyUngrab)
   1.169 -                printf ("Mode: NotifyUngrab\n");
   1.170 +                printf("Mode: NotifyUngrab\n");
   1.171  #endif
   1.172              if ((xevent.xcrossing.mode != NotifyGrab) &&
   1.173                  (xevent.xcrossing.mode != NotifyUngrab) &&
   1.174                  (xevent.xcrossing.detail != NotifyInferior)) {
   1.175                  if (SDL_CurrentWindow.input_grab == SDL_GRAB_OFF) {
   1.176 -                    posted = SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS);
   1.177 +                    posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
   1.178                  } else {
   1.179 -                    posted = SDL_PrivateMouseMotion (0, 0,
   1.180 -                                                     xevent.xcrossing.x,
   1.181 -                                                     xevent.xcrossing.y);
   1.182 +                    posted = SDL_PrivateMouseMotion(0, 0,
   1.183 +                                                    xevent.xcrossing.x,
   1.184 +                                                    xevent.xcrossing.y);
   1.185                  }
   1.186              }
   1.187          }
   1.188 @@ -335,18 +335,18 @@
   1.189      case FocusIn:
   1.190          {
   1.191  #ifdef DEBUG_XEVENTS
   1.192 -            printf ("FocusIn!\n");
   1.193 +            printf("FocusIn!\n");
   1.194  #endif
   1.195 -            posted = SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS);
   1.196 +            posted = SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS);
   1.197  
   1.198  #ifdef X_HAVE_UTF8_STRING
   1.199              if (SDL_IC != NULL) {
   1.200 -                XSetICFocus (SDL_IC);
   1.201 +                XSetICFocus(SDL_IC);
   1.202              }
   1.203  #endif
   1.204              /* Queue entry into fullscreen mode */
   1.205              switch_waiting = 0x01 | SDL_FULLSCREEN;
   1.206 -            switch_time = SDL_GetTicks () + 1500;
   1.207 +            switch_time = SDL_GetTicks() + 1500;
   1.208          }
   1.209          break;
   1.210  
   1.211 @@ -354,18 +354,18 @@
   1.212      case FocusOut:
   1.213          {
   1.214  #ifdef DEBUG_XEVENTS
   1.215 -            printf ("FocusOut!\n");
   1.216 +            printf("FocusOut!\n");
   1.217  #endif
   1.218 -            posted = SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS);
   1.219 +            posted = SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS);
   1.220  
   1.221  #ifdef X_HAVE_UTF8_STRING
   1.222              if (SDL_IC != NULL) {
   1.223 -                XUnsetICFocus (SDL_IC);
   1.224 +                XUnsetICFocus(SDL_IC);
   1.225              }
   1.226  #endif
   1.227              /* Queue leaving fullscreen mode */
   1.228              switch_waiting = 0x01;
   1.229 -            switch_time = SDL_GetTicks () + 200;
   1.230 +            switch_time = SDL_GetTicks() + 200;
   1.231          }
   1.232          break;
   1.233  
   1.234 @@ -373,9 +373,9 @@
   1.235      case KeymapNotify:
   1.236          {
   1.237  #ifdef DEBUG_XEVENTS
   1.238 -            printf ("KeymapNotify!\n");
   1.239 +            printf("KeymapNotify!\n");
   1.240  #endif
   1.241 -            X11_SetKeyboardState (SDL_Display, xevent.xkeymap.key_vector);
   1.242 +            X11_SetKeyboardState(SDL_Display, xevent.xkeymap.key_vector);
   1.243          }
   1.244          break;
   1.245  
   1.246 @@ -386,26 +386,26 @@
   1.247                  if (mouse_relative) {
   1.248                      if (using_dga & DGA_MOUSE) {
   1.249  #ifdef DEBUG_MOTION
   1.250 -                        printf ("DGA motion: %d,%d\n",
   1.251 -                                xevent.xmotion.x_root, xevent.xmotion.y_root);
   1.252 +                        printf("DGA motion: %d,%d\n",
   1.253 +                               xevent.xmotion.x_root, xevent.xmotion.y_root);
   1.254  #endif
   1.255 -                        posted = SDL_PrivateMouseMotion (0, 1,
   1.256 -                                                         xevent.
   1.257 -                                                         xmotion.
   1.258 -                                                         x_root,
   1.259 -                                                         xevent.
   1.260 -                                                         xmotion.y_root);
   1.261 +                        posted = SDL_PrivateMouseMotion(0, 1,
   1.262 +                                                        xevent.
   1.263 +                                                        xmotion.
   1.264 +                                                        x_root,
   1.265 +                                                        xevent.
   1.266 +                                                        xmotion.y_root);
   1.267                      } else {
   1.268 -                        posted = X11_WarpedMotion (_this, &xevent);
   1.269 +                        posted = X11_WarpedMotion(_this, &xevent);
   1.270                      }
   1.271                  } else {
   1.272  #ifdef DEBUG_MOTION
   1.273 -                    printf ("X11 motion: %d,%d\n", xevent.xmotion.x,
   1.274 -                            xevent.xmotion.y);
   1.275 +                    printf("X11 motion: %d,%d\n", xevent.xmotion.x,
   1.276 +                           xevent.xmotion.y);
   1.277  #endif
   1.278 -                    posted = SDL_PrivateMouseMotion (0, 0,
   1.279 -                                                     xevent.xmotion.x,
   1.280 -                                                     xevent.xmotion.y);
   1.281 +                    posted = SDL_PrivateMouseMotion(0, 0,
   1.282 +                                                    xevent.xmotion.x,
   1.283 +                                                    xevent.xmotion.y);
   1.284                  }
   1.285              }
   1.286          }
   1.287 @@ -414,16 +414,16 @@
   1.288          /* Mouse button press? */
   1.289      case ButtonPress:
   1.290          {
   1.291 -            posted = SDL_PrivateMouseButton (SDL_PRESSED,
   1.292 -                                             xevent.xbutton.button, 0, 0);
   1.293 +            posted = SDL_PrivateMouseButton(SDL_PRESSED,
   1.294 +                                            xevent.xbutton.button, 0, 0);
   1.295          }
   1.296          break;
   1.297  
   1.298          /* Mouse button release? */
   1.299      case ButtonRelease:
   1.300          {
   1.301 -            posted = SDL_PrivateMouseButton (SDL_RELEASED,
   1.302 -                                             xevent.xbutton.button, 0, 0);
   1.303 +            posted = SDL_PrivateMouseButton(SDL_RELEASED,
   1.304 +                                            xevent.xbutton.button, 0, 0);
   1.305          }
   1.306          break;
   1.307  
   1.308 @@ -435,12 +435,12 @@
   1.309              KeyCode keycode = xevent.xkey.keycode;
   1.310  
   1.311  #ifdef DEBUG_XEVENTS
   1.312 -            printf ("KeyPress (X11 keycode = 0x%X)\n", xevent.xkey.keycode);
   1.313 +            printf("KeyPress (X11 keycode = 0x%X)\n", xevent.xkey.keycode);
   1.314  #endif
   1.315              /* Get the translated SDL virtual keysym */
   1.316              if (keycode) {
   1.317                  keysym.scancode = keycode;
   1.318 -                keysym.sym = X11_TranslateKeycode (SDL_Display, keycode);
   1.319 +                keysym.sym = X11_TranslateKeycode(SDL_Display, keycode);
   1.320                  keysym.mod = KMOD_NONE;
   1.321                  keysym.unicode = 0;
   1.322              } else {
   1.323 @@ -449,13 +449,13 @@
   1.324  
   1.325              /* If we're not doing translation, we're done! */
   1.326              if (!SDL_TranslateUNICODE) {
   1.327 -                posted = SDL_PrivateKeyboard (SDL_PRESSED, &keysym);
   1.328 +                posted = SDL_PrivateKeyboard(SDL_PRESSED, &keysym);
   1.329                  break;
   1.330              }
   1.331  
   1.332 -            if (XFilterEvent (&xevent, None)) {
   1.333 +            if (XFilterEvent(&xevent, None)) {
   1.334                  if (xevent.xkey.keycode) {
   1.335 -                    posted = SDL_PrivateKeyboard (SDL_PRESSED, &keysym);
   1.336 +                    posted = SDL_PrivateKeyboard(SDL_PRESSED, &keysym);
   1.337                  } else {
   1.338                      /* Save event to be associated with IM text
   1.339                         In 1.3 we'll have a text event instead.. */
   1.340 @@ -470,10 +470,9 @@
   1.341                  static Status state;
   1.342                  /* A UTF-8 character can be at most 6 bytes */
   1.343                  char keybuf[6];
   1.344 -                if (Xutf8LookupString (SDL_IC, &xevent.xkey,
   1.345 -                                       keybuf, sizeof (keybuf),
   1.346 -                                       NULL, &state)) {
   1.347 -                    keysym.unicode = Utf8ToUcs4 ((Uint8 *) keybuf);
   1.348 +                if (Xutf8LookupString(SDL_IC, &xevent.xkey,
   1.349 +                                      keybuf, sizeof(keybuf), NULL, &state)) {
   1.350 +                    keysym.unicode = Utf8ToUcs4((Uint8 *) keybuf);
   1.351                  }
   1.352              } else
   1.353  #endif
   1.354 @@ -481,8 +480,8 @@
   1.355                  static XComposeStatus state;
   1.356                  char keybuf[32];
   1.357  
   1.358 -                if (XLookupString (&xevent.xkey,
   1.359 -                                   keybuf, sizeof (keybuf), NULL, &state)) {
   1.360 +                if (XLookupString(&xevent.xkey,
   1.361 +                                  keybuf, sizeof(keybuf), NULL, &state)) {
   1.362                      /*
   1.363                       * FIXME: XLookupString() may yield more than one
   1.364                       * character, so we need a mechanism to allow for
   1.365 @@ -492,7 +491,7 @@
   1.366                      keysym.unicode = (Uint8) keybuf[0];
   1.367                  }
   1.368              }
   1.369 -            posted = SDL_PrivateKeyboard (SDL_PRESSED, &keysym);
   1.370 +            posted = SDL_PrivateKeyboard(SDL_PRESSED, &keysym);
   1.371          }
   1.372          break;
   1.373  
   1.374 @@ -503,20 +502,20 @@
   1.375              KeyCode keycode = xevent.xkey.keycode;
   1.376  
   1.377  #ifdef DEBUG_XEVENTS
   1.378 -            printf ("KeyRelease (X11 keycode = 0x%X)\n", xevent.xkey.keycode);
   1.379 +            printf("KeyRelease (X11 keycode = 0x%X)\n", xevent.xkey.keycode);
   1.380  #endif
   1.381              /* Check to see if this is a repeated key */
   1.382 -            if (X11_KeyRepeat (SDL_Display, &xevent)) {
   1.383 +            if (X11_KeyRepeat(SDL_Display, &xevent)) {
   1.384                  break;
   1.385              }
   1.386  
   1.387              /* Get the translated SDL virtual keysym */
   1.388              keysym.scancode = keycode;
   1.389 -            keysym.sym = X11_TranslateKeycode (SDL_Display, keycode);
   1.390 +            keysym.sym = X11_TranslateKeycode(SDL_Display, keycode);
   1.391              keysym.mod = KMOD_NONE;
   1.392              keysym.unicode = 0;
   1.393  
   1.394 -            posted = SDL_PrivateKeyboard (SDL_RELEASED, &keysym);
   1.395 +            posted = SDL_PrivateKeyboard(SDL_RELEASED, &keysym);
   1.396          }
   1.397          break;
   1.398  
   1.399 @@ -524,17 +523,17 @@
   1.400      case UnmapNotify:
   1.401          {
   1.402  #ifdef DEBUG_XEVENTS
   1.403 -            printf ("UnmapNotify!\n");
   1.404 +            printf("UnmapNotify!\n");
   1.405  #endif
   1.406              /* If we're active, make ourselves inactive */
   1.407 -            if (SDL_GetAppState () & SDL_APPACTIVE) {
   1.408 +            if (SDL_GetAppState() & SDL_APPACTIVE) {
   1.409                  /* Swap out the gamma before we go inactive */
   1.410 -                X11_SwapVidModeGamma (_this);
   1.411 +                X11_SwapVidModeGamma(_this);
   1.412  
   1.413                  /* Send an internal deactivate event */
   1.414 -                posted = SDL_PrivateAppActive (0,
   1.415 -                                               SDL_APPACTIVE |
   1.416 -                                               SDL_APPINPUTFOCUS);
   1.417 +                posted = SDL_PrivateAppActive(0,
   1.418 +                                              SDL_APPACTIVE |
   1.419 +                                              SDL_APPINPUTFOCUS);
   1.420              }
   1.421          }
   1.422          break;
   1.423 @@ -543,27 +542,27 @@
   1.424      case MapNotify:
   1.425          {
   1.426  #ifdef DEBUG_XEVENTS
   1.427 -            printf ("MapNotify!\n");
   1.428 +            printf("MapNotify!\n");
   1.429  #endif
   1.430              /* If we're not active, make ourselves active */
   1.431 -            if (!(SDL_GetAppState () & SDL_APPACTIVE)) {
   1.432 +            if (!(SDL_GetAppState() & SDL_APPACTIVE)) {
   1.433                  /* Send an internal activate event */
   1.434 -                posted = SDL_PrivateAppActive (1, SDL_APPACTIVE);
   1.435 +                posted = SDL_PrivateAppActive(1, SDL_APPACTIVE);
   1.436  
   1.437                  /* Now that we're active, swap the gamma back */
   1.438 -                X11_SwapVidModeGamma (_this);
   1.439 +                X11_SwapVidModeGamma(_this);
   1.440              }
   1.441  
   1.442              if (SDL_VideoSurface &&
   1.443                  (SDL_VideoSurface->flags & SDL_FULLSCREEN)) {
   1.444 -                X11_EnterFullScreen (_this);
   1.445 +                X11_EnterFullScreen(_this);
   1.446              } else {
   1.447 -                X11_GrabInputNoLock (_this, SDL_CurrentWindow.input_grab);
   1.448 +                X11_GrabInputNoLock(_this, SDL_CurrentWindow.input_grab);
   1.449              }
   1.450 -            X11_CheckMouseModeNoLock (_this);
   1.451 +            X11_CheckMouseModeNoLock(_this);
   1.452  
   1.453              if (SDL_VideoSurface) {
   1.454 -                X11_RefreshDisplay (_this);
   1.455 +                X11_RefreshDisplay(_this);
   1.456              }
   1.457          }
   1.458          break;
   1.459 @@ -572,8 +571,8 @@
   1.460      case ConfigureNotify:
   1.461          {
   1.462  #ifdef DEBUG_XEVENTS
   1.463 -            printf ("ConfigureNotify! (resize: %dx%d)\n",
   1.464 -                    xevent.xconfigure.width, xevent.xconfigure.height);
   1.465 +            printf("ConfigureNotify! (resize: %dx%d)\n",
   1.466 +                   xevent.xconfigure.width, xevent.xconfigure.height);
   1.467  #endif
   1.468              if (SDL_VideoSurface) {
   1.469                  if ((xevent.xconfigure.width != SDL_VideoSurface->w) ||
   1.470 @@ -581,13 +580,13 @@
   1.471                      /* FIXME: Find a better fix for the bug with KDE 1.2 */
   1.472                      if (!((xevent.xconfigure.width == 32) &&
   1.473                            (xevent.xconfigure.height == 32))) {
   1.474 -                        SDL_PrivateResize (xevent.xconfigure.width,
   1.475 -                                           xevent.xconfigure.height);
   1.476 +                        SDL_PrivateResize(xevent.xconfigure.width,
   1.477 +                                          xevent.xconfigure.height);
   1.478                      }
   1.479                  } else {
   1.480                      /* OpenGL windows need to know about the change */
   1.481                      if (SDL_VideoSurface->flags & SDL_INTERNALOPENGL) {
   1.482 -                        SDL_PrivateExpose ();
   1.483 +                        SDL_PrivateExpose();
   1.484                      }
   1.485                  }
   1.486              }
   1.487 @@ -599,14 +598,14 @@
   1.488          {
   1.489              if ((xevent.xclient.format == 32) &&
   1.490                  (xevent.xclient.data.l[0] == WM_DELETE_WINDOW)) {
   1.491 -                posted = SDL_PrivateQuit ();
   1.492 +                posted = SDL_PrivateQuit();
   1.493              } else if (SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE) {
   1.494                  SDL_SysWMmsg wmmsg;
   1.495  
   1.496 -                SDL_VERSION (&wmmsg.version);
   1.497 +                SDL_VERSION(&wmmsg.version);
   1.498                  wmmsg.subsystem = SDL_SYSWM_X11;
   1.499                  wmmsg.event.xevent = xevent;
   1.500 -                posted = SDL_PrivateSysWMEvent (&wmmsg);
   1.501 +                posted = SDL_PrivateSysWMEvent(&wmmsg);
   1.502              }
   1.503          }
   1.504          break;
   1.505 @@ -615,10 +614,10 @@
   1.506      case Expose:
   1.507          {
   1.508  #ifdef DEBUG_XEVENTS
   1.509 -            printf ("Expose (count = %d)\n", xevent.xexpose.count);
   1.510 +            printf("Expose (count = %d)\n", xevent.xexpose.count);
   1.511  #endif
   1.512              if (SDL_VideoSurface && (xevent.xexpose.count == 0)) {
   1.513 -                X11_RefreshDisplay (_this);
   1.514 +                X11_RefreshDisplay(_this);
   1.515              }
   1.516          }
   1.517          break;
   1.518 @@ -626,16 +625,16 @@
   1.519      default:
   1.520          {
   1.521  #ifdef DEBUG_XEVENTS
   1.522 -            printf ("Unhandled event %d\n", xevent.type);
   1.523 +            printf("Unhandled event %d\n", xevent.type);
   1.524  #endif
   1.525              /* Only post the event if we're watching for it */
   1.526              if (SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE) {
   1.527                  SDL_SysWMmsg wmmsg;
   1.528  
   1.529 -                SDL_VERSION (&wmmsg.version);
   1.530 +                SDL_VERSION(&wmmsg.version);
   1.531                  wmmsg.subsystem = SDL_SYSWM_X11;
   1.532                  wmmsg.event.xevent = xevent;
   1.533 -                posted = SDL_PrivateSysWMEvent (&wmmsg);
   1.534 +                posted = SDL_PrivateSysWMEvent(&wmmsg);
   1.535              }
   1.536          }
   1.537          break;
   1.538 @@ -645,11 +644,11 @@
   1.539  
   1.540  /* Ack!  XPending() actually performs a blocking read if no events available */
   1.541  int
   1.542 -X11_Pending (Display * display)
   1.543 +X11_Pending(Display * display)
   1.544  {
   1.545      /* Flush the display connection and look to see if events are queued */
   1.546 -    XFlush (display);
   1.547 -    if (XEventsQueued (display, QueuedAlready)) {
   1.548 +    XFlush(display);
   1.549 +    if (XEventsQueued(display, QueuedAlready)) {
   1.550          return (1);
   1.551      }
   1.552  
   1.553 @@ -659,11 +658,11 @@
   1.554          int x11_fd;
   1.555          fd_set fdset;
   1.556  
   1.557 -        x11_fd = ConnectionNumber (display);
   1.558 -        FD_ZERO (&fdset);
   1.559 -        FD_SET (x11_fd, &fdset);
   1.560 -        if (select (x11_fd + 1, &fdset, NULL, NULL, &zero_time) == 1) {
   1.561 -            return (XPending (display));
   1.562 +        x11_fd = ConnectionNumber(display);
   1.563 +        FD_ZERO(&fdset);
   1.564 +        FD_SET(x11_fd, &fdset);
   1.565 +        if (select(x11_fd + 1, &fdset, NULL, NULL, &zero_time) == 1) {
   1.566 +            return (XPending(display));
   1.567          }
   1.568      }
   1.569  
   1.570 @@ -672,20 +671,20 @@
   1.571  }
   1.572  
   1.573  void
   1.574 -X11_PumpEvents (_THIS)
   1.575 +X11_PumpEvents(_THIS)
   1.576  {
   1.577      int pending;
   1.578  
   1.579      /* Keep processing pending events */
   1.580      pending = 0;
   1.581 -    while (X11_Pending (SDL_Display)) {
   1.582 -        X11_DispatchEvent (_this);
   1.583 +    while (X11_Pending(SDL_Display)) {
   1.584 +        X11_DispatchEvent(_this);
   1.585          ++pending;
   1.586      }
   1.587      if (switch_waiting) {
   1.588          Uint32 now;
   1.589  
   1.590 -        now = SDL_GetTicks ();
   1.591 +        now = SDL_GetTicks();
   1.592          if (pending || !SDL_VideoSurface) {
   1.593              /* Try again later... */
   1.594              if (switch_waiting & SDL_FULLSCREEN) {
   1.595 @@ -700,29 +699,29 @@
   1.596              switch_waiting = 0;
   1.597              if (SDL_VideoSurface->flags & SDL_FULLSCREEN) {
   1.598                  if (go_fullscreen) {
   1.599 -                    X11_EnterFullScreen (_this);
   1.600 +                    X11_EnterFullScreen(_this);
   1.601                  } else {
   1.602 -                    X11_LeaveFullScreen (_this);
   1.603 +                    X11_LeaveFullScreen(_this);
   1.604                  }
   1.605              }
   1.606              /* Handle focus in/out when grabbed */
   1.607              if (go_fullscreen) {
   1.608 -                X11_GrabInputNoLock (_this, SDL_CurrentWindow.input_grab);
   1.609 +                X11_GrabInputNoLock(_this, SDL_CurrentWindow.input_grab);
   1.610              } else {
   1.611 -                X11_GrabInputNoLock (_this, SDL_GRAB_OFF);
   1.612 +                X11_GrabInputNoLock(_this, SDL_GRAB_OFF);
   1.613              }
   1.614 -            X11_CheckMouseModeNoLock (_this);
   1.615 +            X11_CheckMouseModeNoLock(_this);
   1.616          }
   1.617      }
   1.618  }
   1.619  
   1.620  void
   1.621 -X11_InitKeymap (void)
   1.622 +X11_InitKeymap(void)
   1.623  {
   1.624      int i;
   1.625  
   1.626      /* Odd keys used in international keyboards */
   1.627 -    for (i = 0; i < SDL_arraysize (ODD_keymap); ++i)
   1.628 +    for (i = 0; i < SDL_arraysize(ODD_keymap); ++i)
   1.629          ODD_keymap[i] = SDLK_UNKNOWN;
   1.630  
   1.631      /* Some of these might be mappable to an existing SDLK_ code */
   1.632 @@ -758,7 +757,7 @@
   1.633  #endif
   1.634  
   1.635      /* Map the miscellaneous keys */
   1.636 -    for (i = 0; i < SDL_arraysize (MISC_keymap); ++i)
   1.637 +    for (i = 0; i < SDL_arraysize(MISC_keymap); ++i)
   1.638          MISC_keymap[i] = SDLK_UNKNOWN;
   1.639  
   1.640      /* These X keysyms have 0xFF as the high byte */
   1.641 @@ -851,14 +850,14 @@
   1.642  
   1.643  /* Get the translated SDL virtual keysym */
   1.644  SDLKey
   1.645 -X11_TranslateKeycode (Display * display, KeyCode kc)
   1.646 +X11_TranslateKeycode(Display * display, KeyCode kc)
   1.647  {
   1.648      KeySym xsym;
   1.649      SDLKey key;
   1.650  
   1.651 -    xsym = XKeycodeToKeysym (display, kc, 0);
   1.652 +    xsym = XKeycodeToKeysym(display, kc, 0);
   1.653  #ifdef DEBUG_KEYS
   1.654 -    fprintf (stderr, "Translating key code %d -> 0x%.4x\n", kc, xsym);
   1.655 +    fprintf(stderr, "Translating key code %d -> 0x%.4x\n", kc, xsym);
   1.656  #endif
   1.657      key = SDLK_UNKNOWN;
   1.658      if (xsym) {
   1.659 @@ -934,7 +933,7 @@
   1.660  static unsigned num_mask, mode_switch_mask;
   1.661  
   1.662  static void
   1.663 -get_modifier_masks (Display * display)
   1.664 +get_modifier_masks(Display * display)
   1.665  {
   1.666      static unsigned got_masks;
   1.667      int i, j;
   1.668 @@ -944,12 +943,12 @@
   1.669      if (got_masks)
   1.670          return;
   1.671  
   1.672 -    xmods = XGetModifierMapping (display);
   1.673 +    xmods = XGetModifierMapping(display);
   1.674      n = xmods->max_keypermod;
   1.675      for (i = 3; i < 8; i++) {
   1.676          for (j = 0; j < n; j++) {
   1.677              KeyCode kc = xmods->modifiermap[i * n + j];
   1.678 -            KeySym ks = XKeycodeToKeysym (display, kc, 0);
   1.679 +            KeySym ks = XKeycodeToKeysym(display, kc, 0);
   1.680              unsigned mask = 1 << i;
   1.681              switch (ks) {
   1.682              case XK_Num_Lock:
   1.683 @@ -973,7 +972,7 @@
   1.684              }
   1.685          }
   1.686      }
   1.687 -    XFreeModifiermap (xmods);
   1.688 +    XFreeModifiermap(xmods);
   1.689      got_masks = 1;
   1.690  }
   1.691  
   1.692 @@ -989,9 +988,9 @@
   1.693   * state has been irrevocably lost.
   1.694   */
   1.695  Uint16
   1.696 -X11_KeyToUnicode (SDLKey keysym, SDLMod modifiers)
   1.697 +X11_KeyToUnicode(SDLKey keysym, SDLMod modifiers)
   1.698  {
   1.699 -    SDL_VideoDevice *_this = SDL_GetVideoDevice ();
   1.700 +    SDL_VideoDevice *_this = SDL_GetVideoDevice();
   1.701      char keybuf[32];
   1.702      int i;
   1.703      KeySym xsym = 0;
   1.704 @@ -1002,7 +1001,7 @@
   1.705          return 0;
   1.706      }
   1.707  
   1.708 -    SDL_memset (&xkey, 0, sizeof (xkey));
   1.709 +    SDL_memset(&xkey, 0, sizeof(xkey));
   1.710      xkey.display = SDL_Display;
   1.711  
   1.712      xsym = keysym;              /* last resort if not found */
   1.713 @@ -1016,9 +1015,9 @@
   1.714          }
   1.715      }
   1.716  
   1.717 -    xkey.keycode = XKeysymToKeycode (xkey.display, xsym);
   1.718 +    xkey.keycode = XKeysymToKeycode(xkey.display, xsym);
   1.719  
   1.720 -    get_modifier_masks (SDL_Display);
   1.721 +    get_modifier_masks(SDL_Display);
   1.722      if (modifiers & KMOD_SHIFT)
   1.723          xkey.state |= ShiftMask;
   1.724      if (modifiers & KMOD_CAPS)
   1.725 @@ -1039,7 +1038,7 @@
   1.726          xkey.state |= num_mask;
   1.727  
   1.728      unicode = 0;
   1.729 -    if (XLookupString (&xkey, keybuf, sizeof (keybuf), NULL, NULL))
   1.730 +    if (XLookupString(&xkey, keybuf, sizeof(keybuf), NULL, NULL))
   1.731          unicode = (unsigned char) keybuf[0];
   1.732      return (unicode);
   1.733  }
   1.734 @@ -1051,11 +1050,11 @@
   1.735   * key_vec is a bit vector of keycodes (256 bits)
   1.736   */
   1.737  void
   1.738 -X11_SetKeyboardState (Display * display, const char *key_vec)
   1.739 +X11_SetKeyboardState(Display * display, const char *key_vec)
   1.740  {
   1.741      char keys_return[32];
   1.742      int i;
   1.743 -    Uint8 *kstate = SDL_GetKeyState (NULL);
   1.744 +    Uint8 *kstate = SDL_GetKeyState(NULL);
   1.745      SDLMod modstate;
   1.746      Window junk_window;
   1.747      int x, y;
   1.748 @@ -1063,15 +1062,15 @@
   1.749  
   1.750      /* The first time the window is mapped, we initialize key state */
   1.751      if (!key_vec) {
   1.752 -        XQueryKeymap (display, keys_return);
   1.753 +        XQueryKeymap(display, keys_return);
   1.754          key_vec = keys_return;
   1.755      }
   1.756  
   1.757      /* Get the keyboard modifier state */
   1.758      modstate = 0;
   1.759 -    get_modifier_masks (display);
   1.760 -    if (XQueryPointer (display, DefaultRootWindow (display),
   1.761 -                       &junk_window, &junk_window, &x, &y, &x, &y, &mask)) {
   1.762 +    get_modifier_masks(display);
   1.763 +    if (XQueryPointer(display, DefaultRootWindow(display),
   1.764 +                      &junk_window, &junk_window, &x, &y, &x, &y, &mask)) {
   1.765          if (mask & LockMask) {
   1.766              modstate |= KMOD_CAPS;
   1.767          }
   1.768 @@ -1084,7 +1083,7 @@
   1.769      }
   1.770  
   1.771      /* Zero the new keyboard state and generate it */
   1.772 -    SDL_memset (kstate, 0, SDLK_LAST);
   1.773 +    SDL_memset(kstate, 0, SDLK_LAST);
   1.774      /*
   1.775       * An obvious optimisation is to check entire longwords at a time in
   1.776       * both loops, but we can't be sure the arrays are aligned so it's not
   1.777 @@ -1098,7 +1097,7 @@
   1.778              if (key_vec[i] & (1 << j)) {
   1.779                  SDLKey key;
   1.780                  KeyCode kc = (i << 3 | j);
   1.781 -                key = X11_TranslateKeycode (display, kc);
   1.782 +                key = X11_TranslateKeycode(display, kc);
   1.783                  if (key == SDLK_UNKNOWN) {
   1.784                      continue;
   1.785                  }
   1.786 @@ -1148,28 +1147,28 @@
   1.787      }
   1.788  
   1.789      /* Set the final modifier state */
   1.790 -    SDL_SetModState (modstate);
   1.791 +    SDL_SetModState(modstate);
   1.792  }
   1.793  
   1.794  void
   1.795 -X11_InitOSKeymap (_THIS)
   1.796 +X11_InitOSKeymap(_THIS)
   1.797  {
   1.798 -    X11_InitKeymap ();
   1.799 +    X11_InitKeymap();
   1.800  }
   1.801  
   1.802  void
   1.803 -X11_SaveScreenSaver (Display * display, int *saved_timeout, BOOL * dpms)
   1.804 +X11_SaveScreenSaver(Display * display, int *saved_timeout, BOOL * dpms)
   1.805  {
   1.806      int timeout, interval, prefer_blank, allow_exp;
   1.807 -    XGetScreenSaver (display, &timeout, &interval, &prefer_blank, &allow_exp);
   1.808 +    XGetScreenSaver(display, &timeout, &interval, &prefer_blank, &allow_exp);
   1.809      *saved_timeout = timeout;
   1.810  
   1.811  #if SDL_VIDEO_DRIVER_X11_DPMS
   1.812      if (SDL_X11_HAVE_DPMS) {
   1.813          int dummy;
   1.814 -        if (DPMSQueryExtension (display, &dummy, &dummy)) {
   1.815 +        if (DPMSQueryExtension(display, &dummy, &dummy)) {
   1.816              CARD16 state;
   1.817 -            DPMSInfo (display, &state, dpms);
   1.818 +            DPMSInfo(display, &state, dpms);
   1.819          }
   1.820      }
   1.821  #else
   1.822 @@ -1178,37 +1177,37 @@
   1.823  }
   1.824  
   1.825  void
   1.826 -X11_DisableScreenSaver (Display * display)
   1.827 +X11_DisableScreenSaver(Display * display)
   1.828  {
   1.829      int timeout, interval, prefer_blank, allow_exp;
   1.830 -    XGetScreenSaver (display, &timeout, &interval, &prefer_blank, &allow_exp);
   1.831 +    XGetScreenSaver(display, &timeout, &interval, &prefer_blank, &allow_exp);
   1.832      timeout = 0;
   1.833 -    XSetScreenSaver (display, timeout, interval, prefer_blank, allow_exp);
   1.834 +    XSetScreenSaver(display, timeout, interval, prefer_blank, allow_exp);
   1.835  
   1.836  #if SDL_VIDEO_DRIVER_X11_DPMS
   1.837      if (SDL_X11_HAVE_DPMS) {
   1.838          int dummy;
   1.839 -        if (DPMSQueryExtension (display, &dummy, &dummy)) {
   1.840 -            DPMSDisable (display);
   1.841 +        if (DPMSQueryExtension(display, &dummy, &dummy)) {
   1.842 +            DPMSDisable(display);
   1.843          }
   1.844      }
   1.845  #endif /* SDL_VIDEO_DRIVER_X11_DPMS */
   1.846  }
   1.847  
   1.848  void
   1.849 -X11_RestoreScreenSaver (Display * display, int saved_timeout, BOOL dpms)
   1.850 +X11_RestoreScreenSaver(Display * display, int saved_timeout, BOOL dpms)
   1.851  {
   1.852      int timeout, interval, prefer_blank, allow_exp;
   1.853 -    XGetScreenSaver (display, &timeout, &interval, &prefer_blank, &allow_exp);
   1.854 +    XGetScreenSaver(display, &timeout, &interval, &prefer_blank, &allow_exp);
   1.855      timeout = saved_timeout;
   1.856 -    XSetScreenSaver (display, timeout, interval, prefer_blank, allow_exp);
   1.857 +    XSetScreenSaver(display, timeout, interval, prefer_blank, allow_exp);
   1.858  
   1.859  #if SDL_VIDEO_DRIVER_X11_DPMS
   1.860      if (SDL_X11_HAVE_DPMS) {
   1.861          int dummy;
   1.862 -        if (DPMSQueryExtension (display, &dummy, &dummy)) {
   1.863 +        if (DPMSQueryExtension(display, &dummy, &dummy)) {
   1.864              if (dpms) {
   1.865 -                DPMSEnable (display);
   1.866 +                DPMSEnable(display);
   1.867              }
   1.868          }
   1.869      }