aboutsummaryrefslogtreecommitdiffstats
path: root/pugl/detail/win.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-11-03 19:15:05 +0100
committerDavid Robillard <d@drobilla.net>2019-11-03 21:03:18 +0100
commitbe838db18af13390cb9f705d36ab83396d2dd1e6 (patch)
treeb79ae242205607374132f3f9463c35783485d67e /pugl/detail/win.c
parentd9239872c71d117f78ce6c109cd9ab42e2d80c6b (diff)
downloadpugl-be838db18af13390cb9f705d36ab83396d2dd1e6.tar.gz
pugl-be838db18af13390cb9f705d36ab83396d2dd1e6.tar.bz2
pugl-be838db18af13390cb9f705d36ab83396d2dd1e6.zip
Remove redisplay flag and add puglPostRedisplayRect()
Diffstat (limited to 'pugl/detail/win.c')
-rw-r--r--pugl/detail/win.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/pugl/detail/win.c b/pugl/detail/win.c
index ee7eb01..d7026ae 100644
--- a/pugl/detail/win.c
+++ b/pugl/detail/win.c
@@ -26,6 +26,7 @@
#include <windows.h>
#include <windowsx.h>
+#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
@@ -719,15 +720,8 @@ puglWaitForEvent(PuglView* PUGL_UNUSED(view))
}
PUGL_API PuglStatus
-puglDispatchEvents(PuglWorld* world)
+puglDispatchEvents(PuglWorld* PUGL_UNUSED(world))
{
- for (size_t i = 0; i < world->numViews; ++i) {
- if (world->views[i]->redisplay) {
- UpdateWindow(world->views[i]->impl->hwnd);
- world->views[i]->redisplay = false;
- }
- }
-
/* Windows has no facility to process only currently queued messages, which
causes the event loop to run forever in cases like mouse movement where
the queue is constantly being filled with new messages. To work around
@@ -795,7 +789,19 @@ PuglStatus
puglPostRedisplay(PuglView* view)
{
InvalidateRect(view->impl->hwnd, NULL, false);
- view->redisplay = true;
+ return PUGL_SUCCESS;
+}
+
+PuglStatus
+puglPostRedisplayRect(PuglView* view, const PuglRect rect)
+{
+ const RECT r = {(long)floor(rect.x),
+ (long)floor(rect.y),
+ (long)ceil(rect.x + rect.width),
+ (long)ceil(rect.y + rect.height)};
+
+ InvalidateRect(view->impl->hwnd, &r, false);
+
return PUGL_SUCCESS;
}