static int DGA_DispatchEvent(_THIS) { int posted; SDL_NAME(XDGAEvent) xevent; XNextEvent(DGA_Display, (XEvent *)&xevent); posted = 0; xevent.type -= DGA_event_base; switch (xevent.type) { /* Mouse motion? */ case MotionNotify: { if ( SDL_VideoSurface ) { posted = SDL_PrivateMouseMotion(0, 1, xevent.xmotion.dx, xevent.xmotion.dy); } } 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 or release? */ case KeyPress: case KeyRelease: { SDL_keysym keysym; XKeyEvent xkey; SDL_NAME(XDGAKeyEventToXKeyEvent)(&xevent.xkey, &xkey); posted = SDL_PrivateKeyboard((xevent.type == KeyPress), X11_TranslateKey(DGA_Display, &xkey, xkey.keycode, &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); }