diff options
Diffstat (limited to 'intern/ghost/intern')
-rw-r--r-- | intern/ghost/intern/GHOST_SystemPathsCocoa.mm | 169 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_SystemWin32.cpp | 5 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_SystemX11.cpp | 5 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_Window.h | 5 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_WindowViewCocoa.h | 8 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_Wintab.h | 2 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_XrControllerModel.cpp | 22 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_XrControllerModel.h | 2 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_XrSession.cpp | 1 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_XrSession.h | 2 |
10 files changed, 95 insertions, 126 deletions
diff --git a/intern/ghost/intern/GHOST_SystemPathsCocoa.mm b/intern/ghost/intern/GHOST_SystemPathsCocoa.mm index 43ce0bb0533..4032c145ab4 100644 --- a/intern/ghost/intern/GHOST_SystemPathsCocoa.mm +++ b/intern/ghost/intern/GHOST_SystemPathsCocoa.mm @@ -36,130 +36,101 @@ GHOST_SystemPathsCocoa::~GHOST_SystemPathsCocoa() #pragma mark Base directories retrieval -const char *GHOST_SystemPathsCocoa::getSystemDir(int, const char *versionstr) const +static const char *GetApplicationSupportDir(const char *versionstr, + const NSSearchPathDomainMask mask, + char *tempPath, + const std::size_t len_tempPath) { - static char tempPath[512] = ""; - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - NSString *basePath; - NSArray *paths; - - paths = NSSearchPathForDirectoriesInDomains( - NSApplicationSupportDirectory, NSLocalDomainMask, YES); - - if ([paths count] > 0) - basePath = [paths objectAtIndex:0]; - else { - [pool drain]; - return NULL; - } + @autoreleasepool { + const NSArray *const paths = NSSearchPathForDirectoriesInDomains( + NSApplicationSupportDirectory, mask, YES); - snprintf(tempPath, - sizeof(tempPath), - "%s/Blender/%s", - [basePath cStringUsingEncoding:NSASCIIStringEncoding], - versionstr); - - [pool drain]; + if ([paths count] == 0) { + return NULL; + } + const NSString *const basePath = [paths objectAtIndex:0]; + + snprintf(tempPath, + len_tempPath, + "%s/Blender/%s", + [basePath cStringUsingEncoding:NSASCIIStringEncoding], + versionstr); + } return tempPath; } -const char *GHOST_SystemPathsCocoa::getUserDir(int, const char *versionstr) const +const char *GHOST_SystemPathsCocoa::getSystemDir(int, const char *versionstr) const { static char tempPath[512] = ""; - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - NSString *basePath; - NSArray *paths; - - paths = NSSearchPathForDirectoriesInDomains( - NSApplicationSupportDirectory, NSUserDomainMask, YES); - - if ([paths count] > 0) - basePath = [paths objectAtIndex:0]; - else { - [pool drain]; - return NULL; - } - - snprintf(tempPath, - sizeof(tempPath), - "%s/Blender/%s", - [basePath cStringUsingEncoding:NSASCIIStringEncoding], - versionstr); + return GetApplicationSupportDir(versionstr, NSLocalDomainMask, tempPath, sizeof(tempPath)); +} - [pool drain]; - return tempPath; +const char *GHOST_SystemPathsCocoa::getUserDir(int, const char *versionstr) const +{ + static char tempPath[512] = ""; + return GetApplicationSupportDir(versionstr, NSUserDomainMask, tempPath, sizeof(tempPath)); } const char *GHOST_SystemPathsCocoa::getUserSpecialDir(GHOST_TUserSpecialDirTypes type) const { static char tempPath[512] = ""; - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - NSString *basePath; - NSArray *paths; - NSSearchPathDirectory ns_directory; - - switch (type) { - case GHOST_kUserSpecialDirDesktop: - ns_directory = NSDesktopDirectory; - break; - case GHOST_kUserSpecialDirDocuments: - ns_directory = NSDocumentDirectory; - break; - case GHOST_kUserSpecialDirDownloads: - ns_directory = NSDownloadsDirectory; - break; - case GHOST_kUserSpecialDirMusic: - ns_directory = NSMusicDirectory; - break; - case GHOST_kUserSpecialDirPictures: - ns_directory = NSPicturesDirectory; - break; - case GHOST_kUserSpecialDirVideos: - ns_directory = NSMoviesDirectory; - break; - case GHOST_kUserSpecialDirCaches: - ns_directory = NSCachesDirectory; - break; - default: - GHOST_ASSERT( - false, - "GHOST_SystemPathsCocoa::getUserSpecialDir(): Invalid enum value for type parameter"); - [pool drain]; + @autoreleasepool { + NSSearchPathDirectory ns_directory; + + switch (type) { + case GHOST_kUserSpecialDirDesktop: + ns_directory = NSDesktopDirectory; + break; + case GHOST_kUserSpecialDirDocuments: + ns_directory = NSDocumentDirectory; + break; + case GHOST_kUserSpecialDirDownloads: + ns_directory = NSDownloadsDirectory; + break; + case GHOST_kUserSpecialDirMusic: + ns_directory = NSMusicDirectory; + break; + case GHOST_kUserSpecialDirPictures: + ns_directory = NSPicturesDirectory; + break; + case GHOST_kUserSpecialDirVideos: + ns_directory = NSMoviesDirectory; + break; + case GHOST_kUserSpecialDirCaches: + ns_directory = NSCachesDirectory; + break; + default: + GHOST_ASSERT( + false, + "GHOST_SystemPathsCocoa::getUserSpecialDir(): Invalid enum value for type parameter"); + return NULL; + } + + const NSArray *const paths = NSSearchPathForDirectoriesInDomains( + ns_directory, NSUserDomainMask, YES); + if ([paths count] == 0) { return NULL; - } - - paths = NSSearchPathForDirectoriesInDomains(ns_directory, NSUserDomainMask, YES); + } + const NSString *const basePath = [paths objectAtIndex:0]; - if ([paths count] > 0) - basePath = [paths objectAtIndex:0]; - else { - [pool drain]; - return NULL; + strncpy(tempPath, [basePath cStringUsingEncoding:NSASCIIStringEncoding], sizeof(tempPath)); } - - strncpy( - (char *)tempPath, [basePath cStringUsingEncoding:NSASCIIStringEncoding], sizeof(tempPath)); - - [pool drain]; return tempPath; } const char *GHOST_SystemPathsCocoa::getBinaryDir() const { static char tempPath[512] = ""; - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - NSString *basePath; - - basePath = [[NSBundle mainBundle] bundlePath]; - if (basePath == nil) { - [pool drain]; - return NULL; - } + @autoreleasepool { + const NSString *const basePath = [[NSBundle mainBundle] bundlePath]; - strcpy((char *)tempPath, [basePath cStringUsingEncoding:NSASCIIStringEncoding]); + if (basePath == nil) { + return NULL; + } - [pool drain]; + strcpy(tempPath, [basePath cStringUsingEncoding:NSASCIIStringEncoding]); + } return tempPath; } diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index 482f20f5cd1..e4630ad1ab5 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -1002,10 +1002,10 @@ void GHOST_SystemWin32::processWintabEvent(GHOST_WindowWin32 *window) DWORD pos = GetMessagePos(); int x = GET_X_LPARAM(pos); int y = GET_Y_LPARAM(pos); + GHOST_TabletData td = wt->getLastTabletData(); - /* TODO supply tablet data */ system->pushEvent(new GHOST_EventCursor( - system->getMilliSeconds(), GHOST_kEventCursorMove, window, x, y, GHOST_TABLET_DATA_NONE)); + system->getMilliSeconds(), GHOST_kEventCursorMove, window, x, y, td)); } } @@ -1472,6 +1472,7 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, case WM_IME_SETCONTEXT: { GHOST_ImeWin32 *ime = window->getImeInput(); ime->UpdateInputLanguage(); + ime->UpdateConversionStatus(hwnd); ime->CreateImeWindow(hwnd); ime->CleanupComposition(hwnd); ime->CheckFirst(hwnd); diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp index ab8039ea95d..85504bd94fb 100644 --- a/intern/ghost/intern/GHOST_SystemX11.cpp +++ b/intern/ghost/intern/GHOST_SystemX11.cpp @@ -714,7 +714,7 @@ bool GHOST_SystemX11::processEvents(bool waitForEvent) anyProcessed = true; #ifdef USE_UNITY_WORKAROUND - /* note: processEvent() can't include this code because + /* NOTE: processEvent() can't include this code because * KeymapNotify event have no valid window information. */ /* the X server generates KeymapNotify event immediately after @@ -1514,7 +1514,7 @@ void GHOST_SystemX11::processEvent(XEvent *xe) * around tablet surface */ window->GetTabletData().Active = xtablet.mode; - /* Note: This event might be generated with incomplete data-set + /* NOTE: This event might be generated with incomplete data-set * (don't exactly know why, looks like in some cases, if the value does not change, * it is not included in subsequent #XDeviceMotionEvent events). * So we have to check which values this event actually contains! @@ -2278,6 +2278,7 @@ void GHOST_SystemX11::putClipboard(const char *buffer, bool selection) const /* -------------------------------------------------------------------- */ /** \name Message Box * \{ */ + class DialogData { public: /* Width of the dialog. */ diff --git a/intern/ghost/intern/GHOST_Window.h b/intern/ghost/intern/GHOST_Window.h index f061e07b3c8..69d0eea838c 100644 --- a/intern/ghost/intern/GHOST_Window.h +++ b/intern/ghost/intern/GHOST_Window.h @@ -42,10 +42,9 @@ class GHOST_Window : public GHOST_IWindow { * Creates a new window and opens it. * To check if the window was created properly, use the getValid() method. * \param width: The width the window. - * \param heigh: The height the window. + * \param height: The height the window. * \param state: The state the window is initially opened with. - * \param type: The type of drawing context installed in this window. - * \param stereoVisual: Stereo visual for quad buffered stereo. + * \param wantStereoVisual: Stereo visual for quad buffered stereo. * \param exclusive: Use to show the window ontop and ignore others (used full-screen). */ GHOST_Window(uint32_t width, diff --git a/intern/ghost/intern/GHOST_WindowViewCocoa.h b/intern/ghost/intern/GHOST_WindowViewCocoa.h index fa629528809..1bda59c3505 100644 --- a/intern/ghost/intern/GHOST_WindowViewCocoa.h +++ b/intern/ghost/intern/GHOST_WindowViewCocoa.h @@ -510,6 +510,14 @@ - (void)checkKeyCodeIsControlChar:(NSEvent *)event { ime.state_flag &= ~GHOST_IME_KEY_CONTROL_CHAR; + + /* Don't use IME for command and ctrl key combinations, these are shortcuts. */ + if ([event modifierFlags] & (NSEventModifierFlagCommand | NSEventModifierFlagControl)) { + ime.state_flag |= GHOST_IME_KEY_CONTROL_CHAR; + return; + } + + /* Don't use IME for these control keys. */ switch ([event keyCode]) { case kVK_ANSI_KeypadEnter: case kVK_ANSI_KeypadClear: diff --git a/intern/ghost/intern/GHOST_Wintab.h b/intern/ghost/intern/GHOST_Wintab.h index 443c726d270..a6c41bf5f64 100644 --- a/intern/ghost/intern/GHOST_Wintab.h +++ b/intern/ghost/intern/GHOST_Wintab.h @@ -148,7 +148,7 @@ class GHOST_Wintab { * \param wtY: Wintab cursor y position. * \return True if Win32 and Wintab cursor positions match within tolerance. * - * Note: Only test coordinates on button press, not release. This prevents issues when async + * NOTE: Only test coordinates on button press, not release. This prevents issues when async * mismatch causes mouse movement to replay and snap back, which is only an issue while drawing. */ bool testCoordinates(int sysX, int sysY, int wtX, int wtY); diff --git a/intern/ghost/intern/GHOST_XrControllerModel.cpp b/intern/ghost/intern/GHOST_XrControllerModel.cpp index 27f92ffe7c5..aa46aaaf89a 100644 --- a/intern/ghost/intern/GHOST_XrControllerModel.cpp +++ b/intern/ghost/intern/GHOST_XrControllerModel.cpp @@ -244,22 +244,10 @@ static void calc_node_transforms(const tinygltf::Node &gltf_node, * both. */ if (gltf_node.matrix.size() == 16) { const std::vector<double> &dm = gltf_node.matrix; - float m[4][4] = {(float)dm[0], - (float)dm[1], - (float)dm[2], - (float)dm[3], - (float)dm[4], - (float)dm[5], - (float)dm[6], - (float)dm[7], - (float)dm[8], - (float)dm[9], - (float)dm[10], - (float)dm[11], - (float)dm[12], - (float)dm[13], - (float)dm[14], - (float)dm[15]}; + float m[4][4] = {{(float)dm[0], (float)dm[1], (float)dm[2], (float)dm[3]}, + {(float)dm[4], (float)dm[5], (float)dm[6], (float)dm[7]}, + {(float)dm[8], (float)dm[9], (float)dm[10], (float)dm[11]}, + {(float)dm[12], (float)dm[13], (float)dm[14], (float)dm[15]}}; memcpy(r_local_transform, m, sizeof(float) * 16); } else { @@ -534,7 +522,7 @@ void GHOST_XrControllerModel::loadControllerModel(XrSession session) (gltf_model.defaultScene == -1) ? 0 : gltf_model.defaultScene); const int32_t root_idx = -1; const std::string root_name = ""; - float root_transform[4][4] = {0}; + float root_transform[4][4] = {{0}}; root_transform[0][0] = root_transform[1][1] = root_transform[2][2] = root_transform[3][3] = 1.0f; for (const int node_id : default_scene.nodes) { diff --git a/intern/ghost/intern/GHOST_XrControllerModel.h b/intern/ghost/intern/GHOST_XrControllerModel.h index 5ff72957b24..a9aed961713 100644 --- a/intern/ghost/intern/GHOST_XrControllerModel.h +++ b/intern/ghost/intern/GHOST_XrControllerModel.h @@ -18,7 +18,7 @@ * \ingroup GHOST */ -/* Note: Requires OpenXR headers to be included before this one for OpenXR types (XrInstance, +/* NOTE: Requires OpenXR headers to be included before this one for OpenXR types (XrInstance, * XrSession, etc.). */ #pragma once diff --git a/intern/ghost/intern/GHOST_XrSession.cpp b/intern/ghost/intern/GHOST_XrSession.cpp index 64aa2f515c4..c68cb5992e3 100644 --- a/intern/ghost/intern/GHOST_XrSession.cpp +++ b/intern/ghost/intern/GHOST_XrSession.cpp @@ -307,6 +307,7 @@ GHOST_XrSession::LifeExpectancy GHOST_XrSession::handleStateChangeEvent( return SESSION_KEEP_ALIVE; } + /** \} */ /* State Management */ /* -------------------------------------------------------------------- */ diff --git a/intern/ghost/intern/GHOST_XrSession.h b/intern/ghost/intern/GHOST_XrSession.h index 83de44c8d8e..f5c0c04e65d 100644 --- a/intern/ghost/intern/GHOST_XrSession.h +++ b/intern/ghost/intern/GHOST_XrSession.h @@ -53,7 +53,7 @@ class GHOST_XrSession { void draw(void *draw_customdata); /** Action functions to be called pre-session start. - * Note: The "destroy" functions can also be called post-session start. */ + * NOTE: The "destroy" functions can also be called post-session start. */ bool createActionSet(const GHOST_XrActionSetInfo &info); void destroyActionSet(const char *action_set_name); bool createActions(const char *action_set_name, uint32_t count, const GHOST_XrActionInfo *infos); |