mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[settings] IJPL-248297 Fit non-modal window bounds to screen
Mirror DialogWrapper bounds fitting in NonModalWindowWrapper so restored or resized Settings windows stay within the visible screen after scale changes, including high-DPI Windows configurations. (cherry picked from commit 97316571ff6ec210d0a05c12abbd39d5d54a49e5) IJ-CR-217470 GitOrigin-RevId: 63031c7fb58812090f95d0e3c245430aa4f2210a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
c8b5d12aee
commit
913d7f0ee2
@@ -263,6 +263,13 @@ abstract class NonModalWindowWrapper(
|
||||
*/
|
||||
private fun fitWindowToScreen(window: Window) {
|
||||
clampMinimumSizeToScreen(window)
|
||||
window.bounds = fitBoundsToScreen(window.bounds)
|
||||
}
|
||||
|
||||
private fun fitBoundsToScreen(bounds: Rectangle): Rectangle {
|
||||
val rect = Rectangle(bounds)
|
||||
ScreenUtil.fitToScreen(rect)
|
||||
return rect
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -346,25 +353,22 @@ abstract class NonModalWindowWrapper(
|
||||
}
|
||||
|
||||
override fun setSize(width: Int, height: Int) {
|
||||
val rect = Rectangle(location.x, location.y, width, height)
|
||||
ScreenUtil.fitToScreen(rect)
|
||||
super.setSize(rect.width, rect.height)
|
||||
val rect = fitBoundsToScreen(Rectangle(location.x, location.y, width, height))
|
||||
if (location.x != rect.x || location.y != rect.y) {
|
||||
setLocation(rect.x, rect.y)
|
||||
}
|
||||
super.setSize(rect.width, rect.height)
|
||||
}
|
||||
|
||||
override fun setBounds(x: Int, y: Int, width: Int, height: Int) {
|
||||
clampMinimumSizeToScreen(this)
|
||||
val rect = Rectangle(x, y, width, height)
|
||||
ScreenUtil.fitToScreen(rect)
|
||||
val rect = fitBoundsToScreen(Rectangle(x, y, width, height))
|
||||
super.setBounds(rect.x, rect.y, rect.width, rect.height)
|
||||
}
|
||||
|
||||
override fun setBounds(r: Rectangle) {
|
||||
clampMinimumSizeToScreen(this)
|
||||
ScreenUtil.fitToScreen(r)
|
||||
super.setBounds(r)
|
||||
super.setBounds(fitBoundsToScreen(r))
|
||||
}
|
||||
|
||||
override fun uiDataSnapshot(sink: DataSink): Unit = this@NonModalWindowWrapper.uiDataSnapshot(sink)
|
||||
@@ -378,25 +382,22 @@ abstract class NonModalWindowWrapper(
|
||||
}
|
||||
|
||||
override fun setSize(width: Int, height: Int) {
|
||||
val rect = Rectangle(location.x, location.y, width, height)
|
||||
ScreenUtil.fitToScreen(rect)
|
||||
super.setSize(rect.width, rect.height)
|
||||
val rect = fitBoundsToScreen(Rectangle(location.x, location.y, width, height))
|
||||
if (location.x != rect.x || location.y != rect.y) {
|
||||
setLocation(rect.x, rect.y)
|
||||
}
|
||||
super.setSize(rect.width, rect.height)
|
||||
}
|
||||
|
||||
override fun setBounds(x: Int, y: Int, width: Int, height: Int) {
|
||||
clampMinimumSizeToScreen(this)
|
||||
val rect = Rectangle(x, y, width, height)
|
||||
ScreenUtil.fitToScreen(rect)
|
||||
val rect = fitBoundsToScreen(Rectangle(x, y, width, height))
|
||||
super.setBounds(rect.x, rect.y, rect.width, rect.height)
|
||||
}
|
||||
|
||||
override fun setBounds(r: Rectangle) {
|
||||
clampMinimumSizeToScreen(this)
|
||||
ScreenUtil.fitToScreen(r)
|
||||
super.setBounds(r)
|
||||
super.setBounds(fitBoundsToScreen(r))
|
||||
}
|
||||
|
||||
override fun uiDataSnapshot(sink: DataSink): Unit = this@NonModalWindowWrapper.uiDataSnapshot(sink)
|
||||
|
||||
Reference in New Issue
Block a user