device-manager: Don't pass the event mask around

There's no point in doing this, as we always use a constant event mask.
Simply do what everything else does.

https://bugzilla.gnome.org/show_bug.cgi?id=703969
This commit is contained in:
Jasper St. Pierre 2013-07-10 16:34:48 -04:00
parent e38ea7a20f
commit 032688800c
6 changed files with 21 additions and 57 deletions

View File

@ -138,8 +138,7 @@ struct _ClutterInputDeviceClass
GObjectClass parent_class; GObjectClass parent_class;
void (* select_stage_events) (ClutterInputDevice *device, void (* select_stage_events) (ClutterInputDevice *device,
ClutterStage *stage, ClutterStage *stage);
gint event_mask);
gboolean (* keycode_to_evdev) (ClutterInputDevice *device, gboolean (* keycode_to_evdev) (ClutterInputDevice *device,
guint hardware_keycode, guint hardware_keycode,
guint *evdev_keycode); guint *evdev_keycode);
@ -152,8 +151,7 @@ void _clutter_device_manager_remove_device (ClutterDeviceMa
ClutterInputDevice *device); ClutterInputDevice *device);
void _clutter_device_manager_update_devices (ClutterDeviceManager *device_manager); void _clutter_device_manager_update_devices (ClutterDeviceManager *device_manager);
void _clutter_device_manager_select_stage_events (ClutterDeviceManager *device_manager, void _clutter_device_manager_select_stage_events (ClutterDeviceManager *device_manager,
ClutterStage *stage, ClutterStage *stage);
gint event_mask);
ClutterBackend *_clutter_device_manager_get_backend (ClutterDeviceManager *device_manager); ClutterBackend *_clutter_device_manager_get_backend (ClutterDeviceManager *device_manager);
/* input device */ /* input device */
@ -199,8 +197,7 @@ void _clutter_input_device_remove_slave (ClutterInputDev
ClutterInputDevice *slave); ClutterInputDevice *slave);
void _clutter_input_device_select_stage_events (ClutterInputDevice *device, void _clutter_input_device_select_stage_events (ClutterInputDevice *device,
ClutterStage *stage, ClutterStage *stage);
gint event_flags);
gboolean _clutter_input_device_translate_axis (ClutterInputDevice *device, gboolean _clutter_input_device_translate_axis (ClutterInputDevice *device,
guint index_, guint index_,

View File

@ -304,8 +304,7 @@ clutter_device_manager_get_core_device (ClutterDeviceManager *device_manager,
void void
_clutter_device_manager_select_stage_events (ClutterDeviceManager *device_manager, _clutter_device_manager_select_stage_events (ClutterDeviceManager *device_manager,
ClutterStage *stage, ClutterStage *stage)
gint event_flags)
{ {
ClutterDeviceManagerClass *manager_class; ClutterDeviceManagerClass *manager_class;
const GSList *devices, *d; const GSList *devices, *d;
@ -320,7 +319,7 @@ _clutter_device_manager_select_stage_events (ClutterDeviceManager *device_manage
ClutterInputDevice *device = d->data; ClutterInputDevice *device = d->data;
if (device->is_enabled) if (device->is_enabled)
_clutter_input_device_select_stage_events (device, stage, event_flags); _clutter_input_device_select_stage_events (device, stage);
} }
} }

View File

@ -1619,7 +1619,6 @@ clutter_input_device_get_associated_device (ClutterInputDevice *device)
* clutter_input_device_select_stage_events: * clutter_input_device_select_stage_events:
* @device: a #ClutterInputDevice * @device: a #ClutterInputDevice
* @stage: the #ClutterStage to select events on * @stage: the #ClutterStage to select events on
* @event_mask: platform-specific mask of events
* *
* Selects input device events on @stage. * Selects input device events on @stage.
* *
@ -1627,14 +1626,13 @@ clutter_input_device_get_associated_device (ClutterInputDevice *device)
*/ */
void void
_clutter_input_device_select_stage_events (ClutterInputDevice *device, _clutter_input_device_select_stage_events (ClutterInputDevice *device,
ClutterStage *stage, ClutterStage *stage)
gint event_mask)
{ {
ClutterInputDeviceClass *device_class; ClutterInputDeviceClass *device_class;
device_class = CLUTTER_INPUT_DEVICE_GET_CLASS (device); device_class = CLUTTER_INPUT_DEVICE_GET_CLASS (device);
if (device_class->select_stage_events != NULL) if (device_class->select_stage_events != NULL)
device_class->select_stage_events (device, stage, event_mask); device_class->select_stage_events (device, stage);
} }
/** /**

View File

@ -55,8 +55,7 @@ G_DEFINE_TYPE (ClutterInputDeviceXI2,
static void static void
clutter_input_device_xi2_select_stage_events (ClutterInputDevice *device, clutter_input_device_xi2_select_stage_events (ClutterInputDevice *device,
ClutterStage *stage, ClutterStage *stage)
gint event_mask)
{ {
ClutterInputDeviceXI2 *device_xi2 = CLUTTER_INPUT_DEVICE_XI2 (device); ClutterInputDeviceXI2 *device_xi2 = CLUTTER_INPUT_DEVICE_XI2 (device);
ClutterBackendX11 *backend_x11; ClutterBackendX11 *backend_x11;
@ -71,26 +70,13 @@ clutter_input_device_xi2_select_stage_events (ClutterInputDevice *device,
len = XIMaskLen (XI_LASTEVENT); len = XIMaskLen (XI_LASTEVENT);
mask = g_new0 (unsigned char, len); mask = g_new0 (unsigned char, len);
if (event_mask & PointerMotionMask) XISetMask (mask, XI_Motion);
XISetMask (mask, XI_Motion); XISetMask (mask, XI_ButtonPress);
XISetMask (mask, XI_ButtonRelease);
if (event_mask & ButtonPressMask) XISetMask (mask, XI_KeyPress);
XISetMask (mask, XI_ButtonPress); XISetMask (mask, XI_KeyRelease);
XISetMask (mask, XI_Enter);
if (event_mask & ButtonReleaseMask) XISetMask (mask, XI_Leave);
XISetMask (mask, XI_ButtonRelease);
if (event_mask & KeyPressMask)
XISetMask (mask, XI_KeyPress);
if (event_mask & KeyReleaseMask)
XISetMask (mask, XI_KeyRelease);
if (event_mask & EnterWindowMask)
XISetMask (mask, XI_Enter);
if (event_mask & LeaveWindowMask)
XISetMask (mask, XI_Leave);
#ifdef HAVE_XINPUT_2_2 #ifdef HAVE_XINPUT_2_2
/* enable touch event support if we're running on XInput 2.2 */ /* enable touch event support if we're running on XInput 2.2 */

View File

@ -547,14 +547,10 @@ _clutter_stage_x11_events_device_changed (ClutterStageX11 *stage_x11,
ClutterDeviceManager *device_manager) ClutterDeviceManager *device_manager)
{ {
ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_x11); ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_x11);
int event_flags = 0;
if (clutter_input_device_get_device_mode (device) == CLUTTER_INPUT_MODE_FLOATING) 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);
_clutter_device_manager_select_stage_events (device_manager,
stage_cogl->wrapper,
event_flags);
} }
static void static void
@ -564,12 +560,10 @@ stage_events_device_added (ClutterDeviceManager *device_manager,
{ {
ClutterStageWindow *stage_window = user_data; ClutterStageWindow *stage_window = user_data;
ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_window); 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) if (clutter_input_device_get_device_mode (device) == CLUTTER_INPUT_MODE_FLOATING)
_clutter_device_manager_select_stage_events (device_manager, _clutter_device_manager_select_stage_events (device_manager,
stage_cogl->wrapper, stage_cogl->wrapper);
event_flags);
} }
static gboolean static gboolean
@ -580,7 +574,6 @@ clutter_stage_x11_realize (ClutterStageWindow *stage_window)
ClutterBackend *backend = CLUTTER_BACKEND (stage_cogl->backend); ClutterBackend *backend = CLUTTER_BACKEND (stage_cogl->backend);
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (backend); ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (backend);
ClutterDeviceManager *device_manager; ClutterDeviceManager *device_manager;
int event_flags;
gfloat width, height; gfloat width, height;
clutter_actor_get_size (CLUTTER_ACTOR (stage_cogl->wrapper), clutter_actor_get_size (CLUTTER_ACTOR (stage_cogl->wrapper),
@ -623,14 +616,6 @@ clutter_stage_x11_realize (ClutterStageWindow *stage_window)
set_wm_title (stage_x11); set_wm_title (stage_x11);
set_cursor_visible (stage_x11); set_cursor_visible (stage_x11);
/* the masks for the events we want to select on a stage window;
* KeyPressMask and KeyReleaseMask are necessary even with XI1
* because key events are broken with that extension, and will
* be fixed by XI2
*/
event_flags = CLUTTER_STAGE_X11_EVENT_MASK;
/* we unconditionally select input events even with event retrieval /* we unconditionally select input events even with event retrieval
* disabled because we need to guarantee that the Clutter internal * disabled because we need to guarantee that the Clutter internal
* state is maintained when calling clutter_x11_handle_event() without * state is maintained when calling clutter_x11_handle_event() without
@ -648,7 +633,7 @@ clutter_stage_x11_realize (ClutterStageWindow *stage_window)
* for an example of things that break if we do conditional event * for an example of things that break if we do conditional event
* selection. * selection.
*/ */
XSelectInput (backend_x11->xdpy, stage_x11->xwin, event_flags); XSelectInput (backend_x11->xdpy, stage_x11->xwin, CLUTTER_STAGE_X11_EVENT_MASK);
/* input events also depent on the actual device, so we need to /* input events also depent on the actual device, so we need to
* use the device manager to let every device select them, using * use the device manager to let every device select them, using
@ -658,8 +643,7 @@ clutter_stage_x11_realize (ClutterStageWindow *stage_window)
if (G_UNLIKELY (device_manager != NULL)) if (G_UNLIKELY (device_manager != NULL))
{ {
_clutter_device_manager_select_stage_events (device_manager, _clutter_device_manager_select_stage_events (device_manager,
stage_cogl->wrapper, stage_cogl->wrapper);
event_flags);
g_signal_connect (device_manager, "device-added", g_signal_connect (device_manager, "device-added",
G_CALLBACK (stage_events_device_added), G_CALLBACK (stage_events_device_added),

View File

@ -86,7 +86,7 @@ struct _ClutterStageX11Class
KeyReleaseMask | \ KeyReleaseMask | \
ButtonPressMask | \ ButtonPressMask | \
ButtonReleaseMask | \ ButtonReleaseMask | \
PointerMotionMask; PointerMotionMask
GType _clutter_stage_x11_get_type (void) G_GNUC_CONST; GType _clutter_stage_x11_get_type (void) G_GNUC_CONST;