Skip to content

Commit ae40651

Browse files
fix: Battlegrounds overlay buttons unclickable on Linux/Wine (#4741)
* fix(overlay): replace WPF Buttons with Border+MouseLeftButtonUp in BG overlays WPF Button controls do not fire click events reliably under Wine/Linux when used inside WS_EX_TRANSPARENT overlay windows. GuidesTabs (top-right tabs): 3 Buttons replaced, fixing unclickable tabs. BattlegroundsMinionPinning (bottom-left buttons): 6 Buttons replaced. All 9 use Border+MouseLeftButtonUp matching proven BattlegroundsTierButton pattern. Added regression tests asserting zero Button elements in overlay XAML. * refactor: deduplicate Battlegrounds overlay button styles * fix: reflect command CanExecute in OverlayButton enabled state * refactor: target OverlayButton in overlay child RelativeSource triggers * fix: restore plain text labels on Battlegrounds overlay buttons * fix: use OverlayButton for the Battlegrounds session options cog * chore: drop stray prefix from OverlayButton click comment * test: drop the component-level Button tests * feat: trigger OverlayButton on any mouse button --------- Co-authored-by: Benedict Etzel <benedict@hearthsim.net>
1 parent b69c8e4 commit ae40651

17 files changed

Lines changed: 591 additions & 556 deletions
Lines changed: 47 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,61 @@
11
<UserControl x:Class="Hearthstone_Deck_Tracker.Controls.Overlay.Battlegrounds.Guides.Comps.CompButton"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:battlegrounds="clr-namespace:Hearthstone_Deck_Tracker.Controls.Overlay.Battlegrounds"
45
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
56
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
67
xmlns:hearthstoneDeckTracker="clr-namespace:Hearthstone_Deck_Tracker"
78
mc:Ignorable="d"
89
d:DesignHeight="300" d:DesignWidth="300">
9-
<Button Cursor="Hand" DataContext="{Binding}" Click="Button_OnClick" Height="48" Margin="0" Padding="0">
10-
<Button.Style>
11-
<Style TargetType="Button">
12-
<Setter Property="Template">
13-
<Setter.Value>
14-
<ControlTemplate TargetType="Button">
15-
<Border>
16-
<Grid>
17-
<Rectangle x:Name="HoverRectangle" Opacity="0.2">
18-
<Rectangle.Fill>
19-
<ImageBrush
20-
x:Name="ImgBrush"
21-
ImageSource="{Binding CardAsset.Asset}" Stretch="None">
22-
<ImageBrush.Transform>
23-
<TranslateTransform X="-30" Y="0" />
24-
</ImageBrush.Transform>
25-
</ImageBrush>
26-
</Rectangle.Fill>
27-
<Rectangle.OpacityMask>
28-
<LinearGradientBrush StartPoint="0,0" EndPoint="0.70,0">
29-
<GradientStop Color="#292d30" Offset="0.5"/>
30-
<GradientStop Color="Transparent" Offset="1"/>
31-
</LinearGradientBrush>
32-
</Rectangle.OpacityMask>
33-
</Rectangle>
34-
<ContentPresenter />
35-
</Grid>
36-
</Border>
37-
<ControlTemplate.Triggers>
38-
<Trigger Property="IsMouseOver" Value="True">
39-
<Setter TargetName="HoverRectangle" Property="Opacity" Value="0.4" />
40-
</Trigger>
41-
<Trigger Property="IsMouseOver" Value="False">
42-
<Setter TargetName="HoverRectangle" Property="Opacity" Value="0.2" />
43-
</Trigger>
44-
</ControlTemplate.Triggers>
45-
</ControlTemplate>
46-
</Setter.Value>
47-
</Setter>
48-
</Style>
49-
</Button.Style>
50-
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Center">
51-
<Grid.ColumnDefinitions>
52-
<ColumnDefinition Width="*" />
53-
<ColumnDefinition Width="Auto" />
54-
</Grid.ColumnDefinitions>
55-
<hearthstoneDeckTracker:OutlinedTextBlock
56-
Margin="10,0,10,0"
57-
Text="{Binding CompGuide.Name}"
58-
FontSize="12"
59-
TextWrapping="Wrap"
60-
TextTrimming="None"
61-
FontFamily="/HearthstoneDeckTracker;component/Resources/#Chunkfive"
62-
/>
63-
<Rectangle Grid.Column="1" Width="8" Height="8" Opacity="0.5" Margin="0,0,14,0">
10+
<battlegrounds:OverlayButton Cursor="Hand" DataContext="{Binding}" Height="48" Margin="0" Padding="0" Click="Button_OnClick">
11+
<Grid>
12+
<Rectangle>
13+
<Rectangle.Style>
14+
<Style TargetType="Rectangle">
15+
<Setter Property="Opacity" Value="0.2" />
16+
<Style.Triggers>
17+
<DataTrigger Binding="{Binding IsMouseOver, RelativeSource={RelativeSource AncestorType=battlegrounds:OverlayButton}}" Value="True">
18+
<Setter Property="Opacity" Value="0.4" />
19+
</DataTrigger>
20+
</Style.Triggers>
21+
</Style>
22+
</Rectangle.Style>
6423
<Rectangle.Fill>
65-
<VisualBrush Visual="{StaticResource appbar_chevron_right_white}" />
24+
<ImageBrush
25+
x:Name="ImgBrush"
26+
ImageSource="{Binding CardAsset.Asset}" Stretch="None">
27+
<ImageBrush.Transform>
28+
<TranslateTransform X="-30" Y="0" />
29+
</ImageBrush.Transform>
30+
</ImageBrush>
6631
</Rectangle.Fill>
32+
<Rectangle.OpacityMask>
33+
<LinearGradientBrush StartPoint="0,0" EndPoint="0.70,0">
34+
<GradientStop Color="#292d30" Offset="0.5"/>
35+
<GradientStop Color="Transparent" Offset="1"/>
36+
</LinearGradientBrush>
37+
</Rectangle.OpacityMask>
6738
</Rectangle>
39+
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Center">
40+
<Grid.ColumnDefinitions>
41+
<ColumnDefinition Width="*" />
42+
<ColumnDefinition Width="Auto" />
43+
</Grid.ColumnDefinitions>
44+
<hearthstoneDeckTracker:OutlinedTextBlock
45+
Margin="10,0,10,0"
46+
Text="{Binding CompGuide.Name}"
47+
FontSize="12"
48+
TextWrapping="Wrap"
49+
TextTrimming="None"
50+
FontFamily="/HearthstoneDeckTracker;component/Resources/#Chunkfive"
51+
/>
52+
<Rectangle Grid.Column="1" Width="8" Height="8" Opacity="0.5" Margin="0,0,14,0">
53+
<Rectangle.Fill>
54+
<VisualBrush Visual="{StaticResource appbar_chevron_right_white}" />
55+
</Rectangle.Fill>
56+
</Rectangle>
57+
</Grid>
6858
</Grid>
69-
</Button>
59+
</battlegrounds:OverlayButton>
7060
</UserControl>
7161

Hearthstone Deck Tracker/Controls/Overlay/Battlegrounds/Guides/Comps/CompButton.xaml.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,6 @@ public CompButton()
1111
InitializeComponent();
1212
}
1313

14-
private void Comp_Click(object sender, RoutedEventArgs e)
15-
{
16-
if (sender is Button { DataContext: BattlegroundsCompGuideViewModel selectedComp })
17-
{
18-
if (DataContext is BattlegroundsCompsGuidesViewModel compsGuidesViewModel)
19-
{
20-
compsGuidesViewModel.SelectedComp = selectedComp;
21-
}
22-
}
23-
}
24-
2514
public event EventHandler? CompClicked;
2615

2716
private void Button_OnClick(object sender, RoutedEventArgs e)

0 commit comments

Comments
 (0)