Browse Source

Fork after the window is visible, not before

master
Michael Stapelberg 13 years ago
parent
commit
009a0b1a51
  1. 21
      i3lock.c

21
i3lock.c

@ -63,6 +63,7 @@ static bool beep = false;
static bool debug_mode = false; static bool debug_mode = false;
static bool dpms = false; static bool dpms = false;
static bool unlock_indicator = true; static bool unlock_indicator = true;
static bool dont_fork = false;
static struct ev_loop *main_loop; static struct ev_loop *main_loop;
static struct ev_timer *clear_pam_wrong_timeout; static struct ev_timer *clear_pam_wrong_timeout;
static struct ev_timer *clear_indicator_timeout; static struct ev_timer *clear_indicator_timeout;
@ -710,6 +711,19 @@ static void xcb_check_cb(EV_P_ ev_check *w, int revents) {
continue; continue;
} }
if (type == XCB_MAP_NOTIFY) {
if (!dont_fork) {
/* After the first MapNotify, we never fork again. We don’t
* expect to get another MapNotify, but better be sure */
dont_fork = true;
/* In the parent process, we exit */
if (fork() != 0)
exit(0);
}
continue;
}
if (type == XCB_MAPPING_NOTIFY) { if (type == XCB_MAPPING_NOTIFY) {
handle_mapping_notify((xcb_mapping_notify_event_t*)event); handle_mapping_notify((xcb_mapping_notify_event_t*)event);
continue; continue;
@ -727,7 +741,6 @@ static void xcb_check_cb(EV_P_ ev_check *w, int revents) {
} }
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
bool dont_fork = false;
char *username; char *username;
#ifndef NOLIBCAIRO #ifndef NOLIBCAIRO
char *image_path = NULL; char *image_path = NULL;
@ -842,12 +855,6 @@ int main(int argc, char *argv[]) {
xcb_connection_has_error(conn)) xcb_connection_has_error(conn))
errx(EXIT_FAILURE, "Could not connect to X11, maybe you need to set DISPLAY?"); errx(EXIT_FAILURE, "Could not connect to X11, maybe you need to set DISPLAY?");
if (!dont_fork) {
/* In the parent process, we exit */
if (fork() != 0)
return 0;
}
/* if DPMS is enabled, check if the X server really supports it */ /* if DPMS is enabled, check if the X server really supports it */
if (dpms) { if (dpms) {
xcb_dpms_capable_cookie_t dpmsc = xcb_dpms_capable(conn); xcb_dpms_capable_cookie_t dpmsc = xcb_dpms_capable(conn);

Loading…
Cancel
Save