Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

simulator: maintain LCD position/size when toggling background

Change-Id: Id76464b77b33d531d6075a83038466e18fab3a7f

+36 -13
+36 -13
firmware/target/hosted/sdl/window-sdl.c
··· 67 67 } 68 68 } 69 69 70 - #define SNAP_MARGIN 50 70 + #if defined(__APPLE__) || defined(__WIN32) 71 71 static void restore_aspect_ratio(int w, int h) 72 72 { 73 73 float aspect_ratio = (float) h / w; ··· 81 81 SDL_GetWindowSize(sdlWindow, &w, &h); 82 82 if (w != original_width || h != original_height) 83 83 { 84 - if (abs(original_width - w) < SNAP_MARGIN) 85 - { 86 - w = original_width; 87 - h = original_height; 88 - } 89 - else 90 - h = w * aspect_ratio; 91 - 84 + h = w * aspect_ratio; 92 85 SDL_SetWindowSize(sdlWindow, w, h); 93 86 } 94 87 } 88 + #endif 95 89 96 90 static void rebuild_gui_texture(void) 97 91 { 98 92 SDL_Surface *gui_surface; 99 - int w, h, depth = LCD_DEPTH < 8 ? 16 : LCD_DEPTH; 93 + int prev_w, prev_h, x, y, 94 + w, h, depth = LCD_DEPTH < 8 ? 16 : LCD_DEPTH; 95 + Uint32 flags = SDL_GetWindowFlags(sdlWindow); 100 96 101 97 get_window_dimensions(&w, &h); 98 + SDL_RenderGetLogicalSize(sdlRenderer, &prev_w, &prev_h); 102 99 SDL_RenderSetLogicalSize(sdlRenderer, w, h); 103 100 if ((gui_texture = SDL_CreateTexture(sdlRenderer, SDL_MasksToPixelFormatEnum(depth, 104 101 0, 0, 0, 0), SDL_TEXTUREACCESS_STREAMING, w, h)) == NULL) 105 102 panicf("%s", SDL_GetError()); 106 103 107 - if (SDL_GetWindowFlags(sdlWindow) & SDL_WINDOW_RESIZABLE) 108 - restore_aspect_ratio(w, h); 104 + /* Did background change? */ 105 + if ((flags & SDL_WINDOW_RESIZABLE) && 106 + !(flags & (SDL_WINDOW_MAXIMIZED | SDL_WINDOW_FULLSCREEN)) && 107 + prev_w && prev_w != w) 108 + { 109 + SDL_GetWindowSize(sdlWindow, &x, NULL); 110 + 111 + /* Maintain LCD's size */ 112 + float ratio = (float) x / prev_w; 113 + SDL_SetWindowSize(sdlWindow, w * ratio, h * ratio); 114 + 115 + /* move LCD back into previous position */ 116 + SDL_GetWindowPosition(sdlWindow, &x, &y); 117 + if (background) 118 + { 119 + x -= (UI_LCD_POSX * ratio); 120 + y -= (UI_LCD_POSY * ratio); 121 + } 122 + else 123 + { 124 + x += (UI_LCD_POSX * ratio); 125 + y += (UI_LCD_POSY * ratio); 126 + } 127 + SDL_SetWindowPosition(sdlWindow, x > 0 ? x : 0, y > 0 ? y : 0); 128 + } 109 129 110 130 if (background && picture_surface && 111 131 (gui_surface = SDL_ConvertSurface(picture_surface, sim_lcd_surface->format, 0))) ··· 159 179 SDL_SetWindowSize(sdlWindow, display_zoom * w, display_zoom * h); 160 180 } 161 181 #if defined(__APPLE__) || defined(__WIN32) 162 - restore_aspect_ratio(w, h); 182 + int logical_w, logical_h; 183 + SDL_RenderGetLogicalSize(sdlRenderer, &logical_w, &logical_h); 184 + if (logical_w == w && logical_h == h) /* background unchanged */ 185 + restore_aspect_ratio(w, h); 163 186 #endif 164 187 display_zoom = 0; 165 188 sdl_window_render();