OAPAFUPI-360 Reduce dbus calls on hover
authorŁukasz Buśko <l.busko@samsung.com>
Wed, 21 Jan 2015 08:20:18 +0000 (09:20 +0100)
committerŁukasz Buśko <l.busko@samsung.com>
Wed, 21 Jan 2015 08:20:18 +0000 (09:20 +0100)
Change-Id: I77f48c42b1becc76810b1a5b8a6bfaa88434b026

src/navigator.c

index c42a75b..b6556dc 100644 (file)
      error = NULL;\
    }
 
+typedef struct
+{
+  int x,y;
+} last_focus_t;
+
+static last_focus_t last_focus = {-1,-1};
 static AtspiAccessible *current_obj;
 static AtspiAccessible *top_window;
 static AtspiScrollable *scrolled_obj;
@@ -53,7 +59,11 @@ _current_highlight_object_set(AtspiAccessible *obj)
          AtspiComponent *comp = atspi_accessible_get_component(obj);
          if (!comp)
            {
-             ERROR("AtspiComponent *comp NULL");
+             GError *err = NULL;
+             gchar *role = atspi_accessible_get_role_name(obj, &err);
+             ERROR("AtspiComponent *comp NULL, [%s]", role);
+             GERROR_CHECK(err);
+             g_free(role);
              return;
            }
          atspi_component_grab_highlight(comp, &err);
@@ -264,14 +274,20 @@ static void _focus_widget(Gesture_Info *info)
     window_component = atspi_accessible_get_component(top_window);
     if(!window_component)
         return;
+    if ((last_focus.x == info->x_begin) && (last_focus.y == info->y_begin))
+      return;
 
     target_widget = atspi_component_get_accessible_at_point(window_component, info->x_begin, info->y_begin, ATSPI_COORD_TYPE_WINDOW, &err);
     GERROR_CHECK(err)
     if (target_widget) {
          if (flat_navi_context_current_set(context, target_widget))
-           _current_highlight_object_set(target_widget);
+           {
+             _current_highlight_object_set(target_widget);
+             last_focus.x = info->x_begin;
+             last_focus.y = info->y_begin;
+           }
          else
-           ERROR("Hoveed object not found in window context");
+           ERROR("Hoveed object not found in window context[%dx%d][%s]", info->x_begin, info->y_begin, atspi_accessible_get_role_name(top_window, &err));
     }
     else
       DEBUG("NO widget under (%d, %d) found",