Back to index

unity  6.0.0
Defines | Functions
nux-area-accessible.cpp File Reference
#include "nux-area-accessible.h"
#include "unitya11y.h"

Go to the source code of this file.

Defines

#define NUX_AREA_ACCESSIBLE_GET_PRIVATE(obj)

Functions

static void nux_area_accessible_class_init (NuxAreaAccessibleClass *klass)
 SECTION:nux-area-accessible : NuxAreaAccessible : Implementation of the ATK interfaces for #nux::Area : nux::Area.
static void nux_area_accessible_init (NuxAreaAccessible *area_accessible)
static void nux_area_accessible_initialize (AtkObject *accessible, gpointer data)
static AtkObject * nux_area_accessible_get_parent (AtkObject *obj)
static AtkStateSet * nux_area_accessible_ref_state_set (AtkObject *obj)
static void atk_component_interface_init (AtkComponentIface *iface)
static void nux_area_accessible_get_extents (AtkComponent *component, gint *x, gint *y, gint *width, gint *height, AtkCoordType coord_type)
static gboolean nux_area_accessible_grab_focus (AtkComponent *component)
static guint nux_area_accessible_add_focus_handler (AtkComponent *component, AtkFocusHandler handler)
static void nux_area_accessible_remove_focus_handler (AtkComponent *component, guint handler_id)
static void nux_area_accessible_focus_handler (AtkObject *accessible, gboolean focus_in)
static void on_focus_changed_cb (nux::Area *area, bool has_focus, nux::KeyNavDirection direction, AtkObject *accessible)
static void on_parent_window_activate_cb (AtkObject *parent_window, NuxAreaAccessible *self)
static AtkObject * search_for_parent_window (AtkObject *object)
static gboolean nux_area_accessible_real_check_pending_notification (NuxAreaAccessible *self)
static void check_parent_window_connected (NuxAreaAccessible *self)
static void check_focus (NuxAreaAccessible *self)
 G_DEFINE_TYPE_WITH_CODE (NuxAreaAccessible, nux_area_accessible, NUX_TYPE_OBJECT_ACCESSIBLE, G_IMPLEMENT_INTERFACE(ATK_TYPE_COMPONENT, atk_component_interface_init)) struct _NuxAreaAccessiblePrivate
AtkObject * nux_area_accessible_new (nux::Object *object)
static gboolean _check_all_parents_visible (nux::Area *area)
gboolean nux_area_accessible_parent_window_active (NuxAreaAccessible *self)
gboolean nux_area_accessible_check_pending_notification (NuxAreaAccessible *self)
AtkObject * nux_area_accessible_get_parent_window (NuxAreaAccessible *self)

Define Documentation

Value:
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), NUX_TYPE_AREA_ACCESSIBLE,        \
                                NuxAreaAccessiblePrivate))

Function Documentation

static gboolean _check_all_parents_visible ( nux::Area *  area) [static]

Definition at line 217 of file nux-area-accessible.cpp.

{
  nux::Area* iter_parent = NULL;
  gboolean result = TRUE;

  for (iter_parent = area; iter_parent;
       iter_parent = iter_parent->GetParentObject())
  {
    if (!iter_parent->IsVisible())
    {
      result = FALSE;
      break;
    }
  }

  return result;
}

Here is the caller graph for this function:

static void atk_component_interface_init ( AtkComponentIface *  iface) [static]

Definition at line 279 of file nux-area-accessible.cpp.

{
  g_return_if_fail(iface != NULL);

  /* placement */
  iface->get_extents    = nux_area_accessible_get_extents;

  /* focus management based on Focusable */
  iface->grab_focus           = nux_area_accessible_grab_focus;
  iface->add_focus_handler    = nux_area_accessible_add_focus_handler;
  iface->remove_focus_handler = nux_area_accessible_remove_focus_handler;
}

Here is the call graph for this function:

static void check_focus ( NuxAreaAccessible *  self) [static]

Definition at line 533 of file nux-area-accessible.cpp.

