2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
24 * (c) Copyright 1989, 1990, 1991, 1992 OPEN SOFTWARE FOUNDATION, INC.
32 static char rcsid[] = "$TOG: WmMain.c /main/8 1998/04/20 13:01:09 mgreess $"
36 * (c) Copyright 1987, 1988, 1989, 1990 HEWLETT-PACKARD COMPANY */
48 #include <Dt/Message.h>
49 #include <Dt/EnvControlP.h>
52 * include extern functions
61 #include "WmBackdrop.h"
66 * Function Declarations:
69 int WmReturnIdentity (int argc, char *argv[], char *environ[]);
70 #define ManagedRoot(w) (!XFindContext (DISPLAY, (w), wmGD.screenContextType, \
71 (caddr_t *)&pSD) ? (SetActiveScreen (pSD), True) : \
72 (IsBackdropWindow (ACTIVE_PSD, (w))))
74 #define ManagedRoot(w) (!XFindContext (DISPLAY, (w), wmGD.screenContextType, \
75 (caddr_t *)&pSD) ? (SetActiveScreen (pSD), True) : False)
85 #ifndef NO_MESSAGE_CATALOG
94 /*************************************<->*************************************
96 * main (argc, argv, environ)
101 * This is the main window manager function. It calls window manager
102 * initializtion functions and has the main event processing loop.
107 * argc = number of command line arguments (+1)
109 * argv = window manager command line arguments
111 * environ = window manager environment
113 *************************************<->***********************************/
116 main (int argc, char *argv [], char *environ [])
119 Boolean dispatchEvent;
121 setlocale(LC_ALL, "");
126 * Set up environment variables for this HP DT client
128 _DtEnvControl(DT_ENV_SET);
131 * Force LANG lookup early.
132 * (Front end may change $LANG to 'C' as part
133 * of string space reduction optimization.)
136 char * foo = ((char *)GETMESSAGE(44, 1, ""));
139 XtSetLanguageProc (NULL, (XtLanguageProc)NULL, NULL);
145 WmIdentity = WmReturnIdentity(argc, argv, environ);
149 * Initialize the workspace:
152 InitWmGlobal (argc, argv, environ);
156 * Set up PATH variable if it must run as standalone command
161 _DtEnvControl(DT_ENV_SET_BIN);
166 * MAIN EVENT HANDLING LOOP:
171 XtAppNextEvent (wmGD.mwmAppContext, &event);
175 * Check for, and process non-widget events. The events may be
176 * reported to the root window, to some client frame window,
177 * to an icon window, or to a "special" window management window.
178 * The lock modifier is "filtered" out for window manager processing.
181 wmGD.attributesWindow = 0L;
184 if ((event.type == ButtonPress) ||
185 (event.type == ButtonRelease))
187 if ((wmGD.evLastButton.button != 0) &&
188 ReplayedButtonEvent (&(wmGD.evLastButton),
191 wmGD.bReplayedButton = True;
195 /* save this button for next comparison */
196 memcpy (&wmGD.evLastButton, &event, sizeof (XButtonEvent));
197 wmGD.bReplayedButton = False;
201 dispatchEvent = True;
205 * Do special menu event preprocessing.
208 if (wmGD.checkHotspot || wmGD.menuUnpostKeySpec ||
209 wmGD.menuActive->accelKeySpecs)
211 dispatchEvent = WmDispatchMenuEvent ((XButtonEvent *) &event);
217 if (ManagedRoot(event.xany.window))
219 dispatchEvent = WmDispatchWsEvent (&event);
223 dispatchEvent = WmDispatchClientEvent (&event);
229 * Dispatch widget related event:
232 XtDispatchEvent (&event);
237 } /* END OF FUNCTION main */
240 /******************************<->*************************************
242 * WmReturnIdentity (argc, argv, environ)
247 * This function checks the last component of the (path)name
248 * contained in argv[0] and makes a global decision as to whether
249 * it should fetch resources as mwm or dtwm.
253 * argc = number of command line arguments (+1)
255 * argv = window manager command line arguments
257 * environ = window manager environment
259 ******************************<->***********************************/
261 int WmReturnIdentity ( int argc, char *argv[], char *environ[])
266 /* assume it's dtwm until proven differently */
271 (char *)(XtMalloc ((unsigned int)(strlen (argv[0]) + 1)))))
273 Warning(((char *)GETMESSAGE(44, 2, "Insufficient memory for name of window manager")));
274 exit(WM_ERROR_EXIT_VALUE);
277 origPtr = tempString;
279 if (strrchr(argv[0], '/'))
282 strcpy(tempString, (strrchr(argv[0], '/')));
287 strcpy(tempString, argv[0]);
289 if (!(strcmp(tempString, WM_RESOURCE_NAME)))
292 * If it's explicity "mwm", then set our identity anew.
299 XtFree((char *)origPtr);
303 } /* END OF FUNCTION WmReturnIdentity */
306 /************************* eof ******************************/