Compare commits
2 Commits
logical_si
...
render_rew
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d0ecc6c460 | ||
|
|
a6dcbf34ba |
@@ -162,15 +162,10 @@ screen_update_content_rect(struct screen *screen) {
|
||||
int dh;
|
||||
SDL_GL_GetDrawableSize(screen->window, &dw, &dh);
|
||||
|
||||
int ww, wh;
|
||||
SDL_GetWindowSize(screen->window, &ww, &wh);
|
||||
|
||||
struct size content_size = screen->content_size;
|
||||
// The drawable size is the window size * the HiDPI scale
|
||||
struct size drawable_size = {dw, dh};
|
||||
|
||||
LOGI("update_content_rect: window=%dx%d, drawable=%dx%d content=%ux%u", ww, wh, dw, dh, content_size.width, content_size.height);
|
||||
|
||||
SDL_Rect *rect = &screen->rect;
|
||||
|
||||
if (is_optimal_size(drawable_size, content_size)) {
|
||||
@@ -178,7 +173,6 @@ screen_update_content_rect(struct screen *screen) {
|
||||
rect->y = 0;
|
||||
rect->w = drawable_size.width;
|
||||
rect->h = drawable_size.height;
|
||||
LOGI(" --> (optimal) rect (%d, %d) %dx%d", rect->x, rect->y, rect->w, rect->h);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -197,8 +191,6 @@ screen_update_content_rect(struct screen *screen) {
|
||||
/ content_size.height;
|
||||
rect->x = (drawable_size.width - rect->w) / 2;
|
||||
}
|
||||
|
||||
LOGI(" --> rect (%d, %d) %dx%d", rect->x, rect->y, rect->w, rect->h);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -333,6 +325,9 @@ screen_init_rendering(struct screen *screen, const char *window_title,
|
||||
return false;
|
||||
}
|
||||
|
||||
// Reset the window size to trigger a SIZE_CHANGED event, to workaround
|
||||
// HiDPI issues with some SDL renderers when several displays having
|
||||
// different HiDPI scaling are connected
|
||||
SDL_SetWindowSize(screen->window, window_size.width, window_size.height);
|
||||
|
||||
screen_update_content_rect(screen);
|
||||
@@ -561,19 +556,15 @@ screen_handle_window_event(struct screen *screen,
|
||||
const SDL_WindowEvent *event) {
|
||||
switch (event->event) {
|
||||
case SDL_WINDOWEVENT_EXPOSED:
|
||||
LOGI("EXPOSED");
|
||||
screen_render(screen, true);
|
||||
break;
|
||||
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
||||
LOGI("SIZE_CHANGED %dx%d", event->data1, event->data2);
|
||||
screen_render(screen, true);
|
||||
break;
|
||||
case SDL_WINDOWEVENT_MAXIMIZED:
|
||||
LOGI("MAXIMIZED");
|
||||
screen->maximized = true;
|
||||
break;
|
||||
case SDL_WINDOWEVENT_RESTORED:
|
||||
LOGI("RESTORED");
|
||||
if (screen->fullscreen) {
|
||||
// On Windows, in maximized+fullscreen, disabling fullscreen
|
||||
// mode unexpectedly triggers the "restored" then "maximized"
|
||||
|
||||
Reference in New Issue
Block a user