2 * WPrefs - Window Maker Preferences Program
4 * Copyright (c) 1998-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.
25 #include <X11/Xlocale.h>
26 #include <X11/XKBlib.h>
31 char *NOptionValueChanged
= "NOptionValueChanged";
32 Bool xext_xkb_supported
= False
;
40 void (*handler
) (void *);
41 } DeadHandlers
[MAX_DEATHS
];
43 static pid_t DeadChildren
[MAX_DEATHS
];
44 static int DeadChildrenCount
= 0;
46 static void wAbort(Bool foo
)
48 /* Parameter not used, but tell the compiler that it is ok */
54 static void print_help(const char *progname
)
56 printf(_("usage: %s [options]\n"), progname
);
58 puts(_(" -display <display> display to be used"));
59 puts(_(" --version print version number and exit"));
60 puts(_(" --help print this message and exit"));
64 static RETSIGTYPE
handleDeadChild(int sig
)
69 pid
= waitpid(-1, &status
, WNOHANG
);
71 DeadChildren
[DeadChildrenCount
++] = pid
;
76 void AddDeadChildHandler(pid_t pid
, void (*handler
) (void *), void *data
)
80 for (i
= 0; i
< MAX_DEATHS
; i
++) {
81 if (DeadHandlers
[i
].pid
== 0) {
82 DeadHandlers
[i
].pid
= pid
;
83 DeadHandlers
[i
].handler
= handler
;
84 DeadHandlers
[i
].data
= data
;
88 assert(i
!= MAX_DEATHS
);
91 int main(int argc
, char **argv
)
97 char *display_name
= "";
101 memset(DeadHandlers
, 0, sizeof(DeadHandlers
));
103 WMInitializeApplication("WPrefs", &argc
, argv
);
105 WMSetResourcePath(RESOURCE_PATH
);
106 path
= WMPathForResourceOfType("WPrefs.tiff", NULL
);
108 /* maybe it is run directly from the source directory */
109 WMSetResourcePath(".");
110 path
= WMPathForResourceOfType("WPrefs.tiff", NULL
);
112 WMSetResourcePath("..");
120 for (i
= 1; i
< argc
; i
++) {
121 if (strcmp(argv
[i
], "-version") == 0 || strcmp(argv
[i
], "--version") == 0) {
122 printf("WPrefs (Window Maker) %s\n", VERSION
);
124 } else if (strcmp(argv
[i
], "-display") == 0) {
127 wwarning(_("too few arguments for %s"), argv
[i
- 1]);
130 display_name
= argv
[i
];
138 setlocale(LC_ALL
, "");
141 if (getenv("NLSPATH"))
142 bindtextdomain("WPrefs", getenv("NLSPATH"));
144 bindtextdomain("WPrefs", LOCALEDIR
);
145 bind_textdomain_codeset("WPrefs", "UTF-8");
146 textdomain("WPrefs");
148 if (!XSupportsLocale()) {
149 wwarning(_("X server does not support locale"));
151 if (XSetLocaleModifiers("") == NULL
) {
152 wwarning(_("cannot set locale modifiers"));
156 dpy
= XOpenDisplay(display_name
);
158 wfatal(_("could not open display %s"), XDisplayName(display_name
));
162 XSynchronize(dpy
, 1);
164 scr
= WMCreateScreen(dpy
, DefaultScreen(dpy
));
166 wfatal(_("could not initialize application"));
170 xext_xkb_supported
= XkbQueryExtension(dpy
, NULL
, NULL
, NULL
, NULL
, NULL
);
172 WMPLSetCaseSensitive(False
);
179 WMNextEvent(dpy
, &event
);
181 while (DeadChildrenCount
-- > 0) {
184 for (i
= 0; i
< MAX_DEATHS
; i
++) {
185 if (DeadChildren
[i
] == DeadHandlers
[i
].pid
) {
186 (*DeadHandlers
[i
].handler
) (DeadHandlers
[i
].data
);
187 DeadHandlers
[i
].pid
= 0;
192 WMHandleEvent(&event
);