aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/pugl/detail/win.c51
-rw-r--r--include/pugl/detail/win_cairo.c5
-rw-r--r--include/pugl/detail/win_gl.c4
-rw-r--r--test/test_utils.h2
4 files changed, 28 insertions, 34 deletions
diff --git a/include/pugl/detail/win.c b/include/pugl/detail/win.c
index 078b0a0..84cca27 100644
--- a/include/pugl/detail/win.c
+++ b/include/pugl/detail/win.c
@@ -197,10 +197,9 @@ puglRealize(PuglView* view)
return PUGL_BAD_BACKEND;
}
- PuglStatus st;
- if ((st = view->backend->configure(view))) {
- return st;
- } else if ((st = view->backend->create(view))) {
+ PuglStatus st = PUGL_SUCCESS;
+ if ((st = view->backend->configure(view)) ||
+ (st = view->backend->create(view))) {
return st;
}
@@ -418,9 +417,9 @@ initKeyEvent(PuglEventKey* event,
const PuglKey special = keySymToSpecial(vkey);
if (special) {
if (ext && (special == PUGL_KEY_CTRL || special == PUGL_KEY_ALT)) {
- event->key = special + 1u; // Right hand key
+ event->key = (uint32_t)special + 1u; // Right hand key
} else {
- event->key = special;
+ event->key = (uint32_t)special;
}
} else if (!dead) {
// Translate unshifted key
@@ -511,33 +510,33 @@ constrainAspect(const PuglView* const view,
{
const float minA = (float)view->minAspectX / (float)view->minAspectY;
const float maxA = (float)view->maxAspectX / (float)view->maxAspectY;
- const int w = size->right - size->left;
- const int h = size->bottom - size->top;
- const float a = (float)w / (float)h;
+ const float w = (float)(size->right - size->left);
+ const float h = (float)(size->bottom - size->top);
+ const float a = w / h;
switch (wParam) {
case WMSZ_TOP:
- size->top = (a < minA ? (LONG)(size->bottom - w * minA) :
- a > maxA ? (LONG)(size->bottom - w * maxA) :
+ size->top = (a < minA ? (LONG)((float)size->bottom - w * minA) :
+ a > maxA ? (LONG)((float)size->bottom - w * maxA) :
size->top);
break;
case WMSZ_TOPRIGHT:
case WMSZ_RIGHT:
case WMSZ_BOTTOMRIGHT:
- size->right = (a < minA ? (LONG)(size->left + h * minA) :
- a > maxA ? (LONG)(size->left + h * maxA) :
+ size->right = (a < minA ? (LONG)((float)size->left + h * minA) :
+ a > maxA ? (LONG)((float)size->left + h * maxA) :
size->right);
break;
case WMSZ_BOTTOM:
- size->bottom = (a < minA ? (LONG)(size->top + w * minA) :
- a > maxA ? (LONG)(size->top + w * maxA) :
+ size->bottom = (a < minA ? (LONG)((float)size->top + w * minA) :
+ a > maxA ? (LONG)((float)size->top + w * maxA) :
size->bottom);
break;
case WMSZ_BOTTOMLEFT:
case WMSZ_LEFT:
case WMSZ_TOPLEFT:
- size->left = (a < minA ? (LONG)(size->right - h * minA) :
- a > maxA ? (LONG)(size->right - h * maxA) :
+ size->left = (a < minA ? (LONG)((float)size->right - h * minA) :
+ a > maxA ? (LONG)((float)size->right - h * maxA) :
size->left);
break;
}
@@ -546,15 +545,12 @@ constrainAspect(const PuglView* const view,
static LRESULT
handleMessage(PuglView* view, UINT message, WPARAM wParam, LPARAM lParam)
{
- PuglEvent event;
+ PuglEvent event = {{PUGL_NOTHING, 0}};
+ RECT rect = {0, 0, 0, 0};
+ POINT pt = {0, 0};
+ MINMAXINFO* mmi = NULL;
void* dummy_ptr = NULL;
- RECT rect;
- MINMAXINFO* mmi;
- POINT pt;
-
- memset(&event, 0, sizeof(event));
- event.any.type = PUGL_NOTHING;
if (InSendMessageEx(dummy_ptr)) {
event.any.flags |= PUGL_IS_SEND_EVENT;
}
@@ -686,14 +682,14 @@ handleMessage(PuglView* view, UINT message, WPARAM wParam, LPARAM lParam)
break;
case WM_MOUSEWHEEL:
initScrollEvent(&event, view, lParam);
- event.scroll.dy = GET_WHEEL_DELTA_WPARAM(wParam) / (float)WHEEL_DELTA;
+ event.scroll.dy = GET_WHEEL_DELTA_WPARAM(wParam) / (double)WHEEL_DELTA;
event.scroll.direction = (event.scroll.dy > 0
? PUGL_SCROLL_UP
: PUGL_SCROLL_DOWN);
break;
case WM_MOUSEHWHEEL:
initScrollEvent(&event, view, lParam);
- event.scroll.dx = GET_WHEEL_DELTA_WPARAM(wParam) / (float)WHEEL_DELTA;
+ event.scroll.dx = GET_WHEEL_DELTA_WPARAM(wParam) / (double)WHEEL_DELTA;
event.scroll.direction = (event.scroll.dx > 0
? PUGL_SCROLL_RIGHT
: PUGL_SCROLL_LEFT);
@@ -1094,7 +1090,8 @@ puglSetClipboard(PuglView* const view,
// Measure string and allocate global memory for clipboard
const char* str = (const char*)data;
const int wlen = MultiByteToWideChar(CP_UTF8, 0, str, -1, NULL, 0);
- HGLOBAL mem = GlobalAlloc(GMEM_MOVEABLE, (wlen + 1) * sizeof(wchar_t));
+ HGLOBAL mem = GlobalAlloc(GMEM_MOVEABLE,
+ (size_t)(wlen + 1) * sizeof(wchar_t));
if (!mem) {
CloseClipboard();
return PUGL_UNKNOWN_ERROR;
diff --git a/include/pugl/detail/win_cairo.c b/include/pugl/detail/win_cairo.c
index 1b9afb9..866569c 100644
--- a/include/pugl/detail/win_cairo.c
+++ b/include/pugl/detail/win_cairo.c
@@ -96,11 +96,10 @@ puglWinCairoOpen(PuglView* view)
PuglInternals* const impl = view->impl;
PuglWinCairoSurface* const surface = (PuglWinCairoSurface*)impl->surface;
- cairo_status_t st = CAIRO_STATUS_SUCCESS;
if (!(surface->surface = cairo_win32_surface_create(surface->drawDc)) ||
- (st = cairo_surface_status(surface->surface)) ||
+ cairo_surface_status(surface->surface) ||
!(surface->cr = cairo_create(surface->surface)) ||
- (st = cairo_status(surface->cr))) {
+ cairo_status(surface->cr)) {
return PUGL_CREATE_CONTEXT_FAILED;
}
diff --git a/include/pugl/detail/win_gl.c b/include/pugl/detail/win_gl.c
index 096c715..4f71d76 100644
--- a/include/pugl/detail/win_gl.c
+++ b/include/pugl/detail/win_gl.c
@@ -160,9 +160,7 @@ puglWinGlConfigure(PuglView* view)
// Set pixel format for fake window
const PuglWinPFD fakePfd = puglWinGetPixelFormatDescriptor(view->hints);
const int fakePfId = ChoosePixelFormat(fakeWin.hdc, &fakePfd);
- if (!fakePfId) {
- return puglWinError(&fakeWin, PUGL_SET_FORMAT_FAILED);
- } else if (!SetPixelFormat(fakeWin.hdc, fakePfId, &fakePfd)) {
+ if (!fakePfId || !SetPixelFormat(fakeWin.hdc, fakePfId, &fakePfd)) {
return puglWinError(&fakeWin, PUGL_SET_FORMAT_FAILED);
}
diff --git a/test/test_utils.h b/test/test_utils.h
index 42b9ef9..d86018c 100644
--- a/test/test_utils.h
+++ b/test/test_utils.h
@@ -52,7 +52,7 @@ logError(const char* fmt, ...)
{
fprintf(stderr, "error: ");
- va_list args;
+ va_list args; // NOLINT
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);