fork of PCE focusing on macplus, supporting DaynaPort SCSI network emulation
0
fork

Configure Feed

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

sdl2: Turn autosize setting to int, when 2, provide X11 window hints

This gets the requested window size even on aggressive tiling window
managers that try to force a window size

+36 -4
+35 -3
src/drivers/video/sdl2.c
··· 26 26 #include <stdlib.h> 27 27 28 28 #include <SDL.h> 29 + #include <SDL_syswm.h> 30 + 31 + #if !(defined(PCE_HOST_WINDOWS) || defined(PCE_HOST_MACOS)) 32 + #include <X11/Xlib.h> 33 + #include <X11/Xutil.h> 34 + #endif 29 35 30 36 #include <drivers/video/terminal.h> 31 37 #include <drivers/video/keys.h> ··· 261 267 static 262 268 int sdl2_set_window_size (sdl2_t *sdl, unsigned w, unsigned h) 263 269 { 270 + #if !(defined(PCE_HOST_WINDOWS) || defined(PCE_HOST_MACOS)) 271 + XSizeHints hints; 272 + SDL_SysWMinfo info; 273 + long r; 274 + #endif 275 + 264 276 if ((w == 0) || (h == 0)) { 265 277 return (1); 266 278 } ··· 269 281 return (0); 270 282 } 271 283 284 + #if !(defined(PCE_HOST_WINDOWS) || defined(PCE_HOST_MACOS)) 285 + if (sdl->autosize == 2) { 286 + SDL_VERSION(&info.version); 287 + if (SDL_GetWindowWMInfo(sdl->window, &info) && 288 + info.subsystem == SDL_SYSWM_X11 && 289 + XGetWMSizeHints(info.info.x11.display, info.info.x11.window, &hints, &r, XA_WM_SIZE_HINTS) == 0) { 290 + hints.flags = PMinSize | PMaxSize | PAspect; 291 + hints.max_width = w; 292 + hints.min_width = w; 293 + hints.max_height = h; 294 + hints.min_height = h; 295 + XSetWMNormalHints (info.info.x11.display, info.info.x11.window, &hints); 296 + } 297 + } 298 + #endif 299 + 272 300 SDL_SetWindowSize (sdl->window, w, h); 273 301 274 302 sdl->wdw_w = w; ··· 525 553 sdl->wdw_w = evt->data1; 526 554 sdl->wdw_h = evt->data2; 527 555 sdl->autosize = 0; 556 + if (sdl->autosize != 2) 557 + sdl->autosize = 0; 528 558 } 529 559 sdl->update = 1; 530 560 break; ··· 773 803 static 774 804 void sdl2_init (sdl2_t *sdl, ini_sct_t *sct) 775 805 { 776 - int fs, rep; 777 - const char *str; 806 + int fs, rep; 807 + unsigned int autosize; 808 + const char *str; 778 809 779 810 trm_init (&sdl->trm, sdl); 780 811 ··· 813 844 SDL_SetHint (SDL_HINT_RENDER_SCALE_QUALITY, str); 814 845 } 815 846 816 - sdl->autosize = 1; 847 + ini_get_uint16 (sct, "autosize", &autosize, 1); 848 + sdl->autosize = (autosize & 0xff); 817 849 818 850 sdl->grave_down = 0; 819 851 sdl->ignore_keys = 0;
+1 -1
src/drivers/video/sdl2.h
··· 61 61 char fullscreen; 62 62 char grab; 63 63 char report_keys; 64 - char autosize; 65 64 char grave_down; 66 65 char ignore_keys; 67 66 const char *scale_quality; 67 + char autosize; 68 68 69 69 unsigned keymap_cnt; 70 70 sdl2_keymap_t *keymap;