X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fmain.c;h=cc60d69cd8fd07a5a1cf4142d7e9510ad0e4016d;hb=5aa43d61f84e69c9b46cfc3e37c6806b887f01d8;hp=aee95f757b7763eaa4f87f1f250448281d828315;hpb=0e46f17fffa70ac62527d9839a62187fb8b4c1fa;p=i3%2Fi3 diff --git a/src/main.c b/src/main.c index aee95f75..cc60d69c 100644 --- a/src/main.c +++ b/src/main.c @@ -163,6 +163,14 @@ static void xkb_got_event(EV_P_ struct ev_io *w, int revents) { DLOG("Done\n"); } +/* + * Exit handler which destroys the main_loop. Will trigger cleanup handlers. + * + */ +static void i3_exit() { + ev_loop_destroy(main_loop); +} + int main(int argc, char *argv[]) { //parse_cmd("[ foo ] attach, attach ; focus"); int screens; @@ -424,7 +432,10 @@ int main(int argc, char *argv[]) { free(greply); - if (force_xinerama) { + /* Force Xinerama (for drivers which don't support RandR yet, esp. the + * nVidia binary graphics driver), when specified either in the config + * file or on command-line */ + if (force_xinerama || config.force_xinerama) { xinerama_init(); } else { DLOG("Checking for XRandR...\n"); @@ -529,5 +540,9 @@ int main(int argc, char *argv[]) { start_application(exec_always->command); } + /* Make sure to destroy the event loop to invoke the cleeanup callbacks + * when calling exit() */ + atexit(i3_exit); + ev_loop(main_loop, 0); }