Be resilient in case there is no device manager
It's possible to run Clutter with the 'null' input backend, which means that clutter_device_manager_get_default() may return NULL. In the future we may add a default dummy device manager, but right now it's safer to just add a simple NULL check in the places where we ask for the device manager.
This commit is contained in:
parent
f7f8179898
commit
26d8ad7479
@ -2981,6 +2981,9 @@ clutter_grab_pointer_for_device (ClutterActor *actor,
|
||||
}
|
||||
|
||||
manager = clutter_device_manager_get_default ();
|
||||
if (manager == NULL)
|
||||
return;
|
||||
|
||||
dev = clutter_device_manager_get_device (manager, id_);
|
||||
if (dev == NULL)
|
||||
return;
|
||||
@ -3025,6 +3028,9 @@ clutter_ungrab_pointer_for_device (gint id_)
|
||||
ClutterInputDevice *device;
|
||||
|
||||
manager = clutter_device_manager_get_default ();
|
||||
if (manager == NULL)
|
||||
return;
|
||||
|
||||
device = clutter_device_manager_get_device (manager, id_);
|
||||
if (device != NULL)
|
||||
clutter_input_device_ungrab (device);
|
||||
@ -3293,6 +3299,8 @@ clutter_get_input_device_for_id (gint id_)
|
||||
ClutterDeviceManager *manager;
|
||||
|
||||
manager = clutter_device_manager_get_default ();
|
||||
if (manager == NULL)
|
||||
return NULL;
|
||||
|
||||
return clutter_device_manager_get_device (manager, id_);
|
||||
}
|
||||
|
@ -78,9 +78,12 @@ clutter_gdk_handle_event (GdkEvent *gdk_event)
|
||||
if (gdk_event->any.window == NULL)
|
||||
return GDK_FILTER_CONTINUE;
|
||||
|
||||
device_manager = clutter_device_manager_get_default ();
|
||||
if (G_UNLIKELY (device_manager == NULL))
|
||||
return GDK_FILTER_CONTINUE;
|
||||
|
||||
backend_gdk = CLUTTER_BACKEND_GDK (backend);
|
||||
stage = clutter_gdk_get_stage_from_window (gdk_event->any.window);
|
||||
device_manager = clutter_device_manager_get_default ();
|
||||
|
||||
gdk_device = gdk_event_get_device (gdk_event);
|
||||
if (gdk_device != NULL)
|
||||
|
@ -306,14 +306,19 @@ clutter_event_osx_translate (NSEvent *nsevent,
|
||||
ClutterEvent *event)
|
||||
{
|
||||
ClutterDeviceManagerOSX *manager_osx;
|
||||
ClutterDeviceManager *manager;
|
||||
ClutterStageOSX *stage_osx;
|
||||
ClutterStageWindow *impl;
|
||||
ClutterStage *stage;
|
||||
|
||||
stage = event->any.stage;
|
||||
impl = _clutter_stage_get_window (event->any.stage);
|
||||
stage_osx = CLUTTER_STAGE_OSX (impl);
|
||||
manager_osx = CLUTTER_DEVICE_MANAGER_OSX (clutter_device_manager_get_default ());
|
||||
manager = clutter_device_manager_get_default ();
|
||||
if (manager == NULL)
|
||||
return FALSE;
|
||||
|
||||
stage = event->any.stage;
|
||||
impl = _clutter_stage_get_window (event->any.stage);
|
||||
stage_osx = CLUTTER_STAGE_OSX (impl);
|
||||
manager_osx = CLUTTER_DEVICE_MANAGER_OSX (manager);
|
||||
|
||||
event->any.time = [nsevent clutterTime];
|
||||
|
||||
|
@ -375,6 +375,9 @@ clutter_win32_handle_event (const MSG *msg)
|
||||
return TRUE;
|
||||
|
||||
manager = clutter_device_manager_get_default ();
|
||||
if (manager == NULL)
|
||||
return FALSE;
|
||||
|
||||
core_pointer =
|
||||
clutter_device_manager_get_core_device (manager, CLUTTER_POINTER_DEVICE);
|
||||
core_keyboard =
|
||||
|
@ -1185,6 +1185,8 @@ clutter_x11_get_input_devices (void)
|
||||
ClutterDeviceManager *manager;
|
||||
|
||||
manager = clutter_device_manager_get_default ();
|
||||
if (manager == NULL)
|
||||
return NULL;
|
||||
|
||||
return clutter_device_manager_peek_devices (manager);
|
||||
}
|
||||
|
@ -652,12 +652,16 @@ clutter_stage_x11_realize (ClutterStageWindow *stage_window)
|
||||
* the event mask we passed to XSelectInput as the template
|
||||
*/
|
||||
device_manager = clutter_device_manager_get_default ();
|
||||
_clutter_device_manager_select_stage_events (device_manager,
|
||||
stage_cogl->wrapper,
|
||||
event_flags);
|
||||
if (G_UNLIKELY (device_manager != NULL))
|
||||
{
|
||||
_clutter_device_manager_select_stage_events (device_manager,
|
||||
stage_cogl->wrapper,
|
||||
event_flags);
|
||||
|
||||
g_signal_connect (device_manager, "device-added",
|
||||
G_CALLBACK (stage_events_device_added), stage_window);
|
||||
g_signal_connect (device_manager, "device-added",
|
||||
G_CALLBACK (stage_events_device_added),
|
||||
stage_window);
|
||||
}
|
||||
|
||||
clutter_stage_x11_fix_window_size (stage_x11,
|
||||
stage_x11->xwin_width,
|
||||
|
Loading…
Reference in New Issue
Block a user