From 07700ffcd01ed5cc4c284a686c9e05340fccb1c2 Mon Sep 17 00:00:00 2001
From: Chase <chinkle3@illinois.edu>
Date: Thu, 27 Nov 2025 22:16:31 -0500
Subject: [PATCH] dtwm: fix hourglass not showing up where it should

---
 cde/programs/dtwm/UI.c         |  5 +---
 cde/programs/dtwm/WmFeedback.c | 47 +++++++++++++---------------------
 cde/programs/dtwm/WmFeedback.h |  3 ++-
 cde/programs/dtwm/WmInitWs.c   | 16 ++++++------
 4 files changed, 29 insertions(+), 42 deletions(-)

diff --git a/cde/programs/dtwm/UI.c b/cde/programs/dtwm/UI.c
index 0391dc8f0..64942495d 100644
--- a/cde/programs/dtwm/UI.c
+++ b/cde/programs/dtwm/UI.c
@@ -391,9 +391,6 @@ Initialize (DtPanelShellWidget panel_shell)
    Screen  * screen = XtScreen (panel_shell);
    Display * display = XtDisplay (panel_shell);
 
-   Pixmap busy_pixmap;
-   Pixmap busy_pixmap_mask;
-
    Pixel black_pixel = BlackPixelOfScreen (screen);
    Pixel white_pixel = WhitePixelOfScreen (screen);
 
@@ -408,7 +405,7 @@ Initialize (DtPanelShellWidget panel_shell)
 
    /*  Create busy cursor.  */
 
-  _DtGetHourGlassCursor(display);
+   panel.busy_cursor = _DtGetHourGlassCursor(display);
    
    panel.resolution = (int) (intptr_t) panel.element_values[PANEL_RESOLUTION].parsed_value;
 
diff --git a/cde/programs/dtwm/WmFeedback.c b/cde/programs/dtwm/WmFeedback.c
index 7b7f3ede3..3e49e6e5b 100644
--- a/cde/programs/dtwm/WmFeedback.c
+++ b/cde/programs/dtwm/WmFeedback.c
@@ -872,17 +872,17 @@ void ConfirmAction (WmScreenData *pSD, int nbr)
 
 /*************************************<->*************************************
  *
- *  ShowWaitState (flag)
- *
+ *  EnterWaitState (void)
+ *  LeaveWatState (void)
  *
  *  Description:
  *  -----------
- *  Enter/Leave the wait state.
- *
+ *  Enter the wait state.
+ *  Leave the wait state.
  *
  *  Inputs:
  *  ------
- *  flag = TRUE for Enter, FALSE for Leave.
+ *  None.
  *
  * 
  *  Outputs:
@@ -896,33 +896,22 @@ void ConfirmAction (WmScreenData *pSD, int nbr)
  * 
  *************************************<->***********************************/
 
-void ShowWaitState (Boolean flag)
+void EnterWaitState(void)
 {
-    unsigned int width;
-    unsigned int height;
-    unsigned int xHotspot;
-    unsigned int yHotspot;
-    Pixmap       pixmap;
-    Pixmap       maskPixmap;
-    XColor       xcolors[2];
+    waitCursor = _DtGetHourGlassCursor(DISPLAY);
 
-   _DtGetHourGlassCursor(DISPLAY);
-
-    if (flag)
-    {
-	XGrabPointer (DISPLAY, DefaultRootWindow(DISPLAY), FALSE, 
-			0, GrabModeAsync, GrabModeAsync, None, 
-			waitCursor, CurrentTime);
-	XGrabKeyboard (DISPLAY, DefaultRootWindow(DISPLAY), FALSE, 
-			GrabModeAsync, GrabModeAsync, CurrentTime);
-    }
-    else
-    {
-	XUngrabPointer (DISPLAY, CurrentTime);
-	XUngrabKeyboard (DISPLAY, CurrentTime);
-    }
+    XGrabPointer (DISPLAY, DefaultRootWindow(DISPLAY), FALSE,
+		0, GrabModeAsync, GrabModeAsync, None,
+		waitCursor, CurrentTime);
+    XGrabKeyboard (DISPLAY, DefaultRootWindow(DISPLAY), FALSE,
+		GrabModeAsync, GrabModeAsync, CurrentTime);
+}
 
-} /* END OF FUNCTION ShowWaitState */
+void LeaveWaitState(void)
+{
+    XUngrabPointer (DISPLAY, CurrentTime);
+    XUngrabKeyboard (DISPLAY, CurrentTime);
+}
 
 
 
