aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hcalc.h1
-rw-r--r--images.c5
-rw-r--r--input.c44
3 files changed, 17 insertions, 33 deletions
diff --git a/hcalc.h b/hcalc.h
index 62a5593..f04d0a9 100644
--- a/hcalc.h
+++ b/hcalc.h
@@ -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);
diff --git a/images.c b/images.c
index 1ed80d3..e8ca33f 100644
--- a/images.c
+++ b/images.c
@@ -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;
diff --git a/input.c b/input.c
index 53e816d..ba15f07 100644
--- a/input.c
+++ b/input.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) {