I am going to share my experience in case someone else encounters similar issues:
1) 16.1.0633 build feels like a half-measure. It does address some of the issues with focus, but not all of them. For example, now when you click on Toolbar outside the dock site, active window remains highlighted. But if you click on regular button instead - highlighting disappears. Same thing happens when you click on focusable custom control. Maybe it will get better in future versions, but as of now highlighting logic does not make any sense to me.
2) I was able to override default templates in order to get the behaviour I need though. It looks like you need to override three templates. First, you need to override AdvancedTabItem style. Add the following trigger to template:
<DataTrigger Binding="{Binding IsActive}" Value="True">
<Setter TargetName="TabChrome" Property="UntintedBackground" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BackgroundActiveSelected}" />
<Setter TargetName="TabChrome" Property="UntintedBorderBrush" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderBrushActiveSelected}" />
<Setter TargetName="ContentPresenter" Property="TextElement.Foreground" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ForegroundActiveSelected}" />
</DataTrigger>
It will bind highlighting of document window to its IsActive property, instead of binding it to HighlightKind property of AdvancedTabItem. Then you need to do the same for ToolWindowContainer. Replace:
<Trigger Property="IsActive" Value="True">
with
<DataTrigger Binding="{Binding SelectedWindow.IsActive, RelativeSource={RelativeSource Self}}" Value="True">
Finally, you might also want to override AdvancedTabControl style, if you what the color of highlighted border to match the color of active tab. Add:
<DataTrigger Binding="{Binding SelectedWindow.IsActive, RelativeSource={RelativeSource TemplatedParent}}" Value="True">
<Setter TargetName="HighlightBorder" Property="BorderBrush" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=HighlightBrushActive}" />
</DataTrigger>
Thats about it. I did not test this solution extensively, but so far it works. I wish there was an easier way to get the same result. Copy-pasting 700 lines of styles just to alter a few lines of code is really tiresome.
3) I did not succeed in making InteropFocusTracking work with System.Windows.Forms.ToolStrip. If anyone has a working solution, please post the code here or e-mail it to me (or both). Solution which involves hit-testing works though. In my case it looks like this:
//this is a handler for native mouse events (you can use SetWindowsHookEx to get those)
private void OnHookTriggerd(MouseHookEventArgs args)
{
foreach (var window in _windows.Where(x => x.IsLoaded))
{
if (PresentationSource.FromVisual(window) == null) continue;
var point = window.PointFromScreen(args.Position);
if (VisualTreeHelper.HitTest(window, point) == null) continue;
//"false" is important, we do not want to steal focus from focusable content
window.Activate(false);
return;
}
}
There are a few limitations. First, you have to override templates as shown above, in order to also get the correct highlighting. Second, if user manages to somehow move focus directly to ToolStrip from another window without using a mouse - this solution won't work for obvious reasons.