Example #1
1
void ViewerWindow::setSizeFullScreenWindow()
{
	// Save position of window.
	GetWindowPlacement(m_hWnd, &m_workArea);

	// Get size of desktop.
	HMONITOR hmon = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
	MONITORINFO mi;
	mi.cbSize = sizeof(mi);

	RECT fullScreenWindowsRect;
	if (!!GetMonitorInfo(hmon, &mi)) {
		fullScreenWindowsRect = mi.rcMonitor;
	}
	else {
		m_logWriter.warning(_T("Get monitor info is failed. Use second method (no multi-screen)."));
		GetWindowRect(GetDesktopWindow(), &fullScreenWindowsRect);
	}
	Rect fullScreenRect;
	fullScreenRect.fromWindowsRect(&fullScreenWindowsRect);
	m_logWriter.detail(_T("full screen window rect: %d, %d; %d, %d"),
		fullScreenRect.left, fullScreenRect.top,
		fullScreenRect.getWidth(), fullScreenRect.getHeight());

	setStyle((getStyle() | WS_MAXIMIZE) & ~(WS_CAPTION | WS_BORDER | WS_THICKFRAME | WS_MAXIMIZEBOX));
	setExStyle(getExStyle() | WS_EX_TOPMOST);

	SetWindowPos(m_hWnd, 0,
		fullScreenRect.left, fullScreenRect.top,
		fullScreenRect.getWidth(), fullScreenRect.getHeight(),
		SWP_SHOWWINDOW);
}
Example #2
0
static void Manage(vout_display_t *vd)
{
    vout_display_sys_t *sys = vd->sys;

    CommonManage(vd);

    if (sys->changes & DX_POSITION_CHANGE) {
        /* Update overlay */
        if (sys->use_overlay)
            DirectXUpdateOverlay(vd, NULL);

        /* Check if we are still on the same monitor */
        HMONITOR hmon = MonitorFromWindow(sys->hwnd, MONITOR_DEFAULTTONEAREST);
        if (sys->hmonitor != hmon) {
            vout_display_SendEventPicturesInvalid(vd);
        }
        /* */
        sys->changes &= ~DX_POSITION_CHANGE;
    }

    /* Wallpaper mode change */
    vlc_mutex_lock(&sys->lock);
    const bool ch_wallpaper = sys->ch_wallpaper;
    const bool wallpaper_requested = sys->wallpaper_requested;
    sys->ch_wallpaper = false;
    vlc_mutex_unlock(&sys->lock);

    if (ch_wallpaper)
        WallpaperChange(vd, wallpaper_requested);

    /* */
    if (sys->restore_overlay)
        DirectXUpdateOverlay(vd, NULL);
}
	void D3D9RenderWindow::adjustWindow(unsigned int clientWidth, unsigned int clientHeight, 
		unsigned int* winWidth, unsigned int* winHeight)
	{
		// NB only call this for non full screen
		RECT rc;
		SetRect(&rc, 0, 0, clientWidth, clientHeight);
		AdjustWindowRect(&rc, WS_VISIBLE | WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW, false);
		*winWidth = rc.right - rc.left;
		*winHeight = rc.bottom - rc.top;

		// adjust to monitor
		HMONITOR hMonitor = MonitorFromWindow(mHWnd, MONITOR_DEFAULTTONEAREST);

		// Get monitor info	
		MONITORINFO monitorInfo;

		memset(&monitorInfo, 0, sizeof(MONITORINFO));
		monitorInfo.cbSize = sizeof(MONITORINFO);
		GetMonitorInfo(hMonitor, &monitorInfo);

		LONG maxW = monitorInfo.rcWork.right  - monitorInfo.rcWork.left;
		LONG maxH = monitorInfo.rcWork.bottom - monitorInfo.rcWork.top;

		if (*winWidth > (unsigned int)maxW)
			*winWidth = maxW;
		if (*winHeight > (unsigned int)maxH)
			*winHeight = maxH;

	}
