Changeset View
Changeset View
Standalone View
Standalone View
intern/ghost/intern/GHOST_WindowWin32.cpp
| Context not available. | |||||
| const int GHOST_WindowWin32::s_maxTitleLength = 128; | const int GHOST_WindowWin32::s_maxTitleLength = 128; | ||||
| /* force NVidia Optimus to used dedicated graphics */ | /* force NVidia Optimus to used dedicated graphics */ | ||||
| extern "C" { | extern "C" { | ||||
| __declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; | __declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; | ||||
| Context not available. | |||||
| m_parentWindowHwnd(parentwindowhwnd), | m_parentWindowHwnd(parentwindowhwnd), | ||||
| m_debug_context(is_debug) | m_debug_context(is_debug) | ||||
| { | { | ||||
| int wintype = WS_OVERLAPPEDWINDOW; | |||||
| // Initialize tablet variables | // Initialize tablet variables | ||||
| memset(&m_wintab, 0, sizeof(m_wintab)); | memset(&m_wintab, 0, sizeof(m_wintab)); | ||||
| memset(&m_tabletData, 0, sizeof(m_tabletData)); | memset(&m_tabletData, 0, sizeof(m_tabletData)); | ||||
| Context not available. | |||||
| // Create window | // Create window | ||||
| if (state != GHOST_kWindowStateFullScreen) { | if (state != GHOST_kWindowStateFullScreen) { | ||||
| RECT rect; | RECT rect; | ||||
| MONITORINFO monitor; | |||||
| GHOST_TUns32 tw, th; | |||||
| #ifndef _MSC_VER | |||||
| int cxsizeframe = GetSystemMetrics(SM_CXSIZEFRAME); | |||||
| int cysizeframe = GetSystemMetrics(SM_CYSIZEFRAME); | |||||
| #else | |||||
| // MSVC 2012+ returns bogus values from GetSystemMetrics, bug in Windows | |||||
| // http://connect.microsoft.com/VisualStudio/feedback/details/753224/regression-getsystemmetrics-delivers-different-values | |||||
| RECT cxrect = {0, 0, 0, 0}; | |||||
| AdjustWindowRectEx(&cxrect, WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_THICKFRAME | WS_DLGFRAME, FALSE, 0); | |||||
| int cxsizeframe = abs(cxrect.bottom); | |||||
| int cysizeframe = abs(cxrect.left); | |||||
| #endif | |||||
| width += cxsizeframe * 2; | |||||
| height += cysizeframe * 2 + GetSystemMetrics(SM_CYCAPTION); | |||||
| rect.left = left; | rect.left = left; | ||||
| rect.right = left + width; | rect.right = left + width; | ||||
| rect.top = top; | rect.top = top; | ||||
| rect.bottom = top + height; | rect.bottom = top + height; | ||||
| monitor.cbSize = sizeof(monitor); | |||||
| monitor.dwFlags = 0; | |||||
| // take taskbar into account | |||||
| GetMonitorInfo(MonitorFromRect(&rect, MONITOR_DEFAULTTONEAREST), &monitor); | |||||
| th = monitor.rcWork.bottom - monitor.rcWork.top; | |||||
| tw = monitor.rcWork.right - monitor.rcWork.left; | |||||
| if (tw < width) { | |||||
| width = tw; | |||||
| left = monitor.rcWork.left; | |||||
| } | |||||
| else if (monitor.rcWork.right < left + (int)width) | |||||
| left = monitor.rcWork.right - width; | |||||
| else if (left < monitor.rcWork.left) | |||||
| left = monitor.rcWork.left; | |||||
| if (th < height) { | |||||
| height = th; | |||||
| top = monitor.rcWork.top; | |||||
| } | |||||
| else if (monitor.rcWork.bottom < top + (int)height) | |||||
| top = monitor.rcWork.bottom - height; | |||||
| else if (top < monitor.rcWork.top) | |||||
| top = monitor.rcWork.top; | |||||
| int wintype = WS_OVERLAPPEDWINDOW; | |||||
| if (m_parentWindowHwnd != 0) { | if (m_parentWindowHwnd != 0) { | ||||
| wintype = WS_CHILD; | wintype = WS_CHILD; | ||||
| GetWindowRect((HWND)m_parentWindowHwnd, &rect); | GetWindowRect((HWND)m_parentWindowHwnd, &rect); | ||||
| Context not available. | |||||
| width = rect.right - rect.left; | width = rect.right - rect.left; | ||||
| height = rect.bottom - rect.top; | height = rect.bottom - rect.top; | ||||
| } | } | ||||
| wchar_t *title_16 = alloc_utf16_from_8((char *)(const char *)title, 0); | |||||
| m_hWnd = ::CreateWindowW( | |||||
| s_windowClassName, // pointer to registered class name | |||||
| title_16, // pointer to window name | |||||
| wintype, // window style | |||||
| left, // horizontal position of window | |||||
| top, // vertical position of window | |||||
| width, // window width | |||||
| height, // window height | |||||
| (HWND)m_parentWindowHwnd, // handle to parent or owner window | |||||
| 0, // handle to menu or child-window identifier | |||||
| ::GetModuleHandle(0), // handle to application instance | |||||
| 0); // pointer to window-creation data | |||||
| free(title_16); | |||||
| } | } | ||||
| else { | else { | ||||
| wchar_t *title_16 = alloc_utf16_from_8((char *)(const char *)title, 0); | wintype = WS_POPUP | WS_MAXIMIZE; | ||||
| m_hWnd = ::CreateWindowW( | parentwindowhwnd = HWND_DESKTOP; | ||||
| s_windowClassName, // pointer to registered class name | |||||
| title_16, // pointer to window name | |||||
| WS_POPUP | WS_MAXIMIZE, // window style | |||||
| left, // horizontal position of window | |||||
| top, // vertical position of window | |||||
| width, // window width | |||||
| height, // window height | |||||
| HWND_DESKTOP, // handle to parent or owner window | |||||
| 0, // handle to menu or child-window identifier | |||||
| ::GetModuleHandle(0), // handle to application instance | |||||
| 0); // pointer to window-creation data | |||||
| free(title_16); | |||||
| } | } | ||||
| wchar_t *title_16 = alloc_utf16_from_8((char *)(const char *)title, 0); | |||||
| m_hWnd = ::CreateWindowW( | |||||
| s_windowClassName, // pointer to registered class name | |||||
| title_16, // pointer to window name | |||||
| wintype, // window style | |||||
| left, // horizontal position of window | |||||
| top, // vertical position of window | |||||
| width, // window width | |||||
| height, // window height | |||||
| (HWND)parentwindowhwnd, // handle to parent or owner window | |||||
| 0, // handle to menu or child-window identifier | |||||
| ::GetModuleHandle(0), // handle to application instance | |||||
| 0); // pointer to window-creation data | |||||
| free(title_16); | |||||
| m_user32 = ::LoadLibrary("user32.dll"); | m_user32 = ::LoadLibrary("user32.dll"); | ||||
| if (m_hWnd) { | if (m_hWnd) { | ||||
| Context not available. | |||||