Skip to content

Conversation

@janbarari
Copy link

Evidences

preview

Release notes

New features

  • New modifier function clientRegion introduced to let compose hold the component position and size on custom title bar

Bug fixes

  • Fixed custom title bar mouse event (drag/press) not moving the window some times.

Test

This implementation has been tested on Mac (Tahoe, Ventura) and Windows 11 (25H2) machines.

Links

Youtrack Issue
Slack Thread

@janbarari janbarari marked this pull request as draft December 25, 2025 07:19
@janbarari janbarari marked this pull request as ready for review December 25, 2025 07:21
Copy link
Collaborator

@faogustavo faogustavo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you've made some changes to public APIs, you will need to update the API dumps.

Find the 'ApiCheckTest' (or something similar) in the run configurations from the IDE, run it, and update the dumps accordingly. Feel free to ping me on slack if you need help with it :)


Looks like on Linux it works out of the box with no changes (so probably this is only needed for Windows/MacOS).

Screen.Recording.2026-01-02.at.08.18.00.mp4

Comment on lines +72 to +77
fun updateKey(newKey: String) {
if (key != newKey) {
titleBarInfo?.clientRegions?.remove(key)
key = newKey
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we need to keep the last defined value in the 'clientRegions' map? The code bellow is not correct, but I think you can get the main idea.

Suggested change
fun updateKey(newKey: String) {
if (key != newKey) {
titleBarInfo?.clientRegions?.remove(key)
key = newKey
}
}
fun updateKey(newKey: String) {
if (key != newKey) {
titleBarInfo?.clientRegions[newKey] = titleBarInfo?.clientRegions?.remove(key)
key = newKey
}
}

Comment on lines +95 to +97
// Convert from AWT raw pixels to Compose positionInWindow() coordinates
val x = e.x * scaleX
val y = e.y * scaleY
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you checked if e.locationOnScreen works?


Also, if you use the Rect suggestion from the other comment, you can convert the event to offset using something like this:

val location = event.locationOnScreen
val offset = Offset(location.x.toFloat(), location.y.toFloat())

Comment on lines +21 to +26
internal data class ClientRegion(
val x: Float,
val y: Float,
val width: Int,
val height: Int,
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about using androidx.compose.ui.geometry.Rect instead?

You can get the create it with Rect(it.positionOnScreen(), it.size.toSize()) and use the .contains() method to check if the point is inside the area.

Copy link
Collaborator

@wellingtoncosta wellingtoncosta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for making sure the api-dump.txt files are properly updated due to the changes in public API. You can just run the ApiCheckTest and apply the changes by clicking on the <Click to see difference> links in the test output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants