Updated gtk_xtext_unrealize() to use GTK3 accessors (gtk_widget_get_window(), gtk_widget_set_window(), and gtk_widget_set_realized()) while keeping the GTK2 struct access in the #if !HAVE_GTK3 branch.

Consolidated the GTK3 vs GTK2 branching in gtk_xtext_realize() so GTK3 uses gtk_widget_get_allocation(), gtk_widget_get_parent_window(), and gtk_widget_set_window(), with the existing GTK2 direct struct access preserved under #if !HAVE_GTK3.
This commit is contained in:
2026-01-23 22:00:36 -07:00
parent 00eb2de4c8
commit 0df299acf5

View File

@@ -724,22 +724,26 @@ gtk_xtext_destroy (GtkObject * object)
static void static void
gtk_xtext_unrealize (GtkWidget * widget) gtk_xtext_unrealize (GtkWidget * widget)
{ {
#if HAVE_GTK3
GdkWindow *window = gtk_widget_get_window (widget);
#endif
backend_deinit (GTK_XTEXT (widget)); backend_deinit (GTK_XTEXT (widget));
/* if there are still events in the queue, this'll avoid segfault */ /* if there are still events in the queue, this'll avoid segfault */
#if HAVE_GTK3 #if HAVE_GTK3
{ if (window)
GdkWindow *window = gtk_widget_get_window (widget); gdk_window_set_user_data (window, NULL);
if (window) #else
gdk_window_set_user_data (window, NULL);
}
#endif
#if !HAVE_GTK3
gdk_window_set_user_data (widget->window, NULL); gdk_window_set_user_data (widget->window, NULL);
#endif #endif
if (parent_class->unrealize) if (parent_class->unrealize)
(* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget); (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
#if HAVE_GTK3
gtk_widget_set_window (widget, NULL);
gtk_widget_set_realized (widget, FALSE);
#endif
} }
static void static void
@@ -807,8 +811,7 @@ gtk_xtext_realize (GtkWidget * widget)
gtk_widget_set_realized (widget, TRUE); gtk_widget_set_realized (widget, TRUE);
gtk_widget_get_allocation (widget, &allocation); gtk_widget_get_allocation (widget, &allocation);
parent_window = gtk_widget_get_parent_window (widget); parent_window = gtk_widget_get_parent_window (widget);
#endif #else
#if !HAVE_GTK3
gtk_widget_set_realized (widget, TRUE); gtk_widget_set_realized (widget, TRUE);
allocation = widget->allocation; allocation = widget->allocation;
parent_window = widget->parent->window; parent_window = widget->parent->window;
@@ -841,8 +844,7 @@ gtk_xtext_realize (GtkWidget * widget)
#if HAVE_GTK3 #if HAVE_GTK3
gtk_widget_set_window (widget, window); gtk_widget_set_window (widget, window);
#endif #else
#if !HAVE_GTK3
widget->window = window; widget->window = window;
#endif #endif