clutter: Drop select_stage_events() device manager vfunc

This is specific to X11, so handle it within the X11 backend.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
This commit is contained in:
Carlos Garnacho 2019-10-02 17:00:54 +02:00
parent 7afbc01fe8
commit 835f12043e
7 changed files with 41 additions and 66 deletions

View File

@ -203,9 +203,6 @@ CLUTTER_EXPORT
void _clutter_device_manager_remove_device (ClutterDeviceManager *device_manager,
ClutterInputDevice *device);
void _clutter_device_manager_update_devices (ClutterDeviceManager *device_manager);
CLUTTER_EXPORT
void _clutter_device_manager_select_stage_events (ClutterDeviceManager *device_manager,
ClutterStage *stage);
ClutterBackend *_clutter_device_manager_get_backend (ClutterDeviceManager *device_manager);
/* input device */

View File

@ -311,19 +311,6 @@ clutter_device_manager_get_core_device (ClutterDeviceManager *device_manager,
return manager_class->get_core_device (device_manager, device_type);
}
void
_clutter_device_manager_select_stage_events (ClutterDeviceManager *device_manager,
ClutterStage *stage)
{
ClutterDeviceManagerClass *manager_class;
g_return_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager));
manager_class = CLUTTER_DEVICE_MANAGER_GET_CLASS (device_manager);
if (manager_class->select_stage_events)
manager_class->select_stage_events (device_manager, stage);
}
/*
* _clutter_device_manager_add_device:
* @device_manager: a #ClutterDeviceManager

View File

@ -62,8 +62,6 @@ struct _ClutterDeviceManagerClass
ClutterInputDevice *device);
void (* remove_device) (ClutterDeviceManager *manager,
ClutterInputDevice *device);
void (* select_stage_events) (ClutterDeviceManager *manager,
ClutterStage *stage);
/* padding */
gpointer _padding[4];

View File

@ -51,42 +51,6 @@ G_DEFINE_TYPE (MetaDeviceManagerX11,
meta_device_manager_x11,
CLUTTER_TYPE_DEVICE_MANAGER)
static void
meta_device_manager_x11_select_stage_events (ClutterDeviceManager *manager,
ClutterStage *stage)
{
MetaStageX11 *stage_x11;
XIEventMask xi_event_mask;
unsigned char *mask;
int len;
stage_x11 = META_STAGE_X11 (_clutter_stage_get_window (stage));
len = XIMaskLen (XI_LASTEVENT);
mask = g_new0 (unsigned char, len);
XISetMask (mask, XI_Motion);
XISetMask (mask, XI_ButtonPress);
XISetMask (mask, XI_ButtonRelease);
XISetMask (mask, XI_KeyPress);
XISetMask (mask, XI_KeyRelease);
XISetMask (mask, XI_Enter);
XISetMask (mask, XI_Leave);
XISetMask (mask, XI_TouchBegin);
XISetMask (mask, XI_TouchUpdate);
XISetMask (mask, XI_TouchEnd);
xi_event_mask.deviceid = XIAllMasterDevices;
xi_event_mask.mask = mask;
xi_event_mask.mask_len = len;
XISelectEvents (clutter_x11_get_default_display (),
stage_x11->xwin, &xi_event_mask, 1);
g_free (mask);
}
static void
meta_device_manager_x11_add_device (ClutterDeviceManager *manager,
ClutterInputDevice *device)
@ -253,7 +217,6 @@ meta_device_manager_x11_class_init (MetaDeviceManagerX11Class *klass)
manager_class->get_devices = meta_device_manager_x11_get_devices;
manager_class->get_core_device = meta_device_manager_x11_get_core_device;
manager_class->get_device = meta_device_manager_x11_get_device;
manager_class->select_stage_events = meta_device_manager_x11_select_stage_events;
}
static void

View File

@ -2227,3 +2227,39 @@ meta_seat_x11_lookup_device_id (MetaSeatX11 *seat_x11,
return g_hash_table_lookup (seat_x11->devices_by_id,
GINT_TO_POINTER (device_id));
}
void
meta_seat_x11_select_stage_events (MetaSeatX11 *seat,
ClutterStage *stage)
{
MetaStageX11 *stage_x11;
XIEventMask xi_event_mask;
unsigned char *mask;
int len;
stage_x11 = META_STAGE_X11 (_clutter_stage_get_window (stage));
len = XIMaskLen (XI_LASTEVENT);
mask = g_new0 (unsigned char, len);
XISetMask (mask, XI_Motion);
XISetMask (mask, XI_ButtonPress);
XISetMask (mask, XI_ButtonRelease);
XISetMask (mask, XI_KeyPress);
XISetMask (mask, XI_KeyRelease);
XISetMask (mask, XI_Enter);
XISetMask (mask, XI_Leave);
XISetMask (mask, XI_TouchBegin);
XISetMask (mask, XI_TouchUpdate);
XISetMask (mask, XI_TouchEnd);
xi_event_mask.deviceid = XIAllMasterDevices;
xi_event_mask.mask = mask;
xi_event_mask.mask_len = len;
XISelectEvents (clutter_x11_get_default_display (),
stage_x11->xwin, &xi_event_mask, 1);
g_free (mask);
}

View File

@ -34,6 +34,8 @@ gboolean meta_seat_x11_translate_event (MetaSeatX11 *seat,
ClutterEvent *event);
ClutterInputDevice * meta_seat_x11_lookup_device_id (MetaSeatX11 *seat_x11,
int device_id);
void meta_seat_x11_select_stage_events (MetaSeatX11 *seat,
ClutterStage *stage);
G_END_DECLS

View File

@ -33,6 +33,7 @@
#include "core/display-private.h"
#include "meta/meta-x11-errors.h"
#include "meta-backend-x11.h"
#include "meta-seat-x11.h"
#include "meta-stage-x11.h"
#define STAGE_X11_IS_MAPPED(s) ((((MetaStageX11 *) (s))->wm_state & STAGE_X11_WITHDRAWN) == 0)
@ -314,8 +315,8 @@ meta_stage_x11_realize (ClutterStageWindow *stage_window)
MetaStageX11 *stage_x11 = META_STAGE_X11 (stage_window);
ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_window);
ClutterBackend *backend = CLUTTER_BACKEND (stage_cogl->backend);
MetaSeatX11 *seat_x11 = META_SEAT_X11 (clutter_backend_get_default_seat (backend));
Display *xdisplay = clutter_x11_get_default_display ();
ClutterDeviceManager *device_manager;
float width, height;
GError *error = NULL;
@ -382,16 +383,7 @@ meta_stage_x11_realize (ClutterStageWindow *stage_window)
*/
XSelectInput (xdisplay, stage_x11->xwin, META_STAGE_X11_EVENT_MASK);
/* input events also depent on the actual device, so we need to
* use the device manager to let every device select them, using
* the event mask we passed to XSelectInput as the template
*/
device_manager = clutter_device_manager_get_default ();
if (G_UNLIKELY (device_manager != NULL))
{
_clutter_device_manager_select_stage_events (device_manager,
stage_cogl->wrapper);
}
meta_seat_x11_select_stage_events (seat_x11, stage_cogl->wrapper);
meta_stage_x11_fix_window_size (stage_x11,
stage_x11->xwin_width,