seat/x11: Keep a pointer to the backend
This adds a pointer to the backend and replaces places that fetched backend resources via globals (mostly via clutter). Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2014>
This commit is contained in:
parent
56f150aa31
commit
6f80c1e7b5
@ -653,7 +653,8 @@ meta_backend_x11_create_default_seat (MetaBackend *backend,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
seat_x11 = meta_seat_x11_new (event_base,
|
seat_x11 = meta_seat_x11_new (backend,
|
||||||
|
event_base,
|
||||||
META_VIRTUAL_CORE_POINTER_ID,
|
META_VIRTUAL_CORE_POINTER_ID,
|
||||||
META_VIRTUAL_CORE_KEYBOARD_ID);
|
META_VIRTUAL_CORE_KEYBOARD_ID);
|
||||||
return CLUTTER_SEAT (seat_x11);
|
return CLUTTER_SEAT (seat_x11);
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
|
PROP_BACKEND,
|
||||||
PROP_OPCODE,
|
PROP_OPCODE,
|
||||||
PROP_POINTER_ID,
|
PROP_POINTER_ID,
|
||||||
PROP_KEYBOARD_ID,
|
PROP_KEYBOARD_ID,
|
||||||
@ -60,6 +61,9 @@ struct _MetaTouchInfo
|
|||||||
struct _MetaSeatX11
|
struct _MetaSeatX11
|
||||||
{
|
{
|
||||||
ClutterSeat parent_instance;
|
ClutterSeat parent_instance;
|
||||||
|
|
||||||
|
MetaBackend *backend;
|
||||||
|
|
||||||
ClutterInputDevice *core_pointer;
|
ClutterInputDevice *core_pointer;
|
||||||
ClutterInputDevice *core_keyboard;
|
ClutterInputDevice *core_keyboard;
|
||||||
GList *devices;
|
GList *devices;
|
||||||
@ -122,6 +126,12 @@ enum
|
|||||||
|
|
||||||
static Atom clutter_input_axis_atoms[N_AXIS_ATOMS] = { 0, };
|
static Atom clutter_input_axis_atoms[N_AXIS_ATOMS] = { 0, };
|
||||||
|
|
||||||
|
static Display *
|
||||||
|
xdisplay_from_seat (MetaSeatX11 *seat_x11)
|
||||||
|
{
|
||||||
|
return meta_backend_x11_get_xdisplay (META_BACKEND_X11 (seat_x11->backend));
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
translate_valuator_class (Display *xdisplay,
|
translate_valuator_class (Display *xdisplay,
|
||||||
ClutterInputDevice *device,
|
ClutterInputDevice *device,
|
||||||
@ -249,21 +259,23 @@ is_touch_device (XIAnyClassInfo **classes,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
is_touchpad_device (XIDeviceInfo *info)
|
is_touchpad_device (MetaSeatX11 *seat_x11,
|
||||||
|
XIDeviceInfo *info)
|
||||||
{
|
{
|
||||||
|
Display *xdisplay = xdisplay_from_seat (seat_x11);
|
||||||
gulong nitems, bytes_after;
|
gulong nitems, bytes_after;
|
||||||
uint32_t *data = NULL;
|
uint32_t *data = NULL;
|
||||||
int rc, format;
|
int rc, format;
|
||||||
Atom type;
|
Atom type;
|
||||||
Atom prop;
|
Atom prop;
|
||||||
|
|
||||||
prop = XInternAtom (meta_clutter_x11_get_default_display (),
|
prop = XInternAtom (xdisplay,
|
||||||
"libinput Tapping Enabled", True);
|
"libinput Tapping Enabled", True);
|
||||||
if (prop == None)
|
if (prop == None)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
meta_clutter_x11_trap_x_errors ();
|
meta_clutter_x11_trap_x_errors ();
|
||||||
rc = XIGetProperty (meta_clutter_x11_get_default_display (),
|
rc = XIGetProperty (xdisplay,
|
||||||
info->deviceid,
|
info->deviceid,
|
||||||
prop,
|
prop,
|
||||||
0, 1, False, XA_INTEGER, &type, &format, &nitems, &bytes_after,
|
0, 1, False, XA_INTEGER, &type, &format, &nitems, &bytes_after,
|
||||||
@ -280,19 +292,21 @@ is_touchpad_device (XIDeviceInfo *info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
get_device_ids (XIDeviceInfo *info,
|
get_device_ids (MetaSeatX11 *seat_x11,
|
||||||
|
XIDeviceInfo *info,
|
||||||
char **vendor_id,
|
char **vendor_id,
|
||||||
char **product_id)
|
char **product_id)
|
||||||
{
|
{
|
||||||
|
Display *xdisplay = xdisplay_from_seat (seat_x11);
|
||||||
gulong nitems, bytes_after;
|
gulong nitems, bytes_after;
|
||||||
uint32_t *data = NULL;
|
uint32_t *data = NULL;
|
||||||
int rc, format;
|
int rc, format;
|
||||||
Atom type;
|
Atom type;
|
||||||
|
|
||||||
meta_clutter_x11_trap_x_errors ();
|
meta_clutter_x11_trap_x_errors ();
|
||||||
rc = XIGetProperty (meta_clutter_x11_get_default_display (),
|
rc = XIGetProperty (xdisplay,
|
||||||
info->deviceid,
|
info->deviceid,
|
||||||
XInternAtom (meta_clutter_x11_get_default_display (), "Device Product ID", False),
|
XInternAtom (xdisplay, "Device Product ID", False),
|
||||||
0, 2, False, XA_INTEGER, &type, &format, &nitems, &bytes_after,
|
0, 2, False, XA_INTEGER, &type, &format, &nitems, &bytes_after,
|
||||||
(guchar **) &data);
|
(guchar **) &data);
|
||||||
meta_clutter_x11_untrap_x_errors ();
|
meta_clutter_x11_untrap_x_errors ();
|
||||||
@ -314,21 +328,23 @@ get_device_ids (XIDeviceInfo *info,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
get_device_node_path (XIDeviceInfo *info)
|
get_device_node_path (MetaSeatX11 *seat_x11,
|
||||||
|
XIDeviceInfo *info)
|
||||||
{
|
{
|
||||||
|
Display *xdisplay = xdisplay_from_seat (seat_x11);
|
||||||
gulong nitems, bytes_after;
|
gulong nitems, bytes_after;
|
||||||
guchar *data;
|
guchar *data;
|
||||||
int rc, format;
|
int rc, format;
|
||||||
Atom prop, type;
|
Atom prop, type;
|
||||||
char *node_path;
|
char *node_path;
|
||||||
|
|
||||||
prop = XInternAtom (meta_clutter_x11_get_default_display (), "Device Node", False);
|
prop = XInternAtom (xdisplay, "Device Node", False);
|
||||||
if (prop == None)
|
if (prop == None)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
meta_clutter_x11_trap_x_errors ();
|
meta_clutter_x11_trap_x_errors ();
|
||||||
|
|
||||||
rc = XIGetProperty (meta_clutter_x11_get_default_display (),
|
rc = XIGetProperty (xdisplay,
|
||||||
info->deviceid, prop, 0, 1024, False,
|
info->deviceid, prop, 0, 1024, False,
|
||||||
XA_STRING, &type, &format, &nitems, &bytes_after,
|
XA_STRING, &type, &format, &nitems, &bytes_after,
|
||||||
(guchar **) &data);
|
(guchar **) &data);
|
||||||
@ -381,9 +397,11 @@ get_pad_features (XIDeviceInfo *info,
|
|||||||
/* The Wacom driver exports the tool type as property. Use that over
|
/* The Wacom driver exports the tool type as property. Use that over
|
||||||
guessing based on the device name */
|
guessing based on the device name */
|
||||||
static gboolean
|
static gboolean
|
||||||
guess_source_from_wacom_type (XIDeviceInfo *info,
|
guess_source_from_wacom_type (MetaSeatX11 *seat_x11,
|
||||||
|
XIDeviceInfo *info,
|
||||||
ClutterInputDeviceType *source_out)
|
ClutterInputDeviceType *source_out)
|
||||||
{
|
{
|
||||||
|
Display *xdisplay = xdisplay_from_seat (seat_x11);
|
||||||
gulong nitems, bytes_after;
|
gulong nitems, bytes_after;
|
||||||
uint32_t *data = NULL;
|
uint32_t *data = NULL;
|
||||||
int rc, format;
|
int rc, format;
|
||||||
@ -392,12 +410,12 @@ guess_source_from_wacom_type (XIDeviceInfo *info,
|
|||||||
Atom device_type;
|
Atom device_type;
|
||||||
Atom types[N_WACOM_TYPE_ATOMS];
|
Atom types[N_WACOM_TYPE_ATOMS];
|
||||||
|
|
||||||
prop = XInternAtom (meta_clutter_x11_get_default_display (), "Wacom Tool Type", True);
|
prop = XInternAtom (xdisplay, "Wacom Tool Type", True);
|
||||||
if (prop == None)
|
if (prop == None)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
meta_clutter_x11_trap_x_errors ();
|
meta_clutter_x11_trap_x_errors ();
|
||||||
rc = XIGetProperty (meta_clutter_x11_get_default_display (),
|
rc = XIGetProperty (xdisplay,
|
||||||
info->deviceid,
|
info->deviceid,
|
||||||
prop,
|
prop,
|
||||||
0, 1, False, XA_ATOM, &type, &format, &nitems, &bytes_after,
|
0, 1, False, XA_ATOM, &type, &format, &nitems, &bytes_after,
|
||||||
@ -416,7 +434,7 @@ guess_source_from_wacom_type (XIDeviceInfo *info,
|
|||||||
if (device_type == 0)
|
if (device_type == 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
rc = XInternAtoms (meta_clutter_x11_get_default_display (),
|
rc = XInternAtoms (xdisplay,
|
||||||
(char **)wacom_type_atoms,
|
(char **)wacom_type_atoms,
|
||||||
N_WACOM_TYPE_ATOMS,
|
N_WACOM_TYPE_ATOMS,
|
||||||
False,
|
False,
|
||||||
@ -461,6 +479,7 @@ create_device (MetaSeatX11 *seat_x11,
|
|||||||
ClutterBackend *backend,
|
ClutterBackend *backend,
|
||||||
XIDeviceInfo *info)
|
XIDeviceInfo *info)
|
||||||
{
|
{
|
||||||
|
Display *xdisplay = xdisplay_from_seat (seat_x11);
|
||||||
ClutterInputDeviceType source, touch_source;
|
ClutterInputDeviceType source, touch_source;
|
||||||
ClutterInputDevice *retval;
|
ClutterInputDevice *retval;
|
||||||
ClutterInputMode mode;
|
ClutterInputMode mode;
|
||||||
@ -471,7 +490,7 @@ create_device (MetaSeatX11 *seat_x11,
|
|||||||
{
|
{
|
||||||
source = CLUTTER_KEYBOARD_DEVICE;
|
source = CLUTTER_KEYBOARD_DEVICE;
|
||||||
}
|
}
|
||||||
else if (is_touchpad_device (info))
|
else if (is_touchpad_device (seat_x11, info))
|
||||||
{
|
{
|
||||||
source = CLUTTER_TOUCHPAD_DEVICE;
|
source = CLUTTER_TOUCHPAD_DEVICE;
|
||||||
}
|
}
|
||||||
@ -482,7 +501,7 @@ create_device (MetaSeatX11 *seat_x11,
|
|||||||
{
|
{
|
||||||
source = touch_source;
|
source = touch_source;
|
||||||
}
|
}
|
||||||
else if (!guess_source_from_wacom_type (info, &source))
|
else if (!guess_source_from_wacom_type (seat_x11, info, &source))
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
@ -525,8 +544,8 @@ create_device (MetaSeatX11 *seat_x11,
|
|||||||
if (info->use != XIMasterKeyboard &&
|
if (info->use != XIMasterKeyboard &&
|
||||||
info->use != XIMasterPointer)
|
info->use != XIMasterPointer)
|
||||||
{
|
{
|
||||||
get_device_ids (info, &vendor_id, &product_id);
|
get_device_ids (seat_x11, info, &vendor_id, &product_id);
|
||||||
node_path = get_device_node_path (info);
|
node_path = get_device_node_path (seat_x11, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (source == CLUTTER_PAD_DEVICE)
|
if (source == CLUTTER_PAD_DEVICE)
|
||||||
@ -548,7 +567,7 @@ create_device (MetaSeatX11 *seat_x11,
|
|||||||
"seat", seat_x11,
|
"seat", seat_x11,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
translate_device_classes (meta_clutter_x11_get_default_display (), retval,
|
translate_device_classes (xdisplay, retval,
|
||||||
info->classes,
|
info->classes,
|
||||||
info->num_classes);
|
info->num_classes);
|
||||||
|
|
||||||
@ -565,8 +584,10 @@ create_device (MetaSeatX11 *seat_x11,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pad_passive_button_grab (ClutterInputDevice *device)
|
pad_passive_button_grab (MetaSeatX11 *seat_x11,
|
||||||
|
ClutterInputDevice *device)
|
||||||
{
|
{
|
||||||
|
Display *xdisplay = xdisplay_from_seat (seat_x11);
|
||||||
XIGrabModifiers xi_grab_mods = { XIAnyModifier, };
|
XIGrabModifiers xi_grab_mods = { XIAnyModifier, };
|
||||||
XIEventMask xi_event_mask;
|
XIEventMask xi_event_mask;
|
||||||
int device_id, rc;
|
int device_id, rc;
|
||||||
@ -582,7 +603,7 @@ pad_passive_button_grab (ClutterInputDevice *device)
|
|||||||
XISetMask (xi_event_mask.mask, XI_ButtonRelease);
|
XISetMask (xi_event_mask.mask, XI_ButtonRelease);
|
||||||
|
|
||||||
meta_clutter_x11_trap_x_errors ();
|
meta_clutter_x11_trap_x_errors ();
|
||||||
rc = XIGrabButton (meta_clutter_x11_get_default_display (),
|
rc = XIGrabButton (xdisplay,
|
||||||
device_id, XIAnyButton,
|
device_id, XIAnyButton,
|
||||||
meta_clutter_x11_get_root_window (), None,
|
meta_clutter_x11_get_root_window (), None,
|
||||||
XIGrabModeSync, XIGrabModeSync,
|
XIGrabModeSync, XIGrabModeSync,
|
||||||
@ -594,9 +615,7 @@ pad_passive_button_grab (ClutterInputDevice *device)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
XIAllowEvents (meta_clutter_x11_get_default_display (),
|
XIAllowEvents (xdisplay, device_id, XIAsyncDevice, CLUTTER_CURRENT_TIME);
|
||||||
device_id, XIAsyncDevice,
|
|
||||||
CLUTTER_CURRENT_TIME);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
meta_clutter_x11_untrap_x_errors ();
|
meta_clutter_x11_untrap_x_errors ();
|
||||||
@ -655,7 +674,7 @@ add_device (MetaSeatX11 *seat_x11,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (clutter_input_device_get_device_type (device) == CLUTTER_PAD_DEVICE)
|
if (clutter_input_device_get_device_type (device) == CLUTTER_PAD_DEVICE)
|
||||||
pad_passive_button_grab (device);
|
pad_passive_button_grab (seat_x11, device);
|
||||||
|
|
||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
@ -708,7 +727,7 @@ meta_seat_x11_handle_event_post (ClutterSeat *seat,
|
|||||||
device = clutter_event_get_device (event);
|
device = clutter_event_get_device (event);
|
||||||
is_touch =
|
is_touch =
|
||||||
clutter_input_device_get_device_type (device) == CLUTTER_TOUCHSCREEN_DEVICE;
|
clutter_input_device_get_device_type (device) == CLUTTER_TOUCHSCREEN_DEVICE;
|
||||||
input_settings = meta_backend_get_input_settings (meta_get_backend ());
|
input_settings = meta_backend_get_input_settings (seat_x11->backend);
|
||||||
|
|
||||||
switch (event->type)
|
switch (event->type)
|
||||||
{
|
{
|
||||||
@ -732,8 +751,10 @@ meta_seat_x11_handle_event_post (ClutterSeat *seat,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static uint
|
static uint
|
||||||
device_get_tool_serial (ClutterInputDevice *device)
|
device_get_tool_serial (MetaSeatX11 *seat_x11,
|
||||||
|
ClutterInputDevice *device)
|
||||||
{
|
{
|
||||||
|
Display *xdisplay = xdisplay_from_seat (seat_x11);
|
||||||
gulong nitems, bytes_after;
|
gulong nitems, bytes_after;
|
||||||
uint32_t *data = NULL;
|
uint32_t *data = NULL;
|
||||||
int serial_id = 0;
|
int serial_id = 0;
|
||||||
@ -741,13 +762,12 @@ device_get_tool_serial (ClutterInputDevice *device)
|
|||||||
Atom type;
|
Atom type;
|
||||||
Atom prop;
|
Atom prop;
|
||||||
|
|
||||||
prop = XInternAtom (meta_clutter_x11_get_default_display (),
|
prop = XInternAtom (xdisplay, "Wacom Serial IDs", True);
|
||||||
"Wacom Serial IDs", True);
|
|
||||||
if (prop == None)
|
if (prop == None)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
meta_clutter_x11_trap_x_errors ();
|
meta_clutter_x11_trap_x_errors ();
|
||||||
rc = XIGetProperty (meta_clutter_x11_get_default_display (),
|
rc = XIGetProperty (xdisplay,
|
||||||
meta_input_device_x11_get_device_id (device),
|
meta_input_device_x11_get_device_id (device),
|
||||||
prop, 0, 4, FALSE, XA_INTEGER, &type, &format, &nitems, &bytes_after,
|
prop, 0, 4, FALSE, XA_INTEGER, &type, &format, &nitems, &bytes_after,
|
||||||
(guchar **) &data);
|
(guchar **) &data);
|
||||||
@ -767,6 +787,7 @@ translate_hierarchy_event (ClutterBackend *backend,
|
|||||||
XIHierarchyEvent *ev,
|
XIHierarchyEvent *ev,
|
||||||
ClutterEvent *event)
|
ClutterEvent *event)
|
||||||
{
|
{
|
||||||
|
Display *xdisplay = xdisplay_from_seat (seat_x11);
|
||||||
int i;
|
int i;
|
||||||
gboolean retval = FALSE;
|
gboolean retval = FALSE;
|
||||||
|
|
||||||
@ -782,7 +803,7 @@ translate_hierarchy_event (ClutterBackend *backend,
|
|||||||
g_debug ("Hierarchy event: device enabled");
|
g_debug ("Hierarchy event: device enabled");
|
||||||
|
|
||||||
meta_clutter_x11_trap_x_errors ();
|
meta_clutter_x11_trap_x_errors ();
|
||||||
info = XIQueryDevice (meta_clutter_x11_get_default_display (),
|
info = XIQueryDevice (xdisplay,
|
||||||
ev->info[i].deviceid,
|
ev->info[i].deviceid,
|
||||||
&n_devices);
|
&n_devices);
|
||||||
meta_clutter_x11_untrap_x_errors ();
|
meta_clutter_x11_untrap_x_errors ();
|
||||||
@ -838,12 +859,12 @@ static void
|
|||||||
translate_property_event (MetaSeatX11 *seat_x11,
|
translate_property_event (MetaSeatX11 *seat_x11,
|
||||||
XIEvent *event)
|
XIEvent *event)
|
||||||
{
|
{
|
||||||
|
Display *xdisplay = xdisplay_from_seat (seat_x11);
|
||||||
XIPropertyEvent *xev = (XIPropertyEvent *) event;
|
XIPropertyEvent *xev = (XIPropertyEvent *) event;
|
||||||
Atom serial_ids_prop;
|
Atom serial_ids_prop;
|
||||||
ClutterInputDevice *device;
|
ClutterInputDevice *device;
|
||||||
|
|
||||||
serial_ids_prop = XInternAtom (meta_clutter_x11_get_default_display (),
|
serial_ids_prop = XInternAtom (xdisplay, "Wacom Serial IDs", True);
|
||||||
"Wacom Serial IDs", True);
|
|
||||||
if (serial_ids_prop == None)
|
if (serial_ids_prop == None)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -859,7 +880,7 @@ translate_property_event (MetaSeatX11 *seat_x11,
|
|||||||
MetaInputSettings *input_settings;
|
MetaInputSettings *input_settings;
|
||||||
int serial_id;
|
int serial_id;
|
||||||
|
|
||||||
serial_id = device_get_tool_serial (device);
|
serial_id = device_get_tool_serial (seat_x11, device);
|
||||||
|
|
||||||
if (serial_id != 0)
|
if (serial_id != 0)
|
||||||
{
|
{
|
||||||
@ -877,7 +898,7 @@ translate_property_event (MetaSeatX11 *seat_x11,
|
|||||||
}
|
}
|
||||||
|
|
||||||
meta_input_device_x11_update_tool (device, tool);
|
meta_input_device_x11_update_tool (device, tool);
|
||||||
input_settings = meta_backend_get_input_settings (meta_get_backend ());
|
input_settings = meta_backend_get_input_settings (seat_x11->backend);
|
||||||
meta_input_settings_notify_tool_change (input_settings, device, tool);
|
meta_input_settings_notify_tool_change (input_settings, device, tool);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -892,7 +913,7 @@ emulate_motion (MetaSeatX11 *seat_x11,
|
|||||||
ClutterStage *stage;
|
ClutterStage *stage;
|
||||||
|
|
||||||
pointer = clutter_seat_get_pointer (CLUTTER_SEAT (seat_x11));
|
pointer = clutter_seat_get_pointer (CLUTTER_SEAT (seat_x11));
|
||||||
stage = CLUTTER_STAGE (meta_backend_get_stage (meta_get_backend ()));
|
stage = CLUTTER_STAGE (meta_backend_get_stage (seat_x11->backend));
|
||||||
|
|
||||||
event = clutter_event_new (CLUTTER_MOTION);
|
event = clutter_event_new (CLUTTER_MOTION);
|
||||||
clutter_event_set_flags (event, CLUTTER_EVENT_FLAG_SYNTHETIC);
|
clutter_event_set_flags (event, CLUTTER_EVENT_FLAG_SYNTHETIC);
|
||||||
@ -1100,7 +1121,7 @@ get_event_stage (MetaSeatX11 *seat_x11,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case XI_HierarchyChanged:
|
case XI_HierarchyChanged:
|
||||||
return CLUTTER_STAGE (meta_backend_get_stage (meta_get_backend ()));
|
return CLUTTER_STAGE (meta_backend_get_stage (seat_x11->backend));
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -1278,13 +1299,14 @@ on_keymap_state_change (MetaKeymapX11 *keymap_x11,
|
|||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
ClutterSeat *seat = data;
|
ClutterSeat *seat = data;
|
||||||
|
MetaSeatX11 *seat_x11 = META_SEAT_X11 (seat);
|
||||||
MetaInputSettings *input_settings;
|
MetaInputSettings *input_settings;
|
||||||
MetaKbdA11ySettings kbd_a11y_settings;
|
MetaKbdA11ySettings kbd_a11y_settings;
|
||||||
|
|
||||||
/* On keymaps state change, just reapply the current settings, it'll
|
/* On keymaps state change, just reapply the current settings, it'll
|
||||||
* take care of enabling/disabling mousekeys based on NumLock state.
|
* take care of enabling/disabling mousekeys based on NumLock state.
|
||||||
*/
|
*/
|
||||||
input_settings = meta_backend_get_input_settings (meta_get_backend ());
|
input_settings = meta_backend_get_input_settings (seat_x11->backend);
|
||||||
meta_input_settings_get_kbd_a11y_settings (input_settings, &kbd_a11y_settings);
|
meta_input_settings_get_kbd_a11y_settings (input_settings, &kbd_a11y_settings);
|
||||||
meta_seat_x11_apply_kbd_a11y_settings (seat, &kbd_a11y_settings);
|
meta_seat_x11_apply_kbd_a11y_settings (seat, &kbd_a11y_settings);
|
||||||
}
|
}
|
||||||
@ -1299,6 +1321,9 @@ meta_seat_x11_set_property (GObject *object,
|
|||||||
|
|
||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
|
case PROP_BACKEND:
|
||||||
|
seat_x11->backend = g_value_get_object (value);
|
||||||
|
break;
|
||||||
case PROP_OPCODE:
|
case PROP_OPCODE:
|
||||||
seat_x11->opcode = g_value_get_int (value);
|
seat_x11->opcode = g_value_get_int (value);
|
||||||
break;
|
break;
|
||||||
@ -1324,6 +1349,9 @@ meta_seat_x11_get_property (GObject *object,
|
|||||||
|
|
||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
|
case PROP_BACKEND:
|
||||||
|
g_value_set_object (value, seat_x11->backend);
|
||||||
|
break;
|
||||||
case PROP_OPCODE:
|
case PROP_OPCODE:
|
||||||
g_value_set_int (value, seat_x11->opcode);
|
g_value_set_int (value, seat_x11->opcode);
|
||||||
break;
|
break;
|
||||||
@ -1365,14 +1393,13 @@ static void
|
|||||||
meta_seat_x11_constructed (GObject *object)
|
meta_seat_x11_constructed (GObject *object)
|
||||||
{
|
{
|
||||||
MetaSeatX11 *seat_x11 = META_SEAT_X11 (object);
|
MetaSeatX11 *seat_x11 = META_SEAT_X11 (object);
|
||||||
ClutterBackend *backend = clutter_get_default_backend ();
|
Display *xdisplay = xdisplay_from_seat (seat_x11);
|
||||||
|
ClutterBackend *backend =
|
||||||
|
meta_backend_get_clutter_backend (seat_x11->backend);
|
||||||
XIDeviceInfo *info;
|
XIDeviceInfo *info;
|
||||||
XIEventMask event_mask;
|
XIEventMask event_mask;
|
||||||
unsigned char mask[XIMaskLen(XI_LASTEVENT)] = { 0, };
|
unsigned char mask[XIMaskLen(XI_LASTEVENT)] = { 0, };
|
||||||
int n_devices, i;
|
int n_devices, i;
|
||||||
Display *xdisplay;
|
|
||||||
|
|
||||||
xdisplay = meta_clutter_x11_get_default_display ();
|
|
||||||
|
|
||||||
info = XIQueryDevice (xdisplay, XIAllDevices, &n_devices);
|
info = XIQueryDevice (xdisplay, XIAllDevices, &n_devices);
|
||||||
|
|
||||||
@ -1501,9 +1528,10 @@ meta_seat_x11_warp_pointer (ClutterSeat *seat,
|
|||||||
int y)
|
int y)
|
||||||
{
|
{
|
||||||
MetaSeatX11 *seat_x11 = META_SEAT_X11 (seat);
|
MetaSeatX11 *seat_x11 = META_SEAT_X11 (seat);
|
||||||
|
Display *xdisplay = xdisplay_from_seat (seat_x11);
|
||||||
|
|
||||||
meta_clutter_x11_trap_x_errors ();
|
meta_clutter_x11_trap_x_errors ();
|
||||||
XIWarpPointer (meta_clutter_x11_get_default_display (),
|
XIWarpPointer (xdisplay,
|
||||||
seat_x11->pointer_id,
|
seat_x11->pointer_id,
|
||||||
None,
|
None,
|
||||||
meta_clutter_x11_get_root_window (),
|
meta_clutter_x11_get_root_window (),
|
||||||
@ -1566,8 +1594,9 @@ meta_seat_x11_query_state (ClutterSeat *seat,
|
|||||||
graphene_point_t *coords,
|
graphene_point_t *coords,
|
||||||
ClutterModifierType *modifiers)
|
ClutterModifierType *modifiers)
|
||||||
{
|
{
|
||||||
MetaBackendX11 *backend_x11 = META_BACKEND_X11 (meta_get_backend ());
|
|
||||||
MetaSeatX11 *seat_x11 = META_SEAT_X11 (seat);
|
MetaSeatX11 *seat_x11 = META_SEAT_X11 (seat);
|
||||||
|
MetaBackendX11 *backend_x11 = META_BACKEND_X11 (seat_x11->backend);
|
||||||
|
Display *xdisplay = xdisplay_from_seat (seat_x11);
|
||||||
Window root_ret, child_ret;
|
Window root_ret, child_ret;
|
||||||
double root_x, root_y, win_x, win_y;
|
double root_x, root_y, win_x, win_y;
|
||||||
XIButtonState button_state = { 0 };
|
XIButtonState button_state = { 0 };
|
||||||
@ -1575,7 +1604,7 @@ meta_seat_x11_query_state (ClutterSeat *seat,
|
|||||||
XIGroupState group_state;
|
XIGroupState group_state;
|
||||||
|
|
||||||
meta_clutter_x11_trap_x_errors ();
|
meta_clutter_x11_trap_x_errors ();
|
||||||
XIQueryPointer (meta_clutter_x11_get_default_display (),
|
XIQueryPointer (xdisplay,
|
||||||
seat_x11->pointer_id,
|
seat_x11->pointer_id,
|
||||||
meta_backend_x11_get_xwindow (backend_x11),
|
meta_backend_x11_get_xwindow (backend_x11),
|
||||||
&root_ret, &child_ret,
|
&root_ret, &child_ret,
|
||||||
@ -1727,6 +1756,13 @@ meta_seat_x11_class_init (MetaSeatX11Class *klass)
|
|||||||
seat_class->grab = meta_seat_x11_grab;
|
seat_class->grab = meta_seat_x11_grab;
|
||||||
seat_class->ungrab = meta_seat_x11_ungrab;
|
seat_class->ungrab = meta_seat_x11_ungrab;
|
||||||
|
|
||||||
|
props[PROP_BACKEND] =
|
||||||
|
g_param_spec_object ("backend",
|
||||||
|
"MetaBackend",
|
||||||
|
"MetaBackend",
|
||||||
|
META_TYPE_BACKEND,
|
||||||
|
G_PARAM_READWRITE |
|
||||||
|
G_PARAM_CONSTRUCT_ONLY);
|
||||||
props[PROP_OPCODE] =
|
props[PROP_OPCODE] =
|
||||||
g_param_spec_int ("opcode",
|
g_param_spec_int ("opcode",
|
||||||
"Opcode",
|
"Opcode",
|
||||||
@ -1768,15 +1804,21 @@ meta_seat_x11_init (MetaSeatX11 *seat)
|
|||||||
}
|
}
|
||||||
|
|
||||||
MetaSeatX11 *
|
MetaSeatX11 *
|
||||||
meta_seat_x11_new (int opcode,
|
meta_seat_x11_new (MetaBackend *backend,
|
||||||
int logical_pointer,
|
int opcode,
|
||||||
int logical_keyboard)
|
int logical_pointer,
|
||||||
|
int logical_keyboard)
|
||||||
{
|
{
|
||||||
return g_object_new (META_TYPE_SEAT_X11,
|
MetaSeatX11 *seat_x11;
|
||||||
"opcode", opcode,
|
|
||||||
"pointer-id", logical_pointer,
|
seat_x11 = g_object_new (META_TYPE_SEAT_X11,
|
||||||
"keyboard-id", logical_keyboard,
|
"backend", backend,
|
||||||
NULL);
|
"opcode", opcode,
|
||||||
|
"pointer-id", logical_pointer,
|
||||||
|
"keyboard-id", logical_keyboard,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
return seat_x11;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ClutterInputDevice *
|
static ClutterInputDevice *
|
||||||
@ -1829,8 +1871,10 @@ meta_seat_x11_translate_event (MetaSeatX11 *seat,
|
|||||||
XEvent *xevent,
|
XEvent *xevent,
|
||||||
ClutterEvent *event)
|
ClutterEvent *event)
|
||||||
{
|
{
|
||||||
|
Display *xdisplay = xdisplay_from_seat (seat);
|
||||||
|
ClutterBackend *backend =
|
||||||
|
meta_backend_get_clutter_backend (seat->backend);
|
||||||
gboolean retval = FALSE;
|
gboolean retval = FALSE;
|
||||||
ClutterBackend *backend = clutter_get_default_backend ();
|
|
||||||
ClutterStage *stage = NULL;
|
ClutterStage *stage = NULL;
|
||||||
MetaStageX11 *stage_x11 = NULL;
|
MetaStageX11 *stage_x11 = NULL;
|
||||||
ClutterInputDevice *device, *source_device;
|
ClutterInputDevice *device, *source_device;
|
||||||
@ -1892,7 +1936,7 @@ meta_seat_x11_translate_event (MetaSeatX11 *seat,
|
|||||||
if (device)
|
if (device)
|
||||||
{
|
{
|
||||||
meta_input_device_x11_reset_axes (device);
|
meta_input_device_x11_reset_axes (device);
|
||||||
translate_device_classes (meta_clutter_x11_get_default_display (),
|
translate_device_classes (xdisplay,
|
||||||
device,
|
device,
|
||||||
xev->classes,
|
xev->classes,
|
||||||
xev->num_classes);
|
xev->num_classes);
|
||||||
@ -1991,10 +2035,7 @@ meta_seat_x11_translate_event (MetaSeatX11 *seat,
|
|||||||
if (clutter_input_device_get_device_type (source_device) == CLUTTER_PAD_DEVICE)
|
if (clutter_input_device_get_device_type (source_device) == CLUTTER_PAD_DEVICE)
|
||||||
{
|
{
|
||||||
/* We got these events because of the passive button grab */
|
/* We got these events because of the passive button grab */
|
||||||
XIAllowEvents (meta_clutter_x11_get_default_display (),
|
XIAllowEvents (xdisplay, xev->sourceid, XIAsyncDevice, xev->time);
|
||||||
xev->sourceid,
|
|
||||||
XIAsyncDevice,
|
|
||||||
xev->time);
|
|
||||||
|
|
||||||
event->any.stage = stage;
|
event->any.stage = stage;
|
||||||
|
|
||||||
@ -2444,6 +2485,7 @@ void
|
|||||||
meta_seat_x11_select_stage_events (MetaSeatX11 *seat,
|
meta_seat_x11_select_stage_events (MetaSeatX11 *seat,
|
||||||
ClutterStage *stage)
|
ClutterStage *stage)
|
||||||
{
|
{
|
||||||
|
Display *xdisplay = xdisplay_from_seat (seat);
|
||||||
MetaStageX11 *stage_x11;
|
MetaStageX11 *stage_x11;
|
||||||
XIEventMask xi_event_mask;
|
XIEventMask xi_event_mask;
|
||||||
unsigned char *mask;
|
unsigned char *mask;
|
||||||
@ -2470,8 +2512,7 @@ meta_seat_x11_select_stage_events (MetaSeatX11 *seat,
|
|||||||
xi_event_mask.mask = mask;
|
xi_event_mask.mask = mask;
|
||||||
xi_event_mask.mask_len = len;
|
xi_event_mask.mask_len = len;
|
||||||
|
|
||||||
XISelectEvents (meta_clutter_x11_get_default_display (),
|
XISelectEvents (xdisplay, stage_x11->xwin, &xi_event_mask, 1);
|
||||||
stage_x11->xwin, &xi_event_mask, 1);
|
|
||||||
|
|
||||||
g_free (mask);
|
g_free (mask);
|
||||||
}
|
}
|
||||||
|
@ -26,9 +26,10 @@ G_BEGIN_DECLS
|
|||||||
#define META_TYPE_SEAT_X11 meta_seat_x11_get_type ()
|
#define META_TYPE_SEAT_X11 meta_seat_x11_get_type ()
|
||||||
G_DECLARE_FINAL_TYPE (MetaSeatX11, meta_seat_x11, META, SEAT_X11, ClutterSeat)
|
G_DECLARE_FINAL_TYPE (MetaSeatX11, meta_seat_x11, META, SEAT_X11, ClutterSeat)
|
||||||
|
|
||||||
MetaSeatX11 * meta_seat_x11_new (int opcode,
|
MetaSeatX11 * meta_seat_x11_new (MetaBackend *backend,
|
||||||
int logical_pointer,
|
int opcode,
|
||||||
int logical_keyboard);
|
int logical_pointer,
|
||||||
|
int logical_keyboard);
|
||||||
gboolean meta_seat_x11_translate_event (MetaSeatX11 *seat,
|
gboolean meta_seat_x11_translate_event (MetaSeatX11 *seat,
|
||||||
XEvent *xevent,
|
XEvent *xevent,
|
||||||
ClutterEvent *event);
|
ClutterEvent *event);
|
||||||
|
Loading…
Reference in New Issue
Block a user