This behavior has always annoyed me but now that I use a GNUstep
application permanently (Emacs.app) I find it unbearable.

On IceWM, if you start a GNUstep app on Workspace #1 and then switch
to Workspace #2, the app's window and the app icon remain at #1 but
the menu appears on #2.

On Window Maker (the window manager I use) this happens about 50/60%
of the time, without some specific reason.  If you switch workspaces
with the keyboard several times, you end up stuck at the workspace
where the GNUstep app is and can no longer use the keyboard to switch
to anoother workspace -- you must use the Clip's arrows for that.

What makes this worse is chaotically retaining or losing focus.  If my
app is on Workspace #1 and I switch to #3 I expect the application
(not necessarily a GNUstep application) on #3 to be focused and the
GNUstep app at #1 to be unfocused.  But sometimes this doesn't happen
and when you attempt to type something in a terminal on another
workspace, for example, the text appears in Emacs' active buffer
regardless of the fact that it's on Workspace #1 which is not active.

Likewise, if you have EDITOR set to "emacsclient" and you type "git
commit" in a terminal from a checked out Git branch, and then switch
to Workspace #1 where Emacs is, the Emacs frame is often not focused
so you cannot type the commit message immediately.  This is despite
the fact that Emacs is the only app on Workspace #1.

The attached patch fixes this; tested with Emacs, Gorm, PikoPixel,
SystemPreferences, Ink and TextEdit.  If you make a new Emacs frame
(or a new document window in Ink with Cmd-n) and move it to another
workspace, both workspaces have menus.

One side effect is for apps that don't have a main window (AClock,
TimeMon): when you switch to another workspace and then return to the
workspace where the app is, the menu is gone.  You have to right-click
the app icon to get it.  But I think that's a good thing as these are
dockable apps and a user wouldn't want a menu always present anyway.
>From b0de535c4fcf5c43b87658b847bd0921332f0751 Mon Sep 17 00:00:00 2001
From: Yavor Doganov <[email protected]>
Date: Mon, 24 Nov 2025 15:48:21 +0200
Subject: [PATCH] Make the main menu's window transient for the app's main
 window

---
 ChangeLog                   | 6 ++++++
 Source/x11/XGServerWindow.m | 4 +++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 35551b1..c1c5d56 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2025-11-24  Yavor Doganov  <[email protected]>
+
+       * Source/x11/XGServerWindow.m ([XGServer setwindowlevel:]): Set
+       WM_TRANSIENT_FOR and _NET_WM_WINDOW_TYPE_NORMAL for the main
+       menu's window.
+
 2025-05-21 Fred Kiefer <[email protected]>
 
        * Source/x11/scale.c,
diff --git a/Source/x11/XGServerWindow.m b/Source/x11/XGServerWindow.m
index 1add432..5f96b71 100644
--- a/Source/x11/XGServerWindow.m
+++ b/Source/x11/XGServerWindow.m
@@ -3399,7 +3399,9 @@ swapColors(unsigned char *image_data, NSBitmapImageRep 
*rep)
             }
           else if (level == NSMainMenuWindowLevel)
             {
-              data[0] = generic._NET_WM_WINDOW_TYPE_DOCK_ATOM;
+              [self setParentWindow: [self _rootWindow]->number
+                     forChildWindow: window->number];
+              data[0] = generic._NET_WM_WINDOW_TYPE_NORMAL_ATOM;
               skipTaskbar = YES;
             }
           else if (level == NSSubmenuWindowLevel
-- 
2.51.0

Reply via email to