Style cleanup GHOST/Win32

This commit is contained in:
Campbell Barton
2014-07-27 13:40:39 +10:00
parent 698a9a2434
commit 648ee669b7
5 changed files with 222 additions and 189 deletions

View File

@@ -56,7 +56,7 @@ GHOST_TSuccess GHOST_DisplayManagerWin32::getNumDisplays(GHOST_TUns8& numDisplay
return numDisplays > 0 ? GHOST_kSuccess : GHOST_kFailure;
}
static BOOL get_dd(DWORD d, DISPLAY_DEVICE* dd)
static BOOL get_dd(DWORD d, DISPLAY_DEVICE *dd)
{
dd->cb = sizeof(DISPLAY_DEVICE);
return ::EnumDisplayDevices(NULL, d, dd, 0);
@@ -161,8 +161,7 @@ GHOST_TSuccess GHOST_DisplayManagerWin32::setCurrentDisplaySetting(GHOST_TUns8 d
LONG status = ::ChangeDisplaySettings(&dm, CDS_FULLSCREEN);
#ifdef GHOST_DEBUG
switch (status)
{
switch (status) {
case DISP_CHANGE_SUCCESSFUL:
printf("display change: The settings change was successful.\n");
break;
@@ -173,7 +172,8 @@ GHOST_TSuccess GHOST_DisplayManagerWin32::setCurrentDisplaySetting(GHOST_TUns8 d
printf("display change: An invalid set of flags was passed in.\n");
break;
case DISP_CHANGE_BADPARAM:
printf("display change: An invalid parameter was passed in. This can include an invalid flag or combination of flags.\n");
printf("display change: An invalid parameter was passed in. "
"This can include an invalid flag or combination of flags.\n");
break;
case DISP_CHANGE_FAILED:
printf("display change: The display driver failed the specified graphics mode.\n");

View File

@@ -43,10 +43,11 @@ void printLastError(void);
#endif // GHOST_DEBUG
GHOST_DropTargetWin32::GHOST_DropTargetWin32(GHOST_WindowWin32 *window, GHOST_SystemWin32 *system)
:
m_window(window),
m_system(system)
GHOST_DropTargetWin32::GHOST_DropTargetWin32(
GHOST_WindowWin32 *window,
GHOST_SystemWin32 *system)
: m_window(window),
m_system(system)
{
m_cRef = 1;
m_hWnd = window->getHWND();
@@ -68,8 +69,7 @@ HRESULT __stdcall GHOST_DropTargetWin32::QueryInterface(REFIID riid, void **ppvO
return E_INVALIDARG;
*ppvObj = NULL;
if (riid == IID_IUnknown || riid == IID_IDropTarget)
{
if (riid == IID_IUnknown || riid == IID_IDropTarget) {
AddRef();
*ppvObj = (void *)this;
return S_OK;
@@ -208,8 +208,7 @@ GHOST_TDragnDropTypes GHOST_DropTargetWin32::getGhostType(IDataObject *pDataObje
void *GHOST_DropTargetWin32::getGhostData(IDataObject *pDataObject)
{
GHOST_TDragnDropTypes type = getGhostType(pDataObject);
switch (type)
{
switch (type) {
case GHOST_kDragnDropTypeFilenames:
return getDropDataAsFilenames(pDataObject);
break;
@@ -241,15 +240,12 @@ void *GHOST_DropTargetWin32::getDropDataAsFilenames(IDataObject *pDataObject)
// Check if dataobject supplies the format we want.
// Double checking here, first in getGhostType.
if (pDataObject->QueryGetData(&fmtetc) == S_OK)
{
if (pDataObject->GetData(&fmtetc, &stgmed) == S_OK)
{
if (pDataObject->QueryGetData(&fmtetc) == S_OK) {
if (pDataObject->GetData(&fmtetc, &stgmed) == S_OK) {
hdrop = (HDROP) ::GlobalLock(stgmed.hGlobal);
totfiles = ::DragQueryFileW(hdrop, -1, NULL, 0);
if (!totfiles)
{
if (!totfiles) {
::GlobalUnlock(stgmed.hGlobal);
return NULL;
}
@@ -258,14 +254,11 @@ void *GHOST_DropTargetWin32::getDropDataAsFilenames(IDataObject *pDataObject)
strArray->count = 0;
strArray->strings = (GHOST_TUns8 **) ::malloc(totfiles * sizeof(GHOST_TUns8 *));
for (UINT nfile = 0; nfile < totfiles; nfile++)
{
if (::DragQueryFileW(hdrop, nfile, fpath, MAX_PATH) > 0)
{
if (!(temp_path = alloc_utf_8_from_16(fpath, 0)) )
{
for (UINT nfile = 0; nfile < totfiles; nfile++) {
if (::DragQueryFileW(hdrop, nfile, fpath, MAX_PATH) > 0) {
if (!(temp_path = alloc_utf_8_from_16(fpath, 0)) ) {
continue;
}
}
// Just ignore paths that could not be converted verbatim.
strArray->strings[nvalid] = (GHOST_TUns8 *) temp_path;
@@ -291,13 +284,10 @@ void *GHOST_DropTargetWin32::getDropDataAsString(IDataObject *pDataObject)
// Try unicode first.
// Check if dataobject supplies the format we want.
if (pDataObject->QueryGetData(&fmtetc) == S_OK)
{
if (pDataObject->GetData(&fmtetc, &stgmed) == S_OK)
{
if (pDataObject->QueryGetData(&fmtetc) == S_OK) {
if (pDataObject->GetData(&fmtetc, &stgmed) == S_OK) {
LPCWSTR wstr = (LPCWSTR) ::GlobalLock(stgmed.hGlobal);
if (!(tmp_string = alloc_utf_8_from_16((wchar_t *)wstr, 0)) )
{
if (!(tmp_string = alloc_utf_8_from_16((wchar_t *)wstr, 0)) ) {
::GlobalUnlock(stgmed.hGlobal);
return NULL;
}
@@ -313,21 +303,17 @@ void *GHOST_DropTargetWin32::getDropDataAsString(IDataObject *pDataObject)
fmtetc.cfFormat = CF_TEXT;
if (pDataObject->QueryGetData(&fmtetc) == S_OK)
{
if (pDataObject->GetData(&fmtetc, &stgmed) == S_OK)
{
if (pDataObject->QueryGetData(&fmtetc) == S_OK) {
if (pDataObject->GetData(&fmtetc, &stgmed) == S_OK) {
char *str = (char *)::GlobalLock(stgmed.hGlobal);
tmp_string = (char *)::malloc(::strlen(str) + 1);
if (!tmp_string)
{
if (!tmp_string) {
::GlobalUnlock(stgmed.hGlobal);
return NULL;
}
if (!::strcpy(tmp_string, str) )
{
if (!::strcpy(tmp_string, str) ) {
::free(tmp_string);
::GlobalUnlock(stgmed.hGlobal);
return NULL;
@@ -358,8 +344,7 @@ int GHOST_DropTargetWin32::WideCharToANSI(LPCWSTR in, char * &out)
NULL, NULL
);
if (!size)
{
if (!size) {
#ifdef GHOST_DEBUG
::printLastError();
#endif // GHOST_DEBUG
@@ -367,8 +352,7 @@ int GHOST_DropTargetWin32::WideCharToANSI(LPCWSTR in, char * &out)
}
out = (char *)::malloc(size);
if (!out)
{
if (!out) {
::printf("\nmalloc failed!!!");
return 0;
}
@@ -382,8 +366,7 @@ int GHOST_DropTargetWin32::WideCharToANSI(LPCWSTR in, char * &out)
NULL, NULL
);
if (!size)
{
if (!size) {
#ifdef GHOST_DEBUG
::printLastError();
#endif //GHOST_DEBUG
@@ -407,8 +390,7 @@ void printLastError(void)
0,
(LPTSTR)&s,
0,
NULL)
)
NULL))
{
printf("\nLastError: (%d) %s\n", (int)err, s);
LocalFree(s);

View File

@@ -201,23 +201,27 @@ GHOST_TUns8 GHOST_SystemWin32::getNumDisplays() const
}
void GHOST_SystemWin32::getMainDisplayDimensions(GHOST_TUns32& width, GHOST_TUns32& height) const
void GHOST_SystemWin32::getMainDisplayDimensions(GHOST_TUns32 &width, GHOST_TUns32 &height) const
{
width = ::GetSystemMetrics(SM_CXSCREEN);
height = ::GetSystemMetrics(SM_CYSCREEN);
}
void GHOST_SystemWin32::getAllDisplayDimensions(GHOST_TUns32& width, GHOST_TUns32& height) const
void GHOST_SystemWin32::getAllDisplayDimensions(GHOST_TUns32 &width, GHOST_TUns32 &height) const
{
width = ::GetSystemMetrics(SM_CXVIRTUALSCREEN);
height = ::GetSystemMetrics(SM_CYVIRTUALSCREEN);
}
GHOST_IWindow *GHOST_SystemWin32::createWindow(
const STR_String& title,
GHOST_TInt32 left, GHOST_TInt32 top, GHOST_TUns32 width, GHOST_TUns32 height,
GHOST_TWindowState state, GHOST_TDrawingContextType type,
bool stereoVisual, const bool exclusive, const GHOST_TUns16 numOfAASamples, const GHOST_TEmbedderWindowID parentWindow)
const STR_String &title,
GHOST_TInt32 left, GHOST_TInt32 top,
GHOST_TUns32 width, GHOST_TUns32 height,
GHOST_TWindowState state, GHOST_TDrawingContextType type,
bool stereoVisual,
const bool exclusive,
const GHOST_TUns16 numOfAASamples,
const GHOST_TEmbedderWindowID parentWindow)
{
GHOST_Window *window = 0;
window = new GHOST_WindowWin32(this, title, left, top, width, height, state, type, stereoVisual, numOfAASamples, parentWindow);
@@ -300,7 +304,7 @@ bool GHOST_SystemWin32::processEvents(bool waitForEvent)
}
GHOST_TSuccess GHOST_SystemWin32::getCursorPosition(GHOST_TInt32& x, GHOST_TInt32& y) const
GHOST_TSuccess GHOST_SystemWin32::getCursorPosition(GHOST_TInt32 &x, GHOST_TInt32 &y) const
{
POINT point;
if (::GetCursorPos(&point)) {
@@ -314,13 +318,13 @@ GHOST_TSuccess GHOST_SystemWin32::getCursorPosition(GHOST_TInt32& x, GHOST_TInt3
GHOST_TSuccess GHOST_SystemWin32::setCursorPosition(GHOST_TInt32 x, GHOST_TInt32 y)
{
if (!GetActiveWindow())
if (!::GetActiveWindow())
return GHOST_kFailure;
return ::SetCursorPos(x, y) == TRUE ? GHOST_kSuccess : GHOST_kFailure;
}
GHOST_TSuccess GHOST_SystemWin32::getModifierKeys(GHOST_ModifierKeys& keys) const
GHOST_TSuccess GHOST_SystemWin32::getModifierKeys(GHOST_ModifierKeys &keys) const
{
bool down = HIBYTE(::GetKeyState(VK_LSHIFT)) != 0;
keys.set(GHOST_kModifierKeyLeftShift, down);
@@ -347,7 +351,7 @@ GHOST_TSuccess GHOST_SystemWin32::getModifierKeys(GHOST_ModifierKeys& keys) cons
}
GHOST_TSuccess GHOST_SystemWin32::getButtons(GHOST_Buttons& buttons) const
GHOST_TSuccess GHOST_SystemWin32::getButtons(GHOST_Buttons &buttons) const
{
/* Check for swapped buttons (left-handed mouse buttons)
* GetAsyncKeyState() will give back the state of the physical mouse buttons.
@@ -423,7 +427,7 @@ GHOST_TSuccess GHOST_SystemWin32::exit()
return GHOST_System::exit();
}
GHOST_TKey GHOST_SystemWin32::hardKey(GHOST_IWindow *window, RAWINPUT const& raw, int *keyDown, char *vk)
GHOST_TKey GHOST_SystemWin32::hardKey(GHOST_IWindow *window, RAWINPUT const &raw, int *keyDown, char *vk)
{
GHOST_SystemWin32 *system = (GHOST_SystemWin32 *)getSystem();
GHOST_TKey key = GHOST_kKeyUnknown;
@@ -438,8 +442,7 @@ GHOST_TKey GHOST_SystemWin32::hardKey(GHOST_IWindow *window, RAWINPUT const& raw
key = this->convertKey(window, raw.data.keyboard.VKey, raw.data.keyboard.MakeCode, (raw.data.keyboard.Flags & (RI_KEY_E1 | RI_KEY_E0)));
// extra handling of modifier keys: don't send repeats out from GHOST
if (key >= GHOST_kKeyLeftShift && key <= GHOST_kKeyRightAlt)
{
if (key >= GHOST_kKeyLeftShift && key <= GHOST_kKeyRightAlt) {
bool changed = false;
GHOST_TModifierKeyMask modifier;
switch (key) {
@@ -447,43 +450,43 @@ GHOST_TKey GHOST_SystemWin32::hardKey(GHOST_IWindow *window, RAWINPUT const& raw
{
changed = (modifiers.get(GHOST_kModifierKeyLeftShift) != (bool)*keyDown);
modifier = GHOST_kModifierKeyLeftShift;
break;
}
break;
case GHOST_kKeyRightShift:
{
changed = (modifiers.get(GHOST_kModifierKeyRightShift) != (bool)*keyDown);
modifier = GHOST_kModifierKeyRightShift;
break;
}
break;
case GHOST_kKeyLeftControl:
{
changed = (modifiers.get(GHOST_kModifierKeyLeftControl) != (bool)*keyDown);
modifier = GHOST_kModifierKeyLeftControl;
break;
}
break;
case GHOST_kKeyRightControl:
{
changed = (modifiers.get(GHOST_kModifierKeyRightControl) != (bool)*keyDown);
modifier = GHOST_kModifierKeyRightControl;
break;
}
break;
case GHOST_kKeyLeftAlt:
{
changed = (modifiers.get(GHOST_kModifierKeyLeftAlt) != (bool)*keyDown);
modifier = GHOST_kModifierKeyLeftAlt;
break;
}
break;
case GHOST_kKeyRightAlt:
{
changed = (modifiers.get(GHOST_kModifierKeyRightAlt) != (bool)*keyDown);
modifier = GHOST_kModifierKeyRightAlt;
break;
}
break;
default: break;
default:
break;
}
if (changed)
{
if (changed) {
modifiers.set(modifier, (bool)*keyDown);
system->storeModifierKeys(modifiers);
}
@@ -635,7 +638,10 @@ GHOST_TKey GHOST_SystemWin32::convertKey(GHOST_IWindow *window, short vKey, shor
return key;
}
GHOST_EventButton *GHOST_SystemWin32::processButtonEvent(GHOST_TEventType type, GHOST_IWindow *window, GHOST_TButtonMask mask)
GHOST_EventButton *GHOST_SystemWin32::processButtonEvent(
GHOST_TEventType type,
GHOST_IWindow *window,
GHOST_TButtonMask mask)
{
return new GHOST_EventButton(getSystem()->getMilliSeconds(), type, window, mask);
}
@@ -712,7 +718,7 @@ GHOST_EventWheel *GHOST_SystemWin32::processWheelEvent(GHOST_IWindow *window, WP
}
GHOST_EventKey *GHOST_SystemWin32::processKeyEvent(GHOST_IWindow *window, RAWINPUT const& raw)
GHOST_EventKey *GHOST_SystemWin32::processKeyEvent(GHOST_IWindow *window, RAWINPUT const &raw)
{
int keyDown = 0;
char vk;
@@ -730,7 +736,7 @@ GHOST_EventKey *GHOST_SystemWin32::processKeyEvent(GHOST_IWindow *window, RAWINP
GetKeyboardState((PBYTE)state);
// don't call ToUnicodeEx on dead keys as it clears the buffer and so won't allow diacritical composition.
if (MapVirtualKeyW(vk,2) != 0) {
if (MapVirtualKeyW(vk, 2) != 0) {
// todo: ToUnicodeEx can respond with up to 4 utf16 chars (only 2 here). Could be up to 24 utf8 bytes.
if ((r = ToUnicodeEx(vk, raw.data.keyboard.MakeCode, state, utf16, 2, 0, system->m_keylayout))) {
if ((r > 0 && r < 3)) {
@@ -770,17 +776,18 @@ GHOST_Event *GHOST_SystemWin32::processWindowEvent(GHOST_TEventType type, GHOST_
if (type == GHOST_kEventWindowActivate) {
system->getWindowManager()->setActiveWindow(window);
((GHOST_WindowWin32*)window)->bringTabletContextToFront();
((GHOST_WindowWin32 *)window)->bringTabletContextToFront();
}
return new GHOST_Event(system->getMilliSeconds(), type, window);
}
GHOST_TSuccess GHOST_SystemWin32::pushDragDropEvent(GHOST_TEventType eventType,
GHOST_TDragnDropTypes draggedObjectType,
GHOST_IWindow *window,
int mouseX, int mouseY,
void *data)
GHOST_TSuccess GHOST_SystemWin32::pushDragDropEvent(
GHOST_TEventType eventType,
GHOST_TDragnDropTypes draggedObjectType,
GHOST_IWindow *window,
int mouseX, int mouseY,
void *data)
{
GHOST_SystemWin32 *system = ((GHOST_SystemWin32 *)getSystem());
return system->pushEvent(new GHOST_EventDragnDrop(system->getMilliSeconds(),
@@ -797,7 +804,7 @@ void GHOST_SystemWin32::processMinMaxInfo(MINMAXINFO *minmax)
}
#ifdef WITH_INPUT_NDOF
bool GHOST_SystemWin32::processNDOF(RAWINPUT const& raw)
bool GHOST_SystemWin32::processNDOF(RAWINPUT const &raw)
{
bool eventSent = false;
GHOST_TUns64 now = getMilliSeconds();
@@ -843,8 +850,7 @@ bool GHOST_SystemWin32::processNDOF(RAWINPUT const& raw)
#endif
BYTE packetType = data[0];
switch (packetType)
{
switch (packetType) {
case 1: // translation
{
const short *axis = (short *)(data + 1);
@@ -852,8 +858,8 @@ bool GHOST_SystemWin32::processNDOF(RAWINPUT const& raw)
const short t[3] = {axis[0], -axis[2], axis[1]};
m_ndofManager->updateTranslation(t, now);
if (raw.data.hid.dwSizeHid == 13)
{ // this report also includes rotation
if (raw.data.hid.dwSizeHid == 13) {
// this report also includes rotation
const short r[3] = {-axis[3], axis[5], -axis[4]};
m_ndofManager->updateRotation(r, now);
@@ -915,8 +921,7 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
GetRawInputData((HRAWINPUT)lParam, RID_INPUT, raw_ptr, &rawSize, sizeof(RAWINPUTHEADER));
switch (raw.header.dwType)
{
switch (raw.header.dwType) {
case RIM_TYPEKEYBOARD:
event = processKeyEvent(window, raw);
if (!event) {
@@ -976,8 +981,7 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
* maximize, minimize or close the window are triggered. Also it is sent when ALT
* button is press for menu. To prevent this we must return preventing DefWindowProc.
*/
if (wParam == SC_KEYMENU)
{
if (wParam == SC_KEYMENU) {
eventHandled = true;
}
break;
@@ -1105,7 +1109,7 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
event = processWindowEvent(LOWORD(wParam) ? GHOST_kEventWindowActivate : GHOST_kEventWindowDeactivate, window);
/* WARNING: Let DefWindowProc handle WM_ACTIVATE, otherwise WM_MOUSEWHEEL
* will not be dispatched to OUR active window if we minimize one of OUR windows. */
if (LOWORD(wParam)==WA_INACTIVE)
if (LOWORD(wParam) == WA_INACTIVE)
window->lostMouseCapture();
lResult = ::DefWindowProc(hwnd, msg, wParam, lParam);
@@ -1228,8 +1232,8 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
case WM_KILLFOCUS:
/* The WM_KILLFOCUS message is sent to a window immediately before it loses the keyboard focus.
* We want to prevent this if a window is still active and it loses focus to nowhere*/
if (!wParam && hwnd == GetActiveWindow())
SetFocus(hwnd);
if (!wParam && hwnd == ::GetActiveWindow())
::SetFocus(hwnd);
case WM_SHOWWINDOW:
/* The WM_SHOWWINDOW message is sent to a window when the window is about to be hidden or shown. */
case WM_WINDOWPOSCHANGING:
@@ -1419,8 +1423,7 @@ int GHOST_SystemWin32::toggleConsole(int action)
ShowWindow(GetConsoleWindow(), m_consoleStatus ? SW_HIDE : SW_SHOW);
m_consoleStatus = !m_consoleStatus;
break;
};
}
return m_consoleStatus;

View File

@@ -21,8 +21,11 @@
// GHOST_WindowWin32
#ifndef __ITaskbarList_INTERFACE_DEFINED__
#define __ITaskbarList_INTERFACE_DEFINED__
extern "C" {const GUID CLSID_TaskbarList = {0x56FDF344, 0xFD6D, 0x11D0, {0x95, 0x8A, 0x00, 0x60, 0x97, 0xC9, 0xA0, 0x90} };
const GUID IID_ITaskbarList = {0x56FDF342, 0xFD6D, 0x11D0, {0x95, 0x8A, 0x00, 0x60, 0x97, 0xC9, 0xA0, 0x90} }; }
extern "C" {
const GUID CLSID_TaskbarList = {0x56FDF344, 0xFD6D, 0x11D0, {0x95, 0x8A, 0x00, 0x60, 0x97, 0xC9, 0xA0, 0x90}};
const GUID IID_ITaskbarList = {0x56FDF342, 0xFD6D, 0x11D0, {0x95, 0x8A, 0x00, 0x60, 0x97, 0xC9, 0xA0, 0x90}};
}
class ITaskbarList : public IUnknown
{
public:
@@ -36,7 +39,9 @@ public:
#ifndef __ITaskbarList2_INTERFACE_DEFINED__
#define __ITaskbarList2_INTERFACE_DEFINED__
extern "C" {const GUID IID_ITaskbarList2 = {0x602D4995, 0xB13A, 0x429b, {0xA6, 0x6E, 0x19, 0x35, 0xE4, 0x4F, 0x43, 0x17} }; }
extern "C" {
const GUID IID_ITaskbarList2 = {0x602D4995, 0xB13A, 0x429b, {0xA6, 0x6E, 0x19, 0x35, 0xE4, 0x4F, 0x43, 0x17}};
}
class ITaskbarList2 : public ITaskbarList
{
public:
@@ -46,12 +51,46 @@ public:
#ifndef __ITaskbarList3_INTERFACE_DEFINED__
#define __ITaskbarList3_INTERFACE_DEFINED__
typedef enum THUMBBUTTONFLAGS {THBF_ENABLED = 0, THBF_DISABLED = 0x1, THBF_DISMISSONCLICK = 0x2, THBF_NOBACKGROUND = 0x4, THBF_HIDDEN = 0x8, THBF_NONINTERACTIVE = 0x10} THUMBBUTTONFLAGS;
typedef enum THUMBBUTTONMASK {THB_BITMAP = 0x1, THB_ICON = 0x2, THB_TOOLTIP = 0x4, THB_FLAGS = 0x8} THUMBBUTTONMASK;
typedef struct THUMBBUTTON {THUMBBUTTONMASK dwMask; UINT iId; UINT iBitmap; HICON hIcon; WCHAR szTip[260]; THUMBBUTTONFLAGS dwFlags; } THUMBBUTTON;
typedef enum TBPFLAG {TBPF_NOPROGRESS = 0, TBPF_INDETERMINATE = 0x1, TBPF_NORMAL = 0x2, TBPF_ERROR = 0x4, TBPF_PAUSED = 0x8 } TBPFLAG;
typedef enum THUMBBUTTONFLAGS {
THBF_ENABLED = 0,
THBF_DISABLED = 0x1,
THBF_DISMISSONCLICK = 0x2,
THBF_NOBACKGROUND = 0x4,
THBF_HIDDEN = 0x8,
THBF_NONINTERACTIVE = 0x10,
}
THUMBBUTTONFLAGS;
typedef enum THUMBBUTTONMASK {
THB_BITMAP = 0x1,
THB_ICON = 0x2,
THB_TOOLTIP = 0x4,
THB_FLAGS = 0x8,
}
THUMBBUTTONMASK;
typedef struct THUMBBUTTON {
THUMBBUTTONMASK dwMask;
UINT iId;
UINT iBitmap;
HICON hIcon;
WCHAR szTip[260];
THUMBBUTTONFLAGS dwFlags;
} THUMBBUTTON;
typedef enum TBPFLAG {
TBPF_NOPROGRESS = 0,
TBPF_INDETERMINATE = 0x1,
TBPF_NORMAL = 0x2,
TBPF_ERROR = 0x4,
TBPF_PAUSED = 0x8,
} TBPFLAG;
#define THBN_CLICKED 0x1800
extern "C" {const GUID IID_ITaskList3 = { 0xEA1AFB91, 0x9E28, 0x4B86, {0x90, 0xE9, 0x9E, 0x9F, 0x8A, 0x5E, 0xEF, 0xAF} }; }
extern "C" {
const GUID IID_ITaskList3 = {0xEA1AFB91, 0x9E28, 0x4B86, {0x90, 0xE9, 0x9E, 0x9F, 0x8A, 0x5E, 0xEF, 0xAF}};
}
class ITaskbarList3 : public ITaskbarList2
{

View File

@@ -55,7 +55,7 @@ const int GHOST_WindowWin32::s_maxTitleLength = 128;
HGLRC GHOST_WindowWin32::s_firsthGLRc = NULL;
HDC GHOST_WindowWin32::s_firstHDC = NULL;
static int WeightPixelFormat(PIXELFORMATDESCRIPTOR& pfd);
static int WeightPixelFormat(PIXELFORMATDESCRIPTOR &pfd);
static int EnumPixelFormats(HDC hdc);
/*
@@ -112,47 +112,46 @@ extern "C" {
}
GHOST_WindowWin32::GHOST_WindowWin32(
GHOST_SystemWin32 *system,
const STR_String& title,
GHOST_TInt32 left,
GHOST_TInt32 top,
GHOST_TUns32 width,
GHOST_TUns32 height,
GHOST_TWindowState state,
GHOST_TDrawingContextType type,
const bool stereoVisual,
const GHOST_TUns16 numOfAASamples,
GHOST_TEmbedderWindowID parentwindowhwnd,
GHOST_TSuccess msEnabled,
int msPixelFormat)
:
GHOST_Window(width, height, state, GHOST_kDrawingContextTypeNone,
stereoVisual, false, numOfAASamples),
m_inLiveResize(false),
m_system(system),
m_hDC(0),
m_hGlRc(0),
m_hasMouseCaptured(false),
m_hasGrabMouse(false),
m_nPressedButtons(0),
m_customCursor(0),
m_wintab(NULL),
m_tabletData(NULL),
m_tablet(0),
m_maxPressure(0),
m_multisample(numOfAASamples),
m_multisampleEnabled(msEnabled),
m_msPixelFormat(msPixelFormat),
//For recreation
m_title(title),
m_left(left),
m_top(top),
m_width(width),
m_height(height),
m_normal_state(GHOST_kWindowStateNormal),
m_stereo(stereoVisual),
m_nextWindow(NULL),
m_parentWindowHwnd(parentwindowhwnd)
GHOST_SystemWin32 *system,
const STR_String &title,
GHOST_TInt32 left,
GHOST_TInt32 top,
GHOST_TUns32 width,
GHOST_TUns32 height,
GHOST_TWindowState state,
GHOST_TDrawingContextType type,
const bool stereoVisual,
const GHOST_TUns16 numOfAASamples,
GHOST_TEmbedderWindowID parentwindowhwnd,
GHOST_TSuccess msEnabled,
int msPixelFormat)
: GHOST_Window(width, height, state, GHOST_kDrawingContextTypeNone,
stereoVisual, false, numOfAASamples),
m_inLiveResize(false),
m_system(system),
m_hDC(0),
m_hGlRc(0),
m_hasMouseCaptured(false),
m_hasGrabMouse(false),
m_nPressedButtons(0),
m_customCursor(0),
m_wintab(NULL),
m_tabletData(NULL),
m_tablet(0),
m_maxPressure(0),
m_multisample(numOfAASamples),
m_multisampleEnabled(msEnabled),
m_msPixelFormat(msPixelFormat),
//For recreation
m_title(title),
m_left(left),
m_top(top),
m_width(width),
m_height(height),
m_normal_state(GHOST_kWindowStateNormal),
m_stereo(stereoVisual),
m_nextWindow(NULL),
m_parentWindowHwnd(parentwindowhwnd)
{
OSVERSIONINFOEX versionInfo;
bool hasMinVersionForTaskbar = false;
@@ -164,13 +163,17 @@ GHOST_WindowWin32::GHOST_WindowWin32(
if (!GetVersionEx((OSVERSIONINFO *)&versionInfo)) {
versionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
if (GetVersionEx((OSVERSIONINFO *)&versionInfo)) {
if ((versionInfo.dwMajorVersion == 6 && versionInfo.dwMinorVersion >= 1) || versionInfo.dwMajorVersion >= 7) {
if ((versionInfo.dwMajorVersion == 6 && versionInfo.dwMinorVersion >= 1) ||
(versionInfo.dwMajorVersion >= 7))
{
hasMinVersionForTaskbar = true;
}
}
}
else {
if ((versionInfo.dwMajorVersion == 6 && versionInfo.dwMinorVersion >= 1) || versionInfo.dwMajorVersion >= 7) {
if ((versionInfo.dwMajorVersion == 6 && versionInfo.dwMinorVersion >= 1) ||
(versionInfo.dwMajorVersion >= 7))
{
hasMinVersionForTaskbar = true;
}
}
@@ -210,8 +213,7 @@ GHOST_WindowWin32::GHOST_WindowWin32(
th = monitor.rcWork.bottom - monitor.rcWork.top;
tw = monitor.rcWork.right - monitor.rcWork.left;
if (tw < width)
{
if (tw < width) {
width = tw;
left = monitor.rcWork.left;
}
@@ -220,8 +222,7 @@ GHOST_WindowWin32::GHOST_WindowWin32(
else if (left < monitor.rcWork.left)
left = monitor.rcWork.left;
if (th < height)
{
if (th < height) {
height = th;
top = monitor.rcWork.top;
}
@@ -231,8 +232,7 @@ GHOST_WindowWin32::GHOST_WindowWin32(
top = monitor.rcWork.top;
int wintype = WS_OVERLAPPEDWINDOW;
if (m_parentWindowHwnd != 0)
{
if (m_parentWindowHwnd != 0) {
wintype = WS_CHILD;
GetWindowRect((HWND)m_parentWindowHwnd, &rect);
left = 0;
@@ -307,8 +307,7 @@ GHOST_WindowWin32::GHOST_WindowWin32(
GHOST_TSuccess success;
success = setDrawingContextType(type);
if (success)
{
if (success) {
::ShowWindow(m_hWnd, nCmdShow);
// Force an initial paint of the window
::UpdateWindow(m_hWnd);
@@ -338,7 +337,8 @@ GHOST_WindowWin32::GHOST_WindowWin32(
if (fpWTInfo && fpWTInfo(0, 0, NULL)) {
// Now init the tablet
LOGCONTEXT lc;
AXIS TabletX, TabletY, Pressure, Orientation[3]; /* The maximum tablet size, pressure and orientation (tilt) */
/* The maximum tablet size, pressure and orientation (tilt) */
AXIS TabletX, TabletY, Pressure, Orientation[3];
// Open a Wintab context
@@ -394,11 +394,10 @@ GHOST_WindowWin32::GHOST_WindowWin32(
GHOST_WindowWin32::~GHOST_WindowWin32()
{
if (m_Bar)
{
if (m_Bar) {
m_Bar->SetProgressState(m_hWnd, TBPF_NOPROGRESS);
m_Bar->Release();
};
}
if (m_wintab) {
GHOST_WIN32_WTClose fpWTClose = (GHOST_WIN32_WTClose) ::GetProcAddress(m_wintab, "WTClose");
@@ -410,6 +409,7 @@ GHOST_WindowWin32::~GHOST_WindowWin32()
m_tabletData = NULL;
}
}
if (m_customCursor) {
DestroyCursor(m_customCursor);
m_customCursor = NULL;
@@ -419,10 +419,12 @@ GHOST_WindowWin32::~GHOST_WindowWin32()
m_multisampleEnabled = GHOST_kFailure;
m_multisample = 0;
setDrawingContextType(GHOST_kDrawingContextTypeNone);
if (m_hDC && m_hDC != s_firstHDC) {
::ReleaseDC(m_hWnd, m_hDC);
m_hDC = 0;
}
if (m_hWnd) {
if (m_dropTarget) {
// Disable DragDrop
@@ -451,7 +453,7 @@ HWND GHOST_WindowWin32::getHWND() const
return m_hWnd;
}
void GHOST_WindowWin32::setTitle(const STR_String& title)
void GHOST_WindowWin32::setTitle(const STR_String &title)
{
wchar_t *title_16 = alloc_utf16_from_8((char *)(const char *)title, 0);
::SetWindowTextW(m_hWnd, (wchar_t *)title_16);
@@ -459,7 +461,7 @@ void GHOST_WindowWin32::setTitle(const STR_String& title)
}
void GHOST_WindowWin32::getTitle(STR_String& title) const
void GHOST_WindowWin32::getTitle(STR_String &title) const
{
char buf[s_maxTitleLength]; /*CHANGE + never used yet*/
::GetWindowText(m_hWnd, buf, s_maxTitleLength);
@@ -468,7 +470,7 @@ void GHOST_WindowWin32::getTitle(STR_String& title) const
}
void GHOST_WindowWin32::getWindowBounds(GHOST_Rect& bounds) const
void GHOST_WindowWin32::getWindowBounds(GHOST_Rect &bounds) const
{
RECT rect;
::GetWindowRect(m_hWnd, &rect);
@@ -479,7 +481,7 @@ void GHOST_WindowWin32::getWindowBounds(GHOST_Rect& bounds) const
}
void GHOST_WindowWin32::getClientBounds(GHOST_Rect& bounds) const
void GHOST_WindowWin32::getClientBounds(GHOST_Rect &bounds) const
{
RECT rect;
POINT coord;
@@ -570,6 +572,7 @@ GHOST_TWindowState GHOST_WindowWin32::getState() const
state = GHOST_kWindowStateEmbedded;
return state;
}
if (::IsIconic(m_hWnd)) {
state = GHOST_kWindowStateMinimized;
}
@@ -587,18 +590,22 @@ GHOST_TWindowState GHOST_WindowWin32::getState() const
}
void GHOST_WindowWin32::screenToClient(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const
void GHOST_WindowWin32::screenToClient(
GHOST_TInt32 inX, GHOST_TInt32 inY,
GHOST_TInt32 &outX, GHOST_TInt32 &outY) const
{
POINT point = { inX, inY };
POINT point = {inX, inY};
::ScreenToClient(m_hWnd, &point);
outX = point.x;
outY = point.y;
}
void GHOST_WindowWin32::clientToScreen(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const
void GHOST_WindowWin32::clientToScreen(
GHOST_TInt32 inX, GHOST_TInt32 inY,
GHOST_TInt32 &outX, GHOST_TInt32 &outY) const
{
POINT point = { inX, inY };
POINT point = {inX, inY};
::ClientToScreen(m_hWnd, &point);
outX = point.x;
outY = point.y;
@@ -614,13 +621,14 @@ GHOST_TSuccess GHOST_WindowWin32::setState(GHOST_TWindowState state)
if (state == GHOST_kWindowStateNormal)
state = m_normal_state;
switch (state) {
case GHOST_kWindowStateMinimized:
wp.showCmd = SW_SHOWMINIMIZED;
break;
case GHOST_kWindowStateMaximized:
wp.showCmd = SW_SHOWMAXIMIZED;
SetWindowLongPtr(m_hWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW);
::SetWindowLongPtr(m_hWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW);
break;
case GHOST_kWindowStateFullScreen:
if (curstate != state && curstate != GHOST_kWindowStateMinimized)
@@ -628,18 +636,20 @@ GHOST_TSuccess GHOST_WindowWin32::setState(GHOST_TWindowState state)
wp.showCmd = SW_SHOWMAXIMIZED;
wp.ptMaxPosition.x = 0;
wp.ptMaxPosition.y = 0;
SetWindowLongPtr(m_hWnd, GWL_STYLE, WS_POPUP | WS_MAXIMIZE);
::SetWindowLongPtr(m_hWnd, GWL_STYLE, WS_POPUP | WS_MAXIMIZE);
break;
case GHOST_kWindowStateEmbedded:
SetWindowLongPtr(m_hWnd, GWL_STYLE, WS_CHILD);
::SetWindowLongPtr(m_hWnd, GWL_STYLE, WS_CHILD);
break;
case GHOST_kWindowStateNormal:
default:
wp.showCmd = SW_SHOWNORMAL;
SetWindowLongPtr(m_hWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW);
::SetWindowLongPtr(m_hWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW);
break;
}
SetWindowPos(m_hWnd, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); /*Clears window cache for SetWindowLongPtr */
/* Clears window cache for SetWindowLongPtr */
::SetWindowPos(m_hWnd, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
return ::SetWindowPlacement(m_hWnd, &wp) == TRUE ? GHOST_kSuccess : GHOST_kFailure;
}
@@ -656,9 +666,11 @@ GHOST_TSuccess GHOST_WindowWin32::setOrder(GHOST_TWindowOrder order)
hWndInsertAfter = HWND_TOP;
hWndToRaise = NULL;
}
if (::SetWindowPos(m_hWnd, hWndInsertAfter, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE) == FALSE) {
return GHOST_kFailure;
}
if (hWndToRaise && ::SetWindowPos(hWndToRaise, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE) == FALSE) {
return GHOST_kFailure;
}
@@ -750,8 +762,7 @@ GHOST_TSuccess GHOST_WindowWin32::initMultisample(PIXELFORMATDESCRIPTOR pfd)
// Get the function
PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB");
if (!wglChoosePixelFormatARB)
{
if (!wglChoosePixelFormatARB) {
m_multisampleEnabled = GHOST_kFailure;
return GHOST_kFailure;
}
@@ -977,30 +988,28 @@ GHOST_TSuccess GHOST_WindowWin32::removeDrawingContext()
void GHOST_WindowWin32::lostMouseCapture()
{
if (m_hasMouseCaptured)
{ m_hasGrabMouse = false;
if (m_hasMouseCaptured) {
m_hasGrabMouse = false;
m_nPressedButtons = 0;
m_hasMouseCaptured = false; };
m_hasMouseCaptured = false;
}
}
void GHOST_WindowWin32::registerMouseClickEvent(int press)
{
switch (press)
{
switch (press) {
case 0: m_nPressedButtons++; break;
case 1: if (m_nPressedButtons) m_nPressedButtons--; break;
case 2: m_hasGrabMouse = true; break;
case 3: m_hasGrabMouse = false; break;
}
if (!m_nPressedButtons && !m_hasGrabMouse && m_hasMouseCaptured)
{
if (!m_nPressedButtons && !m_hasGrabMouse && m_hasMouseCaptured) {
::ReleaseCapture();
m_hasMouseCaptured = false;
}
else if ((m_nPressedButtons || m_hasGrabMouse) && !m_hasMouseCaptured)
{
else if ((m_nPressedButtons || m_hasGrabMouse) && !m_hasMouseCaptured) {
::SetCapture(m_hWnd);
m_hasMouseCaptured = true;
@@ -1252,17 +1261,19 @@ static GHOST_TUns16 uns16ReverseBits(GHOST_TUns16 shrt)
return shrt;
}
#endif
GHOST_TSuccess GHOST_WindowWin32::setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2],
GHOST_TUns8 mask[16][2],
int hotX, int hotY)
GHOST_TSuccess GHOST_WindowWin32::setWindowCustomCursorShape(
GHOST_TUns8 bitmap[16][2],
GHOST_TUns8 mask[16][2],
int hotX, int hotY)
{
return setWindowCustomCursorShape((GHOST_TUns8 *)bitmap, (GHOST_TUns8 *)mask,
16, 16, hotX, hotY, 0, 1);
}
GHOST_TSuccess GHOST_WindowWin32::setWindowCustomCursorShape(GHOST_TUns8 *bitmap,
GHOST_TUns8 *mask, int sizeX, int sizeY, int hotX, int hotY,
int fg_color, int bg_color)
GHOST_TSuccess GHOST_WindowWin32::setWindowCustomCursorShape(
GHOST_TUns8 *bitmap,
GHOST_TUns8 *mask, int sizeX, int sizeY, int hotX, int hotY,
int fg_color, int bg_color)
{
GHOST_TUns32 andData[32];
GHOST_TUns32 xorData[32];
@@ -1326,7 +1337,7 @@ GHOST_TSuccess GHOST_WindowWin32::endProgressBar()
/* Ron Fosner's code for weighting pixel formats and forcing software.
* See http://www.opengl.org/resources/faq/technical/weight.cpp */
static int WeightPixelFormat(PIXELFORMATDESCRIPTOR& pfd)
static int WeightPixelFormat(PIXELFORMATDESCRIPTOR &pfd)
{
int weight = 0;
@@ -1413,5 +1424,3 @@ static int EnumPixelFormats(HDC hdc)
}
return iPixelFormat;
}