diff options
Diffstat (limited to 'intern/ghost')
37 files changed, 591 insertions, 254 deletions
diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h index b678d52c481..0f4fd47d306 100644 --- a/intern/ghost/GHOST_C-api.h +++ b/intern/ghost/GHOST_C-api.h @@ -151,7 +151,7 @@ extern void GHOST_GetMainDisplayDimensions(GHOST_SystemHandle systemhandle, /** * Returns the dimensions of all displays combine * (the current workspace). - * No need to worrky about overlapping monitors. + * No need to worry about overlapping monitors. * \param systemhandle The handle to the system * \param width A pointer the width gets put in * \param height A pointer the height gets put in @@ -401,7 +401,7 @@ extern GHOST_TSuccess GHOST_SetCursorPosition(GHOST_SystemHandle systemhandle, * do this automatically. * \param windowhandle The handle to the window * \param mode The new grab state of the cursor. - * \param bounds The grab ragion (optional) - left,top,right,bottom + * \param bounds The grab region (optional) - left,top,right,bottom * \param mouse_ungrab_xy XY for new mouse location (optional) - x,y * \return Indication of success. */ @@ -758,7 +758,7 @@ extern GHOST_TSuccess GHOST_IsEmptyRectangle(GHOST_RectangleHandle rectanglehand /** * Returns whether this rectangle is valid. - * Valid rectangles are rectangles that have m_l <= m_r and m_t <= m_b. Thus, emapty rectangles are valid. + * Valid rectangles are rectangles that have m_l <= m_r and m_t <= m_b. Thus, empty rectangles are valid. * \param rectanglehandle The handle to the rectangle * \return intean value (true == valid rectangle) */ @@ -852,7 +852,7 @@ extern GHOST_TSuccess GHOST_ClipRectangle(GHOST_RectangleHandle rectanglehandle, GHOST_RectangleHandle anotherrectanglehandle); /** - * Return the data from the clipboad + * Return the data from the clipboard * \param selection Boolean to return the selection instead, X11 only feature. * \return clipboard data */ diff --git a/intern/ghost/GHOST_ISystem.h b/intern/ghost/GHOST_ISystem.h index 137926b033c..19f36319949 100644 --- a/intern/ghost/GHOST_ISystem.h +++ b/intern/ghost/GHOST_ISystem.h @@ -48,7 +48,7 @@ class GHOST_IEventConsumer; * * GHOST is yet another acronym. It stands for "Generic Handy Operating System * Toolkit". It has been created to replace the OpenGL utility tool kit - * <a href="http://www.opengl.org/developers/documentation/glut.html">GLUT</a>. + * <a href="http://www.opengl.org/resources/libraries/glut/">GLUT</a>. * GLUT was used in <a href="http://www.blender3d.com">Blender</a> until the * point that Blender needed to be ported to Apple's Mac OSX. Blender needed a * number of modifications in GLUT to work but the GLUT sources for OSX were @@ -60,31 +60,29 @@ class GHOST_IEventConsumer; * In short: everything that Blender needed from GLUT to run on all it's supported * operating systems and some extra's. * This includes : - * <ul> - * <li> Time(r) management.</li> - * <li> Display/window management (windows are only created on the main display). - * <li> Event management.</li> - * <li> Cursor shape management (no custom cursors for now).</li> - * <li> Access to the state of the mouse buttons and the keyboard.</li> - * <li> Menus for windows with events generated when they are accessed (this is - * work in progress).</li> - * <li> Video mode switching.</li> - * <li> Copy/Paste buffers.</li> - * <li> System paths.</li> - * </ul> + * + * - Time(r) management. + * - Display/window management (windows are only created on the main display). + * - Event management. + * - Cursor shape management (no custom cursors for now). + * - Access to the state of the mouse buttons and the keyboard. + * - Menus for windows with events generated when they are accessed (this is + * work in progress). + * - Video mode switching. + * - Copy/Paste buffers. + * - System paths. + * * Font management has been moved to a separate library. * * \section platforms Platforms * * GHOST supports the following platforms: - * <ul> - * <li> OSX Cocoa.</li> - * <li> OSX Carbon.</li> - * <li> Windows.</li> - * <li> X11.</li> - * <li> SDL1.3 (experimental).</li> - * <li> NULL (headless mode).</li> - * </ul> + * + * - OSX Cocoa. + * - Windows. + * - X11. + * - SDL2 (experimental). + * - NULL (headless mode). * * \section Building GHOST * @@ -92,23 +90,23 @@ class GHOST_IEventConsumer; * * \section interface Interface * GHOST has two programming interfaces: - * <ul> - * <li>The C-API. For programs written in C.</li> - * <li>The C++-API. For programs written in C++.</li> - * </ul> - * GHOST itself is writtem in C++ and the C-API is a wrapper around the C++ + * + * - The C-API. For programs written in C. + * - The C++-API. For programs written in C++. + * + * GHOST itself is written in C++ and the C-API is a wrapper around the C++ * API. * * \subsection cplusplus_api The C++ API consists of the following files: - * <ul> - * <li>GHOST_IEvent.h</li> - * <li>GHOST_IEventConsumer.h</li> - * <li>GHOST_ISystem.h</li> - * <li>GHOST_ITimerTask.h</li> - * <li>GHOST_IWindow.h</li> - * <li>GHOST_Rect.h</li> - * <li>GHOST_Types.h</li> - * </ul> + * + * - GHOST_IEvent.h + * - GHOST_IEventConsumer.h + * - GHOST_ISystem.h + * - GHOST_ITimerTask.h + * - GHOST_IWindow.h + * - GHOST_Rect.h + * - GHOST_Types.h + * * For an example of using the C++-API, have a look at the GHOST_C-Test.cpp * program in the ?/ghost/test/gears/ directory. * diff --git a/intern/ghost/GHOST_IWindow.h b/intern/ghost/GHOST_IWindow.h index ba3797a77e7..5fde53e397b 100644 --- a/intern/ghost/GHOST_IWindow.h +++ b/intern/ghost/GHOST_IWindow.h @@ -46,13 +46,12 @@ * \see GHOST_ISystem#createWindow * * There are two coordinate systems: - * <ul> - * <li>The screen coordinate system. The origin of the screen is located in the - * upper left corner of the screen.</li> - * <li>The client rectangle coordinate system. The client rectangle of a window - * is the area that is drawable by the application (excluding title bars etc.). - * </li> - * </ul> + * + * - The screen coordinate system. The origin of the screen is located in the + * upper left corner of the screen.</li> + * - The client rectangle coordinate system. The client rectangle of a window + * is the area that is drawable by the application (excluding title bars etc.). + * * \author Maarten Gribnau * \date May 31, 2001 */ diff --git a/intern/ghost/GHOST_Rect.h b/intern/ghost/GHOST_Rect.h index a055b6f7f0d..c2ea8db0a66 100644 --- a/intern/ghost/GHOST_Rect.h +++ b/intern/ghost/GHOST_Rect.h @@ -102,7 +102,7 @@ public: /** * Returns whether this rectangle is valid. - * Valid rectangles are rectangles that have m_l <= m_r and m_t <= m_b. Thus, emapty rectangles are valid. + * Valid rectangles are rectangles that have m_l <= m_r and m_t <= m_b. Thus, empty rectangles are valid. * \return boolean value (true==valid rectangle) */ virtual inline bool isValid() const; diff --git a/intern/ghost/intern/GHOST_Context.cpp b/intern/ghost/intern/GHOST_Context.cpp index 211c712cde2..c3483d7d7c9 100644 --- a/intern/ghost/intern/GHOST_Context.cpp +++ b/intern/ghost/intern/GHOST_Context.cpp @@ -37,7 +37,7 @@ -const char* get_glew_error_message_string(GLenum error) +static const char* get_glew_error_message_string(GLenum error) { switch (error) { case GLEW_OK: /* also GLEW_NO_ERROR */ @@ -52,7 +52,7 @@ const char* get_glew_error_message_string(GLenum error) case GLEW_ERROR_GLX_VERSION_11_ONLY: return "GLX 1.2 or later is required."; -#if WITH_GLEW_ES +#ifdef WITH_GLEW_ES case GLEW_ERROR_NOT_GLES_VERSION: return "OpenGL ES is required."; @@ -73,7 +73,7 @@ const char* get_glew_error_message_string(GLenum error) -const char* get_glew_error_enum_string(GLenum error) +static const char* get_glew_error_enum_string(GLenum error) { switch (error) { case GLEW_OK: /* also GLEW_NO_ERROR */ @@ -88,7 +88,7 @@ const char* get_glew_error_enum_string(GLenum error) case GLEW_ERROR_GLX_VERSION_11_ONLY: return "GLEW_ERROR_GLX_VERSION_11_ONLY"; -#if WITH_GLEW_ES +#ifdef WITH_GLEW_ES case GLEW_ERROR_NOT_GLES_VERSION: return "GLEW_ERROR_NOT_GLES_VERSION"; diff --git a/intern/ghost/intern/GHOST_DisplayManager.cpp b/intern/ghost/intern/GHOST_DisplayManager.cpp index 7ca4c8182b9..9f0b32148f6 100644 --- a/intern/ghost/intern/GHOST_DisplayManager.cpp +++ b/intern/ghost/intern/GHOST_DisplayManager.cpp @@ -40,9 +40,8 @@ #include "GHOST_Debug.h" -GHOST_DisplayManager::GHOST_DisplayManager( - void) - : m_settingsInitialized(false) +GHOST_DisplayManager::GHOST_DisplayManager(void) + : m_settingsInitialized(false) { } diff --git a/intern/ghost/intern/GHOST_DisplayManager.h b/intern/ghost/intern/GHOST_DisplayManager.h index 7dc0cf2ca04..afdb11543e9 100644 --- a/intern/ghost/intern/GHOST_DisplayManager.h +++ b/intern/ghost/intern/GHOST_DisplayManager.h @@ -100,7 +100,7 @@ public: /** * Changes the current setting for this display device. - * The setting given to this method is matched againts the available diplay settings. + * The setting given to this method is matched against the available display settings. * The best match is activated (@see findMatch()). * \param display The index of the display to query with 0 <= display < getNumDisplays(). * \param setting The setting of the display device to be matched and activated. diff --git a/intern/ghost/intern/GHOST_DisplayManagerSDL.cpp b/intern/ghost/intern/GHOST_DisplayManagerSDL.cpp index fa92adf87f0..cdba8cdb4bb 100644 --- a/intern/ghost/intern/GHOST_DisplayManagerSDL.cpp +++ b/intern/ghost/intern/GHOST_DisplayManagerSDL.cpp @@ -35,8 +35,7 @@ #include "GHOST_WindowManager.h" GHOST_DisplayManagerSDL::GHOST_DisplayManagerSDL(GHOST_SystemSDL *system) - : - GHOST_DisplayManager(), + : GHOST_DisplayManager(), m_system(system) { memset(&m_mode, 0, sizeof(m_mode)); diff --git a/intern/ghost/intern/GHOST_DisplayManagerWin32.cpp b/intern/ghost/intern/GHOST_DisplayManagerWin32.cpp index 0bfc67a9126..65d5e650251 100644 --- a/intern/ghost/intern/GHOST_DisplayManagerWin32.cpp +++ b/intern/ghost/intern/GHOST_DisplayManagerWin32.cpp @@ -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"); diff --git a/intern/ghost/intern/GHOST_DisplayManagerX11.cpp b/intern/ghost/intern/GHOST_DisplayManagerX11.cpp index f63a93eebb8..24289e6b006 100644 --- a/intern/ghost/intern/GHOST_DisplayManagerX11.cpp +++ b/intern/ghost/intern/GHOST_DisplayManagerX11.cpp @@ -42,10 +42,9 @@ GHOST_DisplayManagerX11:: GHOST_DisplayManagerX11( - GHOST_SystemX11 *system - ) : - GHOST_DisplayManager(), - m_system(system) + GHOST_SystemX11 *system) + : GHOST_DisplayManager(), + m_system(system) { /* nothing to do. */ } @@ -195,7 +194,7 @@ setCurrentDisplaySetting( fprintf(stderr, "Error: XF86VidMode extension missing!\n"); return GHOST_kFailure; } -# ifdef _DEBUG +# ifdef DEBUG printf("Using XFree86-VidModeExtension Version %d.%d\n", majorVersion, minorVersion); # endif @@ -241,7 +240,7 @@ setCurrentDisplaySetting( } if (best_fit != -1) { -# ifdef _DEBUG +# ifdef DEBUG printf("Switching to video mode %dx%d %dx%d %d\n", vidmodes[best_fit]->hdisplay, vidmodes[best_fit]->vdisplay, vidmodes[best_fit]->htotal, vidmodes[best_fit]->vtotal, diff --git a/intern/ghost/intern/GHOST_DropTargetWin32.cpp b/intern/ghost/intern/GHOST_DropTargetWin32.cpp index 5288b77a3c6..fd9abce96b7 100644 --- a/intern/ghost/intern/GHOST_DropTargetWin32.cpp +++ b/intern/ghost/intern/GHOST_DropTargetWin32.cpp @@ -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; @@ -186,7 +186,7 @@ DWORD GHOST_DropTargetWin32::allowedDropEffect(DWORD dwAllowed) GHOST_TDragnDropTypes GHOST_DropTargetWin32::getGhostType(IDataObject *pDataObject) { /* Text - * Note: Unicode text is aviable as CF_TEXT too, the system can do the + * Note: Unicode text is available as CF_TEXT too, the system can do the * conversion, but we do the conversion ourself with WC_NO_BEST_FIT_CHARS. */ FORMATETC fmtetc = { CF_TEXT, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; @@ -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); diff --git a/intern/ghost/intern/GHOST_DropTargetX11.h b/intern/ghost/intern/GHOST_DropTargetX11.h index 0254139bcd8..e2968844ff0 100644 --- a/intern/ghost/intern/GHOST_DropTargetX11.h +++ b/intern/ghost/intern/GHOST_DropTargetX11.h @@ -73,12 +73,12 @@ private: /* Internal helper functions */ /** - * Initiailize XDND and all related X atoms + * Initialize XDND and all related X atoms */ void Initialize(void); /** - * Uninitiailize XDND and all related X atoms + * Uninitialize XDND and all related X atoms */ void Uninitialize(void); @@ -101,7 +101,7 @@ private: /** * Fully decode file URL (i.e. converts "file:///a%20b/test" to "/a b/test") * \param fileUrl - file path URL to be fully decoded - * \return decoded file path (resutl shold be free-d) + * \return decoded file path (resutl should be free-d) */ char *FileUrlDecode(char *fileUrl); diff --git a/intern/ghost/intern/GHOST_NDOFManager.cpp b/intern/ghost/intern/GHOST_NDOFManager.cpp index c99680641c3..9bd6226d5c2 100644 --- a/intern/ghost/intern/GHOST_NDOFManager.cpp +++ b/intern/ghost/intern/GHOST_NDOFManager.cpp @@ -189,18 +189,18 @@ static const NDOF_ButtonT Generic_HID_map[] = { static const int genericButtonCount = sizeof(Generic_HID_map) / sizeof(NDOF_ButtonT); -GHOST_NDOFManager::GHOST_NDOFManager(GHOST_System& sys) - : m_system(sys) - , m_deviceType(NDOF_UnknownDevice) // each platform has its own device detection code - , m_buttonCount(genericButtonCount) - , m_buttonMask(0) - , m_hidMap(Generic_HID_map) - , m_buttons(0) - , m_motionTime(0) - , m_prevMotionTime(0) - , m_motionState(GHOST_kNotStarted) - , m_motionEventPending(false) - , m_deadZone(0.f) +GHOST_NDOFManager::GHOST_NDOFManager(GHOST_System &sys) + : m_system(sys), + m_deviceType(NDOF_UnknownDevice), /* each platform has its own device detection code */ + m_buttonCount(genericButtonCount), + m_buttonMask(0), + m_hidMap(Generic_HID_map), + m_buttons(0), + m_motionTime(0), + m_prevMotionTime(0), + m_motionState(GHOST_kNotStarted), + m_motionEventPending(false), + m_deadZone(0.0f) { // to avoid the rare situation where one triple is updated and // the other is not, initialize them both here: diff --git a/intern/ghost/intern/GHOST_NDOFManager.h b/intern/ghost/intern/GHOST_NDOFManager.h index 98aebfa4f30..0b2080e36a9 100644 --- a/intern/ghost/intern/GHOST_NDOFManager.h +++ b/intern/ghost/intern/GHOST_NDOFManager.h @@ -105,7 +105,7 @@ typedef enum { class GHOST_NDOFManager { public: - GHOST_NDOFManager(GHOST_System&); + GHOST_NDOFManager(GHOST_System &); virtual ~GHOST_NDOFManager() {} diff --git a/intern/ghost/intern/GHOST_NDOFManager3Dconnexion.c b/intern/ghost/intern/GHOST_NDOFManager3Dconnexion.c index 9df9a56f8b8..01e301f927e 100644 --- a/intern/ghost/intern/GHOST_NDOFManager3Dconnexion.c +++ b/intern/ghost/intern/GHOST_NDOFManager3Dconnexion.c @@ -30,14 +30,14 @@ /* It is to be noted that these implementations are linked in as * 'extern "C"' calls from GHOST_NDOFManagerCocoa. - + * * This is done in order to * preserve weak linking capability (which as of clang-3.3 and xcode5 * breaks weak linking when there is name mangling of c++ libraries.) * * We need to have the weak linked file as pure C. Therefore we build a * compiled bridge from the real weak linked calls and the calls within C++ - + * */ OSErr GHOST_NDOFManager3Dconnexion_available(void) diff --git a/intern/ghost/intern/GHOST_NDOFManagerCocoa.mm b/intern/ghost/intern/GHOST_NDOFManagerCocoa.mm index 1a029257f09..6eedaafb2d1 100644 --- a/intern/ghost/intern/GHOST_NDOFManagerCocoa.mm +++ b/intern/ghost/intern/GHOST_NDOFManagerCocoa.mm @@ -30,7 +30,7 @@ extern "C" { #include <ConnexionClientAPI.h> #include <stdio.h> - } +} // static functions need to talk to these objects: diff --git a/intern/ghost/intern/GHOST_NDOFManagerWin32.cpp b/intern/ghost/intern/GHOST_NDOFManagerWin32.cpp index 939e1272434..6c1627905e0 100644 --- a/intern/ghost/intern/GHOST_NDOFManagerWin32.cpp +++ b/intern/ghost/intern/GHOST_NDOFManagerWin32.cpp @@ -28,7 +28,7 @@ GHOST_NDOFManagerWin32::GHOST_NDOFManagerWin32(GHOST_System& sys) - : GHOST_NDOFManager(sys) + : GHOST_NDOFManager(sys) { setDeadZone(0.1f); } diff --git a/intern/ghost/intern/GHOST_NDOFManagerX11.cpp b/intern/ghost/intern/GHOST_NDOFManagerX11.cpp index 77e09e7ef49..8e6f9994e51 100644 --- a/intern/ghost/intern/GHOST_NDOFManagerX11.cpp +++ b/intern/ghost/intern/GHOST_NDOFManagerX11.cpp @@ -30,9 +30,8 @@ GHOST_NDOFManagerX11::GHOST_NDOFManagerX11(GHOST_System& sys) - : - GHOST_NDOFManager(sys), - m_available(false) + : GHOST_NDOFManager(sys), + m_available(false) { setDeadZone(0.1f); /* how to calibrate on Linux? throw away slight motion! */ diff --git a/intern/ghost/intern/GHOST_System.cpp b/intern/ghost/intern/GHOST_System.cpp index 023c5958c4f..d1f2d5d87c8 100644 --- a/intern/ghost/intern/GHOST_System.cpp +++ b/intern/ghost/intern/GHOST_System.cpp @@ -45,13 +45,13 @@ GHOST_System::GHOST_System() - : m_nativePixel(false), - m_displayManager(NULL), - m_timerManager(NULL), - m_windowManager(NULL), - m_eventManager(NULL) + : m_nativePixel(false), + m_displayManager(NULL), + m_timerManager(NULL), + m_windowManager(NULL), + m_eventManager(NULL) #ifdef WITH_INPUT_NDOF - , m_ndofManager(0) + , m_ndofManager(0) #endif { } diff --git a/intern/ghost/intern/GHOST_System.h b/intern/ghost/intern/GHOST_System.h index 57aa0a31c94..79230b0f505 100644 --- a/intern/ghost/intern/GHOST_System.h +++ b/intern/ghost/intern/GHOST_System.h @@ -250,27 +250,23 @@ public: virtual GHOST_TSuccess pushEvent(GHOST_IEvent *event); /** - * Returns the timer manager. * \return The timer manager. */ inline virtual GHOST_TimerManager *getTimerManager() const; /** - * Returns a pointer to our event manager. * \return A pointer to our event manager. */ virtual inline GHOST_EventManager *getEventManager() const; /** - * Returns a pointer to our window manager. * \return A pointer to our window manager. */ virtual inline GHOST_WindowManager *getWindowManager() const; #ifdef WITH_INPUT_NDOF /** - * Returns a pointer to our n-degree of freedeom manager. - * \return A pointer to our n-degree of freedeom manager. + * \return A pointer to our n-degree of freedom manager. */ virtual inline GHOST_NDOFManager *getNDOFManager() const; #endif @@ -333,7 +329,7 @@ protected: virtual GHOST_TSuccess createFullScreenWindow(GHOST_Window **window, const GHOST_DisplaySetting &settings, const bool stereoVisual, const GHOST_TUns16 numOfAASamples = 0); - /** The display manager (platform dependant). */ + /** The display manager (platform dependent). */ GHOST_DisplayManager *m_displayManager; /** The timer manager. */ diff --git a/intern/ghost/intern/GHOST_SystemCocoa.h b/intern/ghost/intern/GHOST_SystemCocoa.h index 7d58c58b90e..9b30abe75d5 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.h +++ b/intern/ghost/intern/GHOST_SystemCocoa.h @@ -265,7 +265,7 @@ public: protected: /** * Initializes the system. - * For now, it justs registers the window class (WNDCLASS). + * For now, it just registers the window class (WNDCLASS). * \return A success value. */ virtual GHOST_TSuccess init(); diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm index 1d4c6d5e10b..a2e26574530 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.mm +++ b/intern/ghost/intern/GHOST_SystemCocoa.mm @@ -700,10 +700,10 @@ bool GHOST_SystemCocoa::processEvents(bool waitForEvent) handleKeyEvent(event); } else { - // For some reason NSApp is swallowing the key up events when command + // For some reason NSApp is swallowing the key up events when modifier // key is pressed, even if there seems to be no apparent reason to do // so, as a workaround we always handle these up events. - if ([event type] == NSKeyUp && ([event modifierFlags] & NSCommandKeyMask)) + if ([event type] == NSKeyUp && (([event modifierFlags] & NSCommandKeyMask) || ([event modifierFlags] & NSAlternateKeyMask))) handleKeyEvent(event); [NSApp sendEvent:event]; diff --git a/intern/ghost/intern/GHOST_SystemPathsWin32.cpp b/intern/ghost/intern/GHOST_SystemPathsWin32.cpp index 3a313c792d0..2bd380050f1 100644 --- a/intern/ghost/intern/GHOST_SystemPathsWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemPathsWin32.cpp @@ -37,7 +37,7 @@ #include <shlobj.h> #include "utfconv.h" -#if defined(__MINGW32__) || defined(__CYGWIN__) +#ifdef __MINGW32__ #if !defined(SHARD_PIDL) #define SHARD_PIDL 0x00000001L diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index ac0d5f3fadf..c53c6a1082d 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -46,6 +46,8 @@ #include <shlobj.h> #include <tlhelp32.h> +#include <Psapi.h> +#include <windowsx.h> #include "utfconv.h" @@ -114,6 +116,17 @@ #define VK_MEDIA_PLAY_PAUSE 0xB3 #endif // VK_MEDIA_PLAY_PAUSE +/* Workaround for some laptop touchpads, some of which seems to + * have driver issues which makes it so window function receives + * the message, but PeekMessage doesn't pick those messages for + * some reason. + * + * We send a dummy WM_USER message to force PeekMessage to receive + * something, making it so blender's window manager sees the new + * messages coming in. + */ +#define BROKEN_PEEK_TOUCHPAD + static void initRawInput() { #ifdef WITH_INPUT_NDOF @@ -201,23 +214,34 @@ 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( +<<<<<<< HEAD const STR_String& title, GHOST_TInt32 left, GHOST_TInt32 top, GHOST_TUns32 width, GHOST_TUns32 height, GHOST_TWindowState state, GHOST_TDrawingContextType type, bool wantStereoVisual, const bool exclusive, const GHOST_TUns16 wantNumOfAASamples, 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) +>>>>>>> master { GHOST_Window *window = new GHOST_WindowWin32( @@ -294,7 +318,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)) { @@ -308,13 +332,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); @@ -341,7 +365,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. @@ -417,7 +441,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; @@ -432,8 +456,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) { @@ -441,43 +464,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); } @@ -629,7 +652,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); } @@ -706,7 +732,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; @@ -724,7 +750,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)) { @@ -764,17 +790,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(), @@ -791,7 +818,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(); @@ -837,8 +864,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); @@ -846,8 +872,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); @@ -909,8 +935,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) { @@ -970,8 +995,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; @@ -1034,6 +1058,7 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, event = processCursorEvent(GHOST_kEventCursorMove, window); break; case WM_MOUSEWHEEL: + { /* The WM_MOUSEWHEEL message is sent to the focus window * when the mouse wheel is rotated. The DefWindowProc * function propagates the message to the window's parent. @@ -1041,8 +1066,28 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, * since DefWindowProc propagates it up the parent chain * until it finds a window that processes it. */ - event = processWheelEvent(window, wParam, lParam); + + /* Get the winow under the mouse and send event to it's queue. */ + POINT mouse_pos = {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)}; + HWND mouse_hwnd = WindowFromPoint(mouse_pos); + GHOST_WindowWin32 *mouse_window = (GHOST_WindowWin32 *)::GetWindowLongPtr(mouse_hwnd, GWLP_USERDATA); + if (mouse_window != NULL) { + event = processWheelEvent(mouse_window, wParam, lParam); + } + else { + /* If it happened so window under the mouse is not found (which i'm not + * really sure might happen), then we add event to the focused window + * in order to avoid some possible negative side effects. + * - sergey - + */ + event = processWheelEvent(window, wParam, lParam); + } + +#ifdef BROKEN_PEEK_TOUCHPAD + PostMessage(hwnd, WM_USER, 0, 0); +#endif break; + } case WM_SETCURSOR: /* The WM_SETCURSOR message is sent to a window if the mouse causes the cursor * to move within a window and mouse input is not captured. @@ -1099,7 +1144,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); @@ -1222,8 +1267,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: @@ -1373,16 +1418,63 @@ void GHOST_SystemWin32::putClipboard(GHOST_TInt8 *buffer, bool selection) const } } +static DWORD GetParentProcessID(void) +{ + HANDLE snapshot; + PROCESSENTRY32 pe32 = {0}; + DWORD ppid = 0, pid = GetCurrentProcessId(); + snapshot = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 ); + if (snapshot == INVALID_HANDLE_VALUE) { + return -1; + } + pe32.dwSize = sizeof( pe32 ); + if (!Process32First(snapshot, &pe32)) { + CloseHandle(snapshot); + return -1; + } + do { + if (pe32.th32ProcessID == pid) { + ppid = pe32.th32ParentProcessID; + break; + } + } while (Process32Next(snapshot, &pe32)); + CloseHandle(snapshot); + return ppid; +} + +static bool getProcessName(int pid, char *buffer, int max_len) +{ + bool result = false; + HANDLE handle = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, + FALSE, pid); + if (handle) { + GetModuleFileNameEx(handle, 0, buffer, max_len); + result = true; + } + CloseHandle(handle); + return result; +} + static bool isStartedFromCommandPrompt() { HWND hwnd = GetConsoleWindow(); if (hwnd) { DWORD pid = (DWORD)-1; + DWORD ppid = GetParentProcessID(); + char parent_name[MAX_PATH]; + bool start_from_launcher = false; GetWindowThreadProcessId(hwnd, &pid); + if (getProcessName(ppid, parent_name, sizeof(parent_name))) { + char *filename = strrchr(parent_name, '\\'); + if (filename != NULL) { + start_from_launcher = strstr(filename, "blender.exe") != NULL; + } + } - if (pid == GetCurrentProcessId()) + /* When we're starting from a wrapper we need to compare with parent process ID. */ + if (pid == (start_from_launcher ? ppid : GetCurrentProcessId())) return true; } @@ -1413,8 +1505,7 @@ int GHOST_SystemWin32::toggleConsole(int action) ShowWindow(GetConsoleWindow(), m_consoleStatus ? SW_HIDE : SW_SHOW); m_consoleStatus = !m_consoleStatus; break; - - }; + } return m_consoleStatus; diff --git a/intern/ghost/intern/GHOST_SystemWin32.h b/intern/ghost/intern/GHOST_SystemWin32.h index 18aadfbdca6..79fed06c6a5 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.h +++ b/intern/ghost/intern/GHOST_SystemWin32.h @@ -215,7 +215,7 @@ public: protected: /** * Initializes the system. - * For now, it justs registers the window class (WNDCLASS). + * For now, it just registers the window class (WNDCLASS). * \return A success value. */ virtual GHOST_TSuccess init(); @@ -231,7 +231,7 @@ protected: * \param window-> The window for this handling * \param vKey The virtual key from hardKey * \param ScanCode The ScanCode of pressed key (simular to PS/2 Set 1) - * \param extend Flag if key is not primerly (left or right) + * \param extend Flag if key is not primly (left or right) * \return The GHOST key (GHOST_kKeyUnknown if no match). */ virtual GHOST_TKey convertKey(GHOST_IWindow *window, short vKey, short ScanCode, short extend) const; diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp index 9b6d48c5993..75a9223d6a3 100644 --- a/intern/ghost/intern/GHOST_SystemX11.cpp +++ b/intern/ghost/intern/GHOST_SystemX11.cpp @@ -86,9 +86,9 @@ using namespace std; GHOST_SystemX11:: GHOST_SystemX11( - ) : - GHOST_System(), - m_start_time(0) + ) + : GHOST_System(), + m_start_time(0) { m_display = XOpenDisplay(NULL); @@ -141,6 +141,8 @@ GHOST_SystemX11( #undef GHOST_INTERN_ATOM m_last_warp = 0; + m_last_release_keycode = 0; + m_last_release_time = 0; /* compute the initial time */ timeval tv; @@ -244,7 +246,7 @@ getMainDisplayDimensions( { if (m_display) { /* note, for this to work as documented, - * we would need to use Xinerama check r54370 for code that did thia, + * we would need to use Xinerama check r54370 for code that did this, * we've since removed since its not worth the extra dep - campbell */ getAllDisplayDimensions(width, height); } @@ -526,6 +528,16 @@ processEvents( continue; } #endif + /* when using autorepeat, some keypress events can actually come *after* the + * last keyrelease. The next code takes care of that */ + if (xevent.type == KeyRelease) { + m_last_release_keycode = xevent.xkey.keycode; + m_last_release_time = xevent.xkey.time; + } + else if (xevent.type == KeyPress) { + if ((xevent.xkey.keycode == m_last_release_keycode) && ((xevent.xkey.time <= m_last_release_time))) + continue; + } processEvent(&xevent); anyProcessed = true; @@ -659,7 +671,7 @@ GHOST_SystemX11::processEvent(XEvent *xe) #ifdef WITH_X11_XINPUT /* Proximity-Out Events are not reliable, if the tablet is active - check on each event * this adds a little overhead but only while the tablet is in use. - * in the futire we could have a ghost call window->CheckTabletProximity() + * in the future we could have a ghost call window->CheckTabletProximity() * but for now enough parts of the code are checking 'Active' * - campbell */ if (window->GetTabletData()->Active != GHOST_kTabletModeNone) { @@ -1240,7 +1252,7 @@ getModifierKeys( XQueryKeymap(m_display, (char *)m_keyboard_vector); - /* now translate key symobols into keycodes and + /* now translate key symbols into keycodes and * test with vector. */ const static KeyCode shift_l = XKeysymToKeycode(m_display, XK_Shift_L); diff --git a/intern/ghost/intern/GHOST_SystemX11.h b/intern/ghost/intern/GHOST_SystemX11.h index 1a055725aac..be149cbb773 100644 --- a/intern/ghost/intern/GHOST_SystemX11.h +++ b/intern/ghost/intern/GHOST_SystemX11.h @@ -355,6 +355,10 @@ private: * and stop accumulating all events generated before that */ Time m_last_warp; + /* detect autorepeat glitch */ + unsigned int m_last_release_keycode; + Time m_last_release_time; + /** * Return the ghost window associated with the * X11 window xwind diff --git a/intern/ghost/intern/GHOST_TaskbarWin32.h b/intern/ghost/intern/GHOST_TaskbarWin32.h index 4351b387e48..04196701fe9 100644 --- a/intern/ghost/intern/GHOST_TaskbarWin32.h +++ b/intern/ghost/intern/GHOST_TaskbarWin32.h @@ -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 { diff --git a/intern/ghost/intern/GHOST_TimerManager.h b/intern/ghost/intern/GHOST_TimerManager.h index 5a24c56ef10..b94175e9ff8 100644 --- a/intern/ghost/intern/GHOST_TimerManager.h +++ b/intern/ghost/intern/GHOST_TimerManager.h @@ -67,7 +67,7 @@ public: virtual GHOST_TUns32 getNumTimers(); /** - * Returns whther this timer task ins in our list. + * Returns whether this timer task ins in our list. * \return Indication of presence. */ virtual bool getTimerFound(GHOST_TimerTask *timer); diff --git a/intern/ghost/intern/GHOST_TimerTask.h b/intern/ghost/intern/GHOST_TimerTask.h index e8f5ecd9fbb..e33788ec826 100644 --- a/intern/ghost/intern/GHOST_TimerTask.h +++ b/intern/ghost/intern/GHOST_TimerTask.h @@ -48,7 +48,7 @@ public: * Constructor. * \param start The timer start time. * \param interval The interval between calls to the timerProc - * \param timerProc The callbak invoked when the interval expires. + * \param timerProc The callback invoked when the interval expires. * \param data The timer user data. */ GHOST_TimerTask(GHOST_TUns64 start, diff --git a/intern/ghost/intern/GHOST_WindowCocoa.h b/intern/ghost/intern/GHOST_WindowCocoa.h index a11e78d0085..ce35110dcdf 100644 --- a/intern/ghost/intern/GHOST_WindowCocoa.h +++ b/intern/ghost/intern/GHOST_WindowCocoa.h @@ -129,7 +129,7 @@ public: /** * Returns the client rectangle dimensions. * The left and top members of the rectangle are always zero. - * \param bounds The bounding rectangle of the cleient area of the window. + * \param bounds The bounding rectangle of the client area of the window. */ virtual void getClientBounds(GHOST_Rect& bounds) const; diff --git a/intern/ghost/intern/GHOST_WindowManager.h b/intern/ghost/intern/GHOST_WindowManager.h index ecf0cb30860..8297e4d24d2 100644 --- a/intern/ghost/intern/GHOST_WindowManager.h +++ b/intern/ghost/intern/GHOST_WindowManager.h @@ -87,7 +87,7 @@ public: /** * Returns pointer to the full-screen window. - * \return The fll-screen window (0 if not in full-screen). + * \return The full-screen window (NULL if not in full-screen). */ virtual GHOST_IWindow *getFullScreenWindow(void) const; @@ -121,7 +121,7 @@ public: /** * Set this window to be inactive (not receiving events). - * \param window The window to decativate. + * \param window The window to deactivate. */ virtual void setWindowInactive(const GHOST_IWindow *window); diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp index 8e52fe8e133..11ddc478d6c 100644 --- a/intern/ghost/intern/GHOST_WindowWin32.cpp +++ b/intern/ghost/intern/GHOST_WindowWin32.cpp @@ -55,6 +55,51 @@ const wchar_t *GHOST_WindowWin32::s_windowClassName = L"GHOST_WindowClass"; const int GHOST_WindowWin32::s_maxTitleLength = 128; +<<<<<<< HEAD +======= +static int WeightPixelFormat(PIXELFORMATDESCRIPTOR &pfd); +static int EnumPixelFormats(HDC hdc); + +/* + * Color and depth bit values are not to be trusted. + * For instance, on TNT2: + * When the screen color depth is set to 16 bit, we get 5 color bits + * and 16 depth bits. + * When the screen color depth is set to 32 bit, we get 8 color bits + * and 24 depth bits. + * Just to be safe, we request high quality settings. + */ +static PIXELFORMATDESCRIPTOR sPreferredFormat = { + sizeof(PIXELFORMATDESCRIPTOR), /* size */ + 1, /* version */ + PFD_SUPPORT_OPENGL | + PFD_DRAW_TO_WINDOW | + PFD_SWAP_COPY | /* support swap copy */ + PFD_DOUBLEBUFFER, /* support double-buffering */ + PFD_TYPE_RGBA, /* color type */ + 32, /* prefered color depth */ + 0, 0, 0, 0, 0, 0, /* color bits (ignored) */ + 0, /* no alpha buffer */ + 0, /* alpha bits (ignored) */ + 0, /* no accumulation buffer */ + 0, 0, 0, 0, /* accum bits (ignored) */ + 32, /* depth buffer */ + 0, /* no stencil buffer */ + 0, /* no auxiliary buffers */ + PFD_MAIN_PLANE, /* main layer */ + 0, /* reserved */ + 0, 0, 0 /* no layer, visible, damage masks */ +}; + +/* Intel videocards don't work fine with multiple contexts and + * have to share the same context for all windows. + * But if we just share context for all windows it could work incorrect + * with multiple videocards configuration. Suppose, that Intel videocards + * can't be in multiple-devices configuration. */ +static int is_crappy_intel_card(void) +{ + static short is_crappy = -1; +>>>>>>> master @@ -64,6 +109,7 @@ extern "C" { } GHOST_WindowWin32::GHOST_WindowWin32( +<<<<<<< HEAD GHOST_SystemWin32 *system, const STR_String& title, GHOST_TInt32 left, @@ -90,6 +136,48 @@ GHOST_WindowWin32::GHOST_WindowWin32( m_maxPressure(0), m_normal_state(GHOST_kWindowStateNormal), 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) +>>>>>>> master { OSVERSIONINFOEX versionInfo; bool hasMinVersionForTaskbar = false; @@ -101,13 +189,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; } } @@ -117,7 +209,7 @@ GHOST_WindowWin32::GHOST_WindowWin32( MONITORINFO monitor; GHOST_TUns32 tw, th; -#if !defined(_MSC_VER) || _MSC_VER < 1700 +#ifndef _MSC_VER int cxsizeframe = GetSystemMetrics(SM_CXSIZEFRAME); int cysizeframe = GetSystemMetrics(SM_CYSIZEFRAME); #else @@ -147,8 +239,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; } @@ -157,8 +248,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; } @@ -168,8 +258,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; @@ -242,6 +331,10 @@ GHOST_WindowWin32::GHOST_WindowWin32( break; } +<<<<<<< HEAD +======= + if (success) { +>>>>>>> master ::ShowWindow(m_hWnd, nCmdShow); // Force an initial paint of the window @@ -273,7 +366,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 @@ -350,8 +444,20 @@ GHOST_WindowWin32::~GHOST_WindowWin32() m_customCursor = NULL; } +<<<<<<< HEAD if (m_hWnd != NULL && m_hDC != NULL && releaseNativeHandles()) ::ReleaseDC(m_hWnd, m_hDC); +======= + ::wglMakeCurrent(NULL, NULL); + 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; + } +>>>>>>> master if (m_hWnd) { if (m_dropTarget) { @@ -376,7 +482,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); @@ -384,7 +490,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); @@ -393,7 +499,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); @@ -404,7 +510,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; @@ -495,6 +601,7 @@ GHOST_TWindowState GHOST_WindowWin32::getState() const state = GHOST_kWindowStateEmbedded; return state; } + if (::IsIconic(m_hWnd)) { state = GHOST_kWindowStateMinimized; } @@ -512,18 +619,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; @@ -539,13 +650,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) @@ -553,18 +665,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; } @@ -581,9 +695,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; } @@ -683,6 +799,7 @@ GHOST_Context* GHOST_WindowWin32::newDrawingContext(GHOST_TDrawingContextType ty #error #endif +<<<<<<< HEAD #else #error #endif @@ -690,6 +807,11 @@ GHOST_Context* GHOST_WindowWin32::newDrawingContext(GHOST_TDrawingContextType ty return context; else delete context; +======= + if (!wglChoosePixelFormatARB) { + m_multisampleEnabled = GHOST_kFailure; + return GHOST_kFailure; +>>>>>>> master } return NULL; @@ -700,8 +822,13 @@ GHOST_Context* GHOST_WindowWin32::newDrawingContext(GHOST_TDrawingContextType ty void GHOST_WindowWin32::lostMouseCapture() { if (m_hasMouseCaptured) { +<<<<<<< HEAD m_hasGrabMouse = false; m_nPressedButtons = 0; +======= + m_hasGrabMouse = false; + m_nPressedButtons = 0; +>>>>>>> master m_hasMouseCaptured = false; } } @@ -709,21 +836,18 @@ void GHOST_WindowWin32::lostMouseCapture() 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; @@ -975,17 +1099,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]; @@ -1046,3 +1172,96 @@ GHOST_TSuccess GHOST_WindowWin32::endProgressBar() return GHOST_kFailure; } +<<<<<<< HEAD +======= +/* 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) +{ + int weight = 0; + + /* assume desktop color depth is 32 bits per pixel */ + + /* cull unusable pixel formats */ + /* if no formats can be found, can we determine why it was rejected? */ + if (!(pfd.dwFlags & PFD_SUPPORT_OPENGL) || + !(pfd.dwFlags & PFD_DRAW_TO_WINDOW) || + !(pfd.dwFlags & PFD_DOUBLEBUFFER) || /* Blender _needs_ this */ + (pfd.cDepthBits <= 8) || + !(pfd.iPixelType == PFD_TYPE_RGBA)) + { + return 0; + } + + weight = 1; /* it's usable */ + + /* the bigger the depth buffer the better */ + /* give no weight to a 16-bit depth buffer, because those are crap */ + weight += pfd.cDepthBits - 16; + + weight += pfd.cColorBits - 8; + +#ifdef GHOST_OPENGL_ALPHA + if (pfd.cAlphaBits > 0) + weight ++; +#endif + + /* want swap copy capability -- it matters a lot */ + if (pfd.dwFlags & PFD_SWAP_COPY) weight += 16; + + /* but if it's a generic (not accelerated) view, it's really bad */ + if (pfd.dwFlags & PFD_GENERIC_FORMAT) weight /= 10; + + return weight; +} + +/* A modification of Ron Fosner's replacement for ChoosePixelFormat */ +/* returns 0 on error, else returns the pixel format number to be used */ +static int EnumPixelFormats(HDC hdc) +{ + int iPixelFormat; + int i, n, w, weight = 0; + PIXELFORMATDESCRIPTOR pfd; + + /* we need a device context to do anything */ + if (!hdc) return 0; + + iPixelFormat = 1; /* careful! PFD numbers are 1 based, not zero based */ + + /* obtain detailed information about + * the device context's first pixel format */ + n = 1 + ::DescribePixelFormat(hdc, iPixelFormat, + sizeof(PIXELFORMATDESCRIPTOR), &pfd); + + /* choose a pixel format using the useless Windows function in case + * we come up empty handed */ + iPixelFormat = ::ChoosePixelFormat(hdc, &sPreferredFormat); + + if (!iPixelFormat) return 0; /* couldn't find one to use */ + + for (i = 1; i <= n; i++) { /* not the idiom, but it's right */ + ::DescribePixelFormat(hdc, i, sizeof(PIXELFORMATDESCRIPTOR), &pfd); + w = WeightPixelFormat(pfd); + // be strict on stereo + if (!((sPreferredFormat.dwFlags ^ pfd.dwFlags) & PFD_STEREO)) { + if (w > weight) { + weight = w; + iPixelFormat = i; + } + } + } + if (weight == 0) { + // we could find the correct stereo setting, just find any suitable format + for (i = 1; i <= n; i++) { /* not the idiom, but it's right */ + ::DescribePixelFormat(hdc, i, sizeof(PIXELFORMATDESCRIPTOR), &pfd); + w = WeightPixelFormat(pfd); + if (w > weight) { + weight = w; + iPixelFormat = i; + } + } + } + return iPixelFormat; +} +>>>>>>> master diff --git a/intern/ghost/intern/GHOST_WindowWin32.h b/intern/ghost/intern/GHOST_WindowWin32.h index 12dca5f3fee..b5e8157dd62 100644 --- a/intern/ghost/intern/GHOST_WindowWin32.h +++ b/intern/ghost/intern/GHOST_WindowWin32.h @@ -138,7 +138,7 @@ public: /** * Returns the client rectangle dimensions. * The left and top members of the rectangle are always zero. - * \param bounds The bounding rectangle of the cleient area of the window. + * \param bounds The bounding rectangle of the client area of the window. */ virtual void getClientBounds(GHOST_Rect& bounds) const; @@ -318,7 +318,7 @@ private: /** Flag for if window has captured the mouse */ bool m_hasMouseCaptured; /** Flag if an operator grabs the mouse with WM_cursor_grab_enable/ungrab() - * Multiple grabs must be realesed with a single ungrab*/ + * Multiple grabs must be released with a single ungrab */ bool m_hasGrabMouse; /** Count of number of pressed buttons */ int m_nPressedButtons; diff --git a/intern/ghost/intern/GHOST_WindowX11.cpp b/intern/ghost/intern/GHOST_WindowX11.cpp index ade76f2a12a..821cc1076fe 100644 --- a/intern/ghost/intern/GHOST_WindowX11.cpp +++ b/intern/ghost/intern/GHOST_WindowX11.cpp @@ -61,7 +61,7 @@ #include <algorithm> #include <string> -/* For obscure full screen mode stuuf +/* For obscure full screen mode stuff * lifted verbatim from blut. */ typedef struct { diff --git a/intern/ghost/intern/GHOST_WindowX11.h b/intern/ghost/intern/GHOST_WindowX11.h index 8d7cf3a4d44..92d2b8e17d3 100644 --- a/intern/ghost/intern/GHOST_WindowX11.h +++ b/intern/ghost/intern/GHOST_WindowX11.h @@ -246,7 +246,7 @@ protected: /** * Sets the cursor grab on the window using * native window system calls. - * \param warp Only used when grab is enabled, hides the mouse and allows gragging outside the screen. + * \param warp Only used when grab is enabled, hides the mouse and allows dragging outside the screen. */ GHOST_TSuccess setWindowCursorGrab( diff --git a/intern/ghost/test/gears/GHOST_Test.cpp b/intern/ghost/test/gears/GHOST_Test.cpp index 78e5257be1f..a81aaa85ecf 100644 --- a/intern/ghost/test/gears/GHOST_Test.cpp +++ b/intern/ghost/test/gears/GHOST_Test.cpp @@ -262,7 +262,8 @@ static void View(GHOST_IWindow *window, bool stereo, int eye = 0) window->activateDrawingContext(); GHOST_Rect bnds; int noOfScanlines = 0, lowerScanline = 0; - int verticalBlankingInterval = 32; // hard coded for testing purposes, display device dependant + /* hard coded for testing purposes, display device dependent */ + int verticalBlankingInterval = 32; float left, right, bottom, top; float nearplane, farplane, zeroPlane, distance; float eyeSeparation = 0.62f; |