commit 6fce79c9f804f918759b5fb07d2b55e954263e4e
parent c843680815755e9d5211fdaa10e1f2c7626c6dda
Author: Jonathan Boeing <jonathan.n.boeing@gmail.com>
Date: Mon, 19 Jul 2021 14:21:07 -0700
Fix flickering when opening with LiteHTML viewer
Restrict painting to the allocation size of the drawing area, otherwise
we draw over other parts of the interface.
Calling paint_white from redraw isn't needed and causes flickering.
Calling redraw from open_html causes the old message to be redisplayed
after clearing it, before drawing the new message.
Diffstat:
1 file changed, 8 insertions(+), 14 deletions(-)
diff --git a/src/plugins/litehtml_viewer/lh_widget.cpp b/src/plugins/litehtml_viewer/lh_widget.cpp
@@ -193,7 +193,6 @@ void lh_widget::open_html(const gchar *contents)
adj = gtk_scrolled_window_get_vadjustment(
GTK_SCROLLED_WINDOW(m_scrolled_window));
gtk_adjustment_set_value(adj, 0.0);
- redraw(false);
}
lh_widget_statusbar_pop();
}
@@ -229,15 +228,13 @@ void lh_widget::redraw(gboolean force_render)
cairo_region_t *creg;
GdkDrawingContext *gdkctx;
- paint_white();
-
if (m_html == NULL)
return;
/* Get width of the viewport. */
- gdkwin = gtk_viewport_get_view_window(GTK_VIEWPORT(m_viewport));
- width = gdk_window_get_width(gdkwin);
- m_height = gdk_window_get_height(gdkwin);
+ gtk_widget_get_allocation(GTK_WIDGET(m_viewport), &rect);
+ width = rect.width;
+ m_height = rect.height;
/* If the available width has changed, rerender the HTML content. */
if (m_rendered_width != width || force_render) {
@@ -268,7 +265,7 @@ void lh_widget::redraw(gboolean force_render)
g_warning("lh_widget::redraw: No GdkWindow to draw on!");
return;
}
- creg = gdk_window_get_clip_region(gdkwin);
+ creg = cairo_region_create_rectangle(&rect);
gdkctx = gdk_window_begin_draw_frame(gdkwin, creg);
cr = gdk_drawing_context_get_cairo_context(gdkctx);
}
@@ -288,23 +285,20 @@ void lh_widget::paint_white()
cairo_region_t *creg;
cairo_t *cr;
GdkDrawingContext *gdkctx;
+ GtkAllocation rect;
if (gdkwin == NULL) {
g_warning("lh_widget::clear: No GdkWindow to draw on!");
return;
}
- creg = gdk_window_get_clip_region(gdkwin);
+ gtk_widget_get_allocation(GTK_WIDGET(m_viewport), &rect);
+ creg = cairo_region_create_rectangle(&rect);
gdkctx = gdk_window_begin_draw_frame(gdkwin, creg);
cr = gdk_drawing_context_get_cairo_context(gdkctx);
/* Paint white background. */
- gint width, height;
- width = gdk_window_get_width(gdkwin);
- height = gdk_window_get_height(gdkwin);
- cairo_rectangle(cr, 0, 0,
- gdk_window_get_width(gdkwin),
- gdk_window_get_height(gdkwin));
+ cairo_rectangle(cr, rect.x, rect.y, rect.width, rect.height);
cairo_set_source_rgb(cr, 255, 255, 255);
cairo_fill(cr);