diff --git a/cde/programs/dtwm/WmFeedback.h b/cde/programs/dtwm/WmFeedback.h
index 004e47ab8..9f6e304f6 100644
--- a/cde/programs/dtwm/WmFeedback.h
+++ b/cde/programs/dtwm/WmFeedback.h
@@ -38,7 +38,8 @@ extern void PaintFeedbackWindow (WmScreenData *pSD);
 extern void ShowFeedbackWindow (WmScreenData *pSD, int x, int y, 
 				unsigned int width, unsigned int height, 
 				unsigned long style);
-extern void ShowWaitState (Boolean flag);
+extern void EnterWaitState(void);
+extern void LeaveWaitState(void);
 extern void UpdateFeedbackInfo (WmScreenData *pSD, int x, int y, 
 				unsigned int width, unsigned int height);
 extern void UpdateFeedbackText (WmScreenData *pSD, int x, int y, 
diff --git a/cde/programs/dtwm/WmInitWs.c b/cde/programs/dtwm/WmInitWs.c
index 4cdd01c85..bd27e3f42 100644
--- a/cde/programs/dtwm/WmInitWs.c
+++ b/cde/programs/dtwm/WmInitWs.c
@@ -495,7 +495,7 @@ void InitWmGlobal (int argc, char *argv [], char *environ [])
     
     InitCursorInfo ();
     InitWmDisplayEnv ();
-    ShowWaitState (TRUE);
+    EnterWaitState();
 
     /*
      * Initialize support for BMenu virtual mouse binding
@@ -628,7 +628,7 @@ void InitWmGlobal (int argc, char *argv [], char *environ [])
     if (!(wmGD.Screens = (WmScreenData *) 
 	    XtCalloc (wmGD.numScreens, sizeof(WmScreenData))))
     {
-	ShowWaitState (FALSE);
+	LeaveWaitState();
 	Warning (((char *)GETMESSAGE(40, 2, "Insufficient memory for Screen data")));
 	ExitWM (WM_ERROR_EXIT_VALUE);
     }
@@ -748,7 +748,7 @@ void InitWmGlobal (int argc, char *argv [], char *environ [])
 						   dpy2Argv);
 		    if (!wmGD.display1)
 		    {
-			ShowWaitState (FALSE);
+			LeaveWaitState();
 			Warning(((char *)GETMESSAGE(40, 4, "Could not open second display connection.")));
 			ExitWM (WM_ERROR_EXIT_VALUE);
 		    }
@@ -820,7 +820,7 @@ void InitWmGlobal (int argc, char *argv [], char *environ [])
 	    /*
 	     * No screens for me to manage, give up.
 	     */
-	    ShowWaitState (FALSE);
+	    LeaveWaitState();
 	    Warning (((char *)GETMESSAGE(40, 5, "Unable to manage any screens on display.")));
 	    ExitWM (WM_ERROR_EXIT_VALUE);
 	}
@@ -857,7 +857,7 @@ void InitWmGlobal (int argc, char *argv [], char *environ [])
 
     if (fcntl (ConnectionNumber (DISPLAY), F_SETFD, 1) == -1)
     {
-	ShowWaitState (FALSE);
+	LeaveWaitState();
 	Warning (((char *)GETMESSAGE(40, 6, "Cannot configure X connection")));
 	ExitWM (WM_ERROR_EXIT_VALUE);
     }
@@ -1138,7 +1138,7 @@ XFlush (DISPLAY);
     
     InitKeyboardFocus ();
 
-    ShowWaitState (FALSE);
+    LeaveWaitState();
 
     /*
      * Tell the rest of DT that we're up
@@ -2077,7 +2077,7 @@ void InitScreenNames (void)
     if (!(wmGD.screenNames = 
 	  (unsigned char **) XtMalloc (numScreens * sizeof(char *))))
     {
-	ShowWaitState (FALSE);
+	LeaveWaitState();
 	Warning (((char *)GETMESSAGE(40, 12, "Insufficient memory for screen names")));
 	ExitWM (WM_ERROR_EXIT_VALUE);
     }
@@ -2087,7 +2087,7 @@ void InitScreenNames (void)
 	if (!(wmGD.screenNames[num] = 
 	      (unsigned char *) XtMalloc (4*sizeof(char))))
 	{
-	    ShowWaitState (FALSE);
+	    LeaveWaitState();
 	    Warning (((char *)GETMESSAGE(40, 13, "Insufficient memory for screen names")));
 	    ExitWM (WM_ERROR_EXIT_VALUE);
 	}
