mirror of
https://github.com/brl/mutter.git
synced 2024-11-30 03:50:47 -05:00
clutter: Pass target actor of events to event filter functions
We'll need the additional context of which actor the event will be emitted to in mutters event filter (see next commit), so pass that target actor to the event filters that are installed. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2321>
This commit is contained in:
parent
703d8a77f1
commit
2aad56b949
@ -14,7 +14,8 @@ CLUTTER_EXPORT
|
||||
void _clutter_process_event (ClutterEvent *event);
|
||||
|
||||
CLUTTER_EXPORT
|
||||
gboolean _clutter_event_process_filters (ClutterEvent *event);
|
||||
gboolean _clutter_event_process_filters (ClutterEvent *event,
|
||||
ClutterActor *event_actor);
|
||||
|
||||
/* clears the event queue inside the main context */
|
||||
void _clutter_clear_events_queue (void);
|
||||
|
@ -1772,7 +1772,8 @@ clutter_event_is_pointer_emulated (const ClutterEvent *event)
|
||||
}
|
||||
|
||||
gboolean
|
||||
_clutter_event_process_filters (ClutterEvent *event)
|
||||
_clutter_event_process_filters (ClutterEvent *event,
|
||||
ClutterActor *event_actor)
|
||||
{
|
||||
ClutterMainContext *context = _clutter_context_get_default ();
|
||||
GList *l, *next;
|
||||
@ -1789,7 +1790,7 @@ _clutter_event_process_filters (ClutterEvent *event)
|
||||
if (event_filter->stage && event_filter->stage != event->any.stage)
|
||||
continue;
|
||||
|
||||
if (event_filter->func (event, event_filter->user_data) == CLUTTER_EVENT_STOP)
|
||||
if (event_filter->func (event, event_actor, event_filter->user_data) == CLUTTER_EVENT_STOP)
|
||||
return CLUTTER_EVENT_STOP;
|
||||
}
|
||||
|
||||
|
@ -615,6 +615,7 @@ union _ClutterEvent
|
||||
/**
|
||||
* ClutterEventFilterFunc:
|
||||
* @event: the event that is going to be emitted
|
||||
* @event_actor: the current device actor of the events device
|
||||
* @user_data: the data pointer passed to clutter_event_add_filter()
|
||||
*
|
||||
* A function pointer type used by event filters that are added with
|
||||
@ -628,6 +629,7 @@ union _ClutterEvent
|
||||
* Since: 1.18
|
||||
*/
|
||||
typedef gboolean (* ClutterEventFilterFunc) (const ClutterEvent *event,
|
||||
ClutterActor *event_actor,
|
||||
gpointer user_data);
|
||||
|
||||
CLUTTER_EXPORT
|
||||
|
@ -741,6 +741,8 @@ update_device_for_event (ClutterStage *stage,
|
||||
void
|
||||
clutter_do_event (ClutterEvent *event)
|
||||
{
|
||||
ClutterActor *event_actor = NULL;
|
||||
|
||||
/* we need the stage for the event */
|
||||
if (event->any.stage == NULL)
|
||||
{
|
||||
@ -765,7 +767,15 @@ clutter_do_event (ClutterEvent *event)
|
||||
break;
|
||||
}
|
||||
|
||||
if (_clutter_event_process_filters (event))
|
||||
if (event->any.type != CLUTTER_DEVICE_ADDED &&
|
||||
event->any.type != CLUTTER_DEVICE_REMOVED &&
|
||||
event->any.type != CLUTTER_NOTHING &&
|
||||
event->any.type != CLUTTER_EVENT_LAST)
|
||||
{
|
||||
event_actor = clutter_stage_get_event_actor (event->any.stage, event);
|
||||
}
|
||||
|
||||
if (_clutter_event_process_filters (event, event_actor))
|
||||
return;
|
||||
|
||||
/* Instead of processing events when received, we queue them up to
|
||||
|
@ -3478,7 +3478,7 @@ clutter_stage_update_device (ClutterStage *stage,
|
||||
CLUTTER_EVENT_NONE,
|
||||
old_actor, new_actor,
|
||||
point, time_ms);
|
||||
if (!_clutter_event_process_filters (event))
|
||||
if (!_clutter_event_process_filters (event, old_actor))
|
||||
_clutter_actor_handle_event (old_actor, root, event);
|
||||
|
||||
clutter_event_free (event);
|
||||
@ -3492,7 +3492,7 @@ clutter_stage_update_device (ClutterStage *stage,
|
||||
CLUTTER_EVENT_NONE,
|
||||
new_actor, old_actor,
|
||||
point, time_ms);
|
||||
if (!_clutter_event_process_filters (event))
|
||||
if (!_clutter_event_process_filters (event, new_actor))
|
||||
_clutter_actor_handle_event (new_actor, root, event);
|
||||
|
||||
clutter_event_free (event);
|
||||
@ -3676,7 +3676,7 @@ clutter_stage_notify_grab_on_pointer_entry (ClutterStage *stage,
|
||||
grab_actor : old_grab_actor,
|
||||
entry->coords,
|
||||
CLUTTER_CURRENT_TIME);
|
||||
if (!_clutter_event_process_filters (event))
|
||||
if (!_clutter_event_process_filters (event, entry->current_actor))
|
||||
_clutter_actor_handle_event (deepmost, topmost, event);
|
||||
clutter_event_free (event);
|
||||
}
|
||||
|
@ -213,7 +213,8 @@ maybe_unfreeze_pointer_events (MetaBackend *backend,
|
||||
|
||||
static gboolean
|
||||
meta_display_handle_event (MetaDisplay *display,
|
||||
const ClutterEvent *event)
|
||||
const ClutterEvent *event,
|
||||
ClutterActor *event_actor)
|
||||
{
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
MetaWindow *window = NULL;
|
||||
@ -540,11 +541,12 @@ meta_display_handle_event (MetaDisplay *display,
|
||||
|
||||
static gboolean
|
||||
event_callback (const ClutterEvent *event,
|
||||
ClutterActor *event_actor,
|
||||
gpointer data)
|
||||
{
|
||||
MetaDisplay *display = data;
|
||||
|
||||
return meta_display_handle_event (display, event);
|
||||
return meta_display_handle_event (display, event, event_actor);
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user