[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/pgtk b327788: Make interrupt input optionally work on PGTK
From: |
Po Lu |
Subject: |
feature/pgtk b327788: Make interrupt input optionally work on PGTK |
Date: |
Mon, 29 Nov 2021 20:35:26 -0500 (EST) |
branch: feature/pgtk
commit b3277883f35c5ac9980b4ef05dc99fa8b5ce6792
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>
Make interrupt input optionally work on PGTK
* src/pgtkterm.c (pgtk_delete_terminal): Close display fd if it
exists.
(pgtk_term_init): Set up interrupt handling for display fd if
available.
* src/pgtkterm.h (struct pgtk_display_info): Add `connection'
field.
---
src/pgtkterm.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
src/pgtkterm.h | 2 ++
2 files changed, 55 insertions(+)
diff --git a/src/pgtkterm.c b/src/pgtkterm.c
index d9b2e38..9814358 100644
--- a/src/pgtkterm.c
+++ b/src/pgtkterm.c
@@ -63,6 +63,10 @@ along with GNU Emacs. If not, see
<https://www.gnu.org/licenses/>. */
#include "pgtkselect.h"
#include "emacsgtkfixed.h"
+#ifdef GDK_WINDOWING_WAYLAND
+#include <gdk/gdkwayland.h>
+#endif
+
#define STORE_KEYSYM_FOR_DEBUG(keysym) ((void)0)
#define FRAME_CR_CONTEXT(f) ((f)->output_data.pgtk->cr_context)
@@ -4320,6 +4324,11 @@ pgtk_delete_terminal (struct terminal *terminal)
dpyinfo->gdpy = NULL;
}
+ if (dpyinfo->connection >= 0)
+ emacs_close (dpyinfo->connection);
+
+ dpyinfo->connection = -1;
+
delete_keyboard_wait_descriptor (0);
pgtk_delete_display (dpyinfo);
@@ -6285,6 +6294,7 @@ pgtk_term_init (Lisp_Object display_name, char
*resource_name)
static int x_initialized = 0;
static unsigned x_display_id = 0;
static char *initial_display = NULL;
+ static dynlib_handle_ptr *handle = NULL;
char *dpy_name;
Lisp_Object lisp_dpy_name = Qnil;
@@ -6456,6 +6466,49 @@ pgtk_term_init (Lisp_Object display_name, char
*resource_name)
dpyinfo->scroll.x_per_char = 2;
dpyinfo->scroll.y_per_line = 2;
+ dpyinfo->connection = -1;
+
+ if (!handle)
+ handle = dynlib_open (NULL);
+
+#ifdef GDK_WINDOWING_X11
+ if (!strcmp (G_OBJECT_TYPE_NAME (dpy), "GdkX11Display") && handle)
+ {
+ void *(*gdk_x11_display_get_xdisplay) (GdkDisplay *)
+ = dynlib_sym (handle, "gdk_x11_display_get_xdisplay");
+ int (*x_connection_number) (void *)
+ = dynlib_sym (handle, "XConnectionNumber");
+
+ if (x_connection_number
+ && gdk_x11_display_get_xdisplay)
+ dpyinfo->connection
+ = x_connection_number (gdk_x11_display_get_xdisplay (dpy));
+ }
+#endif
+
+#ifdef GDK_WINDOWING_WAYLAND
+ if (GDK_IS_WAYLAND_DISPLAY (dpy) && handle)
+ {
+ struct wl_display *wl_dpy = gdk_wayland_display_get_wl_display (dpy);
+ int (*display_get_fd) (struct wl_display *)
+ = dynlib_sym (handle, "wl_display_get_fd");
+
+ if (display_get_fd)
+ dpyinfo->connection = display_get_fd (wl_dpy);
+ }
+#endif
+
+ if (dpyinfo->connection >= 0)
+ {
+ add_keyboard_wait_descriptor (dpyinfo->connection);
+#ifdef F_SETOWN
+ fcntl (dpyinfo->connection, F_SETOWN, getpid ());
+#endif /* ! defined (F_SETOWN) */
+
+ if (interrupt_input)
+ init_sigio (dpyinfo->connection);
+ }
+
x_setup_pointer_blanking (dpyinfo);
xsettings_initialize (dpyinfo);
diff --git a/src/pgtkterm.h b/src/pgtkterm.h
index 231c8e8..c16221d 100644
--- a/src/pgtkterm.h
+++ b/src/pgtkterm.h
@@ -238,6 +238,8 @@ struct pgtk_display_info
double acc_x, acc_y;
double x_per_char, y_per_line;
} scroll;
+
+ int connection;
};
/* This is a chain of structures for all the PGTK displays currently in use.
*/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- feature/pgtk b327788: Make interrupt input optionally work on PGTK,
Po Lu <=