void ph_UpdateMouse(_THIS) { PhCursorInfo_t phcursor; short abs_x; short abs_y; /* Lock the event thread, in multi-threading environments */ SDL_Lock_EventThread(); /* synchronizing photon mouse cursor position and SDL mouse position, if cursor appears over window. */ PtGetAbsPosition(window, &abs_x, &abs_y); PhQueryCursor(PhInputGroup(NULL), &phcursor); if (((phcursor.pos.x >= abs_x) && (phcursor.pos.x <= abs_x + this->screen->w)) && ((phcursor.pos.y >= abs_y) && (phcursor.pos.y <= abs_y + this->screen->h))) { SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); SDL_PrivateMouseMotion(0, 0, phcursor.pos.x-abs_x, phcursor.pos.y-abs_y); } else { SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); } /* Unlock the event thread, in multi-threading environments */ SDL_Unlock_EventThread(); }
// Update the current mouse state and position static void NX_UpdateMouse (_THIS) { int x, y ; GR_WINDOW_INFO info ; GR_SCREEN_INFO si ; Dprintf ("enter NX_UpdateMouse\n") ; // Lock the event thread, in multi-threading environments SDL_Lock_EventThread () ; GrGetScreenInfo (& si) ; GrGetWindowInfo (SDL_Window, & info) ; x = si.xpos - info.x ; y = si.ypos - info.y ; if (x >= 0 && x <= info.width && y >= 0 && y <= info.height) { SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS) ; SDL_PrivateMouseMotion (0, 0, x, y); } else { SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS) ; } SDL_Unlock_EventThread () ; Dprintf ("leave NX_UpdateMouse\n") ; }
JNIEXPORT void JNICALL JAVA_EXPORT_NAME(DemoRenderer_nativeGlContextRecreated) ( JNIEnv* env, jobject thiz ) { __android_log_print(ANDROID_LOG_INFO, "libSDL", "OpenGL context recreated, sending SDL_ACTIVEEVENT"); SDL_PrivateAppActive(1, SDL_APPACTIVE|SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS); }
LOCAL_C TInt FocusGainedEvent(_THIS) { Private->iFlags |= EFocusedWindow; DisableKeyBlocking(_this); //Markus: guess why:-) EpocSdlEnv::ResumeDsa(); SDL_PauseAudio(0); return SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS); }
static int do_messages(_THIS, short *message) { int quit, posted; quit=0; switch (message[0]) { case WM_CLOSED: case AP_TERM: posted = SDL_PrivateQuit(); quit=1; break; case WM_MOVED: wind_set(message[3],WF_CURRXYWH,message[4],message[5],message[6],message[7]); break; case WM_TOPPED: wind_set(message[3],WF_TOP,message[4],0,0,0); SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS); break; case WM_REDRAW: GEM_wind_redraw(this, message[3],&message[4]); break; case WM_ICONIFY: case WM_ALLICONIFY: wind_set(message[3],WF_ICONIFY,message[4],message[5],message[6],message[7]); /* If we're active, make ourselves inactive */ if ( SDL_GetAppState() & SDL_APPACTIVE ) { /* Send an internal deactivate event */ SDL_PrivateAppActive(0, SDL_APPACTIVE|SDL_APPINPUTFOCUS); } /* Update window title */ if (GEM_refresh_name && GEM_icon_name) { wind_set(GEM_handle,WF_NAME,(short)(((unsigned long)GEM_icon_name)>>16),(short)(((unsigned long)GEM_icon_name) & 0xffff),0,0); GEM_refresh_name = SDL_FALSE; } break; case WM_UNICONIFY: wind_set(message[3],WF_UNICONIFY,message[4],message[5],message[6],message[7]); /* If we're not active, make ourselves active */ if ( !(SDL_GetAppState() & SDL_APPACTIVE) ) { /* Send an internal activate event */ SDL_PrivateAppActive(1, SDL_APPACTIVE); } if (GEM_refresh_name && GEM_title_name) { wind_set(GEM_handle,WF_NAME,(short)(((unsigned long)GEM_title_name)>>16),(short)(((unsigned long)GEM_title_name) & 0xffff),0,0); GEM_refresh_name = SDL_FALSE; }
/* Update the current mouse state and position */ void WIN_UpdateMouse(_THIS) { RECT rect; POINT pt; if ( ! DDRAW_FULLSCREEN() ) { GetClientRect(SDL_Window, &rect); GetCursorPos(&pt); MapWindowPoints(NULL, SDL_Window, &pt, 1); if (PtInRect(&rect, pt) && (WindowFromPoint(pt) == SDL_Window)){ SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); SDL_PrivateMouseMotion(0,0, (Sint16)pt.x, (Sint16)pt.y); } else { SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); } } }
extern void SDL_ANDROID_MainThreadPushAppActive(int active) { #if SDL_VERSION_ATLEAST(1,3,0) //if( ANDROID_CurrentWindow ) // SDL_SendWindowEvent(ANDROID_CurrentWindow, SDL_WINDOWEVENT_MINIMIZED, 0, 0); #else SDL_PrivateAppActive(active, SDL_APPACTIVE|SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS); #endif }
LOCAL_C TInt FocusLostEvent(_THIS) { Private->iFlags &= ~EFocusedWindow; SDL_PauseAudio(1); if(EpocSdlEnv::Flags(CSDL::EEnableFocusStop)) { EpocSdlEnv::WaitDsaAvailable(); } return SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS); }
JNIEXPORT void JNICALL JAVA_EXPORT_NAME(DemoRenderer_nativeGlContextRecreated) ( JNIEnv* env, jobject thiz ) { __android_log_print(ANDROID_LOG_INFO, "libSDL", "OpenGL context recreated, sending SDL_ACTIVEEVENT"); #if SDL_VERSION_ATLEAST(1,3,0) //if( ANDROID_CurrentWindow ) // SDL_SendWindowEvent(ANDROID_CurrentWindow, SDL_WINDOWEVENT_RESTORED, 0, 0); #else SDL_PrivateAppActive(1, SDL_APPACTIVE|SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS); #endif }
JNIEXPORT void JNICALL JAVA_EXPORT_NAME(DemoRenderer_nativeGlContextLost) ( JNIEnv* env, jobject thiz ) { __android_log_print(ANDROID_LOG_INFO, "libSDL", "OpenGL context lost, waiting for new OpenGL context"); glContextLost = 1; appPutToBackgroundCallback(); SDL_PrivateAppActive(0, SDL_APPACTIVE|SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS); SDL_ANDROID_VideoContextLost(); }
/* Update the current mouse state and position */ void WIN_UpdateMouse(_THIS) { POINT pt; /* Always unset SDL_APPMOUSEFOCUS to give the WM_MOUSEMOVE event * handler a chance to install a TRACKMOUSEEVENT */ SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); GetCursorPos(&pt); ScreenToClient(SDL_Window, &pt); SDL_PrivateMouseMotion(0,0, (Sint16)pt.x, (Sint16)pt.y); }
JNIEXPORT void JNICALL JAVA_EXPORT_NAME(MediaPlayer_nativeGlContextLost) ( JNIEnv* env, jobject thiz ) { __android_log_print(ANDROID_LOG_INFO, "libSDL", "OpenGL context lost, waiting for new OpenGL context"); glContextLost = 1; appPutToBackgroundCallback(); #if SDL_VERSION_ATLEAST(1,3,0) if( ANDROID_CurrentWindow ) SDL_SendWindowEvent(ANDROID_CurrentWindow, SDL_WINDOWEVENT_MINIMIZED, 0, 0); #else SDL_PrivateAppActive(0, SDL_APPACTIVE|SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS); #endif SDL_ANDROID_VideoContextLost(); }
int EPOC_HandleWsEvent(_THIS, const TWsEvent& aWsEvent) { int posted = 0; SDL_keysym keysym; // SDL_TRACE1("hws %d", aWsEvent.Type()); switch (aWsEvent.Type()) { case EEventPointer: /* Mouse pointer events */ { /* const TPointerCursorMode mode = EpocSdlEnv::PointerMode(); if(mode == EPointerCursorNone) { return 0; //TODO: Find out why events are get despite of cursor should be off } */ const TPointerEvent* pointerEvent = aWsEvent.Pointer(); const TPoint mousePos = EpocSdlEnv::WindowCoordinates(pointerEvent->iPosition); /*!! TODO Pointer do not yet work properly //SDL_TRACE1("SDL: EPOC_HandleWsEvent, pointerEvent->iType=%d", pointerEvent->iType); //!! if (Private->EPOC_ShrinkedHeight) { mousePos.iY <<= 1; // Scale y coordinate to shrinked screen height } if (Private->EPOC_ShrinkedWidth) { mousePos.iX <<= 1; // Scale x coordinate to shrinked screen width } */ posted += SDL_PrivateMouseMotion(0, 0, mousePos.iX, mousePos.iY); /* Absolute position on screen */ switch (pointerEvent->iType) { case TPointerEvent::EButton1Down: posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT, 0, 0); break; case TPointerEvent::EButton1Up: posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT, 0, 0); break; case TPointerEvent::EButton2Down: posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_RIGHT, 0, 0); break; case TPointerEvent::EButton2Up: posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_RIGHT, 0, 0); break; case TPointerEvent::EButton3Down: posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_MIDDLE, 0, 0); break; case TPointerEvent::EButton3Up: posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_MIDDLE, 0, 0); break; } // switch break; } case EEventKeyDown: /* Key events */ { #ifdef SYMBIAN_CRYSTAL // special case: 9300/9500 rocker down, simulate left mouse button if (aWsEvent.Key()->iScanCode == EStdKeyDeviceA) { const TPointerCursorMode mode = Private->EPOC_WsSession.PointerCursorMode(); if(mode != EPointerCursorNone) posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT, 0, 0); } #endif (void*)TranslateKey(_this, aWsEvent.Key()->iScanCode, &keysym); #ifndef DISABLE_JOYSTICK /* Special handling */ switch((int)keysym.sym) { case SDLK_CAPSLOCK: if (!isCursorVisible) { /* Enable virtual cursor */ HAL::Set(HAL::EMouseState, HAL::EMouseState_Visible); } else { /* Disable virtual cursor */ HAL::Set(HAL::EMouseState, HAL::EMouseState_Invisible); } isCursorVisible = !isCursorVisible; break; } #endif posted += SDL_PrivateKeyboard(SDL_PRESSED, &keysym); break; } case EEventKeyUp: /* Key events */ { #ifdef SYMBIAN_CRYSTAL // special case: 9300/9500 rocker up, simulate left mouse button if (aWsEvent.Key()->iScanCode == EStdKeyDeviceA) { posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT, 0, 0); } #endif posted += SDL_PrivateKeyboard(SDL_RELEASED, TranslateKey(_this, aWsEvent.Key()->iScanCode, &keysym)); break; } case EEventFocusGained: /* SDL window got focus */ { Private->iIsWindowFocused = ETrue; posted += SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS); /* Draw window background and screen buffer */ DisableKeyBlocking(_this); //Markus: guess why:-) //RedrawWindowL(_this); break; } case EEventFocusLost: /* SDL window lost focus */ { Private->iIsWindowFocused = EFalse; posted += SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS); break; } case EEventModifiersChanged: { TModifiersChangedEvent* modEvent = aWsEvent.ModifiersChanged(); TUint modstate = KMOD_NONE; if (modEvent->iModifiers == EModifierLeftShift) modstate |= KMOD_LSHIFT; if (modEvent->iModifiers == EModifierRightShift) modstate |= KMOD_RSHIFT; if (modEvent->iModifiers == EModifierLeftCtrl) modstate |= KMOD_LCTRL; if (modEvent->iModifiers == EModifierRightCtrl) modstate |= KMOD_RCTRL; if (modEvent->iModifiers == EModifierLeftAlt) modstate |= KMOD_LALT; if (modEvent->iModifiers == EModifierRightAlt) modstate |= KMOD_RALT; if (modEvent->iModifiers == EModifierLeftFunc) modstate |= KMOD_LMETA; if (modEvent->iModifiers == EModifierRightFunc) modstate |= KMOD_RMETA; if (modEvent->iModifiers == EModifierCapsLock) modstate |= KMOD_CAPS; SDL_SetModState(STATIC_CAST(SDLMod,(modstate | KMOD_LSHIFT))); break; } case EEventScreenDeviceChanged: { EpocSdlEnv::WaitDeviceChange(); } break; default: break; } return posted; }
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) ; } }
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); }
int EPOC_HandleWsEvent(_THIS, const TWsEvent& aWsEvent) { int posted = 0; SDL_keysym keysym; // SDL_TRACE1("hws %d", aWsEvent.Type()); switch (aWsEvent.Type()) { case EEventPointer: /* Mouse pointer events */ { const TPointerCursorMode mode = Private->EPOC_WsSession.PointerCursorMode(); if(mode == EPointerCursorNone) { return 0; //TODO: Find out why events are get despite of cursor should be off } const TPointerEvent* pointerEvent = aWsEvent.Pointer(); TPoint mousePos = pointerEvent->iPosition; /*!! TODO Pointer do not yet work properly //SDL_TRACE1("SDL: EPOC_HandleWsEvent, pointerEvent->iType=%d", pointerEvent->iType); //!! if (Private->EPOC_ShrinkedHeight) { mousePos.iY <<= 1; // Scale y coordinate to shrinked screen height } if (Private->EPOC_ShrinkedWidth) { mousePos.iX <<= 1; // Scale x coordinate to shrinked screen width } */ posted += SDL_PrivateMouseMotion(0, 0, mousePos.iX, mousePos.iY); /* Absolute position on screen */ switch (pointerEvent->iType) { case TPointerEvent::EButton1Down: posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT, 0, 0); break; case TPointerEvent::EButton1Up: posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT, 0, 0); break; case TPointerEvent::EButton2Down: posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_RIGHT, 0, 0); break; case TPointerEvent::EButton2Up: posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_RIGHT, 0, 0); break; case TPointerEvent::EButton3Down: posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_MIDDLE, 0, 0); break; case TPointerEvent::EButton3Up: posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_MIDDLE, 0, 0); break; } // switch break; } case EEventKeyDown: /* Key events */ { #ifdef SYMBIAN_CRYSTAL // special case: 9300/9500 rocker down, simulate left mouse button if (aWsEvent.Key()->iScanCode == EStdKeyDeviceA) { const TPointerCursorMode mode = Private->EPOC_WsSession.PointerCursorMode(); if(mode != EPointerCursorNone) posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT, 0, 0); } #endif (void*)TranslateKey(_this, aWsEvent.Key()->iScanCode, &keysym); #ifndef DISABLE_JOYSTICK /* Special handling */ switch((int)keysym.sym) { case SDLK_CAPSLOCK: if (!isCursorVisible) { /* Enable virtual cursor */ HAL::Set(HAL::EMouseState, HAL::EMouseState_Visible); } else { /* Disable virtual cursor */ HAL::Set(HAL::EMouseState, HAL::EMouseState_Invisible); } isCursorVisible = !isCursorVisible; break; } #endif posted += SDL_PrivateKeyboard(SDL_PRESSED, &keysym); break; } case EEventKeyUp: /* Key events */ { #ifdef SYMBIAN_CRYSTAL // special case: 9300/9500 rocker up, simulate left mouse button if (aWsEvent.Key()->iScanCode == EStdKeyDeviceA) { posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT, 0, 0); } #endif posted += SDL_PrivateKeyboard(SDL_RELEASED, TranslateKey(_this, aWsEvent.Key()->iScanCode, &keysym)); break; } case EEventFocusGained: /* SDL window got focus */ { Private->EPOC_IsWindowFocused = ETrue; posted += SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS); /* Draw window background and screen buffer */ DisableKeyBlocking(_this); //Markus: guess why:-) RedrawWindowL(_this); break; } case EEventFocusLost: /* SDL window lost focus */ { /* CFbsBitmap* bmp = new (ELeave) CFbsBitmap(); bmp->Create(Private->EPOC_ScreenSize, Private->EPOC_DisplayMode); Private->EPOC_WsScreen->CopyScreenToBitmap(bmp); Private->EPOC_WindowGc->Activate(Private->EPOC_WsWindow); Private->EPOC_WsWindow.BeginRedraw(TRect(Private->EPOC_WsWindow.Size())); Private->EPOC_WindowGc->BitBlt(TPoint(0, 0), bmp); Private->EPOC_WsWindow.EndRedraw(); Private->EPOC_WindowGc->Deactivate(); bmp->Save(_L("C:\\scr.mbm")); delete bmp; */ Private->EPOC_IsWindowFocused = EFalse; posted += SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS); RWsSession s; s.Connect(); RWindowGroup g(s); g.Construct(TUint32(&g), EFalse); g.EnableReceiptOfFocus(EFalse); RWindow w(s); w.Construct(g, TUint32(&w)); w.SetExtent(TPoint(0, 0), Private->EPOC_WsWindow.Size()); w.SetOrdinalPosition(0); w.Activate(); w.Close(); g.Close(); s.Close(); /* Private->EPOC_WsSession.SetWindowGroupOrdinalPosition(Private->EPOC_WsWindowGroupID, -1); SDL_Delay(500); TInt focus = -1; while(focus < 0) { const TInt curr = Private->EPOC_WsSession.GetFocusWindowGroup(); if(curr != Private->EPOC_WsWindowGroupID) focus = curr; else SDL_Delay(500); } if(1 < Private->EPOC_WsSession.GetWindowGroupOrdinalPriority(Private->EPOC_WsWindowGroupID)) { Private->EPOC_WsSession.SetWindowGroupOrdinalPosition(focus, -1); SDL_Delay(500); Private->EPOC_WsSession.SetWindowGroupOrdinalPosition(focus, 0); } */ /*//and the request redraw TRawEvent redrawEvent; redrawEvent.Set(TRawEvent::ERedraw); Private->EPOC_WsSession.SimulateRawEvent(redrawEvent); Private->EPOC_WsSession.Flush();*/ #if 0 //!! Not used // Wait and eat events until focus is gained again while (ETrue) { Private->EPOC_WsSession.EventReady(&Private->EPOC_WsEventStatus); User::WaitForRequest(Private->EPOC_WsEventStatus); Private->EPOC_WsSession.GetEvent(Private->EPOC_WsEvent); TInt eventType = Private->EPOC_WsEvent.Type(); Private->EPOC_WsEventStatus = KRequestPending; //Private->EPOC_WsSession.EventReady(&Private->EPOC_WsEventStatus); if (eventType == EEventFocusGained) { RedrawWindowL(_this); break; } } #endif break; } case EEventModifiersChanged: { TModifiersChangedEvent* modEvent = aWsEvent.ModifiersChanged(); TUint modstate = KMOD_NONE; if (modEvent->iModifiers == EModifierLeftShift) modstate |= KMOD_LSHIFT; if (modEvent->iModifiers == EModifierRightShift) modstate |= KMOD_RSHIFT; if (modEvent->iModifiers == EModifierLeftCtrl) modstate |= KMOD_LCTRL; if (modEvent->iModifiers == EModifierRightCtrl) modstate |= KMOD_RCTRL; if (modEvent->iModifiers == EModifierLeftAlt) modstate |= KMOD_LALT; if (modEvent->iModifiers == EModifierRightAlt) modstate |= KMOD_RALT; if (modEvent->iModifiers == EModifierLeftFunc) modstate |= KMOD_LMETA; if (modEvent->iModifiers == EModifierRightFunc) modstate |= KMOD_RMETA; if (modEvent->iModifiers == EModifierCapsLock) modstate |= KMOD_CAPS; SDL_SetModState(STATIC_CAST(SDLMod,(modstate | KMOD_LSHIFT))); break; } default: break; } return posted; }
/* We need our own event queue, because Free Heroes 2 game uses * SDL_SetEventFilter(), and it calls SDL_Flip() from inside * it's custom filter function, and SDL_Flip() does not work * when it's not called from the main() thread. * So we, like, push the events into our own queue, * read each event from that queue inside SDL_ANDROID_PumpEvents(), * unlock the mutex, and push the event to SDL queue, * which is then immediately read by SDL from the same thread, * and then SDL invokes event filter function from FHeroes2. * FHeroes2 call SDL_Flip() from inside that event filter function, * and it works, because it is called from the main() thread. */ extern void SDL_ANDROID_PumpEvents() { static int oldMouseButtons = 0; SDL_Event ev; SDL_ANDROID_processAndroidTrackballDampening(); SDL_ANDROID_processMoveMouseWithKeyboard(); #if SDL_VERSION_ATLEAST(1,3,0) SDL_Window * window = SDL_GetFocusWindow(); if( !window ) return; #endif if( !BufferedEventsMutex ) BufferedEventsMutex = SDL_CreateMutex(); SDL_mutexP(BufferedEventsMutex); while( BufferedEventsStart != BufferedEventsEnd ) { ev = BufferedEvents[BufferedEventsStart]; BufferedEvents[BufferedEventsStart].type = 0; BufferedEventsStart++; if( BufferedEventsStart >= MAX_BUFFERED_EVENTS ) BufferedEventsStart = 0; SDL_mutexV(BufferedEventsMutex); switch( ev.type ) { case SDL_MOUSEMOTION: SDL_SendMouseMotion( ANDROID_CurrentWindow, 0, ev.motion.x, ev.motion.y ); break; case SDL_MOUSEBUTTONDOWN: if( ((oldMouseButtons & SDL_BUTTON(ev.button.button)) != 0) != ev.button.state ) { oldMouseButtons = (oldMouseButtons & ~SDL_BUTTON(ev.button.button)) | (ev.button.state ? SDL_BUTTON(ev.button.button) : 0); SDL_SendMouseButton( ANDROID_CurrentWindow, ev.button.state, ev.button.button ); } break; case SDL_KEYDOWN: //__android_log_print(ANDROID_LOG_INFO, "libSDL", "SDL_KEYDOWN: %i %i", ev->key.keysym.sym, ev->key.state); SDL_SendKeyboardKey( ev.key.state, &ev.key.keysym ); break; case SDL_JOYAXISMOTION: if( ev.jaxis.which < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[ev.jaxis.which] ) SDL_PrivateJoystickAxis( SDL_ANDROID_CurrentJoysticks[ev.jaxis.which], ev.jaxis.axis, ev.jaxis.value ); break; case SDL_JOYBUTTONDOWN: if( ev.jbutton.which < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[ev.jbutton.which] ) SDL_PrivateJoystickButton( SDL_ANDROID_CurrentJoysticks[ev.jbutton.which], ev.jbutton.button, ev.jbutton.state ); break; case SDL_JOYBALLMOTION: if( ev.jball.which < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[ev.jbutton.which] ) SDL_PrivateJoystickBall( SDL_ANDROID_CurrentJoysticks[ev.jball.which], ev.jball.ball, ev.jball.xrel, ev.jball.yrel ); break; #if SDL_VERSION_ATLEAST(1,3,0) //if( ANDROID_CurrentWindow ) // SDL_SendWindowEvent(ANDROID_CurrentWindow, SDL_WINDOWEVENT_MINIMIZED, 0, 0); #else case SDL_ACTIVEEVENT: SDL_PrivateAppActive(ev.active.gain, ev.active.state); break; #endif #if SDL_VERSION_ATLEAST(1,3,0) case SDL_FINGERMOTION: SDL_SendTouchMotion(0, ev.tfinger.fingerId, 0, (float)ev.tfinger.x / (float)window->w, (float)ev.tfinger.y / (float)window->h, ev.tfinger.pressure); break; case SDL_FINGERDOWN: SDL_SendFingerDown(0, ev.tfinger.fingerId, ev.tfinger.state ? 1 : 0, (float)ev.tfinger.x / (float)window->w, (float)ev.tfinger.y / (float)window->h, ev.tfinger.pressure); break; case SDL_TEXTINPUT: SDL_SendKeyboardText(ev.text.text); break; case SDL_MOUSEWHEEL: SDL_SendMouseWheel( ANDROID_CurrentWindow, ev.wheel.x, ev.wheel.y ); break; #endif } SDL_mutexP(BufferedEventsMutex); } SDL_mutexV(BufferedEventsMutex); };
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); }
void WIMP_Poll(_THIS, int waitTime) { _kernel_swi_regs regs; int message[64]; unsigned int code; int pollMask = 0; int doPoll = 1; int sysEvent; int sdlWindow = this->hidden->window_handle; if (this->PumpEvents != WIMP_PumpEvents) return; if (waitTime > 0) { _kernel_swi(OS_ReadMonotonicTime, ®s, ®s); waitTime += regs.r[0]; } while (doPoll) { if (waitTime <= 0) { regs.r[0] = pollMask; /* Poll Mask */ /* For no wait time mask out null event so we wait until something happens */ if (waitTime < 0) regs.r[0] |= 1; regs.r[1] = (int)message; _kernel_swi(Wimp_Poll, ®s, ®s); } else { regs.r[0] = pollMask; regs.r[1] = (int)message; regs.r[2] = waitTime; _kernel_swi(Wimp_PollIdle, ®s, ®s); } /* Flag to specify if we post a SDL_SysWMEvent */ sysEvent = 0; code = (unsigned int)regs.r[0]; switch(code) { case 0: /* Null Event - drop out for standard processing*/ doPoll = 0; break; case 1: /* Redraw window */ _kernel_swi(Wimp_RedrawWindow, ®s,®s); if (message[0] == sdlWindow) { while (regs.r[0]) { WIMP_PlotSprite(this, message[1], message[2]); _kernel_swi(Wimp_GetRectangle, ®s, ®s); } } else { /* TODO: Currently we just eat them - we may need to pass them on */ while (regs.r[0]) { _kernel_swi(Wimp_GetRectangle, ®s, ®s); } } break; case 2: /* Open window */ if ( resizeOnOpen && message[0] == sdlWindow) { /* Ensure window is correct size */ resizeOnOpen = 0; message[3] = message[1] + (this->screen->w << this->hidden->xeig); message[4] = message[2] + (this->screen->h << this->hidden->yeig); } _kernel_swi(Wimp_OpenWindow, ®s, ®s); break; case 3: /* Close window */ if (message[0] == sdlWindow) { /* Documentation makes it looks as if the following line is correct: ** if (SDL_PrivateQuit() == 1) _kernel_swi(Wimp_CloseWindow, ®s, ®s); ** However some programs don't process this message and so sit there invisibly ** in the background so I just post the quit message and hope the application ** does the correct thing. */ SDL_PrivateQuit(); } else sysEvent = 1; doPoll = 0; break; case 4: /* Pointer_Leaving_Window */ if (message[0] == sdlWindow) { mouseInWindow = 0; //TODO: Lose buttons / dragging /* Reset to default pointer */ regs.r[0] = 106; regs.r[1] = 1; regs.r[2] = 0; _kernel_swi(OS_Byte, ®s, ®s); SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); } else sysEvent = 1; break; case 5: /* Pointer_Entering_Window */ if (message[0] == sdlWindow) { mouseInWindow = 1; WIMP_ReshowCursor(this); SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); } else sysEvent = 1; break; case 6: /* Mouse_Click */ if (hasFocus == 0) { /* First click gives focus if it's not a menu */ /* we only count non-menu clicks on a window that has the focus */ WIMP_SetFocus(message[3]); } else doPoll = 0; // So PollMouse gets a chance to pick it up break; case 7: /* User_Drag_Box - Used for mouse release */ //TODO: May need to implement this in the future sysEvent = 1; break; case 8: /* Keypressed */ doPoll = 0; /* PollKeyboard should pick it up */ if (message[0] != sdlWindow) sysEvent = 1; /*TODO: May want to always pass F12 etc to the wimp { regs.r[0] = message[6]; _kernel_swi(Wimp_ProcessKey, ®s, ®s); } */ break; case 11: /* Lose Caret */ hasFocus = 0; if (message[0] == sdlWindow) SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS); else sysEvent = 1; break; case 12: /* Gain Caret */ hasFocus = 1; if (message[0] == sdlWindow) SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS); else sysEvent = 1; break; case 17: case 18: sysEvent = 1; /* All messages are passed on */ switch(message[4]) { case 0: /* Quit Event */ /* No choice - have to quit */ SDL_Quit(); exit(0); break; case 8: /* Pre Quit */ SDL_PrivateQuit(); break; case 0x400c1: /* Mode change */ WIMP_ModeChanged(this); resizeOnOpen = 1; break; case 9: /* Palette changed */ WIMP_PaletteChanged(this); break; } break; default: /* Pass unknown events on */ sysEvent = 1; break; } if (sysEvent) { SDL_SysWMmsg wmmsg; SDL_VERSION(&wmmsg.version); wmmsg.eventCode = code; memcpy(wmmsg.pollBlock, message, 64 * sizeof(int)); /* Fall out of polling loop if message is successfully posted */ if (SDL_PrivateSysWMEvent(&wmmsg)) doPoll = 0; } } }