unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Po Lu via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 51707@debbugs.gnu.org
Subject: bug#51707: 29.0.50; [PATCH] Fix a crash on X when trying to show a tiny xwidget inside a tiny window
Date: Tue, 09 Nov 2021 15:38:51 +0800	[thread overview]
Message-ID: <87lf1x93sk.fsf@yahoo.com> (raw)
In-Reply-To: 87lf1x93sk.fsf.ref@yahoo.com

[-- Attachment #1: Type: text/plain, Size: 9 bytes --]

Thanks.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Prevent-BadValue-errors-when-creating-tiny-xwidget-v.patch --]
[-- Type: text/x-patch, Size: 1646 bytes --]

From da3b274bb17c7283bc73fefc4bc38803ef895523 Mon Sep 17 00:00:00 2001
From: Po Lu <luangruo@yahoo.com>
Date: Tue, 9 Nov 2021 15:37:01 +0800
Subject: [PATCH] Prevent BadValue errors when creating tiny xwidget views

* src/xwidget.c (x_draw_glph_string): Avoid resizing xwidget views
to an invalid size.
---
 src/xwidget.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/src/xwidget.c b/src/xwidget.c
index d3a8d5eb82..fc76ce307e 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);
-- 
2.31.1


       reply	other threads:[~2021-11-09  7:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87lf1x93sk.fsf.ref@yahoo.com>
2021-11-09  7:38 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2021-11-09 23:52   ` bug#51707: 29.0.50; [PATCH] Fix a crash on X when trying to show a tiny xwidget inside a tiny window Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lf1x93sk.fsf@yahoo.com \
    --to=bug-gnu-emacs@gnu.org \
    --cc=51707@debbugs.gnu.org \
    --cc=luangruo@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).