From 913057b61d319314b18904b94ac47e2323d041d0 Mon Sep 17 00:00:00 2001 From: Graham Date: Sat, 31 Aug 2019 20:08:16 +0100 Subject: [PATCH] Fix JagGLLayer frame in resizable mode --- gl-natives/src/main/c/jaggl.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gl-natives/src/main/c/jaggl.c b/gl-natives/src/main/c/jaggl.c index 13d4692f..c8081f2f 100644 --- a/gl-natives/src/main/c/jaggl.c +++ b/gl-natives/src/main/c/jaggl.c @@ -1067,10 +1067,15 @@ JNIEXPORT jboolean JNICALL Java_jaggl_context_choosePixelFormat1(JNIEnv *env, jc platformInfo.layer = jaggl_layer; /* - * TODO(gpe): this doesn't work in resizable mode, where the Canvas - * only fills part of the Frame. + * XXX(gpe): the DSI bounds include the top/left insets, which we + * need to subtract here. Unfortunately, we can't access them here + * easily. Ignoring the left inset and hard-coding y to zero work, + * but only because windows don't have left borders and there is + * nothing above the Canvas in the Frame. */ - jaggl_layer.frame = frame; + jint x = dsi->bounds.x; /* should be dsi->bounds.x - insets.left */ + jint y = 0; /* should be dsi->bounds.y - insets.top */ + jaggl_layer.frame = NSMakeRect(x, platformInfo.windowLayer.bounds.size.height - y - dsi->bounds.height, dsi->bounds.width, dsi->bounds.height); [jaggl_layer setNeedsDisplay]; });