wmaker: replace and be replaced (ICCCM protocol)
[wmaker-crm.git] / src / main.c
blobb68c5b6fd72ab30a3e4ccc60f01fb5165b77b84d
1 /*
2 * Window Maker window manager
4 * Copyright (c) 1997-2003 Alfredo K. Kojima
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include "wconfig.h"
23 #ifdef HAVE_INOTIFY
24 #include <sys/inotify.h>
25 #endif
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <unistd.h>
30 #include <string.h>
31 #include <sys/stat.h>
32 #include <sys/types.h>
33 #include <fcntl.h>
35 #include <X11/Xlib.h>
36 #include <X11/Xutil.h>
38 /* Xlocale.h and locale.h are the same if X_LOCALE is undefind in wconfig.h,
39 * and if X_LOCALE is defined, X's locale emulating functions will be used.
40 * See Xlocale.h for more information.
42 #include <X11/Xlocale.h>
44 #define MAINFILE
46 #include "WindowMaker.h"
47 #include "window.h"
48 #include "defaults.h"
49 #include "event.h"
50 #include "startup.h"
51 #include "menu.h"
52 #include "keybind.h"
53 #include "xmodifier.h"
54 #include "session.h"
55 #include "shutdown.h"
56 #include "dialog.h"
57 #include "main.h"
58 #include "monitor.h"
60 #include <WINGs/WUtil.h>
62 #ifndef GLOBAL_DEFAULTS_SUBDIR
63 #define GLOBAL_DEFAULTS_SUBDIR "WindowMaker"
64 #endif
66 /****** Global Variables ******/
67 struct wmaker_global_variables w_global;
69 /* general info */
71 Display *dpy;
73 char *ProgName;
75 struct WPreferences wPreferences;
77 WShortKey wKeyBindings[WKBD_LAST];
79 /* notifications */
80 const char WMNManaged[] = "WMNManaged";
81 const char WMNUnmanaged[] = "WMNUnmanaged";
82 const char WMNChangedWorkspace[] = "WMNChangedWorkspace";
83 const char WMNChangedState[] = "WMNChangedState";
84 const char WMNChangedFocus[] = "WMNChangedFocus";
85 const char WMNChangedStacking[] = "WMNChangedStacking";
86 const char WMNChangedName[] = "WMNChangedName";
88 const char WMNWorkspaceCreated[] = "WMNWorkspaceCreated";
89 const char WMNWorkspaceDestroyed[] = "WMNWorkspaceDestroyed";
90 const char WMNWorkspaceChanged[] = "WMNWorkspaceChanged";
91 const char WMNWorkspaceNameChanged[] = "WMNWorkspaceNameChanged";
93 const char WMNResetStacking[] = "WMNResetStacking";
95 /******** End Global Variables *****/
97 static char *DisplayName = NULL;
99 static char **Arguments;
101 static int ArgCount;
103 static Bool multiHead = True;
105 static int *wVisualID = NULL;
106 static int wVisualID_len = 0;
108 static int real_main(int argc, char **argv);
110 int getWVisualID(int screen)
112 if (wVisualID == NULL)
113 return -1;
114 if (screen < 0 || screen >= wVisualID_len)
115 return -1;
117 return wVisualID[screen];
120 static void setWVisualID(int screen, int val)
122 int i;
124 if (screen < 0)
125 return;
127 if (wVisualID == NULL) {
128 /* no array at all, alloc space for screen + 1 entries
129 * and init with default value */
130 wVisualID_len = screen + 1;
131 wVisualID = (int *)malloc(wVisualID_len * sizeof(int));
132 for (i = 0; i < wVisualID_len; i++) {
133 wVisualID[i] = -1;
135 } else if (screen >= wVisualID_len) {
136 /* larger screen number than previously allocated
137 so enlarge array */
138 int oldlen = wVisualID_len;
140 wVisualID_len = screen + 1;
141 wVisualID = (int *)wrealloc(wVisualID, wVisualID_len * sizeof(int));
142 for (i = oldlen; i < wVisualID_len; i++) {
143 wVisualID[i] = -1;
147 wVisualID[screen] = val;
151 * this function splits a given string at the comma into tokens
152 * and set the wVisualID variable to each parsed number
154 static int initWVisualID(const char *user_str)
156 char *mystr = strdup(user_str);
157 int cur_in_pos = 0;
158 int cur_out_pos = 0;
159 int cur_screen = 0;
160 int error_found = 0;
162 for (;;) {
163 /* check for delimiter */
164 if (user_str[cur_in_pos] == '\0' || user_str[cur_in_pos] == ',') {
165 int v;
167 mystr[cur_out_pos] = '\0';
169 if (sscanf(mystr, "%i", &v) != 1) {
170 error_found = 1;
171 break;
174 setWVisualID(cur_screen, v);
176 cur_screen++;
177 cur_out_pos = 0;
180 /* break in case last char has been consumed */
181 if (user_str[cur_in_pos] == '\0')
182 break;
184 /* if the current char is no delimiter put it into mystr */
185 if (user_str[cur_in_pos] != ',') {
186 mystr[cur_out_pos++] = user_str[cur_in_pos];
188 cur_in_pos++;
191 free(mystr);
193 if (cur_screen == 0||error_found != 0)
194 return 1;
196 return 0;
199 noreturn void Exit(int status)
201 if (dpy)
202 XCloseDisplay(dpy);
204 RShutdown(); /* wrlib clean exit */
205 wutil_shutdown(); /* WUtil clean-up */
207 exit(status);
210 void Restart(char *manager, Bool abortOnFailure)
212 char *prog = NULL;
213 char *argv[MAX_RESTART_ARGS];
214 int i;
216 if (manager && manager[0] != 0) {
217 prog = argv[0] = strtok(manager, " ");
218 for (i = 1; i < MAX_RESTART_ARGS; i++) {
219 argv[i] = strtok(NULL, " ");
220 if (argv[i] == NULL) {
221 break;
225 if (dpy) {
226 XCloseDisplay(dpy);
227 dpy = NULL;
229 if (!prog) {
230 execvp(Arguments[0], Arguments);
231 wfatal(_("failed to restart Window Maker."));
232 } else {
233 execvp(prog, argv);
234 werror(_("could not exec %s"), prog);
236 if (abortOnFailure)
237 exit(7);
240 void SetupEnvironment(WScreen * scr)
242 char *tmp, *ptr;
243 char buf[16];
245 if (multiHead) {
246 int len = strlen(DisplayName) + 64;
247 tmp = wmalloc(len);
248 snprintf(tmp, len, "DISPLAY=%s", XDisplayName(DisplayName));
250 /* Search from the end to be compatible with ipv6 address */
251 ptr = strrchr(tmp, ':');
252 if (ptr == NULL) {
253 static Bool message_already_displayed = False;
255 if (!message_already_displayed)
256 wwarning(_("the display name has an unexpected syntax: \"%s\""),
257 XDisplayName(DisplayName));
258 message_already_displayed = True;
259 } else {
260 /* If found, remove the screen specification from the display variable */
261 ptr = strchr(ptr, '.');
262 if (ptr)
263 *ptr = 0;
265 snprintf(buf, sizeof(buf), ".%i", scr->screen);
266 strcat(tmp, buf);
267 putenv(tmp);
269 tmp = wmalloc(60);
270 snprintf(tmp, 60, "WRASTER_COLOR_RESOLUTION%i=%i", scr->screen,
271 scr->rcontext->attribs->colors_per_channel);
272 putenv(tmp);
275 typedef struct {
276 WScreen *scr;
277 char *command;
278 } _tuple;
280 static void shellCommandHandler(pid_t pid, unsigned int status, void *client_data)
282 _tuple *data = (_tuple *) client_data;
284 /* Parameter not used, but tell the compiler that it is ok */
285 (void) pid;
287 if (status == 127) {
288 char *buffer;
290 buffer = wstrconcat(_("Could not execute command: "), data->command);
292 wMessageDialog(data->scr, _("Error"), buffer, _("OK"), NULL, NULL);
293 wfree(buffer);
294 } else if (status != 127) {
296 printf("%s: %i\n", data->command, status);
300 wfree(data->command);
301 wfree(data);
304 void ExecuteShellCommand(WScreen *scr, const char *command)
306 static char *shell = NULL;
307 pid_t pid;
310 * This have a problem: if the shell is tcsh (not sure about others)
311 * and ~/.tcshrc have /bin/stty erase ^H somewhere on it, the shell
312 * will block and the command will not be executed.
313 if (!shell) {
314 shell = getenv("SHELL");
315 if (!shell)
316 shell = "/bin/sh";
319 shell = "/bin/sh";
321 pid = fork();
323 if (pid == 0) {
325 SetupEnvironment(scr);
327 #ifdef HAVE_SETSID
328 setsid();
329 #endif
330 execl(shell, shell, "-c", command, NULL);
331 werror("could not execute %s -c %s", shell, command);
332 Exit(-1);
333 } else if (pid < 0) {
334 werror("cannot fork a new process");
335 } else {
336 _tuple *data = wmalloc(sizeof(_tuple));
338 data->scr = scr;
339 data->command = wstrdup(command);
341 wAddDeathHandler(pid, shellCommandHandler, data);
346 *---------------------------------------------------------------------
347 * RelaunchWindow--
348 * Launch a new instance of the active window
350 *----------------------------------------------------------------------
352 Bool RelaunchWindow(WWindow *wwin)
354 if (! wwin || ! wwin->client_win) {
355 werror("no window to relaunch");
356 return False;
359 char **argv;
360 int argc;
362 if (! XGetCommand(dpy, wwin->client_win, &argv, &argc) || argc == 0 || argv == NULL) {
363 werror("cannot relaunch the application because no WM_COMMAND property is set");
364 return False;
367 pid_t pid = fork();
369 if (pid == 0) {
370 SetupEnvironment(wwin->screen_ptr);
371 #ifdef HAVE_SETSID
372 setsid();
373 #endif
374 /* argv is not null-terminated */
375 char **a = (char **) malloc(argc + 1);
376 if (! a) {
377 werror("out of memory trying to relaunch the application");
378 Exit(-1);
381 int i;
382 for (i = 0; i < argc; i++)
383 a[i] = argv[i];
384 a[i] = NULL;
386 execvp(a[0], a);
387 Exit(-1);
388 } else if (pid < 0) {
389 werror("cannot fork a new process");
391 XFreeStringList(argv);
392 return False;
393 } else {
394 _tuple *data = wmalloc(sizeof(_tuple));
396 data->scr = wwin->screen_ptr;
397 data->command = wtokenjoin(argv, argc);
399 /* not actually a shell command */
400 wAddDeathHandler(pid, shellCommandHandler, data);
402 XFreeStringList(argv);
405 return True;
409 *---------------------------------------------------------------------
410 * wAbort--
411 * Do a major cleanup and exit the program
413 *----------------------------------------------------------------------
415 noreturn void wAbort(Bool dumpCore)
417 int i;
418 WScreen *scr;
420 for (i = 0; i < w_global.screen_count; i++) {
421 scr = wScreenWithNumber(i);
422 if (scr)
423 RestoreDesktop(scr);
425 printf(_("%s aborted.\n"), ProgName);
426 if (dumpCore)
427 abort();
428 else
429 exit(1);
432 static void print_help(void)
434 printf(_("Usage: %s [options]\n"), ProgName);
435 puts(_("The Window Maker window manager for the X window system"));
436 puts("");
437 puts(_(" -display host:dpy display to use"));
438 puts(_(" --replace replace running window manager"));
439 puts(_(" --no-dock do not open the application Dock"));
440 puts(_(" --no-clip do not open the workspace Clip"));
441 puts(_(" --no-autolaunch do not autolaunch applications"));
442 puts(_(" --no-drawer disable drawers in the dock"));
443 puts(_(" --dont-restore do not restore saved session"));
445 puts(_(" --locale locale locale to use"));
447 puts(_(" --visual-id visualid visual id of visual to use"));
448 puts(_(" --static do not update or save configurations"));
449 #ifndef HAVE_INOTIFY
450 puts(_(" --no-polling do not periodically check for configuration updates"));
451 #endif
452 puts(_(" --global_defaults_path print the path for default config and exit"));
453 puts(_(" --version print version and exit"));
454 puts(_(" --help show this message"));
457 static void check_defaults(void)
459 char *path;
461 path = wdefaultspathfordomain("WindowMaker");
463 if (access(path, R_OK) != 0) {
464 wwarning(_("could not find user GNUstep directory (%s)."), path);
466 if (system("wmaker.inst --batch") != 0) {
467 wwarning(_("There was an error while creating GNUstep directory, please "
468 "make sure you have installed Window Maker correctly and run wmaker.inst"));
469 } else {
470 wwarning(_("%s directory created with default configuration."), path);
474 wfree(path);
477 #ifdef HAVE_INOTIFY
479 * Add watch here, used to notify if configuration
480 * files have changed, using linux kernel inotify mechanism
483 static void inotifyWatchConfig(void)
485 char *watchPath = NULL;
487 w_global.inotify.fd_event_queue = inotify_init(); /* Initialise an inotify instance */
488 if (w_global.inotify.fd_event_queue < 0) {
489 wwarning(_("could not initialise an inotify instance."
490 " Changes to the defaults database will require"
491 " a restart to take effect. Check your kernel!"));
492 } else {
493 watchPath = wstrconcat(wusergnusteppath(), "/Defaults");
494 /* Add the watch; really we are only looking for modify events
495 * but we might want more in the future so check all events for now.
496 * The individual events are checked for in event.c.
498 w_global.inotify.wd_defaults = inotify_add_watch(w_global.inotify.fd_event_queue, watchPath, IN_ALL_EVENTS);
499 if (w_global.inotify.wd_defaults < 0) {
500 wwarning(_("could not add an inotify watch on path %s."
501 " Changes to the defaults database will require"
502 " a restart to take effect."), watchPath);
503 close(w_global.inotify.fd_event_queue);
504 w_global.inotify.fd_event_queue = -1;
507 wfree(watchPath);
509 #endif /* HAVE_INOTIFY */
511 static void execInitScript(void)
513 char *file, *paths;
515 paths = wstrconcat(wusergnusteppath(), "/Library/WindowMaker");
516 paths = wstrappend(paths, ":" DEF_CONFIG_PATHS);
518 file = wfindfile(paths, DEF_INIT_SCRIPT);
519 wfree(paths);
521 if (file) {
522 if (system(file) != 0)
523 werror(_("%s:could not execute initialization script"), file);
525 wfree(file);
529 void ExecExitScript(void)
531 char *file, *paths;
533 paths = wstrconcat(wusergnusteppath(), "/Library/WindowMaker");
534 paths = wstrappend(paths, ":" DEF_CONFIG_PATHS);
536 file = wfindfile(paths, DEF_EXIT_SCRIPT);
537 wfree(paths);
539 if (file) {
540 if (system(file) != 0)
541 werror(_("%s:could not execute exit script"), file);
543 wfree(file);
547 int main(int argc, char **argv)
549 int i_am_the_monitor, i, len;
550 char *str, *alt;
552 memset(&w_global, 0, sizeof(w_global));
553 w_global.program.state = WSTATE_NORMAL;
554 w_global.program.signal_state = WSTATE_NORMAL;
555 w_global.timestamp.last_event = CurrentTime;
556 w_global.timestamp.focus_change = CurrentTime;
557 w_global.ignore_workspace_change = False;
558 w_global.shortcut.modifiers_mask = 0xff;
560 /* setup common stuff for the monitor and wmaker itself */
561 WMInitializeApplication("WindowMaker", &argc, argv);
563 memset(&wPreferences, 0, sizeof(wPreferences));
565 wPreferences.fallbackWMs = WMCreateArray(8);
566 alt = getenv("WINDOWMAKER_ALT_WM");
567 if (alt != NULL)
568 WMAddToArray(wPreferences.fallbackWMs, wstrdup(alt));
570 WMAddToArray(wPreferences.fallbackWMs, wstrdup("blackbox"));
571 WMAddToArray(wPreferences.fallbackWMs, wstrdup("metacity"));
572 WMAddToArray(wPreferences.fallbackWMs, wstrdup("fvwm"));
573 WMAddToArray(wPreferences.fallbackWMs, wstrdup("twm"));
574 WMAddToArray(wPreferences.fallbackWMs, NULL);
575 WMAddToArray(wPreferences.fallbackWMs, wstrdup("rxvt"));
576 WMAddToArray(wPreferences.fallbackWMs, wstrdup("xterm"));
578 i_am_the_monitor = 1;
580 for (i = 1; i < argc; i++) {
581 if (strncmp(argv[i], "--for-real", strlen("--for-real")) == 0) {
582 i_am_the_monitor = 0;
583 break;
584 } else if (strcmp(argv[i], "-display") == 0 || strcmp(argv[i], "--display") == 0) {
585 i++;
586 if (i >= argc) {
587 wwarning(_("too few arguments for %s"), argv[i - 1]);
588 exit(0);
590 DisplayName = argv[i];
594 DisplayName = XDisplayName(DisplayName);
595 len = strlen(DisplayName) + 64;
596 str = wmalloc(len);
597 snprintf(str, len, "DISPLAY=%s", DisplayName);
598 putenv(str);
600 if (i_am_the_monitor)
601 return MonitorLoop(argc, argv);
602 else
603 return real_main(argc, argv);
606 static int real_main(int argc, char **argv)
608 int i;
609 char *pos;
610 int d, s;
612 setlocale(LC_ALL, "");
613 wsetabort(wAbort);
615 /* for telling WPrefs what's the name of the wmaker binary being ran */
616 setenv("WMAKER_BIN_NAME", argv[0], 1);
618 ArgCount = argc;
619 Arguments = wmalloc(sizeof(char *) * (ArgCount + 1));
620 for (i = 0; i < argc; i++) {
621 Arguments[i] = argv[i];
623 /* add the extra option to signal that we're just restarting wmaker */
624 Arguments[argc - 1] = "--for-real=";
625 Arguments[argc] = NULL;
627 ProgName = strrchr(argv[0], '/');
628 if (!ProgName)
629 ProgName = argv[0];
630 else
631 ProgName++;
633 if (argc > 1) {
634 for (i = 1; i < argc; i++) {
635 if (strcmp(argv[i], "-nocpp") == 0 || strcmp(argv[i], "--no-cpp") == 0) {
636 wwarning(_("option \"%s\" is deprecated, please remove it from your script"), argv[i]);
637 } else if (strcmp(argv[i], "--for-real") == 0) {
638 wPreferences.flags.restarting = 0;
639 } else if (strcmp(argv[i], "--for-real=") == 0) {
640 wPreferences.flags.restarting = 1;
641 } else if (strcmp(argv[i], "--for-real-") == 0) {
642 wPreferences.flags.restarting = 2;
643 } else if (strcmp(argv[i], "-no-autolaunch") == 0
644 || strcmp(argv[i], "--no-autolaunch") == 0) {
645 wPreferences.flags.noautolaunch = 1;
646 } else if (strcmp(argv[i], "-dont-restore") == 0 || strcmp(argv[i], "--dont-restore") == 0) {
647 wPreferences.flags.norestore = 1;
648 } else if (strcmp(argv[i], "-nodock") == 0 || strcmp(argv[i], "--no-dock") == 0) {
649 wPreferences.flags.nodock = 1;
650 wPreferences.flags.nodrawer = 1;
651 } else if (strcmp(argv[i], "-noclip") == 0 || strcmp(argv[i], "--no-clip") == 0) {
652 wPreferences.flags.noclip = 1;
653 } else if (strcmp(argv[i], "-nodrawer") == 0 || strcmp(argv[i], "--no-drawer") == 0) {
654 wPreferences.flags.nodrawer = 1;
655 } else if (strcmp(argv[i], "-replace") == 0 || strcmp(argv[i], "--replace") == 0) {
656 wPreferences.flags.replace = 1;
657 } else if (strcmp(argv[i], "-version") == 0 || strcmp(argv[i], "--version") == 0) {
658 printf("Window Maker %s\n", VERSION);
659 exit(0);
660 } else if (strcmp(argv[i], "--global_defaults_path") == 0) {
661 printf("%s/%s\n", SYSCONFDIR, GLOBAL_DEFAULTS_SUBDIR);
662 exit(0);
663 } else if (strcmp(argv[i], "-locale") == 0 || strcmp(argv[i], "--locale") == 0) {
664 i++;
665 if (i >= argc) {
666 wwarning(_("too few arguments for %s"), argv[i - 1]);
667 exit(0);
669 w_global.locale = argv[i];
670 } else if (strcmp(argv[i], "-display") == 0 || strcmp(argv[i], "--display") == 0) {
671 i++;
672 if (i >= argc) {
673 wwarning(_("too few arguments for %s"), argv[i - 1]);
674 exit(0);
676 DisplayName = argv[i];
677 } else if (strcmp(argv[i], "-visualid") == 0 || strcmp(argv[i], "--visual-id") == 0) {
678 i++;
679 if (i >= argc) {
680 wwarning(_("too few arguments for %s"), argv[i - 1]);
681 exit(0);
683 if (initWVisualID(argv[i]) != 0) {
684 wwarning(_("bad value for visualid: \"%s\""), argv[i]);
685 exit(0);
687 } else if (strcmp(argv[i], "-static") == 0 || strcmp(argv[i], "--static") == 0) {
688 wPreferences.flags.noupdates = 1;
689 } else if (strcmp(argv[i], "--no-polling") == 0) {
690 #ifndef HAVE_INOTIFY
691 wPreferences.flags.noupdates = 1;
692 #else
693 wmessage(_("your version of Window Maker was compiled with INotify support, so \"--no-polling\" has no effect"));
694 #endif
695 } else if (strcmp(argv[i], "--help") == 0) {
696 print_help();
697 exit(0);
698 } else {
699 printf(_("%s: invalid argument '%s'\n"), argv[0], argv[i]);
700 printf(_("Try '%s --help' for more information\n"), argv[0]);
701 exit(1);
706 if (!wPreferences.flags.noupdates) {
707 /* check existence of Defaults DB directory */
708 check_defaults();
711 if (w_global.locale) {
712 setenv("LANG", w_global.locale, 1);
713 } else {
714 w_global.locale = getenv("LC_ALL");
715 if (!w_global.locale) {
716 w_global.locale = getenv("LANG");
720 setlocale(LC_ALL, "");
722 if (!w_global.locale || strcmp(w_global.locale, "C") == 0 || strcmp(w_global.locale, "POSIX") == 0)
723 w_global.locale = NULL;
724 #ifdef I18N
725 if (getenv("NLSPATH")) {
726 bindtextdomain("WindowMaker", getenv("NLSPATH"));
727 #if defined(MENU_TEXTDOMAIN)
728 bindtextdomain(MENU_TEXTDOMAIN, getenv("NLSPATH"));
729 #endif
730 } else {
731 bindtextdomain("WindowMaker", LOCALEDIR);
732 #if defined(MENU_TEXTDOMAIN)
733 bindtextdomain(MENU_TEXTDOMAIN, LOCALEDIR);
734 #endif
736 bind_textdomain_codeset("WindowMaker", "UTF-8");
737 #if defined(MENU_TEXTDOMAIN)
738 bind_textdomain_codeset(MENU_TEXTDOMAIN, "UTF-8");
739 #endif
740 textdomain("WindowMaker");
742 if (!XSupportsLocale()) {
743 wwarning(_("X server does not support locale"));
746 if (XSetLocaleModifiers("") == NULL) {
747 wwarning(_("cannot set locale modifiers"));
749 #endif
751 if (w_global.locale) {
752 char *ptr;
754 w_global.locale = wstrdup(w_global.locale);
755 ptr = strchr(w_global.locale, '.');
756 if (ptr)
757 *ptr = 0;
760 /* open display */
761 dpy = XOpenDisplay(DisplayName);
762 if (dpy == NULL) {
763 wfatal(_("could not open display \"%s\""), XDisplayName(DisplayName));
764 exit(1);
767 if (fcntl(ConnectionNumber(dpy), F_SETFD, FD_CLOEXEC) < 0) {
768 werror("error setting close-on-exec flag for X connection");
769 exit(1);
773 if (getWVisualID(0) < 0) {
775 * If unspecified, use default visual instead of waiting
776 * for wrlib/context.c:bestContext() that may end up choosing
777 * the "fake" 24 bits added by the Composite extension.
778 * This is required to avoid all sort of corruptions when
779 * composite is enabled, and at a depth other than 24.
781 setWVisualID(0, (int)DefaultVisual(dpy, DefaultScreen(dpy))->visualid);
784 /* check if the user specified a complete display name (with screen).
785 * If so, only manage the specified screen */
786 if (DisplayName)
787 pos = strchr(DisplayName, ':');
788 else
789 pos = NULL;
791 if (pos && sscanf(pos, ":%i.%i", &d, &s) == 2)
792 multiHead = False;
794 DisplayName = XDisplayName(DisplayName);
795 setenv("DISPLAY", DisplayName, 1);
797 wXModifierInitialize();
798 StartUp(!multiHead);
800 if (w_global.screen_count == 1)
801 multiHead = False;
803 execInitScript();
804 #ifdef HAVE_INOTIFY
805 inotifyWatchConfig();
806 #endif
807 EventLoop();
808 return -1;