{
  gboolean focus_in = FALSE;
  nux::Area* area = NULL;
  nux::Object* nux_object = NULL;

  g_return_if_fail(NUX_IS_AREA_ACCESSIBLE(self));

  nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(self));
  if (nux_object == NULL) /* defunct */
    return;

  area = dynamic_cast<nux::Area*>(nux_object);

  if (nux::GetWindowCompositor().GetKeyFocusArea() == area)
    focus_in = TRUE;

  if (self->priv->focused != focus_in)
  {
    gboolean is_parent_window_active = FALSE;

    self->priv->focused = focus_in;
    is_parent_window_active = nux_area_accessible_parent_window_active(self);

    /* we don't emit focus_in=TRUE events until the top level window
       is active */
    if ((focus_in) && (!is_parent_window_active))
    {
      self->priv->pending_notification = TRUE;
    }
    else
    {
      g_signal_emit_by_name(self, "focus_event", focus_in);
      atk_focus_tracker_notify(ATK_OBJECT(self));
      self->priv->pending_notification = FALSE;
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void check_parent_window_connected ( NuxAreaAccessible *  self) [static]

Definition at line 413 of file nux-area-accessible.cpp.

{
  AtkObject* window = NULL;

  if (self->priv->parent_window != NULL)
    return;

  window = search_for_parent_window(ATK_OBJECT(self));

  if (window != NULL)
  {
    self->priv->parent_window = window;

    g_signal_connect(self->priv->parent_window,
                     "activate",
                     G_CALLBACK(on_parent_window_activate_cb),
                     self);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

G_DEFINE_TYPE_WITH_CODE ( NuxAreaAccessible  ,
nux_area_accessible  ,
NUX_TYPE_OBJECT_ACCESSIBLE  ,
G_IMPLEMENT_INTERFACE(ATK_TYPE_COMPONENT,atk_component_interface_init  
)

Definition at line 96 of file nux-area-accessible.cpp.

{
  /* focused as Focusable events */
  gboolean focused;

  /* if there is any pending notification */
  gboolean pending_notification;

  /* Top level parent window, it is not required to be the direct
     parent */
  AtkObject* parent_window;
};
static guint nux_area_accessible_add_focus_handler ( AtkComponent *  component,
AtkFocusHandler  handler 
) [static]

Definition at line 367 of file nux-area-accessible.cpp.

{
  GSignalMatchType match_type;
  gulong ret;
  guint signal_id;

  g_return_val_if_fail(NUX_IS_AREA_ACCESSIBLE(component), 0);

  match_type = (GSignalMatchType)(G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC);
  signal_id = g_signal_lookup("focus-event", ATK_TYPE_OBJECT);

  ret = g_signal_handler_find(component, match_type, signal_id, 0, NULL,
                              (gpointer) handler, NULL);
  if (!ret)
  {
    return g_signal_connect_closure_by_id(component,
                                          signal_id, 0,
                                          g_cclosure_new(G_CALLBACK(handler), NULL,
                                                         (GClosureNotify) NULL),
                                          FALSE);
  }
  else
    return 0;
}

Here is the caller graph for this function:

gboolean nux_area_accessible_check_pending_notification ( NuxAreaAccessible *  self)

Definition at line 500 of file nux-area-accessible.cpp.

{
  NuxAreaAccessibleClass* klass = NULL;

  klass = NUX_AREA_ACCESSIBLE_GET_CLASS(self);
  if (klass->check_pending_notification)
    return klass->check_pending_notification(self);
  else
    return FALSE;
}

Here is the caller graph for this function:

static void nux_area_accessible_class_init ( NuxAreaAccessibleClass *  klass) [static]

SECTION:nux-area-accessible : NuxAreaAccessible : Implementation of the ATK interfaces for #nux::Area : nux::Area.

NuxAreaAccessible implements the required ATK interfaces of

nux::Area, exposing the common elements on each basic individual element (position, extents, etc)

In this object is also implemented the main support for the focused object. This is complex due several reasons:

  • We need to ensure the proper order when the objects gets the focus
  • It doesn't make too sense to give the focus to an object that it is inside a inactive window, so it is also convenient to emit the window:active event before the focus change.

=> this is the reason there is implemented a system to delay the focus notification until the top level window became active

  • But the main complexity comes from the fact that not all the objects on unity are implementing key nav in the same way.

    • Launcher uses exclusively InputArea methods like SetKeyboardFocus, OnStartKeyboardReceiver, etc. This is the key focus at a low level abstraction
    • Dash objects uses the events from Focusable. But in the same way, they require the low level key focus (OnStartFocus) and so on

Definition at line 121 of file nux-area-accessible.cpp.

{
  GObjectClass* gobject_class = G_OBJECT_CLASS(klass);
  AtkObjectClass* atk_class = ATK_OBJECT_CLASS(klass);
  NuxAreaAccessibleClass* area_class = NUX_AREA_ACCESSIBLE_CLASS(klass);

  /* AtkObject */
  atk_class->initialize = nux_area_accessible_initialize;
  atk_class->get_parent = nux_area_accessible_get_parent;
  atk_class->ref_state_set = nux_area_accessible_ref_state_set;

  /* NuxAreaAccessible */
  area_class->check_pending_notification = nux_area_accessible_real_check_pending_notification;

  g_type_class_add_private(gobject_class, sizeof(NuxAreaAccessiblePrivate));
}

Here is the call graph for this function:

static void nux_area_accessible_focus_handler ( AtkObject *  accessible,
gboolean  focus_in 
) [static]

Definition at line 403 of file nux-area-accessible.cpp.

{
  g_return_if_fail(NUX_IS_AREA_ACCESSIBLE(accessible));

  atk_object_notify_state_change(accessible, ATK_STATE_FOCUSED, focus_in);
}

Here is the caller graph for this function:

static void nux_area_accessible_get_extents ( AtkComponent *  component,
gint *  x,
gint *  y,
gint *  width,
gint *  height,
AtkCoordType  coord_type 
) [static]

Definition at line 293 of file nux-area-accessible.cpp.

{
  gint top_level_x = 0;
  gint top_level_y = 0;
  nux::Object* nux_object = NULL;
  nux::Area* area = NULL;
  nux::Geometry geometry;

  g_return_if_fail(NUX_IS_AREA_ACCESSIBLE(component));

  nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(component));

  if (nux_object == NULL) /* defunct */
    return;

  area = dynamic_cast<nux::Area*>(nux_object);

  geometry = area->GetGeometry();

  *width = geometry.GetWidth();
  *height = geometry.GetWidth();
  *x = geometry.x;
  *y = geometry.y;

  /* In the ATK_XY_WINDOW case
   *
   * http://library.gnome.org/devel/atk/stable/AtkUtil.html#AtkCoordType
   */

  if (coord_type == ATK_XY_SCREEN)
  {
    /* For the moment Unity is a full-screen app, so ATK_XY_SCREEN
       and ATK_XY_WINDOW are the same */
    *x += top_level_x;
    *y += top_level_y;
  }

  return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static AtkObject * nux_area_accessible_get_parent ( AtkObject *  obj) [static]

Definition at line 189 of file nux-area-accessible.cpp.

{
  nux::Object* nux_object = NULL;
  nux::Area* area = NULL;
  nux::Area* parent = NULL;

  g_return_val_if_fail(NUX_IS_AREA_ACCESSIBLE(obj), NULL);

  if (obj->accessible_parent)
    return obj->accessible_parent;

  nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(obj));

  if (nux_object == NULL) /* defunct */
    return NULL;

  area = dynamic_cast<nux::Area*>(nux_object);

  parent = area->GetParentObject();

  return unity_a11y_get_accessible(parent);
}

Here is the call graph for this function:

Here is the caller graph for this function:

AtkObject* nux_area_accessible_get_parent_window ( NuxAreaAccessible *  self)

Definition at line 581 of file nux-area-accessible.cpp.

{
  g_return_val_if_fail(NUX_IS_AREA_ACCESSIBLE(self), NULL);

  /* Ensures that at least whe made a search for it */
  check_parent_window_connected(self);

  return self->priv->parent_window;
}

Here is the call graph for this function:

static gboolean nux_area_accessible_grab_focus ( AtkComponent *  component) [static]

Definition at line 339 of file nux-area-accessible.cpp.

{
  nux::Object* nux_object = NULL;
  //nux::Area* area = NULL;

  g_return_val_if_fail(NUX_IS_AREA_ACCESSIBLE(component), FALSE);

  nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(component));
  if (nux_object == NULL) /* defunct */
    return FALSE;

  //area = dynamic_cast<nux::Area*>(nux_object);

  /* FIXME: SetFocused doesn't return if the force was succesful or
     not, we suppose that this is the case like in cally and gail */

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void nux_area_accessible_init ( NuxAreaAccessible *  area_accessible) [static]

Definition at line 139 of file nux-area-accessible.cpp.

{
  NuxAreaAccessiblePrivate* priv =
    NUX_AREA_ACCESSIBLE_GET_PRIVATE(area_accessible);

  area_accessible->priv = priv;
}
static void nux_area_accessible_initialize ( AtkObject *  accessible,
gpointer  data 
) [static]

Definition at line 163 of file nux-area-accessible.cpp.

{
  nux::Object* nux_object = NULL;
  nux::Area* area = NULL;

  ATK_OBJECT_CLASS(nux_area_accessible_parent_class)->initialize(accessible, data);

  accessible->role = ATK_ROLE_UNKNOWN;

  nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(accessible));
  area = dynamic_cast<nux::Area*>(nux_object);

  /* focus support based on Focusable, used on the Dash */
  area->key_nav_focus_change.connect(sigc::bind(sigc::ptr_fun(on_focus_changed_cb), accessible));

  atk_component_add_focus_handler(ATK_COMPONENT(accessible),
                                  nux_area_accessible_focus_handler);

  /* NOTE: we can't search for the parent window on initilization as a
     general rule, or we could enter on a infinite loop. At area this
     is done on the focus event. On the Switcher this is done on their
     initialize itself */
}

Here is the call graph for this function:

Here is the caller graph for this function:

AtkObject* nux_area_accessible_new ( nux::Object *  object)

Definition at line 148 of file nux-area-accessible.cpp.

{
  AtkObject* accessible = NULL;

  g_return_val_if_fail(dynamic_cast<nux::Area*>(object), NULL);

  accessible = ATK_OBJECT(g_object_new(NUX_TYPE_AREA_ACCESSIBLE, NULL));

  atk_object_initialize(accessible, object);

  return accessible;
}

Here is the caller graph for this function:

gboolean nux_area_accessible_parent_window_active ( NuxAreaAccessible *  self)

Definition at line 444 of file nux-area-accessible.cpp.

{
  gboolean active = FALSE;
  AtkStateSet* state_set = NULL;

  check_parent_window_connected(self);

  state_set = atk_object_ref_state_set(ATK_OBJECT(self->priv->parent_window));

  active = atk_state_set_contains_state(state_set, ATK_STATE_ACTIVE);

  g_object_unref(state_set);

  return active;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static gboolean nux_area_accessible_real_check_pending_notification ( NuxAreaAccessible *  self) [static]

Definition at line 512 of file nux-area-accessible.cpp.

{
  nux::Object* nux_object = NULL;

  g_return_val_if_fail(NUX_IS_AREA_ACCESSIBLE(self), FALSE);

  if (self->priv->pending_notification == FALSE)
    return FALSE;

  nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(self));
  if (nux_object == NULL) /* defunct */
    return FALSE;

  g_signal_emit_by_name(self, "focus_event", self->priv->focused);
  atk_focus_tracker_notify(ATK_OBJECT(self));
  self->priv->pending_notification = FALSE;

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static AtkStateSet * nux_area_accessible_ref_state_set ( AtkObject *  obj) [static]

Definition at line 236 of file nux-area-accessible.cpp.

{
  AtkStateSet* state_set = NULL;
  nux::Object* nux_object = NULL;
  nux::Area* area = NULL;

  g_return_val_if_fail(NUX_IS_AREA_ACCESSIBLE(obj), NULL);

  state_set = ATK_OBJECT_CLASS(nux_area_accessible_parent_class)->ref_state_set(obj);

  nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(obj));

  if (nux_object == NULL) /* defunct */
    return state_set;

  area = dynamic_cast<nux::Area*>(nux_object);

  if (area->IsSensitive())
  {
    atk_state_set_add_state(state_set, ATK_STATE_SENSITIVE);
    atk_state_set_add_state(state_set, ATK_STATE_ENABLED);
  }

  if (area->IsVisible())
  {
    atk_state_set_add_state(state_set, ATK_STATE_VISIBLE);

    if (_check_all_parents_visible(area))
      atk_state_set_add_state(state_set, ATK_STATE_SHOWING);
  }

  // FIXME CanFocus is no longer part of Nux API
//  if (area->CanFocus())
//    atk_state_set_add_state(state_set, ATK_STATE_FOCUSABLE);

  if (area->HasKeyFocus())
    atk_state_set_add_state(state_set, ATK_STATE_FOCUSED);

  return state_set;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void nux_area_accessible_remove_focus_handler ( AtkComponent *  component,
guint  handler_id 
) [static]

Definition at line 394 of file nux-area-accessible.cpp.

{
  g_return_if_fail(NUX_IS_AREA_ACCESSIBLE(component));

  g_signal_handler_disconnect(component, handler_id);
}

Here is the caller graph for this function:

static void on_focus_changed_cb ( nux::Area *  area,
bool  has_focus,
nux::KeyNavDirection  direction,
AtkObject *  accessible 
) [static]

Definition at line 461 of file nux-area-accessible.cpp.

{
  check_focus(NUX_AREA_ACCESSIBLE(accessible));
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void on_parent_window_activate_cb ( AtkObject *  parent_window,
NuxAreaAccessible *  self 
) [static]

Definition at line 483 of file nux-area-accessible.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static AtkObject * search_for_parent_window ( AtkObject *  object) [static]

Definition at line 471 of file nux-area-accessible.cpp.

{
  AtkObject* parent = NULL;

  for (parent = atk_object_get_parent(object);
       (parent != NULL) && (atk_object_get_role(parent) != ATK_ROLE_WINDOW);
       parent = atk_object_get_parent(parent));

  return parent;
}

Here is the caller graph for this function: