diff options
Diffstat (limited to 'win32')
-rw-r--r-- | win32/PlatWin.cxx | 8 | ||||
-rw-r--r-- | win32/ScintillaWin.cxx | 18 | ||||
-rw-r--r-- | win32/SurfaceD2D.cxx | 3 | ||||
-rw-r--r-- | win32/makefile | 1 |
4 files changed, 16 insertions, 14 deletions
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index 02f31cc5e..ff47c28ab 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -168,7 +168,7 @@ float GetDeviceScaleFactorWhenGdiScalingActive(HWND hWnd) noexcept { const HMONITOR hMonitor = MonitorFromWindowHandleScaling(hRootWnd); DEVICE_SCALE_FACTOR deviceScaleFactor; if (S_OK == fnGetScaleFactorForMonitor(hMonitor, &deviceScaleFactor)) - return static_cast<int>(deviceScaleFactor) / 100.f; + return static_cast<float>(static_cast<int>(deviceScaleFactor)) / 100.f; } } return 1.f; @@ -404,6 +404,8 @@ class CursorHelper { DWORD *pixels = nullptr; const int width; const int height; + const float scale; + static constexpr float baseSize = 32.0f; static constexpr float arrow[][2] = { { 32.0f - 12.73606f,32.0f - 19.04075f }, @@ -418,7 +420,7 @@ class CursorHelper { public: ~CursorHelper() = default; - CursorHelper(int width_, int height_) noexcept : width{width_}, height{height_} { + CursorHelper(int width_, int height_) noexcept : width{width_}, height{height_}, scale{ static_cast<float>(width) / baseSize } { // https://learn.microsoft.com/en-us/windows/win32/menurc/using-cursors#creating-a-cursor bm.Create({}, width, height, &pixels); } @@ -470,7 +472,6 @@ public: // Draw something on the bitmap section. constexpr size_t nPoints = std::size(arrow); D2D1_POINT_2F points[nPoints]{}; - const FLOAT scale = width/32.0f; for (size_t i = 0; i < nPoints; i++) { points[i].x = arrow[i][0] * scale; points[i].y = arrow[i][1] * scale; @@ -519,7 +520,6 @@ public: // Draw something on the DIB section. constexpr size_t nPoints = std::size(arrow); POINT points[nPoints]{}; - const float scale = width/32.0f; for (size_t i = 0; i < nPoints; i++) { points[i].x = std::lround(arrow[i][0] * scale); points[i].y = std::lround(arrow[i][1] * scale); diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index d6ae32736..f31d1291f 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -874,7 +874,7 @@ void ScintillaWin::CreateRenderTarget() { const RECT rc = GetClientRect(hw); const int integralDeviceScaleFactor = GetFirstIntegralMultipleDeviceScaleFactor(); - const FLOAT dpiTarget = dpiDefault * integralDeviceScaleFactor; + const FLOAT dpiTarget = dpiDefault * static_cast<float>(integralDeviceScaleFactor); const D2D1_RENDER_TARGET_PROPERTIES drtp = D2D1::RenderTargetProperties( D2D1_RENDER_TARGET_TYPE_DEFAULT, @@ -1009,7 +1009,7 @@ void ScintillaWin::DisplayCursor(Window::Cursor c) { c = static_cast<Window::Cursor>(cursorMode); } if (c == Window::Cursor::reverseArrow) { - ::SetCursor(reverseArrowCursor.Load(static_cast<UINT>(dpi * deviceScaleFactor))); + ::SetCursor(reverseArrowCursor.Load(static_cast<UINT>(static_cast<float>(dpi) * deviceScaleFactor))); } else { wMain.SetCursor(c); } @@ -2809,11 +2809,11 @@ constexpr int minTrailByte = 0x30; // CreateFoldMap creates a fold map by calling platform APIs so will differ between platforms. void CreateFoldMap(int codePage, FoldMap *foldingMap) { - for (int byte1 = highByteFirst; byte1 <= highByteLast; byte1++) { - const char ch1 = byte1 & 0xFF; // & 0xFF avoids warnings but has no real effect. + for (unsigned char byte1 = highByteLast; byte1 >= highByteFirst; byte1--) { + const char ch1 = byte1; if (DBCSIsLeadByte(codePage, ch1)) { - for (int byte2 = minTrailByte; byte2 <= highByteLast; byte2++) { - const char ch2 = byte2 & 0xFF; + for (unsigned char byte2 = highByteLast; byte2 >= minTrailByte; byte2--) { + const char ch2 = byte2; if (DBCSIsTrailByte(codePage, ch2)) { const DBCSPair pair{ ch1, ch2 }; const uint16_t index = DBCSIndex(ch1, ch2); @@ -3426,8 +3426,8 @@ LRESULT ScintillaWin::ImeOnReconvert(LPARAM lParam) { return 0; // No selection asks IME to fill target fields with its own value. - const int tgWlen = rc->dwTargetStrLen; - const int tgWstart = rc->dwTargetStrOffset / sizeof(wchar_t); + const size_t tgWlen = rc->dwTargetStrLen; + const size_t tgWstart = rc->dwTargetStrOffset / sizeof(wchar_t); std::string tgCompStart = StringEncode(rcFeed.substr(0, tgWstart), codePage); std::string tgComp = StringEncode(rcFeed.substr(tgWstart, tgWlen), codePage); @@ -3945,7 +3945,7 @@ void ScintillaWin::CTPaint(HWND hWnd) { // Create a Direct2D render target. - const FLOAT dpiTarget = dpiDefault * scaleFactor; + const FLOAT dpiTarget = dpiDefault * static_cast<float>(scaleFactor); const D2D1_RENDER_TARGET_PROPERTIES drtp = D2D1::RenderTargetProperties( D2D1_RENDER_TARGET_TYPE_DEFAULT, diff --git a/win32/SurfaceD2D.cxx b/win32/SurfaceD2D.cxx index fa8383a84..223d35fcf 100644 --- a/win32/SurfaceD2D.cxx +++ b/win32/SurfaceD2D.cxx @@ -1382,7 +1382,8 @@ HRESULT MeasurePositions(TextPositions &poses, const TextWide &tbuf, IDWriteText int ti=0; for (unsigned int ci=0; ci<count; ci++) { for (unsigned int inCluster=0; inCluster<clusterMetrics[ci].length; inCluster++) { - poses.buffer[ti++] = position + clusterMetrics[ci].width * (inCluster + 1) / clusterMetrics[ci].length; + const float proportion = static_cast<float>(inCluster + 1) / clusterMetrics[ci].length; + poses.buffer[ti++] = position + clusterMetrics[ci].width * proportion; } position += clusterMetrics[ci].width; } diff --git a/win32/makefile b/win32/makefile index 72634889f..5db9e6625 100644 --- a/win32/makefile +++ b/win32/makefile @@ -23,6 +23,7 @@ else # MinGW GCC LIBSMINGW = -lstdc++ STRIPOPTION = -s +WARNINGS += -Wconversion endif ARFLAGS = rc RANLIB ?= ranlib |