mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 16:10:41 -05:00
Move cursor tracker ownership to the backend
Let the backend initialize the cursor tracker, and change all call sites to get the cursor tracker from the backend instead of from the screen. It wasn't associated with the screen anyway, so the API was missleading. https://bugzilla.gnome.org/show_bug.cgi?id=777732
This commit is contained in:
parent
e35ac9be8d
commit
317b734dcc
@ -116,6 +116,7 @@ ClutterBackend * meta_backend_get_clutter_backend (MetaBackend *backend);
|
|||||||
MetaIdleMonitor * meta_backend_get_idle_monitor (MetaBackend *backend,
|
MetaIdleMonitor * meta_backend_get_idle_monitor (MetaBackend *backend,
|
||||||
int device_id);
|
int device_id);
|
||||||
MetaMonitorManager * meta_backend_get_monitor_manager (MetaBackend *backend);
|
MetaMonitorManager * meta_backend_get_monitor_manager (MetaBackend *backend);
|
||||||
|
MetaCursorTracker * meta_backend_get_cursor_tracker (MetaBackend *backend);
|
||||||
MetaCursorRenderer * meta_backend_get_cursor_renderer (MetaBackend *backend);
|
MetaCursorRenderer * meta_backend_get_cursor_renderer (MetaBackend *backend);
|
||||||
MetaRenderer * meta_backend_get_renderer (MetaBackend *backend);
|
MetaRenderer * meta_backend_get_renderer (MetaBackend *backend);
|
||||||
MetaEgl * meta_backend_get_egl (MetaBackend *backend);
|
MetaEgl * meta_backend_get_egl (MetaBackend *backend);
|
||||||
|
@ -62,6 +62,7 @@ meta_get_backend (void)
|
|||||||
struct _MetaBackendPrivate
|
struct _MetaBackendPrivate
|
||||||
{
|
{
|
||||||
MetaMonitorManager *monitor_manager;
|
MetaMonitorManager *monitor_manager;
|
||||||
|
MetaCursorTracker *cursor_tracker;
|
||||||
MetaCursorRenderer *cursor_renderer;
|
MetaCursorRenderer *cursor_renderer;
|
||||||
MetaInputSettings *input_settings;
|
MetaInputSettings *input_settings;
|
||||||
MetaRenderer *renderer;
|
MetaRenderer *renderer;
|
||||||
@ -246,7 +247,8 @@ on_device_removed (ClutterDeviceManager *device_manager,
|
|||||||
*/
|
*/
|
||||||
if (backend->current_device_id == device_id)
|
if (backend->current_device_id == device_id)
|
||||||
{
|
{
|
||||||
MetaCursorTracker *cursor_tracker = meta_cursor_tracker_get_for_screen (NULL);
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
||||||
|
MetaCursorTracker *cursor_tracker = priv->cursor_tracker;
|
||||||
gboolean has_touchscreen, has_pointing_device;
|
gboolean has_touchscreen, has_pointing_device;
|
||||||
ClutterInputDeviceType device_type;
|
ClutterInputDeviceType device_type;
|
||||||
|
|
||||||
@ -319,7 +321,7 @@ meta_backend_real_post_init (MetaBackend *backend)
|
|||||||
has_touchscreen |= device_is_slave_touchscreen (device);
|
has_touchscreen |= device_is_slave_touchscreen (device);
|
||||||
}
|
}
|
||||||
|
|
||||||
cursor_tracker = meta_cursor_tracker_get_for_screen (NULL);
|
cursor_tracker = priv->cursor_tracker;
|
||||||
meta_cursor_tracker_set_pointer_visible (cursor_tracker, !has_touchscreen);
|
meta_cursor_tracker_set_pointer_visible (cursor_tracker, !has_touchscreen);
|
||||||
|
|
||||||
g_slist_free (devices);
|
g_slist_free (devices);
|
||||||
@ -424,6 +426,8 @@ meta_backend_initable_init (GInitable *initable,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
priv->cursor_tracker = g_object_new (META_TYPE_CURSOR_TRACKER, NULL);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -466,6 +470,14 @@ meta_backend_get_monitor_manager (MetaBackend *backend)
|
|||||||
return priv->monitor_manager;
|
return priv->monitor_manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MetaCursorTracker *
|
||||||
|
meta_backend_get_cursor_tracker (MetaBackend *backend)
|
||||||
|
{
|
||||||
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
||||||
|
|
||||||
|
return priv->cursor_tracker;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* meta_backend_get_cursor_renderer: (skip)
|
* meta_backend_get_cursor_renderer: (skip)
|
||||||
*/
|
*/
|
||||||
@ -582,8 +594,8 @@ meta_backend_get_stage (MetaBackend *backend)
|
|||||||
static gboolean
|
static gboolean
|
||||||
update_last_device (MetaBackend *backend)
|
update_last_device (MetaBackend *backend)
|
||||||
{
|
{
|
||||||
MetaCursorTracker *cursor_tracker = meta_cursor_tracker_get_for_screen (NULL);
|
|
||||||
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
||||||
|
MetaCursorTracker *cursor_tracker = priv->cursor_tracker;
|
||||||
ClutterInputDeviceType device_type;
|
ClutterInputDeviceType device_type;
|
||||||
ClutterDeviceManager *manager;
|
ClutterDeviceManager *manager;
|
||||||
ClutterInputDevice *device;
|
ClutterInputDevice *device;
|
||||||
|
@ -130,14 +130,6 @@ meta_cursor_tracker_class_init (MetaCursorTrackerClass *klass)
|
|||||||
G_TYPE_NONE, 0);
|
G_TYPE_NONE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static MetaCursorTracker *
|
|
||||||
meta_cursor_tracker_new (void)
|
|
||||||
{
|
|
||||||
return g_object_new (META_TYPE_CURSOR_TRACKER, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static MetaCursorTracker *_cursor_tracker;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* meta_cursor_tracker_get_for_screen:
|
* meta_cursor_tracker_get_for_screen:
|
||||||
* @screen: the #MetaScreen
|
* @screen: the #MetaScreen
|
||||||
@ -149,10 +141,12 @@ static MetaCursorTracker *_cursor_tracker;
|
|||||||
MetaCursorTracker *
|
MetaCursorTracker *
|
||||||
meta_cursor_tracker_get_for_screen (MetaScreen *screen)
|
meta_cursor_tracker_get_for_screen (MetaScreen *screen)
|
||||||
{
|
{
|
||||||
if (!_cursor_tracker)
|
MetaBackend *backend = meta_get_backend ();
|
||||||
_cursor_tracker = meta_cursor_tracker_new ();
|
MetaCursorTracker *tracker = meta_backend_get_cursor_tracker (backend);
|
||||||
|
|
||||||
return _cursor_tracker;
|
g_assert (tracker);
|
||||||
|
|
||||||
|
return tracker;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -318,7 +318,7 @@ meta_backend_native_warp_pointer (MetaBackend *backend,
|
|||||||
{
|
{
|
||||||
ClutterDeviceManager *manager = clutter_device_manager_get_default ();
|
ClutterDeviceManager *manager = clutter_device_manager_get_default ();
|
||||||
ClutterInputDevice *device = clutter_device_manager_get_core_device (manager, CLUTTER_POINTER_DEVICE);
|
ClutterInputDevice *device = clutter_device_manager_get_core_device (manager, CLUTTER_POINTER_DEVICE);
|
||||||
MetaCursorTracker *tracker = meta_cursor_tracker_get_for_screen (NULL);
|
MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
|
||||||
|
|
||||||
/* XXX */
|
/* XXX */
|
||||||
guint32 time_ = 0;
|
guint32 time_ = 0;
|
||||||
@ -327,7 +327,7 @@ meta_backend_native_warp_pointer (MetaBackend *backend,
|
|||||||
clutter_evdev_warp_pointer (device, time_, x, y);
|
clutter_evdev_warp_pointer (device, time_, x, y);
|
||||||
|
|
||||||
/* Warp displayed pointer cursor. */
|
/* Warp displayed pointer cursor. */
|
||||||
meta_cursor_tracker_update_position (tracker, x, y);
|
meta_cursor_tracker_update_position (cursor_tracker, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -253,7 +253,8 @@ meta_display_handle_event (MetaDisplay *display,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MetaCursorTracker *cursor_tracker = meta_cursor_tracker_get_for_screen (NULL);
|
MetaCursorTracker *cursor_tracker =
|
||||||
|
meta_backend_get_cursor_tracker (backend);
|
||||||
|
|
||||||
meta_cursor_tracker_update_position (cursor_tracker,
|
meta_cursor_tracker_update_position (cursor_tracker,
|
||||||
event->motion.x,
|
event->motion.x,
|
||||||
|
@ -1263,14 +1263,15 @@ meta_screen_update_cursor (MetaScreen *screen)
|
|||||||
MetaCursor cursor = screen->current_cursor;
|
MetaCursor cursor = screen->current_cursor;
|
||||||
Cursor xcursor;
|
Cursor xcursor;
|
||||||
MetaCursorSprite *cursor_sprite;
|
MetaCursorSprite *cursor_sprite;
|
||||||
MetaCursorTracker *tracker = meta_cursor_tracker_get_for_screen (screen);
|
MetaBackend *backend = meta_get_backend ();
|
||||||
|
MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
|
||||||
|
|
||||||
cursor_sprite = meta_cursor_sprite_from_theme (cursor);
|
cursor_sprite = meta_cursor_sprite_from_theme (cursor);
|
||||||
|
|
||||||
if (meta_is_wayland_compositor ())
|
if (meta_is_wayland_compositor ())
|
||||||
manage_root_cursor_sprite_scale (screen, cursor_sprite);
|
manage_root_cursor_sprite_scale (screen, cursor_sprite);
|
||||||
|
|
||||||
meta_cursor_tracker_set_root_cursor (tracker, cursor_sprite);
|
meta_cursor_tracker_set_root_cursor (cursor_tracker, cursor_sprite);
|
||||||
g_object_unref (cursor_sprite);
|
g_object_unref (cursor_sprite);
|
||||||
|
|
||||||
/* Set a cursor for X11 applications that don't specify their own */
|
/* Set a cursor for X11 applications that don't specify their own */
|
||||||
@ -1378,7 +1379,8 @@ MetaWindow*
|
|||||||
meta_screen_get_mouse_window (MetaScreen *screen,
|
meta_screen_get_mouse_window (MetaScreen *screen,
|
||||||
MetaWindow *not_this_one)
|
MetaWindow *not_this_one)
|
||||||
{
|
{
|
||||||
MetaCursorTracker *tracker = meta_cursor_tracker_get_for_screen (screen);
|
MetaBackend *backend = meta_get_backend ();
|
||||||
|
MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
|
||||||
MetaWindow *window;
|
MetaWindow *window;
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
@ -1386,7 +1388,7 @@ meta_screen_get_mouse_window (MetaScreen *screen,
|
|||||||
meta_topic (META_DEBUG_FOCUS,
|
meta_topic (META_DEBUG_FOCUS,
|
||||||
"Focusing mouse window excluding %s\n", not_this_one->desc);
|
"Focusing mouse window excluding %s\n", not_this_one->desc);
|
||||||
|
|
||||||
meta_cursor_tracker_get_pointer (tracker, &x, &y, NULL);
|
meta_cursor_tracker_get_pointer (cursor_tracker, &x, &y, NULL);
|
||||||
|
|
||||||
window = meta_stack_get_default_focus_window_at_point (screen->stack,
|
window = meta_stack_get_default_focus_window_at_point (screen->stack,
|
||||||
screen->active_workspace,
|
screen->active_workspace,
|
||||||
@ -1665,7 +1667,7 @@ meta_screen_get_current_monitor (MetaScreen *screen)
|
|||||||
MetaBackend *backend = meta_get_backend ();
|
MetaBackend *backend = meta_get_backend ();
|
||||||
MetaMonitorManager *monitor_manager =
|
MetaMonitorManager *monitor_manager =
|
||||||
meta_backend_get_monitor_manager (backend);
|
meta_backend_get_monitor_manager (backend);
|
||||||
MetaCursorTracker *tracker = meta_cursor_tracker_get_for_screen (screen);
|
MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
|
||||||
int n_logical_monitors =
|
int n_logical_monitors =
|
||||||
meta_monitor_manager_get_num_logical_monitors (monitor_manager);
|
meta_monitor_manager_get_num_logical_monitors (monitor_manager);
|
||||||
|
|
||||||
@ -1679,7 +1681,7 @@ meta_screen_get_current_monitor (MetaScreen *screen)
|
|||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
meta_cursor_tracker_get_pointer (tracker, &x, &y, NULL);
|
meta_cursor_tracker_get_pointer (cursor_tracker, &x, &y, NULL);
|
||||||
meta_screen_get_current_monitor_for_pos (screen, x, y);
|
meta_screen_get_current_monitor_for_pos (screen, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2968,9 +2970,10 @@ gboolean
|
|||||||
meta_screen_handle_xevent (MetaScreen *screen,
|
meta_screen_handle_xevent (MetaScreen *screen,
|
||||||
XEvent *xevent)
|
XEvent *xevent)
|
||||||
{
|
{
|
||||||
MetaCursorTracker *tracker = meta_cursor_tracker_get_for_screen (screen);
|
MetaBackend *backend = meta_get_backend ();
|
||||||
|
MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
|
||||||
|
|
||||||
if (meta_cursor_tracker_handle_xevent (tracker, xevent))
|
if (meta_cursor_tracker_handle_xevent (cursor_tracker, xevent))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -7691,15 +7691,15 @@ window_focus_on_pointer_rest_callback (gpointer data)
|
|||||||
MetaFocusData *focus_data = data;
|
MetaFocusData *focus_data = data;
|
||||||
MetaWindow *window = focus_data->window;
|
MetaWindow *window = focus_data->window;
|
||||||
MetaDisplay *display = window->display;
|
MetaDisplay *display = window->display;
|
||||||
MetaScreen *screen = window->screen;
|
MetaBackend *backend = meta_get_backend ();
|
||||||
MetaCursorTracker *tracker = meta_cursor_tracker_get_for_screen (screen);
|
MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
|
||||||
int root_x, root_y;
|
int root_x, root_y;
|
||||||
guint32 timestamp;
|
guint32 timestamp;
|
||||||
|
|
||||||
if (meta_prefs_get_focus_mode () == G_DESKTOP_FOCUS_MODE_CLICK)
|
if (meta_prefs_get_focus_mode () == G_DESKTOP_FOCUS_MODE_CLICK)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
meta_cursor_tracker_get_pointer (tracker, &root_x, &root_y, NULL);
|
meta_cursor_tracker_get_pointer (cursor_tracker, &root_x, &root_y, NULL);
|
||||||
|
|
||||||
if (root_x != focus_data->pointer_x ||
|
if (root_x != focus_data->pointer_x ||
|
||||||
root_y != focus_data->pointer_y)
|
root_y != focus_data->pointer_y)
|
||||||
|
@ -480,7 +480,8 @@ meta_wayland_pointer_on_cursor_changed (MetaCursorTracker *cursor_tracker,
|
|||||||
void
|
void
|
||||||
meta_wayland_pointer_enable (MetaWaylandPointer *pointer)
|
meta_wayland_pointer_enable (MetaWaylandPointer *pointer)
|
||||||
{
|
{
|
||||||
MetaCursorTracker *cursor_tracker = meta_cursor_tracker_get_for_screen (NULL);
|
MetaBackend *backend = meta_get_backend ();
|
||||||
|
MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
|
||||||
ClutterDeviceManager *manager;
|
ClutterDeviceManager *manager;
|
||||||
|
|
||||||
pointer->pointer_clients =
|
pointer->pointer_clients =
|
||||||
@ -503,7 +504,8 @@ meta_wayland_pointer_enable (MetaWaylandPointer *pointer)
|
|||||||
void
|
void
|
||||||
meta_wayland_pointer_disable (MetaWaylandPointer *pointer)
|
meta_wayland_pointer_disable (MetaWaylandPointer *pointer)
|
||||||
{
|
{
|
||||||
MetaCursorTracker *cursor_tracker = meta_cursor_tracker_get_for_screen (NULL);
|
MetaBackend *backend = meta_get_backend ();
|
||||||
|
MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
|
||||||
|
|
||||||
g_signal_handlers_disconnect_by_func (cursor_tracker,
|
g_signal_handlers_disconnect_by_func (cursor_tracker,
|
||||||
(gpointer) meta_wayland_pointer_on_cursor_changed,
|
(gpointer) meta_wayland_pointer_on_cursor_changed,
|
||||||
@ -965,7 +967,8 @@ meta_wayland_pointer_get_relative_coordinates (MetaWaylandPointer *pointer,
|
|||||||
void
|
void
|
||||||
meta_wayland_pointer_update_cursor_surface (MetaWaylandPointer *pointer)
|
meta_wayland_pointer_update_cursor_surface (MetaWaylandPointer *pointer)
|
||||||
{
|
{
|
||||||
MetaCursorTracker *cursor_tracker = meta_cursor_tracker_get_for_screen (NULL);
|
MetaBackend *backend = meta_get_backend ();
|
||||||
|
MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
|
||||||
|
|
||||||
if (pointer->current)
|
if (pointer->current)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user