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
)
51 static void print_help(const char *progname
)
53 printf(_("usage: %s [options]\n"), progname
);
55 puts(_(" -display <display> display to be used"));
56 puts(_(" --version print version number and exit"));
57 puts(_(" --help print this message and exit"));
61 static RETSIGTYPE
handleDeadChild(int sig
)
66 pid
= waitpid(-1, &status
, WNOHANG
);
68 DeadChildren
[DeadChildrenCount
++] = pid
;
73 void AddDeadChildHandler(pid_t pid
, void (*handler
) (void *), void *data
)
77 for (i
= 0; i
< MAX_DEATHS
; i
++) {
78 if (DeadHandlers
[i
].pid
== 0) {
79 DeadHandlers
[i
].pid
= pid
;
80 DeadHandlers
[i
].handler
= handler
;
81 DeadHandlers
[i
].data
= data
;
85 assert(i
!= MAX_DEATHS
);
88 int main(int argc
, char **argv
)
94 char *display_name
= "";
98 memset(DeadHandlers
, 0, sizeof(DeadHandlers
));
100 WMInitializeApplication("WPrefs", &argc
, argv
);
102 WMSetResourcePath(RESOURCE_PATH
);
103 path
= WMPathForResourceOfType("WPrefs.tiff", NULL
);
105 /* maybe it is run directly from the source directory */
106 WMSetResourcePath(".");
107 path
= WMPathForResourceOfType("WPrefs.tiff", NULL
);
109 WMSetResourcePath("..");
117 for (i
= 1; i
< argc
; i
++) {
118 if (strcmp(argv
[i
], "-version") == 0 || strcmp(argv
[i
], "--version") == 0) {
119 printf("WPrefs (Window Maker) %s\n", VERSION
);
121 } else if (strcmp(argv
[i
], "-display") == 0) {
124 wwarning(_("too few arguments for %s"), argv
[i
- 1]);
127 display_name
= argv
[i
];
135 setlocale(LC_ALL
, "");
138 if (getenv("NLSPATH"))
139 bindtextdomain("WPrefs", getenv("NLSPATH"));
141 bindtextdomain("WPrefs", LOCALEDIR
);
142 bind_textdomain_codeset("WPrefs", "UTF-8");
143 textdomain("WPrefs");
145 if (!XSupportsLocale()) {
146 wwarning(_("X server does not support locale"));
148 if (XSetLocaleModifiers("") == NULL
) {
149 wwarning(_("cannot set locale modifiers"));
153 dpy
= XOpenDisplay(display_name
);
155 wfatal(_("could not open display %s"), XDisplayName(display_name
));
159 XSynchronize(dpy
, 1);
161 scr
= WMCreateScreen(dpy
, DefaultScreen(dpy
));
163 wfatal(_("could not initialize application"));
167 xext_xkb_supported
= XkbQueryExtension(dpy
, NULL
, NULL
, NULL
, NULL
, NULL
);
169 WMPLSetCaseSensitive(False
);
176 WMNextEvent(dpy
, &event
);
178 while (DeadChildrenCount
-- > 0) {
181 for (i
= 0; i
< MAX_DEATHS
; i
++) {
182 if (DeadChildren
[i
] == DeadHandlers
[i
].pid
) {
183 (*DeadHandlers
[i
].handler
) (DeadHandlers
[i
].data
);
184 DeadHandlers
[i
].pid
= 0;
189 WMHandleEvent(&event
);