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
60 #include "WmBackdrop.h"
65 * Function Declarations:
68 int WmReturnIdentity (int argc, char *argv[], char *environ[]);
69 #define ManagedRoot(w) (!XFindContext (DISPLAY, (w), wmGD.screenContextType, \
70 (caddr_t *)&pSD) ? (SetActiveScreen (pSD), True) : \
71 (IsBackdropWindow (ACTIVE_PSD, (w))))
73 #define ManagedRoot(w) (!XFindContext (DISPLAY, (w), wmGD.screenContextType, \
74 (caddr_t *)&pSD) ? (SetActiveScreen (pSD), True) : False)
84 #ifndef NO_MESSAGE_CATALOG
93 /*************************************<->*************************************
95 * main (argc, argv, environ)
100 * This is the main window manager function. It calls window manager
101 * initializtion functions and has the main event processing loop.
106 * argc = number of command line arguments (+1)
108 * argv = window manager command line arguments
110 * environ = window manager environment
112 *************************************<->***********************************/
115 main (int argc, char *argv [], char *environ [])
118 Boolean dispatchEvent;
120 setlocale(LC_ALL, "");
125 * Set up environment variables for this HP DT client
127 _DtEnvControl(DT_ENV_SET);
130 * Force LANG lookup early.
131 * (Front end may change $LANG to 'C' as part
132 * of string space reduction optimization.)
135 char * foo = ((char *)GETMESSAGE(44, 1, ""));
138 XtSetLanguageProc (NULL, (XtLanguageProc)NULL, NULL);
144 WmIdentity = WmReturnIdentity(argc, argv, environ);
148 * Initialize the workspace:
151 InitWmGlobal (argc, argv, environ);
155 * Set up PATH variable if it must run as standalone command
160 _DtEnvControl(DT_ENV_SET_BIN);
165 * MAIN EVENT HANDLING LOOP:
170 XtAppNextEvent (wmGD.mwmAppContext, &event);
174 * Check for, and process non-widget events. The events may be
175 * reported to the root window, to some client frame window,
176 * to an icon window, or to a "special" window management window.
177 * The lock modifier is "filtered" out for window manager processing.
180 wmGD.attributesWindow = 0L;
183 if ((event.type == ButtonPress) ||
184 (event.type == ButtonRelease))
186 if ((wmGD.evLastButton.button != 0) &&
187 ReplayedButtonEvent (&(wmGD.evLastButton),
190 wmGD.bReplayedButton = True;
194 /* save this button for next comparison */
195 memcpy (&wmGD.evLastButton, &event, sizeof (XButtonEvent));
196 wmGD.bReplayedButton = False;
200 dispatchEvent = True;
204 * Do special menu event preprocessing.
207 if (wmGD.checkHotspot || wmGD.menuUnpostKeySpec ||
208 wmGD.menuActive->accelKeySpecs)
210 dispatchEvent = WmDispatchMenuEvent ((XButtonEvent *) &event);
216 if (ManagedRoot(event.xany.window))
218 dispatchEvent = WmDispatchWsEvent (&event);
222 dispatchEvent = WmDispatchClientEvent (&event);
228 * Dispatch widget related event:
231 XtDispatchEvent (&event);
236 } /* END OF FUNCTION main */
239 /******************************<->*************************************
241 * WmReturnIdentity (argc, argv, environ)
246 * This function checks the last component of the (path)name
247 * contained in argv[0] and makes a global decision as to whether
248 * it should fetch resources as mwm or dtwm.
252 * argc = number of command line arguments (+1)
254 * argv = window manager command line arguments
256 * environ = window manager environment
258 ******************************<->***********************************/
260 int WmReturnIdentity ( int argc, char *argv[], char *environ[])
265 /* assume it's dtwm until proven differently */
270 (char *)(XtMalloc ((unsigned int)(strlen (argv[0]) + 1)))))
272 Warning(((char *)GETMESSAGE(44, 2, "Insufficient memory for name of window manager")));
273 exit(WM_ERROR_EXIT_VALUE);
276 origPtr = tempString;
278 if (strrchr(argv[0], '/'))
281 strcpy(tempString, (strrchr(argv[0], '/')));
286 strcpy(tempString, argv[0]);
288 if (!(strcmp(tempString, WM_RESOURCE_NAME)))
291 * If it's explicity "mwm", then set our identity anew.
298 XtFree((char *)origPtr);
302 } /* END OF FUNCTION WmReturnIdentity */
305 /************************* eof ******************************/