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

Improved and fix floating window activation and activation pane #415

Merged
merged 3 commits into from
Dec 26, 2022
Merged
Changes from 1 commit
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
Next Next commit
Improved and fix floating window activation and activation pane
- Use LastActivationTimeStamp instead of IsLastFocusedDocument
  • Loading branch information
Wenveo committed Dec 26, 2022
commit c444860cb62a6d20f6230ad16f6e29ab1fd2a2f4
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,15 @@ private void ActiveOfSinglePane(bool isActive)
var layoutDocumentPane = _model.Descendents().OfType<LayoutDocumentPane>()
.FirstOrDefault(p => p.ChildrenCount > 0 && p.SelectedContent != null);

layoutDocumentPane.SelectedContent.IsActive = isActive;
if (layoutDocumentPane != null)
{
layoutDocumentPane.SelectedContent.IsActive = isActive;
}
//
else
{
ActiveLastActivationOfItems(isActive);
}
}

private static LayoutDocumentPaneControl FindDocumentPaneControlByPoint(IEnumerable<LayoutDocumentPaneControl> areaHosts, Point point)
Expand All @@ -127,7 +135,7 @@ private static LayoutDocumentPaneControl FindDocumentPaneControlByPoint(IEnumera
{
var area = areaHost.GetScreenArea();
var pos = areaHost.TransformFromDeviceDPI(point);
var b = area.Contains(pos);
var b = area.Contains(point);

if (b)
{
Expand All @@ -138,6 +146,53 @@ private static LayoutDocumentPaneControl FindDocumentPaneControlByPoint(IEnumera
return null;
}

private void ActiveLastActivationOfPane(LayoutDocumentPane model)
{
if (model.Children.Count > 0)
{
var index = 0;
if (model.Children.Count > 1)
{
var tmTimeStamp = model.Children[0].LastActivationTimeStamp;
for (var i = 1; i < model.Children.Count; i++)
{
var item = model.Children[i];
if (item.LastActivationTimeStamp > tmTimeStamp)
{
tmTimeStamp = item.LastActivationTimeStamp;
index = i;
}
}
}

model.SelectedContentIndex = index;
}
}

private void ActiveLastActivationOfItems(bool isActive)
{
var items = _model.Descendents().OfType<LayoutContent>().ToList();
if (items.Count > 0)
{
var index = 0;
if (items.Count > 1)
{
var tmpTimeStamp2 = items[0].LastActivationTimeStamp;
for (var i = 1; i < items.Count; i++)
{
var item = items[i];
if (item.LastActivationTimeStamp > tmpTimeStamp2)
{
tmpTimeStamp2 = item.LastActivationTimeStamp;
index = i;
}
}
}

items[index].IsActive = isActive;
}
}

private void ActiveOfMultiPane(bool isActive)
{
var mousePosition = Win32Helper.GetMousePosition();
Expand All @@ -155,56 +210,14 @@ private void ActiveOfMultiPane(bool isActive)
model.SelectedContent.IsActive = true;
return;
}
// AnchorablePane
else
{
var index = 0;
for (var i = 0; i < model.Children.Count; i++)
{
var item = model.Children[i];
if (item.IsLastFocusedDocument)
{
index = i;
}
}

model.SelectedContentIndex = index;
ActiveLastActivationOfPane(model);
return;
}
}
else
{
// Active the Last Focus
foreach (var areaHost in areaHosts)
{
var model = (LayoutDocumentPane)areaHost.Model;
for (var i = 0; i < model.Children.Count; i++)
{
var item = model.Children[i];
if (item.IsLastFocusedDocument)
{
item.IsActive = true;
return;
}
}
}
}
}
else
{
foreach (var areaHost in areaHosts)
{
var model = (LayoutDocumentPane)areaHost.Model;
for (var i = 0; i < model.Children.Count; i++)
{
var item = model.Children[i];
if (item.IsActive)
{
item.IsActive = false;
}
}
}
}
ActiveLastActivationOfItems(isActive);
}

/// <inheritdoc />
Expand Down