[gtk/wip/matthiasc/popup4: 42/110] a11y: Stop supporting ATK_XY_SCREEN



commit 1e2cd59f770253605a85019b2e4a45d69f0efb47
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Mar 23 01:59:47 2019 -0400

    a11y: Stop supporting ATK_XY_SCREEN
    
    We were already not supporting ATK_XY_PARENT, and we can't
    support global positions, so just always do ATK_XY_WINDOW.

 gtk/a11y/gtkentryaccessible.c    | 35 ++++--------------------------
 gtk/a11y/gtklabelaccessible.c    | 36 ++++---------------------------
 gtk/a11y/gtktextaccessible.c     | 35 ++++--------------------------
 gtk/a11y/gtktextcellaccessible.c |  1 -
 gtk/a11y/gtktextviewaccessible.c | 46 +++++-----------------------------------
 gtk/a11y/gtktreeviewaccessible.c | 12 -----------
 gtk/a11y/gtkwidgetaccessible.c   | 23 +++-----------------
 7 files changed, 20 insertions(+), 168 deletions(-)
---
diff --git a/gtk/a11y/gtkentryaccessible.c b/gtk/a11y/gtkentryaccessible.c
index c656efa94a..cd802d2560 100644
--- a/gtk/a11y/gtkentryaccessible.c
+++ b/gtk/a11y/gtkentryaccessible.c
@@ -980,8 +980,6 @@ gtk_entry_accessible_get_character_extents (AtkText      *atk_text,
   PangoRectangle char_rect;
   gchar *entry_text;
   gint index, x_layout, y_layout;
-  GdkSurface *surface;
-  gint x_surface, y_surface;
   GtkAllocation allocation;
 
   textw = get_text (atk_text);
@@ -999,22 +997,10 @@ gtk_entry_accessible_get_character_extents (AtkText      *atk_text,
 
   gtk_widget_get_allocation (GTK_WIDGET (textw), &allocation);
 
-  surface = gtk_widget_get_surface (GTK_WIDGET (textw));
-  gdk_surface_get_origin (surface, &x_surface, &y_surface);
-
-  *x = x_surface + allocation.x + x_layout + char_rect.x;
-  *y = y_surface + allocation.y + y_layout + char_rect.y;
+  *x = allocation.x + x_layout + char_rect.x;
+  *y = allocation.y + y_layout + char_rect.y;
   *width = char_rect.width;
   *height = char_rect.height;
-
-  if (coords == ATK_XY_WINDOW)
-    {
-      surface = gdk_surface_get_toplevel (surface);
-      gdk_surface_get_origin (surface, &x_surface, &y_surface);
-
-      *x -= x_surface;
-      *y -= y_surface;
-    }
 }
 
 static gint
@@ -1026,9 +1012,7 @@ gtk_entry_accessible_get_offset_at_point (AtkText      *atk_text,
   GtkText *textw;
   gchar *text;
   gint index, x_layout, y_layout;
-  gint x_surface, y_surface;
   gint x_local, y_local;
-  GdkSurface *surface;
   glong offset;
 
   textw = get_text (atk_text);
@@ -1038,20 +1022,9 @@ gtk_entry_accessible_get_offset_at_point (AtkText      *atk_text,
 
   gtk_text_get_layout_offsets (textw, &x_layout, &y_layout);
 
-  surface = gtk_widget_get_surface (GTK_WIDGET (textw));
-  gdk_surface_get_origin (surface, &x_surface, &y_surface);
+  x_local = x - x_layout;
+  y_local = y - y_layout;
 
-  x_local = x - x_layout - x_surface;
-  y_local = y - y_layout - y_surface;
-
-  if (coords == ATK_XY_WINDOW)
-    {
-      surface = gdk_surface_get_toplevel (surface);
-      gdk_surface_get_origin (surface, &x_surface, &y_surface);
-
-      x_local += x_surface;
-      y_local += y_surface;
-    }
   if (!pango_layout_xy_to_index (gtk_text_get_layout (textw),
                                  x_local * PANGO_SCALE,
                                  y_local * PANGO_SCALE,
diff --git a/gtk/a11y/gtklabelaccessible.c b/gtk/a11y/gtklabelaccessible.c
index 4c7fbf14f2..da9f83f292 100644
--- a/gtk/a11y/gtklabelaccessible.c
+++ b/gtk/a11y/gtklabelaccessible.c
@@ -999,8 +999,6 @@ gtk_label_accessible_get_character_extents (AtkText      *text,
   PangoRectangle char_rect;
   const gchar *label_text;
   gint index, x_layout, y_layout;
-  GdkSurface *surface;
-  gint x_surface, y_surface;
 
   widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));
   if (widget == NULL)
@@ -1014,22 +1012,10 @@ gtk_label_accessible_get_character_extents (AtkText      *text,
   pango_layout_index_to_pos (gtk_label_get_layout (label), index, &char_rect);
   pango_extents_to_pixels (&char_rect, NULL);
 
-  surface = gtk_widget_get_surface (widget);
-  gdk_surface_get_origin (surface, &x_surface, &y_surface);
-
-  *x = x_surface + x_layout + char_rect.x;
-  *y = y_surface + y_layout + char_rect.y;
+  *x = x_layout + char_rect.x;
+  *y = y_layout + char_rect.y;
   *width = char_rect.width;
   *height = char_rect.height;
-
-  if (coords == ATK_XY_WINDOW)
-    {
-      surface = gdk_surface_get_toplevel (surface);
-      gdk_surface_get_origin (surface, &x_surface, &y_surface);
-
-      *x -= x_surface;
-      *y -= y_surface;
-    }
 }
 
 static gint
@@ -1042,9 +1028,7 @@ gtk_label_accessible_get_offset_at_point (AtkText      *atk_text,
   GtkLabel *label;
   const gchar *text;
   gint index, x_layout, y_layout;
-  gint x_surface, y_surface;
   gint x_local, y_local;
-  GdkSurface *surface;
 
   widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (atk_text));
   if (widget == NULL)
@@ -1054,20 +1038,8 @@ gtk_label_accessible_get_offset_at_point (AtkText      *atk_text,
 
   gtk_label_get_layout_offsets (label, &x_layout, &y_layout);
 
-  surface = gtk_widget_get_surface (widget);
-  gdk_surface_get_origin (surface, &x_surface, &y_surface);
-
-  x_local = x - x_layout - x_surface;
-  y_local = y - y_layout - y_surface;
-
-  if (coords == ATK_XY_WINDOW)
-    {
-      surface = gdk_surface_get_toplevel (surface);
-      gdk_surface_get_origin (surface, &x_surface, &y_surface);
-
-      x_local += x_surface;
-      y_local += y_surface;
-    }
+  x_local = x - x_layout;
+  y_local = y - y_layout;
 
   if (!pango_layout_xy_to_index (gtk_label_get_layout (label),
                                  x_local * PANGO_SCALE,
diff --git a/gtk/a11y/gtktextaccessible.c b/gtk/a11y/gtktextaccessible.c
index 8cea128a64..4792f22900 100644
--- a/gtk/a11y/gtktextaccessible.c
+++ b/gtk/a11y/gtktextaccessible.c
@@ -420,8 +420,6 @@ gtk_text_accessible_get_character_extents (AtkText      *text,
   PangoRectangle char_rect;
   gchar *entry_text;
   gint index, x_layout, y_layout;
-  GdkSurface *surface;
-  gint x_surface, y_surface;
   GtkAllocation allocation;
 
   widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));
@@ -440,22 +438,10 @@ gtk_text_accessible_get_character_extents (AtkText      *text,
 
   gtk_widget_get_allocation (widget, &allocation);
 
-  surface = gtk_widget_get_surface (widget);
-  gdk_surface_get_origin (surface, &x_surface, &y_surface);
-
-  *x = x_surface + allocation.x + x_layout + char_rect.x;
-  *y = y_surface + allocation.y + y_layout + char_rect.y;
+  *x = allocation.x + x_layout + char_rect.x;
+  *y = allocation.y + y_layout + char_rect.y;
   *width = char_rect.width;
   *height = char_rect.height;
-
-  if (coords == ATK_XY_WINDOW)
-    {
-      surface = gdk_surface_get_toplevel (surface);
-      gdk_surface_get_origin (surface, &x_surface, &y_surface);
-
-      *x -= x_surface;
-      *y -= y_surface;
-    }
 }
 
 static gint
@@ -468,9 +454,7 @@ gtk_text_accessible_get_offset_at_point (AtkText      *atk_text,
   GtkText *entry;
   gchar *text;
   gint index, x_layout, y_layout;
-  gint x_surface, y_surface;
   gint x_local, y_local;
-  GdkSurface *surface;
   glong offset;
 
   widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (atk_text));
@@ -481,20 +465,9 @@ gtk_text_accessible_get_offset_at_point (AtkText      *atk_text,
 
   gtk_text_get_layout_offsets (entry, &x_layout, &y_layout);
 
-  surface = gtk_widget_get_surface (widget);
-  gdk_surface_get_origin (surface, &x_surface, &y_surface);
+  x_local = x - x_layout;
+  y_local = y - y_layout;
 
-  x_local = x - x_layout - x_surface;
-  y_local = y - y_layout - y_surface;
-
-  if (coords == ATK_XY_WINDOW)
-    {
-      surface = gdk_surface_get_toplevel (surface);
-      gdk_surface_get_origin (surface, &x_surface, &y_surface);
-
-      x_local += x_surface;
-      y_local += y_surface;
-    }
   if (!pango_layout_xy_to_index (gtk_text_get_layout (entry),
                                  x_local * PANGO_SCALE,
                                  y_local * PANGO_SCALE,
diff --git a/gtk/a11y/gtktextcellaccessible.c b/gtk/a11y/gtktextcellaccessible.c
index 7546f2bb63..c35ba285b5 100644
--- a/gtk/a11y/gtktextcellaccessible.c
+++ b/gtk/a11y/gtktextcellaccessible.c
@@ -489,7 +489,6 @@ get_origins (GtkWidget *widget,
 
   surface = gtk_widget_get_surface (widget);
   gdk_surface_get_origin (surface, x_surface, y_surface);
-  surface = gdk_surface_get_toplevel (gtk_widget_get_surface (widget));
   gdk_surface_get_origin (surface, x_toplevel, y_toplevel);
 
   if (GTK_IS_TREE_VIEW (widget))
diff --git a/gtk/a11y/gtktextviewaccessible.c b/gtk/a11y/gtktextviewaccessible.c
index 52c2514782..67dce5bd0f 100644
--- a/gtk/a11y/gtktextviewaccessible.c
+++ b/gtk/a11y/gtktextviewaccessible.c
@@ -449,35 +449,19 @@ gtk_text_view_accessible_get_offset_at_point (AtkText      *text,
 {
   GtkTextView *view;
   GtkTextIter iter;
-  gint x_widget, y_widget, x_surface, y_surface, buff_x, buff_y;
+  gint buff_x, buff_y;
   GtkWidget *widget;
-  GdkSurface *surface;
   GdkRectangle rect;
 
   widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));
   if (widget == NULL)
     return -1;
 
-  view = GTK_TEXT_VIEW (widget);
-  surface = gtk_widget_get_surface (widget);
-  gdk_surface_get_origin (surface, &x_widget, &y_widget);
-
-  if (coords == ATK_XY_SCREEN)
-    {
-      x = x - x_widget;
-      y = y - y_widget;
-    }
-  else if (coords == ATK_XY_WINDOW)
-    {
-      surface = gdk_surface_get_toplevel (surface);
-      gdk_surface_get_origin (surface, &x_surface, &y_surface);
-
-      x = x - x_widget + x_surface;
-      y = y - y_widget + y_surface;
-    }
-  else
+  if (coords != ATK_XY_WINDOW)
     return -1;
 
+  view = GTK_TEXT_VIEW (widget);
+
   gtk_text_view_window_to_buffer_coords (view, GTK_TEXT_WINDOW_WIDGET,
                                          x, y, &buff_x, &buff_y);
   gtk_text_view_get_visible_rect (view, &rect);
@@ -511,8 +495,6 @@ gtk_text_view_accessible_get_character_extents (AtkText      *text,
   GtkTextIter iter;
   GtkWidget *widget;
   GdkRectangle rectangle;
-  GdkSurface *surface;
-  gint x_widget, y_widget, x_surface, y_surface;
 
   *x = 0;
   *y = 0;
@@ -528,30 +510,12 @@ gtk_text_view_accessible_get_character_extents (AtkText      *text,
   gtk_text_buffer_get_iter_at_offset (buffer, &iter, offset);
   gtk_text_view_get_iter_location (view, &iter, &rectangle);
 
-  surface = gtk_widget_get_surface (widget);
-  if (surface == NULL)
-    return;
-
-  gdk_surface_get_origin (surface, &x_widget, &y_widget);
-
   *height = rectangle.height;
   *width = rectangle.width;
 
   gtk_text_view_buffer_to_surface_coords (view, GTK_TEXT_WINDOW_WIDGET,
     rectangle.x, rectangle.y, x, y);
-  if (coords == ATK_XY_WINDOW)
-    {
-      surface = gdk_surface_get_toplevel (surface);
-      gdk_surface_get_origin (surface, &x_surface, &y_surface);
-      *x += x_widget - x_surface;
-      *y += y_widget - y_surface;
-    }
-  else if (coords == ATK_XY_SCREEN)
-    {
-      *x += x_widget;
-      *y += y_widget;
-    }
-  else
+  if (coords != ATK_XY_WINDOW)
     {
       *x = 0;
       *y = 0;
diff --git a/gtk/a11y/gtktreeviewaccessible.c b/gtk/a11y/gtktreeviewaccessible.c
index 79008638e4..ac17d40860 100644
--- a/gtk/a11y/gtktreeviewaccessible.c
+++ b/gtk/a11y/gtktreeviewaccessible.c
@@ -1094,18 +1094,6 @@ gtk_tree_view_accessible_get_cell_extents (GtkCellAccessibleParent *parent,
                                                      0, 0, 
                                                      &w_x, &w_y);
 
-  if (coord_type != ATK_XY_WINDOW)
-    {
-      GdkSurface *surface;
-      gint x_toplevel, y_toplevel;
-
-      surface = gdk_surface_get_toplevel (gtk_widget_get_surface (widget));
-      gdk_surface_get_origin (surface, &x_toplevel, &y_toplevel);
-
-      w_x += x_toplevel;
-      w_y += y_toplevel;
-    }
-
   *width = cell_rect.width;
   *height = cell_rect.height;
   if (is_cell_showing (tree_view, &cell_rect))
diff --git a/gtk/a11y/gtkwidgetaccessible.c b/gtk/a11y/gtkwidgetaccessible.c
index d2c2471be9..05e1376c6e 100644
--- a/gtk/a11y/gtkwidgetaccessible.c
+++ b/gtk/a11y/gtkwidgetaccessible.c
@@ -533,9 +533,6 @@ gtk_widget_accessible_get_extents (AtkComponent   *component,
                                    gint           *height,
                                    AtkCoordType    coord_type)
 {
-  GdkSurface *surface;
-  gint x_surface, y_surface;
-  gint x_toplevel, y_toplevel;
   GtkWidget *widget;
   GtkAllocation allocation;
 
@@ -557,25 +554,11 @@ gtk_widget_accessible_get_extents (AtkComponent   *component,
     {
       *x = allocation.x;
       *y = allocation.y;
-      surface = gtk_widget_get_parent_surface (widget);
     }
   else
     {
       *x = 0;
       *y = 0;
-      surface = gtk_widget_get_surface (widget);
-    }
-  gdk_surface_get_origin (surface, &x_surface, &y_surface);
-  *x += x_surface;
-  *y += y_surface;
-
-  if (coord_type == ATK_XY_WINDOW)
-    {
-      surface = gdk_surface_get_toplevel (gtk_widget_get_surface (widget));
-      gdk_surface_get_origin (surface, &x_toplevel, &y_toplevel);
-
-      *x -= x_toplevel;
-      *y -= y_toplevel;
     }
 }
 
@@ -625,7 +608,7 @@ gtk_widget_accessible_set_extents (AtkComponent *component,
                                    gint          height,
                                    AtkCoordType  coord_type)
 {
-   return FALSE;
+  return FALSE;
 }
 
 static gboolean
@@ -634,7 +617,7 @@ gtk_widget_accessible_set_position (AtkComponent *component,
                                     gint          y,
                                     AtkCoordType  coord_type)
 {
-   return FALSE;
+  return FALSE;
 }
 
 static gboolean
@@ -642,7 +625,7 @@ gtk_widget_accessible_set_size (AtkComponent *component,
                                 gint          width,
                                 gint          height)
 {
-   return FALSE;
+  return FALSE;
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]