341
340
return CLUTTER_FEATURE_STAGE_USER_RESIZE | CLUTTER_FEATURE_STAGE_CURSOR;
344
clutter_backend_x11_handle_event (ClutterBackendX11 *backend_x11,
350
static ClutterDeviceManager *
351
clutter_backend_x11_get_device_manager (ClutterBackend *backend)
353
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (backend);
355
if (G_UNLIKELY (backend_x11->device_manager == NULL))
357
backend_x11->device_manager =
358
g_object_new (CLUTTER_TYPE_DEVICE_MANAGER_X11,
359
"use-xinput-1", clutter_enable_xinput,
360
"backend", backend_x11,
364
return backend_x11->device_manager;
345
368
clutter_backend_x11_class_init (ClutterBackendX11Class *klass)
347
370
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
348
371
ClutterBackendClass *backend_class = CLUTTER_BACKEND_CLASS (klass);
372
ClutterBackendX11Class *backendx11_class = CLUTTER_BACKEND_X11_CLASS (klass);
350
374
gobject_class->constructor = clutter_backend_x11_constructor;
351
375
gobject_class->dispose = clutter_backend_x11_dispose;
352
376
gobject_class->finalize = clutter_backend_x11_finalize;
354
backend_class->pre_parse = clutter_backend_x11_pre_parse;
355
backend_class->post_parse = clutter_backend_x11_post_parse;
356
backend_class->init_events = clutter_backend_x11_init_events;
357
backend_class->add_options = clutter_backend_x11_add_options;
358
backend_class->get_features = clutter_backend_x11_get_features;
378
backend_class->pre_parse = clutter_backend_x11_pre_parse;
379
backend_class->post_parse = clutter_backend_x11_post_parse;
380
backend_class->init_events = clutter_backend_x11_init_events;
381
backend_class->add_options = clutter_backend_x11_add_options;
382
backend_class->get_features = clutter_backend_x11_get_features;
383
backend_class->get_device_manager = clutter_backend_x11_get_device_manager;
385
backendx11_class->handle_event = clutter_backend_x11_handle_event;
640
_clutter_x11_register_xinput ()
643
XDeviceInfo *xdevices = NULL;
644
XDeviceInfo *info = NULL;
646
XDevice *xdevice = NULL;
648
XInputClassInfo *xclass_info = NULL;
650
gint opcode, event, error;
652
gint num_devices = 0;
655
gboolean have_an_xpointer = FALSE;
657
ClutterBackendX11 *x11b;
658
ClutterX11XInputDevice *device = NULL;
660
ClutterMainContext *context;
662
GSList *input_devices = NULL;
664
if (!backend_singleton)
666
g_critical ("X11 backend has not been initialised");
670
if (!clutter_enable_xinput)
672
CLUTTER_NOTE (BACKEND, "Not enabling XInput");
676
context = _clutter_context_get_default ();
678
backend_singleton->have_xinput = FALSE;
680
/* is the XInput extension available? */
681
res = XQueryExtension (backend_singleton->xdpy, "XInputExtension",
686
CLUTTER_NOTE (BACKEND, "X Input extension not available");
690
x11b = backend_singleton;
692
xdevices = XListInputDevices (x11b->xdpy, &num_devices);
694
CLUTTER_NOTE (BACKEND, "%d XINPUT devices found", num_devices);
696
if (num_devices == 0)
699
for (i = 0; i < num_devices; i++)
704
CLUTTER_NOTE (BACKEND, "Considering %li with type %d",
708
/* Only want 'raw' devices themselves not virtual ones */
709
if (info->use == IsXExtensionPointer ||
710
/*info->use == IsXExtensionKeyboard || XInput 1.x is broken */
711
info->use == IsXExtensionDevice)
713
clutter_x11_trap_x_errors ();
714
xdevice = XOpenDevice (backend_singleton->xdpy, info->id);
715
if (clutter_x11_untrap_x_errors () || xdevice == NULL)
718
/* Create the appropriate Clutter device */
719
device = g_slice_new0 (ClutterX11XInputDevice);
721
device->device.id = info->id;
725
case IsXExtensionPointer:
726
device->device.device_type = CLUTTER_POINTER_DEVICE;
727
have_an_xpointer = TRUE;
731
/* XInput 1.x is broken for keyboards: */
732
case IsXExtensionKeyboard:
733
device->device.type = CLUTTER_KEYBOARD_DEVICE;
737
case IsXExtensionDevice:
738
device->device.device_type = CLUTTER_EXTENSION_DEVICE;
742
/* FIXME: some kind of general device_init() call should do below */
743
device->device.click_count = 0;
744
device->device.previous_time = 0;
745
device->device.previous_x = -1;
746
device->device.previous_y = -1;
747
device->device.previous_button_number = -1;
749
device->num_events = 0;
750
device->xdevice = xdevice;
752
CLUTTER_NOTE (BACKEND, "Registering XINPUT device with XID: %li",
755
/* We must go through all the classes supported by this device and
756
* register the appropriate events we want. Each class only appears
757
* once. We need to store the types with the stage since they are
758
* created dynamically by the server. They are not device specific.
760
for (j = 0; j < xdevice->num_classes; j++)
762
xclass_info = xdevice->classes + j;
764
switch (xclass_info->input_class)
767
/* XInput 1.x is broken for keyboards: */
769
DeviceKeyPress (xdevice,
770
x11b->event_types[CLUTTER_X11_XINPUT_KEY_PRESS_EVENT],
771
device->xevent_list [num_events]);
774
DeviceKeyRelease (xdevice,
775
x11b->event_types[CLUTTER_X11_XINPUT_KEY_RELEASE_EVENT],
776
device->xevent_list [num_events]);
782
DeviceButtonPress (xdevice,
783
x11b->event_types[CLUTTER_X11_XINPUT_BUTTON_PRESS_EVENT],
784
device->xevent_list [num_events]);
787
DeviceButtonRelease (xdevice,
788
x11b->event_types[CLUTTER_X11_XINPUT_BUTTON_RELEASE_EVENT],
789
device->xevent_list [num_events]);
794
DeviceMotionNotify (xdevice,
795
x11b->event_types[CLUTTER_X11_XINPUT_MOTION_NOTIFY_EVENT],
796
device->xevent_list [num_events]);
802
if (info->use == IsXExtensionPointer && num_events > 0)
803
have_an_xpointer = TRUE;
805
device->num_events = num_events;
807
input_devices = g_slist_prepend (input_devices, device);
813
if (!have_an_xpointer)
817
/* Something is likely wrong with Xinput setup so we basically
818
* abort here and fall back to lofi regular xinput.
820
g_warning ("No usuable XInput pointing devices found");
822
for (l = input_devices; l != NULL; l = l->next)
823
g_slice_free (ClutterX11XInputDevice, l->data);
825
g_slist_free (input_devices);
826
context->input_devices = NULL;
831
/* store the list of input devices */
832
context->input_devices = g_slist_reverse (input_devices);
834
/* why yes, we are awesome */
835
backend_singleton->have_xinput = TRUE;
836
#endif /* HAVE_XINPUT */
840
_clutter_x11_unregister_xinput ()
846
669
_clutter_x11_select_events (Window xwin)
848
671
#ifdef HAVE_XINPUT
850
ClutterX11XInputDevice *device = NULL;
852
ClutterMainContext *context;
854
context = _clutter_context_get_default ();
856
if (!backend_singleton)
672
ClutterDeviceManager *manager;
675
if (G_UNLIKELY (backend_singleton == NULL))
858
677
g_critical ("X11 backend has not been initialised");
862
for (list_it = context->input_devices;
864
list_it = list_it->next)
682
manager = clutter_device_manager_get_default ();
684
for (l = clutter_device_manager_peek_devices (manager);
866
device = (ClutterX11XInputDevice *)list_it->data;
688
ClutterInputDevice *device = l->data;
868
XSelectExtensionEvent (backend_singleton->xdpy,
690
_clutter_input_device_x11_select_events (device, backend_singleton, xwin);
873
692
#endif /* HAVE_XINPUT */
876
695
ClutterInputDevice *
877
696
_clutter_x11_get_device_for_xid (XID id)
880
ClutterMainContext *context;
883
context = _clutter_context_get_default ();
885
if (!backend_singleton)
887
g_critical ("X11 backend has not been initialised");
891
for (l = context->input_devices; l != NULL; l = l->next)
893
ClutterX11XInputDevice *device = l->data;
895
if (device->xdevice->device_id == id)
896
return (ClutterInputDevice *) device;
898
#endif /* HAVE_XINPUT */
698
ClutterDeviceManager *manager;
700
manager = clutter_device_manager_get_default ();
702
return clutter_device_manager_get_device (manager, (gint) id);
903
/* FIXME: This nasty little func needs moving elsewhere.. */
706
* clutter_x11_get_input_devices:
708
* Retrieves a pointer to the list of input devices
710
* Deprecated: 1.2: Use clutter_device_manager_peek_devices() instead
714
* Return value: a pointer to the internal list of input devices; the
715
* returned list is owned by Clutter and should not be modified or
904
718
G_CONST_RETURN GSList *
905
719
clutter_x11_get_input_devices (void)
908
ClutterMainContext *context;
910
if (!backend_singleton)
912
g_critical ("X11 backend has not been initialised");
916
context = _clutter_context_get_default ();
918
return context->input_devices;
919
#else /* !HAVE_XINPUT */
921
#endif /* HAVE_XINPUT */
721
ClutterDeviceManager *manager;
723
manager = clutter_device_manager_get_default ();
725
return clutter_device_manager_peek_devices (manager);
980
792
return have_composite;
796
* clutter_x11_set_use_argb_visual:
797
* @use_argb: %TRUE if ARGB visuals should be requested by default
799
* Sets whether the Clutter X11 backend should request ARGB visuals by default
802
* By default, Clutter requests RGB visuals.
804
* <note>If no ARGB visuals are found, the X11 backend will fall back to
805
* requesting a RGB visual instead.</note>
807
* ARGB visuals are required for the #ClutterStage:use-alpha property to work.
809
* <note>This function can only be called once, and before clutter_init() is
815
clutter_x11_set_use_argb_visual (gboolean use_argb)
817
if (backend_singleton != NULL)
819
g_warning ("%s() can only be used before calling clutter_init()",
824
CLUTTER_NOTE (BACKEND, "ARGB visuals are %s",
825
use_argb ? "enabled" : "disabled");
827
clutter_enable_argb = use_argb;
831
* clutter_x11_get_use_argb_visual:
833
* Retrieves whether the Clutter X11 backend is using ARGB visuals by default
835
* Return value: %TRUE if ARGB visuals are queried by default
840
clutter_x11_get_use_argb_visual (void)
842
return clutter_enable_argb;
984
clutter_backend_x11_get_visual_info (ClutterBackendX11 *backend_x11,
985
gboolean for_offscreen)
846
clutter_backend_x11_get_visual_info (ClutterBackendX11 *backend_x11)
987
848
ClutterBackendX11Class *klass;