diff --git a/src/Avalonia.Controls/Platform/IWindowImpl.cs b/src/Avalonia.Controls/Platform/IWindowImpl.cs index d56cdc4e19..37637b1624 100644 --- a/src/Avalonia.Controls/Platform/IWindowImpl.cs +++ b/src/Avalonia.Controls/Platform/IWindowImpl.cs @@ -31,7 +31,7 @@ namespace Avalonia.Platform IDisposable ShowDialog(); /// - /// Enables of disables system window decorations (title bar, buttons, etc) + /// Enables or disables system window decorations (title bar, buttons, etc) /// void SetSystemDecorations(bool enabled); @@ -40,8 +40,9 @@ namespace Avalonia.Platform /// void SetIcon(IWindowIconImpl icon); - - + /// + /// Enables or disables the taskbar icon + /// void ShowTaskbarIcon(bool value); } } diff --git a/src/Avalonia.Controls/Window.cs b/src/Avalonia.Controls/Window.cs index 46c625cc4c..37f7c6d47f 100644 --- a/src/Avalonia.Controls/Window.cs +++ b/src/Avalonia.Controls/Window.cs @@ -61,11 +61,17 @@ namespace Avalonia.Controls AvaloniaProperty.Register(nameof(SizeToContent)); /// - /// Enables of disables system window decorations (title bar, buttons, etc) + /// Enables or disables system window decorations (title bar, buttons, etc) /// public static readonly StyledProperty HasSystemDecorationsProperty = AvaloniaProperty.Register(nameof(HasSystemDecorations), true); - + + /// + /// Enables or disables the taskbar icon + /// + public static readonly StyledProperty HasTaskbarIconProperty = + AvaloniaProperty.Register(nameof(HasTaskbarIcon), true); + /// /// Defines the property. /// @@ -92,6 +98,8 @@ namespace Avalonia.Controls HasSystemDecorationsProperty.Changed.AddClassHandler( (s, e) => s.PlatformImpl?.SetSystemDecorations((bool) e.NewValue)); + HasTaskbarIconProperty.Changed.AddClassHandler((w, e) => w.PlatformImpl?.ShowTaskbarIcon((bool)e.NewValue)); + IconProperty.Changed.AddClassHandler((s, e) => s.PlatformImpl?.SetIcon(((WindowIcon)e.NewValue).PlatformImpl)); } @@ -152,7 +160,7 @@ namespace Avalonia.Controls } /// - /// Enables of disables system window decorations (title bar, buttons, etc) + /// Enables or disables system window decorations (title bar, buttons, etc) /// /// public bool HasSystemDecorations @@ -160,6 +168,16 @@ namespace Avalonia.Controls get { return GetValue(HasSystemDecorationsProperty); } set { SetValue(HasSystemDecorationsProperty, value); } } + + /// + /// Enables or disables the taskbar icon + /// + /// + public bool HasTaskbarIcon + { + get { return GetValue(HasTaskbarIconProperty); } + set { SetValue(HasTaskbarIconProperty, value); } + } /// /// Gets or sets the minimized/maximized state of the window. diff --git a/src/Gtk/Avalonia.Gtk/WindowImpl.cs b/src/Gtk/Avalonia.Gtk/WindowImpl.cs index 4c0eacbcf5..2c1826c509 100644 --- a/src/Gtk/Avalonia.Gtk/WindowImpl.cs +++ b/src/Gtk/Avalonia.Gtk/WindowImpl.cs @@ -6,11 +6,12 @@ using Gdk; namespace Avalonia.Gtk { using Gtk = global::Gtk; + public class WindowImpl : TopLevelImpl, IWindowImpl { private Gtk.Window _window; - private Gtk.Window Window => _window ?? (_window = (Gtk.Window) Widget); - + private Gtk.Window Window => _window ?? (_window = (Gtk.Window)Widget); + public WindowImpl(Gtk.WindowType type) : base(new PlatformHandleAwareWindow(type)) { Init(); @@ -29,8 +30,10 @@ namespace Avalonia.Gtk _lastClientSize = ClientSize; _lastPosition = Position; } + private Size _lastClientSize; private Point _lastPosition; + void OnConfigureEvent(object o, Gtk.ConfigureEventArgs args) { var evnt = args.Event; @@ -44,7 +47,7 @@ namespace Avalonia.Gtk } var newPosition = new Point(evnt.X, evnt.Y); - + if (newPosition != _lastPosition) { PositionChanged(newPosition); @@ -107,10 +110,7 @@ namespace Avalonia.Gtk Window.GetPosition(out x, out y); return new Point(x, y); } - set - { - Window.Move((int)value.X, (int)value.Y); - } + set { Window.Move((int)value.X, (int)value.Y); } } public IDisposable ShowDialog() @@ -128,9 +128,6 @@ namespace Avalonia.Gtk Window.Icon = ((IconImpl)icon).Pixbuf; } - public void ShowTaskbarIcon(bool value) - { - Window.SkipTaskbarHint = !value; - } + public void ShowTaskbarIcon(bool value) => Window.SkipTaskbarHint = !value; } -} +} \ No newline at end of file diff --git a/src/Gtk/Avalonia.Gtk3/WindowImpl.cs b/src/Gtk/Avalonia.Gtk3/WindowImpl.cs index df834561d4..e6935c4f20 100644 --- a/src/Gtk/Avalonia.Gtk3/WindowImpl.cs +++ b/src/Gtk/Avalonia.Gtk3/WindowImpl.cs @@ -60,10 +60,8 @@ namespace Avalonia.Gtk3 //Why do we even have that? } - public void ShowTaskbarIcon(bool value) - { - Native.GtkWindowSetSkipTaskbarHint(GtkWidget, !value); - } + public void ShowTaskbarIcon(bool value) => Native.GtkWindowSetSkipTaskbarHint(GtkWidget, !value); + class EmptyDisposable : IDisposable { diff --git a/src/Windows/Avalonia.Win32/WindowImpl.cs b/src/Windows/Avalonia.Win32/WindowImpl.cs index bb2d4e808c..b9e2151b8f 100644 --- a/src/Windows/Avalonia.Win32/WindowImpl.cs +++ b/src/Windows/Avalonia.Win32/WindowImpl.cs @@ -763,6 +763,7 @@ namespace Avalonia.Win32 else style &= ~(UnmanagedMethods.WindowStyles.WS_EX_APPWINDOW); + //Toggle to make the styles stick UnmanagedMethods.ShowWindow(_hwnd, ShowWindowCommand.Hide); UnmanagedMethods.SetWindowLong(_hwnd, -20, (uint)style); UnmanagedMethods.ShowWindow(_hwnd, ShowWindowCommand.Show);