Commit 94846a39 authored by Alexandre Julliard's avatar Alexandre Julliard

Use a table of handlers to dispatch X events and get rid of the

special casing for DGA and tablet events. Unify the declarations of all the event handlers.
parent 729bfb86
......@@ -2940,18 +2940,19 @@ END:
/***********************************************************************
* X11DRV_SelectionRequest
*/
void X11DRV_SelectionRequest( HWND hWnd, XSelectionRequestEvent *event )
void X11DRV_SelectionRequest( HWND hWnd, XEvent *event )
{
if (!hWnd) return;
X11DRV_HandleSelectionRequest( hWnd, event, FALSE );
X11DRV_HandleSelectionRequest( hWnd, &event->xselectionrequest, FALSE );
}
/***********************************************************************
* X11DRV_SelectionClear
*/
void X11DRV_SelectionClear( HWND hWnd, XSelectionClearEvent *event )
void X11DRV_SelectionClear( HWND hWnd, XEvent *xev )
{
XSelectionClearEvent *event = &xev->xselectionclear;
if (!hWnd) return;
if (event->selection == XA_PRIMARY || event->selection == x11drv_atom(CLIPBOARD))
X11DRV_CLIPBOARD_ReleaseSelection( event->selection, event->window, hWnd, event->time );
......
......@@ -42,8 +42,8 @@ extern int usedga;
LPDDHALMODEINFO xf86dga2_modes;
unsigned xf86dga2_mode_count;
HWND DGAhwnd = 0;
static XDGAMode* modes;
static int dga_event, dga_error;
static void convert_mode(XDGAMode *mode, LPDDHALMODEINFO info)
{
......@@ -66,9 +66,58 @@ static int DGA2ErrorHandler(Display *dpy, XErrorEvent *event, void *arg)
return 1;
}
static void X11DRV_DGAKeyPressEvent( HWND hwnd, XEvent *xev )
{
/* Fill a XKeyEvent to send to EVENT_Key */
XDGAKeyEvent *event = (XDGAKeyEvent *)xev;
XEvent ke;
ke.xkey.type = KeyPress;
ke.xkey.serial = event->serial;
ke.xkey.send_event = FALSE;
ke.xkey.display = event->display;
ke.xkey.window = 0;
ke.xkey.root = 0;
ke.xkey.subwindow = 0;
ke.xkey.time = event->time;
ke.xkey.x = -1;
ke.xkey.y = -1;
ke.xkey.x_root = -1;
ke.xkey.y_root = -1;
ke.xkey.state = event->state;
ke.xkey.keycode = event->keycode;
ke.xkey.same_screen = TRUE;
X11DRV_KeyEvent( 0, &ke );
}
static void X11DRV_DGAKeyReleaseEvent( HWND hwnd, XEvent *xev )
{
/* Fill a XKeyEvent to send to EVENT_Key */
XDGAKeyEvent *event = (XDGAKeyEvent *)xev;
XEvent ke;
ke.xkey.type = KeyRelease;
ke.xkey.serial = event->serial;
ke.xkey.send_event = FALSE;
ke.xkey.display = event->display;
ke.xkey.window = 0;
ke.xkey.root = 0;
ke.xkey.subwindow = 0;
ke.xkey.time = event->time;
ke.xkey.x = -1;
ke.xkey.y = -1;
ke.xkey.x_root = -1;
ke.xkey.y_root = -1;
ke.xkey.state = event->state;
ke.xkey.keycode = event->keycode;
ke.xkey.same_screen = TRUE;
X11DRV_KeyEvent( 0, &ke );
}
void X11DRV_XF86DGA2_Init(void)
{
int nmodes, major, minor, i;
int nmodes, major, minor, i, event_base, error_base;
Bool ok;
TRACE("\n");
......@@ -81,7 +130,7 @@ void X11DRV_XF86DGA2_Init(void)
if (!usedga) return;
wine_tsx11_lock();
ok = XDGAQueryExtension(gdi_display, &dga_event, &dga_error);
ok = XDGAQueryExtension(gdi_display, &event_base, &error_base);
if (ok)
{
X11DRV_expect_error(gdi_display, DGA2ErrorHandler, NULL);
......@@ -121,6 +170,13 @@ void X11DRV_XF86DGA2_Init(void)
for (i=0; i<nmodes; i++)
convert_mode(&modes[i], &xf86dga2_modes[i+1]);
/* register event handlers */
X11DRV_register_event_handler( event_base + MotionNotify, X11DRV_DGAMotionEvent );
X11DRV_register_event_handler( event_base + ButtonPress, X11DRV_DGAButtonPressEvent );
X11DRV_register_event_handler( event_base + ButtonRelease, X11DRV_DGAButtonReleaseEvent );
X11DRV_register_event_handler( event_base + KeyPress, X11DRV_DGAKeyPressEvent );
X11DRV_register_event_handler( event_base + KeyRelease, X11DRV_DGAKeyReleaseEvent );
TRACE("Enabling XF86DGA2 mode\n");
}
......@@ -160,8 +216,7 @@ static DWORD PASCAL X11DRV_XF86DGA2_SetMode(LPDDHAL_SETMODEDATA data)
KeyPressMask|KeyReleaseMask|
ButtonPressMask|ButtonReleaseMask|
PointerMotionMask);
X11DRV_EVENT_SetDGAStatus((HWND)ddlocal->hWnd, dga_event);
X11DRV_EVENT_SetInputMethod(X11DRV_INPUT_RELATIVE);
DGAhwnd = (HWND)ddlocal->hWnd;
}
dga_dev = new_dev;
vram = dga_dev->mode.bytesPerScanline * dga_dev->mode.imageHeight;
......@@ -184,8 +239,7 @@ static DWORD PASCAL X11DRV_XF86DGA2_SetMode(LPDDHAL_SETMODEDATA data)
X11DRV_DDHAL_SwitchMode(0, NULL, NULL);
XDGASetMode(display, DefaultScreen(display), 0);
VirtualFree(dga_dev->data, 0, MEM_RELEASE);
X11DRV_EVENT_SetInputMethod(X11DRV_INPUT_ABSOLUTE);
X11DRV_EVENT_SetDGAStatus(0, -1);
DGAhwnd = 0;
XFree(dga_dev);
XDGACloseFramebuffer(display, DefaultScreen(display));
dga_dev = NULL;
......
......@@ -1097,7 +1097,7 @@ inline static void KEYBOARD_UpdateOneState ( int vkey, int state, DWORD time )
* from wine to another application and back.
* Toggle keys are handled in HandleEvent.
*/
void X11DRV_KeymapNotify( HWND hwnd, XKeymapEvent *event )
void X11DRV_KeymapNotify( HWND hwnd, XEvent *event )
{
int i, j, alt, control, shift;
DWORD time = GetCurrentTime();
......@@ -1105,10 +1105,10 @@ void X11DRV_KeymapNotify( HWND hwnd, XKeymapEvent *event )
alt = control = shift = 0;
for (i = 0; i < 32; i++)
{
if (!event->key_vector[i]) continue;
if (!event->xkeymap.key_vector[i]) continue;
for (j = 0; j < 8; j++)
{
if (!(event->key_vector[i] & (1<<j))) continue;
if (!(event->xkeymap.key_vector[i] & (1<<j))) continue;
switch(keyc2vkey[(i * 8) + j] & 0xff)
{
case VK_MENU: alt = 1; break;
......@@ -1127,8 +1127,9 @@ void X11DRV_KeymapNotify( HWND hwnd, XKeymapEvent *event )
*
* Handle a X key event
*/
void X11DRV_KeyEvent( HWND hwnd, XKeyEvent *event )
void X11DRV_KeyEvent( HWND hwnd, XEvent *xev )
{
XKeyEvent *event = &xev->xkey;
char Str[24];
KeySym keysym = 0;
WORD vkey = 0, bScan;
......@@ -1705,12 +1706,12 @@ HKL X11DRV_ActivateKeyboardLayout(HKL hkl, UINT flags)
/***********************************************************************
* X11DRV_MappingNotify
*/
void X11DRV_MappingNotify( XMappingEvent *event )
void X11DRV_MappingNotify( HWND dummy, XEvent *event )
{
HWND hwnd;
wine_tsx11_lock();
XRefreshKeyboardMapping(event);
XRefreshKeyboardMapping(&event->xmapping);
wine_tsx11_unlock();
X11DRV_InitKeyboard( pKeyStateTable );
......
......@@ -536,8 +536,9 @@ void X11DRV_InitMouse( BYTE *key_state_table )
/***********************************************************************
* X11DRV_ButtonPress
*/
void X11DRV_ButtonPress( HWND hwnd, XButtonEvent *event )
void X11DRV_ButtonPress( HWND hwnd, XEvent *xev )
{
XButtonEvent *event = &xev->xbutton;
int buttonNum = event->button - 1;
WORD wData = 0;
POINT pt;
......@@ -566,8 +567,9 @@ void X11DRV_ButtonPress( HWND hwnd, XButtonEvent *event )
/***********************************************************************
* X11DRV_ButtonRelease
*/
void X11DRV_ButtonRelease( HWND hwnd, XButtonEvent *event )
void X11DRV_ButtonRelease( HWND hwnd, XEvent *xev )
{
XButtonEvent *event = &xev->xbutton;
int buttonNum = event->button - 1;
POINT pt;
......@@ -585,8 +587,9 @@ void X11DRV_ButtonRelease( HWND hwnd, XButtonEvent *event )
/***********************************************************************
* X11DRV_MotionNotify
*/
void X11DRV_MotionNotify( HWND hwnd, XMotionEvent *event )
void X11DRV_MotionNotify( HWND hwnd, XEvent *xev )
{
XMotionEvent *event = &xev->xmotion;
POINT pt;
TRACE("hwnd %p, event->is_hint %d\n", hwnd, event->is_hint);
......@@ -604,8 +607,9 @@ void X11DRV_MotionNotify( HWND hwnd, XMotionEvent *event )
/***********************************************************************
* X11DRV_EnterNotify
*/
void X11DRV_EnterNotify( HWND hwnd, XCrossingEvent *event )
void X11DRV_EnterNotify( HWND hwnd, XEvent *xev )
{
XCrossingEvent *event = &xev->xcrossing;
POINT pt;
TRACE("hwnd %p, event->detail %d\n", hwnd, event->detail);
......@@ -623,36 +627,43 @@ void X11DRV_EnterNotify( HWND hwnd, XCrossingEvent *event )
#ifdef HAVE_LIBXXF86DGA2
extern HWND DGAhwnd;
/**********************************************************************
* X11DRV_DGAMotionEvent
*/
void X11DRV_DGAMotionEvent( HWND hwnd, XDGAMotionEvent *event )
void X11DRV_DGAMotionEvent( HWND hwnd, XEvent *xev )
{
XDGAMotionEvent *event = (XDGAMotionEvent *)xev;
update_key_state( event->state );
send_mouse_event( hwnd, MOUSEEVENTF_MOVE, event->dx, event->dy, 0, event->time );
send_mouse_event( DGAhwnd, MOUSEEVENTF_MOVE, event->dx, event->dy, 0, event->time );
}
/**********************************************************************
* X11DRV_DGAButtonPressEvent
*/
void X11DRV_DGAButtonPressEvent( HWND hwnd, XDGAButtonEvent *event )
void X11DRV_DGAButtonPressEvent( HWND hwnd, XEvent *xev )
{
XDGAButtonEvent *event = (XDGAButtonEvent *)xev;
int buttonNum = event->button - 1;
if (buttonNum >= NB_BUTTONS) return;
update_key_state( event->state );
send_mouse_event( hwnd, button_down_flags[buttonNum], 0, 0, 0, event->time );
send_mouse_event( DGAhwnd, button_down_flags[buttonNum], 0, 0, 0, event->time );
}
/**********************************************************************
* X11DRV_DGAButtonReleaseEvent
*/
void X11DRV_DGAButtonReleaseEvent( HWND hwnd, XDGAButtonEvent *event )
void X11DRV_DGAButtonReleaseEvent( HWND hwnd, XEvent *xev )
{
XDGAButtonEvent *event = (XDGAButtonEvent *)xev;
int buttonNum = event->button - 1;
if (buttonNum >= NB_BUTTONS) return;
update_key_state( event->state );
send_mouse_event( hwnd, button_up_flags[buttonNum], 0, 0, 0, event->time );
send_mouse_event( DGAhwnd, button_up_flags[buttonNum], 0, 0, 0, event->time );
}
#endif /* HAVE_LIBXXF86DGA2 */
......@@ -138,8 +138,9 @@ static HWND get_top_clipping_window( HWND hwnd )
/***********************************************************************
* X11DRV_Expose
*/
void X11DRV_Expose( HWND hwnd, XExposeEvent *event )
void X11DRV_Expose( HWND hwnd, XEvent *xev )
{
XExposeEvent *event = &xev->xexpose;
RECT rect;
struct x11drv_win_data *data;
int flags = RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN;
......@@ -1196,7 +1197,7 @@ END:
/**********************************************************************
* X11DRV_MapNotify
*/
void X11DRV_MapNotify( HWND hwnd, XMapEvent *event )
void X11DRV_MapNotify( HWND hwnd, XEvent *event )
{
struct x11drv_win_data *data;
HWND hwndFocus = GetFocus();
......@@ -1216,9 +1217,9 @@ void X11DRV_MapNotify( HWND hwnd, XMapEvent *event )
/* FIXME: hack */
wine_tsx11_lock();
XGetGeometry( event->display, data->whole_window, &root, &x, &y, &width, &height,
XGetGeometry( event->xmap.display, data->whole_window, &root, &x, &y, &width, &height,
&border, &depth );
XTranslateCoordinates( event->display, data->whole_window, root, 0, 0, &x, &y, &top );
XTranslateCoordinates( event->xmap.display, data->whole_window, root, 0, 0, &x, &y, &top );
wine_tsx11_unlock();
rect.left = x;
rect.top = y;
......@@ -1244,7 +1245,7 @@ void X11DRV_MapNotify( HWND hwnd, XMapEvent *event )
/**********************************************************************
* X11DRV_UnmapNotify
*/
void X11DRV_UnmapNotify( HWND hwnd, XUnmapEvent *event )
void X11DRV_UnmapNotify( HWND hwnd, XEvent *event )
{
struct x11drv_win_data *data;
WND *win;
......@@ -1416,14 +1417,16 @@ void X11DRV_handle_desktop_resize( unsigned int width, unsigned int height )
/***********************************************************************
* X11DRV_ConfigureNotify
*/
void X11DRV_ConfigureNotify( HWND hwnd, XConfigureEvent *event )
void X11DRV_ConfigureNotify( HWND hwnd, XEvent *xev )
{
XConfigureEvent *event = &xev->xconfigure;
HWND oldInsertAfter;
struct x11drv_win_data *data;
RECT rect;
WINDOWPOS winpos;
int x = event->x, y = event->y;
if (!hwnd) return;
if (!(data = X11DRV_get_win_data( hwnd ))) return;
/* Get geometry */
......
......@@ -456,36 +456,28 @@ extern Atom X11DRV_Atoms[NB_XATOMS - FIRST_XATOM];
/* X11 event driver */
typedef enum {
X11DRV_INPUT_RELATIVE,
X11DRV_INPUT_ABSOLUTE
} INPUT_TYPE;
extern INPUT_TYPE X11DRV_EVENT_SetInputMethod(INPUT_TYPE type);
extern void X11DRV_ButtonPress( HWND hwnd, XButtonEvent *event );
extern void X11DRV_ButtonRelease( HWND hwnd, XButtonEvent *event );
extern void X11DRV_MotionNotify( HWND hwnd, XMotionEvent *event );
extern void X11DRV_EnterNotify( HWND hwnd, XCrossingEvent *event );
extern void X11DRV_KeyEvent( HWND hwnd, XKeyEvent *event );
extern void X11DRV_KeymapNotify( HWND hwnd, XKeymapEvent *event );
extern void X11DRV_Expose( HWND hwnd, XExposeEvent *event );
extern void X11DRV_MapNotify( HWND hwnd, XMapEvent *event );
extern void X11DRV_UnmapNotify( HWND hwnd, XUnmapEvent *event );
extern void X11DRV_ConfigureNotify( HWND hwnd, XConfigureEvent *event );
extern void X11DRV_SelectionRequest( HWND hWnd, XSelectionRequestEvent *event );
extern void X11DRV_SelectionClear( HWND hWnd, XSelectionClearEvent *event );
extern void X11DRV_MappingNotify( XMappingEvent *event );
#ifdef HAVE_LIBXXF86DGA2
void X11DRV_EVENT_SetDGAStatus(HWND hwnd, int event_base) ;
extern void X11DRV_DGAMotionEvent( HWND hwnd, XDGAMotionEvent *event );
extern void X11DRV_DGAButtonPressEvent( HWND hwnd, XDGAButtonEvent *event );
extern void X11DRV_DGAButtonReleaseEvent( HWND hwnd, XDGAButtonEvent *event );
#endif
typedef void (*x11drv_event_handler)( HWND hwnd, XEvent *event );
extern void X11DRV_register_event_handler( int type, x11drv_event_handler handler );
extern void X11DRV_ButtonPress( HWND hwnd, XEvent *event );
extern void X11DRV_ButtonRelease( HWND hwnd, XEvent *event );
extern void X11DRV_MotionNotify( HWND hwnd, XEvent *event );
extern void X11DRV_EnterNotify( HWND hwnd, XEvent *event );
extern void X11DRV_KeyEvent( HWND hwnd, XEvent *event );
extern void X11DRV_KeymapNotify( HWND hwnd, XEvent *event );
extern void X11DRV_Expose( HWND hwnd, XEvent *event );
extern void X11DRV_MapNotify( HWND hwnd, XEvent *event );
extern void X11DRV_UnmapNotify( HWND hwnd, XEvent *event );
extern void X11DRV_ConfigureNotify( HWND hwnd, XEvent *event );
extern void X11DRV_SelectionRequest( HWND hWnd, XEvent *event );
extern void X11DRV_SelectionClear( HWND hWnd, XEvent *event );
extern void X11DRV_MappingNotify( HWND hWnd, XEvent *event );
extern void X11DRV_DGAMotionEvent( HWND hwnd, XEvent *event );
extern void X11DRV_DGAButtonPressEvent( HWND hwnd, XEvent *event );
extern void X11DRV_DGAButtonReleaseEvent( HWND hwnd, XEvent *event );
extern DWORD EVENT_x11_time_to_win32_time(Time time);
extern int X11DRV_ProcessTabletEvent(HWND hwnd, XEvent *event);
/* x11drv private window data */
struct x11drv_win_data
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment