[Bf-blender-cvs] [95162e71578] master: Cleanup: add missing braces for GHOST/Win32

Campbell Barton noreply at git.blender.org
Sat Aug 27 05:12:36 CEST 2022


Commit: 95162e715788611822b18ab40bf75e42978baadc
Author: Campbell Barton
Date:   Sat Aug 27 13:11:34 2022 +1000
Branches: master
https://developer.blender.org/rB95162e715788611822b18ab40bf75e42978baadc

Cleanup: add missing braces for GHOST/Win32

===================================================================

M	intern/ghost/intern/GHOST_SystemWin32.cpp
M	intern/ghost/intern/GHOST_WindowWin32.cpp

===================================================================

diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp
index 2188aa11235..43ce5d0b281 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemWin32.cpp
@@ -113,11 +113,12 @@ static void initRawInput()
   devices[1].usUsage = 0x08;
 #endif
 
-  if (RegisterRawInputDevices(devices, DEVICE_COUNT, sizeof(RAWINPUTDEVICE)))
-    ; /* yay! */
-  else
+  if (RegisterRawInputDevices(devices, DEVICE_COUNT, sizeof(RAWINPUTDEVICE))) {
+    /* Success. */
+  }
+  else {
     GHOST_PRINTF("could not register for RawInput: %d\n", (int)GetLastError());
-
+  }
 #undef DEVICE_COUNT
 }
 
@@ -431,8 +432,9 @@ GHOST_TSuccess GHOST_SystemWin32::getCursorPosition(int32_t &x, int32_t &y) cons
 
 GHOST_TSuccess GHOST_SystemWin32::setCursorPosition(int32_t x, int32_t y)
 {
-  if (!::GetActiveWindow())
+  if (!::GetActiveWindow()) {
     return GHOST_kFailure;
+  }
   return ::SetCursorPos(x, y) == TRUE ? GHOST_kSuccess : GHOST_kFailure;
 }
 
@@ -455,10 +457,12 @@ GHOST_TSuccess GHOST_SystemWin32::getModifierKeys(GHOST_ModifierKeys &keys) cons
 
   bool lwindown = HIBYTE(::GetKeyState(VK_LWIN)) != 0;
   bool rwindown = HIBYTE(::GetKeyState(VK_RWIN)) != 0;
-  if (lwindown || rwindown)
+  if (lwindown || rwindown) {
     keys.set(GHOST_kModifierKeyOS, true);
-  else
+  }
+  else {
     keys.set(GHOST_kModifierKeyOS, false);
+  }
   return GHOST_kSuccess;
 }
 
