summaryrefslogtreecommitdiff
path: root/src/xwidget.c
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2021-11-10 00:52:47 +0100
committerLars Ingebrigtsen <larsi@gnus.org>2021-11-10 00:52:47 +0100
commit912ae5de928a5042a8ac77b80d743a6d8f7ed1e8 (patch)
treedece3bfaeee99cd00368401b245daa671d70c4aa /src/xwidget.c
parent2e6ed253ce485698df649904bd9e5254a3f4bf94 (diff)
downloademacs-912ae5de928a5042a8ac77b80d743a6d8f7ed1e8.tar.gz
Prevent BadValue errors when creating tiny xwidget views
* src/xwidget.c (x_draw_glph_string): Avoid resizing xwidget views to an invalid size (bug#51707).
Diffstat (limited to 'src/xwidget.c')
-rw-r--r--src/xwidget.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/xwidget.c b/src/xwidget.c
index d3a8d5eb82b..fc76ce307e5 100644
--- a/src/xwidget.c
+++ b/src/xwidget.c
@@ -1439,6 +1439,13 @@ x_draw_xwidget_glyph_string (struct glyph_string *s)
a.event_mask = (ExposureMask | ButtonPressMask | ButtonReleaseMask
| PointerMotionMask | EnterWindowMask | LeaveWindowMask);
+ if (clip_right - clip_left <= 0
+ || clip_bottom - clip_top <= 0)
+ {
+ unblock_input ();
+ return;
+ }
+
xv->wdesc = XCreateWindow (xv->dpy, FRAME_X_WINDOW (s->f),
x + clip_left, y + clip_top,
clip_right - clip_left,
@@ -1484,8 +1491,17 @@ x_draw_xwidget_glyph_string (struct glyph_string *s)
#ifdef USE_GTK
if (!wdesc_was_none && !moved)
{
- XResizeWindow (xv->dpy, xv->wdesc, clip_right - clip_left,
- clip_bottom - clip_top);
+ if (clip_right - clip_left <= 0
+ || clip_bottom - clip_top <= 0)
+ {
+ XUnmapWindow (xv->dpy, xv->wdesc);
+ xv->hidden = true;
+ }
+ else
+ {
+ XResizeWindow (xv->dpy, xv->wdesc, clip_right - clip_left,
+ clip_bottom - clip_top);
+ }
XFlush (xv->dpy);
cairo_xlib_surface_set_size (xv->cr_surface, clip_right - clip_left,
clip_bottom - clip_top);