diff --git a/0001-Apply-display-kluge-for-PGTK-too.patch b/0001-Apply-display-kluge-for-PGTK-too.patch new file mode 100644 index 0000000..13c9cb3 --- /dev/null +++ b/0001-Apply-display-kluge-for-PGTK-too.patch @@ -0,0 +1,50 @@ +From 2f348ffee3777a8e2b02814d8cc50d282d98d366 Mon Sep 17 00:00:00 2001 +From: Peter Oliver +Date: Sun, 14 Jul 2024 21:50:33 +0100 +Subject: [PATCH 1/2] Apply --display kluge for PGTK too + +* src/emacs.c (main): The --display option needs the same handling +with the PGTK backend as it does with the X11 backends. (Bug#72118) +--- + src/emacs.c | 4 ++-- + src/lisp.h | 2 +- + 2 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/src/emacs.c b/src/emacs.c +index 712826d57b7..ec284b16f8d 100644 +--- a/src/emacs.c ++++ b/src/emacs.c +@@ -181,7 +181,7 @@ #define MAIN_PROGRAM + data on the first attempt to change it inside asynchronous code. */ + bool running_asynch_code; + +-#if defined (HAVE_X_WINDOWS) || defined (HAVE_NS) ++#if defined (HAVE_X_WINDOWS) || defined (HAVE_PGTK) || defined (HAVE_NS) + /* If true, -d was specified, meaning we're using some window system. */ + bool display_arg; + #endif +@@ -2014,7 +2014,7 @@ main (int argc, char **argv) + { + int count_before = skip_args; + +-#ifdef HAVE_X_WINDOWS ++#if defined (HAVE_X_WINDOWS) || defined (HAVE_PGTK) + char *displayname = 0; + + /* Skip any number of -d options, but only use the last one. */ +diff --git a/src/lisp.h b/src/lisp.h +index 5fa48cec2f0..05daceb5dff 100644 +--- a/src/lisp.h ++++ b/src/lisp.h +@@ -4889,7 +4889,7 @@ fast_c_string_match_ignore_case (Lisp_Object regexp, + extern char **initial_argv; + extern int initial_argc; + extern char const *emacs_wd; +-#if defined (HAVE_X_WINDOWS) || defined (HAVE_NS) ++#if defined (HAVE_X_WINDOWS) || defined (HAVE_PGTK) || defined (HAVE_NS) + extern bool display_arg; + #endif + extern Lisp_Object decode_env_path (const char *, const char *, bool); +-- +2.45.2 + diff --git a/0002-Fall-back-to-the-terminal-from-pure-GTK-when-no-disp.patch b/0002-Fall-back-to-the-terminal-from-pure-GTK-when-no-disp.patch new file mode 100644 index 0000000..dbcf3d9 --- /dev/null +++ b/0002-Fall-back-to-the-terminal-from-pure-GTK-when-no-disp.patch @@ -0,0 +1,63 @@ +From 7099578f18b1ea6a168b1883fa7a4ac7f49fc08f Mon Sep 17 00:00:00 2001 +From: Peter Oliver +Date: Sun, 14 Jul 2024 20:47:14 +0100 +Subject: [PATCH 2/2] Fall back to the terminal from pure GTK when no display + is available +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +* src/dispnew.c (init_display_interactive): Only use PGTK windowing if +at least one of the environment variables WAYLAND_DISPLAY, DISPLAY, +BROADWAY_DISPLAY is set. (Bug#63555) + +This patch is not suitable for merging, because it doesn’t consider +what happens if you try to use PGTK on Windows or MacOS. +--- + src/dispnew.c | 29 ++++++++++++++++++++++++++--- + 1 file changed, 26 insertions(+), 3 deletions(-) + +diff --git a/src/dispnew.c b/src/dispnew.c +index 7cf2b49273c..481d33a7302 100644 +--- a/src/dispnew.c ++++ b/src/dispnew.c +@@ -6557,10 +6557,33 @@ init_display_interactive (void) + #endif + + #ifdef HAVE_PGTK +- if (!inhibit_window_system && !will_dump_p ()) ++ if (!inhibit_window_system) + { +- Vinitial_window_system = Qpgtk; +- return; ++ if (!display_arg && !will_dump_p ()) ++ { ++ int i; ++ const char *gdk_display_variables[] = { ++ "WAYLAND_DISPLAY", ++ "DISPLAY", ++ "BROADWAY_DISPLAY", ++ }; ++ size_t n = ARRAYELTS (gdk_display_variables); ++ ++ for (i = 0; i < n; i++) ++ { ++ char *display; ++ display = getenv (gdk_display_variables[i]); ++ if (display != 0 && *display != 0) ++ { ++ display_arg = 1; ++ break; ++ } ++ } ++ } ++ if (display_arg) { ++ Vinitial_window_system = Qpgtk; ++ return; ++ } + } + #endif + +-- +2.45.2 + diff --git a/emacs.spec b/emacs.spec index e7d87e5..6934efa 100644 --- a/emacs.spec +++ b/emacs.spec @@ -46,6 +46,12 @@ Patch: 0001-Fix-flymake-tests-with-GCC-14.patch # Fix intermittently failing test (https://debbugs.gnu.org/cgi/bugreport.cgi?bug=72073) Patch: 0001-Fix-wdired-test-unfinished-edit-01-when-temp-dirname.patch +# Workaround for https://bugzilla.redhat.com/show_bug.cgi?id=2276822 +# (https://debbugs.gnu.org/cgi/bugreport.cgi?bug=63555). If GDK ever +# gets any new backends, this patch may need extending. +Patch: 0001-Apply-display-kluge-for-PGTK-too.patch +Patch: 0002-Fall-back-to-the-terminal-from-pure-GTK-when-no-disp.patch + ExcludeArch: %{ix86} BuildRequires: alsa-lib-devel