@@ -978,7 +982,7 @@ void GHOST_SystemWin32::processPointerEvent(
   }
 
   switch (type) {
-    case WM_POINTERUPDATE:
+    case WM_POINTERUPDATE: {
       /* Coalesced pointer events are reverse chronological order, reorder chronologically.
        * Only contiguous move events are coalesced. */
       for (uint32_t i = pointerInfo.size(); i-- > 0;) {
@@ -993,7 +997,8 @@ void GHOST_SystemWin32::processPointerEvent(
       /* Leave event unhandled so that system cursor is moved. */
 
       break;
-    case WM_POINTERDOWN:
+    }
+    case WM_POINTERDOWN: {
       /* Move cursor to point of contact because GHOST_EventButton does not include position. */
       system->pushEvent(new GHOST_EventCursor(pointerInfo[0].time,
                                               GHOST_kEventCursorMove,
@@ -1012,7 +1017,8 @@ void GHOST_SystemWin32::processPointerEvent(
       eventHandled = true;
 
       break;
-    case WM_POINTERUP:
+    }
+    case WM_POINTERUP: {
       system->pushEvent(new GHOST_EventButton(pointerInfo[0].time,
                                               GHOST_kEventButtonUp,
                                               window,
@@ -1024,8 +1030,10 @@ void GHOST_SystemWin32::processPointerEvent(
       eventHandled = true;
 
       break;
-    default:
+    }
+    default: {
       break;
+    }
   }
 }
 
@@ -1224,9 +1232,7 @@ GHOST_Event *GHOST_SystemWin32::processWindowSizeEvent(GHOST_WindowWin32 *window
     system->dispatchEvents();
     return NULL;
   }
-  else {
-    return sizeEvent;
-  }
+  return sizeEvent;
 }
 
 GHOST_Event *GHOST_SystemWin32::processWindowEvent(GHOST_TEventType type,
@@ -1313,11 +1319,12 @@ bool GHOST_SystemWin32::processNDOF(RAWINPUT const &raw)
     info.cbSize = infoSize;
 
     GetRawInputDeviceInfo(raw.header.hDevice, RIDI_DEVICEINFO, &info, &infoSize);
-    if (info.dwType == RIM_TYPEHID)
+    if (info.dwType == RIM_TYPEHID) {
       m_ndofManager->setDevice(info.hid.dwVendorId, info.hid.dwProductId);
-    else
+    }
+    else {
       GHOST_PRINT("<!> not a HID device... mouse/kb perhaps?\n");
-
+    }
     firstEvent = false;
   }
 
@@ -1460,7 +1467,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) {
-            case RIM_TYPEKEYBOARD:
+            case RIM_TYPEKEYBOARD: {
               event = processKeyEvent(window, raw);
               if (!event) {
                 GHOST_PRINT("GHOST_SystemWin32::wndProc: key event ");
@@ -1468,12 +1475,14 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
                 GHOST_PRINT(" key ignored\n");
               }
               break;
+            }
 #ifdef WITH_INPUT_NDOF
-            case RIM_TYPEHID:
+            case RIM_TYPEHID: {
               if (system->processNDOF(raw)) {
                 eventHandled = true;
               }
               break;
+            }
 #endif
           }
           break;
@@ -1536,11 +1545,11 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
         case WM_SYSKEYDOWN:
         case WM_KEYUP:
         case WM_SYSKEYUP:
-        /* These functions were replaced by #WM_INPUT. */
+          /* These functions were replaced by #WM_INPUT. */
         case WM_CHAR:
-        /* The #WM_CHAR message is posted to the window with the keyboard focus when
-         * a WM_KEYDOWN message is translated by the #TranslateMessage function.
-         * WM_CHAR contains the character code of the key that was pressed. */
+          /* The #WM_CHAR message is posted to the window with the keyboard focus when
+           * a WM_KEYDOWN message is translated by the #TranslateMessage function.
+           * WM_CHAR contains the character code of the key that was pressed. */
         case WM_DEADCHAR:
           /* The #WM_DEADCHAR message is posted to the window with the keyboard focus when a
            * WM_KEYUP message is translated by the #TranslateMessage function. WM_DEADCHAR
@@ -1551,18 +1560,19 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
            * then typing the O key. */
           break;
         case WM_SYSDEADCHAR:
-        /* The #WM_SYSDEADCHAR message is sent to the window with the keyboard focus when
-         * a WM_SYSKEYDOWN message is translated by the #TranslateMessage function.
-         * WM_SYSDEADCHAR specifies the character code of a system dead key - that is,
-         * a dead key that is pressed while holding down the alt key. */
-        case WM_SYSCHAR:
+          /* The #WM_SYSDEADCHAR message is sent to the window with the keyboard focus when
+           * a WM_SYSKEYDOWN message is translated by the #TranslateMessage function.
+           * WM_SYSDEADCHAR specifies the character code of a system dead key - that is,
+           * a dead key that is pressed while holding down the alt key. */
+        case WM_SYSCHAR: {
           /* #The WM_SYSCHAR message is sent to the window with the keyboard focus when
            * a WM_SYSCHAR message is translated by the #TranslateMessage function.
            * WM_SYSCHAR specifies the character code of a dead key - that is,
            * a dead key that is pressed while holding down the alt key.
            * To prevent the sound, #DefWindowProc must be avoided by return. */
           break;
-        case WM_SYSCOMMAND:
+        }
+        case WM_SYSCOMMAND: {
           /* The #WM_SYSCOMMAND message is sent to the window when system commands such as
            * 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.
@@ -1571,9 +1581,10 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
            * OS. To obtain the correct result when testing the value of wParam, an application must
            * combine the value 0xFFF0 with the wParam value by using the bit-wise AND operator. */
           switch (wParam & 0xFFF0) {
-            case SC_KEYMENU:
+            case SC_KEYMENU: {
               eventHandled = true;
               break;
+            }
             case SC_RESTORE: {
               ::ShowWindow(hwnd, SW_RESTORE);
               window->setState(window->getState());
@@ -1604,6 +1615,7 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
             }
           }
           break;
+        }
         /* ========================
          * Wintab events, processed
          * ======================== */
@@ -1658,44 +1670,53 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
           eventHandled = true;
           break;
         }
-        case WT_PACKET:
+        case WT_PACKET: {
           processWintabEvent(window);
           eventHandled = true;
           break;
+        }
         /* ====================
          * Wintab events, debug
          * ==================== */
-        case WT_CTXOPEN:
+        case WT_CTXOPEN: {
           WINTAB_PRINTF("HWND %p HCTX %p WT_CTXOPEN\n", window->getHWND(), (void *)wParam);
           break;
-        case WT_CTXCLOSE:
+        }
+        case WT_CTXCLOSE: {
           WINTAB_PRINTF("HWND %p HCTX %p WT_CTXCLOSE\n", window->getHWND(), (void *)wParam);
           break;
-        case WT_CTXUPDATE:
+        }
+        case WT_CTXUPDATE: {
           WINTAB_PRINTF("HWND %p HCTX %p WT_CTXUPDATE\n", window->getHWND(), (void *)wParam);
           break;
-        case WT_CTXOVERLAP:
+        }
+        case WT_CTXOVERLAP: {
           WINTAB_PRINTF("HWND %p HCTX %p WT_CTXOVERLAP", window->getHWND(), (void *)wParam);
           switch (lParam) {
-            case CXS_DISABLED:
+            case CXS_DISABLED: {
               WINTAB_PRINTF(" CXS_DISABLED\n");
               break;
-            case CXS_OBSCURED:
+            }
+            case CXS_OBSCURED: {
               WINTAB_PRINTF(" CXS_OBSCURED\n");
               break;
-            case CXS_ONTOP:
+            }
+            case CXS_ONTOP: {
               WINTAB_PRINTF(" CXS_ONTOP\n");
               break;
+            }
           }
           break;
+        }
         /* =========================
          * Pointer events, processed
          * ========================= */
         case WM_POINTERUPDATE:
         case WM_POINTERDOWN:
-        case WM_POINTERUP:
+        case WM_POINTERUP: {
           processPointerEvent(msg, window, wParam, lParam, eventHandled);
           break;
+        }
         case WM_POINTERLEAVE: {
           uint32_t pointerId = GET_POINTERID_WPARAM(wParam);
           POINTER_INFO pointerInfo;
@@ -171

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list