Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Commit

Permalink
PRJ-139 Support endpoint of main windows
Browse files Browse the repository at this point in the history
  • Loading branch information
SerVB committed Oct 9, 2020
1 parent 804d358 commit ff47340
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ intellijPluginVersion=0.4.14
javassistVersion=3.26.0-GA
kotlinVersion=1.4.0
mockitoKotlinVersion=2.2.0
projectorClientVersion=de987ed4
projectorClientVersion=766f2a6b
targetJvm=1.8
# Give JitPack some time to build projector-client:
systemProp.org.gradle.internal.http.connectionTimeout=180000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,16 @@ class ProjectorServer private constructor(
override fun onError(connection: WebSocket?, e: Exception) {
logger.error(e) { "onError" }
}

override fun getMainWindows(): List<MainWindow> = ProjectorServer.getMainWindows().map {
MainWindow(
title = it.title,
pngBase64Icon = it.icons
?.firstOrNull()
?.let { imageId -> ProjectorImageCacher.getImage(imageId as ImageId) as? ImageData.PngBase64 }
?.pngBase64,
)
}
}

private lateinit var updateThread: Thread
Expand Down Expand Up @@ -839,14 +849,14 @@ class ProjectorServer private constructor(
setupRepaintManager()
}

private fun getMainWindows(): List<Component> {
val ideWindows = PWindow.windows.filter { it.windowType == WindowType.IDEA_WINDOW }.map(PWindow::target)
private fun getMainWindows(): List<PWindow> {
val ideWindows = PWindow.windows.filter { it.windowType == WindowType.IDEA_WINDOW }

if (ideWindows.isNotEmpty()) {
return ideWindows
}

return PWindow.windows.firstOrNull()?.target?.let(::listOf).orEmpty()
return PWindow.windows.firstOrNull()?.let(::listOf).orEmpty()
}

private fun Component.shiftBounds(shift: AwtPoint): CommonRectangle {
Expand All @@ -869,7 +879,7 @@ class ProjectorServer private constructor(
}

private fun calculateMainWindowShift() {
getMainWindows().firstOrNull()?.let { window ->
getMainWindows().firstOrNull()?.target?.let { window ->
synchronized(window.treeLock) {
var x = 0.0
var y = 0.0
Expand Down Expand Up @@ -897,7 +907,7 @@ class ProjectorServer private constructor(
ge.setSize(width, height)
}

getMainWindows().let { mainWindows ->
getMainWindows().map(PWindow::target).let { mainWindows ->
SwingUtilities.invokeLater {
mainWindows.forEach {
val point = AwtPoint(PGraphicsDevice.clientShift)
Expand Down

0 comments on commit ff47340

Please sign in to comment.