From b97ca87ea9a57ff2c0c90cd574fe8a86becb7002 Mon Sep 17 00:00:00 2001 From: Szymon Wilczek Date: Wed, 2 Jul 2008 20:29:29 +0000 Subject: [PATCH] Proximity events and evil-temporary makefile repair --- configure.in | 2 ++ include/SDL_events.h | 20 ++++++++++++++++---- src/events/SDL_mouse.c | 18 ++++++++++++++++++ src/video/x11/SDL_x11events.c | 13 +++++++++++++ src/video/x11/SDL_x11video.c | 15 +++++++++++---- 5 files changed, 60 insertions(+), 8 deletions(-) diff --git a/configure.in b/configure.in index 33f9b1b42..860ed6da7 100644 --- a/configure.in +++ b/configure.in @@ -1033,6 +1033,8 @@ AC_HELP_STRING([--enable-x11-shared], [dynamically load X11 support [[default=ma SOURCES="$SOURCES $srcdir/src/video/Xext/XmuStdCmap/*.c" EXTRA_CFLAGS="$EXTRA_CFLAGS $X_CFLAGS" + enable_x11_shared=no + if test x$enable_x11_shared = xmaybe; then enable_x11_shared=$x11_symbols_private fi diff --git a/include/SDL_events.h b/include/SDL_events.h index 5792cd569..347370abc 100644 --- a/include/SDL_events.h +++ b/include/SDL_events.h @@ -72,9 +72,11 @@ typedef enum SDL_JOYBUTTONUP, /**< Joystick button released */ SDL_QUIT, /**< User-requested quit */ SDL_SYSWMEVENT, /**< System specific event */ + SDL_PROXIMITYIN, /**< Proximity In event */ + SDL_PROXIMITYOUT, /**< Proximity Out event */ SDL_EVENT_RESERVED1, /**< Reserved for future use... */ - SDL_EVENT_RESERVED2, /**< Reserved for future use... */ - SDL_EVENT_RESERVED3, /**< Reserved for future use... */ + SDL_EVENT_RESERVED2, + SDL_EVENT_RESERVED3, /* Events SDL_USEREVENT through SDL_MAXEVENTS-1 are for your use */ SDL_USEREVENT = 24, /* This last event is only for bounding internal arrays @@ -112,7 +114,9 @@ typedef enum SDL_EVENTMASK(SDL_JOYHATMOTION) | SDL_EVENTMASK(SDL_JOYBUTTONDOWN) | SDL_EVENTMASK(SDL_JOYBUTTONUP), SDL_QUITMASK = SDL_EVENTMASK(SDL_QUIT), - SDL_SYSWMEVENTMASK = SDL_EVENTMASK(SDL_SYSWMEVENT) + SDL_SYSWMEVENTMASK = SDL_EVENTMASK(SDL_SYSWMEVENT), + SDL_PROXIMITYINMASK = SDL_EVENTMASK(SDL_PROXIMITYIN), + SDL_PROXIMITYOUTMASK = SDL_EVENTMASK(SDL_PROXIMITYOUT) } SDL_EventMask; #define SDL_ALLEVENTS 0xFFFFFFFF @@ -317,6 +321,14 @@ typedef struct SDL_ResizeEvent int h; } SDL_ResizeEvent; +typedef struct SDL_ProximityEvent +{ + Uint8 which; + Uint8 type; + int x; + int y; +} SDL_ProximityEvent; + /** * \union SDL_Event * @@ -338,7 +350,7 @@ typedef union SDL_Event SDL_QuitEvent quit; /**< Quit request event data */ SDL_UserEvent user; /**< Custom event data */ SDL_SysWMEvent syswm; /**< System dependent window event data */ - + SDL_ProximityEvent proximity; /**< Proximity In or Out event */ /* Temporarily here for backwards compatibility */ SDL_ActiveEvent active; SDL_ResizeEvent resize; diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c index 05acacf3e..89a1dee51 100644 --- a/src/events/SDL_mouse.c +++ b/src/events/SDL_mouse.c @@ -318,6 +318,24 @@ SDL_SetMouseFocus(int id, SDL_WindowID windowID) } } +int +SDL_SendProximity(int id, int x, int y, int type) +{ + int index=SDL_GetIndexById(id); + int posted=0; + if(SDL_ProcessEvents[type]==SDL_ENABLE) + { + SDL_Event event; + event.proximity.which=index; + event.proximity.x=x; + event.proximity.y=y; + event.type=type; + event.proximity.type=type; + posted = (SDL_PushEvent(&event) > 0); + } + return posted; +} + int SDL_SendMouseMotion(int id, int relative, int x, int y,int z) { diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index 376cd5912..29fde2c79 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -35,6 +35,9 @@ extern int motion; extern int button_pressed; extern int button_released; +extern int proximity_in; +extern int proximity_out; + static void X11_DispatchEvent(_THIS) @@ -315,6 +318,16 @@ X11_DispatchEvent(_THIS) SDL_SendMouseButton(released->deviceid, SDL_RELEASED, released->button); } + else if(xevent.type==proximity_in) + { + XProximityNotifyEvent* proximity = (XProximityNotifyEvent*)&xevent; + SDL_SendProximity(proximity->deviceid, proximity->x, proximity->y,SDL_PROXIMITYIN); + } + else if(xevent.type==proximity_out) + { + XProximityNotifyEvent* proximity = (XProximityNotifyEvent*)&xevent; + SDL_SendProximity(proximity->deviceid, proximity->x, proximity->y,SDL_PROXIMITYOUT); + } else { #ifdef DEBUG_XEVENTS diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c index 3f18dae03..35347a3ef 100644 --- a/src/video/x11/SDL_x11video.c +++ b/src/video/x11/SDL_x11video.c @@ -35,6 +35,7 @@ int SDL_NumOfXDevices; XEventClass SDL_XEvents[256]; int SDL_NumOfXEvents; int motion, button_pressed, button_released; +int proximity_in, proximity_out; /* Initialization/Query functions */ static int X11_VideoInit(_THIS); @@ -277,17 +278,23 @@ X11_VideoInit(_THIS) /* proximity events */ ProximityIn(SDL_XDevices[i],c_not_needed,xEvent); - if (xEvent) SDL_XEvents[index++] = xEvent; + if (xEvent) + { + SDL_XEvents[index++] = xEvent; + proximity_in=c_not_needed; + } ProximityOut(SDL_XDevices[i],c_not_needed,xEvent); - if (xEvent) SDL_XEvents[index++] = xEvent; - + if (xEvent) + { + SDL_XEvents[index++] = xEvent; + proximity_out=c_not_needed; + } /* motion events */ DeviceMotionNotify(SDL_XDevices[i],c_not_needed,xEvent); if (xEvent) { SDL_XEvents[index++] = xEvent; motion=c_not_needed; - //printf("motion: %d", c_not_needed); } /* device state */