-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make resize area larger or configurable for undecorated windows #4574
Make resize area larger or configurable for undecorated windows #4574
Comments
We'll consider it. In the meanwhile, take a look at UndecoratedWindowResizer. You could:
|
Thank you for suggesting this workaround. I was able to get the exact behavior I want. However, I don't love the way I had to do it because I had to resort to reflection and I had make a copy of Here is what I did:
override fun setResizable(value: Boolean) {
super.setResizable(value)
undecoratedWindowResizer.enabled = isUndecorated && isResizable
} I wanted the LaunchedEffect(resizable) {
window.setResizable(resizable)
ComposeWindow::class
.declaredMembers
.single { it.name == "undecoratedWindowResizer" }
.run {
isAccessible = true
val undecoratedWindowResizer = call(window)!!
val enabled =
undecoratedWindowResizer::class.declaredMembers.single {
it.name == "enabled"
} as KMutableProperty
enabled.isAccessible = true
enabled.setter.call(undecoratedWindowResizer, false)
}
myUndecoratedWindowResizer.enabled = resizable
}
content()
myUndecoratedWindowResizer.Content(
modifier = Modifier.layoutId("UndecoratedWindowResizer")
) The end result is that I was able to customize my resizer just the way I wanted, but the process of doing so required reflection and the code doesn't look very stable or pretty. The main things I dislike about the code are:
I hope knowing my use case is helpful if your team ever decides to redesign some of this API. In the end, I needed to make two adjustments to my custom resizer:
/**
* See [[androidx.compose.ui.window.UndecoratedWindowResizer]]
* See https://github.com/JetBrains/compose-multiplatform/issues/4574#issuecomment-2037464649
* Purposes:
* I want to control the width of the resize areas
* I want the resize areas to be different for the title bar
*/
internal class MyUndecoratedWindowResizer(
private val window: Window,
private val borderThickness: Dp,
private val borderThicknessTop: Dp
) {
// Kept the implementation the same except for only replacing `borderThickness` with `borderThicknessTop` where appropriate
} If I could suggest some possible goals here, they might be:
Thanks again. |
Yes, that's unfortunate. We could avoid overriding
You didn't have to do that. I'm not sure we want to expose the resizer itself, but we'll see whether we can provide a smaller API surface to just define the border thickness. Or maybe we just need to select a better default value. Maybe check the sizes of the resizable areas of native windows and use that. @igordmn ? |
Are you sure that I am not putting my content into a I see that |
If you put your resizer immediately in the window, as the last element, then yes, it looks like I'd recommend not relying on this, and instead laying out your resizer by yourself (just put all your content in a |
That sounds like a sufficient workaround for now, thanks. If possible I'd like to keep this issue open, with the hope that maybe some redesigns in the future will make it so we don't need such heavy workarounds to set the resizer widths (and to set them to different widths for different sides). |
Hmm, now that I think about it - do you actually need to make the AWT window resizable? The resizability there is "by the user". You can just call |
Just tested your idea, and it seems to work. Specifically, I remmoved the code that:
And confirmed it seems to behave exactly as before. One of the concerns I have is that by not making the AWT window resizable, I don't know if this would have unintended side effects, some of which might be platform-specific. I am testing on a Mac. Looking at the implementation o @Override
public void setResizable(final boolean resizable) {
setCanFullscreen(resizable);
setStyleBits(RESIZABLE, resizable);
setStyleBits(ZOOMABLE, resizable);
} If the recommendation is that users who make a custom override for the undecorated resizer don't call the AWT |
Window.setResizable is useful for decorated windows. |
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks. |
When making a window undecorated, the area that you can click in the corners on macOS is sigificantly smaller than when the window is decorated. This leads to frustration as you are tying to get the mouse into the tiny little area that allows you to click and drag to resize an undecorated window.
I would like to make this area larger. I am not sure if this is more on the compose side or the swing side.
Platform: Desktop
OS: macos 14.4.1 arm64
Compose Version: 1.6.1
Kotlin version: 2.0.0-Beta5
The text was updated successfully, but these errors were encountered: