clutter/pick-context: Make pick context aware of the pick mode

Pass the pick mode during construction, and add a getter for it. It'll
be used by the next patches to make clutter_actor_should_pick_paint()
not depend on a global context.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1509
This commit is contained in:
Georges Basile Stavracas Neto 2020-10-16 09:59:54 -03:00
parent 8a709b5766
commit a4961ad4a7
4 changed files with 19 additions and 3 deletions

View File

@ -20,6 +20,7 @@
#include "clutter-pick-context.h"
ClutterPickContext * clutter_pick_context_new_for_view (ClutterStageView *view);
ClutterPickContext * clutter_pick_context_new_for_view (ClutterStageView *view,
ClutterPickMode mode);
#endif /* CLUTTER_PICK_CONTEXT_PRIVATE_H */

View File

@ -23,6 +23,7 @@ struct _ClutterPickContext
{
grefcount ref_count;
ClutterPickMode mode;
CoglFramebuffer *framebuffer;
};
@ -31,12 +32,14 @@ G_DEFINE_BOXED_TYPE (ClutterPickContext, clutter_pick_context,
clutter_pick_context_unref)
ClutterPickContext *
clutter_pick_context_new_for_view (ClutterStageView *view)
clutter_pick_context_new_for_view (ClutterStageView *view,
ClutterPickMode mode)
{
ClutterPickContext *pick_context;
pick_context = g_new0 (ClutterPickContext, 1);
g_ref_count_init (&pick_context->ref_count);
pick_context->mode = mode;
pick_context->framebuffer =
g_object_ref (clutter_stage_view_get_framebuffer (view));
@ -81,3 +84,12 @@ clutter_pick_context_get_framebuffer (ClutterPickContext *pick_context)
{
return pick_context->framebuffer;
}
/**
* clutter_pick_context_get_mode: (skip)
*/
ClutterPickMode
clutter_pick_context_get_mode (ClutterPickContext *pick_context)
{
return pick_context->mode;
}

View File

@ -46,4 +46,7 @@ void clutter_pick_context_destroy (ClutterPickContext *pick_context);
CLUTTER_EXPORT
CoglFramebuffer * clutter_pick_context_get_framebuffer (ClutterPickContext *pick_context);
CLUTTER_EXPORT
ClutterPickMode clutter_pick_context_get_mode (ClutterPickContext *pick_context);
#endif /* CLUTTER_PICK_CONTEXT_H */

View File

@ -1405,7 +1405,7 @@ _clutter_stage_do_pick_on_view (ClutterStage *stage,
_clutter_stage_clear_pick_stack (stage);
pick_context = clutter_pick_context_new_for_view (view);
pick_context = clutter_pick_context_new_for_view (view, mode);
context->pick_mode = mode;
priv->cached_pick_mode = CLUTTER_PICK_NONE;