mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 10:00:45 -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,
|
||||
int device_id);
|
||||
MetaMonitorManager * meta_backend_get_monitor_manager (MetaBackend *backend);
|
||||
MetaCursorTracker * meta_backend_get_cursor_tracker (MetaBackend *backend);
|
||||
MetaCursorRenderer * meta_backend_get_cursor_renderer (MetaBackend *backend);
|
||||
MetaRenderer * meta_backend_get_renderer (MetaBackend *backend);
|
||||
MetaEgl * meta_backend_get_egl (MetaBackend *backend);
|
||||
|
@ -62,6 +62,7 @@ meta_get_backend (void)
|
||||
struct _MetaBackendPrivate
|
||||
{
|
||||
MetaMonitorManager *monitor_manager;
|
||||
MetaCursorTracker *cursor_tracker;
|
||||
MetaCursorRenderer *cursor_renderer;
|
||||
MetaInputSettings *input_settings;
|
||||
MetaRenderer *renderer;
|
||||
@ -246,7 +247,8 @@ on_device_removed (ClutterDeviceManager *device_manager,
|
||||
*/
|
||||
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;
|
||||
ClutterInputDeviceType device_type;
|
||||
|
||||
@ -319,7 +321,7 @@ meta_backend_real_post_init (MetaBackend *backend)
|
||||
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);
|
||||
|
||||
g_slist_free (devices);
|
||||
@ -424,6 +426,8 @@ meta_backend_initable_init (GInitable *initable,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
priv->cursor_tracker = g_object_new (META_TYPE_CURSOR_TRACKER, NULL);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -466,6 +470,14 @@ meta_backend_get_monitor_manager (MetaBackend *backend)
|
||||
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)
|
||||
*/
|
||||
@ -582,8 +594,8 @@ meta_backend_get_stage (MetaBackend *backend)
|
||||
static gboolean
|
||||
update_last_device (MetaBackend *backend)
|
||||
{
|
||||
MetaCursorTracker *cursor_tracker = meta_cursor_tracker_get_for_screen (NULL);
|
||||
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
||||
MetaCursorTracker *cursor_tracker = priv->cursor_tracker;
|
||||
ClutterInputDeviceType device_type;
|
||||
ClutterDeviceManager *manager;
|
||||
ClutterInputDevice *device;
|
||||
|
@ -130,14 +130,6 @@ meta_cursor_tracker_class_init (MetaCursorTrackerClass *klass)
|
||||
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:
|
||||
* @screen: the #MetaScreen
|
||||
@ -149,10 +141,12 @@ static MetaCursorTracker *_cursor_tracker;
|
||||
MetaCursorTracker *
|
||||
meta_cursor_tracker_get_for_screen (MetaScreen *screen)
|
||||
{
|
||||
if (!_cursor_tracker)
|
||||
_cursor_tracker = meta_cursor_tracker_new ();
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
MetaCursorTracker *tracker = meta_backend_get_cursor_tracker (backend);
|
||||
|
||||
return _cursor_tracker;
|
||||
g_assert (tracker);
|
||||
|
||||
return tracker;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -318,7 +318,7 @@ meta_backend_native_warp_pointer (MetaBackend *backend,
|
||||
{
|
||||
ClutterDeviceManager *manager = clutter_device_manager_get_default ();
|
||||
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 */
|
||||
guint32 time_ = 0;
|
||||
@ -327,7 +327,7 @@ meta_backend_native_warp_pointer (MetaBackend *backend,
|
||||
clutter_evdev_warp_pointer (device, time_, x, y);
|
||||
|
||||
/* Warp displayed pointer cursor. */
|
||||
meta_cursor_tracker_update_position (tracker, x, y);
|
||||
meta_cursor_tracker_update_position (cursor_tracker, x, y);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -253,7 +253,8 @@ meta_display_handle_event (MetaDisplay *display,
|
||||
}
|
||||
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,
|
||||
event->motion.x,
|
||||
|
@ -1263,14 +1263,15 @@ meta_screen_update_cursor (MetaScreen *screen)
|
||||
MetaCursor cursor = screen->current_cursor;
|
||||
Cursor xcursor;
|
||||
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);
|
||||
|
||||
if (meta_is_wayland_compositor ())
|
||||
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);
|
||||
|
||||
/* Set a cursor for X11 applications that don't specify their own */
|
||||
@ -1378,7 +1379,8 @@ MetaWindow*
|
||||
meta_screen_get_mouse_window (MetaScreen *screen,
|
||||
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;
|
||||
int x, y;
|
||||
|
||||
@ -1386,7 +1388,7 @@ meta_screen_get_mouse_window (MetaScreen *screen,
|
||||
meta_topic (META_DEBUG_FOCUS,
|
||||
"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,
|
||||
screen->active_workspace,
|
||||
@ -1665,7 +1667,7 @@ meta_screen_get_current_monitor (MetaScreen *screen)
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
MetaMonitorManager *monitor_manager =
|
||||
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 =
|
||||
meta_monitor_manager_get_num_logical_monitors (monitor_manager);
|
||||
|
||||
@ -1679,7 +1681,7 @@ meta_screen_get_current_monitor (MetaScreen *screen)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
@ -2968,9 +2970,10 @@ gboolean
|
||||
meta_screen_handle_xevent (MetaScreen *screen,
|
||||
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 FALSE;
|
||||
|
@ -7691,15 +7691,15 @@ window_focus_on_pointer_rest_callback (gpointer data)
|
||||
MetaFocusData *focus_data = data;
|
||||
MetaWindow *window = focus_data->window;
|
||||
MetaDisplay *display = window->display;
|
||||
MetaScreen *screen = window->screen;
|
||||
MetaCursorTracker *tracker = meta_cursor_tracker_get_for_screen (screen);
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
|
||||
int root_x, root_y;
|
||||
guint32 timestamp;
|
||||
|
||||
if (meta_prefs_get_focus_mode () == G_DESKTOP_FOCUS_MODE_CLICK)
|
||||
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 ||
|
||||
root_y != focus_data->pointer_y)
|
||||
|
@ -480,7 +480,8 @@ meta_wayland_pointer_on_cursor_changed (MetaCursorTracker *cursor_tracker,
|
||||
void
|
||||
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;
|
||||
|
||||
pointer->pointer_clients =
|
||||
@ -503,7 +504,8 @@ meta_wayland_pointer_enable (MetaWaylandPointer *pointer)
|
||||
void
|
||||
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,
|
||||
(gpointer) meta_wayland_pointer_on_cursor_changed,
|
||||
@ -965,7 +967,8 @@ meta_wayland_pointer_get_relative_coordinates (MetaWaylandPointer *pointer,
|
||||
void
|
||||
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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user