/** * draw rectangle (filled or not) */ void dev_rect(int x1, int y1, int x2, int y2, int fill) { int px1, py1, px2, py2; int c1, c2, in1, in2; px1 = x1; py1 = y1; px2 = x2; py2 = y2; W2D4(x1, y1, x2, y2); if (x1 == x2) { dev_line(px1, py1, px2, py2); return; } if (y1 == y2) { dev_line(px1, py1, px2, py2); return; } /* * check inside */ CLIPENCODE(x1, y1, c1); CLIPENCODE(x2, y2, c2); in1 = CLIPIN(c1); in2 = CLIPIN(c2); if (in1 && in2) { /* * its inside */ osd_rect(x1, y1, x2, y2, fill); } else { /* * partial inside * TODO: something fast */ int y; if (fill) { for (y = py1; y <= py2; y++) { dev_line(px1, y, px2, y); } } else { dev_line(px1, py1, px1, py2); dev_line(px1, py2, px2, py2); dev_line(px2, py2, px2, py1); dev_line(px2, py1, px1, py1); } } }
void sdl_monitor_info::refresh() { #if (SDLMAME_SDL2) SDL_DisplayMode dmode; #if defined(SDLMAME_WIN32) SDL_GetDesktopDisplayMode(m_handle, &dmode); #else SDL_GetCurrentDisplayMode(m_handle, &dmode); #endif SDL_Rect dimensions; SDL_GetDisplayBounds(m_handle, &dimensions); m_pos_size = SDL_Rect_to_osd_rect(dimensions); m_usuable_pos_size = SDL_Rect_to_osd_rect(dimensions); m_is_primary = (m_handle == 0); #else #if defined(SDLMAME_WIN32) // Win32 version MONITORINFOEX info; info.cbSize = sizeof(info); GetMonitorInfo((HMONITOR)m_handle, (LPMONITORINFO)&info); m_pos_size = RECT_to_osd_rect(info.rcMonitor); m_usuable_pos_size = RECT_to_osd_rect(info.rcWork); m_is_primary = ((info.dwFlags & MONITORINFOF_PRIMARY) != 0); char *temp = utf8_from_wstring(info.szDevice); strncpy(m_name, temp, ARRAY_LENGTH(m_name) - 1); osd_free(temp); #elif defined(SDLMAME_MACOSX) // Mac OS X Core Imaging version CGDirectDisplayID primary; CGRect dbounds; // get the main display primary = CGMainDisplayID(); dbounds = CGDisplayBounds(primary); m_is_primary = (m_handle == 0); m_pos_size = osd_rect(0, 0, dbounds.size.width - dbounds.origin.x, dbounds.size.height - dbounds.origin.y); m_usuable_pos_size = m_pos_size; strncpy(m_name, "Mac OS X display", ARRAY_LENGTH(m_name) - 1); #elif defined(SDLMAME_X11) || defined(SDLMAME_NO_X11) // X11 version { #if defined(SDLMAME_X11) // X11 version int screen; SDL_SysWMinfo info; SDL_VERSION(&info.version); if ( SDL_GetWMInfo(&info) && (info.subsystem == SDL_SYSWM_X11) ) { screen = DefaultScreen(info.info.x11.display); SDL_VideoDriverName(m_name, ARRAY_LENGTH(m_name) - 1); m_pos_size = osd_rect(0, 0, DisplayWidth(info.info.x11.display, screen), DisplayHeight(info.info.x11.display, screen)); /* FIXME: If Xinerame is used we should compile a list of monitors * like we do for other targets and ignore SDL. */ if ((XineramaIsActive(info.info.x11.display)) && video_config.restrictonemonitor) { XineramaScreenInfo *xineinfo; int numscreens; xineinfo = XineramaQueryScreens(info.info.x11.display, &numscreens); m_pos_size = osd_rect(0, 0, xineinfo[0].width, xineinfo[0].height); XFree(xineinfo); } m_usuable_pos_size = m_pos_size; m_is_primary = (m_handle == 0); } else #endif // defined(SDLMAME_X11) { static int first_call=0; static int cw = 0, ch = 0; SDL_VideoDriverName(m_name, ARRAY_LENGTH(m_name) - 1); if (first_call==0) { const char *dimstr = osd_getenv(SDLENV_DESKTOPDIM); const SDL_VideoInfo *sdl_vi; sdl_vi = SDL_GetVideoInfo(); #if (SDL_VERSION_ATLEAST(1,2,10)) cw = sdl_vi->current_w; ch = sdl_vi->current_h; #endif first_call=1; if ((cw==0) || (ch==0)) { if (dimstr != NULL) { sscanf(dimstr, "%dx%d", &cw, &ch); } if ((cw==0) || (ch==0)) { osd_printf_warning("WARNING: SDL_GetVideoInfo() for driver <%s> is broken.\n", m_name); osd_printf_warning(" You should set SDLMAME_DESKTOPDIM to your desktop size.\n"); osd_printf_warning(" e.g. export SDLMAME_DESKTOPDIM=800x600\n"); osd_printf_warning(" Assuming 1024x768 now!\n"); cw=1024; ch=768; } } } m_pos_size = osd_rect(0, 0, cw, ch); m_usuable_pos_size = m_pos_size; m_is_primary = (m_handle == 0); } } #elif defined(SDLMAME_OS2) // OS2 version m_pos_size = osd_rect(0, 0, WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN ), WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN ) ); m_usuable_pos_size = m_pos_size; m_is_primary = (m_handle == 0); strncpy(m_name, "OS/2 display", ARRAY_LENGTH(m_name) - 1); #else #error Unknown SDLMAME_xx OS type! #endif { static int info_shown=0; if (!info_shown) { osd_printf_verbose("SDL Device Driver : %s\n", m_name); osd_printf_verbose("SDL Monitor Dimensions: %d x %d\n", m_pos_size.width(), m_pos_size.height()); info_shown = 1; } } #endif // (SDLMAME_SDL2) }
inline osd_rect RECT_to_osd_rect(const RECT &r) { return osd_rect(r.left, r.top, r.right - r.left, r.bottom - r.top); }