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 libraries 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.
31 * (c) Copyright 1987, 1988, 1989, 1990 HEWLETT-PACKARD COMPANY */
40 #include <Dt/Message.h>
41 #include <Dt/EnvControlP.h>
43 * include extern functions
51 #include "WmBackdrop.h"
55 * Function Declarations:
57 int WmReturnIdentity (int argc, char *argv[], char *environ[]);
58 #define ManagedRoot(w) (!XFindContext (DISPLAY, (w), wmGD.screenContextType, \
59 (caddr_t *)&pSD) ? (SetActiveScreen (pSD), True) : \
60 (IsBackdropWindow (ACTIVE_PSD, (w))))
69 #ifndef NO_MESSAGE_CATALOG
76 /*************************************<->*************************************
78 * main (argc, argv, environ)
83 * This is the main window manager function. It calls window manager
84 * initializtion functions and has the main event processing loop.
89 * argc = number of command line arguments (+1)
91 * argv = window manager command line arguments
93 * environ = window manager environment
95 *************************************<->***********************************/
98 main (int argc, char *argv [], char *environ [])
101 Boolean dispatchEvent;
103 setlocale(LC_ALL, "");
106 * Set up environment variables for this HP DT client
108 _DtEnvControl(DT_ENV_SET);
111 * Force LANG lookup early.
112 * (Front end may change $LANG to 'C' as part
113 * of string space reduction optimization.)
116 char * foo = ((char *)GETMESSAGE(44, 1, ""));
118 XtSetLanguageProc (NULL, (XtLanguageProc)NULL, NULL);
123 WmIdentity = WmReturnIdentity(argc, argv, environ);
126 * Initialize the workspace:
129 InitWmGlobal (argc, argv, environ);
132 * Set up PATH variable if it must run as standalone command
137 _DtEnvControl(DT_ENV_SET_BIN);
141 * MAIN EVENT HANDLING LOOP:
146 XtAppNextEvent (wmGD.mwmAppContext, &event);
150 * Check for, and process non-widget events. The events may be
151 * reported to the root window, to some client frame window,
152 * to an icon window, or to a "special" window management window.
153 * The lock modifier is "filtered" out for window manager processing.
156 wmGD.attributesWindow = 0L;
158 if ((event.type == ButtonPress) ||
159 (event.type == ButtonRelease))
161 if ((wmGD.evLastButton.button != 0) &&
162 ReplayedButtonEvent (&(wmGD.evLastButton),
165 wmGD.bReplayedButton = True;
169 /* save this button for next comparison */
170 memcpy (&wmGD.evLastButton, &event, sizeof (XButtonEvent));
171 wmGD.bReplayedButton = False;
174 dispatchEvent = True;
178 * Do special menu event preprocessing.
181 if (wmGD.checkHotspot || wmGD.menuUnpostKeySpec ||
182 wmGD.menuActive->accelKeySpecs)
184 dispatchEvent = WmDispatchMenuEvent ((XButtonEvent *) &event);
190 if (ManagedRoot(event.xany.window))
192 dispatchEvent = WmDispatchWsEvent (&event);
196 dispatchEvent = WmDispatchClientEvent (&event);
202 * Dispatch widget related event:
205 XtDispatchEvent (&event);
210 } /* END OF FUNCTION main */
212 /******************************<->*************************************
214 * WmReturnIdentity (argc, argv, environ)
219 * This function checks the last component of the (path)name
220 * contained in argv[0] and makes a global decision as to whether
221 * it should fetch resources as mwm or dtwm.
225 * argc = number of command line arguments (+1)
227 * argv = window manager command line arguments
229 * environ = window manager environment
231 ******************************<->***********************************/
233 int WmReturnIdentity ( int argc, char *argv[], char *environ[])
238 /* assume it's dtwm until proven differently */
243 (char *)(XtMalloc ((unsigned int)(strlen (argv[0]) + 1)))))
245 Warning(((char *)GETMESSAGE(44, 2, "Insufficient memory for name of window manager")));
246 exit(WM_ERROR_EXIT_VALUE);
249 origPtr = tempString;
251 if (strrchr(argv[0], '/'))
254 strcpy(tempString, (strrchr(argv[0], '/')));
259 strcpy(tempString, argv[0]);
261 if (!(strcmp(tempString, WM_RESOURCE_NAME)))
264 * If it's explicity "mwm", then set our identity anew.
271 XtFree((char *)origPtr);
275 } /* END OF FUNCTION WmReturnIdentity */
277 /************************* eof ******************************/