Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Proximity events and evil-temporary makefile repair
Browse files Browse the repository at this point in the history
  • Loading branch information
Szymon Wilczek committed Jul 2, 2008
1 parent 0f42551 commit b97ca87
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 8 deletions.
2 changes: 2 additions & 0 deletions configure.in
Expand Up @@ -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
Expand Down
20 changes: 16 additions & 4 deletions include/SDL_events.h
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
*
Expand All @@ -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;
Expand Down
18 changes: 18 additions & 0 deletions src/events/SDL_mouse.c
Expand Up @@ -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)
{
Expand Down
13 changes: 13 additions & 0 deletions src/video/x11/SDL_x11events.c
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
15 changes: 11 additions & 4 deletions src/video/x11/SDL_x11video.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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 */
Expand Down

0 comments on commit b97ca87

Please sign in to comment.