Skip to content

Commit

Permalink
SDL2 windows were freezing on moving to another screen (reported by Mark
Browse files Browse the repository at this point in the history
Hessling); also, all resizes resulted in an extra hidden resize. This
fixes those, but still isn't quite right (observe the behavior of
sdltest when dragged to another screen, or any program maximized after
such a move).
  • Loading branch information
wmcbrine committed Apr 19, 2019
1 parent e5b37d5 commit 33b4f57
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 32 deletions.
28 changes: 11 additions & 17 deletions sdl2/pdckbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -447,24 +447,18 @@ int PDC_get_key(void)
switch (event.window.event)
{
case SDL_WINDOWEVENT_SIZE_CHANGED:
case SDL_WINDOWEVENT_RESIZED:
if (pdc_own_window &&
(event.window.data2 / pdc_fheight != LINES ||
event.window.data1 / pdc_fwidth != COLS))
pdc_sheight = event.window.data2;
pdc_swidth = event.window.data1;

pdc_screen = SDL_GetWindowSurface(pdc_window);
touchwin(curscr);
wrefresh(curscr);

if (!SP->resized)
{
pdc_sheight = event.window.data2;
pdc_swidth = event.window.data1;

pdc_screen = SDL_GetWindowSurface(pdc_window);
touchwin(curscr);
wrefresh(curscr);

if (!SP->resized)
{
SP->resized = TRUE;
SP->key_code = TRUE;
return KEY_RESIZE;
}
SP->resized = TRUE;
SP->key_code = TRUE;
return KEY_RESIZE;
}
break;
case SDL_WINDOWEVENT_RESTORED:
Expand Down
26 changes: 11 additions & 15 deletions sdl2/pdcscrn.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,35 +331,31 @@ int PDC_scr_open(int argc, char **argv)

int PDC_resize_screen(int nlines, int ncols)
{
#if SDL_VERSION_ATLEAST(2, 0, 5)
SDL_Rect max;
int top, left, bottom, right;
#endif

if (!pdc_own_window)
return ERR;

#if SDL_VERSION_ATLEAST(2, 0, 5)
SDL_GetDisplayUsableBounds(0, &max);
SDL_GetWindowBordersSize(pdc_window, &top, &left, &bottom, &right);
max.h -= top + bottom;
max.w -= left + right;
#endif

if (nlines && ncols)
{
#if SDL_VERSION_ATLEAST(2, 0, 5)
SDL_Rect max;
int top, left, bottom, right;

SDL_GetDisplayUsableBounds(0, &max);
SDL_GetWindowBordersSize(pdc_window, &top, &left, &bottom, &right);
max.h -= top + bottom;
max.w -= left + right;

while (nlines * pdc_fheight > max.h)
nlines--;
while (ncols * pdc_fwidth > max.w)
ncols--;
#endif
pdc_sheight = nlines * pdc_fheight;
pdc_swidth = ncols * pdc_fwidth;
}

SDL_SetWindowSize(pdc_window, pdc_swidth, pdc_sheight);
pdc_screen = SDL_GetWindowSurface(pdc_window);
SDL_SetWindowSize(pdc_window, pdc_swidth, pdc_sheight);
pdc_screen = SDL_GetWindowSurface(pdc_window);
}

if (pdc_tileback)
PDC_retile();
Expand Down

0 comments on commit 33b4f57

Please sign in to comment.