1 /*****************************************************************************/
2 /** Copyright 1988 by Evans & Sutherland Computer Corporation, **/
3 /** Salt Lake City, Utah **/
4 /** Portions Copyright 1989 by the Massachusetts Institute of Technology **/
5 /** Cambridge, Massachusetts **/
7 /** All Rights Reserved **/
9 /** Permission to use, copy, modify, and distribute this software and **/
10 /** its documentation for any purpose and without fee is hereby **/
11 /** granted, provided that the above copyright notice appear in all **/
12 /** copies and that both that copyright notice and this permis- **/
13 /** sion notice appear in supporting documentation, and that the **/
14 /** names of Evans & Sutherland and M.I.T. not be used in advertising **/
15 /** in publicity pertaining to distribution of the software without **/
16 /** specific, written prior permission. **/
18 /** EVANS & SUTHERLAND AND M.I.T. DISCLAIM ALL WARRANTIES WITH REGARD **/
19 /** TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT- **/
20 /** ABILITY AND FITNESS, IN NO EVENT SHALL EVANS & SUTHERLAND OR **/
21 /** M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAM- **/
22 /** AGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA **/
23 /** OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER **/
24 /** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE **/
25 /** OR PERFORMANCE OF THIS SOFTWARE. **/
26 /*****************************************************************************/
29 /***********************************************************************
31 * $XConsortium: twm.c,v 1.124 91/05/08 11:01:54 dave Exp $
33 * twm - "Tom's Window Manager"
35 * 27-Oct-87 Thomas E. LaStrange File created
36 * 10-Oct-90 David M. Sternlicht Storing saved colors on root
37 ***********************************************************************/
42 #include <unistd.h> /* for sleep() */
46 #include "add_window.h"
58 #ifndef NO_SOUND_SUPPORT
61 #include <X11/Xresource.h>
62 #include <X11/Xproto.h>
63 #include <X11/Xatom.h>
64 #include <X11/Xmu/Error.h>
66 #ifndef NO_I18N_SUPPORT
67 #include <X11/Xlocale.h>
70 Display *dpy; /* which display are we talking to */
71 Window ResizeWindow; /* the window we are resizing */
73 int MultiScreen = TRUE; /* try for more than one screen? */
74 int NumScreens; /* number of screens in ScreenList */
75 int HasShape; /* server supports shape extension? */
76 int ShapeEventBase, ShapeErrorBase;
77 ScreenInfo **ScreenList; /* structures for each screen */
78 ScreenInfo *Scr = NULL; /* the cur and prev screens */
79 int PreviousScreen; /* last screen that we were on */
80 int FirstScreen; /* TRUE ==> first screen of display */
81 Bool PrintPID = False; /* controls PID file - djhjr - 12/2/01 */
82 Bool PrintErrorMessages = False; /* controls error messages */
83 static int RedirectError; /* TRUE ==> another window manager running */
84 static int CatchRedirectError(); /* for settting RedirectError */
85 static int TwmErrorHandler(); /* for everything else */
87 void InternUsefulAtoms();
89 char Info[INFO_LINES][INFO_SIZE]; /* info strings to print */
92 char *InitFile = NULL;
93 int parseInitFile = TRUE; /* djhjr - 10/7/02 */
95 Cursor UpperLeftCursor; /* upper Left corner cursor */
100 XContext TwmContext; /* context for twm windows */
101 XContext MenuContext; /* context for all menu windows */
102 XContext IconManagerContext; /* context for all window list windows */
103 XContext VirtualContext; /* context for all desktop display windows */
104 XContext ScreenContext; /* context to get screen data */
105 XContext ColormapContext; /* context for colormap operations */
106 XContext DoorContext; /* context for doors */
108 XClassHint NoClass; /* for applications with no class */
112 char *Home; /* the HOME environment variable */
113 int HomeLen; /* length of Home */
114 int ParseError; /* error parsing the .twmrc file */
116 int HandlingEvents = FALSE; /* are we handling events yet? */
118 Window JunkRoot; /* junk window */
119 Window JunkChild; /* junk window */
120 int JunkX; /* junk variable */
121 int JunkY; /* junk variable */
122 unsigned int JunkWidth, JunkHeight, JunkBW, JunkDepth, JunkMask;
124 char *ProgramName, *PidName = "vtwm.pid"; /* PID file - djhjr - 12/2/01 */
129 Bool RestartPreviousState = False; /* try to restart in previous state */
131 unsigned long black, white;
133 /* djhjr - 9/14/03 */
134 #ifndef NO_I18N_SUPPORT
138 extern void assign_var_savecolor();
140 /* djhjr - 4/26/99 */
141 extern void FreeRegions();
143 /***********************************************************************
146 * main - start of twm
148 ***********************************************************************
151 /* Changes for m4 pre-processing submitted by Jason Gloudon */
153 main(argc, argv, environ)
158 Window root, parent, *children;
159 unsigned int nchildren;
161 char *def, *display_name = NULL;
162 unsigned long valuemask; /* mask for create windows */
163 XSetWindowAttributes attributes; /* attributes for create windows */
164 int numManaged, firstscrn, lastscrn, scrnum;
165 extern ColormapWindow *CreateColormapWindow();
166 #ifndef NO_M4_SUPPORT
167 int m4_preprocess = False; /* filter the *twmrc file through m4 */
168 char *m4_option = NULL; /* pass these options to m4 - djhjr - 2/20/98 */
170 /* djhjr - 6/22/01 */
171 #ifndef NO_SOUND_SUPPORT
174 extern char *defTwmrc[]; /* djhjr - 10/7/02 */
175 /* djhjr - 9/14/03 */
176 #ifndef NO_I18N_SUPPORT
180 /* djhjr - 7/21/98 */
181 SIGNAL_T QueueRestartVtwm();
183 if ((ProgramName = strrchr(argv[0], '/')))
186 ProgramName = argv[0];
191 for (i = 1; i < argc; i++) {
192 if (argv[i][0] == '-') {
193 switch (argv[i][1]) {
194 case 'd': /* -display display */
195 if (++i >= argc) goto usage;
196 display_name = argv[i];
198 case 'f': /* -file [initfile] */
199 /* this isn't really right, but hey... - djhjr - 10/7/02 */
201 (argv[i + 1][0] != '-' ||
202 (argv[i + 1][0] == '-' && !strchr("dfmpsv", argv[i + 1][1]))))
203 InitFile = argv[++i];
205 parseInitFile = FALSE;
207 #ifndef NO_M4_SUPPORT
208 case 'm': /* -m4 [options] */
209 m4_preprocess = True;
210 /* this isn't really right, but hey... - djhjr - 2/20/98 */
212 (argv[i + 1][0] != '-' ||
213 (argv[i + 1][0] == '-' && !strchr("dfmpsv", argv[i + 1][1]))))
214 m4_option = argv[++i];
217 case 'p': /* -pidfile - djhjr - 12/2/01 */
220 case 's': /* -single */
223 case 'v': /* -verbose */
224 PrintErrorMessages = True;
226 #ifdef NEVER /* djhjr - 2/20/99 */
227 case 'q': /* -quiet */
228 PrintErrorMessages = False;
235 #ifndef NO_M4_SUPPORT
236 "usage: %s [-d display] [-f [initfile]] [-m [options]] [-p] [-s] [-v]\n",
238 "usage: %s [-d display] [-f [initfile]] [-p] [-s] [-v]\n",
244 /* djhjr - 9/14/03 */
245 #ifndef NO_I18N_SUPPORT
246 loc = setlocale(LC_ALL, "");
247 if (!loc || !strcmp(loc, "C") || !strcmp(loc, "POSIX") ||
253 if (PrintErrorMessages)
254 fprintf(stderr, "%s: I18N supported, L10N %sabled\n",
255 ProgramName, (use_fontset) ? "en" : "dis");
258 /* djhjr - 6/22/01 */
259 #ifndef NO_SOUND_SUPPORT
260 #define sounddonehandler(sig) \
261 if (signal (sig, SIG_IGN) != SIG_IGN) (void) signal (sig, PlaySoundDone)
263 #define sounddonehandler(sig) \
264 if (signal (sig, SIG_IGN) != SIG_IGN) (void) signal (sig, Done)
266 #define donehandler(sig) \
267 if (signal (sig, SIG_IGN) != SIG_IGN) (void) signal (sig, Done)
269 sounddonehandler (SIGINT);
270 sounddonehandler (SIGHUP);
271 sounddonehandler (SIGQUIT);
272 sounddonehandler (SIGTERM);
274 /* djhjr - 12/2/01 */
275 donehandler (SIGABRT);
276 donehandler (SIGFPE);
277 donehandler (SIGSEGV);
278 donehandler (SIGILL);
279 donehandler (SIGTSTP);
280 donehandler (SIGPIPE);
281 #undef sounddonehandler
284 /* djhjr - 7/31/98 */
285 signal (SIGUSR1, QueueRestartVtwm);
287 Home = getenv("HOME");
291 HomeLen = strlen(Home);
293 NoClass.res_name = NoName;
294 NoClass.res_class = NoName;
296 if (!(dpy = XOpenDisplay(display_name))) {
297 fprintf (stderr, "%s: unable to open display \"%s\"\n",
298 ProgramName, XDisplayName(display_name));
302 if (fcntl(ConnectionNumber(dpy), F_SETFD, 1) == -1) {
304 "%s: unable to mark display connection as close-on-exec\n",
309 HasShape = XShapeQueryExtension (dpy, &ShapeEventBase, &ShapeErrorBase);
310 TwmContext = XUniqueContext();
311 MenuContext = XUniqueContext();
312 IconManagerContext = XUniqueContext();
313 VirtualContext = XUniqueContext();
314 ScreenContext = XUniqueContext();
315 ColormapContext = XUniqueContext();
316 DoorContext = XUniqueContext();
318 InternUsefulAtoms ();
321 /* Set up the per-screen global information. */
323 NumScreens = ScreenCount(dpy);
328 lastscrn = NumScreens - 1;
332 firstscrn = lastscrn = DefaultScreen(dpy);
337 /* for simplicity, always allocate NumScreens ScreenInfo struct pointers */
338 ScreenList = (ScreenInfo **) calloc (NumScreens, sizeof (ScreenInfo *));
339 if (ScreenList == NULL)
341 fprintf (stderr, "%s: Unable to allocate memory for screen list, exiting.\n",
346 PreviousScreen = DefaultScreen(dpy);
348 for (scrnum = firstscrn ; scrnum <= lastscrn; scrnum++)
350 /* Make sure property priority colors is empty */
351 XChangeProperty (dpy, RootWindow(dpy, scrnum), _XA_MIT_PRIORITY_COLORS,
352 XA_CARDINAL, 32, PropModeReplace, NULL, 0);
353 RedirectError = FALSE;
354 XSetErrorHandler(CatchRedirectError);
355 XSelectInput(dpy, RootWindow (dpy, scrnum),
356 ColormapChangeMask | EnterWindowMask | PropertyChangeMask |
357 SubstructureRedirectMask | KeyPressMask |
358 ButtonPressMask | ButtonReleaseMask);
360 XSetErrorHandler(TwmErrorHandler);
364 fprintf (stderr, "%s: another window manager is already running",
366 if (MultiScreen && NumScreens > 0)
367 fprintf(stderr, " on screen %d?\n", scrnum);
369 fprintf(stderr, "?\n");
375 /* Note: ScreenInfo struct is calloc'ed to initialize to zero. */
376 Scr = ScreenList[scrnum] =
377 (ScreenInfo *) calloc(1, sizeof(ScreenInfo));
380 fprintf (stderr, "%s: unable to allocate memory for ScreenInfo structure for screen %d.\n",
381 ProgramName, scrnum);
385 /* initialize list pointers, remember to put an initialization
386 * in InitVariables also
388 Scr->BorderColorL = NULL;
389 Scr->IconBorderColorL = NULL;
390 Scr->BorderTileForegroundL = NULL;
391 Scr->BorderTileBackgroundL = NULL;
392 Scr->TitleForegroundL = NULL;
393 Scr->TitleBackgroundL = NULL;
394 Scr->IconForegroundL = NULL;
395 Scr->IconBackgroundL = NULL;
397 Scr->MakeTitle = NULL;
398 Scr->AutoRaise = NULL;
399 Scr->IconNames = NULL;
400 Scr->NoHighlight = NULL;
401 Scr->NoStackModeL = NULL;
402 Scr->NoTitleHighlight = NULL;
403 Scr->DontIconify = NULL;
404 Scr->IconMgrNoShow = NULL;
405 Scr->IconMgrShow = NULL;
406 Scr->IconifyByUn = NULL;
407 Scr->IconManagerFL = NULL;
408 Scr->IconManagerBL = NULL;
409 Scr->IconMgrs = NULL;
410 Scr->StartIconified = NULL;
411 Scr->SqueezeTitleL = NULL;
412 Scr->DontSqueezeTitleL = NULL;
413 Scr->WindowRingL = NULL;
415 /* submitted by Jonathan Paisley - 10/27/02 */
416 Scr->NoWindowRingL = NULL;
418 Scr->WarpCursorL = NULL;
420 /* djhjr - 4/22/96 */
421 Scr->ImageCache = NULL;
424 Scr->OpaqueMoveL = NULL;
425 Scr->NoOpaqueMoveL = NULL;
426 Scr->OpaqueResizeL = NULL;
427 Scr->NoOpaqueResizeL = NULL;
430 Scr->NoBorder = NULL;
432 /* djhjr - 9/24/02 */
433 Scr->UsePPositionL = NULL;
435 /* remember to put an initialization in InitVariables also
438 Scr->screen = scrnum;
439 Scr->d_depth = DefaultDepth(dpy, scrnum);
440 Scr->d_visual = DefaultVisual(dpy, scrnum);
441 Scr->Root = RootWindow(dpy, scrnum);
442 XSaveContext (dpy, Scr->Root, ScreenContext, (caddr_t) Scr);
444 /* djhjr - 1/31/99 */
445 if ((def = XGetDefault(dpy, "*", "bitmapFilePath")))
446 Scr->BitmapFilePath = strdup(def);
448 Scr->BitmapFilePath = NULL;
450 Scr->TwmRoot.cmaps.number_cwins = 1;
451 Scr->TwmRoot.cmaps.cwins =
452 (ColormapWindow **) malloc(sizeof(ColormapWindow *));
453 Scr->TwmRoot.cmaps.cwins[0] =
454 CreateColormapWindow(Scr->Root, True, False);
455 Scr->TwmRoot.cmaps.cwins[0]->visibility = VisibilityPartiallyObscured;
457 Scr->cmapInfo.cmaps = NULL;
458 Scr->cmapInfo.maxCmaps =
459 MaxCmapsOfScreen(ScreenOfDisplay(dpy, Scr->screen));
460 Scr->cmapInfo.root_pushes = 0;
461 InstallWindowColormaps(0, &Scr->TwmRoot);
463 Scr->StdCmapInfo.head = Scr->StdCmapInfo.tail =
464 Scr->StdCmapInfo.mru = NULL;
465 Scr->StdCmapInfo.mruindex = 0;
466 LocateStandardColormaps();
468 Scr->TBInfo.nleft = Scr->TBInfo.nright = 0;
469 Scr->TBInfo.head = NULL;
472 Scr->TBInfo.border = 1;
474 Scr->TBInfo.border = -100;
476 Scr->TBInfo.width = 0;
477 Scr->TBInfo.leftx = 0;
478 Scr->TBInfo.titlex = 0;
480 Scr->MyDisplayWidth = DisplayWidth(dpy, scrnum);
481 Scr->MyDisplayHeight = DisplayHeight(dpy, scrnum);
482 Scr->MaxWindowWidth = 32767 - Scr->MyDisplayWidth;
483 Scr->MaxWindowHeight = 32767 - Scr->MyDisplayHeight;
485 Scr->XORvalue = (((unsigned long) 1) << Scr->d_depth) - 1;
487 if (DisplayCells(dpy, scrnum) < 3)
488 Scr->Monochrome = MONOCHROME;
490 Scr->Monochrome = COLOR;
492 /* setup default colors */
493 Scr->FirstTime = TRUE;
494 GetColor(Scr->Monochrome, &black, "black");
496 GetColor(Scr->Monochrome, &white, "white");
501 SetFocus ((TwmWindow *)NULL, CurrentTime);
505 NewFontCursor(&UpperLeftCursor, "top_left_corner");
506 NewFontCursor(&RightButt, "rightbutton");
507 NewFontCursor(&LeftButt, "leftbutton");
508 NewFontCursor(&MiddleButt, "middlebutton");
513 Scr->iconmgr.width = 150;
514 Scr->iconmgr.height = 5;
515 Scr->iconmgr.next = NULL;
516 Scr->iconmgr.prev = NULL;
517 Scr->iconmgr.lasti = &(Scr->iconmgr);
518 Scr->iconmgr.first = NULL;
519 Scr->iconmgr.last = NULL;
520 Scr->iconmgr.active = NULL;
521 Scr->iconmgr.scr = Scr;
522 Scr->iconmgr.columns = 1;
523 Scr->iconmgr.count = 0;
524 Scr->iconmgr.name = "VTWM";
525 Scr->iconmgr.icon_name = "Icons";
527 Scr->IconDirectory = NULL;
529 /* djhjr - 10/30/02 */
530 Scr->hiliteName = NULL;
531 Scr->menuIconName = TBPM_MENU;
532 Scr->iconMgrIconName = TBPM_XLOGO;
535 Scr->siconifyPm = NULL;
539 /* djhjr - 5/17/98 */
540 #ifdef ORIGINAL_PIXMAPS
541 Scr->hilitePm = None;
542 Scr->virtualPm = None; /* RFB PIXMAP */
543 Scr->RealScreenPm = None; /* RFB PIXMAP */
544 #else /* ORIGINAL_PIXMAPS */
545 /* djhjr - 10/25/02 */
546 Scr->hiliteName = NULL;
548 Scr->hilitePm = NULL;
549 Scr->virtualPm = NULL;
550 Scr->realscreenPm = NULL;
551 #endif /* ORIGINAL_PIXMAPS */
553 if ( Scr->FirstTime )
554 { /* retain max size on restart. */
555 Scr->VirtualDesktopMaxWidth = 0;
556 Scr->VirtualDesktopMaxHeight = 0;
562 /* added this 'if (...) else' - djhjr - 10/7/02 */
564 ParseStringList(defTwmrc);
567 /* Parse it once for each screen. */
568 #ifndef NO_M4_SUPPORT
569 /* added 'm4_option' - djhjr - 2/20/99 */
570 ParseTwmrc(InitFile, display_name, m4_preprocess, m4_option);
572 ParseTwmrc(InitFile);
576 /* djhjr - 6/22/01 */
577 #ifndef NO_SOUND_SUPPORT
580 if (PlaySound(S_START))
583 * Save setting from resource file, and turn sound off
585 sound_state = ToggleSounds();
587 if (sound_state == 0) ToggleSounds();
591 assign_var_savecolor(); /* storeing pixels for twmrc "entities" */
593 /* djhjr - 10/17/02 */
595 /* djhjr - 4/19/96 */
596 /* was 'Scr->use3Dtitles' - djhjr - 8/11/98 */
597 if (Scr->TitleBevelWidth > 0) {
599 if (Scr->TBInfo.border == -100) Scr->TBInfo.border = 0;
603 if (Scr->ButtonIndent == -100) Scr->ButtonIndent = 0;
604 if (Scr->FramePadding == -100) Scr->FramePadding = 0;
605 if (Scr->TitlePadding == -100) Scr->TitlePadding = 0;
607 Scr->ButtonIndent = 0;
608 Scr->FramePadding = 0;
609 Scr->TitlePadding = 0;
613 if (Scr->SunkFocusWindowTitle) Scr->TitleHighlight = FALSE;
618 Scr->SunkFocusWindowTitle = FALSE;
622 /* was only if Scr->TitleBevelWidth == 0 - djhjr - 10/17/02 */
623 if (Scr->FramePadding == -100) Scr->FramePadding = 2; /* values that look */
624 if (Scr->TitlePadding == -100) Scr->TitlePadding = 8; /* "nice" on */
625 if (Scr->ButtonIndent == -100) Scr->ButtonIndent = 1; /* 75 and 100dpi displays */
626 if (Scr->TBInfo.border == -100) Scr->TBInfo.border = 1;
628 /* was 'Scr->use3D*' - djhjr - 8/11/98 */
629 /* rem'd 'Scr->*BevelWidth > 0' - djhjr - 10/30/02 */
630 if (/*Scr->TitleBevelWidth > 0 && */!Scr->BeNiceToColormap) GetShadeColors (&Scr->TitleC);
631 if (/*Scr->MenuBevelWidth > 0 && */!Scr->BeNiceToColormap) GetShadeColors (&Scr->MenuC);
632 if (Scr->MenuBevelWidth > 0 && !Scr->BeNiceToColormap) GetShadeColors (&Scr->MenuTitleC);
633 if (Scr->BorderBevelWidth > 0 && !Scr->BeNiceToColormap) GetShadeColors (&Scr->BorderColorC);
636 if (Scr->DoorBevelWidth > 0 && !Scr->BeNiceToColormap) GetShadeColors (&Scr->DoorC);
637 if (Scr->VirtualDesktopBevelWidth > 0 && !Scr->BeNiceToColormap) GetShadeColors (&Scr->VirtualC);
640 * was 'Scr->use3Dborders' - djhjr - 8/11/98 *
641 if (Scr->BorderBevelWidth == 0)
642 Scr->ThreeDBorderWidth = 0;
648 if (2 * Scr->BorderBevelWidth > Scr->ThreeDBorderWidth)
649 Scr->ThreeDBorderWidth = 2 * Scr->BorderBevelWidth;
651 if (2 * Scr->BorderBevelWidth > Scr->BorderWidth)
652 Scr->BorderWidth = 2 * Scr->BorderBevelWidth;
654 if (!Scr->BeNiceToColormap)
655 GetShadeColors(&Scr->DefaultC);
659 /* was 'Scr->use3Dicons' - djhjr - 8/11/98 */
660 if (Scr->IconBevelWidth > 0)
661 Scr->IconBorderWidth = 0;
663 if (Scr->SqueezeTitle == -1) Scr->SqueezeTitle = FALSE;
664 if (!Scr->HaveFonts) CreateFonts();
668 /* djhjr - 10/18/02 */
671 * Set titlebar height from font height and padding,
672 * then adjust to titlebutton height - djhjr - 12/10/98
674 Scr->TitleBarFont.y += Scr->FramePadding;
675 i = Scr->TitleBarFont.height;
678 Scr->TitleBarFont.y += (i - Scr->TitleBarFont.height) / 2;
679 Scr->TitleHeight = i + Scr->FramePadding * 2;
683 if (Scr->use3Dtitles) Scr->TitleHeight += 4;
686 * was 'Scr->use3Dtitles' - djhjr - 8/11/98 *
687 if (Scr->TitleBevelWidth > 0)
688 Scr->TitleHeight += 2 * Scr->TitleBevelWidth + 2;
691 /* make title height be odd so buttons look nice and centered */
692 if (!(Scr->TitleHeight & 1)) Scr->TitleHeight++;
693 } while ((i = InitTitlebarButtons()) > Scr->TitleHeight - Scr->FramePadding * 2);
695 /* set titlebar height to font height plus frame padding */
696 Scr->TitleHeight = Scr->TitleBarFont.height + Scr->FramePadding * 2;
697 if (!(Scr->TitleHeight & 1)) Scr->TitleHeight++;
699 i = InitTitlebarButtons(); /* returns the button height */
701 /* adjust titlebar height to button height */
702 if (i > Scr->TitleHeight) Scr->TitleHeight = i + Scr->FramePadding * 2;
703 if (!(Scr->TitleHeight & 1)) Scr->TitleHeight++;
705 /* adjust font baseline */
706 Scr->TitleBarFont.y += ((Scr->TitleHeight - Scr->TitleBarFont.height) / 2);
715 XQueryTree(dpy, Scr->Root, &root, &parent, &children, &nchildren);
716 CreateIconManagers();
717 if (!Scr->NoIconManagers)
718 Scr->iconmgr.twm_win->icon = TRUE;
720 if (Scr->VirtualDesktopWidth > 0)
721 CreateDesktopDisplay();
723 /* create all of the door windows */
727 * weed out icon windows
729 for (i = 0; i < nchildren; i++) {
731 XWMHints *wmhintsp = XGetWMHints (dpy, children[i]);
734 if (wmhintsp->flags & IconWindowHint) {
735 for (j = 0; j < nchildren; j++) {
736 if (children[j] == wmhintsp->icon_window) {
742 XFree ((char *) wmhintsp);
748 * map all of the non-override windows
750 for (i = 0; i < nchildren; i++)
752 if (children[i] && MappedNotOverride(children[i]))
754 XUnmapWindow(dpy, children[i]);
755 SimulateMapRequest(children[i]);
759 if (Scr->ShowIconManager && !Scr->NoIconManagers)
761 Scr->iconmgr.twm_win->icon = FALSE;
762 if (Scr->iconmgr.count)
764 SetMapStateProp (Scr->iconmgr.twm_win, NormalState);
765 XMapWindow(dpy, Scr->iconmgr.w);
766 XMapWindow(dpy, Scr->iconmgr.twm_win->frame);
771 /* was 'Scr->use3Dborders' - djhjr - 8/11/98 */
772 if (!Scr->BorderBevelWidth > 0)
773 attributes.border_pixel = Scr->DefaultC.fore;
775 attributes.background_pixel = Scr->DefaultC.back;
776 attributes.event_mask = (ExposureMask | ButtonPressMask |
777 KeyPressMask | ButtonReleaseMask);
778 attributes.backing_store = NotUseful;
780 #ifdef ORIGINAL_INFOCURSOR
781 attributes.cursor = XCreateFontCursor (dpy, Scr->WaitCursor);
784 /* was 'Scr->use3Dborders' - djhjr - 8/11/98 */
785 if (!Scr->BorderBevelWidth > 0)
786 valuemask = (CWBorderPixel | CWBackPixel | CWEventMask |
787 CWBackingStore | CWCursor);
789 valuemask = (CWBackPixel | CWEventMask | CWBackingStore | CWCursor);
793 /* was 'Scr->use3Dborders' - djhjr - 8/11/98 */
794 if (!Scr->BorderBevelWidth > 0)
795 valuemask = (CWBorderPixel | CWBackPixel | CWEventMask |
798 valuemask = (CWBackPixel | CWEventMask | CWBackingStore);
801 Scr->InfoWindow = XCreateWindow (dpy, Scr->Root, 0, 0,
802 (unsigned int) 5, (unsigned int) 5,
805 /* was 'Scr->use3Dborders' - djhjr - 8/11/98 */
806 (unsigned int) (Scr->InfoBevelWidth > 0) ? 0 : BW, 0,
808 (unsigned int) CopyFromParent,
809 (Visual *) CopyFromParent,
810 valuemask, &attributes);
812 /* djhjr - 9/14/03 */
813 #ifndef NO_I18N_SUPPORT
814 Scr->SizeStringWidth = MyFont_TextWidth (&Scr->SizeFont,
816 Scr->SizeStringWidth = XTextWidth (Scr->SizeFont.font,
819 " 8888 x 8888 ", 13);
822 "nnnnnnnnnnnnn", 13);
824 /* was 'Scr->use3Dborders' - djhjr - 8/11/98 */
825 "nnnnnnnnnnnnn", 13) + ((Scr->InfoBevelWidth > 0) ? 2 * Scr->InfoBevelWidth : 0);
828 /* was 'Scr->use3Dborders' - djhjr - 8/11/98 */
829 if (!Scr->InfoBevelWidth > 0)
830 valuemask = (CWBorderPixel | CWBackPixel | CWBitGravity);
832 valuemask = (CWBackPixel | CWBitGravity);
834 /* djhjr - 5/15/96 */
835 switch (Scr->ResizeX)
842 Scr->ResizeX = (Scr->MyDisplayWidth - Scr->SizeStringWidth) - 20;
847 Scr->ResizeY = (Scr->MyDisplayHeight - (Scr->SizeFont.height + SIZE_VINDENT*2)) - 20;
850 Scr->ResizeX = (Scr->MyDisplayWidth - Scr->SizeStringWidth) - 20;
851 Scr->ResizeY = (Scr->MyDisplayHeight - (Scr->SizeFont.height + SIZE_VINDENT*2)) - 20;
854 Scr->ResizeX = (Scr->MyDisplayWidth - Scr->SizeStringWidth) / 2;
855 Scr->ResizeY = (Scr->MyDisplayHeight - (Scr->SizeFont.height + SIZE_VINDENT*2)) / 2;
859 attributes.bit_gravity = NorthWestGravity;
860 Scr->SizeWindow = XCreateWindow (dpy, Scr->Root,
865 Scr->ResizeX, Scr->ResizeY,
867 (unsigned int) Scr->SizeStringWidth,
870 (unsigned int) (Scr->SizeFont.height + SIZE_VINDENT*2),
872 /* was 'Scr->use3Dborders' - djhjr - 8/11/98 */
873 (unsigned int) (Scr->SizeFont.height + SIZE_VINDENT*2) +
874 ((Scr->InfoBevelWidth > 0) ? 2 * Scr->InfoBevelWidth : 0),
877 /* was 'Scr->use3Dborders' - djhjr - 8/11/98 */
878 (unsigned int) (Scr->InfoBevelWidth > 0) ? 0 : BW, 0,
880 (unsigned int) CopyFromParent,
881 (Visual *) CopyFromParent,
882 valuemask, &attributes);
887 Scr->FirstTime = FALSE;
890 if (numManaged == 0) {
891 if (MultiScreen && NumScreens > 0)
892 fprintf (stderr, "%s: unable to find any unmanaged screens\n",
898 RestartPreviousState = False;
899 HandlingEvents = TRUE;
901 RaiseStickyAbove(); /* DSE */
902 RaiseAutoPan(); /* autopan windows should have been raised
903 after [re]starting vtwm -- DSE */
907 /* profile function stuff by DSE */
908 #define VTWM_PROFILE "VTWM Profile"
909 if (FindMenuRoot (VTWM_PROFILE)) {
910 ExecuteFunction (F_FUNCTION, VTWM_PROFILE, Event.xany.window,
911 &Scr->TwmRoot, &Event, C_NO_CONTEXT, FALSE);
914 /* djhjr - 6/22/01 */
915 #ifndef NO_SOUND_SUPPORT
916 /* restore setting from resource file */
917 if (sound_state == 1) ToggleSounds();
921 /* write out a PID file - djhjr - 12/2/01 */
925 char buf[10], *fn = malloc(HomeLen + strlen(PidName) + 2);
927 /* removed group and other permissions - djhjr - 10/20/02 */
928 sprintf(fn, "%s/%s", Home, PidName);
930 O_WRONLY|O_EXCL|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR)) != -1)
932 sprintf(buf, "%d\n", getpid());
933 err = write(fd, buf, strlen(buf));
937 if (fd == -1 || err == -1)
939 fprintf(stderr, "%s: cannot write to %s\n", ProgramName, fn);
951 /***********************************************************************
954 * InitVariables - initialize twm variables
956 ***********************************************************************
961 FreeList(&Scr->BorderColorL);
962 FreeList(&Scr->IconBorderColorL);
963 FreeList(&Scr->BorderTileForegroundL);
964 FreeList(&Scr->BorderTileBackgroundL);
965 FreeList(&Scr->TitleForegroundL);
966 FreeList(&Scr->TitleBackgroundL);
967 FreeList(&Scr->IconForegroundL);
968 FreeList(&Scr->IconBackgroundL);
969 FreeList(&Scr->IconManagerFL);
970 FreeList(&Scr->IconManagerBL);
971 FreeList(&Scr->IconMgrs);
972 FreeList(&Scr->NoTitle);
973 FreeList(&Scr->MakeTitle);
974 FreeList(&Scr->AutoRaise);
975 FreeList(&Scr->IconNames);
976 FreeList(&Scr->NoHighlight);
977 FreeList(&Scr->NoStackModeL);
978 FreeList(&Scr->NoTitleHighlight);
979 FreeList(&Scr->DontIconify);
980 FreeList(&Scr->IconMgrNoShow);
981 FreeList(&Scr->IconMgrShow);
982 FreeList(&Scr->IconifyByUn);
983 FreeList(&Scr->StartIconified);
984 FreeList(&Scr->IconManagerHighlightL);
985 FreeList(&Scr->SqueezeTitleL);
986 FreeList(&Scr->DontSqueezeTitleL);
987 FreeList(&Scr->WindowRingL);
989 /* submitted by Jonathan Paisley - 10/27/02 */
990 FreeList(&Scr->NoWindowRingL);
992 FreeList(&Scr->WarpCursorL);
993 FreeList(&Scr->NailedDown);
994 FreeList(&Scr->VirtualDesktopColorFL);
995 FreeList(&Scr->VirtualDesktopColorBL);
996 FreeList(&Scr->VirtualDesktopColorBoL);
997 FreeList(&Scr->DontShowInDisplay);
999 /* Submitted by Erik Agsjo <erik.agsjo@aktiedirekt.com> */
1000 FreeList(&Scr->DontShowInTWMWindows);
1002 FreeList(&Scr->DoorForegroundL);
1003 FreeList(&Scr->DoorBackgroundL);
1005 /* djhjr - 4/22/96 */
1006 FreeList(&Scr->ImageCache);
1008 /* djhjr - 4/7/98 */
1009 FreeList(&Scr->OpaqueMoveL);
1010 FreeList(&Scr->NoOpaqueMoveL);
1011 FreeList(&Scr->OpaqueResizeL);
1012 FreeList(&Scr->NoOpaqueResizeL);
1014 /* djhjr - 5/2/98 */
1015 FreeList(&Scr->NoBorder);
1017 /* djhjr - 9/24/02 */
1018 FreeList(&Scr->UsePPositionL);
1020 NewFontCursor(&Scr->FrameCursor, "top_left_arrow");
1021 NewFontCursor(&Scr->TitleCursor, "top_left_arrow");
1022 NewFontCursor(&Scr->IconCursor, "top_left_arrow");
1023 NewFontCursor(&Scr->IconMgrCursor, "top_left_arrow");
1024 NewFontCursor(&Scr->MoveCursor, "fleur");
1025 NewFontCursor(&Scr->ResizeCursor, "fleur");
1026 NewFontCursor(&Scr->MenuCursor, "sb_left_arrow");
1027 NewFontCursor(&Scr->ButtonCursor, "hand2");
1028 NewFontCursor(&Scr->WaitCursor, "watch");
1029 NewFontCursor(&Scr->SelectCursor, "dot");
1030 NewFontCursor(&Scr->DestroyCursor, "pirate");
1031 NewFontCursor(&Scr->DoorCursor, "exchange");/*RFBCURSOR*/
1032 NewFontCursor(&Scr->VirtualCursor, "rtl_logo");/*RFBCURSOR*/
1033 NewFontCursor(&Scr->DesktopCursor, "dotbox");/*RFBCURSOR*/
1034 Scr->NoCursor = NoCursor();
1037 Scr->RingLeader = NULL;
1039 Scr->DefaultC.fore = black;
1040 Scr->DefaultC.back = white;
1041 Scr->BorderColor = black;
1042 Scr->BorderTileC.fore = black;
1043 Scr->BorderTileC.back = white;
1044 Scr->TitleC.fore = black;
1045 Scr->TitleC.back = white;
1046 Scr->MenuC.fore = black;
1047 Scr->MenuC.back = white;
1048 Scr->MenuTitleC.fore = black;
1049 Scr->MenuTitleC.back = white;
1050 Scr->MenuShadowColor = black;
1051 Scr->IconC.fore = black;
1052 Scr->IconC.back = white;
1053 Scr->IconBorderColor = black;
1054 Scr->IconManagerC.fore = black;
1055 Scr->IconManagerC.back = white;
1056 Scr->IconManagerHighlight = black;
1058 /* djhjr - 4/19/96 */
1059 Scr->FramePadding = -100;
1060 Scr->TitlePadding = -100;
1061 Scr->ButtonIndent = -100;
1064 Scr->ThreeDBorderWidth = 6;
1067 /* djhjr - 5/15/96 */
1068 Scr->ResizeX = Scr->ResizeY = 0;
1070 Scr->VirtualC.fore = black;/*RFB VCOLOR*/
1071 Scr->VirtualC.back = white;/*RFB VCOLOR*/
1072 Scr->RealScreenC.back = black;/*RFB 4/92 */
1073 Scr->RealScreenC.fore = white;/*RFB 4/92 */
1074 Scr->VirtualDesktopDisplayC.fore = black;
1075 Scr->VirtualDesktopDisplayC.back = white;
1076 Scr->VirtualDesktopDisplayBorder = black;
1077 Scr->DoorC.fore = black;
1078 Scr->DoorC.back = white;
1080 Scr->AutoRaiseDefault = FALSE;/*RAISEDELAY*/
1081 Scr->FramePadding = 2; /* values that look "nice" on */
1082 Scr->TitlePadding = 8; /* 75 and 100dpi displays */
1083 Scr->ButtonIndent = 1;
1084 Scr->SizeStringOffset = 0;
1085 Scr->BorderWidth = BW;
1086 Scr->IconBorderWidth = BW;
1088 /* djhjr - 8/13/98 */
1089 #ifdef ORIGINAL_PIXMAPS
1090 Scr->UnknownWidth = 0;
1091 Scr->UnknownHeight = 0;
1093 Scr->unknownName = NULL;
1096 Scr->NumAutoRaises = 0;
1097 /* Scr->NoDefaults = FALSE; */
1098 Scr->NoDefaultMouseOrKeyboardBindings = FALSE; /* DSE */
1099 Scr->NoDefaultTitleButtons = FALSE; /* DSE */
1100 Scr->UsePPosition = PPOS_OFF;
1101 Scr->FocusRoot = TRUE;
1102 Scr->Newest = NULL; /* PF */
1105 /* djhjr - 9/10/03 */
1106 Scr->IgnoreModifiers = 0;
1108 /* djhjr - 10/16/02 */
1109 Scr->WarpCentered = WARPC_OFF;
1111 Scr->WarpCursor = FALSE;
1112 Scr->ForceIcon = FALSE;
1113 Scr->NoGrabServer = FALSE;
1114 Scr->NoRaiseMove = FALSE;
1115 Scr->NoRaiseResize = FALSE;
1116 Scr->NoRaiseDeicon = FALSE;
1117 Scr->NoRaiseWarp = FALSE;
1118 Scr->DontMoveOff = FALSE;
1119 Scr->DoZoom = FALSE;
1120 Scr->TitleFocus = TRUE;
1122 /* djhjr - 5/27/98 */
1123 Scr->IconManagerFocus = TRUE;
1125 /* djhjr - 12/14/98 */
1126 Scr->StaticIconPositions = FALSE;
1128 /* djhjr - 10/2/01 */
1129 Scr->StrictIconManager = FALSE;
1131 /* djhjr - 8/23/02 */
1132 Scr->NoBorders = FALSE;
1134 Scr->NoTitlebar = FALSE;
1135 Scr->DecorateTransients = FALSE;
1136 Scr->IconifyByUnmapping = FALSE;
1137 Scr->ShowIconManager = FALSE;
1138 Scr->IconManagerDontShow =FALSE;
1139 Scr->BackingStore = TRUE;
1140 Scr->SaveUnder = TRUE;
1141 Scr->RandomPlacement = FALSE;
1142 Scr->PointerPlacement = FALSE;
1143 Scr->OpaqueMove = FALSE;
1145 /* djhjr - 4/6/98 */
1146 Scr->OpaqueResize = FALSE;
1148 Scr->Highlight = TRUE;
1150 /* djhjr - 1/27/98 */
1151 Scr->IconMgrHighlight = TRUE;
1153 Scr->StackMode = TRUE;
1154 Scr->TitleHighlight = TRUE;
1155 Scr->MoveDelta = 1; /* so that f.deltastop will work */
1157 Scr->SortIconMgr = FALSE;
1159 Scr->InterpolateMenuColors = FALSE;
1160 Scr->NoIconManagers = FALSE;
1161 Scr->NoIconifyIconManagers = FALSE; /* PF */
1162 Scr->ClientBorderWidth = FALSE;
1163 Scr->SqueezeTitle = -1;
1166 Scr->FirstIconRegion = NULL;
1167 Scr->LastIconRegion = NULL;
1169 FreeRegions(Scr->FirstIconRegion, Scr->LastIconRegion);
1171 /* djhjr - 4/26/99 */
1172 FreeRegions(Scr->FirstAppletRegion, Scr->LastAppletRegion);
1174 Scr->FirstTime = TRUE;
1175 Scr->HaveFonts = FALSE; /* i.e. not loaded yet */
1176 Scr->CaseSensitive = TRUE;
1177 Scr->WarpUnmapped = FALSE;
1178 Scr->DeIconifyToScreen = FALSE;
1179 Scr->WarpWindows = FALSE;
1180 Scr->WarpToTransients = FALSE; /* PF */
1182 /* djhjr - 6/25/96 */
1183 Scr->ShallowReliefWindowButton = 2;
1185 /* obsoleted by the *BevelWidth resources - djhjr - 8/11/98
1187 Scr->use3Diconmanagers = FALSE;
1188 Scr->use3Dmenus = FALSE;
1189 Scr->use3Dtitles = FALSE;
1190 Scr->use3Dborders = FALSE;
1193 Scr->ClearBevelContrast = 50;
1194 Scr->DarkBevelContrast = 40;
1195 Scr->BeNiceToColormap = FALSE;
1197 /* obsoleted by the *BevelWidth resources - djhjr - 8/11/98
1199 Scr->use3Dicons = FALSE;
1202 /* obsoleted by the ":xpm:*" built-in pixmaps - djhjr - 10/26/02
1204 Scr->SunkFocusWindowTitle = FALSE;
1207 /* for rader - djhjr - 2/9/99 */
1208 Scr->NoPrettyTitles = FALSE;
1210 /* djhjr - 9/21/96 */
1211 Scr->ButtonColorIsFrame = FALSE;
1213 Scr->snapRealScreen = FALSE;
1214 Scr->OldFashionedTwmWindowsMenu = FALSE;
1215 Scr->GeometriesAreVirtual = TRUE;
1216 Scr->UseWindowRing = FALSE;
1218 /* setup default fonts; overridden by defaults from system.twmrc */
1219 #define DEFAULT_NICE_FONT "variable"
1220 #define DEFAULT_FAST_FONT "fixed"
1221 #define DEFAULT_SMALL_FONT "5x8"
1223 Scr->TitleBarFont.font = NULL;
1224 Scr->TitleBarFont.name = DEFAULT_NICE_FONT;
1225 Scr->MenuFont.font = NULL;
1226 Scr->MenuFont.name = DEFAULT_NICE_FONT;
1227 Scr->MenuTitleFont.font = NULL; /* DSE */
1228 Scr->MenuTitleFont.name = NULL; /* uses MenuFont unless set -- DSE */
1229 Scr->IconFont.font = NULL;
1230 Scr->IconFont.name = DEFAULT_NICE_FONT;
1231 Scr->SizeFont.font = NULL;
1232 Scr->SizeFont.name = DEFAULT_FAST_FONT;
1234 /* djhjr - 5/10/96 */
1235 Scr->InfoFont.font = NULL;
1236 Scr->InfoFont.name = DEFAULT_FAST_FONT;
1238 Scr->IconManagerFont.font = NULL;
1239 Scr->IconManagerFont.name = DEFAULT_NICE_FONT;
1240 Scr->VirtualFont.font = NULL;
1241 Scr->VirtualFont.name = DEFAULT_SMALL_FONT;
1242 Scr->DoorFont.font = NULL;
1243 Scr->DoorFont.name = DEFAULT_NICE_FONT;
1244 Scr->DefaultFont.font = NULL;
1245 Scr->DefaultFont.name = DEFAULT_FAST_FONT;
1247 /* no names unless they say so */
1248 Scr->NamesInVirtualDesktop = FALSE;
1250 /* by default we emulate the old twm - ie. no virtual desktop */
1251 Scr->Virtual = FALSE;
1253 /* this makes some of the algorithms for checking if windows
1254 * are on the screen simpler */
1255 Scr->VirtualDesktopWidth = Scr->MyDisplayWidth;
1256 Scr->VirtualDesktopHeight = Scr->MyDisplayHeight;
1258 /* start at the top left of the virtual desktop */
1259 Scr->VirtualDesktopX = 0;
1260 Scr->VirtualDesktopY = 0;
1262 /* pan defaults to half screen size */
1263 Scr->VirtualDesktopPanDistanceX = 50;
1264 Scr->VirtualDesktopPanDistanceY = 50;
1266 /* djhjr - 9/8/98 */
1267 Scr->VirtualDesktopPanResistance = 0;
1269 /* default scale is 1:25 */
1270 Scr->VirtualDesktopDScale = 25;
1272 /* and the display should appear at 0, 0 */
1273 Scr->VirtualDesktopDX = 0;
1274 Scr->VirtualDesktopDY = 0;
1276 /* by default no autopan */
1278 Scr->StayUpMenus = FALSE;
1279 Scr->StayUpOptionalMenus = FALSE; /* PF */
1281 Scr->AutoPanWarpWithRespectToRealScreen = 0; /* DSE */
1282 Scr->AutoPanBorderWidth = 5; /* DSE */
1283 Scr->AutoPanExtraWarp = 2; /* DSE */
1284 Scr->EnhancedExecResources = FALSE; /* DSE */
1285 Scr->RightHandSidePulldownMenus = FALSE; /* DSE */
1287 /* was '2' for when UseRealScreenBorderWidth existed - djhjr - 2/15/99 */
1288 Scr->RealScreenBorderWidth = 0; /* DSE */
1290 /* djhjr - 10/11/01 */
1291 Scr->ZoomZoom = FALSE;
1293 Scr->LessRandomZoomZoom = FALSE; /* DSE */
1294 Scr->PrettyZoom = FALSE; /* DSE */
1295 Scr->StickyAbove = FALSE; /* DSE */
1296 Scr->DontInterpolateTitles = FALSE; /* DSE */
1298 /* djhjr - 1/6/98 */
1299 Scr->FixManagedVirtualGeometries = FALSE;
1301 Scr->FixTransientVirtualGeometries = FALSE; /* DSE */
1302 Scr->WarpSnug = FALSE; /* DSE */
1304 /* djhjr - 4/17/98 */
1305 Scr->VirtualReceivesMotionEvents = FALSE;
1306 Scr->VirtualSendsMotionEvents = FALSE;
1308 /* djhjr - 5/2/98 */
1309 Scr->BorderBevelWidth = 0;
1310 Scr->TitleBevelWidth = 0;
1311 Scr->MenuBevelWidth = 0;
1312 Scr->IconMgrBevelWidth = 0;
1313 Scr->InfoBevelWidth = 0;
1315 /* djhjr - 8/11/98 */
1316 Scr->IconBevelWidth = 0;
1317 Scr->ButtonBevelWidth = 0;
1319 /* djhjr - 2/7/99 */
1320 Scr->DoorBevelWidth = 0;
1321 Scr->VirtualDesktopBevelWidth = 0;
1323 /* djhjr - 5/22/00 */
1324 Scr->MenuScrollBorderWidth = 2;
1325 Scr->MenuScrollJump = 3;
1327 /* djhjr - 6/22/99 */
1328 Scr->DontDeiconifyTransients = FALSE;
1330 /* submitted by Ugen Antsilevitch - 5/28/00 */
1331 Scr->WarpVisible = FALSE;
1333 /* djhjr - 6/22/01 */
1334 Scr->PauseOnExit = 0;
1335 Scr->PauseOnQuit = 0;
1337 /* djhjr - 11/3/03 */
1338 Scr->RaiseOnStart = FALSE;
1344 GetFont(&Scr->TitleBarFont);
1345 GetFont(&Scr->MenuFont);
1346 GetFont(&Scr->IconFont);
1347 GetFont(&Scr->SizeFont);
1349 /* djhjr - 5/10/96 */
1350 GetFont(&Scr->InfoFont);
1352 GetFont(&Scr->IconManagerFont);
1353 GetFont(&Scr->VirtualFont);
1354 GetFont(&Scr->DoorFont);
1355 GetFont(&Scr->DefaultFont);
1356 GetFont(&Scr->MenuTitleFont); /* DSE */
1357 Scr->HaveFonts = TRUE;
1361 void RestoreWithdrawnLocation (tmp)
1365 unsigned int bw, mask;
1368 if (XGetGeometry (dpy, tmp->w, &JunkRoot, &xwc.x, &xwc.y,
1369 &JunkWidth, &JunkHeight, &bw, &JunkDepth)) {
1371 GetGravityOffsets (tmp, &gravx, &gravy);
1372 if (gravy < 0) xwc.y -= tmp->title_height;
1374 /* djhjr - 4/19/96 */
1375 xwc.x += gravx * tmp->frame_bw3D;
1376 xwc.y += gravy * tmp->frame_bw3D;
1378 if (bw != tmp->old_bw) {
1381 if (!Scr->ClientBorderWidth) {
1389 xwc.x -= (xoff + 1) * tmp->old_bw;
1390 xwc.y -= (yoff + 1) * tmp->old_bw;
1392 if (!Scr->ClientBorderWidth) {
1393 xwc.x += gravx * tmp->frame_bw;
1394 xwc.y += gravy * tmp->frame_bw;
1398 if (bw != tmp->old_bw) {
1399 xwc.border_width = tmp->old_bw;
1400 mask |= CWBorderWidth;
1403 XConfigureWindow (dpy, tmp->w, mask, &xwc);
1405 if (tmp->wmhints && (tmp->wmhints->flags & IconWindowHint)) {
1406 XUnmapWindow (dpy, tmp->wmhints->icon_window);
1413 void Reborder (time)
1416 TwmWindow *tmp; /* temp twm window structure */
1419 /* put a border back around all windows */
1422 for (scrnum = 0; scrnum < NumScreens; scrnum++)
1424 if ((Scr = ScreenList[scrnum]) == NULL)
1427 InstallWindowColormaps (0, &Scr->TwmRoot); /* force reinstall */
1428 for (tmp = Scr->TwmRoot.next; tmp != NULL; tmp = tmp->next)
1430 RestoreWithdrawnLocation (tmp);
1431 XMapWindow (dpy, tmp->w);
1435 XUngrabServer (dpy);
1436 SetFocus ((TwmWindow*)NULL, time);
1439 /* delete the PID file - djhjr - 12/2/01 */
1440 void delete_pidfile()
1446 fn = malloc(HomeLen + strlen(PidName) + 2);
1447 sprintf(fn, "%s/%s", Home, PidName);
1455 * Exit handlers. Clean up and exit VTWM.
1459 * QueueRestartVtwm()
1462 /* djhjr - 6/22/01 */
1463 #ifndef NO_SOUND_SUPPORT
1464 SIGNAL_T PlaySoundDone()
1466 if (PlaySound(S_STOP))
1468 /* allow time to emit */
1469 if (Scr->PauseOnExit) sleep(Scr->PauseOnExit);
1481 Reborder (CurrentTime);
1484 delete_pidfile(); /* djhjr - 12/2/01 */
1492 Reborder (CurrentTime);
1495 delete_pidfile(); /* djhjr - 12/2/01 */
1502 /* djhjr - 7/31/98 */
1506 XClientMessageEvent ev;
1508 delete_pidfile(); /* djhjr - 12/2/01 */
1510 ev.type = ClientMessage;
1511 ev.window = Scr->Root;
1512 ev.message_type = _XA_TWM_RESTART;
1514 ev.data.b[0] = (char)0;
1516 XSendEvent (dpy, Scr->VirtualDesktopDisplay, False, 0L, (XEvent *) &ev);
1523 * Error Handlers. If a client dies, we'll get a BadWindow error (except for
1524 * GetGeometry which returns BadDrawable) for most operations that we do before
1525 * manipulating the client's window.
1528 Bool ErrorOccurred = False;
1529 XErrorEvent LastErrorEvent;
1531 static int TwmErrorHandler(dpy, event)
1535 LastErrorEvent = *event;
1536 ErrorOccurred = True;
1538 if (PrintErrorMessages && /* don't be too obnoxious */
1539 event->error_code != BadWindow && /* watch for dead puppies */
1540 (event->request_code != X_GetGeometry && /* of all styles */
1541 event->error_code != BadDrawable))
1542 XmuPrintDefaultErrorMessage (dpy, event, stderr);
1548 static int CatchRedirectError(dpy, event)
1552 RedirectError = TRUE;
1553 LastErrorEvent = *event;
1554 ErrorOccurred = True;
1558 Atom _XA_MIT_PRIORITY_COLORS;
1559 Atom _XA_WM_CHANGE_STATE;
1561 Atom _XA_WM_COLORMAP_WINDOWS;
1562 Atom _XA_WM_PROTOCOLS;
1563 Atom _XA_WM_TAKE_FOCUS;
1564 Atom _XA_WM_SAVE_YOURSELF;
1565 Atom _XA_WM_DELETE_WINDOW;
1567 /* djhjr - 7/31/98 */
1568 Atom _XA_TWM_RESTART;
1570 void InternUsefulAtoms ()
1573 * Create priority colors if necessary.
1575 _XA_MIT_PRIORITY_COLORS = XInternAtom(dpy, "_MIT_PRIORITY_COLORS", False);
1576 _XA_WM_CHANGE_STATE = XInternAtom (dpy, "WM_CHANGE_STATE", False);
1577 _XA_WM_STATE = XInternAtom (dpy, "WM_STATE", False);
1578 _XA_WM_COLORMAP_WINDOWS = XInternAtom (dpy, "WM_COLORMAP_WINDOWS", False);
1579 _XA_WM_PROTOCOLS = XInternAtom (dpy, "WM_PROTOCOLS", False);
1580 _XA_WM_TAKE_FOCUS = XInternAtom (dpy, "WM_TAKE_FOCUS", False);
1581 _XA_WM_SAVE_YOURSELF = XInternAtom (dpy, "WM_SAVE_YOURSELF", False);
1582 _XA_WM_DELETE_WINDOW = XInternAtom (dpy, "WM_DELETE_WINDOW", False);
1584 /* djhjr - 7/31/98 */
1585 _XA_TWM_RESTART = XInternAtom (dpy, "_TWM_RESTART", False);