2 * (c) Copyright 1989, 1990, 1991, 1992 OPEN SOFTWARE FOUNDATION, INC.
10 static char rcsid[] = "$TOG: WmMain.c /main/8 1998/04/20 13:01:09 mgreess $"
14 * (c) Copyright 1987, 1988, 1989, 1990 HEWLETT-PACKARD COMPANY */
26 #include <Dt/Message.h>
27 #include <Dt/EnvControlP.h>
30 * include extern functions
38 #include "WmBackdrop.h"
43 * Function Declarations:
46 int WmReturnIdentity (int argc, char *argv[], char *environ[]);
47 #define ManagedRoot(w) (!XFindContext (DISPLAY, (w), wmGD.screenContextType, \
48 (caddr_t *)&pSD) ? (SetActiveScreen (pSD), True) : \
49 (IsBackdropWindow (ACTIVE_PSD, (w))))
51 #define ManagedRoot(w) (!XFindContext (DISPLAY, (w), wmGD.screenContextType, \
52 (caddr_t *)&pSD) ? (SetActiveScreen (pSD), True) : False)
62 #ifndef NO_MESSAGE_CATALOG
71 /*************************************<->*************************************
73 * main (argc, argv, environ)
78 * This is the main window manager function. It calls window manager
79 * initializtion functions and has the main event processing loop.
84 * argc = number of command line arguments (+1)
86 * argv = window manager command line arguments
88 * environ = window manager environment
90 *************************************<->***********************************/
93 main (int argc, char *argv [], char *environ [])
96 Boolean dispatchEvent;
98 setlocale(LC_ALL, "");
103 * Set up environment variables for this HP DT client
105 _DtEnvControl(DT_ENV_SET);
108 * Force LANG lookup early.
109 * (Front end may change $LANG to 'C' as part
110 * of string space reduction optimization.)
113 char * foo = ((char *)GETMESSAGE(44, 1, ""));
116 XtSetLanguageProc (NULL, (XtLanguageProc)NULL, NULL);
122 WmIdentity = WmReturnIdentity(argc, argv, environ);
126 * Initialize the workspace:
129 InitWmGlobal (argc, argv, environ);
133 * Set up PATH variable if it must run as standalone command
138 _DtEnvControl(DT_ENV_SET_BIN);
143 * MAIN EVENT HANDLING LOOP:
148 XtAppNextEvent (wmGD.mwmAppContext, &event);
152 * Check for, and process non-widget events. The events may be
153 * reported to the root window, to some client frame window,
154 * to an icon window, or to a "special" window management window.
155 * The lock modifier is "filtered" out for window manager processing.
158 wmGD.attributesWindow = 0L;
161 if ((event.type == ButtonPress) ||
162 (event.type == ButtonRelease))
164 if ((wmGD.evLastButton.button != 0) &&
165 ReplayedButtonEvent (&(wmGD.evLastButton),
168 wmGD.bReplayedButton = True;
172 /* save this button for next comparison */
173 memcpy (&wmGD.evLastButton, &event, sizeof (XButtonEvent));
174 wmGD.bReplayedButton = False;
178 dispatchEvent = True;
182 * Do special menu event preprocessing.
185 if (wmGD.checkHotspot || wmGD.menuUnpostKeySpec ||
186 wmGD.menuActive->accelKeySpecs)
188 dispatchEvent = WmDispatchMenuEvent ((XButtonEvent *) &event);
194 if (ManagedRoot(event.xany.window))
196 dispatchEvent = WmDispatchWsEvent (&event);
200 dispatchEvent = WmDispatchClientEvent (&event);
206 * Dispatch widget related event:
209 XtDispatchEvent (&event);
214 } /* END OF FUNCTION main */
217 /******************************<->*************************************
219 * WmReturnIdentity (argc, argv, environ)
224 * This function checks the last component of the (path)name
225 * contained in argv[0] and makes a global decision as to whether
226 * it should fetch resources as mwm or dtwm.
230 * argc = number of command line arguments (+1)
232 * argv = window manager command line arguments
234 * environ = window manager environment
236 ******************************<->***********************************/
238 int WmReturnIdentity ( int argc, char *argv[], char *environ[])
243 /* assume it's dtwm until proven differently */
248 (char *)(XtMalloc ((unsigned int)(strlen (argv[0]) + 1)))))
250 Warning(((char *)GETMESSAGE(44, 2, "Insufficient memory for name of window manager")));
251 exit(WM_ERROR_EXIT_VALUE);
254 origPtr = tempString;
256 if (strrchr(argv[0], '/'))
259 strcpy(tempString, (strrchr(argv[0], '/')));
264 strcpy(tempString, argv[0]);
266 if (!(strcmp(tempString, WM_RESOURCE_NAME)))
269 * If it's explicity "mwm", then set our identity anew.
276 XtFree((char *)origPtr);
280 } /* END OF FUNCTION WmReturnIdentity */
283 /************************* eof ******************************/