Commit 96d7ce0d authored by Roman Sedaikin's avatar Roman Sedaikin

Fixed skia layer location on macos.

parent f89c3902
...@@ -2,6 +2,8 @@ package org.jetbrains.skiko ...@@ -2,6 +2,8 @@ package org.jetbrains.skiko
import java.awt.Graphics import java.awt.Graphics
import java.awt.Canvas import java.awt.Canvas
import javax.swing.SwingUtilities.convertPoint
import javax.swing.SwingUtilities.getRootPane
open class HardwareLayer : Canvas(), Drawable { open class HardwareLayer : Canvas(), Drawable {
override fun paint(g: Graphics) { override fun paint(g: Graphics) {
...@@ -19,4 +21,8 @@ open class HardwareLayer : Canvas(), Drawable { ...@@ -19,4 +21,8 @@ open class HardwareLayer : Canvas(), Drawable {
external get external get
override val contentScale: Float override val contentScale: Float
get() = graphicsConfiguration.defaultTransform.scaleX.toFloat() get() = graphicsConfiguration.defaultTransform.scaleX.toFloat()
val absoluteX: Int
get() = convertPoint(this, x, y, getRootPane(this)).x
val absoluteY: Int
get() = convertPoint(this, x, y, getRootPane(this)).y
} }
\ No newline at end of file
...@@ -90,9 +90,6 @@ JavaVM *jvm = NULL; ...@@ -90,9 +90,6 @@ JavaVM *jvm = NULL;
- (void) syncLayersSize - (void) syncLayersSize
{ {
self.glLayer.bounds = self.container.bounds;
self.glLayer.frame = self.container.frame;
if (jvm != NULL) { if (jvm != NULL) {
JNIEnv *env; JNIEnv *env;
(*jvm)->AttachCurrentThread(jvm, (void **)&env, NULL); (*jvm)->AttachCurrentThread(jvm, (void **)&env, NULL);
...@@ -122,22 +119,22 @@ JavaVM *jvm = NULL; ...@@ -122,22 +119,22 @@ JavaVM *jvm = NULL;
static jmethodID getXMethod = NULL; static jmethodID getXMethod = NULL;
if (!getXMethod) if (!getXMethod)
{ {
getXMethod = (*env)->GetMethodID(env, wndClass, "getX", "()I"); getXMethod = (*env)->GetMethodID(env, wndClass, "getAbsoluteX", "()I");
} }
if (NULL == getXMethod) if (NULL == getXMethod)
{ {
NSLog(@"The method HardwareLayer.getX() not found!"); NSLog(@"The method HardwareLayer.getAbsoluteX() not found!");
return; return;
} }
static jmethodID getYMethod = NULL; static jmethodID getYMethod = NULL;
if (!getYMethod) if (!getYMethod)
{ {
getYMethod = (*env)->GetMethodID(env, wndClass, "getY", "()I"); getYMethod = (*env)->GetMethodID(env, wndClass, "getAbsoluteY", "()I");
} }
if (NULL == getYMethod) if (NULL == getYMethod)
{ {
NSLog(@"The method HardwareLayer.getY() not found!"); NSLog(@"The method HardwareLayer.getAbsoluteY() not found!");
return; return;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment