debian: Update with version 0.95.9-2 packaging.
[wmaker-crm.git] / src / main.c
bloba00d9c7f43509919fb72761c4b36d5082b7c1ed0
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 /****** Global Variables ******/
63 struct wmaker_global_variables w_global;
65 /* general info */
67 Display *dpy;
69 char *ProgName;
71 struct WPreferences wPreferences;
73 WShortKey wKeyBindings[WKBD_LAST];
75 /* notifications */
76 const char WMNManaged[] = "WMNManaged";
77 const char WMNUnmanaged[] = "WMNUnmanaged";
78 const char WMNChangedWorkspace[] = "WMNChangedWorkspace";
79 const char WMNChangedState[] = "WMNChangedState";
80 const char WMNChangedFocus[] = "WMNChangedFocus";
81 const char WMNChangedStacking[] = "WMNChangedStacking";
82 const char WMNChangedName[] = "WMNChangedName";
84 const char WMNWorkspaceCreated[] = "WMNWorkspaceCreated";
85 const char WMNWorkspaceDestroyed[] = "WMNWorkspaceDestroyed";
86 const char WMNWorkspaceChanged[] = "WMNWorkspaceChanged";
87 const char WMNWorkspaceNameChanged[] = "WMNWorkspaceNameChanged";
89 const char WMNResetStacking[] = "WMNResetStacking";
91 /******** End Global Variables *****/
93 static char *DisplayName = NULL;
95 static char **Arguments;
97 static int ArgCount;
99 static Bool multiHead = True;
101 static int *wVisualID = NULL;
102 static int wVisualID_len = 0;
104 static int real_main(int argc, char **argv);
106 int getWVisualID(int screen)
108 if (wVisualID == NULL)
109 return -1;
110 if (screen < 0 || screen >= wVisualID_len)
111 return -1;
113 return wVisualID[screen];
116 static void setWVisualID(int screen, int val)
118 int i;
120 if (screen < 0)
121 return;
123 if (wVisualID == NULL) {
124 /* no array at all, alloc space for screen + 1 entries
125 * and init with default value */
126 wVisualID_len = screen + 1;
127 wVisualID = (int *)malloc(wVisualID_len * sizeof(int));
128 for (i = 0; i < wVisualID_len; i++) {
129 wVisualID[i] = -1;
131 } else if (screen >= wVisualID_len) {
132 /* larger screen number than previously allocated
133 so enlarge array */
134 int oldlen = wVisualID_len;
136 wVisualID_len = screen + 1;
137 wVisualID = (int *)wrealloc(wVisualID, wVisualID_len * sizeof(int));
138 for (i = oldlen; i < wVisualID_len; i++) {
139 wVisualID[i] = -1;
143 wVisualID[screen] = val;
147 * this function splits a given string at the comma into tokens
148 * and set the wVisualID variable to each parsed number
150 static int initWVisualID(const char *user_str)
152 char *mystr = strdup(user_str);
153 int cur_in_pos = 0;
154 int cur_out_pos = 0;
155 int cur_screen = 0;
156 int error_found = 0;
158 for (;;) {
159 /* check for delimiter */
160 if (user_str[cur_in_pos] == '\0' || user_str[cur_in_pos] == ',') {
161 int v;
163 mystr[cur_out_pos] = '\0';
165 if (sscanf(mystr, "%i", &v) != 1) {
166 error_found = 1;
167 break;
170 setWVisualID(cur_screen, v);
172 cur_screen++;
173 cur_out_pos = 0;
176 /* break in case last char has been consumed */
177 if (user_str[cur_in_pos] == '\0')
178 break;
180 /* if the current char is no delimiter put it into mystr */
181 if (user_str[cur_in_pos] != ',') {
182 mystr[cur_out_pos++] = user_str[cur_in_pos];
184 cur_in_pos++;
187 free(mystr);
189 if (cur_screen == 0||error_found != 0)
190 return 1;
192 return 0;
195 noreturn void Exit(int status)
197 if (dpy)
198 XCloseDisplay(dpy);
200 RShutdown(); /* wrlib clean exit */
201 wutil_shutdown(); /* WUtil clean-up */
203 exit(status);
206 void Restart(char *manager, Bool abortOnFailure)
208 char *prog = NULL;
209 char *argv[MAX_RESTART_ARGS];
210 int i;
212 if (manager && manager[0] != 0) {
213 prog = argv[0] = strtok(manager, " ");
214 for (i = 1; i < MAX_RESTART_ARGS; i++) {
215 argv[i] = strtok(NULL, " ");
216 if (argv[i] == NULL) {
217 break;
221 if (dpy) {
222 XCloseDisplay(dpy);
223 dpy = NULL;
225 if (!prog) {
226 execvp(Arguments[0], Arguments);
227 wfatal(_("failed to restart Window Maker."));
228 } else {
229 execvp(prog, argv);
230 werror(_("could not exec %s"), prog);
232 if (abortOnFailure)
233 exit(7);
236 void SetupEnvironment(WScreen * scr)
238 char *tmp, *ptr;
239 char buf[16];
241 if (multiHead) {
242 int len = strlen(DisplayName) + 64;
243 tmp = wmalloc(len);
244 snprintf(tmp, len, "DISPLAY=%s", XDisplayName(DisplayName));
246 /* Search from the end to be compatible with ipv6 address */
247 ptr = strrchr(tmp, ':');
248 if (ptr == NULL) {
249 static Bool message_already_displayed = False;
251 if (!message_already_displayed)
252 wwarning(_("the display name has an unexpected syntax: \"%s\""),
253 XDisplayName(DisplayName));
254 message_already_displayed = True;
255 } else {
256 /* If found, remove the screen specification from the display variable */
257 ptr = strchr(ptr, '.');
258 if (ptr)
259 *ptr = 0;
261 snprintf(buf, sizeof(buf), ".%i", scr->screen);
262 strcat(tmp, buf);
263 putenv(tmp);
265 tmp = wmalloc(60);
266 snprintf(tmp, 60, "WRASTER_COLOR_RESOLUTION%i=%i", scr->screen,
267 scr->rcontext->attribs->colors_per_channel);
268 putenv(tmp);
271 typedef struct {
272 WScreen *scr;
273 char *command;
274 } _tuple;
276 static void shellCommandHandler(pid_t pid, unsigned int status, void *client_data)
278 _tuple *data = (_tuple *) client_data;
280 /* Parameter not used, but tell the compiler that it is ok */
281 (void) pid;
283 if (status == 127) {
284 char *buffer;
286 buffer = wstrconcat(_("Could not execute command: "), data->command);
288 wMessageDialog(data->scr, _("Error"), buffer, _("OK"), NULL, NULL);
289 wfree(buffer);
290 } else if (status != 127) {
292 printf("%s: %i\n", data->command, status);
296 wfree(data->command);
297 wfree(data);
300 void ExecuteShellCommand(WScreen *scr, const char *command)
302 static char *shell = NULL;
303 pid_t pid;
306 * This have a problem: if the shell is tcsh (not sure about others)
307 * and ~/.tcshrc have /bin/stty erase ^H somewhere on it, the shell
308 * will block and the command will not be executed.
309 if (!shell) {
310 shell = getenv("SHELL");
311 if (!shell)
312 shell = "/bin/sh";
315 shell = "/bin/sh";
317 pid = fork();
319 if (pid == 0) {
321 SetupEnvironment(scr);
323 #ifdef HAVE_SETSID
324 setsid();
325 #endif
326 execl(shell, shell, "-c", command, NULL);
327 werror("could not execute %s -c %s", shell, command);
328 Exit(-1);
329 } else if (pid < 0) {
330 werror("cannot fork a new process");
331 } else {
332 _tuple *data = wmalloc(sizeof(_tuple));
334 data->scr = scr;
335 data->command = wstrdup(command);
337 wAddDeathHandler(pid, shellCommandHandler, data);
342 *---------------------------------------------------------------------
343 * RelaunchWindow--
344 * Launch a new instance of the active window
346 *----------------------------------------------------------------------
348 Bool RelaunchWindow(WWindow *wwin)
350 if (! wwin || ! wwin->client_win) {
351 werror("no window to relaunch");
352 return False;
355 char **argv;
356 int argc;
358 if (! XGetCommand(dpy, wwin->client_win, &argv, &argc) || argc == 0 || argv == NULL) {
359 werror("cannot relaunch the application because no WM_COMMAND property is set");
360 return False;
363 pid_t pid = fork();
365 if (pid == 0) {
366 SetupEnvironment(wwin->screen_ptr);
367 #ifdef HAVE_SETSID
368 setsid();
369 #endif
370 /* argv is not null-terminated */
371 char **a = (char **) malloc(argc + 1);
372 if (! a) {
373 werror("out of memory trying to relaunch the application");
374 Exit(-1);
377 int i;
378 for (i = 0; i < argc; i++)
379 a[i] = argv[i];
380 a[i] = NULL;
382 execvp(a[0], a);
383 Exit(-1);
384 } else if (pid < 0) {
385 werror("cannot fork a new process");
387 XFreeStringList(argv);
388 return False;
389 } else {
390 _tuple *data = wmalloc(sizeof(_tuple));
392 data->scr = wwin->screen_ptr;
393 data->command = wtokenjoin(argv, argc);
395 /* not actually a shell command */
396 wAddDeathHandler(pid, shellCommandHandler, data);
398 XFreeStringList(argv);
401 return True;
405 *---------------------------------------------------------------------
406 * wAbort--
407 * Do a major cleanup and exit the program
409 *----------------------------------------------------------------------
411 noreturn void wAbort(Bool dumpCore)
413 int i;
414 WScreen *scr;
416 for (i = 0; i < w_global.screen_count; i++) {
417 scr = wScreenWithNumber(i);
418 if (scr)
419 RestoreDesktop(scr);
421 printf(_("%s aborted.\n"), ProgName);
422 if (dumpCore)
423 abort();
424 else
425 exit(1);
428 static void print_help(void)
430 printf(_("Usage: %s [options]\n"), ProgName);
431 puts(_("The Window Maker window manager for the X window system"));
432 puts("");
433 puts(_(" -display host:dpy display to use"));
434 #ifdef USE_ICCCM_WMREPLACE
435 puts(_(" --replace replace running window manager"));
436 #endif
437 puts(_(" --no-dock do not open the application Dock"));
438 puts(_(" --no-clip do not open the workspace Clip"));
439 puts(_(" --no-autolaunch do not autolaunch applications"));
440 puts(_(" --no-drawer disable drawers in the dock"));
441 puts(_(" --dont-restore do not restore saved session"));
443 puts(_(" --locale locale locale to use"));
445 puts(_(" --visual-id visualid visual id of visual to use"));
446 puts(_(" --static do not update or save configurations"));
447 #ifndef HAVE_INOTIFY
448 puts(_(" --no-polling do not periodically check for configuration updates"));
449 #endif
450 puts(_(" --global_defaults_path print the path for default config and exit"));
451 puts(_(" --version print version and exit"));
452 puts(_(" --help show this message"));
455 static void check_defaults(void)
457 char *path;
459 path = wdefaultspathfordomain("WindowMaker");
461 if (access(path, R_OK) != 0) {
462 wwarning(_("could not find user GNUstep directory (%s)."), path);
464 if (system("wmaker.inst --batch") != 0) {
465 wwarning(_("There was an error while creating GNUstep directory, please "
466 "make sure you have installed Window Maker correctly and run wmaker.inst"));
467 } else {
468 wwarning(_("%s directory created with default configuration."), path);
472 wfree(path);
475 #ifdef HAVE_INOTIFY
477 * Add watch here, used to notify if configuration
478 * files have changed, using linux kernel inotify mechanism
481 static void inotifyWatchConfig(void)
483 char *watchPath = NULL;
485 w_global.inotify.fd_event_queue = inotify_init(); /* Initialise an inotify instance */
486 if (w_global.inotify.fd_event_queue < 0) {
487 wwarning(_("could not initialise an inotify instance."
488 " Changes to the defaults database will require"
489 " a restart to take effect. Check your kernel!"));
490 } else {
491 watchPath = wstrconcat(wusergnusteppath(), "/Defaults");
492 /* Add the watch; really we are only looking for modify events
493 * but we might want more in the future so check all events for now.
494 * The individual events are checked for in event.c.
496 w_global.inotify.wd_defaults = inotify_add_watch(w_global.inotify.fd_event_queue, watchPath, IN_ALL_EVENTS);
497 if (w_global.inotify.wd_defaults < 0) {
498 wwarning(_("could not add an inotify watch on path %s."
499 " Changes to the defaults database will require"
500 " a restart to take effect."), watchPath);
501 close(w_global.inotify.fd_event_queue);
502 w_global.inotify.fd_event_queue = -1;
505 wfree(watchPath);
507 #endif /* HAVE_INOTIFY */
509 static void execInitScript(void)
511 char *file, *paths;
513 paths = wstrconcat(wusergnusteppath(), "/Library/WindowMaker");
514 paths = wstrappend(paths, ":" DEF_CONFIG_PATHS);
516 file = wfindfile(paths, DEF_INIT_SCRIPT);
517 wfree(paths);
519 if (file) {
520 if (system(file) != 0)
521 werror(_("%s:could not execute initialization script"), file);
523 wfree(file);
527 void ExecExitScript(void)
529 char *file, *paths;
531 paths = wstrconcat(wusergnusteppath(), "/Library/WindowMaker");
532 paths = wstrappend(paths, ":" DEF_CONFIG_PATHS);
534 file = wfindfile(paths, DEF_EXIT_SCRIPT);
535 wfree(paths);
537 if (file) {
538 if (system(file) != 0)
539 werror(_("%s:could not execute exit script"), file);
541 wfree(file);
545 int main(int argc, char **argv)
547 int i_am_the_monitor, i, len;
548 char *str, *alt;
550 memset(&w_global, 0, sizeof(w_global));
551 w_global.program.state = WSTATE_NORMAL;
552 w_global.program.signal_state = WSTATE_NORMAL;
553 w_global.timestamp.last_event = CurrentTime;
554 w_global.timestamp.focus_change = CurrentTime;
555 w_global.ignore_workspace_change = False;
556 w_global.shortcut.modifiers_mask = 0xff;
558 /* setup common stuff for the monitor and wmaker itself */
559 WMInitializeApplication("WindowMaker", &argc, argv);
561 memset(&wPreferences, 0, sizeof(wPreferences));
563 wPreferences.fallbackWMs = WMCreateArray(8);
564 alt = getenv("WINDOWMAKER_ALT_WM");
565 if (alt != NULL)
566 WMAddToArray(wPreferences.fallbackWMs, wstrdup(alt));
568 WMAddToArray(wPreferences.fallbackWMs, wstrdup("blackbox"));
569 WMAddToArray(wPreferences.fallbackWMs, wstrdup("metacity"));
570 WMAddToArray(wPreferences.fallbackWMs, wstrdup("fvwm"));
571 WMAddToArray(wPreferences.fallbackWMs, wstrdup("twm"));
572 WMAddToArray(wPreferences.fallbackWMs, NULL);
573 WMAddToArray(wPreferences.fallbackWMs, wstrdup("rxvt"));
574 WMAddToArray(wPreferences.fallbackWMs, wstrdup("xterm"));
576 i_am_the_monitor = 1;
578 for (i = 1; i < argc; i++) {
579 if (strncmp(argv[i], "--for-real", strlen("--for-real")) == 0) {
580 i_am_the_monitor = 0;
581 break;
582 } else if (strcmp(argv[i], "-display") == 0 || strcmp(argv[i], "--display") == 0) {
583 i++;
584 if (i >= argc) {
585 wwarning(_("too few arguments for %s"), argv[i - 1]);
586 exit(0);
588 DisplayName = argv[i];
592 DisplayName = XDisplayName(DisplayName);
593 len = strlen(DisplayName) + 64;
594 str = wmalloc(len);
595 snprintf(str, len, "DISPLAY=%s", DisplayName);
596 putenv(str);
598 if (i_am_the_monitor)
599 return MonitorLoop(argc, argv);
600 else
601 return real_main(argc, argv);
604 static int real_main(int argc, char **argv)
606 int i;
607 char *pos;
608 int d, s;
610 setlocale(LC_ALL, "");
611 wsetabort(wAbort);
613 /* for telling WPrefs what's the name of the wmaker binary being ran */
614 setenv("WMAKER_BIN_NAME", argv[0], 1);
616 ArgCount = argc;
617 Arguments = wmalloc(sizeof(char *) * (ArgCount + 1));
618 for (i = 0; i < argc; i++) {
619 Arguments[i] = argv[i];
621 /* add the extra option to signal that we're just restarting wmaker */
622 Arguments[argc - 1] = "--for-real=";
623 Arguments[argc] = NULL;
625 ProgName = strrchr(argv[0], '/');
626 if (!ProgName)
627 ProgName = argv[0];
628 else
629 ProgName++;
631 if (argc > 1) {
632 for (i = 1; i < argc; i++) {
633 if (strcmp(argv[i], "-nocpp") == 0 || strcmp(argv[i], "--no-cpp") == 0) {
634 wwarning(_("option \"%s\" is deprecated, please remove it from your script"), argv[i]);
635 } else if (strcmp(argv[i], "--for-real") == 0) {
636 wPreferences.flags.restarting = 0;
637 } else if (strcmp(argv[i], "--for-real=") == 0) {
638 wPreferences.flags.restarting = 1;
639 } else if (strcmp(argv[i], "--for-real-") == 0) {
640 wPreferences.flags.restarting = 2;
641 } else if (strcmp(argv[i], "-no-autolaunch") == 0
642 || strcmp(argv[i], "--no-autolaunch") == 0) {
643 wPreferences.flags.noautolaunch = 1;
644 } else if (strcmp(argv[i], "-dont-restore") == 0 || strcmp(argv[i], "--dont-restore") == 0) {
645 wPreferences.flags.norestore = 1;
646 } else if (strcmp(argv[i], "-nodock") == 0 || strcmp(argv[i], "--no-dock") == 0) {
647 wPreferences.flags.nodock = 1;
648 wPreferences.flags.nodrawer = 1;
649 } else if (strcmp(argv[i], "-noclip") == 0 || strcmp(argv[i], "--no-clip") == 0) {
650 wPreferences.flags.noclip = 1;
651 } else if (strcmp(argv[i], "-nodrawer") == 0 || strcmp(argv[i], "--no-drawer") == 0) {
652 wPreferences.flags.nodrawer = 1;
653 #ifdef USE_ICCCM_WMREPLACE
654 } else if (strcmp(argv[i], "-replace") == 0 || strcmp(argv[i], "--replace") == 0) {
655 wPreferences.flags.replace = 1;
656 #endif
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\n", DEFSDATADIR);
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;