diff options
-rw-r--r-- | hcalc.h | 1 | ||||
-rw-r--r-- | images.c | 5 | ||||
-rw-r--r-- | input.c | 44 |
3 files changed, 17 insertions, 33 deletions
@@ -53,6 +53,7 @@ void button(int b, int x, int y); void complete_paste(unsigned char *s, int n); void send_current_display(void); void setup_x(void); +void free_pixmaps(void); void load_pixmaps(void); void process_input(); void load_config(void); @@ -38,6 +38,11 @@ Pixmap chars; char charmap[] = " 0123456789ABCDEF-x,.ro+"; int char_to_x[256]; +void free_pixmaps(void) { + if(face) XFreePixmap(display, face); + if(chars) XFreePixmap(display, chars); +} + void load_pixmaps(void) { int i, c; @@ -430,49 +430,27 @@ void key(char c) { exit(0); case 'z': - { - /* dirty hack method of changing window size: - re-execute ourselves with appropriate argument. - TODO: see if this leaks memory, fds, etc */ - extern char *self; - char *args[4]; - - args[0] = self; - - switch (winsize) { - case 0: - args[1] = "-medium"; - break; - case 1: - args[1] = "-large"; - break; - case 2: - args[1] = "-small"; - break; - } - - args[2] = NULL; - - /* note that atexit() functions do NOT get called on execv() */ - save_config(); - - XCloseDisplay(display); - - execv(self, args); - } + winsize++; + if(winsize == 3) winsize = 0; + free_pixmaps(); + XCloseDisplay(display); + setup_x(); + load_pixmaps(); + show_value(); + break; } } static char *bmap[] = { - "PPPP\033", /* mouse copy and paste, CLR */ - "DHOB\010", /* DEC, HEX, OCT, BIN, DEL */ + "PPPP\033", /* mouse copy and paste, CLR */ + "DHOB\010", /* DEC, HEX, OCT, BIN, DEL */ "[]}<>", /* STO, RCL, SUM, <<, >> */ "Sdef/", /* SHF, D E F / */ "~abc*", /* INV, */ "|789-", /* OR, */ "&456+", /* AND, */ "^123=", /* XOR, */ - "u0._=" /* CE, 0, . , +/-, = */ + "u0._=" /* CE, 0, . , +/-, = */ }; void copy(void) { |