aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2021-11-30 09:34:24 +0800
committerPo Lu2021-11-30 09:34:24 +0800
commitb3277883f35c5ac9980b4ef05dc99fa8b5ce6792 (patch)
tree17994378afbe7b14ccb49cfd2cebadf7f173b9a6 /src
parentd15dafeefb58fc521186385a1a703f7f660f2f6b (diff)
downloademacs-b3277883f35c5ac9980b4ef05dc99fa8b5ce6792.tar.gz
emacs-b3277883f35c5ac9980b4ef05dc99fa8b5ce6792.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/pgtkterm.c53
-rw-r--r--src/pgtkterm.h2
2 files changed, 55 insertions, 0 deletions
diff --git a/src/pgtkterm.c b/src/pgtkterm.c
index d9b2e385fc5..98143585cf9 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/>. */
63#include "pgtkselect.h" 63#include "pgtkselect.h"
64#include "emacsgtkfixed.h" 64#include "emacsgtkfixed.h"
65 65
66#ifdef GDK_WINDOWING_WAYLAND
67#include <gdk/gdkwayland.h>
68#endif
69
66#define STORE_KEYSYM_FOR_DEBUG(keysym) ((void)0) 70#define STORE_KEYSYM_FOR_DEBUG(keysym) ((void)0)
67 71
68#define FRAME_CR_CONTEXT(f) ((f)->output_data.pgtk->cr_context) 72#define FRAME_CR_CONTEXT(f) ((f)->output_data.pgtk->cr_context)
@@ -4320,6 +4324,11 @@ pgtk_delete_terminal (struct terminal *terminal)
4320 dpyinfo->gdpy = NULL; 4324 dpyinfo->gdpy = NULL;
4321 } 4325 }
4322 4326
4327 if (dpyinfo->connection >= 0)
4328 emacs_close (dpyinfo->connection);
4329
4330 dpyinfo->connection = -1;
4331
4323 delete_keyboard_wait_descriptor (0); 4332 delete_keyboard_wait_descriptor (0);
4324 4333
4325 pgtk_delete_display (dpyinfo); 4334 pgtk_delete_display (dpyinfo);
@@ -6285,6 +6294,7 @@ pgtk_term_init (Lisp_Object display_name, char *resource_name)
6285 static int x_initialized = 0; 6294 static int x_initialized = 0;
6286 static unsigned x_display_id = 0; 6295 static unsigned x_display_id = 0;
6287 static char *initial_display = NULL; 6296 static char *initial_display = NULL;
6297 static dynlib_handle_ptr *handle = NULL;
6288 char *dpy_name; 6298 char *dpy_name;
6289 Lisp_Object lisp_dpy_name = Qnil; 6299 Lisp_Object lisp_dpy_name = Qnil;
6290 6300
@@ -6456,6 +6466,49 @@ pgtk_term_init (Lisp_Object display_name, char *resource_name)
6456 dpyinfo->scroll.x_per_char = 2; 6466 dpyinfo->scroll.x_per_char = 2;
6457 dpyinfo->scroll.y_per_line = 2; 6467 dpyinfo->scroll.y_per_line = 2;
6458 6468
6469 dpyinfo->connection = -1;
6470
6471 if (!handle)
6472 handle = dynlib_open (NULL);
6473
6474#ifdef GDK_WINDOWING_X11
6475 if (!strcmp (G_OBJECT_TYPE_NAME (dpy), "GdkX11Display") && handle)
6476 {
6477 void *(*gdk_x11_display_get_xdisplay) (GdkDisplay *)
6478 = dynlib_sym (handle, "gdk_x11_display_get_xdisplay");
6479 int (*x_connection_number) (void *)
6480 = dynlib_sym (handle, "XConnectionNumber");
6481
6482 if (x_connection_number
6483 && gdk_x11_display_get_xdisplay)
6484 dpyinfo->connection
6485 = x_connection_number (gdk_x11_display_get_xdisplay (dpy));
6486 }
6487#endif
6488
6489#ifdef GDK_WINDOWING_WAYLAND
6490 if (GDK_IS_WAYLAND_DISPLAY (dpy) && handle)
6491 {
6492 struct wl_display *wl_dpy = gdk_wayland_display_get_wl_display (dpy);
6493 int (*display_get_fd) (struct wl_display *)
6494 = dynlib_sym (handle, "wl_display_get_fd");
6495
6496 if (display_get_fd)
6497 dpyinfo->connection = display_get_fd (wl_dpy);
6498 }
6499#endif
6500
6501 if (dpyinfo->connection >= 0)
6502 {
6503 add_keyboard_wait_descriptor (dpyinfo->connection);
6504#ifdef F_SETOWN
6505 fcntl (dpyinfo->connection, F_SETOWN, getpid ());
6506#endif /* ! defined (F_SETOWN) */
6507
6508 if (interrupt_input)
6509 init_sigio (dpyinfo->connection);
6510 }
6511
6459 x_setup_pointer_blanking (dpyinfo); 6512 x_setup_pointer_blanking (dpyinfo);
6460 6513
6461 xsettings_initialize (dpyinfo); 6514 xsettings_initialize (dpyinfo);
diff --git a/src/pgtkterm.h b/src/pgtkterm.h
index 231c8e87064..c16221da832 100644
--- a/src/pgtkterm.h
+++ b/src/pgtkterm.h
@@ -238,6 +238,8 @@ struct pgtk_display_info
238 double acc_x, acc_y; 238 double acc_x, acc_y;
239 double x_per_char, y_per_line; 239 double x_per_char, y_per_line;
240 } scroll; 240 } scroll;
241
242 int connection;
241}; 243};
242 244
243/* This is a chain of structures for all the PGTK displays currently in use. */ 245/* This is a chain of structures for all the PGTK displays currently in use. */