mirror of
https://github.com/brl/mutter.git
synced 2025-06-13 16:59:30 +00:00
clutter: Simplify stage state management
Making this an event is overly convoluted, accounting that we emit the event, then convert it to a ClutterStage signal, then its only consumer (a11y) sets the active ATK state. Take the event out of the equation, unify activation/deactivation of the stage in MetaStage, and use it from the X11 backend too. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1623>
This commit is contained in:

committed by
Marge Bot

parent
96e320ba5a
commit
4a0c56f928
@ -434,40 +434,13 @@ void
|
||||
meta_stage_set_active (MetaStage *stage,
|
||||
gboolean is_active)
|
||||
{
|
||||
ClutterEvent *event;
|
||||
|
||||
/* Used by the native backend to inform accessibility technologies
|
||||
* about when the stage loses and gains input focus.
|
||||
*
|
||||
* For the X11 backend, clutter transparently takes care of this
|
||||
* for us.
|
||||
*/
|
||||
|
||||
if (stage->is_active == is_active)
|
||||
return;
|
||||
|
||||
event = clutter_event_new (CLUTTER_STAGE_STATE);
|
||||
clutter_event_set_stage (event, CLUTTER_STAGE (stage));
|
||||
event->stage_state.changed_mask = CLUTTER_STAGE_STATE_ACTIVATED;
|
||||
|
||||
if (is_active)
|
||||
event->stage_state.new_state = CLUTTER_STAGE_STATE_ACTIVATED;
|
||||
|
||||
/* Emitting this StageState event will result in the stage getting
|
||||
* activated or deactivated (with the activated or deactivated signal
|
||||
* getting emitted from the stage)
|
||||
*
|
||||
* FIXME: This won't update ClutterStage's own notion of its
|
||||
* activeness. For that we would need to somehow trigger a
|
||||
* _clutter_stage_update_state call, which will probably
|
||||
* require new API in clutter. In practice, nothing relies
|
||||
* on the ClutterStage's own notion of activeness when using
|
||||
* the EGL backend.
|
||||
*
|
||||
* See http://bugzilla.gnome.org/746670
|
||||
*/
|
||||
clutter_stage_event (CLUTTER_STAGE (stage), event);
|
||||
clutter_event_free (event);
|
||||
g_signal_emit_by_name (CLUTTER_STAGE (stage), "activate");
|
||||
else
|
||||
g_signal_emit_by_name (CLUTTER_STAGE (stage), "deactivate");
|
||||
}
|
||||
|
||||
MetaStageWatch *
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "backends/meta-stage-private.h"
|
||||
#include "backends/x11/cm/meta-backend-x11-cm.h"
|
||||
#include "backends/x11/cm/meta-renderer-x11-cm.h"
|
||||
#include "backends/x11/meta-backend-x11.h"
|
||||
@ -692,21 +693,11 @@ meta_stage_x11_translate_event (MetaStageX11 *stage_x11,
|
||||
break;
|
||||
|
||||
case FocusIn:
|
||||
if (!_clutter_stage_is_activated (stage_cogl->wrapper))
|
||||
{
|
||||
_clutter_stage_update_state (stage_cogl->wrapper,
|
||||
0,
|
||||
CLUTTER_STAGE_STATE_ACTIVATED);
|
||||
}
|
||||
meta_stage_set_active ((MetaStage *) stage_cogl->wrapper, TRUE);
|
||||
break;
|
||||
|
||||
case FocusOut:
|
||||
if (_clutter_stage_is_activated (stage_cogl->wrapper))
|
||||
{
|
||||
_clutter_stage_update_state (stage_cogl->wrapper,
|
||||
CLUTTER_STAGE_STATE_ACTIVATED,
|
||||
0);
|
||||
}
|
||||
meta_stage_set_active ((MetaStage *) stage_cogl->wrapper, FALSE);
|
||||
break;
|
||||
|
||||
case Expose:
|
||||
|
@ -109,8 +109,7 @@ handle_idletime_for_event (const ClutterEvent *event)
|
||||
|
||||
if (event->any.flags & CLUTTER_EVENT_FLAG_SYNTHETIC ||
|
||||
event->type == CLUTTER_ENTER ||
|
||||
event->type == CLUTTER_LEAVE ||
|
||||
event->type == CLUTTER_STAGE_STATE)
|
||||
event->type == CLUTTER_LEAVE)
|
||||
return;
|
||||
|
||||
core_monitor = meta_idle_monitor_get_core ();
|
||||
|
@ -104,15 +104,6 @@ get_event_state_string (const ClutterEvent *event)
|
||||
return g_strjoinv (",", (char **) mods);
|
||||
}
|
||||
|
||||
static void
|
||||
stage_state_cb (ClutterStage *stage,
|
||||
gpointer data)
|
||||
{
|
||||
gchar *detail = (gchar*)data;
|
||||
|
||||
printf("[stage signal] %s\n", detail);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
red_button_cb (ClutterActor *actor,
|
||||
ClutterEvent *event,
|
||||
@ -347,9 +338,6 @@ input_cb (ClutterActor *actor,
|
||||
state);
|
||||
}
|
||||
break;
|
||||
case CLUTTER_STAGE_STATE:
|
||||
g_print ("[%s] STAGE STATE", clutter_actor_get_name (source_actor));
|
||||
break;
|
||||
case CLUTTER_TOUCHPAD_PINCH:
|
||||
g_print ("[%s] TOUCHPAD PINCH", clutter_actor_get_name (source_actor));
|
||||
break;
|
||||
@ -401,10 +389,6 @@ test_events_main (int argc, char *argv[])
|
||||
clutter_actor_set_name (stage, "Stage");
|
||||
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_test_quit), NULL);
|
||||
g_signal_connect (stage, "event", G_CALLBACK (input_cb), (char *) "stage");
|
||||
g_signal_connect (stage, "activate",
|
||||
G_CALLBACK (stage_state_cb), (char *) "activate");
|
||||
g_signal_connect (stage, "deactivate",
|
||||
G_CALLBACK (stage_state_cb), (char *) "deactivate");
|
||||
|
||||
focus_box = clutter_actor_new ();
|
||||
clutter_actor_set_background_color (focus_box, CLUTTER_COLOR_Black);
|
||||
|
@ -9,15 +9,6 @@ test_grab_main (int argc, char *argv[]);
|
||||
const char *
|
||||
test_grab_describe (void);
|
||||
|
||||
static void
|
||||
stage_state_cb (ClutterStage *stage,
|
||||
gpointer data)
|
||||
{
|
||||
gchar *detail = (gchar*)data;
|
||||
|
||||
printf("[stage signal] %s\n", detail);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
debug_event_cb (ClutterActor *actor,
|
||||
ClutterEvent *event,
|
||||
@ -59,9 +50,6 @@ debug_event_cb (ClutterActor *actor,
|
||||
case CLUTTER_SCROLL:
|
||||
printf("[%s] BUTTON SCROLL", source);
|
||||
break;
|
||||
case CLUTTER_STAGE_STATE:
|
||||
printf("[%s] STAGE STATE", source);
|
||||
break;
|
||||
case CLUTTER_TOUCH_BEGIN:
|
||||
g_print ("[%s] TOUCH BEGIN", source);
|
||||
break;
|
||||
@ -222,10 +210,6 @@ test_grab_main (int argc, char *argv[])
|
||||
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_test_quit), NULL);
|
||||
g_signal_connect (stage, "event",
|
||||
G_CALLBACK (debug_event_cb), (char *) "stage");
|
||||
g_signal_connect (stage, "activate",
|
||||
G_CALLBACK (stage_state_cb), (char *) "activate");
|
||||
g_signal_connect (stage, "deactivate",
|
||||
G_CALLBACK (stage_state_cb), (char *) "deactivate");
|
||||
|
||||
actor = clutter_actor_new ();
|
||||
clutter_actor_set_background_color (actor, &rcol);
|
||||
|
Reference in New Issue
Block a user