LOCAL_C TInt ScreenDeviceChanged() { static TInt w = -1; static TInt h = -1; const TSize screenSize = EpocSdlEnv::WindowSize(); if(w != screenSize.iWidth || h != screenSize.iHeight) { SDL_PrivateResize(screenSize.iWidth, screenSize.iHeight); // EpocSdlEnv::WaitDeviceChange(); w = screenSize.iWidth; h = screenSize.iHeight; } return 0; }
void NX_PumpEvents (_THIS) { GR_EVENT event ; static GR_BUTTON last_button_down = 0 ; GrCheckNextEvent (& event) ; while (event.type != GR_EVENT_TYPE_NONE) { // dispatch event switch (event.type) { case GR_EVENT_TYPE_MOUSE_ENTER : { Dprintf ("mouse enter\n") ; SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS) ; break ; } case GR_EVENT_TYPE_MOUSE_EXIT : { Dprintf ("mouse exit\n") ; SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS) ; break ; } case GR_EVENT_TYPE_FOCUS_IN : { Dprintf ("focus in\n") ; SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS) ; break ; } case GR_EVENT_TYPE_FOCUS_OUT : { Dprintf ("focus out\n") ; SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS) ; break ; } case GR_EVENT_TYPE_MOUSE_MOTION : { Dprintf ("mouse motion\n") ; if (SDL_VideoSurface) { if (currently_fullscreen) { if (check_boundary (this, event.button.x, event.button.y)) { SDL_PrivateMouseMotion (0, 0, event.button.x - OffsetX, event.button.y - OffsetY) ; } } else { SDL_PrivateMouseMotion (0, 0, event.button.x, event.button.y) ; } } break ; } case GR_EVENT_TYPE_BUTTON_DOWN : { int button = event.button.buttons ; Dprintf ("button down\n") ; switch (button) { case MWBUTTON_L : button = 1 ; break ; case MWBUTTON_M : button = 2 ; break ; case MWBUTTON_R : button = 3 ; break ; default : button = 0 ; } last_button_down = button ; if (currently_fullscreen) { if (check_boundary (this, event.button.x, event.button.y)) { SDL_PrivateMouseButton (SDL_PRESSED, button, event.button.x - OffsetX, event.button.y - OffsetY) ; } } else { SDL_PrivateMouseButton (SDL_PRESSED, button, event.button.x, event.button.y) ; } break ; } // do not konw which button is released case GR_EVENT_TYPE_BUTTON_UP : { Dprintf ("button up\n") ; if (currently_fullscreen) { if (check_boundary (this, event.button.x, event.button.y)) { SDL_PrivateMouseButton (SDL_RELEASED, last_button_down, event.button.x - OffsetX, event.button.y - OffsetY) ; } } else { SDL_PrivateMouseButton (SDL_RELEASED, last_button_down, event.button.x, event.button.y) ; } last_button_down = 0 ; break ; } case GR_EVENT_TYPE_KEY_DOWN : { SDL_keysym keysym ; Dprintf ("key down\n") ; SDL_PrivateKeyboard (SDL_PRESSED, NX_TranslateKey (& event.keystroke, & keysym)) ; break ; } case GR_EVENT_TYPE_KEY_UP : { SDL_keysym keysym ; Dprintf ("key up\n") ; SDL_PrivateKeyboard (SDL_RELEASED, NX_TranslateKey (& event.keystroke, & keysym)) ; break ; } case GR_EVENT_TYPE_CLOSE_REQ : { Dprintf ("close require\n") ; SDL_PrivateQuit () ; break ; } case GR_EVENT_TYPE_EXPOSURE : { Dprintf ("event_type_exposure\n") ; if (SDL_VideoSurface) { NX_RefreshDisplay (this) ;//, & event.exposure) ; } break ; } case GR_EVENT_TYPE_UPDATE : { switch (event.update.utype) { case GR_UPDATE_MAP : { Dprintf ("GR_UPDATE_MAP\n") ; // If we're not active, make ourselves active if (!(SDL_GetAppState () & SDL_APPACTIVE)) { // Send an internal activate event SDL_PrivateAppActive (1, SDL_APPACTIVE) ; } if (SDL_VideoSurface) { NX_RefreshDisplay (this) ; } break ; } case GR_UPDATE_UNMAP : case GR_UPDATE_UNMAPTEMP : { Dprintf ("GR_UPDATE_UNMAP or GR_UPDATE_UNMAPTEMP\n") ; // If we're active, make ourselves inactive if (SDL_GetAppState () & SDL_APPACTIVE) { // Send an internal deactivate event SDL_PrivateAppActive (0, SDL_APPACTIVE | SDL_APPINPUTFOCUS) ; } break ; } case GR_UPDATE_SIZE : { Dprintf ("GR_UPDATE_SIZE\n") ; SDL_PrivateResize (event.update.width, event.update.height) ; break ; } case GR_UPDATE_MOVE : case GR_UPDATE_REPARENT : { Dprintf ("GR_UPDATE_MOVE or GR_UPDATE_REPARENT\n") ; #ifdef ENABLE_NANOX_DIRECT_FB if (Clientfb) { /* Get current window position and fb pointer*/ if (currently_fullscreen) GrGetWindowFBInfo(FSwindow, &fbinfo); else GrGetWindowFBInfo(SDL_Window, &fbinfo); } #endif break ; } default : Dprintf ("unknown GR_EVENT_TYPE_UPDATE\n") ; break ; } break ; } default : { Dprintf ("pump event default\n") ; } } GrCheckNextEvent (& event) ; } }
int PG_HandleResize(struct pgEvent *evt) { SDL_PrivateResize(evt->e.size.w, evt->e.size.h); return 0; }
static int ph_DispatchEvent(_THIS) { int posted; PhRect_t* rect; PhPointerEvent_t* pointerEvent; PhKeyEvent_t* keyEvent; PhWindowEvent_t* winEvent; int i, buttons; SDL_Rect sdlrects[50]; posted = 0; switch (event->type) { case Ph_EV_BOUNDARY: { if (event->subtype == Ph_EV_PTR_ENTER) { posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); } else if (event->subtype ==Ph_EV_PTR_LEAVE) { posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); } } break; case Ph_EV_PTR_MOTION_BUTTON: case Ph_EV_PTR_MOTION_NOBUTTON: { if (SDL_VideoSurface) { pointerEvent = PhGetData(event); rect = PhGetRects(event); if (mouse_relative) { posted = ph_WarpedMotion(this, event); } else { posted = SDL_PrivateMouseMotion(0, 0, rect->ul.x, rect->ul.y); } } } break; case Ph_EV_BUT_PRESS: { pointerEvent = PhGetData( event ); buttons = ph2sdl_mousebutton( pointerEvent->buttons ); if (buttons != 0) { posted = SDL_PrivateMouseButton(SDL_PRESSED, buttons, 0, 0); } } break; case Ph_EV_BUT_RELEASE: { pointerEvent = PhGetData(event); buttons = ph2sdl_mousebutton(pointerEvent->buttons); if (event->subtype == Ph_EV_RELEASE_REAL && buttons != 0) { posted = SDL_PrivateMouseButton(SDL_RELEASED, buttons, 0, 0); } else if(event->subtype == Ph_EV_RELEASE_PHANTOM) { /* If the mouse is outside the window, * only a phantom release event is sent, so * check if the window doesn't have mouse focus. * Not perfect, maybe checking the mouse button * state for Ph_EV_BOUNDARY events would be * better. */ if ((SDL_GetAppState() & SDL_APPMOUSEFOCUS) == 0) { posted = SDL_PrivateMouseButton(SDL_RELEASED, buttons, 0, 0); } } } break; case Ph_EV_WM: { winEvent = PhGetData(event); /* losing focus */ if ((winEvent->event_f==Ph_WM_FOCUS) && (winEvent->event_state==Ph_WM_EVSTATE_FOCUSLOST)) { set_motion_sensitivity(this, Ph_EV_PTR_MOTION_BUTTON); posted = SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS); } /* gaining focus */ else if ((winEvent->event_f==Ph_WM_FOCUS) && (winEvent->event_state==Ph_WM_EVSTATE_FOCUS)) { set_motion_sensitivity(this, -1); posted = SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS); } /* request to quit */ else if (winEvent->event_f==Ph_WM_CLOSE) { posted = SDL_PrivateQuit(); } /* request to hide/unhide */ else if (winEvent->event_f==Ph_WM_HIDE) { if (currently_hided) { /* got unhide window event */ /* TODO: restore application's palette if in palette mode */ currently_hided=0; } else { /* got hide window event */ /* TODO: restore original palette if in palette mode */ currently_hided=1; } } /* request to resize */ else if (winEvent->event_f==Ph_WM_RESIZE) { SDL_PrivateResize(winEvent->size.w, winEvent->size.h); } /* request to move */ else if (winEvent->event_f==Ph_WM_MOVE) { if (current_overlay!=NULL) { int lockedstate=current_overlay->hwdata->locked; int chromastate=current_overlay->hwdata->ischromakey; SDL_Rect target; current_overlay->hwdata->locked=1; target.x=current_overlay->hwdata->CurrentViewPort.pos.x; target.y=current_overlay->hwdata->CurrentViewPort.pos.y; target.w=current_overlay->hwdata->CurrentViewPort.size.w; target.h=current_overlay->hwdata->CurrentViewPort.size.h; current_overlay->hwdata->ischromakey=0; ph_DisplayYUVOverlay(this, current_overlay, &target); current_overlay->hwdata->ischromakey=chromastate; current_overlay->hwdata->locked=lockedstate; } } /* request to maximize */ else if (winEvent->event_f==Ph_WM_MAX) { /* window already moved and resized here */ SDL_PrivateResize(winEvent->size.w-winEvent->pos.x, winEvent->size.h-winEvent->pos.y); } /* request to restore */ else if (winEvent->event_f==Ph_WM_RESTORE) { } } break; /* window has been resized, moved or removed */ case Ph_EV_EXPOSE: { if (event->num_rects!=0) { if (SDL_VideoSurface) { rect = PhGetRects(event); for(i=0;i<event->num_rects;i++) { sdlrects[i].x = rect[i].ul.x; sdlrects[i].y = rect[i].ul.y; sdlrects[i].w = rect[i].lr.x - rect[i].ul.x + 1; sdlrects[i].h = rect[i].lr.y - rect[i].ul.y + 1; } this->UpdateRects(this, event->num_rects, sdlrects); if (current_overlay!=NULL) { int lockedstate=current_overlay->hwdata->locked; SDL_Rect target; current_overlay->hwdata->locked=1; target.x=current_overlay->hwdata->CurrentViewPort.pos.x; target.y=current_overlay->hwdata->CurrentViewPort.pos.y; target.w=current_overlay->hwdata->CurrentViewPort.size.w; target.h=current_overlay->hwdata->CurrentViewPort.size.h; current_overlay->hwdata->forcedredraw=1; ph_DisplayYUVOverlay(this, current_overlay, &target); current_overlay->hwdata->forcedredraw=0; current_overlay->hwdata->locked=lockedstate; } } } } break; case Ph_EV_KEY: { SDL_keysym keysym; posted = 0; keyEvent = PhGetData( event ); if (Pk_KF_Key_Down & keyEvent->key_flags) { /* split the wheel events from real key events */ if ((keyEvent->key_cap==Pk_Up) && (keyEvent->key_scan==0) && ((keyEvent->key_flags & Pk_KF_Scan_Valid)==Pk_KF_Scan_Valid)) { posted = SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_WHEELUP, 0, 0); break; } if ((keyEvent->key_cap==Pk_Down) && (keyEvent->key_scan==0) && ((keyEvent->key_flags & Pk_KF_Scan_Valid)==Pk_KF_Scan_Valid)) { posted = SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_WHEELDOWN, 0, 0); break; } posted = SDL_PrivateKeyboard(SDL_PRESSED, ph_TranslateKey(keyEvent, &keysym)); } else /* must be key release */ { /* split the wheel events from real key events */ if ((keyEvent->key_cap==Pk_Up) && (keyEvent->key_scan==0) && ((keyEvent->key_flags & Pk_KF_Scan_Valid)==Pk_KF_Scan_Valid)) { posted = SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_WHEELUP, 0, 0); break; } if ((keyEvent->key_cap==Pk_Down) && (keyEvent->key_scan==0) && ((keyEvent->key_flags & Pk_KF_Scan_Valid)==Pk_KF_Scan_Valid)) { posted = SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_WHEELDOWN, 0, 0); break; } posted = SDL_PrivateKeyboard(SDL_RELEASED, ph_TranslateKey( keyEvent, &keysym)); } } break; } return(posted); }
static int X11_DispatchEvent(_THIS) { int posted; XEvent xevent; XNextEvent(SDL_Display, &xevent); posted = 0; switch (xevent.type) { /* Gaining mouse coverage? */ case EnterNotify: { #ifdef DEBUG_XEVENTS printf("EnterNotify! (%d,%d)\n", xevent.xcrossing.x, xevent.xcrossing.y); if ( xevent.xcrossing.mode == NotifyGrab ) printf("Mode: NotifyGrab\n"); if ( xevent.xcrossing.mode == NotifyUngrab ) printf("Mode: NotifyUngrab\n"); #endif if ( (xevent.xcrossing.mode != NotifyGrab) && (xevent.xcrossing.mode != NotifyUngrab) ) { if ( this->input_grab == SDL_GRAB_OFF ) { posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); } else { posted = SDL_PrivateMouseMotion(0, 0, xevent.xcrossing.x, xevent.xcrossing.y); } } } break; /* Losing mouse coverage? */ case LeaveNotify: { #ifdef DEBUG_XEVENTS printf("LeaveNotify! (%d,%d)\n", xevent.xcrossing.x, xevent.xcrossing.y); if ( xevent.xcrossing.mode == NotifyGrab ) printf("Mode: NotifyGrab\n"); if ( xevent.xcrossing.mode == NotifyUngrab ) printf("Mode: NotifyUngrab\n"); #endif if ( (xevent.xcrossing.mode != NotifyGrab) && (xevent.xcrossing.mode != NotifyUngrab) && (xevent.xcrossing.detail != NotifyInferior) ) { if ( this->input_grab == SDL_GRAB_OFF ) { posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); } else { posted = SDL_PrivateMouseMotion(0, 0, xevent.xcrossing.x, xevent.xcrossing.y); } } } break; /* Gaining input focus? */ case FocusIn: { #ifdef DEBUG_XEVENTS printf("FocusIn!\n"); #endif posted = SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS); /* Queue entry into fullscreen mode */ switch_waiting = 0x01 | SDL_FULLSCREEN; switch_time = SDL_GetTicks() + 1500; } break; /* Losing input focus? */ case FocusOut: { #ifdef DEBUG_XEVENTS printf("FocusOut!\n"); #endif posted = SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS); /* Queue leaving fullscreen mode */ switch_waiting = 0x01; switch_time = SDL_GetTicks() + 200; } break; /* Generated upon EnterWindow and FocusIn */ case KeymapNotify: { #ifdef DEBUG_XEVENTS printf("KeymapNotify!\n"); #endif X11_SetKeyboardState(SDL_Display, xevent.xkeymap.key_vector); } break; /* Mouse motion? */ case MotionNotify: { if ( SDL_VideoSurface ) { if ( mouse_relative ) { if ( using_dga & DGA_MOUSE ) { #ifdef DEBUG_MOTION printf("DGA motion: %d,%d\n", xevent.xmotion.x_root, xevent.xmotion.y_root); #endif posted = SDL_PrivateMouseMotion(0, 1, xevent.xmotion.x_root, xevent.xmotion.y_root); } else { posted = X11_WarpedMotion(this,&xevent); } } else { #ifdef DEBUG_MOTION printf("X11 motion: %d,%d\n", xevent.xmotion.x, xevent.xmotion.y); #endif posted = SDL_PrivateMouseMotion(0, 0, xevent.xmotion.x, xevent.xmotion.y); } } } break; /* Mouse button press? */ case ButtonPress: { posted = SDL_PrivateMouseButton(SDL_PRESSED, xevent.xbutton.button, 0, 0); } break; /* Mouse button release? */ case ButtonRelease: { posted = SDL_PrivateMouseButton(SDL_RELEASED, xevent.xbutton.button, 0, 0); } break; /* Key press? */ case KeyPress: { SDL_keysym keysym; #ifdef DEBUG_XEVENTS printf("KeyPress (X11 keycode = 0x%X)\n", xevent.xkey.keycode); #endif posted = SDL_PrivateKeyboard(SDL_PRESSED, X11_TranslateKey(SDL_Display, &xevent.xkey, xevent.xkey.keycode, &keysym)); } break; /* Key release? */ case KeyRelease: { SDL_keysym keysym; #ifdef DEBUG_XEVENTS printf("KeyRelease (X11 keycode = 0x%X)\n", xevent.xkey.keycode); #endif /* Check to see if this is a repeated key */ if ( ! X11_KeyRepeat(SDL_Display, &xevent) ) { posted = SDL_PrivateKeyboard(SDL_RELEASED, X11_TranslateKey(SDL_Display, &xevent.xkey, xevent.xkey.keycode, &keysym)); } } break; /* Have we been iconified? */ case UnmapNotify: { #ifdef DEBUG_XEVENTS printf("UnmapNotify!\n"); #endif /* If we're active, make ourselves inactive */ if ( SDL_GetAppState() & SDL_APPACTIVE ) { /* Swap out the gamma before we go inactive */ X11_SwapVidModeGamma(this); /* Send an internal deactivate event */ posted = SDL_PrivateAppActive(0, SDL_APPACTIVE|SDL_APPINPUTFOCUS); } } break; /* Have we been restored? */ case MapNotify: { #ifdef DEBUG_XEVENTS printf("MapNotify!\n"); #endif /* If we're not active, make ourselves active */ if ( !(SDL_GetAppState() & SDL_APPACTIVE) ) { /* Send an internal activate event */ posted = SDL_PrivateAppActive(1, SDL_APPACTIVE); /* Now that we're active, swap the gamma back */ X11_SwapVidModeGamma(this); } if ( SDL_VideoSurface && (SDL_VideoSurface->flags & SDL_FULLSCREEN) ) { X11_EnterFullScreen(this); } else { X11_GrabInputNoLock(this, this->input_grab); } X11_CheckMouseModeNoLock(this); if ( SDL_VideoSurface ) { X11_RefreshDisplay(this); } } break; /* Have we been resized or moved? */ case ConfigureNotify: { #ifdef DEBUG_XEVENTS printf("ConfigureNotify! (resize: %dx%d)\n", xevent.xconfigure.width, xevent.xconfigure.height); #endif if ( SDL_VideoSurface ) { if ((xevent.xconfigure.width != SDL_VideoSurface->w) || (xevent.xconfigure.height != SDL_VideoSurface->h)) { /* FIXME: Find a better fix for the bug with KDE 1.2 */ if ( ! ((xevent.xconfigure.width == 32) && (xevent.xconfigure.height == 32)) ) { SDL_PrivateResize(xevent.xconfigure.width, xevent.xconfigure.height); } } else { /* OpenGL windows need to know about the change */ if ( SDL_VideoSurface->flags & (SDL_OPENGL | SDL_OPENGLES) ) { SDL_PrivateExpose(); } } } } break; /* Have we been requested to quit (or another client message?) */ case ClientMessage: { if ( (xevent.xclient.format == 32) && (xevent.xclient.data.l[0] == WM_DELETE_WINDOW) ) { posted = SDL_PrivateQuit(); } else if ( SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE ) { SDL_SysWMmsg wmmsg; SDL_VERSION(&wmmsg.version); wmmsg.subsystem = SDL_SYSWM_X11; wmmsg.event.xevent = xevent; posted = SDL_PrivateSysWMEvent(&wmmsg); } } break; /* Do we need to refresh ourselves? */ case Expose: { #ifdef DEBUG_XEVENTS printf("Expose (count = %d)\n", xevent.xexpose.count); #endif if ( SDL_VideoSurface && (xevent.xexpose.count == 0) ) { X11_RefreshDisplay(this); } } break; default: { #ifdef DEBUG_XEVENTS printf("Unhandled event %d\n", xevent.type); #endif /* Only post the event if we're watching for it */ if ( SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE ) { SDL_SysWMmsg wmmsg; SDL_VERSION(&wmmsg.version); wmmsg.subsystem = SDL_SYSWM_X11; wmmsg.event.xevent = xevent; posted = SDL_PrivateSysWMEvent(&wmmsg); } } break; } return(posted); }