src/video/photon/SDL_ph_events.c
branchSDL-1.3
changeset 1668 4da1ee79c9af
parent 1662 782fd950bd46
     1.1 --- a/src/video/photon/SDL_ph_events.c	Mon May 29 03:53:21 2006 +0000
     1.2 +++ b/src/video/photon/SDL_ph_events.c	Mon May 29 04:04:35 2006 +0000
     1.3 @@ -44,14 +44,14 @@
     1.4  /* The translation tables from a photon keysym to a SDL keysym */
     1.5  static SDLKey ODD_keymap[256];
     1.6  static SDLKey MISC_keymap[0xFF + 1];
     1.7 -SDL_keysym *ph_TranslateKey (PhKeyEvent_t * key, SDL_keysym * keysym);
     1.8 +SDL_keysym *ph_TranslateKey(PhKeyEvent_t * key, SDL_keysym * keysym);
     1.9  
    1.10  /* Check to see if this is a repeated key.
    1.11     (idea shamelessly lifted from GII -- thanks guys! :) */
    1.12  static int
    1.13 -ph_WarpedMotion (_THIS, PhEvent_t * winEvent)
    1.14 +ph_WarpedMotion(_THIS, PhEvent_t * winEvent)
    1.15  {
    1.16 -    PhRect_t *rect = PhGetRects (winEvent);
    1.17 +    PhRect_t *rect = PhGetRects(winEvent);
    1.18  
    1.19      int centre_x, centre_y;
    1.20      int dx, dy;
    1.21 @@ -64,11 +64,11 @@
    1.22      dx = rect->ul.x - centre_x;
    1.23      dy = rect->ul.y - centre_y;
    1.24  
    1.25 -    posted = SDL_PrivateMouseMotion (0, 1, dx, dy);
    1.26 +    posted = SDL_PrivateMouseMotion(0, 1, dx, dy);
    1.27  
    1.28      /* Move mouse cursor to middle of the window */
    1.29 -    PtGetAbsPosition (window, &abs_x, &abs_y);
    1.30 -    PhMoveCursorAbs (PhInputGroup (NULL), abs_x + centre_x, abs_y + centre_y);
    1.31 +    PtGetAbsPosition(window, &abs_x, &abs_y);
    1.32 +    PhMoveCursorAbs(PhInputGroup(NULL), abs_x + centre_x, abs_y + centre_y);
    1.33  
    1.34      return (posted);
    1.35  }
    1.36 @@ -77,25 +77,25 @@
    1.37   * MOTION_BUTTON and MOTION_NOBUTTON */
    1.38  
    1.39  static void
    1.40 -set_motion_sensitivity (_THIS, unsigned int flags)
    1.41 +set_motion_sensitivity(_THIS, unsigned int flags)
    1.42  {
    1.43      int rid;
    1.44      int fields = Ph_EV_PTR_MOTION_BUTTON | Ph_EV_PTR_MOTION_NOBUTTON;
    1.45      PhRegion_t region;
    1.46  
    1.47      if (window) {
    1.48 -        rid = PtWidgetRid (window);
    1.49 -        if (rid != 0 && PhRegionQuery (rid, &region, NULL, NULL, 0) == 0) {
    1.50 +        rid = PtWidgetRid(window);
    1.51 +        if (rid != 0 && PhRegionQuery(rid, &region, NULL, NULL, 0) == 0) {
    1.52              region.events_sense =
    1.53                  (region.events_sense & ~fields) | (flags & fields);
    1.54 -            PhRegionChange (Ph_REGION_EV_SENSE, 0, &region, NULL, NULL);
    1.55 +            PhRegionChange(Ph_REGION_EV_SENSE, 0, &region, NULL, NULL);
    1.56          }
    1.57      }
    1.58  }
    1.59  
    1.60  /* Convert the photon button state value to an SDL value */
    1.61  static Uint8
    1.62 -ph2sdl_mousebutton (unsigned short button_state)
    1.63 +ph2sdl_mousebutton(unsigned short button_state)
    1.64  {
    1.65      Uint8 mouse_button = 0;
    1.66  
    1.67 @@ -110,7 +110,7 @@
    1.68  }
    1.69  
    1.70  static int
    1.71 -ph_DispatchEvent (_THIS)
    1.72 +ph_DispatchEvent(_THIS)
    1.73  {
    1.74      int posted;
    1.75      PhRect_t *rect;
    1.76 @@ -126,9 +126,9 @@
    1.77      case Ph_EV_BOUNDARY:
    1.78          {
    1.79              if (phevent->subtype == Ph_EV_PTR_ENTER) {
    1.80 -                posted = SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS);
    1.81 +                posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
    1.82              } else if (phevent->subtype == Ph_EV_PTR_LEAVE) {
    1.83 -                posted = SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS);
    1.84 +                posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
    1.85              }
    1.86          }
    1.87          break;
    1.88 @@ -137,14 +137,14 @@
    1.89      case Ph_EV_PTR_MOTION_NOBUTTON:
    1.90          {
    1.91              if (SDL_VideoSurface) {
    1.92 -                pointerEvent = PhGetData (phevent);
    1.93 -                rect = PhGetRects (phevent);
    1.94 +                pointerEvent = PhGetData(phevent);
    1.95 +                rect = PhGetRects(phevent);
    1.96  
    1.97                  if (mouse_relative) {
    1.98 -                    posted = ph_WarpedMotion (this, phevent);
    1.99 +                    posted = ph_WarpedMotion(this, phevent);
   1.100                  } else {
   1.101                      posted =
   1.102 -                        SDL_PrivateMouseMotion (0, 0, rect->ul.x, rect->ul.y);
   1.103 +                        SDL_PrivateMouseMotion(0, 0, rect->ul.x, rect->ul.y);
   1.104                  }
   1.105              }
   1.106          }
   1.107 @@ -152,20 +152,20 @@
   1.108  
   1.109      case Ph_EV_BUT_PRESS:
   1.110          {
   1.111 -            pointerEvent = PhGetData (phevent);
   1.112 -            buttons = ph2sdl_mousebutton (pointerEvent->buttons);
   1.113 +            pointerEvent = PhGetData(phevent);
   1.114 +            buttons = ph2sdl_mousebutton(pointerEvent->buttons);
   1.115              if (buttons != 0) {
   1.116 -                posted = SDL_PrivateMouseButton (SDL_PRESSED, buttons, 0, 0);
   1.117 +                posted = SDL_PrivateMouseButton(SDL_PRESSED, buttons, 0, 0);
   1.118              }
   1.119          }
   1.120          break;
   1.121  
   1.122      case Ph_EV_BUT_RELEASE:
   1.123          {
   1.124 -            pointerEvent = PhGetData (phevent);
   1.125 -            buttons = ph2sdl_mousebutton (pointerEvent->buttons);
   1.126 +            pointerEvent = PhGetData(phevent);
   1.127 +            buttons = ph2sdl_mousebutton(pointerEvent->buttons);
   1.128              if (phevent->subtype == Ph_EV_RELEASE_REAL && buttons != 0) {
   1.129 -                posted = SDL_PrivateMouseButton (SDL_RELEASED, buttons, 0, 0);
   1.130 +                posted = SDL_PrivateMouseButton(SDL_RELEASED, buttons, 0, 0);
   1.131              } else if (phevent->subtype == Ph_EV_RELEASE_PHANTOM) {
   1.132                  /* If the mouse is outside the window,
   1.133                   * only a phantom release event is sent, so
   1.134 @@ -173,9 +173,9 @@
   1.135                   * Not perfect, maybe checking the mouse button
   1.136                   * state for Ph_EV_BOUNDARY events would be
   1.137                   * better. */
   1.138 -                if ((SDL_GetAppState () & SDL_APPMOUSEFOCUS) == 0) {
   1.139 +                if ((SDL_GetAppState() & SDL_APPMOUSEFOCUS) == 0) {
   1.140                      posted =
   1.141 -                        SDL_PrivateMouseButton (SDL_RELEASED, buttons, 0, 0);
   1.142 +                        SDL_PrivateMouseButton(SDL_RELEASED, buttons, 0, 0);
   1.143                  }
   1.144              }
   1.145          }
   1.146 @@ -183,23 +183,23 @@
   1.147  
   1.148      case Ph_EV_WM:
   1.149          {
   1.150 -            winEvent = PhGetData (phevent);
   1.151 +            winEvent = PhGetData(phevent);
   1.152  
   1.153              /* losing focus */
   1.154              if ((winEvent->event_f == Ph_WM_FOCUS)
   1.155                  && (winEvent->event_state == Ph_WM_EVSTATE_FOCUSLOST)) {
   1.156 -                set_motion_sensitivity (this, Ph_EV_PTR_MOTION_BUTTON);
   1.157 -                posted = SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS);
   1.158 +                set_motion_sensitivity(this, Ph_EV_PTR_MOTION_BUTTON);
   1.159 +                posted = SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS);
   1.160              }
   1.161              /* gaining focus */
   1.162              else if ((winEvent->event_f == Ph_WM_FOCUS)
   1.163                       && (winEvent->event_state == Ph_WM_EVSTATE_FOCUS)) {
   1.164 -                set_motion_sensitivity (this, -1);
   1.165 -                posted = SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS);
   1.166 +                set_motion_sensitivity(this, -1);
   1.167 +                posted = SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS);
   1.168              }
   1.169              /* request quit */
   1.170              else if (winEvent->event_f == Ph_WM_CLOSE) {
   1.171 -                posted = SDL_PrivateQuit ();
   1.172 +                posted = SDL_PrivateQuit();
   1.173              }
   1.174              /* request hide/unhide */
   1.175              else if (winEvent->event_f == Ph_WM_HIDE) {
   1.176 @@ -217,11 +217,10 @@
   1.177              else if (winEvent->event_f == Ph_WM_RESIZE) {
   1.178                  currently_maximized = 0;
   1.179  #if (_NTO_VERSION < 630)
   1.180 -                SDL_PrivateResize (winEvent->size.w + 1,
   1.181 -                                   winEvent->size.h + 1);
   1.182 +                SDL_PrivateResize(winEvent->size.w + 1, winEvent->size.h + 1);
   1.183  #else
   1.184                  /* QNX 6.3.0 have this bug fixed */
   1.185 -                SDL_PrivateResize (winEvent->size.w, winEvent->size.h);
   1.186 +                SDL_PrivateResize(winEvent->size.w, winEvent->size.h);
   1.187  #endif /* _NTO_VERSION */
   1.188              }
   1.189              /* request to move */
   1.190 @@ -243,8 +242,8 @@
   1.191                      dst.h = current_overlay->hwdata->CurrentViewPort.size.h;
   1.192                      current_overlay->hwdata->ischromakey = 0;
   1.193                      error =
   1.194 -                        ph_DisplayYUVOverlay (this, current_overlay,
   1.195 -                                              &src, &dst);
   1.196 +                        ph_DisplayYUVOverlay(this, current_overlay,
   1.197 +                                             &src, &dst);
   1.198                      if (!error) {
   1.199                          current_overlay->hwdata->ischromakey = chromastate;
   1.200                          current_overlay->hwdata->locked = lockedstate;
   1.201 @@ -271,7 +270,7 @@
   1.202                  int numrects;
   1.203  
   1.204                  if (SDL_VideoSurface) {
   1.205 -                    rect = PhGetRects (phevent);
   1.206 +                    rect = PhGetRects(phevent);
   1.207                      if (phevent->num_rects > PH_SDL_MAX_RECTS) {
   1.208                          /* sorry, buffers underrun, we'll update only first PH_SDL_MAX_RECTS rects */
   1.209                          numrects = PH_SDL_MAX_RECTS;
   1.210 @@ -284,7 +283,7 @@
   1.211                          sdlrects[i].h = rect[i].lr.y - rect[i].ul.y + 1;
   1.212                      }
   1.213  
   1.214 -                    this->UpdateRects (this, phevent->num_rects, sdlrects);
   1.215 +                    this->UpdateRects(this, phevent->num_rects, sdlrects);
   1.216  
   1.217                      if (current_overlay != NULL) {
   1.218                          int lockedstate = current_overlay->hwdata->locked;
   1.219 @@ -306,9 +305,8 @@
   1.220                              current_overlay->hwdata->CurrentViewPort.size.h;
   1.221                          current_overlay->hwdata->forcedredraw = 1;
   1.222                          error =
   1.223 -                            ph_DisplayYUVOverlay (this,
   1.224 -                                                  current_overlay,
   1.225 -                                                  &src, &dst);
   1.226 +                            ph_DisplayYUVOverlay(this,
   1.227 +                                                 current_overlay, &src, &dst);
   1.228                          if (!error) {
   1.229                              current_overlay->hwdata->forcedredraw = 0;
   1.230                              current_overlay->hwdata->locked = lockedstate;
   1.231 @@ -325,7 +323,7 @@
   1.232  
   1.233              posted = 0;
   1.234  
   1.235 -            keyEvent = PhGetData (phevent);
   1.236 +            keyEvent = PhGetData(phevent);
   1.237  
   1.238              if (Pk_KF_Key_Down & keyEvent->key_flags) {
   1.239                  /* split the wheel events from real key events */
   1.240 @@ -334,8 +332,8 @@
   1.241                      && ((keyEvent->key_flags & Pk_KF_Scan_Valid) ==
   1.242                          Pk_KF_Scan_Valid)) {
   1.243                      posted =
   1.244 -                        SDL_PrivateMouseButton (SDL_PRESSED,
   1.245 -                                                SDL_BUTTON_WHEELUP, 0, 0);
   1.246 +                        SDL_PrivateMouseButton(SDL_PRESSED,
   1.247 +                                               SDL_BUTTON_WHEELUP, 0, 0);
   1.248                      break;
   1.249                  }
   1.250                  if ((keyEvent->key_cap == Pk_Down)
   1.251 @@ -343,13 +341,13 @@
   1.252                      && ((keyEvent->key_flags & Pk_KF_Scan_Valid) ==
   1.253                          Pk_KF_Scan_Valid)) {
   1.254                      posted =
   1.255 -                        SDL_PrivateMouseButton (SDL_PRESSED,
   1.256 -                                                SDL_BUTTON_WHEELDOWN, 0, 0);
   1.257 +                        SDL_PrivateMouseButton(SDL_PRESSED,
   1.258 +                                               SDL_BUTTON_WHEELDOWN, 0, 0);
   1.259                      break;
   1.260                  }
   1.261                  posted =
   1.262 -                    SDL_PrivateKeyboard (SDL_PRESSED,
   1.263 -                                         ph_TranslateKey (keyEvent, &keysym));
   1.264 +                    SDL_PrivateKeyboard(SDL_PRESSED,
   1.265 +                                        ph_TranslateKey(keyEvent, &keysym));
   1.266              } else {            /* must be key release */
   1.267  
   1.268                  /* split the wheel events from real key events */
   1.269 @@ -358,8 +356,8 @@
   1.270                      && ((keyEvent->key_flags & Pk_KF_Scan_Valid) ==
   1.271                          Pk_KF_Scan_Valid)) {
   1.272                      posted =
   1.273 -                        SDL_PrivateMouseButton (SDL_RELEASED,
   1.274 -                                                SDL_BUTTON_WHEELUP, 0, 0);
   1.275 +                        SDL_PrivateMouseButton(SDL_RELEASED,
   1.276 +                                               SDL_BUTTON_WHEELUP, 0, 0);
   1.277                      break;
   1.278                  }
   1.279                  if ((keyEvent->key_cap == Pk_Down)
   1.280 @@ -367,13 +365,13 @@
   1.281                      && ((keyEvent->key_flags & Pk_KF_Scan_Valid) ==
   1.282                          Pk_KF_Scan_Valid)) {
   1.283                      posted =
   1.284 -                        SDL_PrivateMouseButton (SDL_RELEASED,
   1.285 -                                                SDL_BUTTON_WHEELDOWN, 0, 0);
   1.286 +                        SDL_PrivateMouseButton(SDL_RELEASED,
   1.287 +                                               SDL_BUTTON_WHEELDOWN, 0, 0);
   1.288                      break;
   1.289                  }
   1.290                  posted =
   1.291 -                    SDL_PrivateKeyboard (SDL_RELEASED,
   1.292 -                                         ph_TranslateKey (keyEvent, &keysym));
   1.293 +                    SDL_PrivateKeyboard(SDL_RELEASED,
   1.294 +                                        ph_TranslateKey(keyEvent, &keysym));
   1.295              }
   1.296          }
   1.297          break;
   1.298 @@ -383,7 +381,7 @@
   1.299              if (phevent->subtype == Ph_OFFSCREEN_INVALID) {
   1.300                  unsigned long *EvInfoData;
   1.301  
   1.302 -                EvInfoData = (unsigned long *) PhGetData (phevent);
   1.303 +                EvInfoData = (unsigned long *) PhGetData(phevent);
   1.304  
   1.305                  switch (*EvInfoData) {
   1.306                  case Pg_VIDEO_MODE_SWITCHED:
   1.307 @@ -413,17 +411,17 @@
   1.308  
   1.309  /* perform a blocking read if no events available */
   1.310  int
   1.311 -ph_Pending (_THIS)
   1.312 +ph_Pending(_THIS)
   1.313  {
   1.314      /* Flush the display connection and look to see if events are queued */
   1.315 -    PgFlush ();
   1.316 +    PgFlush();
   1.317  
   1.318      while (1) {
   1.319 -        switch (PhEventPeek (phevent, EVENT_SIZE)) {
   1.320 +        switch (PhEventPeek(phevent, EVENT_SIZE)) {
   1.321          case Ph_EVENT_MSG:
   1.322              return 1;
   1.323          case -1:
   1.324 -            SDL_SetError ("ph_Pending(): PhEventNext failed.\n");
   1.325 +            SDL_SetError("ph_Pending(): PhEventNext failed.\n");
   1.326              return 0;
   1.327          default:
   1.328              return 0;
   1.329 @@ -435,29 +433,29 @@
   1.330  }
   1.331  
   1.332  void
   1.333 -ph_PumpEvents (_THIS)
   1.334 +ph_PumpEvents(_THIS)
   1.335  {
   1.336      /* Flush the display connection and look to see if events are queued */
   1.337 -    PgFlush ();
   1.338 +    PgFlush();
   1.339  
   1.340 -    while (ph_Pending (this)) {
   1.341 -        PtEventHandler (phevent);
   1.342 -        ph_DispatchEvent (this);
   1.343 +    while (ph_Pending(this)) {
   1.344 +        PtEventHandler(phevent);
   1.345 +        ph_DispatchEvent(this);
   1.346      }
   1.347  }
   1.348  
   1.349  void
   1.350 -ph_InitKeymap (void)
   1.351 +ph_InitKeymap(void)
   1.352  {
   1.353      int i;
   1.354  
   1.355      /* Odd keys used in international keyboards */
   1.356 -    for (i = 0; i < SDL_arraysize (ODD_keymap); ++i) {
   1.357 +    for (i = 0; i < SDL_arraysize(ODD_keymap); ++i) {
   1.358          ODD_keymap[i] = SDLK_UNKNOWN;
   1.359      }
   1.360  
   1.361      /* Map the miscellaneous keys */
   1.362 -    for (i = 0; i < SDL_arraysize (MISC_keymap); ++i) {
   1.363 +    for (i = 0; i < SDL_arraysize(MISC_keymap); ++i) {
   1.364          MISC_keymap[i] = SDLK_UNKNOWN;
   1.365      }
   1.366  
   1.367 @@ -543,7 +541,7 @@
   1.368  static unsigned long cap;
   1.369  
   1.370  SDL_keysym *
   1.371 -ph_TranslateKey (PhKeyEvent_t * key, SDL_keysym * keysym)
   1.372 +ph_TranslateKey(PhKeyEvent_t * key, SDL_keysym * keysym)
   1.373  {
   1.374      /* 'sym' is set to the value of the key with modifiers applied to it.
   1.375         This member is valid only if Pk_KF_Sym_Valid is set in the key_flags.
   1.376 @@ -601,9 +599,9 @@
   1.377              keysym->unicode = 10;
   1.378              break;
   1.379          default:
   1.380 -            utf8len = PhKeyToMb (utf8, key);
   1.381 +            utf8len = PhKeyToMb(utf8, key);
   1.382              if (utf8len > 0) {
   1.383 -                utf8len = mbtowc (&unicode, utf8, utf8len);
   1.384 +                utf8len = mbtowc(&unicode, utf8, utf8len);
   1.385                  if (utf8len > 0) {
   1.386                      keysym->unicode = unicode;
   1.387                  }
   1.388 @@ -617,9 +615,9 @@
   1.389  }
   1.390  
   1.391  void
   1.392 -ph_InitOSKeymap (_THIS)
   1.393 +ph_InitOSKeymap(_THIS)
   1.394  {
   1.395 -    ph_InitKeymap ();
   1.396 +    ph_InitKeymap();
   1.397  }
   1.398  
   1.399  /* vi: set ts=4 sw=4 expandtab: */