diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mac.m | 23 | ||||
-rw-r--r-- | src/mac_cairo.m | 5 | ||||
-rw-r--r-- | src/win.c | 25 | ||||
-rw-r--r-- | src/x11.c | 50 |
4 files changed, 55 insertions, 48 deletions
@@ -97,10 +97,12 @@ updateViewRect(PuglView* view) const NSRect contentPx = nsRectFromPoints(view, contentPt); const double screenHeight = screenFramePx.size.height; - view->frame.x = contentPx.origin.x; - view->frame.y = screenHeight - contentPx.origin.y - contentPx.size.height; - view->frame.width = contentPx.size.width; - view->frame.height = contentPx.size.height; + view->frame.x = (PuglCoord)contentPx.origin.x; + view->frame.y = + (PuglCoord)(screenHeight - contentPx.origin.y - contentPx.size.height); + + view->frame.width = (PuglSpan)contentPx.size.width; + view->frame.height = (PuglSpan)contentPx.size.height; } } @@ -207,10 +209,10 @@ updateViewRect(PuglView* view) const PuglExposeEvent ev = { PUGL_EXPOSE, 0, - rect.origin.x * scaleFactor, - rect.origin.y * scaleFactor, - rect.size.width * scaleFactor, - rect.size.height * scaleFactor, + (PuglCoord)(rect.origin.x * scaleFactor), + (PuglCoord)(rect.origin.y * scaleFactor), + (PuglSpan)(rect.size.width * scaleFactor), + (PuglSpan)(rect.size.height * scaleFactor), }; PuglEvent exposeEvent; @@ -985,8 +987,9 @@ puglRealize(PuglView* view) view->frame.width = defaultSize.width; view->frame.height = defaultSize.height; - view->frame.x = screenWidthPx / 2.0 - view->frame.width / 2.0; - view->frame.y = screenHeightPx / 2.0 - view->frame.height / 2.0; + + view->frame.x = (PuglCoord)((screenWidthPx - view->frame.width) / 2.0); + view->frame.y = (PuglCoord)((screenHeightPx - view->frame.height) / 2.0); } const NSRect framePx = rectToNsRect(view->frame); diff --git a/src/mac_cairo.m b/src/mac_cairo.m index 33fc89a..e269955 100644 --- a/src/mac_cairo.m +++ b/src/mac_cairo.m @@ -89,7 +89,10 @@ puglMacCairoEnter(PuglView* view, const PuglExposeEvent* expose) const double scale = 1.0 / [[NSScreen mainScreen] backingScaleFactor]; CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort]; - const CGSize sizePx = {view->frame.width, view->frame.height}; + + const CGSize sizePx = {(CGFloat)view->frame.width, + (CGFloat)view->frame.height}; + const CGSize sizePt = CGContextConvertSizeToUserSpace(context, sizePx); // Convert coordinates to standard Cairo space @@ -482,14 +482,14 @@ handleConfigure(PuglView* view, PuglEvent* event) const LONG width = rect.right - rect.left; const LONG height = rect.bottom - rect.top; - view->frame.x = rect.left; - view->frame.y = rect.top; + view->frame.x = (PuglCoord)rect.left; + view->frame.y = (PuglCoord)rect.top; event->configure.type = PUGL_CONFIGURE; - event->configure.x = view->frame.x; - event->configure.y = view->frame.y; - event->configure.width = width; - event->configure.height = height; + event->configure.x = (PuglCoord)view->frame.x; + event->configure.y = (PuglCoord)view->frame.y; + event->configure.width = (PuglSpan)width; + event->configure.height = (PuglSpan)height; return rect; } @@ -638,10 +638,10 @@ handleMessage(PuglView* view, UINT message, WPARAM wParam, LPARAM lParam) case WM_PAINT: GetUpdateRect(view->impl->hwnd, &rect, false); event.expose.type = PUGL_EXPOSE; - event.expose.x = rect.left; - event.expose.y = rect.top; - event.expose.width = rect.right - rect.left; - event.expose.height = rect.bottom - rect.top; + event.expose.x = (PuglCoord)rect.left; + event.expose.y = (PuglCoord)rect.top; + event.expose.width = (PuglSpan)(rect.right - rect.left); + event.expose.height = (PuglSpan)(rect.bottom - rect.top); break; case WM_ERASEBKGND: return true; @@ -1200,8 +1200,9 @@ puglWinCreateWindow(PuglView* const view, view->frame.width = defaultSize.width; view->frame.height = defaultSize.height; - view->frame.x = (screenWidth - view->frame.width) / 2.0; - view->frame.y = (screenHeight - view->frame.height) / 2.0; + + view->frame.x = (PuglCoord)((screenWidth - view->frame.width) / 2); + view->frame.y = (PuglCoord)((screenHeight - view->frame.height) / 2); } // The meaning of "parent" depends on the window type (WS_CHILD) @@ -339,12 +339,12 @@ puglRealize(PuglView* const view) } // Center top-level windows if a position has not been set - if (!view->parent && view->frame.x <= 0.0 && view->frame.y <= 0.0) { + if (!view->parent && !view->frame.x && !view->frame.y) { const int screenWidth = DisplayWidth(display, screen); const int screenHeight = DisplayHeight(display, screen); - view->frame.x = screenWidth / 2.0 - view->frame.width / 2.0; - view->frame.y = screenHeight / 2.0 - view->frame.height / 2.0; + view->frame.x = (PuglCoord)((screenWidth - view->frame.width) / 2); + view->frame.y = (PuglCoord)((screenHeight - view->frame.height) / 2); } // Configure the backend to get the visual info @@ -374,10 +374,10 @@ puglRealize(PuglView* const view) // Create the window impl->win = XCreateWindow(display, parent, - (int)view->frame.x, - (int)view->frame.y, - (unsigned)view->frame.width, - (unsigned)view->frame.height, + view->frame.x, + view->frame.y, + view->frame.width, + view->frame.height, 0, impl->vi->depth, InputOutput, @@ -698,17 +698,17 @@ translateEvent(PuglView* const view, XEvent xevent) break; case ConfigureNotify: event.type = PUGL_CONFIGURE; - event.configure.x = xevent.xconfigure.x; - event.configure.y = xevent.xconfigure.y; - event.configure.width = xevent.xconfigure.width; - event.configure.height = xevent.xconfigure.height; + event.configure.x = (PuglCoord)xevent.xconfigure.x; + event.configure.y = (PuglCoord)xevent.xconfigure.y; + event.configure.width = (PuglSpan)xevent.xconfigure.width; + event.configure.height = (PuglSpan)xevent.xconfigure.height; break; case Expose: event.type = PUGL_EXPOSE; - event.expose.x = xevent.xexpose.x; - event.expose.y = xevent.xexpose.y; - event.expose.width = xevent.xexpose.width; - event.expose.height = xevent.xexpose.height; + event.expose.x = (PuglCoord)xevent.xexpose.x; + event.expose.y = (PuglCoord)xevent.xexpose.y; + event.expose.width = (PuglSpan)xevent.xexpose.width; + event.expose.height = (PuglSpan)xevent.xexpose.height; break; case MotionNotify: event.type = PUGL_MOTION; @@ -1031,8 +1031,8 @@ mergeExposeEvents(PuglExposeEvent* const dst, const PuglExposeEvent* const src) dst->x = MIN(dst->x, src->x); dst->y = MIN(dst->y, src->y); - dst->width = max_x - dst->x; - dst->height = max_y - dst->y; + dst->width = (PuglSpan)(max_x - dst->x); + dst->height = (PuglSpan)(max_y - dst->y); } } @@ -1240,10 +1240,10 @@ dispatchX11Events(PuglWorld* const world) // Build an initial configure event in case the WM doesn't send one PuglEvent configureEvent = {{PUGL_CONFIGURE, 0}}; - configureEvent.configure.x = (double)attrs.x; - configureEvent.configure.y = (double)attrs.y; - configureEvent.configure.width = (double)attrs.width; - configureEvent.configure.height = (double)attrs.height; + configureEvent.configure.x = (PuglCoord)attrs.x; + configureEvent.configure.y = (PuglCoord)attrs.y; + configureEvent.configure.width = (PuglSpan)attrs.width; + configureEvent.configure.height = (PuglSpan)attrs.height; // Dispatch an initial configure (if necessary), then the map event st0 = puglDispatchEvent(view, &configureEvent); @@ -1369,10 +1369,10 @@ puglSetFrame(PuglView* const view, const PuglRect frame) if (view->impl->win) { if (!XMoveResizeWindow(view->world->impl->display, view->impl->win, - (int)frame.x, - (int)frame.y, - (unsigned)frame.width, - (unsigned)frame.height)) { + frame.x, + frame.y, + frame.width, + frame.height)) { return PUGL_UNKNOWN_ERROR; } } |