Files
mcde/programs/dtwm/WmMain.c
T
lotherk 26c66b7444 dtwm: the program switcher stays while Command is held (t0115 follow-up)
Command+Tab raised and focused the next program at once, but the bar closed
by a five-second timer: holding Command longer made it vanish, and letting
Command go did not close it.  The bar now stays as long as Command is held:
dtwm grabs the keyboard while it is up (the Mod4 keycodes come from the
modifier map), KeyRelease of a Command key is looked at in WmMain before the
generic dispatch (McdeSwitcherEvent), and it hides and ungrabs at once.  A
long timer (60 s) only covers a grab that failed or a release that never
came; without the grab the old five-second flash stays.

Repeated Tab while held walks on, Shift+Command+Tab goes back; the chosen
program is raised and focused on every press (unchanged).  MCDE_SW_DEBUG=1
prints the grab and the key events.

Measured on an out-of-tree copy of the configured build (the tree's build
lock was held by another session's release/distfiles run): make dtwm linked
the changed sources, and under Xvfb :93 with two xterms
- keydown Super_L, Tab: the bar "MCDE Switcher" is IsViewable;
- after 7 s still held: IsViewable (the old code hid at 5 s);
- Tab again, keyup Super_L: IsUnMapped within 0.5 s, focus on the chosen
  xterm; the debug log shows the grab with keycodes 133 134 206 and the
  release of 133 closing it.

The official make mcde-linux and the install into /usr/mdt follow when the
build lock is free; the change touches only dtwm.  AGENTS.md describes the
behavior.
2026-11-16 18:57:06 +00:00

304 lines
6.9 KiB
C

/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/*
* (c) Copyright 1989, 1990, 1991, 1992 OPEN SOFTWARE FOUNDATION, INC.
* ALL RIGHTS RESERVED
*/
/*
* Motif Release 1.2.1
*/
/*
* (c) Copyright 1987, 1988, 1989, 1990 HEWLETT-PACKARD COMPANY */
/*
* Included Files:
*/
#include "WmGlobal.h"
#include <locale.h>
#include <Dt/Message.h>
#include <Dt/EnvControlP.h>
/*
* include extern functions
*/
#include "WmCEvent.h"
#include "WmEvent.h"
#include "WmInitWs.h"
#include "WmError.h"
#include "WmIPC.h"
#include "WmMcdeDisplays.h"
#include "WmFunction.h"
#include "WmBackdrop.h"
/*
* Function Declarations:
*/
int WmReturnIdentity (int argc, char *argv[], char *environ[]);
#define ManagedRoot(w) (!XFindContext (DISPLAY, (w), wmGD.screenContextType, \
(caddr_t *)&pSD) ? (SetActiveScreen (pSD), True) : \
(IsBackdropWindow (ACTIVE_PSD, (w))))
WmScreenData *pSD;
/*
* Global Variables:
*/
WmGlobalData wmGD;
#ifndef NO_MESSAGE_CATALOG
NlsStrings wmNLS;
#endif
int WmIdentity;
/*************************************<->*************************************
*
* main (argc, argv, environ)
*
*
* Description:
* -----------
* This is the main window manager function. It calls window manager
* initializtion functions and has the main event processing loop.
*
*
* Inputs:
* ------
* argc = number of command line arguments (+1)
*
* argv = window manager command line arguments
*
* environ = window manager environment
*
*************************************<->***********************************/
int
main (int argc, char *argv [], char *environ [])
{
XEvent event;
Boolean dispatchEvent;
setlocale(LC_ALL, "");
/*
* Set up environment variables for this HP DT client
*/
_DtEnvControl(DT_ENV_SET);
/*
* Force LANG lookup early.
* (Front end may change $LANG to 'C' as part
* of string space reduction optimization.)
*/
{
char * foo = ((char *)GETMESSAGE(44, 1, ""));
}
XtSetLanguageProc (NULL, (XtLanguageProc)NULL, NULL);
/*
* Get Identity
*/
WmIdentity = WmReturnIdentity(argc, argv, environ);
/*
* Initialize the workspace:
*/
InitWmGlobal (argc, argv, environ);
/*
* Set up PATH variable if it must run as standalone command
* invoker
*/
if (wmGD.dtLite)
{
_DtEnvControl(DT_ENV_SET_BIN);
}
/* MCDE: the drives on the desktop (WmMcdeDesktop.c) */
McdeDesktopInit ();
/*
* MAIN EVENT HANDLING LOOP:
*/
for (;;)
{
XtAppNextEvent (wmGD.mwmAppContext, &event);
/*
* Check for, and process non-widget events. The events may be
* reported to the root window, to some client frame window,
* to an icon window, or to a "special" window management window.
* The lock modifier is "filtered" out for window manager processing.
*/
wmGD.attributesWindow = 0L;
if ((event.type == ButtonPress) ||
(event.type == ButtonRelease))
{
if ((wmGD.evLastButton.button != 0) &&
ReplayedButtonEvent (&(wmGD.evLastButton),
&(event.xbutton)))
{
wmGD.bReplayedButton = True;
}
else
{
/* save this button for next comparison */
memcpy (&wmGD.evLastButton, &event, sizeof (XButtonEvent));
wmGD.bReplayedButton = False;
}
}
/* MCDE: RandR's events (monitors plugged in and out) */
if (McdeDisplaysEvent (&event))
continue;
/* MCDE: the keyboard and pointer of the window overview (F9/F10) */
if (McdeOverviewEvent (&event))
continue;
/* MCDE: the keyboard and pointer of the workspaces overview (F8) */
if (McdeSpacesEvent (&event))
continue;
/* MCDE: Command let go ends the program switcher (Command+Tab) */
if (McdeSwitcherEvent (&event))
continue;
/* MCDE: a right click on the empty desktop (its own menu) */
if (McdeDesktopRootEvent (&event))
continue;
/* MCDE: a click on the desktop icon menu */
if (McdeDesktopMenuEvent (&event))
continue;
/* MCDE: a click on a drive of the desktop */
if (McdeDesktopEvent (&event))
continue;
dispatchEvent = True;
if (wmGD.menuActive)
{
/*
* Do special menu event preprocessing.
*/
if (wmGD.checkHotspot || wmGD.menuUnpostKeySpec ||
wmGD.menuActive->accelKeySpecs)
{
dispatchEvent = WmDispatchMenuEvent ((XButtonEvent *) &event);
}
}
if (dispatchEvent)
{
if (ManagedRoot(event.xany.window))
{
dispatchEvent = WmDispatchWsEvent (&event);
}
else
{
dispatchEvent = WmDispatchClientEvent (&event);
}
if (dispatchEvent)
{
/*
* Dispatch widget related event:
*/
XtDispatchEvent (&event);
}
}
}
} /* END OF FUNCTION main */
/******************************<->*************************************
*
* WmReturnIdentity (argc, argv, environ)
*
*
* Description:
* -----------
* This function checks the last component of the (path)name
* contained in argv[0] and makes a global decision as to whether
* it should fetch resources as mwm or dtwm.
*
* Inputs:
* ------
* argc = number of command line arguments (+1)
*
* argv = window manager command line arguments
*
* environ = window manager environment
*
******************************<->***********************************/
int WmReturnIdentity ( int argc, char *argv[], char *environ[])
{
char *tempString;
char *origPtr;
/* assume it's dtwm until proven differently */
int retVal = DT_MWM;
if (!(tempString =
(char *)(XtMalloc ((unsigned int)(strlen (argv[0]) + 1)))))
{
Warning(((char *)GETMESSAGE(44, 2, "Insufficient memory for name of window manager")));
exit(WM_ERROR_EXIT_VALUE);
}
origPtr = tempString;
if (strrchr(argv[0], '/'))
{
strcpy(tempString, (strrchr(argv[0], '/')));
tempString++;
}
else
strcpy(tempString, argv[0]);
if (!(strcmp(tempString, WM_RESOURCE_NAME)))
/*
*
* If it's explicity "mwm", then set our identity anew.
*
*/
{
retVal = MWM;
}
XtFree((char *)origPtr);
return(retVal);
} /* END OF FUNCTION WmReturnIdentity */
/************************* eof ******************************/