mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 15:40:41 -05:00
backends: Add a method for monitoring cursor position
This commit is contained in:
parent
b51b2f7aa4
commit
46c0795125
@ -95,6 +95,8 @@ struct _MetaBackendClass
|
||||
void (* set_numlock) (MetaBackend *backend,
|
||||
gboolean numlock_state);
|
||||
|
||||
void (* track_position) (MetaBackend *backend,
|
||||
gboolean enabled);
|
||||
};
|
||||
|
||||
void meta_init_backend (GType backend_gtype);
|
||||
@ -152,4 +154,8 @@ MetaInputSettings *meta_backend_get_input_settings (MetaBackend *backend);
|
||||
|
||||
void meta_backend_update_cursor_position (MetaBackend *backend, int x, int y);
|
||||
|
||||
void meta_backend_cursor_position_changed (MetaBackend *backend);
|
||||
void meta_backend_track_position_ref (MetaBackend *backend);
|
||||
void meta_backend_track_position_unref (MetaBackend *backend);
|
||||
|
||||
#endif /* META_BACKEND_PRIVATE_H */
|
||||
|
@ -78,6 +78,8 @@ struct _MetaBackendPrivate
|
||||
int current_device_id;
|
||||
|
||||
MetaPointerConstraint *client_pointer_constraint;
|
||||
|
||||
uint32_t track_position_refcount;
|
||||
};
|
||||
typedef struct _MetaBackendPrivate MetaBackendPrivate;
|
||||
|
||||
@ -866,3 +868,42 @@ meta_backend_get_input_settings (MetaBackend *backend)
|
||||
|
||||
return priv->input_settings;
|
||||
}
|
||||
|
||||
void
|
||||
meta_backend_update_cursor_position (MetaBackend *backend, int x, int y)
|
||||
{
|
||||
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
||||
|
||||
meta_cursor_renderer_set_position (priv->cursor_renderer, x, y);
|
||||
|
||||
meta_backend_cursor_position_changed (backend);
|
||||
}
|
||||
|
||||
void
|
||||
meta_backend_cursor_position_changed (MetaBackend *backend)
|
||||
{
|
||||
meta_cursor_tracker_cursor_position_changed (backend->cursor_tracker);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_backend_track_position (MetaBackend *backend, gboolean enabled)
|
||||
{
|
||||
if (META_BACKEND_GET_CLASS (backend)->track_position)
|
||||
META_BACKEND_GET_CLASS (backend)->track_position (backend, enabled);
|
||||
}
|
||||
|
||||
void
|
||||
meta_backend_track_position_ref (MetaBackend *backend)
|
||||
{
|
||||
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
||||
if (priv->track_position_refcount++ == 0)
|
||||
meta_backend_track_position (backend, TRUE);
|
||||
}
|
||||
|
||||
void
|
||||
meta_backend_track_position_unref (MetaBackend *backend)
|
||||
{
|
||||
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
||||
if (priv->track_position_refcount-- == 0)
|
||||
meta_backend_track_position (backend, FALSE);
|
||||
}
|
||||
|
@ -63,4 +63,6 @@ void meta_cursor_tracker_set_root_cursor (MetaCursorTracker *tracker,
|
||||
|
||||
MetaCursorSprite * meta_cursor_tracker_get_displayed_cursor (MetaCursorTracker *tracker);
|
||||
|
||||
void meta_backend_cursor_position_changed (MetaCursorTracker *tracker);
|
||||
|
||||
#endif
|
||||
|
@ -47,6 +47,7 @@
|
||||
G_DEFINE_TYPE (MetaCursorTracker, meta_cursor_tracker, G_TYPE_OBJECT);
|
||||
|
||||
enum {
|
||||
POSITION_CHANGED,
|
||||
CURSOR_CHANGED,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
@ -128,6 +129,13 @@ meta_cursor_tracker_class_init (MetaCursorTrackerClass *klass)
|
||||
0,
|
||||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
signals[POSITION_CHANGED] = g_signal_new ("position-changed",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
0,
|
||||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -421,3 +429,21 @@ meta_cursor_tracker_get_displayed_cursor (MetaCursorTracker *tracker)
|
||||
{
|
||||
return tracker->displayed_cursor;
|
||||
}
|
||||
|
||||
void
|
||||
meta_cursor_tracker_position_changed (MetaCursorTracker *tracker)
|
||||
{
|
||||
g_signal_emit (tracker, signals[POSITION_CHANGED], 0);
|
||||
}
|
||||
|
||||
void
|
||||
meta_cursor_tracker_enable_track_position (MetaCursorTracker *tracker)
|
||||
{
|
||||
meta_backend_track_position_ref (meta_get_backend ());
|
||||
}
|
||||
|
||||
void
|
||||
meta_cursor_tracker_disable_track_position (MetaCursorTracker *tracker)
|
||||
{
|
||||
meta_backend_track_position_unref (meta_get_backend ());
|
||||
}
|
||||
|
@ -114,7 +114,8 @@ meta_backend_x11_cm_update_screen_size (MetaBackend *backend,
|
||||
}
|
||||
|
||||
static void
|
||||
meta_backend_x11_cm_select_stage_events (MetaBackend *backend)
|
||||
select_xi_stage (MetaBackend *backend,
|
||||
gboolean include_motion)
|
||||
{
|
||||
MetaBackendX11 *x11 = META_BACKEND_X11 (backend);
|
||||
Display *xdisplay = meta_backend_x11_get_xdisplay (x11);
|
||||
@ -132,9 +133,24 @@ meta_backend_x11_cm_select_stage_events (MetaBackend *backend)
|
||||
XISetMask (mask.mask, XI_FocusOut);
|
||||
XISetMask (mask.mask, XI_Motion);
|
||||
|
||||
if (include_motion)
|
||||
XISetMask (mask.mask, XI_RawMotion);
|
||||
|
||||
XISelectEvents (xdisplay, xwin, &mask, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_backend_x11_cm_select_stage_events (MetaBackend *backend)
|
||||
{
|
||||
select_xi_stage (backend, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_backend_x11_cm_track_position (MetaBackend *x11, gboolean enabled)
|
||||
{
|
||||
select_xi_stage (backend, enabled);
|
||||
}
|
||||
|
||||
static void
|
||||
get_xkbrf_var_defs (Display *xdisplay,
|
||||
const char *layouts,
|
||||
@ -386,6 +402,7 @@ meta_backend_x11_cm_class_init (MetaBackendX11CmClass *klass)
|
||||
backend_class->select_stage_events = meta_backend_x11_cm_select_stage_events;
|
||||
backend_class->lock_layout_group = meta_backend_x11_cm_lock_layout_group;
|
||||
backend_class->set_keymap = meta_backend_x11_cm_set_keymap;
|
||||
backend_class->track_position = meta_backend_x11_cm_track_position;
|
||||
|
||||
backend_x11_class->handle_host_xevent = meta_backend_x11_cm_handle_host_xevent;
|
||||
backend_x11_class->translate_device_event = meta_backend_x11_cm_translate_device_event;
|
||||
|
@ -207,6 +207,8 @@ handle_input_event (MetaBackendX11 *x11,
|
||||
|
||||
if (input_event->evtype == XI_DeviceChanged)
|
||||
handle_device_change (x11, input_event);
|
||||
else if (input_event->evtype == XI_RawMotion)
|
||||
meta_backend_cursor_position_changed (META_BACKEND (x11));
|
||||
else
|
||||
maybe_spoof_event_as_stage_event (x11, input_event);
|
||||
}
|
||||
|
@ -61,7 +61,8 @@ meta_backend_x11_nested_update_screen_size (MetaBackend *backend,
|
||||
}
|
||||
|
||||
static void
|
||||
meta_backend_x11_nested_select_stage_events (MetaBackend *backend)
|
||||
select_xi_stage (MetaBackend *backend,
|
||||
gboolean include_motion)
|
||||
{
|
||||
MetaBackendX11 *x11 = META_BACKEND_X11 (backend);
|
||||
Display *xdisplay = meta_backend_x11_get_xdisplay (x11);
|
||||
@ -79,6 +80,9 @@ meta_backend_x11_nested_select_stage_events (MetaBackend *backend)
|
||||
XISetMask (mask.mask, XI_FocusOut);
|
||||
XISetMask (mask.mask, XI_Motion);
|
||||
|
||||
if (include_motion)
|
||||
XISetMask (mask.mask, XI_RawMotion);
|
||||
|
||||
/*
|
||||
* When we're an X11 compositor, we can't take these events or else replaying
|
||||
* events from our passive root window grab will cause them to come back to
|
||||
@ -91,6 +95,16 @@ meta_backend_x11_nested_select_stage_events (MetaBackend *backend)
|
||||
XISetMask (mask.mask, XI_TouchUpdate);
|
||||
|
||||
XISelectEvents (xdisplay, xwin, &mask, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_backend_x11_nested_select_stage_events (MetaBackend *backend)
|
||||
{
|
||||
select_xi_stage (backend, FALSE);
|
||||
|
||||
MetaBackendX11 *x11 = META_BACKEND_X11 (backend);
|
||||
Display *xdisplay = meta_backend_x11_get_xdisplay (x11);
|
||||
Window xwin = meta_backend_x11_get_xwindow (x11);
|
||||
|
||||
/*
|
||||
* We have no way of tracking key changes when the stage doesn't have focus,
|
||||
@ -105,6 +119,12 @@ meta_backend_x11_nested_select_stage_events (MetaBackend *backend)
|
||||
xwa.your_event_mask | FocusChangeMask | KeymapStateMask);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_backend_x11_nested_track_position (MetaBackend *x11, gboolean enabled)
|
||||
{
|
||||
select_xi_stage (backend, enabled);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_backend_x11_nested_lock_layout_group (MetaBackend *backend,
|
||||
guint idx)
|
||||
@ -178,6 +198,7 @@ meta_backend_x11_nested_class_init (MetaBackendX11NestedClass *klass)
|
||||
backend_class->select_stage_events = meta_backend_x11_nested_select_stage_events;
|
||||
backend_class->lock_layout_group = meta_backend_x11_nested_lock_layout_group;
|
||||
backend_class->set_keymap = meta_backend_x11_nested_set_keymap;
|
||||
backend_class->track_position = meta_backend_x11_nested_track_position;
|
||||
|
||||
backend_x11_class->handle_host_xevent = meta_backend_x11_nested_handle_host_xevent;
|
||||
backend_x11_class->translate_device_event = meta_backend_x11_nested_translate_device_event;
|
||||
|
@ -53,4 +53,7 @@ void meta_cursor_tracker_get_pointer (MetaCursorTracker *tracker,
|
||||
void meta_cursor_tracker_set_pointer_visible (MetaCursorTracker *tracker,
|
||||
gboolean visible);
|
||||
|
||||
void meta_cursor_tracker_enable_track_position (MetaCursorTracker *tracker);
|
||||
void meta_cursor_tracker_disable_track_position (MetaCursorTracker *tracker);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user