File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
src/commonMain/kotlin/com/kdroid/composetray/lib/windows Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -62,10 +62,16 @@ class WindowsOutsideClickWatcher(
6262 if (win != null && win.isShowing) {
6363 val winLoc = try { win.locationOnScreen } catch (_: Throwable ) { null }
6464 if (winLoc != null ) {
65- val wx = winLoc.x
66- val wy = winLoc.y
67- val ww = win.width
68- val wh = win.height
65+ // Get the graphics configuration to determine the DPI scale
66+ val scale = try {
67+ win.graphicsConfiguration?.defaultTransform?.scaleX ? : 1.0
68+ } catch (_: Throwable ) { 1.0 }
69+
70+ // Convert window bounds from logical to physical pixels
71+ val wx = (winLoc.x * scale).toInt()
72+ val wy = (winLoc.y * scale).toInt()
73+ val ww = (win.width * scale).toInt()
74+ val wh = (win.height * scale).toInt()
6975
7076 val insideWindow = px in wx until (wx + ww) && py in wy until (wy + wh)
7177 val ignored = ignorePointPredicate?.invoke(px, py) == true
You can’t perform that action at this time.
0 commit comments