remove more

This commit is contained in:
Jonathan Campbell 2019-04-13 18:12:50 -07:00
parent 21315f52c9
commit dd4d280f8b
3 changed files with 1 additions and 277 deletions

View File

@ -38,51 +38,6 @@ enum PRIORITY_LEVELS {
PRIORITY_LEVEL_HIGHEST
};
// Screen DPI and size info
class ScreenSizeInfo {
public:
enum method {
METHOD_NONE=0,
METHOD_X11,
METHOD_XRANDR,
METHOD_WIN98BASE,
METHOD_COREGRAPHICS
};
public:
struct wxh {
double width = -1;
double height = -1;
void clear(void) {
width = height = -1;
}
};
struct xvy {
double x = 0;
double y = 0;
void clear(void) {
x = y = 0;
}
};
public:
xvy screen_position_pixels; // position of the screen on the "virtual" overall desktop
wxh screen_dimensions_pixels; // size of the screen in pixels
wxh screen_dimensions_mm; // size of the screen in mm
wxh screen_dpi; // DPI of the screen
enum method method = METHOD_NONE;
public:
void clear(void) {
screen_dpi.clear();
screen_dimensions_mm.clear();
screen_dimensions_pixels.clear();
screen_position_pixels.clear();
method = METHOD_NONE;
}
};
extern ScreenSizeInfo screen_size_info;
// do not specify any defaults inside, it is zeroed at start of main()
struct SDL_Block {
bool inited;

View File

@ -445,61 +445,6 @@ extern "C" int sdl1_hax_macosx_window_to_monitor_and_update(CGDirectDisplayID *d
int my_quartz_match_window_to_monitor(CGDirectDisplayID *new_id,NSWindow *wnd);
void MacOSX_GetWindowDPI(ScreenSizeInfo &info) {
NSWindow *wnd = nil;
info.clear();
#if !defined(C_SDL2)
wnd = sdl1_hax_get_window();
#else
SDL_Window* GFX_GetSDLWindow(void);
SDL_SysWMinfo wminfo;
memset(&wminfo,0,sizeof(wminfo));
SDL_VERSION(&wminfo.version);
if (SDL_GetWindowWMInfo(GFX_GetSDLWindow(),&wminfo) >= 0) {
if (wminfo.subsystem == SDL_SYSWM_COCOA && wminfo.info.cocoa.window != NULL) {
wnd = wminfo.info.cocoa.window;
}
}
#endif
if (wnd != nil) {
CGDirectDisplayID did = 0;
if (my_quartz_match_window_to_monitor(&did,wnd) >= 0) {
CGRect drct = CGDisplayBounds(did);
CGSize dsz = CGDisplayScreenSize(did);
info.method = ScreenSizeInfo::METHOD_COREGRAPHICS;
info.screen_position_pixels.x = drct.origin.x;
info.screen_position_pixels.y = drct.origin.y;
info.screen_dimensions_pixels.width = drct.size.width;
info.screen_dimensions_pixels.height = drct.size.height;
/* According to Apple documentation, this function CAN return zero */
if (dsz.width > 0 && dsz.height > 0) {
info.screen_dimensions_mm.width = dsz.width;
info.screen_dimensions_mm.height = dsz.height;
if (info.screen_dimensions_mm.width > 0)
info.screen_dpi.width =
((((double)info.screen_dimensions_pixels.width) * 25.4) /
((double)info.screen_dimensions_mm.width));
if (info.screen_dimensions_mm.height > 0)
info.screen_dpi.height =
((((double)info.screen_dimensions_pixels.height) * 25.4) /
((double)info.screen_dimensions_mm.height));
}
}
}
}
int my_quartz_match_window_to_monitor(CGDirectDisplayID *new_id,NSWindow *wnd) {
if (wnd != nil) {
CGError err;

View File

@ -146,8 +146,6 @@ void osx_init_touchbar(void);
SDL_Block sdl;
Bitu frames = 0;
ScreenSizeInfo screen_size_info;
const char *scaler_menu_opts[][2] = {
{ "none", "None" },
{ "normal2x", "Normal 2X" },
@ -256,93 +254,6 @@ void UpdateWindowDimensions(Bitu width, Bitu height)
currentWindowHeight = height;
}
void PrintScreenSizeInfo(void) {
#if 1
const char *method = "?";
switch (screen_size_info.method) {
case ScreenSizeInfo::METHOD_NONE: method = "None"; break;
case ScreenSizeInfo::METHOD_X11: method = "X11"; break;
case ScreenSizeInfo::METHOD_XRANDR: method = "XRandR"; break;
case ScreenSizeInfo::METHOD_WIN98BASE: method = "Win98base"; break;
case ScreenSizeInfo::METHOD_COREGRAPHICS:method = "CoreGraphics";break;
default: break;
};
LOG_MSG("Screen report: Method '%s' (%.3f x %.3f pixels) at (%.3f x %.3f) (%.3f x %.3f mm) (%.3f x %.3f in) (%.3f x %.3f DPI)",
method,
screen_size_info.screen_dimensions_pixels.width,
screen_size_info.screen_dimensions_pixels.height,
screen_size_info.screen_position_pixels.x,
screen_size_info.screen_position_pixels.y,
screen_size_info.screen_dimensions_mm.width,
screen_size_info.screen_dimensions_mm.height,
screen_size_info.screen_dimensions_mm.width / 25.4,
screen_size_info.screen_dimensions_mm.height / 25.4,
screen_size_info.screen_dpi.width,
screen_size_info.screen_dpi.height);
#endif
}
#if defined(WIN32)
void Windows_GetWindowDPI(ScreenSizeInfo &info) {
info.clear();
# if !defined(HX_DOS)
HMONITOR mon;
HWND hwnd;
info.method = ScreenSizeInfo::METHOD_WIN98BASE;
hwnd = GetHWND();
if (hwnd == NULL) return;
mon = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
if (mon == NULL) mon = MonitorFromWindow(hwnd, MONITOR_DEFAULTTOPRIMARY);
if (mon == NULL) return;
MONITORINFO mi;
memset(&mi,0,sizeof(mi));
mi.cbSize = sizeof(mi);
if (!GetMonitorInfo(mon,&mi)) return;
info.screen_position_pixels.x = mi.rcMonitor.left;
info.screen_position_pixels.y = mi.rcMonitor.top;
info.screen_dimensions_pixels.width = mi.rcMonitor.right - mi.rcMonitor.left;
info.screen_dimensions_pixels.height = mi.rcMonitor.bottom - mi.rcMonitor.top;
/* Windows 10 build 1607 and later offer a "Get DPI of window" function */
{
HMODULE __user32;
__user32 = GetModuleHandle("USER32.DLL");
if (__user32) {
UINT (WINAPI *__GetDpiForWindow)(HWND) = NULL;
__GetDpiForWindow = (UINT (WINAPI *)(HWND))GetProcAddress(__user32,"GetDpiForWindow");
if (__GetDpiForWindow) {
UINT dpi = __GetDpiForWindow(hwnd);
if (dpi != 0) {
info.screen_dpi.width = dpi;
info.screen_dpi.height = dpi;
info.screen_dimensions_mm.width = (25.4 * screen_size_info.screen_dimensions_pixels.width) / dpi;
info.screen_dimensions_mm.height = (25.4 * screen_size_info.screen_dimensions_pixels.height) / dpi;
}
}
}
}
# endif
}
#endif
void UpdateWindowDimensions(void)
{
#if defined(C_SDL2)
@ -353,10 +264,6 @@ void UpdateWindowDimensions(void)
Uint32 fl = SDL_GetWindowFlags(sdl.window);
UpdateWindowMaximized((fl & SDL_WINDOW_MAXIMIZED) != 0);
#endif
#if defined(MACOSX)
void MacOSX_GetWindowDPI(ScreenSizeInfo &info);
MacOSX_GetWindowDPI(/*&*/screen_size_info);
#endif
#if defined(WIN32)
// When maximized, SDL won't actually tell us our new dimensions, so get it ourselves.
// FIXME: Instead of GetHWND() we need to track our own handle or add something to SDL 1.x
@ -366,9 +273,7 @@ void UpdateWindowDimensions(void)
GetClientRect(GetHWND(), &r);
UpdateWindowDimensions(r.right, r.bottom);
UpdateWindowMaximized(IsZoomed(GetHWND()));
Windows_GetWindowDPI(/*&*/screen_size_info);
#endif
PrintScreenSizeInfo();
}
#if defined(C_SDL2)
@ -1964,83 +1869,6 @@ void GFX_SwitchFullScreen(void)
if (!sdl.desktop.fullscreen) {/*is GOING fullscreen*/
UpdateWindowDimensions();
if (screen_size_info.screen_dimensions_pixels.width != 0 && screen_size_info.screen_dimensions_pixels.height != 0) {
if (sdl.desktop.full.width_auto)
sdl.desktop.full.width = screen_size_info.screen_dimensions_pixels.width;
if (sdl.desktop.full.height_auto)
sdl.desktop.full.height = screen_size_info.screen_dimensions_pixels.height;
#if !defined(C_SDL2) && defined(MACOSX)
/* Mac OS X has this annoying problem with their API where the System Preferences app, display settings panel
allows setting 720p and 1080i/1080p modes on monitors who's native resolution is less than 1920x1080 but
supports 1920x1080.
This is a problem with HDTV sets made in the late 2000s early 2010s when "HD" apparently meant LCD displays
with 1368x768 resolution that will nonetheless accept 1080i (and later, 1080p) and downscale on display.
The problem is that with these monitors, Mac OS X's display API will NOT list 1920x1080 as one of the
display modes even when the freaking desktop is obviously set to 1920x1080 on that monitor!
If the screen reporting code says 1920x1080 and we try to go fullscreen, SDL1 will intervene and say
"hey wait there's no 1920x1080 in the mode list" and then fail the call.
So to work around this, we have to go check SDL's mode list before using the screen size returned by the
API.
Oh and for extra fun, Mac OS X is one of those modern systems where "setting the video mode" apparently
means NOT setting the video hardware mode but just changing how the GPU scales the display... EXCEPT when
talking to these older displays where if the user set it to 1080i/1080p, our request to set 1368x768
actually DOES change the video mode. This is just wonderful considering the old HDTV set I bought back in
2008 takes 1-2 seconds to adjust to the mode change on it's HDMI input.
Frankly I wish I knew how to fix the SDL1 Quartz code to use whatever abracadabra magic code is required
to enumerate these extra HDTV modes so this hack isn't necessary, except that experience says this hack is
always necesary because it might not always work.
This magic hidden super secret API bullshit is annoying. You're worse than Microsoft with this stuff, Apple --J.C. */
{
SDL_Rect **ls = SDLCALL SDL_ListModes(NULL, SDL_FULLSCREEN);
if (ls != NULL) {
unsigned int maxwidth = 0,maxheight = 0;
for (size_t i=0;ls[i] != NULL;i++) {
unsigned int w = ls[i]->w;
unsigned int h = ls[i]->h;
if (maxwidth < w || maxheight < h) {
maxwidth = w;
maxheight = h;
}
}
if (maxwidth != 0 && maxheight != 0) {
LOG_MSG("OS X: Actual maximum screen resolution is %d x %d\n",maxwidth,maxheight);
if (sdl.desktop.full.width_auto) {
if (sdl.desktop.full.width > maxwidth)
sdl.desktop.full.width = maxwidth;
}
if (sdl.desktop.full.height_auto) {
if (sdl.desktop.full.height > maxheight)
sdl.desktop.full.height = maxheight;
}
}
}
}
#endif
#if !defined(C_SDL2) && defined(SDL_DOSBOX_X_SPECIAL)
SDL_hax_SetFSWindowPosition(
screen_size_info.screen_position_pixels.x,screen_size_info.screen_position_pixels.y,
screen_size_info.screen_dimensions_pixels.width,screen_size_info.screen_dimensions_pixels.height);
#endif
}
else {
#if !defined(C_SDL2) && defined(SDL_DOSBOX_X_SPECIAL)
SDL_hax_SetFSWindowPosition(0,0,0,0);
#endif
}
}
menu.resizeusing = true;
@ -2864,11 +2692,7 @@ void GFX_HandleVideoResize(int width, int height) {
}
/* TODO: Only if FULLSCREEN_DESKTOP */
if (screen_size_info.screen_dimensions_pixels.width != 0 && screen_size_info.screen_dimensions_pixels.height != 0) {
sdl.desktop.full.width = screen_size_info.screen_dimensions_pixels.width;
sdl.desktop.full.height = screen_size_info.screen_dimensions_pixels.height;
}
else {
{
SDL_DisplayMode dm;
if (SDL_GetDesktopDisplayMode(0/*FIXME display index*/,&dm) == 0) {
sdl.desktop.full.width = dm.w;