Skip to content
This repository has been archived by the owner on Jul 8, 2022. It is now read-only.

Commit

Permalink
Fix windows coordinates on the JVM
Browse files Browse the repository at this point in the history
  • Loading branch information
soywiz committed Feb 16, 2019
1 parent e222dff commit 4d2643f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions korgw/src/jvmMain/kotlin/com/soywiz/korgw/DefaultGameWindowJvm.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ actual val DefaultGameWindow: GameWindow = object : GameWindow() {
override val ag: AGAwt = AGAwt(AGConfig())

init {
frame.add(ag.glcanvas)
//frame.contentPane.layout = BorderLayout()
//frame.contentPane.add(JPanel(), BorderLayout.PAGE_START)
//frame.contentPane.add(ag.glcanvas, BorderLayout.CENTER)
frame.contentPane.add(ag.glcanvas)
ag.glcanvas.requestFocusInWindow()
}

Expand All @@ -45,9 +48,13 @@ actual val DefaultGameWindow: GameWindow = object : GameWindow() {
override fun setSize(width: Int, height: Int) {
this.width = width
this.height = height
frame.setSize(width, height)
frame.contentPane.preferredSize = Dimension(width, height)
//frame.setSize(width, height)
frame.pack()
frame.setLocationRelativeTo(null)

//println(ag.glcanvas.size)

//val screenSize = Toolkit.getDefaultToolkit().screenSize
//frame.setPosition(
// (screenSize.width - value.width) / 2,
Expand Down Expand Up @@ -359,7 +366,7 @@ actual val DefaultGameWindow: GameWindow = object : GameWindow() {

frame.addComponentListener(object : ComponentAdapter() {
override fun componentResized(e: ComponentEvent) {
dispatchReshapeEvent(0, 0, e.component.width, e.component.height)
dispatchReshapeEvent(0, 0, ag.glcanvas.width, ag.glcanvas.height)
}
})
launchAsap(coroutineDispatcher) {
Expand Down

0 comments on commit 4d2643f

Please sign in to comment.