foo
[cdmenu] / menu / src / app.c
index bb7f73f..c102330 100644 (file)
@@ -8,7 +8,6 @@
 
 int mouse_x, mouse_y, mouse_state[3];
 unsigned int modkeys;
-int scr_width, scr_height;
 int fullscr;
 
 long time_msec;
@@ -29,6 +28,11 @@ int app_init(void)
        char *start_scr_name;
        static rtk_draw_ops guigfx = {gui_fill, 0, gui_drawtext, gui_textrect};
 
+       if(!(framebuf = malloc(SCR_WIDTH * SCR_HEIGHT))) {
+               errormsg("failed to allocate framebuffer (%dx%d)\n", SCR_WIDTH, SCR_HEIGHT);
+               return -1;
+       }
+
        rtk_setup(&guigfx);
 
        /* initialize screens */
@@ -68,6 +72,7 @@ void app_shutdown(void)
        }
 
        cleanup_logger();
+       free(framebuf);
 }
 
 void app_display(void)
@@ -77,30 +82,6 @@ void app_display(void)
        cur_scr->display();
 }
 
-void app_reshape(int x, int y)
-{
-       int numpix = x * y;
-       int prev_numpix = scr_width * scr_height;
-
-       if(!framebuf || numpix > prev_numpix) {
-               void *tmp;
-               if(!(tmp = realloc(framebuf, numpix * sizeof *framebuf))) {
-                       errormsg("failed to resize framebuffer to %dx%d\n", x, y);
-                       return;
-               }
-               framebuf = tmp;
-       }
-
-       scr_width = x;
-       scr_height = y;
-
-       if(cur_scr && cur_scr->reshape) {
-               cur_scr->reshape(x, y);
-       }
-
-       app_invalidate(0, 0, 0, 0);
-}
-
 void app_keyboard(int key, int press)
 {
        long msec;
@@ -125,15 +106,6 @@ void app_keyboard(int key, int press)
                                return;
                        }
                        break;
-
-               case '\n':
-               case '\r':
-                       if(modkeys & KEY_MOD_ALT) {
-               case KEY_F11:
-                               app_fullscreen(-1);
-                               return;
-                       }
-                       break;
                }
        }
 
@@ -173,9 +145,6 @@ void app_chscr(struct app_screen *scr)
        if(scr->start && scr->start() == -1) {
                return;
        }
-       if(scr->reshape) {
-               scr->reshape(scr_width, scr_height);
-       }
 
        if(prev && prev->stop) {
                prev->stop();
@@ -183,7 +152,7 @@ void app_chscr(struct app_screen *scr)
        cur_scr = scr;
 }
 
-void gui_fill(rtk_rect *rect, int color)
+void gui_fill(rtk_rect *rect, uint32_t color)
 {
        int i, j;
        unsigned char *fb;
@@ -196,19 +165,19 @@ void gui_fill(rtk_rect *rect, int color)
                rect->height += rect->y;
                rect->y = 0;
        }
-       if(rect->x + rect->width >= scr_width) {
-               rect->width = scr_width - rect->x;
+       if(rect->x + rect->width >= SCR_WIDTH) {
+               rect->width = SCR_WIDTH - rect->x;
        }
-       if(rect->y + rect->height >= scr_height) {
-               rect->height = scr_height - rect->y;
+       if(rect->y + rect->height >= SCR_HEIGHT) {
+               rect->height = SCR_HEIGHT - rect->y;
        }
 
-       fb = framebuf + rect->y * scr_width + rect->x;
+       fb = framebuf + rect->y * SCR_WIDTH + rect->x;
        for(i=0; i<rect->height; i++) {
                for(j=0; j<rect->width; j++) {
                        fb[j] = color;
                }
-               fb += scr_width;
+               fb += SCR_WIDTH;
        }
 }