diff options
author | David Robillard <d@drobilla.net> | 2025-01-23 17:00:37 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2025-01-23 18:02:52 -0500 |
commit | ef551ed4b85bc29b3eb48775faeadcf41596c40a (patch) | |
tree | 9ce41788cd4c06b9e9e3ce3f6fbfa01cd4931e8b /src/mac.m | |
parent | d7a93950b3af397580572adf2e366f3b162104a9 (diff) | |
download | pugl-ef551ed4b85bc29b3eb48775faeadcf41596c40a.tar.gz pugl-ef551ed4b85bc29b3eb48775faeadcf41596c40a.tar.bz2 pugl-ef551ed4b85bc29b3eb48775faeadcf41596c40a.zip |
Replace puglPostRedisplayRect() with puglObscureRegion()
Diffstat (limited to 'src/mac.m')
-rw-r--r-- | src/mac.m | 30 |
1 files changed, 23 insertions, 7 deletions
@@ -7,6 +7,7 @@ #include "mac.h" #include "internal.h" +#include "macros.h" #include "platform.h" #include "pugl/pugl.h" @@ -1651,15 +1652,30 @@ puglObscureView(PuglView* view) } PuglStatus -puglPostRedisplayRect(PuglView* view, const PuglRect rect) +puglObscureRegion(PuglView* view, + const int x, + const int y, + const unsigned width, + const unsigned height) { - const NSRect rectPx = { - {(double)rect.x, - (double)view->lastConfigure.height - (rect.y + rect.height)}, - {(double)rect.width, (double)rect.height}, - }; + if (!puglIsValidPosition(x, y) || !puglIsValidSize(width, height)) { + return PUGL_BAD_PARAMETER; + } + + const PuglSpan viewHeight = view->lastConfigure.height; + + const int cx = MAX(0, x); + const int cy = MAX(0, viewHeight - y - (int)height); + const unsigned cw = MIN(view->lastConfigure.width, width); + const unsigned ch = MIN(view->lastConfigure.height, height); - [view->impl->drawView setNeedsDisplayInRect:nsRectToPoints(view, rectPx)]; + if (cw == view->lastConfigure.width && ch == view->lastConfigure.height) { + [view->impl->drawView setNeedsDisplay:YES]; + } else { + const NSRect rectPx = NSMakeRect(cx, cy, cw, ch); + + [view->impl->drawView setNeedsDisplayInRect:nsRectToPoints(view, rectPx)]; + } return PUGL_SUCCESS; } |