mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 09:30:45 -05:00
device-map: Get slave devices in the XI2 implementation
Slave devices are at least needed for touch devices.
This commit is contained in:
parent
0eefb6b306
commit
50aa509ee1
@ -25,6 +25,7 @@
|
|||||||
#include "device-map-xi2.h"
|
#include "device-map-xi2.h"
|
||||||
#include <X11/extensions/XInput2.h>
|
#include <X11/extensions/XInput2.h>
|
||||||
#include "devices-xi2.h"
|
#include "devices-xi2.h"
|
||||||
|
#include "input-events.h"
|
||||||
|
|
||||||
#define XINPUT2_VERSION_MAJOR 2
|
#define XINPUT2_VERSION_MAJOR 2
|
||||||
#define XINPUT2_VERSION_MINOR 0
|
#define XINPUT2_VERSION_MINOR 0
|
||||||
@ -119,26 +120,23 @@ meta_device_map_xi2_ungrab_button (MetaDeviceMap *device_map,
|
|||||||
n_button, xwindow, 1, &mods);
|
n_button, xwindow, 1, &mods);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static MetaDevice *
|
||||||
add_device_from_info (MetaDeviceMap *device_map,
|
create_device_from_info (MetaDeviceMap *device_map,
|
||||||
gint use,
|
gint use,
|
||||||
gint device_id)
|
gint device_id)
|
||||||
{
|
{
|
||||||
MetaDevice *device;
|
MetaDevice *device = NULL;
|
||||||
MetaDisplay *display;
|
MetaDisplay *display;
|
||||||
|
|
||||||
display = meta_device_map_get_display (device_map);
|
display = meta_device_map_get_display (device_map);
|
||||||
|
|
||||||
if (use == XIMasterPointer)
|
if (use == XIMasterPointer ||
|
||||||
|
use == XISlavePointer)
|
||||||
device = meta_device_pointer_xi2_new (display, device_id);
|
device = meta_device_pointer_xi2_new (display, device_id);
|
||||||
else if (use == XIMasterKeyboard)
|
else if (use == XIMasterKeyboard)
|
||||||
device = meta_device_keyboard_xi2_new (display, device_id);
|
device = meta_device_keyboard_xi2_new (display, device_id);
|
||||||
|
|
||||||
if (device)
|
return device;
|
||||||
{
|
|
||||||
meta_device_map_add_device (device_map, device);
|
|
||||||
g_object_unref (device);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -171,15 +169,27 @@ meta_device_map_xi2_constructed (GObject *object)
|
|||||||
* detached slave devices are left for applications
|
* detached slave devices are left for applications
|
||||||
* to handle.
|
* to handle.
|
||||||
*/
|
*/
|
||||||
info = XIQueryDevice (display->xdisplay, XIAllMasterDevices, &n_devices);
|
info = XIQueryDevice (display->xdisplay, XIAllDevices, &n_devices);
|
||||||
pairs = g_hash_table_new (NULL, NULL);
|
pairs = g_hash_table_new (NULL, NULL);
|
||||||
|
|
||||||
for (i = 0; i < n_devices; i++)
|
for (i = 0; i < n_devices; i++)
|
||||||
{
|
{
|
||||||
add_device_from_info (device_map, info[i].use, info[i].deviceid);
|
MetaDevice *device;
|
||||||
g_hash_table_insert (pairs,
|
|
||||||
GINT_TO_POINTER (info[i].deviceid),
|
device = create_device_from_info (device_map, info[i].use,
|
||||||
GINT_TO_POINTER (info[i].attachment));
|
info[i].deviceid);
|
||||||
|
if (device)
|
||||||
|
{
|
||||||
|
meta_device_map_add_device (device_map, device);
|
||||||
|
|
||||||
|
if (info[i].use == XIMasterPointer ||
|
||||||
|
info[i].use == XIMasterKeyboard)
|
||||||
|
g_hash_table_insert (pairs,
|
||||||
|
GINT_TO_POINTER (info[i].deviceid),
|
||||||
|
GINT_TO_POINTER (info[i].attachment));
|
||||||
|
|
||||||
|
g_object_unref (device);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_hash_table_foreach (pairs, pair_devices, device_map);
|
g_hash_table_foreach (pairs, pair_devices, device_map);
|
||||||
@ -274,16 +284,23 @@ meta_device_map_xi2_handle_hierarchy_event (MetaDeviceMapXI2 *device_map,
|
|||||||
|
|
||||||
for (i = 0; i < xev->num_info; i++)
|
for (i = 0; i < xev->num_info; i++)
|
||||||
{
|
{
|
||||||
if (xev->info[i].flags & XIMasterAdded)
|
if (xev->info[i].flags & XIMasterAdded ||
|
||||||
|
xev->info[i].flags & XISlaveAdded)
|
||||||
{
|
{
|
||||||
add_device_from_info (META_DEVICE_MAP (device_map),
|
MetaDevice *device;
|
||||||
xev->info[i].use,
|
|
||||||
xev->info[i].deviceid);
|
device = create_device_from_info (META_DEVICE_MAP (device_map),
|
||||||
g_hash_table_insert (pairs,
|
xev->info[i].use,
|
||||||
GINT_TO_POINTER (xev->info[i].deviceid),
|
xev->info[i].deviceid);
|
||||||
GINT_TO_POINTER (xev->info[i].attachment));
|
|
||||||
|
if (device &&
|
||||||
|
xev->info[i].flags & XIMasterAdded)
|
||||||
|
g_hash_table_insert (pairs,
|
||||||
|
GINT_TO_POINTER (xev->info[i].deviceid),
|
||||||
|
GINT_TO_POINTER (xev->info[i].attachment));
|
||||||
}
|
}
|
||||||
else if (xev->info[i].flags & XIMasterRemoved)
|
else if (xev->info[i].flags & XIMasterRemoved ||
|
||||||
|
xev->info[i].flags & XISlaveRemoved)
|
||||||
{
|
{
|
||||||
MetaDevice *device;
|
MetaDevice *device;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user