fixed api updates

This commit is contained in:
Robinson 2023-08-20 13:40:57 +02:00
parent 56b7230b26
commit d9236a7b15
No known key found for this signature in database
GPG Key ID: 8E7DB78588BD6F5C
2 changed files with 13 additions and 8 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2015 dorkbox, llc * Copyright 2023 dorkbox, llc
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -141,7 +141,7 @@ internal class DesktopNotify(override val notification: Notify) : JWindow(), Not
* have to adjust for offsets when the window-manager has a toolbar that consumes space and prevents overlap. * have to adjust for offsets when the window-manager has a toolbar that consumes space and prevents overlap.
*/ */
private fun calculateOffset(showFromTop: Boolean, point: Point): Int { private fun calculateOffset(showFromTop: Boolean, point: Point): Int {
val gc = ScreenUtil.getMonitorAtLocation(point).defaultConfiguration val gc = ScreenUtil.getMonitorAtLocation(point)?.defaultConfiguration ?: return 0
val screenInsets = Toolkit.getDefaultToolkit().getScreenInsets(gc) val screenInsets = Toolkit.getDefaultToolkit().getScreenInsets(gc)
if (showFromTop) { if (showFromTop) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2015 dorkbox, llc * Copyright 2023 dorkbox, llc
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package dorkbox.notify
import dorkbox.swingActiveRender.SwingActiveRender import dorkbox.swingActiveRender.SwingActiveRender
import dorkbox.tweenEngine.TweenEngine.Companion.create import dorkbox.tweenEngine.TweenEngine.Companion.create
import dorkbox.util.ScreenUtil import dorkbox.util.ScreenUtil
import java.awt.GraphicsDevice
import java.awt.GraphicsEnvironment import java.awt.GraphicsEnvironment
import java.awt.MouseInfo import java.awt.MouseInfo
import java.awt.Rectangle import java.awt.Rectangle
@ -37,11 +38,15 @@ internal object LAFUtil {
val RANDOM = Random() val RANDOM = Random()
fun getGraphics(screen: Int): Rectangle { fun getGraphics(screen: Int): Rectangle {
val device = if (screen == Short.MIN_VALUE.toInt()) { var device: GraphicsDevice? = null
if (screen == Short.MIN_VALUE.toInt()) {
// set screen position based on mouse // set screen position based on mouse
val mouseLocation = MouseInfo.getPointerInfo().location val mouseLocation = MouseInfo.getPointerInfo().location
ScreenUtil.getMonitorAtLocation(mouseLocation) device = ScreenUtil.getMonitorAtLocation(mouseLocation)
} else { }
if (device == null) {
// set screen position based on specified screen // set screen position based on specified screen
var screenNumber = screen var screenNumber = screen
val ge = GraphicsEnvironment.getLocalGraphicsEnvironment() val ge = GraphicsEnvironment.getLocalGraphicsEnvironment()
@ -53,10 +58,10 @@ internal object LAFUtil {
screenNumber = screenDevices.size - 1 screenNumber = screenDevices.size - 1
} }
screenDevices[screenNumber] device = screenDevices[screenNumber]
} }
return device.defaultConfiguration.bounds return device!!.defaultConfiguration.bounds
} }
// only called on the swing EDT thread // only called on the swing EDT thread