src/video/photon/SDL_ph_events.c
changeset 1482 141528317f4f
parent 1402 d910939febfa
child 1643 51038e80ae59
equal deleted inserted replaced
1481:deb22b9fe970 1482:141528317f4f
   117     int i, buttons;
   117     int i, buttons;
   118     SDL_Rect sdlrects[PH_SDL_MAX_RECTS];
   118     SDL_Rect sdlrects[PH_SDL_MAX_RECTS];
   119 	
   119 	
   120     posted = 0;
   120     posted = 0;
   121 	
   121 	
   122     switch (event->type)
   122     switch (phevent->type)
   123     {
   123     {
   124         case Ph_EV_BOUNDARY:
   124         case Ph_EV_BOUNDARY:
   125         {
   125         {
   126             if (event->subtype == Ph_EV_PTR_ENTER)
   126             if (phevent->subtype == Ph_EV_PTR_ENTER)
   127             {
   127             {
   128                 posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
   128                 posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
   129             }
   129             }
   130             else if (event->subtype ==Ph_EV_PTR_LEAVE)
   130             else if (phevent->subtype ==Ph_EV_PTR_LEAVE)
   131             {
   131             {
   132                 posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);	
   132                 posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);	
   133             }
   133             }
   134         }
   134         }
   135         break;
   135         break;
   137         case Ph_EV_PTR_MOTION_BUTTON:
   137         case Ph_EV_PTR_MOTION_BUTTON:
   138         case Ph_EV_PTR_MOTION_NOBUTTON:
   138         case Ph_EV_PTR_MOTION_NOBUTTON:
   139         {
   139         {
   140             if (SDL_VideoSurface)
   140             if (SDL_VideoSurface)
   141             {
   141             {
   142                 pointerEvent = PhGetData(event);
   142                 pointerEvent = PhGetData(phevent);
   143                 rect = PhGetRects(event);
   143                 rect = PhGetRects(phevent);
   144 
   144 
   145                 if (mouse_relative)
   145                 if (mouse_relative)
   146                 {
   146                 {
   147                     posted = ph_WarpedMotion(this, event);
   147                     posted = ph_WarpedMotion(this, phevent);
   148                 }
   148                 }
   149                 else
   149                 else
   150                 {
   150                 {
   151                     posted = SDL_PrivateMouseMotion(0, 0, rect->ul.x, rect->ul.y);
   151                     posted = SDL_PrivateMouseMotion(0, 0, rect->ul.x, rect->ul.y);
   152                 }
   152                 }
   154         }
   154         }
   155         break;
   155         break;
   156 
   156 
   157         case Ph_EV_BUT_PRESS:
   157         case Ph_EV_BUT_PRESS:
   158         {
   158         {
   159             pointerEvent = PhGetData( event );
   159             pointerEvent = PhGetData(phevent);
   160             buttons = ph2sdl_mousebutton( pointerEvent->buttons );
   160             buttons = ph2sdl_mousebutton(pointerEvent->buttons);
   161             if (buttons != 0)
   161             if (buttons != 0)
   162             {
   162             {
   163                 posted = SDL_PrivateMouseButton(SDL_PRESSED, buttons, 0, 0);
   163                 posted = SDL_PrivateMouseButton(SDL_PRESSED, buttons, 0, 0);
   164             }
   164             }
   165         }
   165         }
   166         break;
   166         break;
   167 
   167 
   168         case Ph_EV_BUT_RELEASE:
   168         case Ph_EV_BUT_RELEASE:
   169         {
   169         {
   170             pointerEvent = PhGetData(event);
   170             pointerEvent = PhGetData(phevent);
   171             buttons = ph2sdl_mousebutton(pointerEvent->buttons);
   171             buttons = ph2sdl_mousebutton(pointerEvent->buttons);
   172             if (event->subtype == Ph_EV_RELEASE_REAL && buttons != 0)
   172             if (phevent->subtype == Ph_EV_RELEASE_REAL && buttons != 0)
   173             {
   173             {
   174                 posted = SDL_PrivateMouseButton(SDL_RELEASED, buttons, 0, 0);
   174                 posted = SDL_PrivateMouseButton(SDL_RELEASED, buttons, 0, 0);
   175             }
   175             }
   176             else if(event->subtype == Ph_EV_RELEASE_PHANTOM)
   176             else if(phevent->subtype == Ph_EV_RELEASE_PHANTOM)
   177             {
   177             {
   178                 /* If the mouse is outside the window,
   178                 /* If the mouse is outside the window,
   179                  * only a phantom release event is sent, so
   179                  * only a phantom release event is sent, so
   180                  * check if the window doesn't have mouse focus.
   180                  * check if the window doesn't have mouse focus.
   181                  * Not perfect, maybe checking the mouse button
   181                  * Not perfect, maybe checking the mouse button
   189         }
   189         }
   190         break;
   190         break;
   191 
   191 
   192         case Ph_EV_WM:
   192         case Ph_EV_WM:
   193         {
   193         {
   194             winEvent = PhGetData(event);
   194             winEvent = PhGetData(phevent);
   195 
   195 
   196             /* losing focus */
   196             /* losing focus */
   197             if ((winEvent->event_f==Ph_WM_FOCUS) && (winEvent->event_state==Ph_WM_EVSTATE_FOCUSLOST))
   197             if ((winEvent->event_f==Ph_WM_FOCUS) && (winEvent->event_state==Ph_WM_EVSTATE_FOCUSLOST))
   198             {
   198             {
   199                 set_motion_sensitivity(this, Ph_EV_PTR_MOTION_BUTTON);
   199                 set_motion_sensitivity(this, Ph_EV_PTR_MOTION_BUTTON);
   277         break;
   277         break;
   278 
   278 
   279         /* window has been resized, moved or removed */
   279         /* window has been resized, moved or removed */
   280         case Ph_EV_EXPOSE:
   280         case Ph_EV_EXPOSE:
   281         {
   281         {
   282             if (event->num_rects!=0)
   282             if (phevent->num_rects!=0)
   283             {
   283             {
   284                 int numrects;
   284                 int numrects;
   285 
   285 
   286                 if (SDL_VideoSurface)
   286                 if (SDL_VideoSurface)
   287                 {
   287                 {
   288                     rect = PhGetRects(event);
   288                     rect = PhGetRects(phevent);
   289                     if (event->num_rects>PH_SDL_MAX_RECTS)
   289                     if (phevent->num_rects>PH_SDL_MAX_RECTS)
   290                     {
   290                     {
   291                        /* sorry, buffers underrun, we'll update only first PH_SDL_MAX_RECTS rects */
   291                        /* sorry, buffers underrun, we'll update only first PH_SDL_MAX_RECTS rects */
   292                        numrects=PH_SDL_MAX_RECTS;
   292                        numrects=PH_SDL_MAX_RECTS;
   293                     }
   293                     }
   294 
   294 
   295                     for(i=0; i<event->num_rects; i++)
   295                     for(i=0; i<phevent->num_rects; i++)
   296                     {
   296                     {
   297                         sdlrects[i].x = rect[i].ul.x;
   297                         sdlrects[i].x = rect[i].ul.x;
   298                         sdlrects[i].y = rect[i].ul.y;
   298                         sdlrects[i].y = rect[i].ul.y;
   299                         sdlrects[i].w = rect[i].lr.x - rect[i].ul.x + 1;
   299                         sdlrects[i].w = rect[i].lr.x - rect[i].ul.x + 1;
   300                         sdlrects[i].h = rect[i].lr.y - rect[i].ul.y + 1;
   300                         sdlrects[i].h = rect[i].lr.y - rect[i].ul.y + 1;
   301                     }
   301                     }
   302 
   302 
   303                     this->UpdateRects(this, event->num_rects, sdlrects);
   303                     this->UpdateRects(this, phevent->num_rects, sdlrects);
   304 
   304 
   305                     if (current_overlay!=NULL)
   305                     if (current_overlay!=NULL)
   306                     {
   306                     {
   307                         int lockedstate=current_overlay->hwdata->locked;
   307                         int lockedstate=current_overlay->hwdata->locked;
   308                         int error;
   308                         int error;
   330         {
   330         {
   331             SDL_keysym keysym;
   331             SDL_keysym keysym;
   332 
   332 
   333             posted = 0;
   333             posted = 0;
   334 
   334 
   335             keyEvent = PhGetData( event );
   335             keyEvent = PhGetData(phevent);
   336 
   336 
   337             if (Pk_KF_Key_Down & keyEvent->key_flags)
   337             if (Pk_KF_Key_Down & keyEvent->key_flags)
   338             {
   338             {
   339                 /* split the wheel events from real key events */
   339                 /* split the wheel events from real key events */
   340                 if ((keyEvent->key_cap==Pk_Up) && (keyEvent->key_scan==0) && ((keyEvent->key_flags & Pk_KF_Scan_Valid)==Pk_KF_Scan_Valid))
   340                 if ((keyEvent->key_cap==Pk_Up) && (keyEvent->key_scan==0) && ((keyEvent->key_flags & Pk_KF_Scan_Valid)==Pk_KF_Scan_Valid))
   367         }
   367         }
   368         break;
   368         break;
   369         
   369         
   370         case Ph_EV_INFO:
   370         case Ph_EV_INFO:
   371         {
   371         {
   372            if (event->subtype==Ph_OFFSCREEN_INVALID)
   372            if (phevent->subtype==Ph_OFFSCREEN_INVALID)
   373            {
   373            {
   374               unsigned long* EvInfoData;
   374               unsigned long* EvInfoData;
   375 
   375 
   376               EvInfoData=(unsigned long*)PhGetData(event);
   376               EvInfoData=(unsigned long*)PhGetData(phevent);
   377 
   377 
   378               switch (*EvInfoData)
   378               switch (*EvInfoData)
   379               {
   379               {
   380                  case Pg_VIDEO_MODE_SWITCHED:
   380                  case Pg_VIDEO_MODE_SWITCHED:
   381                       {
   381                       {
   408     /* Flush the display connection and look to see if events are queued */
   408     /* Flush the display connection and look to see if events are queued */
   409     PgFlush();
   409     PgFlush();
   410 
   410 
   411     while (1)
   411     while (1)
   412     {
   412     {
   413         switch(PhEventPeek(event, EVENT_SIZE))
   413         switch(PhEventPeek(phevent, EVENT_SIZE))
   414         {
   414         {
   415             case Ph_EVENT_MSG:
   415             case Ph_EVENT_MSG:
   416                  return 1;
   416                  return 1;
   417             case -1:
   417             case -1:
   418                  SDL_SetError("ph_Pending(): PhEventNext failed.\n");
   418                  SDL_SetError("ph_Pending(): PhEventNext failed.\n");
   431     /* Flush the display connection and look to see if events are queued */
   431     /* Flush the display connection and look to see if events are queued */
   432     PgFlush();
   432     PgFlush();
   433 
   433 
   434     while (ph_Pending(this))
   434     while (ph_Pending(this))
   435     {
   435     {
   436         PtEventHandler(event);
   436         PtEventHandler(phevent);
   437         ph_DispatchEvent(this);
   437         ph_DispatchEvent(this);
   438     }
   438     }
   439 }
   439 }
   440 
   440 
   441 void ph_InitKeymap(void)
   441 void ph_InitKeymap(void)