mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-03-10 07:50:19 +00:00
Added a GTK3-specific branch in gtk_xtext_unrealize() that clears user data via gtk_widget_get_window() while preserving the GTK2 struct access under #if !HAVE_GTK3.
Updated gtk_xtext_realize() to use gtk_widget_get_allocation(), gtk_widget_get_parent_window(), and gtk_widget_set_window() on GTK3, and routed all subsequent window usage through the local window variable instead of direct struct access; the GTK2 path remains intact under #if !HAVE_GTK3. Adjusted gtk_xtext_clear_background() to use gtk_widget_get_window() on GTK3 rather than widget->window.
This commit is contained in:
@@ -727,7 +727,15 @@ gtk_xtext_unrealize (GtkWidget * widget)
|
|||||||
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
|
||||||
|
{
|
||||||
|
GdkWindow *window = gtk_widget_get_window (widget);
|
||||||
|
if (window)
|
||||||
|
gdk_window_set_user_data (window, NULL);
|
||||||
|
}
|
||||||
|
#else
|
||||||
gdk_window_set_user_data (widget->window, NULL);
|
gdk_window_set_user_data (widget->window, NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (parent_class->unrealize)
|
if (parent_class->unrealize)
|
||||||
(* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
|
(* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
|
||||||
@@ -776,7 +784,9 @@ gtk_xtext_clear_background (GtkWidget *widget)
|
|||||||
#if !HAVE_GTK3
|
#if !HAVE_GTK3
|
||||||
gdk_window_set_back_pixmap (widget->window, NULL, FALSE);
|
gdk_window_set_back_pixmap (widget->window, NULL, FALSE);
|
||||||
#else
|
#else
|
||||||
gdk_window_set_background_pattern (widget->window, NULL);
|
GdkWindow *window = gtk_widget_get_window (widget);
|
||||||
|
if (window)
|
||||||
|
gdk_window_set_background_pattern (window, NULL);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -785,30 +795,56 @@ gtk_xtext_realize (GtkWidget * widget)
|
|||||||
{
|
{
|
||||||
GtkXText *xtext;
|
GtkXText *xtext;
|
||||||
GdkWindowAttr attributes;
|
GdkWindowAttr attributes;
|
||||||
|
GdkWindow *window;
|
||||||
|
GtkAllocation allocation;
|
||||||
|
GdkWindow *parent_window;
|
||||||
|
gint attributes_mask;
|
||||||
|
|
||||||
gtk_widget_set_realized (widget, TRUE);
|
gtk_widget_set_realized (widget, TRUE);
|
||||||
xtext = GTK_XTEXT (widget);
|
xtext = GTK_XTEXT (widget);
|
||||||
|
|
||||||
attributes.x = widget->allocation.x;
|
#if HAVE_GTK3
|
||||||
attributes.y = widget->allocation.y;
|
gtk_widget_get_allocation (widget, &allocation);
|
||||||
attributes.width = widget->allocation.width;
|
parent_window = gtk_widget_get_parent_window (widget);
|
||||||
attributes.height = widget->allocation.height;
|
#else
|
||||||
|
allocation = widget->allocation;
|
||||||
|
parent_window = widget->parent->window;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
attributes.x = allocation.x;
|
||||||
|
attributes.y = allocation.y;
|
||||||
|
attributes.width = allocation.width;
|
||||||
|
attributes.height = allocation.height;
|
||||||
attributes.wclass = GDK_INPUT_OUTPUT;
|
attributes.wclass = GDK_INPUT_OUTPUT;
|
||||||
attributes.window_type = GDK_WINDOW_CHILD;
|
attributes.window_type = GDK_WINDOW_CHILD;
|
||||||
attributes.event_mask = gtk_widget_get_events (widget) |
|
attributes.event_mask = gtk_widget_get_events (widget) |
|
||||||
GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
|
GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
|
||||||
| GDK_POINTER_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK;
|
| GDK_POINTER_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK;
|
||||||
|
|
||||||
|
#if !HAVE_GTK3
|
||||||
attributes.colormap = gtk_widget_get_colormap (widget);
|
attributes.colormap = gtk_widget_get_colormap (widget);
|
||||||
attributes.visual = gtk_widget_get_visual (widget);
|
attributes.visual = gtk_widget_get_visual (widget);
|
||||||
|
#else
|
||||||
|
attributes.visual = gtk_widget_get_visual (widget);
|
||||||
|
#endif
|
||||||
|
|
||||||
widget->window = gdk_window_new (widget->parent->window, &attributes,
|
#if HAVE_GTK3
|
||||||
GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL |
|
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
|
||||||
GDK_WA_COLORMAP);
|
#else
|
||||||
|
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
|
||||||
|
#endif
|
||||||
|
|
||||||
gdk_window_set_user_data (widget->window, widget);
|
window = gdk_window_new (parent_window, &attributes, attributes_mask);
|
||||||
|
|
||||||
xtext->depth = gdk_window_get_visual (widget->window)->depth;
|
#if HAVE_GTK3
|
||||||
|
gtk_widget_set_window (widget, window);
|
||||||
|
#else
|
||||||
|
widget->window = window;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
gdk_window_set_user_data (window, widget);
|
||||||
|
|
||||||
|
xtext->depth = gdk_window_get_visual (window)->depth;
|
||||||
|
|
||||||
/* for the separator bar (light) */
|
/* for the separator bar (light) */
|
||||||
xtext->light_gc.red = 1.0;
|
xtext->light_gc.red = 1.0;
|
||||||
@@ -835,15 +871,15 @@ gtk_xtext_realize (GtkWidget * widget)
|
|||||||
xtext_set_bg (xtext, XTEXT_BG);
|
xtext_set_bg (xtext, XTEXT_BG);
|
||||||
|
|
||||||
/* draw directly to window */
|
/* draw directly to window */
|
||||||
xtext->draw_window = widget->window;
|
xtext->draw_window = window;
|
||||||
|
|
||||||
if (xtext->background_surface)
|
if (xtext->background_surface)
|
||||||
{
|
{
|
||||||
xtext->ts_x = xtext->ts_y = 0;
|
xtext->ts_x = xtext->ts_y = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
xtext->hand_cursor = gdk_cursor_new_for_display (gdk_window_get_display (widget->window), GDK_HAND1);
|
xtext->hand_cursor = gdk_cursor_new_for_display (gdk_window_get_display (window), GDK_HAND1);
|
||||||
xtext->resize_cursor = gdk_cursor_new_for_display (gdk_window_get_display (widget->window), GDK_LEFT_SIDE);
|
xtext->resize_cursor = gdk_cursor_new_for_display (gdk_window_get_display (window), GDK_LEFT_SIDE);
|
||||||
|
|
||||||
gtk_xtext_clear_background (widget);
|
gtk_xtext_clear_background (widget);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user