]> git.sur5r.net Git - i3/i3/blobdiff - i3-config-wizard/main.c
Only react on the last Expose event in a series of events. (#2636)
[i3/i3] / i3-config-wizard / main.c
index 9c9241cd0ad5223d67c77ba20b7ee1a01de31227..8eec941c758144f41e216d7ecdbf498a34677c63 100644 (file)
@@ -2,12 +2,14 @@
  * vim:ts=4:sw=4:expandtab
  *
  * i3 - an improved dynamic tiling window manager
- * © 2009-2012 Michael Stapelberg and contributors (see also: LICENSE)
+ * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
  *
  * i3-config-wizard: Program to convert configs using keycodes to configs using
  *                   keysyms.
  *
  */
+#include <config.h>
+
 #if defined(__FreeBSD__)
 #include <sys/param.h>
 #endif
@@ -392,7 +394,7 @@ static char *rewrite_binding(const char *input) {
                     }
                 }
                 if (walk != beginning) {
-                    char *str = scalloc(walk - beginning + 1);
+                    char *str = scalloc(walk - beginning + 1, 1);
                     /* We copy manually to handle escaping of characters. */
                     int inpos, outpos;
                     for (inpos = 0, outpos = 0;
@@ -479,7 +481,7 @@ static int handle_expose() {
 
     if (current_step == STEP_WELCOME) {
         /* restore font color */
-        set_font_colors(pixmap_gc, get_colorpixel("#FFFFFF"), get_colorpixel("#000000"));
+        set_font_colors(pixmap_gc, draw_util_hex_to_color("#FFFFFF"), draw_util_hex_to_color("#000000"));
 
         txt(logical_px(10), 2, "You have not configured i3 yet.");
         txt(logical_px(10), 3, "Do you want me to generate a config at");
@@ -493,16 +495,16 @@ static int handle_expose() {
         txt(logical_px(85), 8, "No, I will use the defaults");
 
         /* green */
-        set_font_colors(pixmap_gc, get_colorpixel("#00FF00"), get_colorpixel("#000000"));
+        set_font_colors(pixmap_gc, draw_util_hex_to_color("#00FF00"), draw_util_hex_to_color("#000000"));
         txt(logical_px(25), 6, "<Enter>");
 
         /* red */
-        set_font_colors(pixmap_gc, get_colorpixel("#FF0000"), get_colorpixel("#000000"));
+        set_font_colors(pixmap_gc, draw_util_hex_to_color("#FF0000"), draw_util_hex_to_color("#000000"));
         txt(logical_px(31), 8, "<ESC>");
     }
 
     if (current_step == STEP_GENERATE) {
-        set_font_colors(pixmap_gc, get_colorpixel("#FFFFFF"), get_colorpixel("#000000"));
+        set_font_colors(pixmap_gc, draw_util_hex_to_color("#FFFFFF"), draw_util_hex_to_color("#000000"));
 
         txt(logical_px(10), 2, "Please choose either:");
         txt(logical_px(85), 4, "Win as default modifier");
@@ -519,7 +521,7 @@ static int handle_expose() {
 
         /* the selected modifier */
         set_font(&bold_font);
-        set_font_colors(pixmap_gc, get_colorpixel("#FFFFFF"), get_colorpixel("#000000"));
+        set_font_colors(pixmap_gc, draw_util_hex_to_color("#FFFFFF"), draw_util_hex_to_color("#000000"));
         if (modifier == MOD_Mod4)
             txt(logical_px(10), 4, "-> <Win>");
         else
@@ -527,11 +529,11 @@ static int handle_expose() {
 
         /* green */
         set_font(&font);
-        set_font_colors(pixmap_gc, get_colorpixel("#00FF00"), get_colorpixel("#000000"));
+        set_font_colors(pixmap_gc, draw_util_hex_to_color("#00FF00"), draw_util_hex_to_color("#000000"));
         txt(logical_px(25), 9, "<Enter>");
 
         /* red */
-        set_font_colors(pixmap_gc, get_colorpixel("#FF0000"), get_colorpixel("#000000"));
+        set_font_colors(pixmap_gc, draw_util_hex_to_color("#FF0000"), draw_util_hex_to_color("#000000"));
         txt(logical_px(31), 10, "<ESC>");
     }
 
@@ -768,7 +770,7 @@ int main(int argc, char *argv[]) {
         switch (o) {
             case 's':
                 FREE(socket_path);
-                socket_path = strdup(optarg);
+                socket_path = sstrdup(optarg);
                 break;
             case 'v':
                 printf("i3-config-wizard " I3_VERSION "\n");
@@ -799,7 +801,7 @@ int main(int argc, char *argv[]) {
     struct stat stbuf;
     sasprintf(&config_dir, "%s/i3", xdg_config_home);
     if (stat(config_dir, &stbuf) != 0)
-        if (!mkdirp(config_dir))
+        if (mkdirp(config_dir, DEFAULT_DIR_MODE) != 0)
             err(EXIT_FAILURE, "mkdirp(%s) failed", config_dir);
     free(config_dir);
     free(xdg_config_home);
@@ -852,6 +854,7 @@ int main(int argc, char *argv[]) {
 
     xcb_numlock_mask = get_mod_mask_for(XCB_NUM_LOCK, symbols, modmap_reply);
 
+    init_dpi();
     font = load_font(pattern, true);
     bold_font = load_font(patternbold, true);
 
@@ -963,7 +966,10 @@ int main(int argc, char *argv[]) {
                 break;
 
             case XCB_EXPOSE:
-                handle_expose();
+                if (((xcb_expose_event_t *)event)->count == 0) {
+                    handle_expose();
+                }
+
                 break;
         }