diff --git a/src/WindowDebugger/Localizations/en.toml b/src/WindowDebugger/Localizations/en.toml index cc35c60..06a4daf 100644 --- a/src/WindowDebugger/Localizations/en.toml +++ b/src/WindowDebugger/Localizations/en.toml @@ -124,6 +124,12 @@ App.UI.WindowDetail.Pages.Windows.Operations.ThreadOperations.Kill.Action = "End App.UI.WindowDetail.Pages.Windows.Others.Title = "Others" App.UI.WindowDetail.Pages.Windows.Others.IsTouchWindow = "Is Touch Window" App.UI.WindowDetail.Pages.Windows.Others.VirtualDesktopId = "Virtual Desktop ID" +App.UI.WindowDetail.Pages.Linux.Info.Bounds.Title = "Rect" +App.UI.WindowDetail.Pages.Linux.Info.Bounds.Description = "Screen coordinates" +App.UI.WindowDetail.Pages.Linux.Info.Bounds.Left = "Left" +App.UI.WindowDetail.Pages.Linux.Info.Bounds.Top = "Top" +App.UI.WindowDetail.Pages.Linux.Info.Bounds.Width = "Width" +App.UI.WindowDetail.Pages.Linux.Info.Bounds.Height = "Height" App.UI.WindowDetail.Pages.Linux.Info.Title = "Info" App.UI.WindowDetail.Pages.Linux.Properties.Title = "Properties" App.UI.WindowDetail.Pages.Linux.Operations.Title = "Operations" diff --git a/src/WindowDebugger/Localizations/zh-hans.toml b/src/WindowDebugger/Localizations/zh-hans.toml index a14afe7..7bf06d4 100644 --- a/src/WindowDebugger/Localizations/zh-hans.toml +++ b/src/WindowDebugger/Localizations/zh-hans.toml @@ -124,6 +124,12 @@ App.UI.WindowDetail.Pages.Windows.Operations.ThreadOperations.Kill.Action = "终 App.UI.WindowDetail.Pages.Windows.Others.Title = "其他" App.UI.WindowDetail.Pages.Windows.Others.IsTouchWindow = "是否支持触摸" App.UI.WindowDetail.Pages.Windows.Others.VirtualDesktopId = "虚拟桌面标识符" +App.UI.WindowDetail.Pages.Linux.Info.Bounds.Title = "位置和大小" +App.UI.WindowDetail.Pages.Linux.Info.Bounds.Description = "屏幕坐标系" +App.UI.WindowDetail.Pages.Linux.Info.Bounds.Height = "高" +App.UI.WindowDetail.Pages.Linux.Info.Bounds.Left = "左" +App.UI.WindowDetail.Pages.Linux.Info.Bounds.Top = "上" +App.UI.WindowDetail.Pages.Linux.Info.Bounds.Width = "宽" App.UI.WindowDetail.Pages.Linux.Info.Title = "信息" App.UI.WindowDetail.Pages.Linux.Properties.Title = "属性" App.UI.WindowDetail.Pages.Linux.Operations.Title = "操作" diff --git a/src/WindowDebugger/Services/NativeWindows/Linux/LinuxNativeWindowModel.cs b/src/WindowDebugger/Services/NativeWindows/Linux/LinuxNativeWindowModel.cs index 6a3b128..04ce4b0 100644 --- a/src/WindowDebugger/Services/NativeWindows/Linux/LinuxNativeWindowModel.cs +++ b/src/WindowDebugger/Services/NativeWindows/Linux/LinuxNativeWindowModel.cs @@ -1,5 +1,5 @@ -using SeWzc.WinInfo.Models; -using SeWzc.X11Sharp; +using SeWzc.X11Sharp; +using WindowDebugger.Services.NativeWindows.Linux.Models; namespace WindowDebugger.Services.NativeWindows.Linux; @@ -14,6 +14,8 @@ public LinuxNativeWindowModel(X11DisplayWindow window) : base(window.Window.ToPt { ProcessId = (int)pid; } + + _windowAttributes = window.GetAttributes() ?? throw new ArgumentException("Failed to get window attributes."); } internal X11DisplayWindow Window { get; } @@ -24,6 +26,32 @@ public LinuxNativeWindowModel(X11DisplayWindow window) : base(window.Window.ToPt public int Handle { get; } + #region attributes + + private readonly WindowAttributes _windowAttributes; + + public int Left => _windowAttributes.X; + + public int Top => _windowAttributes.Y; + + public int Width => _windowAttributes.Width; + + public int Height => _windowAttributes.Height; + + public int Depth => _windowAttributes.Depth; + + public int BorderWidth => _windowAttributes.BorderWidth; + + public WindowClasses WindowClasses => _windowAttributes.WindowClass; + + public MapState MapState => _windowAttributes.MapState; + + public bool OverrideRedirect => _windowAttributes.OverrideRedirect; + + #endregion + + public IEnumerable> WindowPropertyGroups => GetWindowValuesGrouped(); + public IReadOnlyList GetChildren() { return Window.QueryTree(out _, out _, out var children) @@ -39,4 +67,17 @@ public IReadOnlyList GetWindowValues() select new WindowProperty(Window, property); return windowProperties.ToList(); } + + public IEnumerable> GetWindowValuesGrouped() + { + return GetWindowValues() + .ToLookup(x => + { + var name = x.Name; + if (!name.StartsWith('_')) + return "普通属性"; + var index = name.IndexOf('_', 1); + return "扩展属性:" + (index > 0 ? name[1..index] : name[1..]); + }); + } } diff --git a/src/WindowDebugger/Services/NativeWindows/Linux/Models/LinuxNativeWindowCollectionManager.cs b/src/WindowDebugger/Services/NativeWindows/Linux/Models/LinuxNativeWindowCollectionManager.cs index d100413..5dd45da 100644 --- a/src/WindowDebugger/Services/NativeWindows/Linux/Models/LinuxNativeWindowCollectionManager.cs +++ b/src/WindowDebugger/Services/NativeWindows/Linux/Models/LinuxNativeWindowCollectionManager.cs @@ -1,6 +1,6 @@ using SeWzc.X11Sharp; -namespace SeWzc.WinInfo.Models; +namespace WindowDebugger.Services.NativeWindows.Linux.Models; public class LinuxNativeWindowCollectionManager { diff --git a/src/WindowDebugger/Services/NativeWindows/Linux/Models/WindowProperty.cs b/src/WindowDebugger/Services/NativeWindows/Linux/Models/WindowProperty.cs index 1d2e774..fc6a803 100644 --- a/src/WindowDebugger/Services/NativeWindows/Linux/Models/WindowProperty.cs +++ b/src/WindowDebugger/Services/NativeWindows/Linux/Models/WindowProperty.cs @@ -1,6 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Linq; using System.Text; using Avalonia; using Avalonia.Media.Imaging; @@ -8,12 +5,14 @@ using SeWzc.X11Sharp; using SeWzc.X11Sharp.Structs; -namespace SeWzc.WinInfo.Models; +namespace WindowDebugger.Services.NativeWindows.Linux.Models; public class WindowProperty(X11DisplayWindow window, X11DisplayAtom property) { public string Name { get; } = property.GetAtomName() ?? "(null)"; + public IReadOnlyWindowPropertyValue Value => GetValue(); + public IReadOnlyWindowPropertyValue GetValue() { var propertyData = window.GetProperty(property); @@ -242,4 +241,4 @@ public PropertyData ToPropertyData() { return new PropertyData.Format32Array(_propertyType, _propertyType.Display.InternAtoms(Atoms).Select(x => (Long)(int)x.Atom).ToArray()); } -} \ No newline at end of file +} diff --git a/src/WindowDebugger/Services/NativeWindows/Linux/Models/WindowProxy.cs b/src/WindowDebugger/Services/NativeWindows/Linux/Models/WindowProxy.cs index 61a9ace..97abbc2 100644 --- a/src/WindowDebugger/Services/NativeWindows/Linux/Models/WindowProxy.cs +++ b/src/WindowDebugger/Services/NativeWindows/Linux/Models/WindowProxy.cs @@ -1,8 +1,6 @@ -using System.Collections.Generic; -using System.Linq; using SeWzc.X11Sharp; -namespace SeWzc.WinInfo.Models; +namespace WindowDebugger.Services.NativeWindows.Linux.Models; public class WindowProxy { @@ -34,4 +32,4 @@ public IReadOnlyList GetWindowValues() select new WindowProperty(Window, property); return windowProperties.ToList(); } -} \ No newline at end of file +} diff --git a/src/WindowDebugger/Services/NativeWindows/Linux/ViewModels/ViewModelBase.cs b/src/WindowDebugger/Services/NativeWindows/Linux/ViewModels/ViewModelBase.cs index f16f3bc..56dce3c 100644 --- a/src/WindowDebugger/Services/NativeWindows/Linux/ViewModels/ViewModelBase.cs +++ b/src/WindowDebugger/Services/NativeWindows/Linux/ViewModels/ViewModelBase.cs @@ -1,5 +1,5 @@ using ReactiveUI; -namespace SeWzc.WinInfo.ViewModels; +namespace WindowDebugger.Services.NativeWindows.Linux.ViewModels; -public abstract class ViewModelBase : ReactiveObject; \ No newline at end of file +public abstract class ViewModelBase : ReactiveObject; diff --git a/src/WindowDebugger/Services/NativeWindows/Linux/ViewModels/WindowInfoTabViewModel.cs b/src/WindowDebugger/Services/NativeWindows/Linux/ViewModels/WindowInfoTabViewModel.cs index 40d9930..30c165c 100644 --- a/src/WindowDebugger/Services/NativeWindows/Linux/ViewModels/WindowInfoTabViewModel.cs +++ b/src/WindowDebugger/Services/NativeWindows/Linux/ViewModels/WindowInfoTabViewModel.cs @@ -1,7 +1,6 @@ -using System.Collections.Generic; using ReactiveUI; -namespace SeWzc.WinInfo.ViewModels; +namespace WindowDebugger.Services.NativeWindows.Linux.ViewModels; public class WindowInfoTabViewModel : ViewModelBase { diff --git a/src/WindowDebugger/Services/NativeWindows/Linux/ViewModels/WindowProxyViewModel.cs b/src/WindowDebugger/Services/NativeWindows/Linux/ViewModels/WindowProxyViewModel.cs index 4769955..550aeb3 100644 --- a/src/WindowDebugger/Services/NativeWindows/Linux/ViewModels/WindowProxyViewModel.cs +++ b/src/WindowDebugger/Services/NativeWindows/Linux/ViewModels/WindowProxyViewModel.cs @@ -1,8 +1,6 @@ -using System.Collections.Generic; -using System.Linq; -using SeWzc.WinInfo.Models; +using WindowDebugger.Services.NativeWindows.Linux.Models; -namespace SeWzc.WinInfo.ViewModels; +namespace WindowDebugger.Services.NativeWindows.Linux.ViewModels; public class WindowProxyViewModel : ViewModelBase { diff --git a/src/WindowDebugger/Services/NativeWindows/Linux/ViewModels/WindowValueViewModel.cs b/src/WindowDebugger/Services/NativeWindows/Linux/ViewModels/WindowValueViewModel.cs index ec094bd..68312c9 100644 --- a/src/WindowDebugger/Services/NativeWindows/Linux/ViewModels/WindowValueViewModel.cs +++ b/src/WindowDebugger/Services/NativeWindows/Linux/ViewModels/WindowValueViewModel.cs @@ -1,7 +1,7 @@ using ReactiveUI; -using SeWzc.WinInfo.Models; +using WindowDebugger.Services.NativeWindows.Linux.Models; -namespace SeWzc.WinInfo.ViewModels; +namespace WindowDebugger.Services.NativeWindows.Linux.ViewModels; public class WindowValueViewModel(WindowProperty model) : ViewModelBase { @@ -23,4 +23,4 @@ public IReadOnlyWindowPropertyValue Value this.RaisePropertyChanged(); } } -} \ No newline at end of file +} diff --git a/src/WindowDebugger/Services/NativeWindows/NativeWindowCollectionManager.linux.cs b/src/WindowDebugger/Services/NativeWindows/NativeWindowCollectionManager.linux.cs index 9756336..d0b7c55 100644 --- a/src/WindowDebugger/Services/NativeWindows/NativeWindowCollectionManager.linux.cs +++ b/src/WindowDebugger/Services/NativeWindows/NativeWindowCollectionManager.linux.cs @@ -8,12 +8,12 @@ partial class NativeWindowCollectionManager { [SupportedOSPlatform("linux")] private X11Display? _display; - + [SupportedOSPlatform("linux")] private LinuxNativeWindowModel[] FindWindowsOnLinux(WindowSearchingFilter filter) { var display = _display ??= X11Display.Open(); - + return [..new LinuxNativeWindowModel(display.DefaultRootWindow) .GetChildren() .Select(x=>new LinuxNativeWindowModel(x.Window))]; diff --git a/src/WindowDebugger/Views/Details/Linux/WindowInfosPage.axaml b/src/WindowDebugger/Views/Details/Linux/WindowInfosPage.axaml new file mode 100644 index 0000000..5adff61 --- /dev/null +++ b/src/WindowDebugger/Views/Details/Linux/WindowInfosPage.axaml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/WindowDebugger/Views/Details/Linux/WindowInfosPage.axaml.cs b/src/WindowDebugger/Views/Details/Linux/WindowInfosPage.axaml.cs new file mode 100644 index 0000000..11f708e --- /dev/null +++ b/src/WindowDebugger/Views/Details/Linux/WindowInfosPage.axaml.cs @@ -0,0 +1,11 @@ +using Avalonia.Controls; + +namespace WindowDebugger.Views.Details.Linux; + +public partial class WindowInfosPage : UserControl +{ + public WindowInfosPage() + { + InitializeComponent(); + } +} diff --git a/src/WindowDebugger/Views/Details/Linux/WindowPropertiesPage.axaml b/src/WindowDebugger/Views/Details/Linux/WindowPropertiesPage.axaml new file mode 100644 index 0000000..dc7d62b --- /dev/null +++ b/src/WindowDebugger/Views/Details/Linux/WindowPropertiesPage.axaml @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/WindowDebugger/Views/Details/Linux/WindowPropertiesPage.axaml.cs b/src/WindowDebugger/Views/Details/Linux/WindowPropertiesPage.axaml.cs new file mode 100644 index 0000000..f23454b --- /dev/null +++ b/src/WindowDebugger/Views/Details/Linux/WindowPropertiesPage.axaml.cs @@ -0,0 +1,11 @@ +using Avalonia.Controls; + +namespace WindowDebugger.Views.Details.Linux; + +public partial class WindowPropertiesPage : UserControl +{ + public WindowPropertiesPage() + { + InitializeComponent(); + } +} diff --git a/src/WindowDebugger/Views/MainView.axaml.cs b/src/WindowDebugger/Views/MainView.axaml.cs index 8b36231..e0732f2 100644 --- a/src/WindowDebugger/Views/MainView.axaml.cs +++ b/src/WindowDebugger/Views/MainView.axaml.cs @@ -6,6 +6,7 @@ using WindowDebugger.Native; using WindowDebugger.Services.NativeWindows.Windows; using WindowDebugger.Views.Details; +using WindowDebugger.Views.Details.Linux; using WindowDebugger.Views.Details.Windows; namespace WindowDebugger.Views; @@ -123,12 +124,12 @@ private void InitializePlatformPages() WindowDetailTabControl.Items.Add(new TabItem { Header = Lang.Current.App.UI.WindowDetail.Pages.Linux.Info.Title, - Content = new WipPage(), + Content = new WindowInfosPage(), }); WindowDetailTabControl.Items.Add(new TabItem { Header = Lang.Current.App.UI.WindowDetail.Pages.Linux.Properties.Title, - Content = new WipPage(), + Content = new WindowPropertiesPage(), }); WindowDetailTabControl.Items.Add(new TabItem {