File tree Expand file tree Collapse file tree 2 files changed +12
-23
lines changed
uno-awt/src/main/kotlin/uno/awt Expand file tree Collapse file tree 2 files changed +12
-23
lines changed Original file line number Diff line number Diff line change @@ -11,11 +11,10 @@ import uno.glfw.HWND
1111import uno.glfw.VSync
1212import uno.glfw.glfw
1313import java.awt.Canvas
14+ import java.awt.EventQueue
1415import java.awt.Graphics
1516import java.awt.event.ComponentAdapter
1617import java.awt.event.ComponentEvent
17- import java.lang.reflect.InvocationTargetException
18- import javax.swing.SwingUtilities
1918
2019
2120/* *
@@ -107,7 +106,9 @@ abstract class LwjglCanvas(val glDebug: Boolean = false) : Canvas() {
107106// }
108107 })
109108
110- SwingUtilities .invokeAndWait {
109+ if (EventQueue .isDispatchThread())
110+ surface = awt.getDrawingSurface(this )!!
111+ else EventQueue .invokeAndWait {
111112 surface = awt.getDrawingSurface(this )!!
112113 }
113114 }
@@ -309,30 +310,16 @@ abstract class LwjglCanvas(val glDebug: Boolean = false) : Canvas() {
309310
310311 animated = animate
311312
312- if (animate) {
313-
314- if (SwingUtilities .isEventDispatchThread()) {
315- val g = graphics
316- if (g != null ) {
313+ if (animate)
314+ graphics?.let { g ->
315+ if (EventQueue .isDispatchThread()) {
316+ paint(g)
317+ g.dispose()
318+ } else EventQueue .invokeAndWait {
317319 paint(g)
318320 g.dispose()
319- }
320- } else {
321- try {
322- SwingUtilities .invokeAndWait {
323- val g = graphics
324- if (g != null ) {
325- paint(g)
326- g.dispose()
327- }
328- }
329- } catch (ex: InterruptedException ) {
330- println (" Exception while starting viewer animation" )
331- } catch (ex: InvocationTargetException ) {
332- println (" Exception while starting viewer animation" )
333321 }
334322 }
335- }
336323 }
337324 }
338325
Original file line number Diff line number Diff line change @@ -32,6 +32,8 @@ fun JAWT.getDrawingSurface(canvas: Canvas): JAWTDrawingSurface? {
3232 return JAWTDrawingSurface .createSafe(result)
3333}
3434
35+
36+
3537inline class JawtLock (val int : Int ) {
3638 companion object {
3739 val ERROR = JawtLock (0x1 )
You can’t perform that action at this time.
0 commit comments