Update Serbian translation from master branch
[wmaker-crm.git] / src / main.c
blob7bc8bcdb7c71546299199e7d5a72913ce4b762e8
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"
59 #include "misc.h"
61 #include <WINGs/WUtil.h>
63 /****** Global Variables ******/
64 struct wmaker_global_variables w_global;
66 /* general info */
68 Display *dpy;
70 char *ProgName;
72 struct WPreferences wPreferences;
74 WShortKey wKeyBindings[WKBD_LAST];
76 /* notifications */
77 const char WMNManaged[] = "WMNManaged";
78 const char WMNUnmanaged[] = "WMNUnmanaged";
79 const char WMNChangedWorkspace[] = "WMNChangedWorkspace";
80 const char WMNChangedState[] = "WMNChangedState";
81 const char WMNChangedFocus[] = "WMNChangedFocus";
82 const char WMNChangedStacking[] = "WMNChangedStacking";
83 const char WMNChangedName[] = "WMNChangedName";
85 const char WMNWorkspaceCreated[] = "WMNWorkspaceCreated";
86 const char WMNWorkspaceDestroyed[] = "WMNWorkspaceDestroyed";
87 const char WMNWorkspaceChanged[] = "WMNWorkspaceChanged";
88 const char WMNWorkspaceNameChanged[] = "WMNWorkspaceNameChanged";
90 const char WMNResetStacking[] = "WMNResetStacking";
92 /******** End Global Variables *****/
94 static char *DisplayName = NULL;
96 static char **Arguments;
98 static int ArgCount;
100 static Bool multiHead = True;
102 static int *wVisualID = NULL;
103 static int wVisualID_len = 0;
105 static int real_main(int argc, char **argv);
107 int getWVisualID(int screen)
109 if (wVisualID == NULL)
110 return -1;
111 if (screen < 0 || screen >= wVisualID_len)
112 return -1;
114 return wVisualID[screen];
117 static void setWVisualID(int screen, int val)
119 int i;
121 if (screen < 0)
122 return;
124 if (wVisualID == NULL) {
125 /* no array at all, alloc space for screen + 1 entries
126 * and init with default value */
127 wVisualID_len = screen + 1;
128 wVisualID = (int *)malloc(wVisualID_len * sizeof(int));
129 for (i = 0; i < wVisualID_len; i++) {
130 wVisualID[i] = -1;
132 } else if (screen >= wVisualID_len) {
133 /* larger screen number than previously allocated
134 so enlarge array */
135 int oldlen = wVisualID_len;
137 wVisualID_len = screen + 1;
138 wVisualID = (int *)wrealloc(wVisualID, wVisualID_len * sizeof(int));
139 for (i = oldlen; i < wVisualID_len; i++) {
140 wVisualID[i] = -1;
144 wVisualID[screen] = val;
148 * this function splits a given string at the comma into tokens
149 * and set the wVisualID variable to each parsed number
151 static int initWVisualID(const char *user_str)
153 char *mystr = strdup(user_str);
154 int cur_in_pos = 0;
155 int cur_out_pos = 0;
156 int cur_screen = 0;
157 int error_found = 0;
159 for (;;) {
160 /* check for delimiter */
161 if (user_str[cur_in_pos] == '\0' || user_str[cur_in_pos] == ',') {
162 int v;
164 mystr[cur_out_pos] = '\0';
166 if (sscanf(mystr, "%i", &v) != 1) {
167 error_found = 1;
168 break;
171 setWVisualID(cur_screen, v);
173 cur_screen++;
174 cur_out_pos = 0;
177 /* break in case last char has been consumed */
178 if (user_str[cur_in_pos] == '\0')
179 break;
181 /* if the current char is no delimiter put it into mystr */
182 if (user_str[cur_in_pos] != ',') {
183 mystr[cur_out_pos++] = user_str[cur_in_pos];
185 cur_in_pos++;
188 free(mystr);
190 if (cur_screen == 0||error_found != 0)
191 return 1;
193 return 0;
196 noreturn void Exit(int status)
198 if (dpy)
199 XCloseDisplay(dpy);
201 RShutdown(); /* wrlib clean exit */
202 wutil_shutdown(); /* WUtil clean-up */
204 exit(status);
207 void Restart(char *manager, Bool abortOnFailure)
209 char *prog = NULL;
210 char *argv[MAX_RESTART_ARGS];
211 int i;
213 if (manager && manager[0] != 0) {
214 prog = argv[0] = strtok(manager, " ");
215 for (i = 1; i < MAX_RESTART_ARGS; i++) {
216 argv[i] = strtok(NULL, " ");
217 if (argv[i] == NULL) {
218 break;
222 if (dpy) {
223 XCloseDisplay(dpy);
224 dpy = NULL;
226 if (!prog) {
227 execvp(Arguments[0], Arguments);
228 wfatal(_("failed to restart Window Maker."));
229 } else {
230 execvp(prog, argv);
231 werror(_("could not exec %s"), prog);
233 if (abortOnFailure)
234 exit(7);
237 void SetupEnvironment(WScreen * scr)
239 char *tmp, *ptr;
240 char buf[16];
242 if (multiHead) {
243 int len = strlen(DisplayName) + 64;
244 tmp = wmalloc(len);
245 snprintf(tmp, len, "DISPLAY=%s", XDisplayName(DisplayName));
247 /* Search from the end to be compatible with ipv6 address */
248 ptr = strrchr(tmp, ':');
249 if (ptr == NULL) {
250 static Bool message_already_displayed = False;
252 if (!message_already_displayed)
253 wwarning(_("the display name has an unexpected syntax: \"%s\""),
254 XDisplayName(DisplayName));
255 message_already_displayed = True;
256 } else {
257 /* If found, remove the screen specification from the display variable */
258 ptr = strchr(ptr, '.');
259 if (ptr)
260 *ptr = 0;
262 snprintf(buf, sizeof(buf), ".%i", scr->screen);
263 strcat(tmp, buf);
264 putenv(tmp);
266 tmp = wmalloc(60);
267 snprintf(tmp, 60, "WRASTER_COLOR_RESOLUTION%i=%i", scr->screen,
268 scr->rcontext->attribs->colors_per_channel);
269 putenv(tmp);
272 typedef struct {
273 WScreen *scr;
274 char *command;
275 } _tuple;
277 static void shellCommandHandler(pid_t pid, unsigned int status, void *client_data)
279 _tuple *data = (_tuple *) client_data;
281 /* Parameter not used, but tell the compiler that it is ok */
282 (void) pid;
284 if (status == 127) {
285 char *buffer;
287 buffer = wstrconcat(_("Could not execute command: "), data->command);
289 wMessageDialog(data->scr, _("Error"), buffer, _("OK"), NULL, NULL);
290 wfree(buffer);
291 } else if (status != 127) {
293 printf("%s: %i\n", data->command, status);
297 wfree(data->command);
298 wfree(data);
301 void ExecuteShellCommand(WScreen *scr, const char *command)
303 static char *shell = NULL;
304 pid_t pid;
307 * This have a problem: if the shell is tcsh (not sure about others)
308 * and ~/.tcshrc have /bin/stty erase ^H somewhere on it, the shell
309 * will block and the command will not be executed.
310 if (!shell) {
311 shell = getenv("SHELL");
312 if (!shell)
313 shell = "/bin/sh";
316 shell = "/bin/sh";
318 pid = fork();
320 if (pid == 0) {
322 SetupEnvironment(scr);
324 #ifdef HAVE_SETSID
325 setsid();
326 #endif
327 execl(shell, shell, "-c", command, NULL);
328 werror("could not execute %s -c %s", shell, command);
329 Exit(-1);
330 } else if (pid < 0) {
331 werror("cannot fork a new process");
332 } else {
333 _tuple *data = wmalloc(sizeof(_tuple));
335 data->scr = scr;
336 data->command = wstrdup(command);
338 wAddDeathHandler(pid, shellCommandHandler, data);
343 *---------------------------------------------------------------------
344 * RelaunchWindow--
345 * Launch a new instance of the active window
347 *----------------------------------------------------------------------
349 Bool RelaunchWindow(WWindow *wwin)
351 if (! wwin || ! wwin->client_win) {
352 werror("no window to relaunch");
353 return False;
356 char **argv;
357 int argc;
358 char *command = NULL;
360 command = GetCommandForWindow(wwin->client_win);
361 if (!command) {
362 #ifdef USE_XRES
363 werror("cannot relaunch the application because no associated process found");
364 #else
365 werror("cannot relaunch the application because no WM_COMMAND property is set");
366 #endif
367 return False;
368 } else
369 wtokensplit(command, &argv, &argc);
372 pid_t pid = fork();
374 if (pid == 0) {
375 SetupEnvironment(wwin->screen_ptr);
376 #ifdef HAVE_SETSID
377 setsid();
378 #endif
379 /* argv is not null-terminated */
380 char **a = (char **) malloc(argc + 1);
381 if (! a) {
382 werror("out of memory trying to relaunch the application");
383 Exit(-1);
386 int i;
387 for (i = 0; i < argc; i++)
388 a[i] = argv[i];
389 a[i] = NULL;
391 execvp(a[0], a);
392 Exit(-1);
393 } else if (pid < 0) {
394 werror("cannot fork a new process");
396 wtokenfree(argv, argc);
397 wfree(command);
398 return False;
399 } else {
400 _tuple *data = wmalloc(sizeof(_tuple));
402 data->scr = wwin->screen_ptr;
403 data->command = command;
405 /* not actually a shell command */
406 wAddDeathHandler(pid, shellCommandHandler, data);
408 wtokenfree(argv, argc);
411 return True;
415 *---------------------------------------------------------------------
416 * wAbort--
417 * Do a major cleanup and exit the program
419 *----------------------------------------------------------------------
421 noreturn void wAbort(Bool dumpCore)
423 int i;
424 WScreen *scr;
426 for (i = 0; i < w_global.screen_count; i++) {
427 scr = wScreenWithNumber(i);
428 if (scr)
429 RestoreDesktop(scr);
431 printf(_("%s aborted.\n"), ProgName);
432 if (dumpCore)
433 abort();
434 else
435 exit(1);
438 static void print_help(void)
440 printf(_("Usage: %s [options]\n"), ProgName);
441 puts(_("The Window Maker window manager for the X window system"));
442 puts("");
443 puts(_(" -display host:dpy display to use"));
444 #ifdef USE_ICCCM_WMREPLACE
445 puts(_(" --replace replace running window manager"));
446 #endif
447 puts(_(" --no-dock do not open the application Dock"));
448 puts(_(" --no-clip do not open the workspace Clip"));
449 puts(_(" --no-autolaunch do not autolaunch applications"));
450 puts(_(" --no-drawer disable drawers in the dock"));
451 puts(_(" --dont-restore do not restore saved session"));
453 puts(_(" --locale locale locale to use"));
455 puts(_(" --visual-id visualid visual id of visual to use"));
456 puts(_(" --static do not update or save configurations"));
457 #ifndef HAVE_INOTIFY
458 puts(_(" --no-polling do not periodically check for configuration updates"));
459 #endif
460 puts(_(" --global_defaults_path print the path for default config and exit"));
461 puts(_(" --version print version and exit"));
462 puts(_(" --help show this message"));
465 static void check_defaults(void)
467 char *path;
469 path = wdefaultspathfordomain("WindowMaker");
471 if (access(path, R_OK) != 0) {
472 wwarning(_("could not find user GNUstep directory (%s)."), path);
474 if (system("wmaker.inst --batch") != 0) {
475 wwarning(_("There was an error while creating GNUstep directory, please "
476 "make sure you have installed Window Maker correctly and run wmaker.inst"));
477 } else {
478 wwarning(_("%s directory created with default configuration."), path);
482 wfree(path);
485 #ifdef HAVE_INOTIFY
487 * Add watch here, used to notify if configuration
488 * files have changed, using linux kernel inotify mechanism
491 static void inotifyWatchConfig(void)
493 char *watchPath = NULL;
495 w_global.inotify.fd_event_queue = inotify_init(); /* Initialise an inotify instance */
496 if (w_global.inotify.fd_event_queue < 0) {
497 wwarning(_("could not initialise an inotify instance."
498 " Changes to the defaults database will require"
499 " a restart to take effect. Check your kernel!"));
500 } else {
501 watchPath = wdefaultspathfordomain("");
502 /* Add the watch; really we are only looking for modify events
503 * but we might want more in the future so check all events for now.
504 * The individual events are checked for in event.c.
506 w_global.inotify.wd_defaults = inotify_add_watch(w_global.inotify.fd_event_queue, watchPath, IN_ALL_EVENTS);
507 if (w_global.inotify.wd_defaults < 0) {
508 wwarning(_("could not add an inotify watch on path %s."
509 " Changes to the defaults database will require"
510 " a restart to take effect."), watchPath);
511 close(w_global.inotify.fd_event_queue);
512 w_global.inotify.fd_event_queue = -1;
515 wfree(watchPath);
517 #endif /* HAVE_INOTIFY */
519 static void execInitScript(void)
521 char *file, *paths;
523 paths = wstrconcat(wuserdatapath(), "/" PACKAGE_TARNAME);
524 paths = wstrappend(paths, ":" DEF_CONFIG_PATHS);
526 file = wfindfile(paths, DEF_INIT_SCRIPT);
527 wfree(paths);
529 if (file) {
530 if (system(file) != 0)
531 werror(_("%s:could not execute initialization script"), file);
533 wfree(file);
537 void ExecExitScript(void)
539 char *file, *paths;
541 paths = wstrconcat(wuserdatapath(), "/" PACKAGE_TARNAME);
542 paths = wstrappend(paths, ":" DEF_CONFIG_PATHS);
544 file = wfindfile(paths, DEF_EXIT_SCRIPT);
545 wfree(paths);
547 if (file) {
548 if (system(file) != 0)
549 werror(_("%s:could not execute exit script"), file);
551 wfree(file);
555 int main(int argc, char **argv)
557 int i_am_the_monitor, i, len;
558 char *str, *alt;
560 memset(&w_global, 0, sizeof(w_global));
561 w_global.program.state = WSTATE_NORMAL;
562 w_global.program.signal_state = WSTATE_NORMAL;
563 w_global.timestamp.last_event = CurrentTime;
564 w_global.timestamp.focus_change = CurrentTime;
565 w_global.ignore_workspace_change = False;
566 w_global.shortcut.modifiers_mask = 0xff;
568 /* setup common stuff for the monitor and wmaker itself */
569 WMInitializeApplication("WindowMaker", &argc, argv);
571 memset(&wPreferences, 0, sizeof(wPreferences));
573 wPreferences.fallbackWMs = WMCreateArray(8);
574 alt = getenv("WINDOWMAKER_ALT_WM");
575 if (alt != NULL)
576 WMAddToArray(wPreferences.fallbackWMs, wstrdup(alt));
578 WMAddToArray(wPreferences.fallbackWMs, wstrdup("blackbox"));
579 WMAddToArray(wPreferences.fallbackWMs, wstrdup("metacity"));
580 WMAddToArray(wPreferences.fallbackWMs, wstrdup("fvwm"));
581 WMAddToArray(wPreferences.fallbackWMs, wstrdup("twm"));
582 WMAddToArray(wPreferences.fallbackWMs, NULL);
583 WMAddToArray(wPreferences.fallbackWMs, wstrdup("rxvt"));
584 WMAddToArray(wPreferences.fallbackWMs, wstrdup("xterm"));
586 i_am_the_monitor = 1;
588 for (i = 1; i < argc; i++) {
589 if (strncmp(argv[i], "--for-real", strlen("--for-real")) == 0) {
590 i_am_the_monitor = 0;
591 break;
592 } else if (strcmp(argv[i], "-display") == 0 || strcmp(argv[i], "--display") == 0) {
593 i++;
594 if (i >= argc) {
595 wwarning(_("too few arguments for %s"), argv[i - 1]);
596 exit(0);
598 DisplayName = argv[i];
602 DisplayName = XDisplayName(DisplayName);
603 len = strlen(DisplayName) + 64;
604 str = wmalloc(len);
605 snprintf(str, len, "DISPLAY=%s", DisplayName);
606 putenv(str);
608 if (i_am_the_monitor)
609 return MonitorLoop(argc, argv);
610 else
611 return real_main(argc, argv);
614 static int real_main(int argc, char **argv)
616 int i;
617 char *pos;
618 int d, s;
620 setlocale(LC_ALL, "");
621 wsetabort(wAbort);
623 /* for telling WPrefs what's the name of the wmaker binary being ran */
624 setenv("WMAKER_BIN_NAME", argv[0], 1);
626 ArgCount = argc;
627 Arguments = wmalloc(sizeof(char *) * (ArgCount + 1));
628 for (i = 0; i < argc; i++) {
629 Arguments[i] = argv[i];
631 /* add the extra option to signal that we're just restarting wmaker */
632 Arguments[argc - 1] = "--for-real=";
633 Arguments[argc] = NULL;
635 ProgName = strrchr(argv[0], '/');
636 if (!ProgName)
637 ProgName = argv[0];
638 else
639 ProgName++;
641 if (argc > 1) {
642 for (i = 1; i < argc; i++) {
643 if (strcmp(argv[i], "-nocpp") == 0 || strcmp(argv[i], "--no-cpp") == 0) {
644 wwarning(_("option \"%s\" is deprecated, please remove it from your script"), argv[i]);
645 } else if (strcmp(argv[i], "--for-real") == 0) {
646 wPreferences.flags.restarting = 0;
647 } else if (strcmp(argv[i], "--for-real=") == 0) {
648 wPreferences.flags.restarting = 1;
649 } else if (strcmp(argv[i], "--for-real-") == 0) {
650 wPreferences.flags.restarting = 2;
651 } else if (strcmp(argv[i], "-no-autolaunch") == 0
652 || strcmp(argv[i], "--no-autolaunch") == 0) {
653 wPreferences.flags.noautolaunch = 1;
654 } else if (strcmp(argv[i], "-dont-restore") == 0 || strcmp(argv[i], "--dont-restore") == 0) {
655 wPreferences.flags.norestore = 1;
656 } else if (strcmp(argv[i], "-nodock") == 0 || strcmp(argv[i], "--no-dock") == 0) {
657 wPreferences.flags.nodock = 1;
658 wPreferences.flags.nodrawer = 1;
659 } else if (strcmp(argv[i], "-noclip") == 0 || strcmp(argv[i], "--no-clip") == 0) {
660 wPreferences.flags.noclip = 1;
661 } else if (strcmp(argv[i], "-nodrawer") == 0 || strcmp(argv[i], "--no-drawer") == 0) {
662 wPreferences.flags.nodrawer = 1;
663 #ifdef USE_ICCCM_WMREPLACE
664 } else if (strcmp(argv[i], "-replace") == 0 || strcmp(argv[i], "--replace") == 0) {
665 wPreferences.flags.replace = 1;
666 #endif
667 } else if (strcmp(argv[i], "-version") == 0 || strcmp(argv[i], "--version") == 0) {
668 printf("Window Maker %s\n", VERSION);
669 exit(0);
670 } else if (strcmp(argv[i], "--global_defaults_path") == 0) {
671 printf("%s\n", PKGCONFDIR);
672 exit(0);
673 } else if (strcmp(argv[i], "-locale") == 0 || strcmp(argv[i], "--locale") == 0) {
674 i++;
675 if (i >= argc) {
676 wwarning(_("too few arguments for %s"), argv[i - 1]);
677 exit(0);
679 w_global.locale = argv[i];
680 } else if (strcmp(argv[i], "-display") == 0 || strcmp(argv[i], "--display") == 0) {
681 i++;
682 if (i >= argc) {
683 wwarning(_("too few arguments for %s"), argv[i - 1]);
684 exit(0);
686 DisplayName = argv[i];
687 } else if (strcmp(argv[i], "-visualid") == 0 || strcmp(argv[i], "--visual-id") == 0) {
688 i++;
689 if (i >= argc) {
690 wwarning(_("too few arguments for %s"), argv[i - 1]);
691 exit(0);
693 if (initWVisualID(argv[i]) != 0) {
694 wwarning(_("bad value for visualid: \"%s\""), argv[i]);
695 exit(0);
697 } else if (strcmp(argv[i], "-static") == 0 || strcmp(argv[i], "--static") == 0) {
698 wPreferences.flags.noupdates = 1;
699 } else if (strcmp(argv[i], "--no-polling") == 0) {
700 #ifndef HAVE_INOTIFY
701 wPreferences.flags.noupdates = 1;
702 #else
703 wmessage(_("your version of Window Maker was compiled with INotify support, so \"--no-polling\" has no effect"));
704 #endif
705 } else if (strcmp(argv[i], "--help") == 0) {
706 print_help();
707 exit(0);
708 } else {
709 printf(_("%s: invalid argument '%s'\n"), argv[0], argv[i]);
710 printf(_("Try '%s --help' for more information\n"), argv[0]);
711 exit(1);
716 if (!wPreferences.flags.noupdates) {
717 /* check existence of Defaults DB directory */
718 check_defaults();
721 if (w_global.locale) {
722 setenv("LANG", w_global.locale, 1);
723 } else {
724 w_global.locale = getenv("LC_ALL");
725 if (!w_global.locale) {
726 w_global.locale = getenv("LANG");
730 setlocale(LC_ALL, "");
732 if (!w_global.locale || strcmp(w_global.locale, "C") == 0 || strcmp(w_global.locale, "POSIX") == 0)
733 w_global.locale = NULL;
734 #ifdef I18N
735 if (getenv("NLSPATH")) {
736 bindtextdomain("WindowMaker", getenv("NLSPATH"));
737 #if defined(MENU_TEXTDOMAIN)
738 bindtextdomain(MENU_TEXTDOMAIN, getenv("NLSPATH"));
739 #endif
740 } else {
741 bindtextdomain("WindowMaker", LOCALEDIR);
742 #if defined(MENU_TEXTDOMAIN)
743 bindtextdomain(MENU_TEXTDOMAIN, LOCALEDIR);
744 #endif
746 bind_textdomain_codeset("WindowMaker", "UTF-8");
747 #if defined(MENU_TEXTDOMAIN)
748 bind_textdomain_codeset(MENU_TEXTDOMAIN, "UTF-8");
749 #endif
750 textdomain("WindowMaker");
752 if (!XSupportsLocale()) {
753 wwarning(_("X server does not support locale"));
756 if (XSetLocaleModifiers("") == NULL) {
757 wwarning(_("cannot set locale modifiers"));
759 #endif
761 if (w_global.locale) {
762 char *ptr;
764 w_global.locale = wstrdup(w_global.locale);
765 ptr = strchr(w_global.locale, '.');
766 if (ptr)
767 *ptr = 0;
770 /* open display */
771 dpy = XOpenDisplay(DisplayName);
772 if (dpy == NULL) {
773 wfatal(_("could not open display \"%s\""), XDisplayName(DisplayName));
774 exit(1);
777 if (fcntl(ConnectionNumber(dpy), F_SETFD, FD_CLOEXEC) < 0) {
778 werror("error setting close-on-exec flag for X connection");
779 exit(1);
783 if (getWVisualID(0) < 0) {
785 * If unspecified, use default visual instead of waiting
786 * for wrlib/context.c:bestContext() that may end up choosing
787 * the "fake" 24 bits added by the Composite extension.
788 * This is required to avoid all sort of corruptions when
789 * composite is enabled, and at a depth other than 24.
791 setWVisualID(0, (int)DefaultVisual(dpy, DefaultScreen(dpy))->visualid);
794 /* check if the user specified a complete display name (with screen).
795 * If so, only manage the specified screen */
796 if (DisplayName)
797 pos = strchr(DisplayName, ':');
798 else
799 pos = NULL;
801 if (pos && sscanf(pos, ":%i.%i", &d, &s) == 2)
802 multiHead = False;
804 DisplayName = XDisplayName(DisplayName);
805 setenv("DISPLAY", DisplayName, 1);
807 wXModifierInitialize();
808 StartUp(!multiHead);
810 if (w_global.screen_count == 1)
811 multiHead = False;
813 execInitScript();
814 #ifdef HAVE_INOTIFY
815 inotifyWatchConfig();
816 #endif
817 EventLoop();
818 return -1;