Example #4
0
BOOL CMonitorManager::GetMonitorResolution(HWND hWnd, long *lResoluteW, long *lResoluteH)
{
	HMONITOR hm = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
	
	BOOL bFindMonitor = FALSE;

	for(int i = 0; i < m_MonitorList.size(); i++)
	{
		if (hm == m_MonitorList[i].hMonitor)
		{
			bFindMonitor = TRUE;
			break;
		}
	}

	if (!bFindMonitor) return FALSE;
	
	DISPLAY_DEVICE dd;
	ZeroMemory(&dd, sizeof(DISPLAY_DEVICE));
	dd.cb = sizeof(DISPLAY_DEVICE);
	bFindMonitor = EnumDisplayDevices(NULL, i, &dd, 0);
	if (!bFindMonitor) return FALSE;
	
	DEVMODE dm;
	ZeroMemory(&dm, sizeof(DEVMODE));
	dm.dmSize = sizeof(dm);
	bFindMonitor = EnumDisplaySettings((char*)dd.DeviceName, ENUM_CURRENT_SETTINGS, &dm);
	if (!bFindMonitor) return FALSE;
	
	*lResoluteW = dm.dmPelsWidth;
	*lResoluteH = dm.dmPelsHeight;
	
	return TRUE;
}
Example #5
0
static void d3d_free(void *data)
{
   d3d_video_t *d3d = (d3d_video_t*)data;
   d3d_deinitialize(d3d);
#ifdef _XBOX
   if (d3d->ctx_driver && d3d->ctx_driver->destroy)
      d3d->ctx_driver->destroy(d3d);
   d3d->ctx_driver = NULL;
#endif
   if (d3d->dev)
      d3d->dev->Release();
   if (d3d->g_pD3D)
      d3d->g_pD3D->Release();

#ifdef HAVE_MONITOR
   Monitor::last_hm = MonitorFromWindow(d3d->hWnd, MONITOR_DEFAULTTONEAREST);
   DestroyWindow(d3d->hWnd);
#endif

   if (d3d)
      delete d3d;

#ifndef _XBOX
   UnregisterClass("RetroArch", GetModuleHandle(NULL));
#endif
}
Example #6
0
static void gfx_ctx_destroy(void)
{
   if (g_hrc)
   {
      wglMakeCurrent(NULL, NULL);
      wglDeleteContext(g_hrc);
      g_hrc = NULL;
   }

   if (g_hwnd && g_hdc)
   {
      ReleaseDC(g_hwnd, g_hdc);
      g_hdc = NULL;
   }

   if (g_hwnd)
   {
      g_last_hm = MonitorFromWindow(g_hwnd, MONITOR_DEFAULTTONEAREST);
      DestroyWindow(g_hwnd);
      UnregisterClass("RetroArch", GetModuleHandle(NULL));
      g_hwnd = NULL;
   }

   if (g_restore_desktop)
   {
      MONITORINFOEX current_mon;
      memset(&current_mon, 0, sizeof(current_mon));
      current_mon.cbSize = sizeof(MONITORINFOEX);
      GetMonitorInfo(g_last_hm, (MONITORINFO*)&current_mon);
      ChangeDisplaySettingsEx(current_mon.szDevice, NULL, NULL, 0, NULL);
      g_restore_desktop = false;
   }

   g_inited = false;
}
void ConfigFileManager::CreateInstallerWindow(const std::wstring& title)
{
	if (m_pInstallerWindow != NULL)
	{
		delete m_pInstallerWindow;
		m_pInstallerWindow = NULL;
	}

	MONITORINFO mi = { 0 };
	mi.cbSize = sizeof(mi);
	CHECK_WIN32_BOOL(GetMonitorInfo(MonitorFromWindow(NULL, MONITOR_DEFAULTTOPRIMARY), & mi),
		L"GetMonitorInfo");

	int cx = 640;
	int cy = 480;

	m_pInstallerWindow = new InstallerWindow(); // deletes itself
	m_pInstallerWindow->Create(
		(mi.rcWork.left + mi.rcWork.right) / 2 - cx / 2, 
		(mi.rcWork.top + mi.rcWork.bottom) / 2 - cy / 2, 
		cx, cy, title.c_str());

	CHECK_BOOL(m_pInstallerWindow->hwnd != NULL,
		L"InstallerWindow::Create");
}
Example #8
0
static void
SetWindowMode(window_data Data, int Width, int Height)
{
	MONITORINFO MonitorInfo = {};
	MonitorInfo.cbSize = sizeof(MonitorInfo);
	if(GetMonitorInfo(MonitorFromWindow(Data.Window, MONITOR_DEFAULTTONEAREST), &MonitorInfo)) {
		RECT Rect = MonitorInfo.rcMonitor;
		int MonitorWidth = Rect.right - Rect.left;
		int MonitorHeight = Rect.bottom - Rect.top;
		int X = Rect.left;
		int Y = Rect.top;
		if(MonitorWidth > Width) {
			X = (MonitorWidth - Width) / 2;
		}
		if(MonitorHeight > Height) {
			Y = (MonitorHeight - Height) / 2;
		}
		SetWindowDimensions(Data, X, Y, Width, Height);
	}
	else {
		PRINT_ERR("Could not get monitor info.\n");
	}

	SetBorderlessWindowStyle(Data);
}
Example #9
0
void WindowManager::toggleBorderlessFullscreen() {
	borderlessFullscreen = !borderlessFullscreen;
	HWND hwnd = ::GetActiveWindow();
	if(borderlessFullscreen) {
		// store previous rect
		::GetClientRect(hwnd, &prevWindowRect);
		// set styles
		LONG lStyle = ::GetWindowLong(hwnd, GWL_STYLE);
		prevStyle = lStyle;
		lStyle &= ~(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZE | WS_MAXIMIZE | WS_SYSMENU);
		::SetWindowLong(hwnd, GWL_STYLE, lStyle);
		LONG lExStyle = ::GetWindowLong(hwnd, GWL_EXSTYLE);
		prevExStyle = lExStyle;
		lExStyle &= ~(WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE);
		::SetWindowLong(hwnd, GWL_EXSTYLE, lExStyle);
		// adjust size & position
		HMONITOR monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
		MONITORINFO info;
		info.cbSize = sizeof(MONITORINFO);
		GetMonitorInfo(monitor, &info);
		int monitorWidth = info.rcMonitor.right - info.rcMonitor.left;
		int monitorHeight = info.rcMonitor.bottom - info.rcMonitor.top;
		::SetWindowPos(hwnd, NULL, info.rcMonitor.left, info.rcMonitor.top, monitorWidth, monitorHeight, SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOOWNERZORDER);
	} else {
		// restore previous window
		::SetWindowLong(hwnd, GWL_STYLE, prevStyle);
		::SetWindowLong(hwnd, GWL_EXSTYLE, prevExStyle);
		RECT desiredRect = prevWindowRect;
		::AdjustWindowRect(&desiredRect, prevStyle, false);
		int wWidth = desiredRect.right - desiredRect.left, wHeight = desiredRect.bottom - desiredRect.top;
		::SetWindowPos(hwnd, NULL, prevWindowRect.left, prevWindowRect.top, wWidth, wHeight, SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOOWNERZORDER);
	}
}
// Thank you Raymond Chen!!
void Win32FullscreenToggle(HWND window)
{
    DWORD style = GetWindowLong(window, GWL_STYLE);
    if (style & WS_OVERLAPPEDWINDOW)
    {
        MONITORINFO monitorInfo = { sizeof(monitorInfo) };
        if (GetWindowPlacement(window, &globalWindowPos) &&
            GetMonitorInfo(MonitorFromWindow(window, MONITOR_DEFAULTTOPRIMARY), &monitorInfo))
        {//NOT BITWISE OPERATOR
            SetWindowLong(window, GWL_STYLE, style & ~WS_OVERLAPPEDWINDOW);
            SetWindowPos(window, HWND_TOP,
                         monitorInfo.rcMonitor.left, monitorInfo.rcMonitor.top,
                         monitorInfo.rcMonitor.right - monitorInfo.rcMonitor.left,
                         monitorInfo.rcMonitor.bottom - monitorInfo.rcMonitor.top,
                         SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
        }
    }
    else
    {
        SetWindowLong(window, GWL_STYLE, style | WS_OVERLAPPEDWINDOW);
        SetWindowPlacement(window, &globalWindowPos);
        SetWindowPos(window, NULL, 0, 0, 0, 0,
                     SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER |
                     SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
    }
}
Example #11
0
void DXContext::MinimizeWinamp(HMONITOR hPluginMonitor)
{
	// minimize Winamp window

	HMONITOR hWinampMon = MonitorFromWindow(m_hwnd_winamp, MONITOR_DEFAULTTONEAREST);
	HMONITOR hPluginMon = hPluginMonitor;//MonitorFromWindow(m_hwnd, MONITOR_DEFAULTTONEAREST);//m_lpD3D->GetAdapterMonitor(ordinal_adapter);

	if ((m_current_mode.screenmode == FULLSCREEN || m_current_mode.screenmode == FAKE_FULLSCREEN) &&
	    (m_minimize_winamp) &&
	    (hWinampMon && hPluginMon && hPluginMon==hWinampMon) &&
	    (!m_winamp_minimized)
	   )
	{
		// nitpicky check: if we're in fake fullscreen mode
		// and are only going to display on half the screen,
		// don't minimize Winamp.
		if (m_current_mode.screenmode == FAKE_FULLSCREEN)
		{
			int x = m_monitor_rect.right - m_monitor_rect.left;
			int y = m_monitor_rect.bottom - m_monitor_rect.top;
			if ((x >= y*2 && m_current_mode.m_dualhead_horz != 0) ||
			    (y > x*4/3 && m_current_mode.m_dualhead_vert != 0))
			{
				return;
			}
		}

		ShowWindow(m_hwnd_winamp, SW_MINIMIZE);
		// also restore the focus to the plugin window, since this will steal it:
		SetFocus(m_hwnd);
		SetActiveWindow(m_hwnd);
		SetForegroundWindow(m_hwnd);
		m_winamp_minimized = 1;
	}
}
Example #12
0
	bool D3D9Device::validateDisplayMonitor(D3D9RenderWindowCore* renderWindow)
	{
		// Ignore full screen since it doesn't really move and it is possible 
		// that it created using multi-head adapter so for a subordinate the
		// native monitor handle and this device handle will be different.
		if (renderWindow->getProperties().isFullScreen())
			return true;

		HMONITOR	hRenderWindowMonitor = NULL;

		// Find the monitor this render window belongs to.
		hRenderWindowMonitor = MonitorFromWindow(renderWindow->_getWindowHandle(), MONITOR_DEFAULTTONULL);

		// This window doesn't intersect with any of the display monitor
		if (hRenderWindowMonitor == NULL)		
			return false;		
		

		// Case this window changed monitor.
		if (hRenderWindowMonitor != mMonitor)
		{	
			// Lock access to rendering device.
			D3D9RenderAPI::getResourceManager()->lockDeviceAccess();

			mpDeviceManager->linkRenderWindow(renderWindow);

			// UnLock access to rendering device.
			D3D9RenderAPI::getResourceManager()->unlockDeviceAccess();

			return false;
		}

		return true;
	}
Example #13
0
void CorrectConsolePos(HWND hConWnd)
{
	RECT rcNew = {};
	if (GetWindowRect(hConWnd, &rcNew))
	{
		HMONITOR hMon = MonitorFromWindow(hConWnd, MONITOR_DEFAULTTOPRIMARY);
		MONITORINFO mi = {sizeof(mi)};
		//int nMaxX = 0, nMaxY = 0;
		if (GetMonitorInfo(hMon, &mi))
		{
			int newW = (rcNew.right-rcNew.left), newH = (rcNew.bottom-rcNew.top);
			int newX = rcNew.left, newY = rcNew.top;

			if (newX < mi.rcWork.left)
				newX = mi.rcWork.left;
			else if (rcNew.right > mi.rcWork.right)
				newX = max(mi.rcWork.left,(mi.rcWork.right-newW));

			if (newY < mi.rcWork.top)
				newY = mi.rcWork.top;
			else if (rcNew.bottom > mi.rcWork.bottom)
				newY = max(mi.rcWork.top,(mi.rcWork.bottom-newH));

			if ((newX != rcNew.left) || (newY != rcNew.top))
				SetWindowPos(hConWnd, HWND_TOP, newX, newY,0,0, SWP_NOSIZE);
		}
	}
}
Example #14
0
void Dialog::SnapToEdges(LPWINDOWPOS window_pos) {
  if (!snap_gap_)
    return;

  RECT rc_monitor = {0};
  SystemParametersInfo(SPI_GETWORKAREA, 0, &rc_monitor, 0);
  if (GetSystemMetrics(SM_CMONITORS) > 1) {
    HMONITOR monitor = MonitorFromWindow(window_, MONITOR_DEFAULTTONEAREST);
    if (monitor) {
      MONITORINFO mi;
      mi.cbSize = sizeof(mi);
      GetMonitorInfo(monitor, &mi);
      rc_monitor = mi.rcWork;
    }
  }

  // Snap X axis
  if (abs(window_pos->x - rc_monitor.left) <= snap_gap_) {
    window_pos->x = rc_monitor.left;
  } else if (abs(window_pos->x + window_pos->cx - rc_monitor.right) <= snap_gap_) {
    window_pos->x = rc_monitor.right - window_pos->cx;
  }
  // Snap Y axis
  if (abs(window_pos->y - rc_monitor.top) <= snap_gap_) {
    window_pos->y = rc_monitor.top;
  } else if (abs(window_pos->y + window_pos->cy - rc_monitor.bottom) <= snap_gap_) {
    window_pos->y = rc_monitor.bottom - window_pos->cy;
  }
}
Example #15
0
void CDpiAware::GetCenteredRect(HWND hWnd, RECT& rcCentered, HMONITOR hDefault /*= NULL*/)
{
	bool lbCentered = false;
	HMONITOR hMon;

	if (hWnd)
		hMon = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
	else
		hMon = MonitorFromRect(&rcCentered, MONITOR_DEFAULTTONEAREST);

	MONITORINFO mi = {};
	GetNearestMonitorInfo(&mi, hDefault, hWnd ? NULL : &rcCentered, hWnd);

	int iWidth  = rcCentered.right - rcCentered.left;
	int iHeight = rcCentered.bottom - rcCentered.top;

	RECT rcNew = {
			(mi.rcWork.left + mi.rcWork.right - iWidth)/2,
			(mi.rcWork.top + mi.rcWork.bottom - iHeight)/2
	};
	rcNew.right = rcNew.left + iWidth;
	rcNew.bottom = rcNew.top + iHeight;

	rcCentered = rcNew;
}
Example #16
0
void WindowManager::resize(unsigned clientW, unsigned clientH) {
	HWND hwnd = ::GetActiveWindow();
	// Store current window rect
	::GetClientRect(hwnd, &prevWindowRect);
	// Get monitor size
	HMONITOR monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
	MONITORINFO info;
	info.cbSize = sizeof(MONITORINFO);
	GetMonitorInfo(monitor, &info);
	int monitorWidth = info.rcMonitor.right - info.rcMonitor.left;
	int monitorHeight = info.rcMonitor.bottom - info.rcMonitor.top;

	// How much do we overlap or are smaller than the actual screen size
	int widthDiff = monitorWidth - (clientW ? clientW : prevWindowRect.right);
	int heightDiff = monitorHeight - (clientH ? clientH : prevWindowRect.bottom);

 	RECT desiredRect;
	desiredRect.left = widthDiff / 2;
	desiredRect.top = heightDiff / 2;
	desiredRect.right = monitorWidth - (widthDiff / 2);
	desiredRect.bottom = monitorHeight - (heightDiff / 2);
 	LONG lStyle = ::GetWindowLong(hwnd, GWL_STYLE);
 	::AdjustWindowRect(&desiredRect, lStyle, false);
	::SetWindowPos(hwnd, NULL, desiredRect.left, desiredRect.top, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
}
void Win32WindowManager::lowerCurtain()
{
   if(mCurtainWindow)
      return;

   // For now just grab monitor of the first window... we may need to
   // beef this up later on, maybe by passing in the window that's entering
   // leaving full-screen to lowerCurtain.
   HMONITOR hMon = MonitorFromWindow(mWindowListHead->getHWND(), MONITOR_DEFAULTTOPRIMARY);

   // Get the monitor's extents.
   MONITORINFO monInfo;
   dMemset(&monInfo, 0, sizeof MONITORINFO);
   monInfo.cbSize = sizeof MONITORINFO;

   GetMonitorInfo(hMon, &monInfo);
 
   mCurtainWindow = CreateWindow(Win32Window::getCurtainWindowClassName(), 
                           dT(""), (WS_POPUP | WS_MAXIMIZE | WS_VISIBLE),
                           monInfo.rcWork.left, monInfo.rcWork.top, 
                           monInfo.rcWork.right - monInfo.rcWork.left, 
                           monInfo.rcWork.bottom - monInfo.rcWork.top, 
                           NULL, NULL, NULL, NULL);

   if (!mOffscreenRender)
      SetWindowPos(mCurtainWindow, HWND_TOPMOST, 0, 0, 0, 0,  SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
}
Example #18
0
void CResizableStandAloneDialog::OnNcMButtonUp(UINT nHitTest, CPoint point)
{
    WINDOWPLACEMENT windowPlacement;
    if ((nHitTest == HTMAXBUTTON) && GetWindowPlacement(&windowPlacement) && windowPlacement.showCmd == SW_SHOWNORMAL)
    {
        CRect rcWindowRect;
        GetWindowRect(&rcWindowRect);

        MONITORINFO mi = {0};
        mi.cbSize = sizeof(MONITORINFO);

        if (m_bVertical)
        {
            rcWindowRect.top = m_rcOrgWindowRect.top;
            rcWindowRect.bottom = m_rcOrgWindowRect.bottom;
        }
        else if (GetMonitorInfo(MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST), &mi))
        {
            m_rcOrgWindowRect.top = rcWindowRect.top;
            m_rcOrgWindowRect.bottom = rcWindowRect.bottom;
            rcWindowRect.top = mi.rcWork.top;
            rcWindowRect.bottom = mi.rcWork.bottom;
        }
        m_bVertical = !m_bVertical;
        //m_bHorizontal = m_bHorizontal;
        MoveWindow(&rcWindowRect);
    }
    CStandAloneDialogTmpl<CResizableDialog>::OnNcMButtonUp(nHitTest, point);
}
void ConfigFileManager::CreateDownloadWindow(const DownloadDialogPtr& dialog)
{
	if (m_pDownloadWindow != NULL)
	{
		delete m_pDownloadWindow;
		m_pDownloadWindow = NULL;
	}

	MONITORINFO mi = { 0 };
	mi.cbSize = sizeof(mi);
	CHECK_WIN32_BOOL(GetMonitorInfo(MonitorFromWindow(NULL, MONITOR_DEFAULTTOPRIMARY), & mi),
		L"GetMonitorInfo");

	int cx = 550;
	int cy = 250;

	m_pDownloadWindow = new DownloadWindow(dialog); // deletes itself
	m_pDownloadWindow->Create(
		(mi.rcWork.left + mi.rcWork.right) / 2 - cx / 2, 
		(mi.rcWork.top + mi.rcWork.bottom) / 2 - cy / 2, 
		cx, cy, dialog->caption.GetValue().c_str());

	CHECK_BOOL(m_pDownloadWindow->hwnd != NULL,
		L"DownloadWindow::Create");
}
Example #20
0
void CResizableStandAloneDialog::OnNcRButtonUp(UINT nHitTest, CPoint point)
{
    WINDOWPLACEMENT windowPlacement;
    if ((nHitTest == HTMAXBUTTON) && GetWindowPlacement(&windowPlacement) && windowPlacement.showCmd == SW_SHOWNORMAL)
    {
        CRect rcWindowRect;
        GetWindowRect(&rcWindowRect);

        MONITORINFO mi = {0};
        mi.cbSize = sizeof(MONITORINFO);

        if (m_bHorizontal)
        {
            rcWindowRect.left = m_rcOrgWindowRect.left;
            rcWindowRect.right = m_rcOrgWindowRect.right;
        }
        else if (GetMonitorInfo(MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST), &mi))
        {
            m_rcOrgWindowRect.left = rcWindowRect.left;
            m_rcOrgWindowRect.right = rcWindowRect.right;
            rcWindowRect.left = mi.rcWork.left;
            rcWindowRect.right = mi.rcWork.right;
        }
        //m_bVertical = m_bVertical;
        m_bHorizontal = !m_bHorizontal;
        MoveWindow(&rcWindowRect);
        // WORKAROUND
        // for some reasons, when the window is resized horizontally, its menu size is not get adjusted.
        // so, we force it to happen.
        SetMenu(GetMenu());
    }
    CStandAloneDialogTmpl<CResizableDialog>::OnNcRButtonUp(nHitTest, point);
}
NS_IMETHODIMP
nsScreenManagerWin :: ScreenForNativeWidget(void *aWidget, nsIScreen **outScreen)
{
  HMONITOR mon = MonitorFromWindow ((HWND) aWidget, MONITOR_DEFAULTTOPRIMARY);
  *outScreen = CreateNewScreenObject (mon);
  return NS_OK;
}
Example #22
0
void win32_monitor_info(void *data, void *hm_data, unsigned *mon_id)
{
   unsigned i, fs_monitor;
   settings_t *settings = config_get_ptr();
   MONITORINFOEX *mon   = (MONITORINFOEX*)data;
   HMONITOR *hm_to_use  = (HMONITOR*)hm_data;

   if (!win32_monitor_last)
      win32_monitor_last = MonitorFromWindow(GetDesktopWindow(), MONITOR_DEFAULTTONEAREST);

   *hm_to_use = win32_monitor_last;
   fs_monitor = settings->video.monitor_index;

   if (fs_monitor && fs_monitor <= win32_monitor_count
         && win32_monitor_all[fs_monitor - 1])
   {
      *hm_to_use = win32_monitor_all[fs_monitor - 1];
      *mon_id    = fs_monitor - 1;
   }
   else
   {
      for (i = 0; i < win32_monitor_count; i++)
      {
         if (win32_monitor_all[i] != *hm_to_use)
            continue;

         *mon_id = i;
         break;
      }
   }

   memset(mon, 0, sizeof(*mon));
   mon->cbSize = sizeof(MONITORINFOEX);
   GetMonitorInfo(*hm_to_use, (MONITORINFO*)mon);
}
Example #23
0
void toggleFullscreen(bool isFullscreen)
{
    MONITORINFO monitorInfo;
    dwStyle = GetWindowLong(hWindow, GWL_STYLE);

    if(isFullscreen)
    {
        if(dwStyle & WS_OVERLAPPEDWINDOW)
        {
            monitorInfo = { sizeof(MONITORINFO) };

            if(GetWindowPlacement(hWindow, &wpPrev) && GetMonitorInfo(MonitorFromWindow(hWindow, MONITORINFOF_PRIMARY), &monitorInfo))
            {
                SetWindowLong(hWindow, GWL_STYLE, dwStyle & ~WS_OVERLAPPEDWINDOW);
                SetWindowPos(hWindow, HWND_TOP, monitorInfo.rcMonitor.left, monitorInfo.rcMonitor.top, monitorInfo.rcMonitor.right - monitorInfo.rcMonitor.left, monitorInfo.rcMonitor.bottom - monitorInfo.rcMonitor.top, SWP_NOZORDER | SWP_FRAMECHANGED);
            }
        }

        ShowCursor(FALSE);
    }
    else
    {
        SetWindowLong(hWindow, GWL_STYLE, dwStyle | WS_OVERLAPPEDWINDOW);
        SetWindowPlacement(hWindow, &wpPrev);
        SetWindowPos(hWindow, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_FRAMECHANGED);
        ShowCursor(TRUE);
    }
}
Example #24
0
// Multi-monitor support.
RECT d3d_monitor_rect(void *data)
{
   d3d_video_t *d3d = (d3d_video_t*)data;
   Monitor::num_mons = 0;
   EnumDisplayMonitors(NULL, NULL, monitor_enum_proc, 0);

   if (!Monitor::last_hm)
      Monitor::last_hm = MonitorFromWindow(GetDesktopWindow(), MONITOR_DEFAULTTONEAREST);
   HMONITOR hm_to_use = Monitor::last_hm;

   unsigned fs_monitor = g_settings.video.monitor_index;
   if (fs_monitor && fs_monitor <= Monitor::num_mons && Monitor::all_hms[fs_monitor - 1])
   {
      hm_to_use = Monitor::all_hms[fs_monitor - 1];
      d3d->cur_mon_id = fs_monitor - 1;
   }
   else
   {
      for (unsigned i = 0; i < Monitor::num_mons; i++)
      {
         if (Monitor::all_hms[i] == hm_to_use)
         {
            d3d->cur_mon_id = i;
            break;
         }
      }
   }

   MONITORINFOEX current_mon;
   memset(&current_mon, 0, sizeof(current_mon));
   current_mon.cbSize = sizeof(MONITORINFOEX);
   GetMonitorInfo(hm_to_use, (MONITORINFO*)&current_mon);

   return current_mon.rcMonitor;
}
Example #25
0
/**
 * \brief Update screen information.
 *
 * This function should be called in libvo's "control" callback
 * with parameter VOCTRL_UPDATE_SCREENINFO.
 * Note that this also enables the new API where geometry and aspect
 * calculations are done in video_out.c:config_video_out
 *
 * Global libvo variables changed:
 * xinerama_x
 * xinerama_y
 * vo_screenwidth
 * vo_screenheight
 */
static void w32_update_xinerama_info(struct vo *vo)
{
    struct vo_w32_state *w32 = vo->w32;
    struct mp_vo_opts *opts = vo->opts;
    int screen = opts->fullscreen ? opts->fsscreen_id : opts->screen_id;
    vo->xinerama_x = vo->xinerama_y = 0;
    if (opts->fullscreen && screen == -2) {
        int tmp;
        vo->xinerama_x = GetSystemMetrics(SM_XVIRTUALSCREEN);
        vo->xinerama_y = GetSystemMetrics(SM_YVIRTUALSCREEN);
        tmp = GetSystemMetrics(SM_CXVIRTUALSCREEN);
        if (tmp) vo->opts->screenwidth = tmp;
        tmp = GetSystemMetrics(SM_CYVIRTUALSCREEN);
        if (tmp) vo->opts->screenheight = tmp;
    } else if (screen == -1) {
        MONITORINFO mi;
        HMONITOR m = MonitorFromWindow(w32->window, MONITOR_DEFAULTTOPRIMARY);
        mi.cbSize = sizeof(mi);
        GetMonitorInfoW(m, &mi);
        vo->xinerama_x = mi.rcMonitor.left;
        vo->xinerama_y = mi.rcMonitor.top;
        vo->opts->screenwidth = mi.rcMonitor.right - mi.rcMonitor.left;
        vo->opts->screenheight = mi.rcMonitor.bottom - mi.rcMonitor.top;
    } else if (screen >= 0) {
        w32->mon_cnt = 0;
        w32->mon_id = screen;
        EnumDisplayMonitors(NULL, NULL, mon_enum, (LONG_PTR)vo);
    }
    aspect_save_screenres(vo, vo->opts->screenwidth,
                          vo->opts->screenheight);
}
Example #26
0
static void d3d_free(void *data)
{
   d3d_video_t *d3d = (d3d_video_t*)data;
   d3d_deinitialize(d3d);
#ifdef HAVE_OVERLAY
   d3d_free_overlays(d3d);
#endif
#ifdef HAVE_MENU
   d3d_free_overlay(d3d, d3d->rgui);
#endif
   if (d3d->dev)
      d3d->dev->Release();
   if (d3d->g_pD3D)
      d3d->g_pD3D->Release();

#ifdef HAVE_MONITOR
   Monitor::last_hm = MonitorFromWindow(d3d->hWnd, MONITOR_DEFAULTTONEAREST);
#endif
   DestroyWindow(d3d->hWnd);

   if (d3d)
      free(d3d);

#ifndef _XBOX
   UnregisterClass("RetroArch", GetModuleHandle(NULL));
#endif
}
void Init()
{
	CIniReader iniReader("");
	res_x = iniReader.ReadInteger("MAIN", "ResX", 0);
	res_y = iniReader.ReadInteger("MAIN", "ResY", 0);
	hud_patch = iniReader.ReadInteger("MAIN", "FixHUD", 0);

	if (!res_x || !res_y) {
		HMONITOR monitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
		MONITORINFO info;
		info.cbSize = sizeof(MONITORINFO);
		GetMonitorInfo(monitor, &info);
		res_x = info.rcMonitor.right - info.rcMonitor.left;
		res_y = info.rcMonitor.bottom - info.rcMonitor.top;
	}

	CPatch::Nop(0x7A3B5E, 7);
	CPatch::SetUInt(0x7A3B72 + 0x2, res_x);
	CPatch::SetUInt(0x7A3B7B + 0x2, res_y);

	if (hud_patch)
	{
		fHudPos = (-1.0f * (4.0f / 3.0f)) / (static_cast<float>(res_x) / static_cast<float>(res_y));
		fHudScale = (2.0f * (4.0f / 3.0f)) / (static_cast<float>(res_x) / static_cast<float>(res_y));

		CPatch::SetFloat(0x756CF8 + 0x1, fHudPos);
		CPatch::SetPointer(0x756D23 + 0x2, &fHudScale);
	}
}
/**
 * Resize the GL context.
 */
void PlatformResizeGLContext( FPlatformOpenGLDevice* Device, FPlatformOpenGLContext* Context, uint32 SizeX, uint32 SizeY, bool bFullscreen, bool bWasFullscreen, GLenum BackBufferTarget, GLuint BackBufferResource)
{
	FScopeLock ScopeLock(Device->ContextUsageGuard);
{
	uint32 WindowStyle = WS_CAPTION | WS_SYSMENU;
	uint32 WindowStyleEx = 0;
	HWND InsertAfter = HWND_NOTOPMOST;

	if (bFullscreen)
	{
		// Get the monitor info from the window handle.
		HMONITOR hMonitor = MonitorFromWindow(Context->WindowHandle, MONITOR_DEFAULTTOPRIMARY);
		MONITORINFOEX MonitorInfo;
		memset(&MonitorInfo, 0, sizeof(MONITORINFOEX));
		MonitorInfo.cbSize = sizeof(MONITORINFOEX);
		GetMonitorInfo(hMonitor, &MonitorInfo);

		DEVMODE Mode;
		Mode.dmSize = sizeof(DEVMODE);
		Mode.dmBitsPerPel = 32;
		Mode.dmPelsWidth = SizeX;
		Mode.dmPelsHeight = SizeY;
		Mode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;

		// Turn on fullscreen mode for the current monitor
		ChangeDisplaySettingsEx(MonitorInfo.szDevice, &Mode, NULL, CDS_FULLSCREEN, NULL);

		WindowStyle = WS_POPUP;
		WindowStyleEx = WS_EX_APPWINDOW | WS_EX_TOPMOST;
		InsertAfter = HWND_TOPMOST;
	}
	else if (bWasFullscreen)
	{
		ChangeDisplaySettings(NULL, 0);
	}

	//SetWindowLong(Context->WindowHandle, GWL_STYLE, WindowStyle);
	//SetWindowLong(Context->WindowHandle, GWL_EXSTYLE, WindowStyleEx);

		{
			FScopeContext ScopeContext(Context);

			if (Context->ViewportFramebuffer == 0)
			{
				glGenFramebuffers(1, &Context->ViewportFramebuffer);
			}
			glBindFramebuffer(GL_FRAMEBUFFER, Context->ViewportFramebuffer);
			glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, BackBufferTarget, BackBufferResource, 0);
#if UE_BUILD_DEBUG
			glReadBuffer(GL_COLOR_ATTACHMENT0);
			glDrawBuffer(GL_COLOR_ATTACHMENT0);
#endif
			FOpenGL::CheckFrameBuffer();

			glViewport(0, 0, SizeX, SizeY);
			static GLfloat ZeroColor[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
			glClearBufferfv(GL_COLOR, 0, ZeroColor );
		}
	}
}
Example #29
0
void ToggleFullscreen(HWND Window)
{
	//WINDOWPLACEMENT WindowPosition = { sizeof(WINDOWPLACEMENT) };
	//GetWindowPlacement(Window, &WindowPosition);

	// This follows Raymond Chen's prescription
	// for fullscreen toggling, see:
	// http://blogs.msdn.com/b/oldnewthing/archive/2010/04/12/9994016.aspx

	DWORD Style = GetWindowLongW(Window, GWL_STYLE);
	if (Style & WS_OVERLAPPEDWINDOW)
	{
		MONITORINFO MonitorInfo = { sizeof(MonitorInfo) };
		if (GetWindowPlacement(Window, &WindowPosition) &&
			GetMonitorInfoW(MonitorFromWindow(Window, MONITOR_DEFAULTTOPRIMARY), &MonitorInfo))
		{
			SetWindowLongW(Window, GWL_STYLE, Style & ~WS_OVERLAPPEDWINDOW);
			SetWindowPos(Window, HWND_TOP,
						 MonitorInfo.rcMonitor.left, MonitorInfo.rcMonitor.top,
						 MonitorInfo.rcMonitor.right - MonitorInfo.rcMonitor.left,
						 MonitorInfo.rcMonitor.bottom - MonitorInfo.rcMonitor.top,
						 SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
		}
	}
	else
	{
		SetWindowLongW(Window, GWL_STYLE, Style | WS_OVERLAPPEDWINDOW);
		SetWindowPlacement(Window, &WindowPosition);
		SetWindowPos(Window, 0, 0, 0, 0, 0,
					 SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER |
					 SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
	}
}
Example #30
0
LONG WINAPI ChangeDisplaySettingsHook(LPDEVMODEA lpDevMode, DWORD dwFlags)
{
	DWORD pCaller;
	__asm {mov eax, [ebp+0x4]}
	__asm {mov pCaller, eax}
	fprintf(logFile, "* ChangeDisplaySettings: %x, caller: %x\n", dwFlags, pCaller);
	fprintf(logFile, "hWnd: %x\n", *g_hWnd);
	fprintf(logFile, "hRenderWnd: %x\n", *g_hRenderWnd);
	fprintf(logFile, "GetForegroundWindow: %x\n", GetForegroundWindow());

	HWND hWnd = *g_hRenderWnd;
	char sWindowCaption[64];
	sWindowCaption[0] = 0;
	GetWindowText(hWnd, sWindowCaption, 64);

	fprintf(logFile, "Window caption: %s\n", sWindowCaption);
	
	HMONITOR hMonitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
	
	fprintf(logFile, "hMonitor: %x\n", hMonitor);
	MONITORINFOEX stMonitorInfo;
	memset(&stMonitorInfo, 0, sizeof(MONITORINFOEX));
	stMonitorInfo.cbSize = sizeof(MONITORINFOEX);
	if(GetMonitorInfo(hMonitor, &stMonitorInfo))
	{
		fprintf(logFile, "Got monitor info\n");
		fprintf(logFile, "Device: %s\n", stMonitorInfo.szDevice);
	}
	else
	{
		fprintf(logFile, "MONITORINFO is NULL\n");
	}
	fflush(logFile);
	return ChangeDisplaySettingsEx(NULL, lpDevMode, NULL, dwFlags, NULL);
}