1998-12-07 10:13:40 +01:00
|
|
|
/*
|
1998-12-26 13:00:43 +01:00
|
|
|
* X11 mouse driver
|
1998-12-07 10:13:40 +01:00
|
|
|
*
|
1998-12-26 13:00:43 +01:00
|
|
|
* Copyright 1998 Ulrich Weigand
|
2007-03-22 20:06:19 +01:00
|
|
|
* Copyright 2007 Henri Verbeet
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
1998-12-07 10:13:40 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
2007-03-22 20:06:19 +01:00
|
|
|
#include "wine/port.h"
|
1998-12-07 10:13:40 +01:00
|
|
|
|
2003-11-21 22:48:36 +01:00
|
|
|
#include <X11/Xlib.h>
|
2010-10-18 12:16:28 +02:00
|
|
|
#include <X11/cursorfont.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2011-04-13 18:56:37 +02:00
|
|
|
#ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
|
|
|
|
#include <X11/extensions/XInput2.h>
|
|
|
|
#endif
|
1998-12-26 13:00:43 +01:00
|
|
|
|
2007-07-09 22:42:28 +02:00
|
|
|
#ifdef SONAME_LIBXCURSOR
|
2007-03-22 20:06:19 +01:00
|
|
|
# include <X11/Xcursor/Xcursor.h>
|
|
|
|
static void *xcursor_handle;
|
|
|
|
# define MAKE_FUNCPTR(f) static typeof(f) * p##f
|
|
|
|
MAKE_FUNCPTR(XcursorImageCreate);
|
|
|
|
MAKE_FUNCPTR(XcursorImageDestroy);
|
|
|
|
MAKE_FUNCPTR(XcursorImageLoadCursor);
|
2010-10-05 20:06:18 +02:00
|
|
|
MAKE_FUNCPTR(XcursorImagesCreate);
|
|
|
|
MAKE_FUNCPTR(XcursorImagesDestroy);
|
|
|
|
MAKE_FUNCPTR(XcursorImagesLoadCursor);
|
2010-10-18 12:16:28 +02:00
|
|
|
MAKE_FUNCPTR(XcursorLibraryLoadCursor);
|
2007-03-22 20:06:19 +01:00
|
|
|
# undef MAKE_FUNCPTR
|
2007-07-09 22:42:28 +02:00
|
|
|
#endif /* SONAME_LIBXCURSOR */
|
2007-03-22 20:06:19 +01:00
|
|
|
|
2003-01-07 21:36:20 +01:00
|
|
|
#define NONAMELESSUNION
|
2010-10-18 12:16:28 +02:00
|
|
|
#define OEMRESOURCE
|
2001-01-15 23:30:50 +01:00
|
|
|
#include "windef.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "winbase.h"
|
2010-10-18 12:26:28 +02:00
|
|
|
#include "winreg.h"
|
2001-01-15 23:30:50 +01:00
|
|
|
|
1998-12-07 10:13:40 +01:00
|
|
|
#include "x11drv.h"
|
2005-03-09 17:45:23 +01:00
|
|
|
#include "wine/server.h"
|
2007-03-22 20:06:19 +01:00
|
|
|
#include "wine/library.h"
|
2010-10-18 12:26:28 +02:00
|
|
|
#include "wine/unicode.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
1998-12-07 10:13:40 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(cursor);
|
1999-04-19 16:56:29 +02:00
|
|
|
|
1998-12-26 13:00:43 +01:00
|
|
|
/**********************************************************************/
|
|
|
|
|
2005-03-24 20:15:41 +01:00
|
|
|
#ifndef Button6Mask
|
|
|
|
#define Button6Mask (1<<13)
|
|
|
|
#endif
|
|
|
|
#ifndef Button7Mask
|
|
|
|
#define Button7Mask (1<<14)
|
|
|
|
#endif
|
|
|
|
|
2008-05-22 20:45:30 +02:00
|
|
|
#define NB_BUTTONS 9 /* Windows can handle 5 buttons and the wheel too */
|
2001-10-18 23:38:59 +02:00
|
|
|
|
|
|
|
static const UINT button_down_flags[NB_BUTTONS] =
|
|
|
|
{
|
|
|
|
MOUSEEVENTF_LEFTDOWN,
|
|
|
|
MOUSEEVENTF_MIDDLEDOWN,
|
|
|
|
MOUSEEVENTF_RIGHTDOWN,
|
|
|
|
MOUSEEVENTF_WHEEL,
|
2005-03-24 20:15:41 +01:00
|
|
|
MOUSEEVENTF_WHEEL,
|
2008-05-22 20:45:30 +02:00
|
|
|
MOUSEEVENTF_XDOWN, /* FIXME: horizontal wheel */
|
|
|
|
MOUSEEVENTF_XDOWN,
|
2005-03-24 20:15:41 +01:00
|
|
|
MOUSEEVENTF_XDOWN,
|
|
|
|
MOUSEEVENTF_XDOWN
|
2001-10-18 23:38:59 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static const UINT button_up_flags[NB_BUTTONS] =
|
|
|
|
{
|
|
|
|
MOUSEEVENTF_LEFTUP,
|
|
|
|
MOUSEEVENTF_MIDDLEUP,
|
|
|
|
MOUSEEVENTF_RIGHTUP,
|
|
|
|
0,
|
2005-03-24 20:15:41 +01:00
|
|
|
0,
|
|
|
|
MOUSEEVENTF_XUP,
|
2008-05-22 20:45:30 +02:00
|
|
|
MOUSEEVENTF_XUP,
|
|
|
|
MOUSEEVENTF_XUP,
|
2005-03-24 20:15:41 +01:00
|
|
|
MOUSEEVENTF_XUP
|
2001-10-18 23:38:59 +02:00
|
|
|
};
|
|
|
|
|
2011-04-12 21:20:08 +02:00
|
|
|
static const UINT button_down_data[NB_BUTTONS] =
|
|
|
|
{
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
WHEEL_DELTA,
|
|
|
|
-WHEEL_DELTA,
|
|
|
|
XBUTTON1,
|
|
|
|
XBUTTON2,
|
|
|
|
XBUTTON1,
|
|
|
|
XBUTTON2
|
|
|
|
};
|
|
|
|
|
|
|
|
static const UINT button_up_data[NB_BUTTONS] =
|
|
|
|
{
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
XBUTTON1,
|
|
|
|
XBUTTON2,
|
|
|
|
XBUTTON1,
|
|
|
|
XBUTTON2
|
|
|
|
};
|
|
|
|
|
2012-08-15 15:51:06 +02:00
|
|
|
XContext cursor_context = 0;
|
|
|
|
|
2010-04-29 02:23:05 +02:00
|
|
|
static HWND cursor_window;
|
2011-04-04 15:06:59 +02:00
|
|
|
static HCURSOR last_cursor;
|
|
|
|
static DWORD last_cursor_change;
|
2011-04-05 11:50:45 +02:00
|
|
|
static RECT clip_rect;
|
2010-05-21 13:26:22 +02:00
|
|
|
static Cursor create_cursor( HANDLE handle );
|
2001-10-18 23:38:59 +02:00
|
|
|
|
2011-04-13 20:18:30 +02:00
|
|
|
#ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
|
|
|
|
static BOOL xinput2_available;
|
2015-01-26 05:42:32 +01:00
|
|
|
static BOOL broken_rawevents;
|
2011-04-13 20:18:30 +02:00
|
|
|
#define MAKE_FUNCPTR(f) static typeof(f) * p##f
|
|
|
|
MAKE_FUNCPTR(XIFreeDeviceInfo);
|
|
|
|
MAKE_FUNCPTR(XIQueryDevice);
|
|
|
|
MAKE_FUNCPTR(XIQueryVersion);
|
|
|
|
MAKE_FUNCPTR(XISelectEvents);
|
|
|
|
#undef MAKE_FUNCPTR
|
|
|
|
#endif
|
2007-03-22 20:06:19 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_Xcursor_Init
|
|
|
|
*
|
|
|
|
* Load the Xcursor library for use.
|
|
|
|
*/
|
|
|
|
void X11DRV_Xcursor_Init(void)
|
|
|
|
{
|
2007-07-09 22:42:28 +02:00
|
|
|
#ifdef SONAME_LIBXCURSOR
|
2007-03-22 20:06:19 +01:00
|
|
|
xcursor_handle = wine_dlopen(SONAME_LIBXCURSOR, RTLD_NOW, NULL, 0);
|
|
|
|
if (!xcursor_handle) /* wine_dlopen failed. */
|
|
|
|
{
|
|
|
|
WARN("Xcursor failed to load. Using fallback code.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#define LOAD_FUNCPTR(f) \
|
|
|
|
p##f = wine_dlsym(xcursor_handle, #f, NULL, 0)
|
|
|
|
|
|
|
|
LOAD_FUNCPTR(XcursorImageCreate);
|
|
|
|
LOAD_FUNCPTR(XcursorImageDestroy);
|
|
|
|
LOAD_FUNCPTR(XcursorImageLoadCursor);
|
2010-10-05 20:06:18 +02:00
|
|
|
LOAD_FUNCPTR(XcursorImagesCreate);
|
|
|
|
LOAD_FUNCPTR(XcursorImagesDestroy);
|
|
|
|
LOAD_FUNCPTR(XcursorImagesLoadCursor);
|
2010-10-18 12:16:28 +02:00
|
|
|
LOAD_FUNCPTR(XcursorLibraryLoadCursor);
|
2007-03-22 20:06:19 +01:00
|
|
|
#undef LOAD_FUNCPTR
|
2007-07-09 22:42:28 +02:00
|
|
|
#endif /* SONAME_LIBXCURSOR */
|
2007-03-22 20:06:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-04-20 21:23:00 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* get_empty_cursor
|
|
|
|
*/
|
|
|
|
static Cursor get_empty_cursor(void)
|
|
|
|
{
|
|
|
|
static Cursor cursor;
|
|
|
|
static const char data[] = { 0 };
|
|
|
|
|
|
|
|
if (!cursor)
|
|
|
|
{
|
|
|
|
XColor bg;
|
|
|
|
Pixmap pixmap;
|
|
|
|
|
|
|
|
bg.red = bg.green = bg.blue = 0x0000;
|
|
|
|
pixmap = XCreateBitmapFromData( gdi_display, root_window, data, 1, 1 );
|
|
|
|
if (pixmap)
|
|
|
|
{
|
2012-08-16 16:46:37 +02:00
|
|
|
Cursor new = XCreatePixmapCursor( gdi_display, pixmap, pixmap, &bg, &bg, 0, 0 );
|
|
|
|
if (InterlockedCompareExchangePointer( (void **)&cursor, (void *)new, 0 ))
|
|
|
|
XFreeCursor( gdi_display, new );
|
2010-04-20 21:23:00 +02:00
|
|
|
XFreePixmap( gdi_display, pixmap );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return cursor;
|
|
|
|
}
|
|
|
|
|
2010-04-29 02:23:05 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* set_window_cursor
|
|
|
|
*/
|
2011-04-04 15:06:59 +02:00
|
|
|
void set_window_cursor( Window window, HCURSOR handle )
|
2010-04-29 02:23:05 +02:00
|
|
|
{
|
2010-05-21 13:26:22 +02:00
|
|
|
Cursor cursor, prev;
|
2010-04-29 02:23:05 +02:00
|
|
|
|
2010-05-21 13:26:22 +02:00
|
|
|
if (!handle) cursor = get_empty_cursor();
|
2012-08-15 15:51:06 +02:00
|
|
|
else if (XFindContext( gdi_display, (XID)handle, cursor_context, (char **)&cursor ))
|
2010-04-29 02:23:05 +02:00
|
|
|
{
|
2010-05-21 13:26:22 +02:00
|
|
|
/* try to create it */
|
|
|
|
if (!(cursor = create_cursor( handle ))) return;
|
|
|
|
|
2012-08-16 16:46:37 +02:00
|
|
|
XLockDisplay( gdi_display );
|
2010-05-21 13:26:22 +02:00
|
|
|
if (!XFindContext( gdi_display, (XID)handle, cursor_context, (char **)&prev ))
|
|
|
|
{
|
|
|
|
/* someone else was here first */
|
|
|
|
XFreeCursor( gdi_display, cursor );
|
|
|
|
cursor = prev;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
XSaveContext( gdi_display, (XID)handle, cursor_context, (char *)cursor );
|
|
|
|
TRACE( "cursor %p created %lx\n", handle, cursor );
|
|
|
|
}
|
2012-08-16 16:46:37 +02:00
|
|
|
XUnlockDisplay( gdi_display );
|
2010-04-29 02:23:05 +02:00
|
|
|
}
|
2010-05-21 13:26:22 +02:00
|
|
|
|
2011-04-04 15:06:59 +02:00
|
|
|
XDefineCursor( gdi_display, window, cursor );
|
2010-05-21 13:26:22 +02:00
|
|
|
/* make the change take effect immediately */
|
|
|
|
XFlush( gdi_display );
|
2010-04-29 02:23:05 +02:00
|
|
|
}
|
|
|
|
|
2011-02-23 21:46:08 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* sync_window_cursor
|
|
|
|
*/
|
2011-04-06 12:35:11 +02:00
|
|
|
void sync_window_cursor( Window window )
|
2011-02-23 21:46:08 +01:00
|
|
|
{
|
|
|
|
HCURSOR cursor;
|
|
|
|
|
|
|
|
SERVER_START_REQ( set_cursor )
|
|
|
|
{
|
|
|
|
req->flags = 0;
|
|
|
|
wine_server_call( req );
|
|
|
|
cursor = reply->prev_count >= 0 ? wine_server_ptr_handle( reply->prev_handle ) : 0;
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
|
2011-04-06 12:35:11 +02:00
|
|
|
set_window_cursor( window, cursor );
|
2011-02-23 21:46:08 +01:00
|
|
|
}
|
|
|
|
|
2011-04-13 20:18:30 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* enable_xinput2
|
|
|
|
*/
|
|
|
|
static void enable_xinput2(void)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
|
|
|
|
struct x11drv_thread_data *data = x11drv_thread_data();
|
|
|
|
XIEventMask mask;
|
2012-08-15 21:21:20 +02:00
|
|
|
XIDeviceInfo *devices;
|
2011-04-13 20:18:30 +02:00
|
|
|
unsigned char mask_bits[XIMaskLen(XI_LASTEVENT)];
|
2012-08-15 22:05:07 +02:00
|
|
|
int i, j, count;
|
2011-04-13 20:18:30 +02:00
|
|
|
|
|
|
|
if (!xinput2_available) return;
|
|
|
|
|
|
|
|
if (data->xi2_state == xi_unknown)
|
|
|
|
{
|
|
|
|
int major = 2, minor = 0;
|
|
|
|
if (!pXIQueryVersion( data->display, &major, &minor )) data->xi2_state = xi_disabled;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
data->xi2_state = xi_unavailable;
|
|
|
|
WARN( "X Input 2 not available\n" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (data->xi2_state == xi_unavailable) return;
|
|
|
|
|
2012-08-15 21:21:20 +02:00
|
|
|
if (data->xi2_devices) pXIFreeDeviceInfo( data->xi2_devices );
|
|
|
|
data->xi2_devices = devices = pXIQueryDevice( data->display, XIAllDevices, &data->xi2_device_count );
|
|
|
|
for (i = 0; i < data->xi2_device_count; ++i)
|
2011-04-13 20:18:30 +02:00
|
|
|
{
|
2012-08-15 21:21:20 +02:00
|
|
|
if (devices[i].use != XIMasterPointer) continue;
|
2012-08-15 22:05:07 +02:00
|
|
|
for (j = count = 0; j < devices[i].num_classes; j++)
|
2011-06-21 13:23:19 +02:00
|
|
|
{
|
2012-08-15 21:21:20 +02:00
|
|
|
XIValuatorClassInfo *class = (XIValuatorClassInfo *)devices[i].classes[j];
|
2011-06-21 13:23:19 +02:00
|
|
|
|
2012-08-15 21:21:20 +02:00
|
|
|
if (devices[i].classes[j]->type != XIValuatorClass) continue;
|
2012-08-15 22:05:07 +02:00
|
|
|
TRACE( "Device %u (%s) num %u %f,%f res %u mode %u label %s\n",
|
2012-08-15 21:21:20 +02:00
|
|
|
devices[i].deviceid, debugstr_a(devices[i].name),
|
2012-08-15 22:05:07 +02:00
|
|
|
class->number, class->min, class->max, class->resolution, class->mode,
|
|
|
|
XGetAtomName( data->display, class->label ));
|
|
|
|
if (class->label == x11drv_atom( Rel_X ) || class->label == x11drv_atom( Rel_Y )) count++;
|
2012-09-25 19:25:02 +02:00
|
|
|
/* workaround for drivers that don't provide labels */
|
|
|
|
if (!class->label && class->number <= 1 && class->mode == XIModeRelative) count++;
|
2011-06-21 13:23:19 +02:00
|
|
|
}
|
2012-08-15 22:05:07 +02:00
|
|
|
if (count < 2) continue;
|
2011-04-13 20:18:30 +02:00
|
|
|
TRACE( "Using %u (%s) as core pointer\n",
|
2012-08-15 21:21:20 +02:00
|
|
|
devices[i].deviceid, debugstr_a(devices[i].name) );
|
|
|
|
data->xi2_core_pointer = devices[i].deviceid;
|
2011-04-13 20:18:30 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
mask.mask = mask_bits;
|
|
|
|
mask.mask_len = sizeof(mask_bits);
|
|
|
|
memset( mask_bits, 0, sizeof(mask_bits) );
|
|
|
|
XISetMask( mask_bits, XI_RawMotion );
|
2011-07-11 02:29:26 +02:00
|
|
|
XISetMask( mask_bits, XI_ButtonPress );
|
2011-04-13 20:18:30 +02:00
|
|
|
|
2012-08-15 21:21:20 +02:00
|
|
|
for (i = 0; i < data->xi2_device_count; ++i)
|
2011-04-13 20:18:30 +02:00
|
|
|
{
|
2012-08-15 21:21:20 +02:00
|
|
|
if (devices[i].use == XISlavePointer && devices[i].attachment == data->xi2_core_pointer)
|
2011-04-13 20:18:30 +02:00
|
|
|
{
|
|
|
|
TRACE( "Device %u (%s) is attached to the core pointer\n",
|
2012-08-15 21:21:20 +02:00
|
|
|
devices[i].deviceid, debugstr_a(devices[i].name) );
|
|
|
|
mask.deviceid = devices[i].deviceid;
|
2011-04-13 20:18:30 +02:00
|
|
|
pXISelectEvents( data->display, DefaultRootWindow( data->display ), &mask, 1 );
|
|
|
|
data->xi2_state = xi_enabled;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* disable_xinput2
|
|
|
|
*/
|
|
|
|
static void disable_xinput2(void)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
|
|
|
|
struct x11drv_thread_data *data = x11drv_thread_data();
|
2012-08-15 21:21:20 +02:00
|
|
|
XIDeviceInfo *devices = data->xi2_devices;
|
2011-04-13 20:18:30 +02:00
|
|
|
XIEventMask mask;
|
2011-12-21 10:57:40 +01:00
|
|
|
int i;
|
2011-04-13 20:18:30 +02:00
|
|
|
|
|
|
|
if (data->xi2_state != xi_enabled) return;
|
|
|
|
|
|
|
|
TRACE( "disabling\n" );
|
|
|
|
data->xi2_state = xi_disabled;
|
|
|
|
|
|
|
|
mask.mask = NULL;
|
|
|
|
mask.mask_len = 0;
|
|
|
|
|
2012-08-15 21:21:20 +02:00
|
|
|
for (i = 0; i < data->xi2_device_count; ++i)
|
2011-04-13 20:18:30 +02:00
|
|
|
{
|
2012-08-15 21:21:20 +02:00
|
|
|
if (devices[i].use == XISlavePointer && devices[i].attachment == data->xi2_core_pointer)
|
2011-04-13 20:18:30 +02:00
|
|
|
{
|
2012-08-15 21:21:20 +02:00
|
|
|
mask.deviceid = devices[i].deviceid;
|
2011-04-13 20:18:30 +02:00
|
|
|
pXISelectEvents( data->display, DefaultRootWindow( data->display ), &mask, 1 );
|
|
|
|
}
|
|
|
|
}
|
2012-08-15 21:21:20 +02:00
|
|
|
pXIFreeDeviceInfo( devices );
|
|
|
|
data->xi2_devices = NULL;
|
|
|
|
data->xi2_device_count = 0;
|
2011-04-13 20:18:30 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2011-04-22 16:22:09 +02:00
|
|
|
|
2011-04-22 16:28:25 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* grab_clipping_window
|
|
|
|
*
|
|
|
|
* Start a pointer grab on the clip window.
|
|
|
|
*/
|
2012-03-12 10:33:52 +01:00
|
|
|
static BOOL grab_clipping_window( const RECT *clip )
|
2011-04-22 16:28:25 +02:00
|
|
|
{
|
2011-07-18 21:19:55 +02:00
|
|
|
static const WCHAR messageW[] = {'M','e','s','s','a','g','e',0};
|
2011-04-28 13:07:05 +02:00
|
|
|
struct x11drv_thread_data *data = x11drv_thread_data();
|
|
|
|
Window clip_window;
|
2011-04-22 16:58:20 +02:00
|
|
|
HWND msg_hwnd = 0;
|
2013-10-14 14:20:08 +02:00
|
|
|
POINT pos;
|
2011-04-22 16:28:25 +02:00
|
|
|
|
2013-04-25 09:59:42 +02:00
|
|
|
if (GetWindowThreadProcessId( GetDesktopWindow(), NULL ) == GetCurrentThreadId())
|
|
|
|
return TRUE; /* don't clip in the desktop process */
|
|
|
|
|
2011-04-28 13:07:05 +02:00
|
|
|
if (!data) return FALSE;
|
|
|
|
if (!(clip_window = init_clip_window())) return TRUE;
|
2011-04-22 16:28:25 +02:00
|
|
|
|
2011-07-18 21:19:55 +02:00
|
|
|
if (!(msg_hwnd = CreateWindowW( messageW, NULL, 0, 0, 0, 0, 0, HWND_MESSAGE, 0,
|
|
|
|
GetModuleHandleW(0), NULL )))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* enable XInput2 unless we are already clipping */
|
|
|
|
if (!data->clip_hwnd) enable_xinput2();
|
2011-04-26 14:40:59 +02:00
|
|
|
|
2012-03-12 10:33:52 +01:00
|
|
|
if (data->xi2_state != xi_enabled)
|
2011-04-26 14:40:59 +02:00
|
|
|
{
|
|
|
|
WARN( "XInput2 not supported, refusing to clip to %s\n", wine_dbgstr_rect(clip) );
|
2011-07-18 21:19:55 +02:00
|
|
|
DestroyWindow( msg_hwnd );
|
2011-04-26 14:40:59 +02:00
|
|
|
ClipCursor( NULL );
|
|
|
|
return TRUE;
|
|
|
|
}
|
2011-04-22 16:28:25 +02:00
|
|
|
|
2011-05-13 16:44:09 +02:00
|
|
|
TRACE( "clipping to %s win %lx\n", wine_dbgstr_rect(clip), clip_window );
|
2011-04-22 16:58:20 +02:00
|
|
|
|
2011-07-18 21:19:55 +02:00
|
|
|
if (!data->clip_hwnd) XUnmapWindow( data->display, clip_window );
|
2013-10-14 14:20:08 +02:00
|
|
|
pos = virtual_screen_to_root( clip->left, clip->top );
|
|
|
|
XMoveResizeWindow( data->display, clip_window, pos.x, pos.y,
|
2011-06-21 14:50:23 +02:00
|
|
|
max( 1, clip->right - clip->left ), max( 1, clip->bottom - clip->top ) );
|
2011-05-13 16:44:09 +02:00
|
|
|
XMapWindow( data->display, clip_window );
|
2011-05-16 14:34:10 +02:00
|
|
|
|
|
|
|
/* if the rectangle is shrinking we may get a pointer warp */
|
2011-07-18 21:19:55 +02:00
|
|
|
if (!data->clip_hwnd || clip->left > clip_rect.left || clip->top > clip_rect.top ||
|
2011-05-16 14:34:10 +02:00
|
|
|
clip->right < clip_rect.right || clip->bottom < clip_rect.bottom)
|
|
|
|
data->warp_serial = NextRequest( data->display );
|
|
|
|
|
2011-04-22 16:28:25 +02:00
|
|
|
if (!XGrabPointer( data->display, clip_window, False,
|
|
|
|
PointerMotionMask | ButtonPressMask | ButtonReleaseMask,
|
|
|
|
GrabModeAsync, GrabModeAsync, clip_window, None, CurrentTime ))
|
2013-11-29 12:33:09 +01:00
|
|
|
clipping_cursor = TRUE;
|
2011-04-22 16:28:25 +02:00
|
|
|
|
|
|
|
if (!clipping_cursor)
|
|
|
|
{
|
2011-04-26 14:40:59 +02:00
|
|
|
disable_xinput2();
|
2011-07-18 21:19:55 +02:00
|
|
|
DestroyWindow( msg_hwnd );
|
2011-04-22 16:28:25 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
2011-05-12 16:24:58 +02:00
|
|
|
clip_rect = *clip;
|
2011-07-18 21:19:55 +02:00
|
|
|
if (!data->clip_hwnd) sync_window_cursor( clip_window );
|
2011-11-09 14:26:34 +01:00
|
|
|
InterlockedExchangePointer( (void **)&cursor_window, msg_hwnd );
|
2011-07-18 21:19:55 +02:00
|
|
|
data->clip_hwnd = msg_hwnd;
|
|
|
|
SendMessageW( GetDesktopWindow(), WM_X11DRV_CLIP_CURSOR, 0, (LPARAM)msg_hwnd );
|
2011-04-22 16:28:25 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* ungrab_clipping_window
|
|
|
|
*
|
|
|
|
* Release the pointer grab on the clip window.
|
|
|
|
*/
|
2011-04-25 10:49:49 +02:00
|
|
|
void ungrab_clipping_window(void)
|
2011-04-22 16:28:25 +02:00
|
|
|
{
|
|
|
|
Display *display = thread_init_display();
|
|
|
|
Window clip_window = init_clip_window();
|
|
|
|
|
|
|
|
if (!clip_window) return;
|
|
|
|
|
|
|
|
TRACE( "no longer clipping\n" );
|
|
|
|
XUnmapWindow( display, clip_window );
|
2013-11-29 12:33:09 +01:00
|
|
|
clipping_cursor = FALSE;
|
2011-04-22 16:28:25 +02:00
|
|
|
SendMessageW( GetDesktopWindow(), WM_X11DRV_CLIP_CURSOR, 0, 0 );
|
|
|
|
}
|
|
|
|
|
2011-05-11 12:07:37 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* reset_clipping_window
|
|
|
|
*
|
|
|
|
* Forcibly reset the window clipping on external events.
|
|
|
|
*/
|
|
|
|
void reset_clipping_window(void)
|
|
|
|
{
|
|
|
|
ungrab_clipping_window();
|
|
|
|
ClipCursor( NULL ); /* make sure the clip rectangle is reset too */
|
|
|
|
}
|
|
|
|
|
2011-04-28 13:07:05 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* clip_cursor_notify
|
|
|
|
*
|
|
|
|
* Notification function called upon receiving a WM_X11DRV_CLIP_CURSOR.
|
|
|
|
*/
|
|
|
|
LRESULT clip_cursor_notify( HWND hwnd, HWND new_clip_hwnd )
|
|
|
|
{
|
2015-08-04 18:43:26 +02:00
|
|
|
struct x11drv_thread_data *data = x11drv_init_thread_data();
|
2011-04-28 13:07:05 +02:00
|
|
|
|
|
|
|
if (hwnd == GetDesktopWindow()) /* change the clip window stored in the desktop process */
|
|
|
|
{
|
|
|
|
static HWND clip_hwnd;
|
|
|
|
|
|
|
|
HWND prev = clip_hwnd;
|
|
|
|
clip_hwnd = new_clip_hwnd;
|
|
|
|
if (prev || new_clip_hwnd) TRACE( "clip hwnd changed from %p to %p\n", prev, new_clip_hwnd );
|
|
|
|
if (prev) SendNotifyMessageW( prev, WM_X11DRV_CLIP_CURSOR, 0, 0 );
|
|
|
|
}
|
|
|
|
else if (hwnd == data->clip_hwnd) /* this is a notification that clipping has been reset */
|
|
|
|
{
|
2011-07-18 21:19:55 +02:00
|
|
|
TRACE( "clip hwnd reset from %p\n", hwnd );
|
2011-04-28 13:07:05 +02:00
|
|
|
data->clip_hwnd = 0;
|
2011-05-11 12:30:03 +02:00
|
|
|
data->clip_reset = GetTickCount();
|
2011-04-28 13:07:05 +02:00
|
|
|
disable_xinput2();
|
|
|
|
DestroyWindow( hwnd );
|
|
|
|
}
|
|
|
|
else if (hwnd == GetForegroundWindow()) /* request to clip */
|
|
|
|
{
|
2013-10-14 14:38:58 +02:00
|
|
|
RECT clip, virtual_rect = get_virtual_screen_rect();
|
2011-04-28 13:07:05 +02:00
|
|
|
|
|
|
|
GetClipCursor( &clip );
|
2013-10-14 14:38:58 +02:00
|
|
|
if (clip.left > virtual_rect.left || clip.right < virtual_rect.right ||
|
|
|
|
clip.top > virtual_rect.top || clip.bottom < virtual_rect.bottom)
|
2012-03-12 10:33:52 +01:00
|
|
|
return grab_clipping_window( &clip );
|
2011-04-28 13:07:05 +02:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-05-11 12:30:03 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* clip_fullscreen_window
|
|
|
|
*
|
|
|
|
* Turn on clipping if the active window is fullscreen.
|
|
|
|
*/
|
2011-05-12 16:24:58 +02:00
|
|
|
BOOL clip_fullscreen_window( HWND hwnd, BOOL reset )
|
2011-05-11 12:30:03 +02:00
|
|
|
{
|
|
|
|
struct x11drv_win_data *data;
|
2011-05-12 16:24:58 +02:00
|
|
|
struct x11drv_thread_data *thread_data;
|
2011-05-11 12:30:03 +02:00
|
|
|
RECT rect;
|
|
|
|
DWORD style;
|
2012-09-17 16:37:26 +02:00
|
|
|
BOOL fullscreen;
|
2011-05-11 12:30:03 +02:00
|
|
|
|
|
|
|
if (hwnd == GetDesktopWindow()) return FALSE;
|
|
|
|
style = GetWindowLongW( hwnd, GWL_STYLE );
|
|
|
|
if (!(style & WS_VISIBLE)) return FALSE;
|
|
|
|
if ((style & (WS_POPUP | WS_CHILD)) == WS_CHILD) return FALSE;
|
|
|
|
/* maximized windows don't count as full screen */
|
|
|
|
if ((style & WS_MAXIMIZE) && (style & WS_CAPTION) == WS_CAPTION) return FALSE;
|
2012-09-17 16:37:26 +02:00
|
|
|
if (!(data = get_win_data( hwnd ))) return FALSE;
|
|
|
|
fullscreen = is_window_rect_fullscreen( &data->whole_rect );
|
|
|
|
release_win_data( data );
|
|
|
|
if (!fullscreen) return FALSE;
|
2011-05-12 16:24:58 +02:00
|
|
|
if (!(thread_data = x11drv_thread_data())) return FALSE;
|
|
|
|
if (GetTickCount() - thread_data->clip_reset < 1000) return FALSE;
|
2011-05-13 16:44:09 +02:00
|
|
|
if (!reset && clipping_cursor && thread_data->clip_hwnd) return FALSE; /* already clipping */
|
2013-10-14 14:59:01 +02:00
|
|
|
rect = get_primary_monitor_rect();
|
2011-05-11 13:07:34 +02:00
|
|
|
if (!grab_fullscreen)
|
|
|
|
{
|
2013-10-14 14:38:58 +02:00
|
|
|
RECT virtual_rect = get_virtual_screen_rect();
|
|
|
|
if (!EqualRect( &rect, &virtual_rect )) return FALSE;
|
2011-05-11 13:07:34 +02:00
|
|
|
if (root_window != DefaultRootWindow( gdi_display )) return FALSE;
|
|
|
|
}
|
2011-05-11 12:30:03 +02:00
|
|
|
TRACE( "win %p clipping fullscreen\n", hwnd );
|
2012-03-12 10:33:52 +01:00
|
|
|
return grab_clipping_window( &rect );
|
2011-05-11 12:30:03 +02:00
|
|
|
}
|
|
|
|
|
2015-12-01 09:42:01 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* is_old_motion_event
|
|
|
|
*/
|
|
|
|
static BOOL is_old_motion_event( unsigned long serial )
|
|
|
|
{
|
|
|
|
struct x11drv_thread_data *thread_data = x11drv_thread_data();
|
|
|
|
|
|
|
|
if (!thread_data->warp_serial) return FALSE;
|
|
|
|
if ((long)(serial - thread_data->warp_serial) < 0) return TRUE;
|
|
|
|
thread_data->warp_serial = 0; /* we caught up now */
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-03-21 13:37:00 +01:00
|
|
|
/***********************************************************************
|
2011-03-03 17:47:08 +01:00
|
|
|
* send_mouse_input
|
2005-03-21 13:37:00 +01:00
|
|
|
*
|
|
|
|
* Update the various window states on a mouse event.
|
|
|
|
*/
|
2011-04-12 21:20:08 +02:00
|
|
|
static void send_mouse_input( HWND hwnd, Window window, unsigned int state, INPUT *input )
|
2005-03-21 13:37:00 +01:00
|
|
|
{
|
2011-04-05 11:50:45 +02:00
|
|
|
struct x11drv_win_data *data;
|
2011-03-03 17:47:08 +01:00
|
|
|
POINT pt;
|
2011-04-12 21:20:08 +02:00
|
|
|
|
|
|
|
input->type = INPUT_MOUSE;
|
2005-03-21 13:37:00 +01:00
|
|
|
|
2011-05-13 12:40:19 +02:00
|
|
|
if (!hwnd)
|
2011-04-05 11:50:45 +02:00
|
|
|
{
|
2011-05-13 12:40:19 +02:00
|
|
|
struct x11drv_thread_data *thread_data = x11drv_thread_data();
|
2011-11-09 14:26:34 +01:00
|
|
|
HWND clip_hwnd = thread_data->clip_hwnd;
|
2011-05-13 12:40:19 +02:00
|
|
|
|
2011-11-09 14:26:34 +01:00
|
|
|
if (!clip_hwnd) return;
|
2011-05-13 12:40:19 +02:00
|
|
|
if (thread_data->clip_window != window) return;
|
2011-11-09 14:26:34 +01:00
|
|
|
if (InterlockedExchangePointer( (void **)&cursor_window, clip_hwnd ) != clip_hwnd ||
|
2011-11-09 14:53:34 +01:00
|
|
|
input->u.mi.time - last_cursor_change > 100)
|
2011-11-09 14:26:34 +01:00
|
|
|
{
|
|
|
|
sync_window_cursor( window );
|
2011-11-09 14:53:34 +01:00
|
|
|
last_cursor_change = input->u.mi.time;
|
2011-11-09 14:26:34 +01:00
|
|
|
}
|
2011-04-12 21:20:08 +02:00
|
|
|
input->u.mi.dx += clip_rect.left;
|
|
|
|
input->u.mi.dy += clip_rect.top;
|
2011-05-13 12:40:19 +02:00
|
|
|
__wine_send_input( hwnd, input );
|
2011-04-12 21:20:08 +02:00
|
|
|
return;
|
2011-04-05 11:50:45 +02:00
|
|
|
}
|
|
|
|
|
2013-10-14 14:20:08 +02:00
|
|
|
if (window != root_window)
|
|
|
|
{
|
|
|
|
pt.x = input->u.mi.dx;
|
|
|
|
pt.y = input->u.mi.dy;
|
|
|
|
}
|
|
|
|
else pt = root_to_virtual_screen( input->u.mi.dx, input->u.mi.dy );
|
|
|
|
|
2012-09-17 16:37:26 +02:00
|
|
|
if (!(data = get_win_data( hwnd ))) return;
|
2010-09-27 21:12:49 +02:00
|
|
|
|
|
|
|
if (window == data->whole_window)
|
|
|
|
{
|
2013-10-14 14:20:08 +02:00
|
|
|
pt.x += data->whole_rect.left - data->client_rect.left;
|
|
|
|
pt.y += data->whole_rect.top - data->client_rect.top;
|
2010-09-27 21:12:49 +02:00
|
|
|
}
|
2013-10-14 14:20:08 +02:00
|
|
|
|
2010-11-05 13:41:03 +01:00
|
|
|
if (GetWindowLongW( data->hwnd, GWL_EXSTYLE ) & WS_EX_LAYOUTRTL)
|
2011-03-03 17:47:08 +01:00
|
|
|
pt.x = data->client_rect.right - data->client_rect.left - 1 - pt.x;
|
|
|
|
MapWindowPoints( hwnd, 0, &pt, 1 );
|
2005-03-21 13:37:00 +01:00
|
|
|
|
2011-02-24 12:14:58 +01:00
|
|
|
if (InterlockedExchangePointer( (void **)&cursor_window, hwnd ) != hwnd ||
|
2011-11-09 14:53:34 +01:00
|
|
|
input->u.mi.time - last_cursor_change > 100)
|
2011-02-24 12:14:58 +01:00
|
|
|
{
|
2011-04-06 12:35:11 +02:00
|
|
|
sync_window_cursor( data->whole_window );
|
2011-11-09 14:53:34 +01:00
|
|
|
last_cursor_change = input->u.mi.time;
|
2011-02-24 12:14:58 +01:00
|
|
|
}
|
2012-09-17 16:37:26 +02:00
|
|
|
release_win_data( data );
|
2011-03-03 17:47:08 +01:00
|
|
|
|
2011-05-11 12:30:03 +02:00
|
|
|
if (hwnd != GetDesktopWindow())
|
|
|
|
{
|
|
|
|
hwnd = GetAncestor( hwnd, GA_ROOT );
|
|
|
|
if ((input->u.mi.dwFlags & (MOUSEEVENTF_LEFTDOWN|MOUSEEVENTF_RIGHTDOWN)) && hwnd == GetForegroundWindow())
|
2011-05-12 16:24:58 +02:00
|
|
|
clip_fullscreen_window( hwnd, FALSE );
|
2011-05-11 12:30:03 +02:00
|
|
|
}
|
2005-03-21 13:37:00 +01:00
|
|
|
|
|
|
|
/* update the wine server Z-order */
|
|
|
|
|
2016-03-10 14:03:02 +01:00
|
|
|
if (hwnd != x11drv_thread_data()->grab_hwnd &&
|
2005-03-21 13:37:00 +01:00
|
|
|
/* ignore event if a button is pressed, since the mouse is then grabbed too */
|
2005-03-24 20:15:41 +01:00
|
|
|
!(state & (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask|Button6Mask|Button7Mask)))
|
2005-03-21 13:37:00 +01:00
|
|
|
{
|
2010-10-07 14:26:21 +02:00
|
|
|
RECT rect;
|
2011-03-03 17:47:08 +01:00
|
|
|
SetRect( &rect, pt.x, pt.y, pt.x + 1, pt.y + 1 );
|
2010-11-05 13:41:03 +01:00
|
|
|
MapWindowPoints( 0, hwnd, (POINT *)&rect, 2 );
|
2010-10-07 14:26:21 +02:00
|
|
|
|
2005-03-21 13:37:00 +01:00
|
|
|
SERVER_START_REQ( update_window_zorder )
|
|
|
|
{
|
2008-12-08 16:58:20 +01:00
|
|
|
req->window = wine_server_user_handle( hwnd );
|
2010-10-07 14:26:21 +02:00
|
|
|
req->rect.left = rect.left;
|
|
|
|
req->rect.top = rect.top;
|
|
|
|
req->rect.right = rect.right;
|
|
|
|
req->rect.bottom = rect.bottom;
|
2005-03-21 13:37:00 +01:00
|
|
|
wine_server_call( req );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
}
|
2011-03-02 11:59:38 +01:00
|
|
|
|
2011-04-12 21:20:08 +02:00
|
|
|
input->u.mi.dx = pt.x;
|
|
|
|
input->u.mi.dy = pt.y;
|
|
|
|
__wine_send_input( hwnd, input );
|
2001-10-18 23:38:59 +02:00
|
|
|
}
|
|
|
|
|
2007-07-09 22:42:28 +02:00
|
|
|
#ifdef SONAME_LIBXCURSOR
|
2007-03-22 20:06:19 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
2010-10-05 20:06:18 +02:00
|
|
|
* create_xcursor_frame
|
2007-03-22 20:06:19 +01:00
|
|
|
*
|
2010-10-05 20:06:18 +02:00
|
|
|
* Use Xcursor to create a frame of an X cursor from a Windows one.
|
2007-03-22 20:06:19 +01:00
|
|
|
*/
|
2010-10-18 12:09:25 +02:00
|
|
|
static XcursorImage *create_xcursor_frame( HDC hdc, const ICONINFOEXW *iinfo, HANDLE icon,
|
2010-10-05 20:06:18 +02:00
|
|
|
HBITMAP hbmColor, unsigned char *color_bits, int color_size,
|
|
|
|
HBITMAP hbmMask, unsigned char *mask_bits, int mask_size,
|
|
|
|
int width, int height, int istep )
|
2007-03-22 20:06:19 +01:00
|
|
|
{
|
2010-10-05 20:06:18 +02:00
|
|
|
XcursorImage *image, *ret = NULL;
|
2011-03-10 06:56:50 +01:00
|
|
|
DWORD delay_jiffies, num_steps;
|
2013-10-01 23:33:53 +02:00
|
|
|
int x, y, i;
|
|
|
|
BOOL has_alpha = FALSE;
|
2010-05-20 14:54:41 +02:00
|
|
|
XcursorPixel *ptr;
|
2007-03-22 20:06:19 +01:00
|
|
|
|
2010-05-20 14:54:41 +02:00
|
|
|
image = pXcursorImageCreate( width, height );
|
|
|
|
if (!image)
|
2007-03-22 20:06:19 +01:00
|
|
|
{
|
2010-10-05 20:06:18 +02:00
|
|
|
ERR("X11 failed to produce a cursor frame!\n");
|
2012-08-14 13:38:03 +02:00
|
|
|
return NULL;
|
2010-10-05 20:06:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
image->xhot = iinfo->xHotspot;
|
|
|
|
image->yhot = iinfo->yHotspot;
|
2011-03-06 06:42:31 +01:00
|
|
|
|
|
|
|
image->delay = 100; /* fallback delay, 100 ms */
|
2011-03-10 06:56:50 +01:00
|
|
|
if (GetCursorFrameInfo(icon, 0x0 /* unknown parameter */, istep, &delay_jiffies, &num_steps) != 0)
|
2011-03-06 06:42:31 +01:00
|
|
|
image->delay = (100 * delay_jiffies) / 6; /* convert jiffies (1/60s) to milliseconds */
|
|
|
|
else
|
2011-03-10 06:56:50 +01:00
|
|
|
WARN("Failed to retrieve animated cursor frame-rate for frame %d.\n", istep);
|
2010-10-05 20:06:18 +02:00
|
|
|
|
|
|
|
/* draw the cursor frame to a temporary buffer then copy it into the XcursorImage */
|
|
|
|
memset( color_bits, 0x00, color_size );
|
|
|
|
SelectObject( hdc, hbmColor );
|
|
|
|
if (!DrawIconEx( hdc, 0, 0, icon, width, height, istep, NULL, DI_NORMAL ))
|
|
|
|
{
|
|
|
|
TRACE("Could not draw frame %d (walk past end of frames).\n", istep);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
memcpy( image->pixels, color_bits, color_size );
|
|
|
|
|
|
|
|
/* check if the cursor frame was drawn with an alpha channel */
|
|
|
|
for (i = 0, ptr = image->pixels; i < width * height; i++, ptr++)
|
|
|
|
if ((has_alpha = (*ptr & 0xff000000) != 0)) break;
|
|
|
|
|
|
|
|
/* if no alpha channel was drawn then generate it from the mask */
|
|
|
|
if (!has_alpha)
|
|
|
|
{
|
|
|
|
unsigned int width_bytes = (width + 31) / 32 * 4;
|
|
|
|
|
|
|
|
/* draw the cursor mask to a temporary buffer */
|
|
|
|
memset( mask_bits, 0xFF, mask_size );
|
|
|
|
SelectObject( hdc, hbmMask );
|
|
|
|
if (!DrawIconEx( hdc, 0, 0, icon, width, height, istep, NULL, DI_MASK ))
|
|
|
|
{
|
|
|
|
ERR("Failed to draw frame mask %d.\n", istep);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
/* use the buffer to directly modify the XcursorImage alpha channel */
|
|
|
|
for (y = 0, ptr = image->pixels; y < height; y++)
|
|
|
|
for (x = 0; x < width; x++, ptr++)
|
|
|
|
if (!((mask_bits[y * width_bytes + x / 8] << (x % 8)) & 0x80))
|
|
|
|
*ptr |= 0xff000000;
|
2007-03-22 20:06:19 +01:00
|
|
|
}
|
2010-10-05 20:06:18 +02:00
|
|
|
ret = image;
|
2007-03-22 20:06:19 +01:00
|
|
|
|
2010-10-05 20:06:18 +02:00
|
|
|
cleanup:
|
|
|
|
if (ret == NULL) pXcursorImageDestroy( image );
|
|
|
|
return ret;
|
|
|
|
}
|
2007-03-22 20:06:19 +01:00
|
|
|
|
2010-10-05 20:06:18 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* create_xcursor_cursor
|
|
|
|
*
|
|
|
|
* Use Xcursor to create an X cursor from a Windows one.
|
|
|
|
*/
|
2010-10-18 12:09:25 +02:00
|
|
|
static Cursor create_xcursor_cursor( HDC hdc, const ICONINFOEXW *iinfo, HANDLE icon, int width, int height )
|
2010-10-05 20:06:18 +02:00
|
|
|
{
|
|
|
|
unsigned char *color_bits, *mask_bits;
|
|
|
|
HBITMAP hbmColor = 0, hbmMask = 0;
|
2011-03-10 06:56:50 +01:00
|
|
|
DWORD nFrames, delay_jiffies, i;
|
2010-10-05 20:06:18 +02:00
|
|
|
int color_size, mask_size;
|
|
|
|
BITMAPINFO *info = NULL;
|
|
|
|
XcursorImages *images;
|
2011-03-10 06:56:50 +01:00
|
|
|
XcursorImage **imgs;
|
2010-10-05 20:06:18 +02:00
|
|
|
Cursor cursor = 0;
|
|
|
|
|
2011-03-10 06:56:50 +01:00
|
|
|
/* Retrieve the number of frames to render */
|
|
|
|
if (!GetCursorFrameInfo(icon, 0x0 /* unknown parameter */, 0, &delay_jiffies, &nFrames)) return 0;
|
|
|
|
if (!(imgs = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(XcursorImage*)*nFrames ))) return 0;
|
2010-10-05 20:06:18 +02:00
|
|
|
|
|
|
|
/* Allocate all of the resources necessary to obtain a cursor frame */
|
|
|
|
if (!(info = HeapAlloc( GetProcessHeap(), 0, FIELD_OFFSET( BITMAPINFO, bmiColors[256] )))) goto cleanup;
|
2010-05-20 14:54:41 +02:00
|
|
|
info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
|
|
|
info->bmiHeader.biWidth = width;
|
|
|
|
info->bmiHeader.biHeight = -height;
|
|
|
|
info->bmiHeader.biPlanes = 1;
|
|
|
|
info->bmiHeader.biCompression = BI_RGB;
|
|
|
|
info->bmiHeader.biXPelsPerMeter = 0;
|
|
|
|
info->bmiHeader.biYPelsPerMeter = 0;
|
|
|
|
info->bmiHeader.biClrUsed = 0;
|
|
|
|
info->bmiHeader.biClrImportant = 0;
|
2010-10-05 20:06:18 +02:00
|
|
|
info->bmiHeader.biBitCount = 32;
|
|
|
|
color_size = width * height * 4;
|
|
|
|
info->bmiHeader.biSizeImage = color_size;
|
|
|
|
hbmColor = CreateDIBSection( hdc, info, DIB_RGB_COLORS, (VOID **) &color_bits, NULL, 0);
|
|
|
|
if (!hbmColor)
|
|
|
|
{
|
|
|
|
ERR("Failed to create DIB section for cursor color data!\n");
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
info->bmiHeader.biBitCount = 1;
|
2011-10-05 00:48:23 +02:00
|
|
|
info->bmiColors[0].rgbRed = 0;
|
|
|
|
info->bmiColors[0].rgbGreen = 0;
|
|
|
|
info->bmiColors[0].rgbBlue = 0;
|
|
|
|
info->bmiColors[0].rgbReserved = 0;
|
|
|
|
info->bmiColors[1].rgbRed = 0xff;
|
|
|
|
info->bmiColors[1].rgbGreen = 0xff;
|
|
|
|
info->bmiColors[1].rgbBlue = 0xff;
|
|
|
|
info->bmiColors[1].rgbReserved = 0;
|
|
|
|
|
2010-10-05 20:06:18 +02:00
|
|
|
mask_size = ((width + 31) / 32 * 4) * height; /* width_bytes * height */
|
|
|
|
info->bmiHeader.biSizeImage = mask_size;
|
|
|
|
hbmMask = CreateDIBSection( hdc, info, DIB_RGB_COLORS, (VOID **) &mask_bits, NULL, 0);
|
|
|
|
if (!hbmMask)
|
|
|
|
{
|
|
|
|
ERR("Failed to create DIB section for cursor mask data!\n");
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2010-05-20 14:54:41 +02:00
|
|
|
|
2010-10-05 20:06:18 +02:00
|
|
|
/* Create an XcursorImage for each frame of the cursor */
|
2011-03-10 06:56:50 +01:00
|
|
|
for (i=0; i<nFrames; i++)
|
2010-05-20 14:54:41 +02:00
|
|
|
{
|
2011-03-10 06:56:50 +01:00
|
|
|
imgs[i] = create_xcursor_frame( hdc, iinfo, icon,
|
|
|
|
hbmColor, color_bits, color_size,
|
|
|
|
hbmMask, mask_bits, mask_size,
|
|
|
|
width, height, i );
|
|
|
|
if (!imgs[i]) goto cleanup;
|
2010-05-20 14:54:41 +02:00
|
|
|
}
|
2007-03-22 20:06:19 +01:00
|
|
|
|
2010-10-05 20:06:18 +02:00
|
|
|
/* Build an X cursor out of all of the frames */
|
|
|
|
if (!(images = pXcursorImagesCreate( nFrames ))) goto cleanup;
|
|
|
|
for (images->nimage = 0; images->nimage < nFrames; images->nimage++)
|
|
|
|
images->images[images->nimage] = imgs[images->nimage];
|
|
|
|
cursor = pXcursorImagesLoadCursor( gdi_display, images );
|
|
|
|
pXcursorImagesDestroy( images ); /* Note: this frees each individual frame (calls XcursorImageDestroy) */
|
|
|
|
HeapFree( GetProcessHeap(), 0, imgs );
|
|
|
|
imgs = NULL;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (imgs)
|
|
|
|
{
|
|
|
|
/* Failed to produce a cursor, free previously allocated frames */
|
2011-03-10 06:56:50 +01:00
|
|
|
for (i=0; i<nFrames && imgs[i]; i++)
|
|
|
|
pXcursorImageDestroy( imgs[i] );
|
2010-10-05 20:06:18 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, imgs );
|
|
|
|
}
|
|
|
|
/* Cleanup all of the resources used to obtain the frame data */
|
|
|
|
if (hbmColor) DeleteObject( hbmColor );
|
|
|
|
if (hbmMask) DeleteObject( hbmMask );
|
|
|
|
HeapFree( GetProcessHeap(), 0, info );
|
2007-03-22 20:06:19 +01:00
|
|
|
return cursor;
|
|
|
|
}
|
|
|
|
|
2013-01-17 15:33:09 +01:00
|
|
|
#endif /* SONAME_LIBXCURSOR */
|
|
|
|
|
2010-10-18 12:16:28 +02:00
|
|
|
|
|
|
|
struct system_cursors
|
|
|
|
{
|
|
|
|
WORD id;
|
|
|
|
const char *name;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct system_cursors user32_cursors[] =
|
|
|
|
{
|
|
|
|
{ OCR_NORMAL, "left_ptr" },
|
|
|
|
{ OCR_IBEAM, "xterm" },
|
|
|
|
{ OCR_WAIT, "watch" },
|
|
|
|
{ OCR_CROSS, "cross" },
|
|
|
|
{ OCR_UP, "center_ptr" },
|
|
|
|
{ OCR_SIZE, "fleur" },
|
|
|
|
{ OCR_SIZEALL, "fleur" },
|
|
|
|
{ OCR_ICON, "icon" },
|
|
|
|
{ OCR_SIZENWSE, "nwse-resize" },
|
|
|
|
{ OCR_SIZENESW, "nesw-resize" },
|
|
|
|
{ OCR_SIZEWE, "ew-resize" },
|
|
|
|
{ OCR_SIZENS, "ns-resize" },
|
|
|
|
{ OCR_NO, "not-allowed" },
|
|
|
|
{ OCR_HAND, "hand2" },
|
|
|
|
{ OCR_APPSTARTING, "left_ptr_watch" },
|
|
|
|
{ OCR_HELP, "question_arrow" },
|
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct system_cursors comctl32_cursors[] =
|
|
|
|
{
|
|
|
|
{ 102, "move" },
|
|
|
|
{ 104, "copy" },
|
|
|
|
{ 105, "left_ptr" },
|
2015-03-25 08:36:08 +01:00
|
|
|
{ 106, "col-resize" },
|
|
|
|
{ 107, "col-resize" },
|
2010-10-18 12:16:28 +02:00
|
|
|
{ 108, "hand2" },
|
2015-03-25 08:36:08 +01:00
|
|
|
{ 135, "row-resize" },
|
2010-10-18 12:16:28 +02:00
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct system_cursors ole32_cursors[] =
|
|
|
|
{
|
|
|
|
{ 1, "no-drop" },
|
|
|
|
{ 2, "move" },
|
|
|
|
{ 3, "copy" },
|
|
|
|
{ 4, "alias" },
|
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct system_cursors riched20_cursors[] =
|
|
|
|
{
|
|
|
|
{ 105, "hand2" },
|
|
|
|
{ 107, "right_ptr" },
|
|
|
|
{ 109, "copy" },
|
|
|
|
{ 110, "move" },
|
|
|
|
{ 111, "no-drop" },
|
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct
|
|
|
|
{
|
|
|
|
const struct system_cursors *cursors;
|
|
|
|
WCHAR name[16];
|
|
|
|
} module_cursors[] =
|
|
|
|
{
|
|
|
|
{ user32_cursors, {'u','s','e','r','3','2','.','d','l','l',0} },
|
|
|
|
{ comctl32_cursors, {'c','o','m','c','t','l','3','2','.','d','l','l',0} },
|
|
|
|
{ ole32_cursors, {'o','l','e','3','2','.','d','l','l',0} },
|
|
|
|
{ riched20_cursors, {'r','i','c','h','e','d','2','0','.','d','l','l',0} }
|
|
|
|
};
|
|
|
|
|
2013-01-17 15:33:09 +01:00
|
|
|
struct cursor_font_fallback
|
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
unsigned int shape;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct cursor_font_fallback fallbacks[] =
|
|
|
|
{
|
|
|
|
{ "X_cursor", XC_X_cursor },
|
|
|
|
{ "arrow", XC_arrow },
|
|
|
|
{ "based_arrow_down", XC_based_arrow_down },
|
|
|
|
{ "based_arrow_up", XC_based_arrow_up },
|
|
|
|
{ "boat", XC_boat },
|
|
|
|
{ "bogosity", XC_bogosity },
|
|
|
|
{ "bottom_left_corner", XC_bottom_left_corner },
|
|
|
|
{ "bottom_right_corner", XC_bottom_right_corner },
|
|
|
|
{ "bottom_side", XC_bottom_side },
|
|
|
|
{ "bottom_tee", XC_bottom_tee },
|
|
|
|
{ "box_spiral", XC_box_spiral },
|
|
|
|
{ "center_ptr", XC_center_ptr },
|
|
|
|
{ "circle", XC_circle },
|
|
|
|
{ "clock", XC_clock },
|
|
|
|
{ "coffee_mug", XC_coffee_mug },
|
2015-03-25 08:36:08 +01:00
|
|
|
{ "col-resize", XC_sb_h_double_arrow },
|
2013-01-17 15:33:09 +01:00
|
|
|
{ "cross", XC_cross },
|
|
|
|
{ "cross_reverse", XC_cross_reverse },
|
|
|
|
{ "crosshair", XC_crosshair },
|
|
|
|
{ "diamond_cross", XC_diamond_cross },
|
|
|
|
{ "dot", XC_dot },
|
|
|
|
{ "dotbox", XC_dotbox },
|
|
|
|
{ "double_arrow", XC_double_arrow },
|
|
|
|
{ "draft_large", XC_draft_large },
|
|
|
|
{ "draft_small", XC_draft_small },
|
|
|
|
{ "draped_box", XC_draped_box },
|
|
|
|
{ "exchange", XC_exchange },
|
|
|
|
{ "fleur", XC_fleur },
|
|
|
|
{ "gobbler", XC_gobbler },
|
|
|
|
{ "gumby", XC_gumby },
|
|
|
|
{ "hand1", XC_hand1 },
|
|
|
|
{ "hand2", XC_hand2 },
|
|
|
|
{ "heart", XC_heart },
|
|
|
|
{ "icon", XC_icon },
|
|
|
|
{ "iron_cross", XC_iron_cross },
|
|
|
|
{ "left_ptr", XC_left_ptr },
|
|
|
|
{ "left_side", XC_left_side },
|
|
|
|
{ "left_tee", XC_left_tee },
|
|
|
|
{ "leftbutton", XC_leftbutton },
|
|
|
|
{ "ll_angle", XC_ll_angle },
|
|
|
|
{ "lr_angle", XC_lr_angle },
|
|
|
|
{ "man", XC_man },
|
|
|
|
{ "middlebutton", XC_middlebutton },
|
|
|
|
{ "mouse", XC_mouse },
|
|
|
|
{ "pencil", XC_pencil },
|
|
|
|
{ "pirate", XC_pirate },
|
|
|
|
{ "plus", XC_plus },
|
|
|
|
{ "question_arrow", XC_question_arrow },
|
|
|
|
{ "right_ptr", XC_right_ptr },
|
|
|
|
{ "right_side", XC_right_side },
|
|
|
|
{ "right_tee", XC_right_tee },
|
|
|
|
{ "rightbutton", XC_rightbutton },
|
2015-03-25 08:36:08 +01:00
|
|
|
{ "row-resize", XC_sb_v_double_arrow },
|
2013-01-17 15:33:09 +01:00
|
|
|
{ "rtl_logo", XC_rtl_logo },
|
|
|
|
{ "sailboat", XC_sailboat },
|
|
|
|
{ "sb_down_arrow", XC_sb_down_arrow },
|
|
|
|
{ "sb_h_double_arrow", XC_sb_h_double_arrow },
|
|
|
|
{ "sb_left_arrow", XC_sb_left_arrow },
|
|
|
|
{ "sb_right_arrow", XC_sb_right_arrow },
|
|
|
|
{ "sb_up_arrow", XC_sb_up_arrow },
|
|
|
|
{ "sb_v_double_arrow", XC_sb_v_double_arrow },
|
|
|
|
{ "shuttle", XC_shuttle },
|
|
|
|
{ "sizing", XC_sizing },
|
|
|
|
{ "spider", XC_spider },
|
|
|
|
{ "spraycan", XC_spraycan },
|
|
|
|
{ "star", XC_star },
|
|
|
|
{ "target", XC_target },
|
|
|
|
{ "tcross", XC_tcross },
|
|
|
|
{ "top_left_arrow", XC_top_left_arrow },
|
|
|
|
{ "top_left_corner", XC_top_left_corner },
|
|
|
|
{ "top_right_corner", XC_top_right_corner },
|
|
|
|
{ "top_side", XC_top_side },
|
|
|
|
{ "top_tee", XC_top_tee },
|
|
|
|
{ "trek", XC_trek },
|
|
|
|
{ "ul_angle", XC_ul_angle },
|
|
|
|
{ "umbrella", XC_umbrella },
|
|
|
|
{ "ur_angle", XC_ur_angle },
|
|
|
|
{ "watch", XC_watch },
|
|
|
|
{ "xterm", XC_xterm }
|
|
|
|
};
|
|
|
|
|
|
|
|
static int fallback_cmp( const void *key, const void *member )
|
|
|
|
{
|
|
|
|
const struct cursor_font_fallback *fallback = member;
|
|
|
|
return strcmp( key, fallback->name );
|
|
|
|
}
|
|
|
|
|
|
|
|
static int find_fallback_shape( const char *name )
|
|
|
|
{
|
|
|
|
struct cursor_font_fallback *fallback;
|
|
|
|
|
|
|
|
if ((fallback = bsearch( name, fallbacks, sizeof(fallbacks) / sizeof(fallbacks[0]),
|
|
|
|
sizeof(*fallback), fallback_cmp )))
|
|
|
|
return fallback->shape;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2010-10-18 12:16:28 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* create_xcursor_system_cursor
|
|
|
|
*
|
|
|
|
* Create an X cursor for a system cursor.
|
|
|
|
*/
|
|
|
|
static Cursor create_xcursor_system_cursor( const ICONINFOEXW *info )
|
|
|
|
{
|
2010-10-18 12:26:28 +02:00
|
|
|
static const WCHAR idW[] = {'%','h','u',0};
|
2010-10-18 12:16:28 +02:00
|
|
|
const struct system_cursors *cursors;
|
|
|
|
unsigned int i;
|
|
|
|
Cursor cursor = 0;
|
|
|
|
HMODULE module;
|
2010-10-18 12:26:28 +02:00
|
|
|
HKEY key;
|
|
|
|
WCHAR *p, name[MAX_PATH * 2], valueW[64];
|
|
|
|
char valueA[64];
|
|
|
|
DWORD size, ret;
|
2010-10-18 12:16:28 +02:00
|
|
|
|
2010-10-18 12:26:28 +02:00
|
|
|
if (!info->szModName[0]) return 0;
|
|
|
|
|
|
|
|
p = strrchrW( info->szModName, '\\' );
|
|
|
|
strcpyW( name, p ? p + 1 : info->szModName );
|
|
|
|
p = name + strlenW( name );
|
|
|
|
*p++ = ',';
|
|
|
|
if (info->szResName[0]) strcpyW( p, info->szResName );
|
|
|
|
else sprintfW( p, idW, info->wResID );
|
|
|
|
valueA[0] = 0;
|
|
|
|
|
|
|
|
/* @@ Wine registry key: HKCU\Software\Wine\X11 Driver\Cursors */
|
|
|
|
if (!RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\X11 Driver\\Cursors", &key ))
|
|
|
|
{
|
|
|
|
size = sizeof(valueW) / sizeof(WCHAR);
|
|
|
|
ret = RegQueryValueExW( key, name, NULL, NULL, (BYTE *)valueW, &size );
|
|
|
|
RegCloseKey( key );
|
|
|
|
if (!ret)
|
|
|
|
{
|
|
|
|
if (!valueW[0]) return 0; /* force standard cursor */
|
|
|
|
if (!WideCharToMultiByte( CP_UNIXCP, 0, valueW, -1, valueA, sizeof(valueA), NULL, NULL ))
|
|
|
|
valueA[0] = 0;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info->szResName[0]) goto done; /* only integer resources are supported here */
|
|
|
|
if (!(module = GetModuleHandleW( info->szModName ))) goto done;
|
2010-10-18 12:16:28 +02:00
|
|
|
|
|
|
|
for (i = 0; i < sizeof(module_cursors)/sizeof(module_cursors[0]); i++)
|
|
|
|
if (GetModuleHandleW( module_cursors[i].name ) == module) break;
|
2010-10-18 12:26:28 +02:00
|
|
|
if (i == sizeof(module_cursors)/sizeof(module_cursors[0])) goto done;
|
2010-10-18 12:16:28 +02:00
|
|
|
|
|
|
|
cursors = module_cursors[i].cursors;
|
2010-10-18 12:26:28 +02:00
|
|
|
for (i = 0; cursors[i].id; i++)
|
|
|
|
if (cursors[i].id == info->wResID)
|
|
|
|
{
|
|
|
|
strcpy( valueA, cursors[i].name );
|
|
|
|
break;
|
|
|
|
}
|
2010-10-18 12:16:28 +02:00
|
|
|
|
2010-10-18 12:26:28 +02:00
|
|
|
done:
|
|
|
|
if (valueA[0])
|
2010-10-18 12:16:28 +02:00
|
|
|
{
|
2013-01-17 15:33:09 +01:00
|
|
|
#ifdef SONAME_LIBXCURSOR
|
|
|
|
if (pXcursorLibraryLoadCursor) cursor = pXcursorLibraryLoadCursor( gdi_display, valueA );
|
|
|
|
#endif
|
|
|
|
if (!cursor)
|
|
|
|
{
|
|
|
|
int shape = find_fallback_shape( valueA );
|
|
|
|
if (shape != -1) cursor = XCreateFontCursor( gdi_display, shape );
|
|
|
|
}
|
2010-10-18 12:26:28 +02:00
|
|
|
if (!cursor) WARN( "no system cursor found for %s mapped to %s\n",
|
|
|
|
debugstr_w(name), debugstr_a(valueA) );
|
2010-10-18 12:16:28 +02:00
|
|
|
}
|
2010-10-18 12:26:28 +02:00
|
|
|
else WARN( "no system cursor found for %s\n", debugstr_w(name) );
|
2010-10-18 12:16:28 +02:00
|
|
|
return cursor;
|
|
|
|
}
|
|
|
|
|
2007-03-22 20:06:19 +01:00
|
|
|
|
2002-06-14 02:08:40 +02:00
|
|
|
/***********************************************************************
|
2012-05-15 16:18:34 +02:00
|
|
|
* create_xlib_monochrome_cursor
|
2010-05-21 12:51:14 +02:00
|
|
|
*
|
2012-05-15 16:18:34 +02:00
|
|
|
* Create a monochrome X cursor from a Windows one.
|
2010-05-21 12:51:14 +02:00
|
|
|
*/
|
2012-05-15 16:18:34 +02:00
|
|
|
static Cursor create_xlib_monochrome_cursor( HDC hdc, const ICONINFOEXW *icon, int width, int height )
|
2010-05-21 12:51:14 +02:00
|
|
|
{
|
2012-05-15 16:18:34 +02:00
|
|
|
char buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )];
|
|
|
|
BITMAPINFO *info = (BITMAPINFO *)buffer;
|
|
|
|
const int and_y = 0;
|
|
|
|
const int xor_y = height;
|
|
|
|
unsigned int width_bytes = (width + 31) / 32 * 4;
|
|
|
|
unsigned char *mask_bits = NULL;
|
|
|
|
GC gc;
|
|
|
|
XColor fg, bg;
|
2012-09-25 15:51:03 +02:00
|
|
|
XVisualInfo vis = default_visual;
|
2012-05-15 16:18:34 +02:00
|
|
|
Pixmap src_pixmap, bits_pixmap, mask_pixmap;
|
|
|
|
struct gdi_image_bits bits;
|
2010-05-21 12:51:14 +02:00
|
|
|
Cursor cursor = 0;
|
|
|
|
|
2012-05-15 16:18:34 +02:00
|
|
|
info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
|
|
|
info->bmiHeader.biWidth = width;
|
|
|
|
info->bmiHeader.biHeight = -height * 2;
|
|
|
|
info->bmiHeader.biPlanes = 1;
|
|
|
|
info->bmiHeader.biBitCount = 1;
|
|
|
|
info->bmiHeader.biCompression = BI_RGB;
|
|
|
|
info->bmiHeader.biSizeImage = width_bytes * height * 2;
|
|
|
|
info->bmiHeader.biXPelsPerMeter = 0;
|
|
|
|
info->bmiHeader.biYPelsPerMeter = 0;
|
|
|
|
info->bmiHeader.biClrUsed = 0;
|
|
|
|
info->bmiHeader.biClrImportant = 0;
|
|
|
|
|
|
|
|
if (!(mask_bits = HeapAlloc( GetProcessHeap(), 0, info->bmiHeader.biSizeImage ))) goto done;
|
|
|
|
if (!GetDIBits( hdc, icon->hbmMask, 0, height * 2, mask_bits, info, DIB_RGB_COLORS )) goto done;
|
|
|
|
|
|
|
|
vis.depth = 1;
|
|
|
|
bits.ptr = mask_bits;
|
|
|
|
bits.free = NULL;
|
|
|
|
bits.is_copy = TRUE;
|
|
|
|
if (!(src_pixmap = create_pixmap_from_image( hdc, &vis, info, &bits, DIB_RGB_COLORS ))) goto done;
|
2010-05-21 12:51:14 +02:00
|
|
|
|
2012-05-15 16:18:34 +02:00
|
|
|
bits_pixmap = XCreatePixmap( gdi_display, root_window, width, height, 1 );
|
|
|
|
mask_pixmap = XCreatePixmap( gdi_display, root_window, width, height, 1 );
|
|
|
|
gc = XCreateGC( gdi_display, src_pixmap, 0, NULL );
|
|
|
|
XSetGraphicsExposures( gdi_display, gc, False );
|
2010-05-21 12:51:14 +02:00
|
|
|
|
|
|
|
/* We have to do some magic here, as cursors are not fully
|
|
|
|
* compatible between Windows and X11. Under X11, there are
|
|
|
|
* only 3 possible color cursor: black, white and masked. So
|
|
|
|
* we map the 4th Windows color (invert the bits on the screen)
|
2012-05-15 10:15:32 +02:00
|
|
|
* to black and an additional white bit on another place
|
2010-05-21 12:51:14 +02:00
|
|
|
* (+1,+1). This require some boolean arithmetic:
|
|
|
|
*
|
|
|
|
* Windows | X11
|
|
|
|
* And Xor Result | Bits Mask Result
|
|
|
|
* 0 0 black | 0 1 background
|
|
|
|
* 0 1 white | 1 1 foreground
|
|
|
|
* 1 0 no change | X 0 no change
|
|
|
|
* 1 1 inverted | 0 1 background
|
|
|
|
*
|
|
|
|
* which gives:
|
|
|
|
* Bits = not 'And' and 'Xor' or 'And2' and 'Xor2'
|
|
|
|
* Mask = not 'And' or 'Xor' or 'And2' and 'Xor2'
|
|
|
|
*/
|
2012-05-15 16:18:34 +02:00
|
|
|
XSetFunction( gdi_display, gc, GXcopy );
|
|
|
|
XCopyArea( gdi_display, src_pixmap, bits_pixmap, gc, 0, and_y, width, height, 0, 0 );
|
|
|
|
XCopyArea( gdi_display, src_pixmap, mask_pixmap, gc, 0, and_y, width, height, 0, 0 );
|
|
|
|
XSetFunction( gdi_display, gc, GXandReverse );
|
|
|
|
XCopyArea( gdi_display, src_pixmap, bits_pixmap, gc, 0, xor_y, width, height, 0, 0 );
|
|
|
|
XSetFunction( gdi_display, gc, GXorReverse );
|
|
|
|
XCopyArea( gdi_display, src_pixmap, mask_pixmap, gc, 0, xor_y, width, height, 0, 0 );
|
2010-05-21 12:51:14 +02:00
|
|
|
/* additional white */
|
2012-05-15 16:18:34 +02:00
|
|
|
XSetFunction( gdi_display, gc, GXand );
|
|
|
|
XCopyArea( gdi_display, src_pixmap, src_pixmap, gc, 0, xor_y, width, height, 0, and_y );
|
|
|
|
XSetFunction( gdi_display, gc, GXor );
|
|
|
|
XCopyArea( gdi_display, src_pixmap, mask_pixmap, gc, 0, and_y, width, height, 1, 1 );
|
|
|
|
XCopyArea( gdi_display, src_pixmap, bits_pixmap, gc, 0, and_y, width, height, 1, 1 );
|
|
|
|
XFreeGC( gdi_display, gc );
|
|
|
|
|
|
|
|
fg.red = fg.green = fg.blue = 0xffff;
|
|
|
|
bg.red = bg.green = bg.blue = 0;
|
|
|
|
cursor = XCreatePixmapCursor( gdi_display, bits_pixmap, mask_pixmap,
|
|
|
|
&fg, &bg, icon->xHotspot, icon->yHotspot );
|
|
|
|
XFreePixmap( gdi_display, src_pixmap );
|
|
|
|
XFreePixmap( gdi_display, bits_pixmap );
|
|
|
|
XFreePixmap( gdi_display, mask_pixmap );
|
2010-05-21 12:51:14 +02:00
|
|
|
|
|
|
|
done:
|
2012-05-15 16:18:34 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, mask_bits );
|
2010-05-21 12:51:14 +02:00
|
|
|
return cursor;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2012-05-15 16:18:34 +02:00
|
|
|
* create_xlib_color_cursor
|
2002-06-14 02:08:40 +02:00
|
|
|
*
|
2012-05-15 16:18:34 +02:00
|
|
|
* Create a color X cursor from a Windows one.
|
2002-06-14 02:08:40 +02:00
|
|
|
*/
|
2012-05-15 16:18:34 +02:00
|
|
|
static Cursor create_xlib_color_cursor( HDC hdc, const ICONINFOEXW *icon, int width, int height )
|
1998-12-26 13:00:43 +01:00
|
|
|
{
|
2012-05-15 15:46:23 +02:00
|
|
|
char buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )];
|
|
|
|
BITMAPINFO *info = (BITMAPINFO *)buffer;
|
1998-12-26 13:00:43 +01:00
|
|
|
XColor fg, bg;
|
|
|
|
Cursor cursor = None;
|
2012-09-25 15:51:03 +02:00
|
|
|
XVisualInfo vis = default_visual;
|
2012-05-15 15:46:23 +02:00
|
|
|
Pixmap xor_pixmap, mask_pixmap;
|
|
|
|
struct gdi_image_bits bits;
|
2010-05-21 12:51:14 +02:00
|
|
|
unsigned int *color_bits = NULL, *ptr;
|
|
|
|
unsigned char *mask_bits = NULL, *xor_bits = NULL;
|
2013-10-01 23:33:53 +02:00
|
|
|
int i, x, y;
|
|
|
|
BOOL has_alpha = FALSE;
|
2010-05-21 12:51:14 +02:00
|
|
|
int rfg, gfg, bfg, rbg, gbg, bbg, fgBits, bgBits;
|
|
|
|
unsigned int width_bytes = (width + 31) / 32 * 4;
|
|
|
|
|
|
|
|
info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
|
|
|
info->bmiHeader.biWidth = width;
|
|
|
|
info->bmiHeader.biHeight = -height;
|
|
|
|
info->bmiHeader.biPlanes = 1;
|
|
|
|
info->bmiHeader.biBitCount = 1;
|
|
|
|
info->bmiHeader.biCompression = BI_RGB;
|
|
|
|
info->bmiHeader.biSizeImage = width_bytes * height;
|
|
|
|
info->bmiHeader.biXPelsPerMeter = 0;
|
|
|
|
info->bmiHeader.biYPelsPerMeter = 0;
|
|
|
|
info->bmiHeader.biClrUsed = 0;
|
|
|
|
info->bmiHeader.biClrImportant = 0;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2010-05-21 12:51:14 +02:00
|
|
|
if (!(mask_bits = HeapAlloc( GetProcessHeap(), 0, info->bmiHeader.biSizeImage ))) goto done;
|
|
|
|
if (!GetDIBits( hdc, icon->hbmMask, 0, height, mask_bits, info, DIB_RGB_COLORS )) goto done;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2010-05-21 12:51:14 +02:00
|
|
|
info->bmiHeader.biBitCount = 32;
|
|
|
|
info->bmiHeader.biSizeImage = width * height * 4;
|
|
|
|
if (!(color_bits = HeapAlloc( GetProcessHeap(), 0, info->bmiHeader.biSizeImage ))) goto done;
|
|
|
|
if (!(xor_bits = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, width_bytes * height ))) goto done;
|
|
|
|
GetDIBits( hdc, icon->hbmColor, 0, height, color_bits, info, DIB_RGB_COLORS );
|
1998-12-26 13:00:43 +01:00
|
|
|
|
2010-05-21 12:51:14 +02:00
|
|
|
/* compute fg/bg color and xor bitmap based on average of the color values */
|
1998-12-26 13:00:43 +01:00
|
|
|
|
2010-05-21 12:51:14 +02:00
|
|
|
rfg = gfg = bfg = rbg = gbg = bbg = fgBits = 0;
|
|
|
|
for (y = 0, ptr = color_bits; y < height; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < width; x++, ptr++)
|
1998-12-26 13:00:43 +01:00
|
|
|
{
|
2010-05-21 12:51:14 +02:00
|
|
|
int red = (*ptr >> 16) & 0xff;
|
|
|
|
int green = (*ptr >> 8) & 0xff;
|
|
|
|
int blue = (*ptr >> 0) & 0xff;
|
|
|
|
if (red + green + blue > 0x40)
|
2002-06-02 23:29:23 +02:00
|
|
|
{
|
2010-05-21 12:51:14 +02:00
|
|
|
rfg += red;
|
|
|
|
gfg += green;
|
|
|
|
bfg += blue;
|
|
|
|
fgBits++;
|
|
|
|
xor_bits[y * width_bytes + x / 8] |= 0x80 >> (x % 8);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rbg += red;
|
|
|
|
gbg += green;
|
|
|
|
bbg += blue;
|
2002-06-02 23:29:23 +02:00
|
|
|
}
|
2007-04-26 01:49:22 +02:00
|
|
|
}
|
2010-05-21 12:51:14 +02:00
|
|
|
}
|
|
|
|
if (fgBits)
|
|
|
|
{
|
|
|
|
fg.red = rfg * 257 / fgBits;
|
|
|
|
fg.green = gfg * 257 / fgBits;
|
|
|
|
fg.blue = bfg * 257 / fgBits;
|
|
|
|
}
|
|
|
|
else fg.red = fg.green = fg.blue = 0;
|
|
|
|
bgBits = width * height - fgBits;
|
|
|
|
if (bgBits)
|
|
|
|
{
|
|
|
|
bg.red = rbg * 257 / bgBits;
|
|
|
|
bg.green = gbg * 257 / bgBits;
|
|
|
|
bg.blue = bbg * 257 / bgBits;
|
|
|
|
}
|
|
|
|
else bg.red = bg.green = bg.blue = 0;
|
2007-04-26 01:49:22 +02:00
|
|
|
|
2010-05-21 12:51:14 +02:00
|
|
|
info->bmiHeader.biBitCount = 1;
|
2012-05-15 15:46:23 +02:00
|
|
|
info->bmiHeader.biClrUsed = 0;
|
2010-05-21 12:51:14 +02:00
|
|
|
info->bmiHeader.biSizeImage = width_bytes * height;
|
|
|
|
|
|
|
|
/* generate mask from the alpha channel if we have one */
|
|
|
|
|
|
|
|
for (i = 0, ptr = color_bits; i < width * height; i++, ptr++)
|
|
|
|
if ((has_alpha = (*ptr & 0xff000000) != 0)) break;
|
2007-04-26 01:49:22 +02:00
|
|
|
|
2010-05-21 12:51:14 +02:00
|
|
|
if (has_alpha)
|
|
|
|
{
|
|
|
|
memset( mask_bits, 0, width_bytes * height );
|
|
|
|
for (y = 0, ptr = color_bits; y < height; y++)
|
|
|
|
for (x = 0; x < width; x++, ptr++)
|
|
|
|
if ((*ptr >> 24) > 25) /* more than 10% alpha */
|
|
|
|
mask_bits[y * width_bytes + x / 8] |= 0x80 >> (x % 8);
|
2012-05-15 15:46:23 +02:00
|
|
|
}
|
|
|
|
else /* invert the mask */
|
|
|
|
{
|
2013-03-05 23:52:11 +01:00
|
|
|
unsigned int j;
|
|
|
|
|
2012-05-15 15:46:23 +02:00
|
|
|
ptr = (unsigned int *)mask_bits;
|
2013-03-05 23:52:11 +01:00
|
|
|
for (j = 0; j < info->bmiHeader.biSizeImage / sizeof(*ptr); j++, ptr++) *ptr ^= ~0u;
|
2012-05-15 15:46:23 +02:00
|
|
|
}
|
1998-12-26 13:00:43 +01:00
|
|
|
|
2012-05-15 15:46:23 +02:00
|
|
|
vis.depth = 1;
|
|
|
|
bits.ptr = xor_bits;
|
|
|
|
bits.free = NULL;
|
|
|
|
bits.is_copy = TRUE;
|
|
|
|
if (!(xor_pixmap = create_pixmap_from_image( hdc, &vis, info, &bits, DIB_RGB_COLORS ))) goto done;
|
1998-12-26 13:00:43 +01:00
|
|
|
|
2012-05-15 15:46:23 +02:00
|
|
|
bits.ptr = mask_bits;
|
|
|
|
mask_pixmap = create_pixmap_from_image( hdc, &vis, info, &bits, DIB_RGB_COLORS );
|
|
|
|
|
|
|
|
if (mask_pixmap)
|
2010-05-21 12:51:14 +02:00
|
|
|
{
|
2012-05-15 15:46:23 +02:00
|
|
|
cursor = XCreatePixmapCursor( gdi_display, xor_pixmap, mask_pixmap,
|
|
|
|
&fg, &bg, icon->xHotspot, icon->yHotspot );
|
|
|
|
XFreePixmap( gdi_display, mask_pixmap );
|
1998-12-26 13:00:43 +01:00
|
|
|
}
|
2012-05-15 15:46:23 +02:00
|
|
|
XFreePixmap( gdi_display, xor_pixmap );
|
2010-05-21 12:51:14 +02:00
|
|
|
|
|
|
|
done:
|
|
|
|
HeapFree( GetProcessHeap(), 0, color_bits );
|
|
|
|
HeapFree( GetProcessHeap(), 0, xor_bits );
|
|
|
|
HeapFree( GetProcessHeap(), 0, mask_bits );
|
2001-05-16 21:52:29 +02:00
|
|
|
return cursor;
|
|
|
|
}
|
1998-12-26 13:00:43 +01:00
|
|
|
|
2010-05-20 14:40:06 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* create_cursor
|
|
|
|
*
|
|
|
|
* Create an X cursor from a Windows one.
|
|
|
|
*/
|
2010-05-21 12:51:14 +02:00
|
|
|
static Cursor create_cursor( HANDLE handle )
|
2010-05-20 14:40:06 +02:00
|
|
|
{
|
2010-05-20 14:54:41 +02:00
|
|
|
Cursor cursor = 0;
|
2010-10-18 12:09:25 +02:00
|
|
|
ICONINFOEXW info;
|
2010-05-20 14:54:41 +02:00
|
|
|
BITMAP bm;
|
2012-05-15 16:18:34 +02:00
|
|
|
HDC hdc;
|
2010-05-20 14:40:06 +02:00
|
|
|
|
|
|
|
if (!handle) return get_empty_cursor();
|
|
|
|
|
2010-10-18 12:09:25 +02:00
|
|
|
info.cbSize = sizeof(info);
|
2010-10-18 12:11:17 +02:00
|
|
|
if (!GetIconInfoExW( handle, &info )) return 0;
|
2010-05-20 14:54:41 +02:00
|
|
|
|
2010-10-18 12:16:28 +02:00
|
|
|
if (use_system_cursors && (cursor = create_xcursor_system_cursor( &info )))
|
|
|
|
{
|
|
|
|
DeleteObject( info.hbmColor );
|
|
|
|
DeleteObject( info.hbmMask );
|
|
|
|
return cursor;
|
|
|
|
}
|
|
|
|
|
2010-05-20 14:54:41 +02:00
|
|
|
GetObjectW( info.hbmMask, sizeof(bm), &bm );
|
2011-11-16 18:21:21 +01:00
|
|
|
if (!info.hbmColor) bm.bmHeight = max( 1, bm.bmHeight / 2 );
|
2010-05-20 14:54:41 +02:00
|
|
|
|
|
|
|
/* make sure hotspot is valid */
|
|
|
|
if (info.xHotspot >= bm.bmWidth || info.yHotspot >= bm.bmHeight)
|
|
|
|
{
|
|
|
|
info.xHotspot = bm.bmWidth / 2;
|
|
|
|
info.yHotspot = bm.bmHeight / 2;
|
|
|
|
}
|
|
|
|
|
2012-05-15 16:18:34 +02:00
|
|
|
hdc = CreateCompatibleDC( 0 );
|
|
|
|
|
2010-05-21 12:51:14 +02:00
|
|
|
if (info.hbmColor)
|
|
|
|
{
|
2010-05-20 14:40:06 +02:00
|
|
|
#ifdef SONAME_LIBXCURSOR
|
2012-05-15 16:18:34 +02:00
|
|
|
if (pXcursorImagesLoadCursor)
|
|
|
|
cursor = create_xcursor_cursor( hdc, &info, handle, bm.bmWidth, bm.bmHeight );
|
2010-05-20 14:54:41 +02:00
|
|
|
#endif
|
2012-05-15 16:18:34 +02:00
|
|
|
if (!cursor) cursor = create_xlib_color_cursor( hdc, &info, bm.bmWidth, bm.bmHeight );
|
2010-05-21 12:51:14 +02:00
|
|
|
DeleteObject( info.hbmColor );
|
|
|
|
}
|
|
|
|
else
|
2010-05-20 14:40:06 +02:00
|
|
|
{
|
2012-05-15 16:18:34 +02:00
|
|
|
cursor = create_xlib_monochrome_cursor( hdc, &info, bm.bmWidth, bm.bmHeight );
|
2010-05-20 14:40:06 +02:00
|
|
|
}
|
2010-05-21 12:51:14 +02:00
|
|
|
|
2010-05-20 14:54:41 +02:00
|
|
|
DeleteObject( info.hbmMask );
|
2012-05-15 16:18:34 +02:00
|
|
|
DeleteDC( hdc );
|
2010-05-20 14:40:06 +02:00
|
|
|
return cursor;
|
|
|
|
}
|
|
|
|
|
2010-04-20 19:25:14 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* DestroyCursorIcon (X11DRV.@)
|
|
|
|
*/
|
|
|
|
void CDECL X11DRV_DestroyCursorIcon( HCURSOR handle )
|
|
|
|
{
|
|
|
|
Cursor cursor;
|
|
|
|
|
2012-08-15 15:51:06 +02:00
|
|
|
if (!XFindContext( gdi_display, (XID)handle, cursor_context, (char **)&cursor ))
|
2010-04-20 19:25:14 +02:00
|
|
|
{
|
|
|
|
TRACE( "%p xid %lx\n", handle, cursor );
|
|
|
|
XFreeCursor( gdi_display, cursor );
|
|
|
|
XDeleteContext( gdi_display, (XID)handle, cursor_context );
|
|
|
|
}
|
|
|
|
}
|
1999-06-13 10:35:26 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
2001-02-12 04:49:07 +01:00
|
|
|
* SetCursor (X11DRV.@)
|
1999-06-13 10:35:26 +02:00
|
|
|
*/
|
2010-04-20 21:14:31 +02:00
|
|
|
void CDECL X11DRV_SetCursor( HCURSOR handle )
|
1999-06-13 10:35:26 +02:00
|
|
|
{
|
2011-04-04 15:06:59 +02:00
|
|
|
if (InterlockedExchangePointer( (void **)&last_cursor, handle ) != handle ||
|
|
|
|
GetTickCount() - last_cursor_change > 100)
|
|
|
|
{
|
|
|
|
last_cursor_change = GetTickCount();
|
2011-11-09 14:26:34 +01:00
|
|
|
if (cursor_window) SendNotifyMessageW( cursor_window, WM_X11DRV_SET_CURSOR, 0, (LPARAM)handle );
|
2011-04-04 15:06:59 +02:00
|
|
|
}
|
1998-12-26 13:00:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-21 02:44:09 +02:00
|
|
|
* SetCursorPos (X11DRV.@)
|
1998-12-26 13:00:43 +01:00
|
|
|
*/
|
2008-12-16 15:32:08 +01:00
|
|
|
BOOL CDECL X11DRV_SetCursorPos( INT x, INT y )
|
1998-12-26 13:00:43 +01:00
|
|
|
{
|
2011-04-13 20:18:30 +02:00
|
|
|
struct x11drv_thread_data *data = x11drv_init_thread_data();
|
2013-10-14 14:20:08 +02:00
|
|
|
POINT pos = virtual_screen_to_root( x, y );
|
2011-04-13 20:18:30 +02:00
|
|
|
|
2013-10-14 14:20:08 +02:00
|
|
|
XWarpPointer( data->display, root_window, root_window, 0, 0, 0, 0, pos.x, pos.y );
|
2011-06-20 19:31:05 +02:00
|
|
|
data->warp_serial = NextRequest( data->display );
|
|
|
|
XNoOp( data->display );
|
2011-04-13 20:18:30 +02:00
|
|
|
XFlush( data->display ); /* avoids bad mouse lag in games that do their own mouse warping */
|
2011-05-16 14:33:32 +02:00
|
|
|
TRACE( "warped to %d,%d serial %lu\n", x, y, data->warp_serial );
|
2005-03-09 17:45:23 +01:00
|
|
|
return TRUE;
|
2001-06-21 02:44:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetCursorPos (X11DRV.@)
|
|
|
|
*/
|
2008-12-16 15:32:08 +01:00
|
|
|
BOOL CDECL X11DRV_GetCursorPos(LPPOINT pos)
|
2001-06-21 02:44:09 +02:00
|
|
|
{
|
2008-06-26 16:47:42 +02:00
|
|
|
Display *display = thread_init_display();
|
2005-03-09 17:45:23 +01:00
|
|
|
Window root, child;
|
|
|
|
int rootX, rootY, winX, winY;
|
|
|
|
unsigned int xstate;
|
2011-03-02 16:28:23 +01:00
|
|
|
BOOL ret;
|
1998-12-26 13:00:43 +01:00
|
|
|
|
2011-03-02 16:28:23 +01:00
|
|
|
ret = XQueryPointer( display, root_window, &root, &child, &rootX, &rootY, &winX, &winY, &xstate );
|
|
|
|
if (ret)
|
2005-03-09 17:45:23 +01:00
|
|
|
{
|
2011-05-16 14:33:32 +02:00
|
|
|
POINT old = *pos;
|
2013-10-14 14:20:08 +02:00
|
|
|
*pos = root_to_virtual_screen( winX, winY );
|
2016-07-06 00:54:09 +02:00
|
|
|
TRACE( "pointer at %s server pos %s\n", wine_dbgstr_point(pos), wine_dbgstr_point(&old) );
|
2005-03-09 17:45:23 +01:00
|
|
|
}
|
2011-02-28 22:50:21 +01:00
|
|
|
return ret;
|
2001-10-18 23:38:59 +02:00
|
|
|
}
|
|
|
|
|
2011-04-05 11:50:45 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ClipCursor (X11DRV.@)
|
|
|
|
*/
|
|
|
|
BOOL CDECL X11DRV_ClipCursor( LPCRECT clip )
|
|
|
|
{
|
2013-10-14 14:38:58 +02:00
|
|
|
RECT virtual_rect = get_virtual_screen_rect();
|
|
|
|
|
|
|
|
if (!clip) clip = &virtual_rect;
|
2011-04-28 13:07:05 +02:00
|
|
|
|
2011-05-11 12:30:03 +02:00
|
|
|
if (grab_pointer)
|
2011-04-05 11:50:45 +02:00
|
|
|
{
|
2011-04-28 13:07:05 +02:00
|
|
|
HWND foreground = GetForegroundWindow();
|
2011-04-05 11:50:45 +02:00
|
|
|
|
2011-05-11 12:30:03 +02:00
|
|
|
/* we are clipping if the clip rectangle is smaller than the screen */
|
2013-10-14 14:38:58 +02:00
|
|
|
if (clip->left > virtual_rect.left || clip->right < virtual_rect.right ||
|
|
|
|
clip->top > virtual_rect.top || clip->bottom < virtual_rect.bottom)
|
2011-04-28 13:07:05 +02:00
|
|
|
{
|
2011-05-11 12:30:03 +02:00
|
|
|
DWORD tid, pid;
|
|
|
|
|
|
|
|
/* forward request to the foreground window if it's in a different thread */
|
|
|
|
tid = GetWindowThreadProcessId( foreground, &pid );
|
|
|
|
if (tid && tid != GetCurrentThreadId() && pid == GetCurrentProcessId())
|
|
|
|
{
|
|
|
|
TRACE( "forwarding clip request to %p\n", foreground );
|
2011-05-16 14:31:05 +02:00
|
|
|
SendNotifyMessageW( foreground, WM_X11DRV_CLIP_CURSOR, 0, 0 );
|
|
|
|
return TRUE;
|
2011-05-11 12:30:03 +02:00
|
|
|
}
|
2012-03-12 10:33:52 +01:00
|
|
|
else if (grab_clipping_window( clip )) return TRUE;
|
2011-05-11 12:30:03 +02:00
|
|
|
}
|
|
|
|
else /* if currently clipping, check if we should switch to fullscreen clipping */
|
|
|
|
{
|
|
|
|
struct x11drv_thread_data *data = x11drv_thread_data();
|
2011-05-12 16:24:58 +02:00
|
|
|
if (data && data->clip_hwnd)
|
|
|
|
{
|
|
|
|
if (EqualRect( clip, &clip_rect ) || clip_fullscreen_window( foreground, TRUE ))
|
|
|
|
return TRUE;
|
|
|
|
}
|
2011-04-28 13:07:05 +02:00
|
|
|
}
|
2011-04-05 11:50:45 +02:00
|
|
|
}
|
2011-04-22 16:28:25 +02:00
|
|
|
ungrab_clipping_window();
|
2011-04-05 11:50:45 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2007-01-04 20:24:50 +01:00
|
|
|
|
2012-02-01 15:46:52 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* move_resize_window
|
|
|
|
*/
|
2012-09-13 20:08:01 +02:00
|
|
|
void move_resize_window( HWND hwnd, int dir )
|
2012-02-01 15:46:52 +01:00
|
|
|
{
|
2012-09-13 20:08:01 +02:00
|
|
|
Display *display = thread_display();
|
2012-02-01 15:46:52 +01:00
|
|
|
DWORD pt;
|
2013-10-14 14:20:08 +02:00
|
|
|
POINT pos;
|
|
|
|
int button = 0;
|
2012-02-01 15:46:52 +01:00
|
|
|
XEvent xev;
|
2012-09-13 20:08:01 +02:00
|
|
|
Window win, root, child;
|
2012-02-01 15:49:19 +01:00
|
|
|
unsigned int xstate;
|
2012-02-01 15:46:52 +01:00
|
|
|
|
2012-09-13 20:08:01 +02:00
|
|
|
if (!(win = X11DRV_get_whole_window( hwnd ))) return;
|
|
|
|
|
2012-02-01 15:46:52 +01:00
|
|
|
pt = GetMessagePos();
|
2013-10-14 14:20:08 +02:00
|
|
|
pos = virtual_screen_to_root( (short)LOWORD( pt ), (short)HIWORD( pt ) );
|
2012-02-01 15:46:52 +01:00
|
|
|
|
|
|
|
if (GetKeyState( VK_LBUTTON ) & 0x8000) button = 1;
|
|
|
|
else if (GetKeyState( VK_MBUTTON ) & 0x8000) button = 2;
|
|
|
|
else if (GetKeyState( VK_RBUTTON ) & 0x8000) button = 3;
|
|
|
|
|
2016-07-06 00:54:09 +02:00
|
|
|
TRACE( "hwnd %p/%lx, pos %s, dir %d, button %d\n", hwnd, win, wine_dbgstr_point(&pos), dir, button );
|
2012-02-01 15:46:52 +01:00
|
|
|
|
|
|
|
xev.xclient.type = ClientMessage;
|
2012-09-13 20:08:01 +02:00
|
|
|
xev.xclient.window = win;
|
2012-02-01 15:46:52 +01:00
|
|
|
xev.xclient.message_type = x11drv_atom(_NET_WM_MOVERESIZE);
|
|
|
|
xev.xclient.serial = 0;
|
|
|
|
xev.xclient.display = display;
|
|
|
|
xev.xclient.send_event = True;
|
|
|
|
xev.xclient.format = 32;
|
2013-10-14 14:20:08 +02:00
|
|
|
xev.xclient.data.l[0] = pos.x; /* x coord */
|
|
|
|
xev.xclient.data.l[1] = pos.y; /* y coord */
|
2012-02-01 15:46:52 +01:00
|
|
|
xev.xclient.data.l[2] = dir; /* direction */
|
|
|
|
xev.xclient.data.l[3] = button; /* button */
|
|
|
|
xev.xclient.data.l[4] = 0; /* unused */
|
|
|
|
|
|
|
|
/* need to ungrab the pointer that may have been automatically grabbed
|
|
|
|
* with a ButtonPress event */
|
|
|
|
XUngrabPointer( display, CurrentTime );
|
|
|
|
XSendEvent(display, root_window, False, SubstructureNotifyMask | SubstructureRedirectMask, &xev);
|
2012-02-01 15:49:19 +01:00
|
|
|
|
|
|
|
/* try to detect the end of the size/move by polling for the mouse button to be released */
|
|
|
|
/* (some apps don't like it if we return before the size/move is done) */
|
|
|
|
|
|
|
|
if (!button) return;
|
2012-12-11 13:57:35 +01:00
|
|
|
SendMessageW( hwnd, WM_ENTERSIZEMOVE, 0, 0 );
|
|
|
|
|
2012-02-01 15:49:19 +01:00
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
MSG msg;
|
|
|
|
INPUT input;
|
2013-10-14 14:20:08 +02:00
|
|
|
int x, y, rootX, rootY;
|
2012-02-01 15:49:19 +01:00
|
|
|
|
2012-08-14 13:38:03 +02:00
|
|
|
if (!XQueryPointer( display, root_window, &root, &child, &rootX, &rootY, &x, &y, &xstate )) break;
|
2012-02-01 15:49:19 +01:00
|
|
|
|
|
|
|
if (!(xstate & (Button1Mask << (button - 1))))
|
|
|
|
{
|
|
|
|
/* fake a button release event */
|
2013-10-14 14:20:08 +02:00
|
|
|
pos = root_to_virtual_screen( x, y );
|
2012-02-01 15:49:19 +01:00
|
|
|
input.type = INPUT_MOUSE;
|
2013-10-14 14:20:08 +02:00
|
|
|
input.u.mi.dx = pos.x;
|
|
|
|
input.u.mi.dy = pos.y;
|
2012-02-01 15:49:19 +01:00
|
|
|
input.u.mi.mouseData = button_up_data[button - 1];
|
|
|
|
input.u.mi.dwFlags = button_up_flags[button - 1] | MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
|
|
|
|
input.u.mi.time = GetTickCount();
|
|
|
|
input.u.mi.dwExtraInfo = 0;
|
2012-09-13 20:08:01 +02:00
|
|
|
__wine_send_input( hwnd, &input );
|
2012-02-01 15:49:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ))
|
|
|
|
{
|
|
|
|
if (!CallMsgFilterW( &msg, MSGF_SIZE ))
|
|
|
|
{
|
|
|
|
TranslateMessage( &msg );
|
|
|
|
DispatchMessageW( &msg );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(xstate & (Button1Mask << (button - 1)))) break;
|
|
|
|
MsgWaitForMultipleObjects( 0, NULL, FALSE, 100, QS_ALLINPUT );
|
|
|
|
}
|
|
|
|
|
2012-09-13 20:08:01 +02:00
|
|
|
TRACE( "hwnd %p/%lx done\n", hwnd, win );
|
2012-12-10 20:30:20 +01:00
|
|
|
SendMessageW( hwnd, WM_EXITSIZEMOVE, 0, 0 );
|
2012-02-01 15:46:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-10-18 23:38:59 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_ButtonPress
|
|
|
|
*/
|
2005-02-26 18:49:38 +01:00
|
|
|
void X11DRV_ButtonPress( HWND hwnd, XEvent *xev )
|
1999-04-01 10:16:08 +02:00
|
|
|
{
|
2005-02-26 18:49:38 +01:00
|
|
|
XButtonEvent *event = &xev->xbutton;
|
2001-10-18 23:38:59 +02:00
|
|
|
int buttonNum = event->button - 1;
|
2011-04-12 21:20:08 +02:00
|
|
|
INPUT input;
|
2000-06-08 06:57:22 +02:00
|
|
|
|
2001-10-18 23:38:59 +02:00
|
|
|
if (buttonNum >= NB_BUTTONS) return;
|
2000-06-08 06:57:22 +02:00
|
|
|
|
2011-04-12 21:20:08 +02:00
|
|
|
TRACE( "hwnd %p/%lx button %u pos %d,%d\n", hwnd, event->window, buttonNum, event->x, event->y );
|
|
|
|
|
|
|
|
input.u.mi.dx = event->x;
|
|
|
|
input.u.mi.dy = event->y;
|
|
|
|
input.u.mi.mouseData = button_down_data[buttonNum];
|
|
|
|
input.u.mi.dwFlags = button_down_flags[buttonNum] | MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
|
|
|
|
input.u.mi.time = EVENT_x11_time_to_win32_time( event->time );
|
|
|
|
input.u.mi.dwExtraInfo = 0;
|
2005-03-21 13:37:00 +01:00
|
|
|
|
2010-06-29 11:08:51 +02:00
|
|
|
update_user_time( event->time );
|
2011-04-12 21:20:08 +02:00
|
|
|
send_mouse_input( hwnd, event->window, event->state, &input );
|
1999-04-01 10:16:08 +02:00
|
|
|
}
|
|
|
|
|
2000-06-08 06:57:22 +02:00
|
|
|
|
1999-11-07 22:25:57 +01:00
|
|
|
/***********************************************************************
|
2001-10-18 23:38:59 +02:00
|
|
|
* X11DRV_ButtonRelease
|
1999-11-07 22:25:57 +01:00
|
|
|
*/
|
2005-02-26 18:49:38 +01:00
|
|
|
void X11DRV_ButtonRelease( HWND hwnd, XEvent *xev )
|
1999-11-07 22:25:57 +01:00
|
|
|
{
|
2005-02-26 18:49:38 +01:00
|
|
|
XButtonEvent *event = &xev->xbutton;
|
2001-10-18 23:38:59 +02:00
|
|
|
int buttonNum = event->button - 1;
|
2011-04-12 21:20:08 +02:00
|
|
|
INPUT input;
|
2000-06-08 06:57:22 +02:00
|
|
|
|
2001-10-18 23:38:59 +02:00
|
|
|
if (buttonNum >= NB_BUTTONS || !button_up_flags[buttonNum]) return;
|
2000-06-08 06:57:22 +02:00
|
|
|
|
2011-04-12 21:20:08 +02:00
|
|
|
TRACE( "hwnd %p/%lx button %u pos %d,%d\n", hwnd, event->window, buttonNum, event->x, event->y );
|
|
|
|
|
|
|
|
input.u.mi.dx = event->x;
|
|
|
|
input.u.mi.dy = event->y;
|
|
|
|
input.u.mi.mouseData = button_up_data[buttonNum];
|
|
|
|
input.u.mi.dwFlags = button_up_flags[buttonNum] | MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
|
|
|
|
input.u.mi.time = EVENT_x11_time_to_win32_time( event->time );
|
|
|
|
input.u.mi.dwExtraInfo = 0;
|
2005-03-24 20:15:41 +01:00
|
|
|
|
2011-04-12 21:20:08 +02:00
|
|
|
send_mouse_input( hwnd, event->window, event->state, &input );
|
2001-10-18 23:38:59 +02:00
|
|
|
}
|
2000-06-08 06:57:22 +02:00
|
|
|
|
|
|
|
|
2001-10-18 23:38:59 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_MotionNotify
|
|
|
|
*/
|
2005-02-26 18:49:38 +01:00
|
|
|
void X11DRV_MotionNotify( HWND hwnd, XEvent *xev )
|
2001-10-18 23:38:59 +02:00
|
|
|
{
|
2005-02-26 18:49:38 +01:00
|
|
|
XMotionEvent *event = &xev->xmotion;
|
2011-04-12 21:20:08 +02:00
|
|
|
INPUT input;
|
2001-10-18 23:38:59 +02:00
|
|
|
|
2011-05-16 14:33:32 +02:00
|
|
|
TRACE( "hwnd %p/%lx pos %d,%d is_hint %d serial %lu\n",
|
|
|
|
hwnd, event->window, event->x, event->y, event->is_hint, event->serial );
|
2004-12-17 19:49:24 +01:00
|
|
|
|
2011-04-12 21:20:08 +02:00
|
|
|
input.u.mi.dx = event->x;
|
|
|
|
input.u.mi.dy = event->y;
|
|
|
|
input.u.mi.mouseData = 0;
|
|
|
|
input.u.mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE;
|
|
|
|
input.u.mi.time = EVENT_x11_time_to_win32_time( event->time );
|
|
|
|
input.u.mi.dwExtraInfo = 0;
|
|
|
|
|
2015-12-01 09:42:01 +01:00
|
|
|
if (!hwnd && is_old_motion_event( event->serial ))
|
2011-05-13 16:19:45 +02:00
|
|
|
{
|
2015-12-01 09:42:01 +01:00
|
|
|
TRACE( "pos %d,%d old serial %lu, ignoring\n", input.u.mi.dx, input.u.mi.dy, event->serial );
|
|
|
|
return;
|
2011-05-13 16:19:45 +02:00
|
|
|
}
|
2011-04-12 21:20:08 +02:00
|
|
|
send_mouse_input( hwnd, event->window, event->state, &input );
|
2002-06-14 02:08:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_EnterNotify
|
|
|
|
*/
|
2005-02-26 18:49:38 +01:00
|
|
|
void X11DRV_EnterNotify( HWND hwnd, XEvent *xev )
|
2002-06-14 02:08:40 +02:00
|
|
|
{
|
2005-02-26 18:49:38 +01:00
|
|
|
XCrossingEvent *event = &xev->xcrossing;
|
2011-04-12 21:20:08 +02:00
|
|
|
INPUT input;
|
2002-06-14 02:08:40 +02:00
|
|
|
|
2011-04-12 21:20:08 +02:00
|
|
|
TRACE( "hwnd %p/%lx pos %d,%d detail %d\n", hwnd, event->window, event->x, event->y, event->detail );
|
2004-12-17 19:49:24 +01:00
|
|
|
|
2012-08-30 12:57:45 +02:00
|
|
|
if (event->detail == NotifyVirtual) return;
|
2016-03-10 14:03:02 +01:00
|
|
|
if (hwnd == x11drv_thread_data()->grab_hwnd) return;
|
2002-06-14 02:08:40 +02:00
|
|
|
|
|
|
|
/* simulate a mouse motion event */
|
2011-04-12 21:20:08 +02:00
|
|
|
input.u.mi.dx = event->x;
|
|
|
|
input.u.mi.dy = event->y;
|
|
|
|
input.u.mi.mouseData = 0;
|
|
|
|
input.u.mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE;
|
|
|
|
input.u.mi.time = EVENT_x11_time_to_win32_time( event->time );
|
|
|
|
input.u.mi.dwExtraInfo = 0;
|
|
|
|
|
2015-12-01 09:42:38 +01:00
|
|
|
if (is_old_motion_event( event->serial ))
|
|
|
|
{
|
|
|
|
TRACE( "pos %d,%d old serial %lu, ignoring\n", input.u.mi.dx, input.u.mi.dy, event->serial );
|
|
|
|
return;
|
|
|
|
}
|
2011-04-12 21:20:08 +02:00
|
|
|
send_mouse_input( hwnd, event->window, event->state, &input );
|
2001-10-18 23:38:59 +02:00
|
|
|
}
|
2011-04-13 18:56:37 +02:00
|
|
|
|
|
|
|
#ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_RawMotion
|
|
|
|
*/
|
2011-05-16 14:33:32 +02:00
|
|
|
static void X11DRV_RawMotion( XGenericEventCookie *xev )
|
2011-04-13 18:56:37 +02:00
|
|
|
{
|
2011-05-16 14:33:32 +02:00
|
|
|
XIRawEvent *event = xev->data;
|
2011-04-13 18:56:37 +02:00
|
|
|
const double *values = event->valuators.values;
|
2013-10-14 14:38:58 +02:00
|
|
|
RECT virtual_rect;
|
2011-04-13 18:56:37 +02:00
|
|
|
INPUT input;
|
2011-12-21 10:58:25 +01:00
|
|
|
int i, j;
|
|
|
|
double dx = 0, dy = 0;
|
2011-05-16 14:33:32 +02:00
|
|
|
struct x11drv_thread_data *thread_data = x11drv_thread_data();
|
2012-08-15 21:21:20 +02:00
|
|
|
XIDeviceInfo *devices = thread_data->xi2_devices;
|
2011-04-13 18:56:37 +02:00
|
|
|
|
|
|
|
if (!event->valuators.mask_len) return;
|
2011-05-16 14:33:32 +02:00
|
|
|
if (thread_data->xi2_state != xi_enabled) return;
|
2011-04-13 18:56:37 +02:00
|
|
|
|
|
|
|
input.u.mi.mouseData = 0;
|
|
|
|
input.u.mi.dwFlags = MOUSEEVENTF_MOVE;
|
|
|
|
input.u.mi.time = EVENT_x11_time_to_win32_time( event->time );
|
|
|
|
input.u.mi.dwExtraInfo = 0;
|
2012-08-15 22:05:07 +02:00
|
|
|
input.u.mi.dx = 0;
|
|
|
|
input.u.mi.dy = 0;
|
2011-12-21 10:58:25 +01:00
|
|
|
|
2013-10-14 14:38:58 +02:00
|
|
|
virtual_rect = get_virtual_screen_rect();
|
2012-08-15 21:21:20 +02:00
|
|
|
for (i = 0; i < thread_data->xi2_device_count; ++i)
|
2011-12-21 10:58:25 +01:00
|
|
|
{
|
2012-08-15 21:21:20 +02:00
|
|
|
if (devices[i].deviceid != event->deviceid) continue;
|
|
|
|
for (j = 0; j < devices[i].num_classes; j++)
|
2011-12-21 10:58:25 +01:00
|
|
|
{
|
2012-08-15 21:21:20 +02:00
|
|
|
XIValuatorClassInfo *class = (XIValuatorClassInfo *)devices[i].classes[j];
|
2011-12-21 10:58:25 +01:00
|
|
|
|
2012-08-15 21:21:20 +02:00
|
|
|
if (devices[i].classes[j]->type != XIValuatorClass) continue;
|
2012-08-15 22:05:07 +02:00
|
|
|
if (XIMaskIsSet( event->valuators.mask, class->number ))
|
|
|
|
{
|
|
|
|
double val = *values++;
|
2012-09-25 19:25:02 +02:00
|
|
|
if (class->label == x11drv_atom( Rel_X ) ||
|
|
|
|
(!class->label && class->number == 0 && class->mode == XIModeRelative))
|
2012-08-15 22:05:07 +02:00
|
|
|
{
|
|
|
|
input.u.mi.dx = dx = val;
|
|
|
|
if (class->min < class->max)
|
2013-10-14 14:38:58 +02:00
|
|
|
input.u.mi.dx = val * (virtual_rect.right - virtual_rect.left)
|
2012-08-15 22:05:07 +02:00
|
|
|
/ (class->max - class->min);
|
|
|
|
}
|
2012-09-25 19:25:02 +02:00
|
|
|
else if (class->label == x11drv_atom( Rel_Y ) ||
|
|
|
|
(!class->label && class->number == 1 && class->mode == XIModeRelative))
|
2012-08-15 22:05:07 +02:00
|
|
|
{
|
|
|
|
input.u.mi.dy = dy = val;
|
|
|
|
if (class->min < class->max)
|
2013-10-14 14:38:58 +02:00
|
|
|
input.u.mi.dy = val * (virtual_rect.bottom - virtual_rect.top)
|
2012-08-15 22:05:07 +02:00
|
|
|
/ (class->max - class->min);
|
|
|
|
}
|
|
|
|
}
|
2011-12-21 10:58:25 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-12-01 09:42:01 +01:00
|
|
|
if (broken_rawevents && is_old_motion_event( xev->serial ))
|
2011-05-16 14:33:32 +02:00
|
|
|
{
|
2015-12-01 09:42:01 +01:00
|
|
|
TRACE( "pos %d,%d old serial %lu, ignoring\n", input.u.mi.dx, input.u.mi.dy, xev->serial );
|
|
|
|
return;
|
2011-05-16 14:33:32 +02:00
|
|
|
}
|
|
|
|
|
2011-12-21 10:58:25 +01:00
|
|
|
TRACE( "pos %d,%d (event %f,%f)\n", input.u.mi.dx, input.u.mi.dy, dx, dy );
|
2011-04-13 18:56:37 +02:00
|
|
|
|
|
|
|
input.type = INPUT_MOUSE;
|
|
|
|
__wine_send_input( 0, &input );
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* HAVE_X11_EXTENSIONS_XINPUT2_H */
|
|
|
|
|
|
|
|
|
2011-04-13 20:18:30 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_XInput2_Init
|
|
|
|
*/
|
|
|
|
void X11DRV_XInput2_Init(void)
|
|
|
|
{
|
|
|
|
#if defined(SONAME_LIBXI) && defined(HAVE_X11_EXTENSIONS_XINPUT2_H)
|
|
|
|
int event, error;
|
|
|
|
void *libxi_handle = wine_dlopen( SONAME_LIBXI, RTLD_NOW, NULL, 0 );
|
|
|
|
|
|
|
|
if (!libxi_handle)
|
|
|
|
{
|
|
|
|
WARN( "couldn't load %s\n", SONAME_LIBXI );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#define LOAD_FUNCPTR(f) \
|
|
|
|
if (!(p##f = wine_dlsym( libxi_handle, #f, NULL, 0))) \
|
|
|
|
{ \
|
|
|
|
WARN("Failed to load %s.\n", #f); \
|
|
|
|
return; \
|
|
|
|
}
|
|
|
|
|
|
|
|
LOAD_FUNCPTR(XIFreeDeviceInfo);
|
|
|
|
LOAD_FUNCPTR(XIQueryDevice);
|
|
|
|
LOAD_FUNCPTR(XIQueryVersion);
|
|
|
|
LOAD_FUNCPTR(XISelectEvents);
|
|
|
|
#undef LOAD_FUNCPTR
|
|
|
|
|
|
|
|
xinput2_available = XQueryExtension( gdi_display, "XInputExtension", &xinput2_opcode, &event, &error );
|
2015-01-26 05:42:32 +01:00
|
|
|
|
|
|
|
/* Until version 1.10.4 rawinput was broken in XOrg, see
|
|
|
|
* https://bugs.freedesktop.org/show_bug.cgi?id=30068 */
|
|
|
|
broken_rawevents = strstr(XServerVendor( gdi_display ), "X.Org") &&
|
|
|
|
XVendorRelease( gdi_display ) < 11004000;
|
|
|
|
|
2011-04-13 20:18:30 +02:00
|
|
|
#else
|
|
|
|
TRACE( "X Input 2 support not compiled in.\n" );
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-13 18:56:37 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_GenericEvent
|
|
|
|
*/
|
|
|
|
void X11DRV_GenericEvent( HWND hwnd, XEvent *xev )
|
|
|
|
{
|
|
|
|
#ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
|
|
|
|
XGenericEventCookie *event = &xev->xcookie;
|
|
|
|
|
|
|
|
if (!event->data) return;
|
2011-04-13 20:18:30 +02:00
|
|
|
if (event->extension != xinput2_opcode) return;
|
2011-04-13 18:56:37 +02:00
|
|
|
|
|
|
|
switch (event->evtype)
|
|
|
|
{
|
|
|
|
case XI_RawMotion:
|
2011-05-16 14:33:32 +02:00
|
|
|
X11DRV_RawMotion( event );
|
2011-04-13 18:56:37 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
TRACE( "Unhandled event %#x\n", event->evtype );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|