1 Commits

Author SHA1 Message Date
6d65871c4d Fix xtext resize paint clipping 2026-05-11 13:32:11 -06:00

View File

@@ -1283,13 +1283,25 @@ gtk_xtext_get_preferred_height_for_width (GtkWidget *widget, gint width,
*natural = requisition.height; *natural = requisition.height;
} }
static void
gtk_xtext_invalidate_resize (GtkXText *xtext, xtext_buffer *buf)
{
buf->pagetop_ent = NULL;
dontscroll (buf);
xtext->force_render = TRUE;
}
static void static void
gtk_xtext_size_allocate (GtkWidget * widget, GtkAllocation * allocation) gtk_xtext_size_allocate (GtkWidget * widget, GtkAllocation * allocation)
{ {
GtkXText *xtext = GTK_XTEXT (widget); GtkXText *xtext = GTK_XTEXT (widget);
int height_only = FALSE; int height_only = FALSE;
gboolean resized;
GdkWindow *window; GdkWindow *window;
resized = allocation->width != xtext->buffer->window_width ||
allocation->height != xtext->buffer->window_height;
if (allocation->width == xtext->buffer->window_width) if (allocation->width == xtext->buffer->window_width)
height_only = TRUE; height_only = TRUE;
@@ -1315,6 +1327,11 @@ gtk_xtext_size_allocate (GtkWidget * widget, GtkAllocation * allocation)
xtext_adj_set_value (xtext->adj, xtext_adj_set_value (xtext->adj,
xtext_adj_get_upper (xtext->adj) - xtext_adj_get_upper (xtext->adj) -
xtext_adj_get_page_size (xtext->adj)); xtext_adj_get_page_size (xtext->adj));
if (resized)
{
gtk_xtext_invalidate_resize (xtext, xtext->buffer);
gtk_widget_queue_draw (widget);
}
} }
} }
@@ -1587,6 +1604,17 @@ gtk_xtext_render (GtkWidget *widget, GdkRectangle *area, cairo_t *cr)
gtk_widget_get_allocation (widget, &allocation); gtk_widget_get_allocation (widget, &allocation);
if (xtext->force_render && area->x == 0 && area->y == 0 &&
area->height == allocation.height &&
area->width == allocation.width)
{
xtext->force_render = FALSE;
}
else if (xtext->force_render)
{
gtk_widget_queue_draw (widget);
}
if (area->x == 0 && area->y == 0 && if (area->x == 0 && area->y == 0 &&
area->height == allocation.height && area->height == allocation.height &&
area->width == allocation.width) area->width == allocation.width)
@@ -4302,13 +4330,9 @@ gtk_xtext_calc_lines (xtext_buffer *buf, int fire_signal)
int width; int width;
int height; int height;
int lines; int lines;
GdkWindow *window;
window = gtk_widget_get_window (GTK_WIDGET (buf->xtext)); height = buf->window_height;
if (!window) width = buf->window_width;
return;
height = gdk_window_get_height (window);
width = gdk_window_get_width (window);
width -= MARGIN; width -= MARGIN;
if (width < 30 || height < buf->xtext->fontsize || width < buf->indent + 30) if (width < 30 || height < buf->xtext->fontsize || width < buf->indent + 30)
@@ -4520,6 +4544,7 @@ gtk_xtext_render_page (GtkXText * xtext)
int startline = adj_value; int startline = adj_value;
int pos, overlap; int pos, overlap;
GdkWindow *window; GdkWindow *window;
GtkAllocation allocation;
if(!gtk_widget_get_realized(GTK_WIDGET(xtext))) if(!gtk_widget_get_realized(GTK_WIDGET(xtext)))
return; return;
@@ -4530,8 +4555,9 @@ gtk_xtext_render_page (GtkXText * xtext)
window = gtk_widget_get_window (GTK_WIDGET (xtext)); window = gtk_widget_get_window (GTK_WIDGET (xtext));
if (!window) if (!window)
return; return;
width = gdk_window_get_width (window); gtk_widget_get_allocation (GTK_WIDGET (xtext), &allocation);
height = gdk_window_get_height (window); width = allocation.width;
height = allocation.height;
if (width < 34 || height < xtext->fontsize || width < xtext->buffer->indent + 32) if (width < 34 || height < xtext->fontsize || width < xtext->buffer->indent + 32)
return; return;
@@ -5742,6 +5768,7 @@ gtk_xtext_buffer_show (GtkXText *xtext, xtext_buffer *buf, int render)
{ {
int w, h; int w, h;
GdkWindow *window; GdkWindow *window;
GtkAllocation allocation;
buf->xtext = xtext; buf->xtext = xtext;
@@ -5768,8 +5795,9 @@ gtk_xtext_buffer_show (GtkXText *xtext, xtext_buffer *buf, int render)
window = gtk_widget_get_window (GTK_WIDGET (xtext)); window = gtk_widget_get_window (GTK_WIDGET (xtext));
if (!window) if (!window)
return; return;
h = gdk_window_get_height (window); gtk_widget_get_allocation (GTK_WIDGET (xtext), &allocation);
w = gdk_window_get_width (window); h = allocation.height;
w = allocation.width;
/* after a font change */ /* after a font change */
if (buf->needs_recalc) if (buf->needs_recalc)
@@ -5807,6 +5835,10 @@ gtk_xtext_buffer_show (GtkXText *xtext, xtext_buffer *buf, int render)
if (render) if (render)
{ {
gboolean resized;
resized = buf->window_width != w || buf->window_height != h;
/* did the window change size since this buffer was last shown? */ /* did the window change size since this buffer was last shown? */
if (buf->window_width != w) if (buf->window_width != w)
{ {
@@ -5827,6 +5859,9 @@ gtk_xtext_buffer_show (GtkXText *xtext, xtext_buffer *buf, int render)
gtk_xtext_adjustment_set (buf, FALSE); gtk_xtext_adjustment_set (buf, FALSE);
} }
if (resized)
gtk_xtext_invalidate_resize (xtext, buf);
gtk_xtext_render_page (xtext); gtk_xtext_render_page (xtext);
{ {
GtkAllocation allocation; GtkAllocation allocation;