Skip to content
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

Bugfix decorated window on windows - clickable components inside title area should work now #731

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions decorated-window/api/decorated-window.api
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ public abstract interface class com/jetbrains/WindowMove {
public abstract fun startMovingTogetherWithMouse (Ljava/awt/Window;I)V
}

public final class org/jetbrains/jewel/window/ComposableSingletons$TitleBarKt {
public static final field INSTANCE Lorg/jetbrains/jewel/window/ComposableSingletons$TitleBarKt;
public static field lambda-1 Lkotlin/jvm/functions/Function2;
public fun <init> ()V
public final fun getLambda-1$decorated_window ()Lkotlin/jvm/functions/Function2;
}

public final class org/jetbrains/jewel/window/DecoratedWindowKt {
public static final fun DecoratedWindow (Lkotlin/jvm/functions/Function0;Landroidx/compose/ui/window/WindowState;ZLjava/lang/String;Landroidx/compose/ui/graphics/painter/Painter;ZZZZLkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lorg/jetbrains/jewel/window/styling/DecoratedWindowStyle;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;III)V
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.jetbrains.jewel.window

import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
Expand All @@ -27,7 +29,7 @@ internal fun DecoratedWindowScope.TitleBarOnWindows(
val titleBar = remember { JBR.getWindowDecorations().createCustomTitleBar() }

TitleBarImpl(
modifier = modifier.customTitleBarMouseEventHandler(titleBar),
modifier = modifier,
gradientStartColor = gradientStartColor,
style = style,
applyTitleBar = { height, _ ->
Expand All @@ -36,6 +38,7 @@ internal fun DecoratedWindowScope.TitleBarOnWindows(
JBR.getWindowDecorations().setCustomTitleBar(window, titleBar)
PaddingValues(start = titleBar.leftInset.dp, end = titleBar.rightInset.dp)
},
backgroundContent = { Spacer(modifier = modifier.fillMaxSize().customTitleBarMouseEventHandler(titleBar)) },
content = content,
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package org.jetbrains.jewel.window

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.runtime.Composable
Expand Down Expand Up @@ -77,6 +79,7 @@ internal fun DecoratedWindowScope.TitleBarImpl(
gradientStartColor: Color = Color.Unspecified,
style: TitleBarStyle = JewelTheme.defaultTitleBarStyle,
applyTitleBar: (Dp, DecoratedWindowState) -> PaddingValues,
backgroundContent: @Composable () -> Unit = {},
content: @Composable TitleBarScope.(DecoratedWindowState) -> Unit,
) {
val titleBarInfo = LocalTitleBarInfo.current
Expand All @@ -102,29 +105,34 @@ internal fun DecoratedWindowScope.TitleBarImpl(
}
}

Layout(
content = {
CompositionLocalProvider(
LocalContentColor provides style.colors.content,
LocalIconButtonStyle provides style.iconButtonStyle,
LocalDefaultDropdownStyle provides style.dropdownStyle,
) {
OverrideDarkMode(background.isDark()) {
val scope = TitleBarScopeImpl(titleBarInfo.title, titleBarInfo.icon)
scope.content(state)
}
}
},
Box(
modifier =
modifier
.background(backgroundBrush)
.focusProperties { canFocus = false }
.layoutId(TITLE_BAR_LAYOUT_ID)
.height(style.metrics.height)
.onSizeChanged { with(density) { applyTitleBar(it.height.toDp(), state) } }
.fillMaxWidth(),
measurePolicy = rememberTitleBarMeasurePolicy(window, state, applyTitleBar),
)
.fillMaxWidth()
) {
backgroundContent()
Layout(
content = {
CompositionLocalProvider(
LocalContentColor provides style.colors.content,
LocalIconButtonStyle provides style.iconButtonStyle,
LocalDefaultDropdownStyle provides style.dropdownStyle,
) {
OverrideDarkMode(background.isDark()) {
val scope = TitleBarScopeImpl(titleBarInfo.title, titleBarInfo.icon)
scope.content(state)
}
}
},
modifier = modifier.fillMaxSize(),
measurePolicy = rememberTitleBarMeasurePolicy(window, state, applyTitleBar),
)
}

Spacer(Modifier.layoutId(TITLE_BAR_BORDER_LAYOUT_ID).height(1.dp).fillMaxWidth().background(style.colors.border))
}
Expand Down
Loading