diff --git a/menu/menu.c b/menu/menu.c index 1f1c13edf1..7950a4e5e0 100644 --- a/menu/menu.c +++ b/menu/menu.c @@ -232,7 +232,8 @@ static void menu_free_list(menu_handle_t *menu) **/ void menu_free(menu_handle_t *menu) { - global_t *global = global_get_ptr(); + global_t *global = global_get_ptr(); + menu_framebuf_t *frame_buf = menu_display_fb_get_ptr(); if (!menu) return; @@ -261,10 +262,6 @@ void menu_free(menu_handle_t *menu) menu_display_free(menu); - if (menu->frame_buf.data) - free(menu->frame_buf.data); - menu->frame_buf.data = NULL; - menu_list_free(menu->menu_list); menu->menu_list = NULL; diff --git a/menu/menu_display.c b/menu/menu_display.c index b73b10b787..35280ad6d5 100644 --- a/menu/menu_display.c +++ b/menu/menu_display.c @@ -32,6 +32,7 @@ menu_framebuf_t *menu_display_fb_get_ptr(void) return &menu->frame_buf; } + static bool menu_display_fb_in_use(menu_framebuf_t *frame_buf) { if (!frame_buf) @@ -98,6 +99,16 @@ bool menu_display_update_pending(void) return false; } +static void menu_display_fb_free(menu_framebuf_t *frame_buf) +{ + if (!frame_buf) + return; + + if (frame_buf->data) + free(frame_buf->data); + frame_buf->data = NULL; +} + void menu_display_free(menu_handle_t *menu) { if (!menu) @@ -105,6 +116,8 @@ void menu_display_free(menu_handle_t *menu) menu_animation_free(menu->animation); menu->animation = NULL; + + menu_display_fb_free(&menu->frame_buf); } bool menu_display_init(menu_handle_t *menu) diff --git a/menu/menu_input.c b/menu/menu_input.c index d7a7153873..7014e44d63 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -27,6 +27,7 @@ #include "menu_input.h" #include "menu.h" +#include "menu_display.h" #include "menu_entry.h" #include "menu_setting.h" #include "menu_shader.h" @@ -574,6 +575,7 @@ static int menu_input_mouse(unsigned *action) const struct retro_keybind *binds[MAX_USERS]; driver_t *driver = driver_get_ptr(); menu_handle_t *menu = menu_driver_get_ptr(); + menu_framebuf_t *frame_buf= menu_display_fb_get_ptr(); settings_t *settings = config_get_ptr(); if (!menu) @@ -639,20 +641,20 @@ static int menu_input_mouse(unsigned *action) menu->mouse.screen_x += menu->mouse.dx; menu->mouse.screen_y += menu->mouse.dy; - menu->mouse.x = ((int)menu->mouse.screen_x * (int)menu->frame_buf.width) / (int)vp.width; - menu->mouse.y = ((int)menu->mouse.screen_y * (int)menu->frame_buf.height) / (int)vp.height; + menu->mouse.x = ((int)menu->mouse.screen_x * (int)frame_buf->width) / (int)vp.width; + menu->mouse.y = ((int)menu->mouse.screen_y * (int)frame_buf->height) / (int)vp.height; if (menu->mouse.x < 5) menu->mouse.x = 5; if (menu->mouse.y < 5) menu->mouse.y = 5; - if (menu->mouse.x > (int)menu->frame_buf.width - 5) - menu->mouse.x = menu->frame_buf.width - 5; - if (menu->mouse.y > (int)menu->frame_buf.height - 5) - menu->mouse.y = menu->frame_buf.height - 5; + if (menu->mouse.x > (int)frame_buf->width - 5) + menu->mouse.x = frame_buf->width - 5; + if (menu->mouse.y > (int)frame_buf->height - 5) + menu->mouse.y = frame_buf->height - 5; menu->mouse.scrollup = (menu->mouse.y == 5); - menu->mouse.scrolldown = (menu->mouse.y == (int)menu->frame_buf.height - 5); + menu->mouse.scrolldown = (menu->mouse.y == (int)frame_buf->height - 5); if (menu->mouse.dx != 0 || menu->mouse.dy !=0 || menu->mouse.left || menu->mouse.wheelup || menu->mouse.wheeldown @@ -668,6 +670,7 @@ static int menu_input_pointer(unsigned *action) int pointer_device, pointer_x, pointer_y; const struct retro_keybind *binds[MAX_USERS] = {NULL}; menu_handle_t *menu = menu_driver_get_ptr(); + menu_framebuf_t *frame_buf= menu_display_fb_get_ptr(); settings_t *settings = config_get_ptr(); driver_t *driver = driver_get_ptr(); @@ -693,8 +696,8 @@ static int menu_input_pointer(unsigned *action) pointer_x = input_driver_state(binds, 0, pointer_device, 0, RETRO_DEVICE_ID_POINTER_X); pointer_y = input_driver_state(binds, 0, pointer_device, 0, RETRO_DEVICE_ID_POINTER_Y); - menu->pointer.x = ((pointer_x + 0x7fff) * (int)menu->frame_buf.width) / 0xFFFF; - menu->pointer.y = ((pointer_y + 0x7fff) * (int)menu->frame_buf.height) / 0xFFFF; + menu->pointer.x = ((pointer_x + 0x7fff) * (int)frame_buf->width) / 0xFFFF; + menu->pointer.y = ((pointer_y + 0x7fff) * (int)frame_buf->height) / 0xFFFF; if (menu->pointer.pressed[0] || menu->pointer.oldpressed[0] || menu->pointer.back || menu->pointer.dragging