Compare commits

...

3 Commits

Author SHA1 Message Date
Betsegaw Tadele
e679751ea6 Check that the plugin that returned the result actually put in a selection action in there 2020-05-03 15:52:00 -07:00
Betsegaw Tadele
8d9dd378e7 Merge branch 'dev/PowerLauncher' into betsegaw/reenable-aero-ww 2020-05-03 15:44:24 -07:00
Betsegaw Tadele
cd80e65574 Add Aero view to WW plugin in Launcher 2020-05-03 15:22:09 -07:00
7 changed files with 119 additions and 47 deletions

View File

@@ -838,5 +838,8 @@ namespace Wox.Plugin.WindowWalker.Components
[DllImport("user32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetWindowPlacement(IntPtr hWnd, out WINDOWPLACEMENT lpwndpl);
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
public static extern IntPtr GetForegroundWindow();
}
}

View File

@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Windows.Interop;
using Wox.Plugin.WindowWalker.Components;
namespace Wox.Plugin.WindowWalker
@@ -29,7 +30,17 @@ namespace Wox.Plugin.WindowWalker
{
x.Result.SwitchToWindow();
return true;
}
},
SelectionAction = c =>
{
var excludeWindowHandle =
OpenWindows.Instance.Windows
.Where(window => window.Title == "PopupHost"
&& window.ProcessName == "PowerLauncher.exe").First().Hwnd;
LivePreview.ActivateLivePreview(x.Result.Hwnd, excludeWindowHandle);
return null;
},
}
).ToList();
}

View File

@@ -8,7 +8,8 @@
ActualThemeChanged="UserControl_ActualThemeChanged"
Loaded="UserControl_Loaded"
d:DesignHeight="300"
d:DesignWidth="720">
d:DesignWidth="720"
PreviewKeyDown="OnKeyDown">
<UserControl.Resources>
<Style TargetType="TextBox" x:Key="CustomAutoSuggestBoxTextBoxStyle">

View File

@@ -33,6 +33,38 @@ namespace PowerLauncher.UI
OnPropertyChanged(propertyName);
}
private void OnKeyDown(object sender, Windows.UI.Xaml.Input.KeyRoutedEventArgs e)
{
var NextResultCommand = this.DataContext.GetType().GetMethod("get_SelectNextItemCommand").Invoke(this.DataContext, new object[] { });
var NextResult = NextResultCommand.GetType().GetMethod("Execute");
var PreviousResultCommand = this.DataContext.GetType().GetMethod("get_SelectPrevItemCommand").Invoke(this.DataContext, new object[] { });
var PreviousResult = PreviousResultCommand.GetType().GetMethod("Execute");
var NextPageResultCommand = this.DataContext.GetType().GetMethod("get_SelectNextPageCommand").Invoke(this.DataContext, new object[] { });
var NextPageResult = NextResultCommand.GetType().GetMethod("Execute");
var PreviousPageResultCommand = this.DataContext.GetType().GetMethod("get_SelectPrevPageCommand").Invoke(this.DataContext, new object[] { });
var PreviousPageResult = PreviousResultCommand.GetType().GetMethod("Execute");
if (e.Key == Windows.System.VirtualKey.Down)
{
NextResult.Invoke(NextResultCommand, new object[] { null });
}
else if (e.Key == Windows.System.VirtualKey.Up)
{
PreviousResult.Invoke(PreviousResultCommand, new object[] { null });
}
else if (e.Key == Windows.System.VirtualKey.PageDown)
{
NextPageResult.Invoke(NextPageResultCommand, new object[] { null });
}
else if (e.Key == Windows.System.VirtualKey.PageUp)
{
PreviousPageResult.Invoke(PreviousPageResultCommand, new object[] { null });
}
}
private void UserControl_ActualThemeChanged(FrameworkElement sender, object args)
{
SolidBorderBrush = Application.Current.Resources["SystemChromeLow"] as SolidColorBrush;
@@ -46,5 +78,5 @@ namespace PowerLauncher.UI
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}

View File

@@ -44,6 +44,11 @@ namespace Wox.Plugin
/// </summary>
public Func<ActionContext, bool> Action { get; set; }
/// <summary>
/// Highlighted Action
/// </summary>
public Func<ActionContext, string> SelectionAction { get; set; }
public int Score { get; set; }
/// <summary>

View File

@@ -152,7 +152,7 @@ namespace Wox
return GlobalKeyboardEvent((int)keyevent, vkcode, state);
}
return true;
}
}
#endregion
}
}

View File

@@ -6,7 +6,7 @@ using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Input;
using Wox.Infrastructure.UserSettings;
using Wox.Plugin;
@@ -18,6 +18,10 @@ namespace Wox.ViewModel
public ResultCollection Results { get; }
private ResultViewModel _selectedItem;
private int _selectedIndex;
private readonly object _addResultsLock = new object();
private readonly object _collectionLock = new object();
private readonly Settings _settings;
@@ -46,33 +50,49 @@ namespace Wox.ViewModel
public int MaxHeight => MaxResults * 50;
public int SelectedIndex { get; set; }
private ResultViewModel _selectedItem;
public ResultViewModel SelectedItem
public int SelectedIndex
{
get { return _selectedItem; }
set
{
//value can be null when selecting an item in a virtualized list
if (value != null)
{
if (_selectedItem != null)
{
_selectedItem.DeactivateContextButtons(ResultViewModel.ActivationType.Selection);
}
_selectedItem = value;
_selectedItem.ActivateContextButtons(ResultViewModel.ActivationType.Selection);
}
else
{
_selectedItem = value;
}
get
{
return _selectedIndex;
}
set
{
if (value != _selectedIndex)
{
_selectedIndex = value;
SelectedItem = Results[_selectedIndex];
}
}
}
public ResultViewModel SelectedItem
{
get { return _selectedItem; }
set
{
//value can be null when selecting an item in a virtualized list
if (value != null)
{
if (_selectedItem != null)
{
_selectedItem.DeactivateContextButtons(ResultViewModel.ActivationType.Selection);
}
_selectedItem = value;
_selectedItem.ActivateContextButtons(ResultViewModel.ActivationType.Selection);
if (_selectedItem.Result.SelectionAction != null)
{
_selectedItem.Result.SelectionAction(new ActionContext());
}
}
else
{
_selectedItem = value;
}
}
}
public Thickness Margin { get; set; }
public Visibility Visbility { get; set; } = Visibility.Hidden;
@@ -153,26 +173,26 @@ namespace Wox.ViewModel
public void RemoveResultsFor(PluginMetadata metadata)
{
Results.RemoveAll(r => r.Result.PluginID == metadata.ID);
}
public void SelectNextTabItem()
{
if(!SelectedItem.SelectNextContextButton())
{
SelectNextResult();
}
}
public void SelectPrevTabItem()
{
if (!SelectedItem.SelectPrevContextButton())
{
//Tabbing backwards should highlight the last item of the previous row
SelectPrevResult();
SelectedItem.SelectLastContextButton();
}
}
}
public void SelectNextTabItem()
{
if(!SelectedItem.SelectNextContextButton())
{
SelectNextResult();
}
}
public void SelectPrevTabItem()
{
if (!SelectedItem.SelectPrevContextButton())
{
//Tabbing backwards should highlight the last item of the previous row
SelectPrevResult();
SelectedItem.SelectLastContextButton();
}
}
/// <summary>
/// To avoid deadlock, this method should not called from main thread
/// </summary>