From: Po Lu via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 51473@debbugs.gnu.org
Subject: bug#51473: [PATCH] Enable xwidget scrolling optimizations, and other xwidgets improvements
Date: Fri, 29 Oct 2021 21:18:14 +0800 [thread overview]
Message-ID: <87mtmskm09.fsf@yahoo.com> (raw)
In-Reply-To: <87zgqslafe.fsf@yahoo.com> (Po Lu's message of "Fri, 29 Oct 2021 12:30:45 +0800")
[-- Attachment #1: Type: text/plain, Size: 849 bytes --]
Po Lu <luangruo@yahoo.com> writes:
> The attached changes fix flickering xwidgets by moving xwidget display
> into a separate X window, and also enable the scrolling optimization for
> xwidgets.
>
> Someone with access to a Mac will have to do the changes necessary for
> xwidget scrolling to work correctly on macOS, as they don't work on
> GNUstep in the first place.
>
> However, event passthrough doesn't work yet, and will require some
> thought. But that would be a fantastic opportunity to clean up the
> current xwidget event handling mess (and perhaps even define a mechanism
> for Lisp code to send events into xwidgets, which would make integrating
> them into the existing Emacs event model much easier.) Any thoughts?
>
> Thanks.
And I missed something, you will also need the following patch for
everything to function correctly:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0003-Destroy-xwidgets-when-destroying-frames.patch --]
[-- Type: text/x-patch, Size: 4692 bytes --]
From b490315aad58c704589fbb753de3238ce0d08819 Mon Sep 17 00:00:00 2001
From: Po Lu <luangruo@yahoo.com>
Date: Fri, 29 Oct 2021 19:26:49 +0800
Subject: [PATCH 3/3] Destroy xwidgets when destroying frames
* src/xterm.c (x_free_frame_resources): Make sure to kill xwidget views.
* src/xwidget.c (Fmake_xwidget): Attach damage event signal.
(offscreen_damage_event): Operate on xwidgets and not individual
views.
(xwidget_init_view): Don't attach damage event signal here.
(Fdelete_xwidget_view): Destroy window correctly and stop removing
damage event signal.
(kill_frame_xwidget_views): New function.
* src/xwidget.c (kill_frame_xwidget_views): New function.
---
src/xterm.c | 4 ++++
src/xwidget.c | 52 +++++++++++++++++++++++++++++++++++----------------
src/xwidget.h | 1 +
3 files changed, 41 insertions(+), 16 deletions(-)
diff --git a/src/xterm.c b/src/xterm.c
index b12c15cb7a..3e8cfb8b29 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -12210,6 +12210,10 @@ x_free_frame_resources (struct frame *f)
xfree (f->shell_position);
#else /* !USE_X_TOOLKIT */
+#ifdef HAVE_XWIDGETS
+ kill_frame_xwidget_views (f);
+#endif
+
#ifdef USE_GTK
xg_free_frame_widgets (f);
#endif /* USE_GTK */
diff --git a/src/xwidget.c b/src/xwidget.c
index 68188eba08..fe6640171c 100644
--- a/src/xwidget.c
+++ b/src/xwidget.c
@@ -46,6 +46,7 @@ Copyright (C) 2011-2021 Free Software Foundation, Inc.
#ifdef USE_GTK
static Lisp_Object x_window_to_xwv_map;
+static gboolean offscreen_damage_event (GtkWidget *, GdkEvent *, gpointer);
#endif
static struct xwidget *
@@ -193,6 +194,9 @@ DEFUN ("make-xwidget",
xw);
}
+ g_signal_connect (G_OBJECT (xw->widgetwindow_osr), "damage-event",
+ G_CALLBACK (offscreen_damage_event), xw);
+
unblock_input ();
}
#elif defined NS_IMPL_COCOA
@@ -297,15 +301,20 @@ xv_do_draw (struct xwidget_view *xw, struct xwidget *w)
It copies the bitmap from the off-screen instance. */
static gboolean
offscreen_damage_event (GtkWidget *widget, GdkEvent *event,
- gpointer xwidget_view)
+ gpointer xwidget)
{
- struct xwidget_view *xw = xwidget_view;
- struct xwidget *w = XXWIDGET (xw->model);
+ block_input ();
- if (xw->wdesc == None)
- return FALSE;
+ for (Lisp_Object tail = Vxwidget_view_list; CONSP (tail);
+ tail = XCDR (tail))
+ {
+ struct xwidget_view *view = XXWIDGET_VIEW (XCAR (tail));
+
+ if (view->wdesc && XXWIDGET (view->model) == xwidget)
+ xv_do_draw (view, XXWIDGET (view->model));
+ }
- xv_do_draw (xw, w);
+ unblock_input ();
return FALSE;
}
@@ -592,9 +601,6 @@ xwidget_init_view (struct xwidget *xww,
xv->wdesc = None;
xv->frame = s->f;
-
- g_signal_connect (G_OBJECT (xww->widgetwindow_osr), "damage-event",
- G_CALLBACK (offscreen_damage_event), xv);
#elif defined NS_IMPL_COCOA
nsxwidget_init_view (xv, xww, s, x, y);
nsxwidget_resize_view(xv, xww->width, xww->height);
@@ -1102,15 +1108,9 @@ DEFUN ("delete-xwidget-view",
if (xv->wdesc != None)
{
block_input ();
- XDestroyWindow (xv->dpy, xv->wdesc);
- /* xv->model still has signals pointing to the view. There can be
- several views. Find the matching signals and delete them all. */
- g_signal_handlers_disconnect_matched (XXWIDGET (xv->model)->widgetwindow_osr,
- G_SIGNAL_MATCH_DATA,
- 0, 0, 0, 0, xv);
-
cairo_destroy (xv->cr_context);
cairo_surface_destroy (xv->cr_surface);
+ XDestroyWindow (xv->dpy, xv->wdesc);
Fremhash (make_fixnum (xv->wdesc), x_window_to_xwv_map);
unblock_input ();
}
@@ -1456,6 +1456,26 @@ xwidget_end_redisplay (struct window *w, struct glyph_matrix *matrix)
}
}
+#ifdef USE_GTK
+void
+kill_frame_xwidget_views (struct frame *f)
+{
+ Lisp_Object rem = Qnil;
+
+ for (Lisp_Object tail = Vxwidget_view_list; CONSP (tail);
+ tail = XCDR (tail))
+ {
+ if (XXWIDGET_VIEW (XCAR (tail))->frame == f)
+ rem = Fcons (XCAR (tail), rem);
+ }
+
+ for (; CONSP (rem); rem = XCDR (rem))
+ {
+ Fdelete_xwidget_view (XCAR (rem));
+ }
+}
+#endif
+
/* Kill all xwidget in BUFFER. */
void
kill_buffer_xwidgets (Lisp_Object buffer)
diff --git a/src/xwidget.h b/src/xwidget.h
index 28098c0b09..f51921dbef 100644
--- a/src/xwidget.h
+++ b/src/xwidget.h
@@ -171,6 +171,7 @@ #define XG_XWIDGET_VIEW "emacs_xwidget_view"
void xwidget_expose (struct xwidget_view *xv);
extern struct xwidget *xwidget_from_id (uint32_t id);
+extern void kill_frame_xwidget_views (struct frame *f);
#else
INLINE_HEADER_BEGIN
INLINE void syms_of_xwidget (void) {}
--
2.31.1
next prev parent reply other threads:[~2021-10-29 13:18 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <87zgqslafe.fsf.ref@yahoo.com>
2021-10-29 4:30 ` bug#51473: [PATCH] Enable xwidget scrolling optimizations, and other xwidgets improvements Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-10-29 13:18 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2021-11-04 23:11 ` Lars Ingebrigtsen
2021-11-05 7:20 ` Eli Zaretskii
2021-11-05 7:29 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-05 7:33 ` Lars Ingebrigtsen
2021-11-05 7:47 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-05 13:35 ` Lars Ingebrigtsen
2021-11-05 7:34 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-05 13:10 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-05 13:32 ` Lars Ingebrigtsen
2021-11-05 13:28 ` Lars Ingebrigtsen
2021-11-05 13:40 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-05 13:48 ` Lars Ingebrigtsen
2021-11-06 0:00 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-06 0:22 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-06 0:25 ` Lars Ingebrigtsen
2021-11-06 2:06 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-06 5:39 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-06 8:58 ` Eli Zaretskii
2021-11-06 10:41 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-06 17:42 ` Lars Ingebrigtsen
2021-11-07 0:41 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-07 0:55 ` Lars Ingebrigtsen
2021-11-07 1:16 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-07 1:04 ` Lars Ingebrigtsen
2021-11-07 1:18 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-07 1:23 ` Lars Ingebrigtsen
2021-11-07 1:26 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-07 1:29 ` Lars Ingebrigtsen
2021-11-07 1:34 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-07 1:39 ` Lars Ingebrigtsen
2021-11-07 1:55 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-07 2:04 ` Lars Ingebrigtsen
2021-11-07 10:09 ` Eli Zaretskii
2021-11-07 12:03 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-07 12:33 ` Eli Zaretskii
2021-11-07 12:40 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-07 12:52 ` Eli Zaretskii
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=87mtmskm09.fsf@yahoo.com \
--to=bug-gnu-emacs@gnu.org \
--cc=51473@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).