2 Commits 42946432a2 ... f425afb2e8

Author SHA1 Message Date
  Lucas Sköldqvist f425afb2e8 Exit when connection to X cannot be established 4 years ago
  Lucas Sköldqvist 9b6a24cc97 Rename Center to Centre 4 years ago
1 changed files with 9 additions and 2 deletions
  1. 9 2
      fittsen.c

+ 9 - 2
fittsen.c

@@ -244,7 +244,7 @@ get_section(const char *section)
 {
     if (strcmp(section, "TopLeft") == 0)
         return 0;
-    else if (strcmp(section, "TopCenter") == 0 || strcmp(section, "TopCentre") == 0)
+    else if (strcmp(section, "TopCentre") == 0)
         return 1;
     else if (strcmp(section, "TopRight") == 0)
         return 2;
@@ -252,7 +252,7 @@ get_section(const char *section)
         return 3;
     else if (strcmp(section, "BottomRight") == 0)
         return 4;
-    else if (strcmp(section, "BottomCenter") == 0 || strcmp(section, "BottomCentre") == 0)
+    else if (strcmp(section, "BottomCentre") == 0)
         return 5;
     else if (strcmp(section, "BottomLeft") == 0)
         return 6;
@@ -340,6 +340,12 @@ int
 main(int argc, char *argv[])
 {
     xcb_connection_t *conn = xcb_connect(NULL, NULL);
+
+    if (xcb_connection_has_error(conn) > 0) {
+        fprintf(stderr, "Cannot connect to X\n");
+        return 1;
+    }
+
     xcb_screen_t *screen = xcb_setup_roots_iterator(xcb_get_setup(conn)).data;
 
     init_options(screen->width_in_pixels, screen->height_in_pixels);
@@ -350,6 +356,7 @@ main(int argc, char *argv[])
 
     server_create_windows(conn, screen);
     server_event_loop(conn);
+
     xcb_disconnect(conn);
 
     return 0;