Be robust against unrealized windows in GtkWindowAccessible

Based on a patch by Albert Astals Cid,
https://bugzilla.gnome.org/show_bug.cgi?id=686152
This commit is contained in:
Matthias Clasen 2012-10-22 19:42:41 -04:00
parent c51157d437
commit bec6b260b4

View File

@ -262,7 +262,7 @@ gtk_window_accessible_ref_state_set (AtkObject *accessible)
atk_state_set_add_state (state_set, ATK_STATE_ACTIVE);
gdk_window = gtk_widget_get_window (widget);
if (window)
if (gdk_window)
{
state = gdk_window_get_state (gdk_window);
if (state & GDK_WINDOW_STATE_ICONIFIED)
@ -307,6 +307,7 @@ gtk_window_accessible_get_extents (AtkComponent *component,
AtkCoordType coord_type)
{
GtkWidget *widget;
GdkWindow *window;
GdkRectangle rect;
gint x_toplevel, y_toplevel;
@ -323,7 +324,11 @@ gtk_window_accessible_get_extents (AtkComponent *component,
return;
}
gdk_window_get_frame_extents (gtk_widget_get_window (widget), &rect);
window = gtk_widget_get_window (widget);
if (window == NULL)
return;
gdk_window_get_frame_extents (window, &rect);
*width = rect.width;
*height = rect.height;
@ -338,8 +343,7 @@ gtk_window_accessible_get_extents (AtkComponent *component,
*y = rect.y;
if (coord_type == ATK_XY_WINDOW)
{
gdk_window_get_origin (gtk_widget_get_window (widget),
&x_toplevel, &y_toplevel);
gdk_window_get_origin (window, &x_toplevel, &y_toplevel);
*x -= x_toplevel;
*y -= y_toplevel;
}
@ -351,6 +355,7 @@ gtk_window_accessible_get_size (AtkComponent *component,
gint *height)
{
GtkWidget *widget;
GdkWindow *window;
GdkRectangle rect;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (component));
@ -366,7 +371,11 @@ gtk_window_accessible_get_size (AtkComponent *component,
return;
}
gdk_window_get_frame_extents (gtk_widget_get_window (widget), &rect);
window = gtk_widget_get_window (widget);
if (window == NULL)
return;
gdk_window_get_frame_extents (window, &rect);
*width = rect.width;
*height = rect.height;