mirror of
https://github.com/brl/mutter.git
synced 2024-11-23 08:30:42 -05:00
device-manager: select/unselect device events as device change
When a device is added or changes, select/unselect events from X accordingly. https://bugzilla.gnome.org/show_bug.cgi?id=673644
This commit is contained in:
parent
b746044415
commit
032870dccc
@ -425,6 +425,7 @@ translate_hierarchy_event (ClutterBackendX11 *backend_x11,
|
|||||||
ClutterInputDevice *master, *slave;
|
ClutterInputDevice *master, *slave;
|
||||||
XIDeviceInfo *info;
|
XIDeviceInfo *info;
|
||||||
int n_devices;
|
int n_devices;
|
||||||
|
gboolean send_changed = FALSE;
|
||||||
|
|
||||||
CLUTTER_NOTE (EVENT, "Hierarchy event: slave %s",
|
CLUTTER_NOTE (EVENT, "Hierarchy event: slave %s",
|
||||||
(ev->info[i].flags & XISlaveAttached)
|
(ev->info[i].flags & XISlaveAttached)
|
||||||
@ -440,6 +441,8 @@ translate_hierarchy_event (ClutterBackendX11 *backend_x11,
|
|||||||
{
|
{
|
||||||
_clutter_input_device_remove_slave (master, slave);
|
_clutter_input_device_remove_slave (master, slave);
|
||||||
_clutter_input_device_set_associated_device (slave, NULL);
|
_clutter_input_device_set_associated_device (slave, NULL);
|
||||||
|
|
||||||
|
send_changed = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* and attach the slave to the new master if needed */
|
/* and attach the slave to the new master if needed */
|
||||||
@ -453,8 +456,18 @@ translate_hierarchy_event (ClutterBackendX11 *backend_x11,
|
|||||||
_clutter_input_device_set_associated_device (slave, master);
|
_clutter_input_device_set_associated_device (slave, master);
|
||||||
_clutter_input_device_add_slave (master, slave);
|
_clutter_input_device_add_slave (master, slave);
|
||||||
|
|
||||||
|
send_changed = TRUE;
|
||||||
XIFreeDeviceInfo (info);
|
XIFreeDeviceInfo (info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (send_changed)
|
||||||
|
{
|
||||||
|
ClutterStage *stage = _clutter_input_device_get_stage (master);
|
||||||
|
if (stage != NULL)
|
||||||
|
_clutter_stage_x11_events_device_changed (CLUTTER_STAGE_X11 (_clutter_stage_get_window (stage)),
|
||||||
|
master,
|
||||||
|
CLUTTER_DEVICE_MANAGER (manager_xi2));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -538,6 +538,37 @@ clutter_stage_x11_set_fullscreen (ClutterStageWindow *stage_window,
|
|||||||
* queue a relayout etc. */
|
* queue a relayout etc. */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_clutter_stage_x11_events_device_changed (ClutterStageX11 *stage_x11,
|
||||||
|
ClutterInputDevice *device,
|
||||||
|
ClutterDeviceManager *device_manager)
|
||||||
|
{
|
||||||
|
ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_x11);
|
||||||
|
int event_flags = 0;
|
||||||
|
|
||||||
|
if (clutter_input_device_get_device_mode (device) == CLUTTER_INPUT_MODE_FLOATING)
|
||||||
|
event_flags = CLUTTER_STAGE_X11_EVENT_MASK;
|
||||||
|
|
||||||
|
_clutter_device_manager_select_stage_events (device_manager,
|
||||||
|
stage_cogl->wrapper,
|
||||||
|
event_flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
stage_events_device_added (ClutterDeviceManager *device_manager,
|
||||||
|
ClutterInputDevice *device,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
ClutterStageWindow *stage_window = user_data;
|
||||||
|
ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_window);
|
||||||
|
int event_flags = CLUTTER_STAGE_X11_EVENT_MASK;
|
||||||
|
|
||||||
|
if (clutter_input_device_get_device_mode (device) == CLUTTER_INPUT_MODE_FLOATING)
|
||||||
|
_clutter_device_manager_select_stage_events (device_manager,
|
||||||
|
stage_cogl->wrapper,
|
||||||
|
event_flags);
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
clutter_stage_x11_realize (ClutterStageWindow *stage_window)
|
clutter_stage_x11_realize (ClutterStageWindow *stage_window)
|
||||||
{
|
{
|
||||||
@ -625,6 +656,9 @@ clutter_stage_x11_realize (ClutterStageWindow *stage_window)
|
|||||||
stage_cogl->wrapper,
|
stage_cogl->wrapper,
|
||||||
event_flags);
|
event_flags);
|
||||||
|
|
||||||
|
g_signal_connect (device_manager, "device-added",
|
||||||
|
G_CALLBACK (stage_events_device_added), stage_window);
|
||||||
|
|
||||||
clutter_stage_x11_fix_window_size (stage_x11,
|
clutter_stage_x11_fix_window_size (stage_x11,
|
||||||
stage_x11->xwin_width,
|
stage_x11->xwin_width,
|
||||||
stage_x11->xwin_height);
|
stage_x11->xwin_height);
|
||||||
|
@ -92,6 +92,9 @@ GType _clutter_stage_x11_get_type (void) G_GNUC_CONST;
|
|||||||
void _clutter_stage_x11_update_foreign_event_mask (CoglOnscreen *onscreen,
|
void _clutter_stage_x11_update_foreign_event_mask (CoglOnscreen *onscreen,
|
||||||
guint32 event_mask,
|
guint32 event_mask,
|
||||||
void *user_data);
|
void *user_data);
|
||||||
|
void _clutter_stage_x11_events_device_changed (ClutterStageX11 *stage_x11,
|
||||||
|
ClutterInputDevice *device,
|
||||||
|
ClutterDeviceManager *device_manager);
|
||||||
|
|
||||||
/* Private to subclasses */
|
/* Private to subclasses */
|
||||||
void _clutter_stage_x11_set_user_time (ClutterStageX11 *stage_x11,
|
void _clutter_stage_x11_set_user_time (ClutterStageX11 *stage_x11,
|
||||||
|
Loading…
Reference in New Issue
Block a user