Subject: bug#74496: 30.0.91; fullscreen frame set with F11 is shifted when ctwm restarts

From: martin rudalics <[email-masked]>
Date: Wed, 4 Dec 2024 10:52:37 +0100

>    33  (gdb) condition 1 lval == Qnil
 >    34  No symbol "builtin_lisp_symbol" in current context.

I see.  The condition would have been

   condition 1 EQ (lval, Qnil)

but lval is not a C variable.  So it won't work without modifying the
source.  I have no good idea yet how to do that.  Setting these
breakpoints unconditionally is out of the question - we want to catch
the transition from Qfullboth to Qnil here.

Maybe you can try the attached diff (it's against the release version)
and set breakpoints at the four lines I marked with a

// break-here

comment.  Start gdb via run -Q, do F11 and restart CWTM.  Here you have
to switch to the debugging Emacs (either you have it on another
workspace or you find an equivalent of Alt-TAB used by most window
managers) type "bt" and post the backtrace here.  Maybe it will let us
find out why that parameter gets reset.

martin

diff --git a/src/frame.c b/src/frame.c
index f6053fca3ef..e4787ae1bf5 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -4539,7 +4539,11 @@ gui_set_frame_parameters_1 (struct frame *f, Lisp_Object alist,
     {
       Lisp_Object old_value = get_frame_param (f, Qfullscreen);
 
-      store_frame_param (f, Qfullscreen, fullscreen);
+      if (EQ (old_value, Qfullboth) && EQ (fullscreen, Qnil))
+	store_frame_param (f, Qfullscreen, fullscreen); // break here
+      else
+	store_frame_param (f, Qfullscreen, fullscreen);
+
       if (!EQ (fullscreen, old_value))
 	gui_set_fullscreen (f, fullscreen, old_value);
     }
diff --git a/src/xterm.c b/src/xterm.c
index fd3e58f85f6..3b5311b0977 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -18041,7 +18041,11 @@ x_net_wm_state (struct frame *f, Window window)
       break;
     }
 
-  store_frame_param (f, Qfullscreen, lval);
+  if (EQ (get_frame_param (f, Qfullscreen), Qfullboth) && EQ (lval, Qnil))
+    store_frame_param (f, Qfullscreen, lval); // break here
+  else
+    store_frame_param (f, Qfullscreen, lval);
+
   store_frame_param (f, Qsticky, sticky ? Qt : Qnil);
   store_frame_param (f, Qshaded, shaded ? Qt : Qnil);
 }
@@ -28272,7 +28276,11 @@ x_handle_net_wm_state (struct frame *f, const XPropertyEvent *event)
       break;
     }
 
-  store_frame_param (f, Qfullscreen, lval);
+  if (EQ (get_frame_param (f, Qfullscreen), Qfullboth) && EQ (lval, Qnil))
+    store_frame_param (f, Qfullscreen, lval); // break here
+  else
+    store_frame_param (f, Qfullscreen, lval);
+
   store_frame_param (f, Qsticky, sticky ? Qt : Qnil);
   store_frame_param (f, Qshaded, shaded ? Qt : Qnil);
 
@@ -28340,7 +28348,10 @@ x_check_fullscreen (struct frame *f)
 
   /* `x_net_wm_state' might have reset the fullscreen frame parameter,
      restore it. */
-  store_frame_param (f, Qfullscreen, lval);
+  if (EQ (get_frame_param (f, Qfullscreen), Qfullboth) && EQ (lval, Qnil))
+    store_frame_param (f, Qfullscreen, lval); // break here
+  else
+    store_frame_param (f, Qfullscreen, lval);
 }
 
 /* This function is called by x_set_offset to determine whether the window