Subject: Re: bug#31650: 26.1; Desktop mode adds wm stickiness to emacs windows.

From: martin rudalics <[email-masked]>
Date: Wed, 30 May 2018 08:40:56 +0200

> I've
 >
 > (desktop-save-mode 1)
 >
 > in my init.el. This works fine for rare occasions is restart emacs.
 > Though, after restart, I not only find all my files open but the eamcs
 > window "sticky" speaking in windows manager terms, meaning if I jump to
 > another virtual desktop, my emacs windwos will "follow" me.

We would eventually have to find out whether and how an Emacs frame
can get "spontaneously" sticky in a session that has not been polluted
from a saved desktop.  I'd suggest to proceed as follows: Somewhere
near the end of your init file (that is, after the code that restores
the previous desktop) insert this code:

(let (sticky-frames)
   (dolist (frame (frame-list))
     (when (frame-parameter frame 'sticky)
       (setq sticky-frames (cons frame sticky-frames)))
     (set-frame-parameter frame 'sticky nil))

   (when sticky-frames
     (message "The following frames were found sticky: %s" sticky-frames)))

Now this should (1) make all your frames non-sticky in the new session
and (2) tell you if some frames were stored as sticky in your last
session.  If (2) happens frequently and you are sure that you have
never marked any frames as sticky, we could execute that code above
with an idle timer and so get an approximate indication of _when_ a
frame changes its stickyness spontaneously.

 > The emacs window wasn't in this state at the last
 > save-buffers-kill-terminal call.

How can you be sure of that?  The code for saving the desktop is dumb
and handles stickyness like any other frame parameter it does not
treat specially.  So it would surprise me if the desktop saving code
deliberately remembered a frame as sticky.

 > It doesn't have this state if I start
 > emacs -Q. It's  desktop-save-mode, that put my emacs window into this
 > state.
 >
 > It's a minor nuisance, no doubt, but it's clearly wrong.
 >
 > I'm using GNU Emacs 26.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 >   2.24.10) of 2018-05-29 built on linux-qg7d Repository revision:
 >   07f8f9bc5a51f5aa94eb099f3e15fbe0c20ea1ea Windowing system distributor
 >   'The X.Org Foundation', version 11.0.11203000 (x86_64) and as windows
 >   manager fvwm 2.6.

martin