diff --git a/samples/ControlCatalog/MainWindow.xaml.cs b/samples/ControlCatalog/MainWindow.xaml.cs index 413794dfa2..ef86b1a434 100644 --- a/samples/ControlCatalog/MainWindow.xaml.cs +++ b/samples/ControlCatalog/MainWindow.xaml.cs @@ -1,6 +1,7 @@ using Avalonia; using Avalonia.Controls; using Avalonia.Markup.Xaml; +using System; namespace ControlCatalog { @@ -10,7 +11,8 @@ namespace ControlCatalog { this.InitializeComponent(); this.AttachDevTools(); - Renderer.DrawDirtyRects = Renderer.DrawFps = true; + //Renderer.DrawDirtyRects = Renderer.DrawFps = true; + PlatformImpl.ShowTaskbarIcon(false); } private void InitializeComponent() diff --git a/src/Avalonia.Controls/Platform/IWindowImpl.cs b/src/Avalonia.Controls/Platform/IWindowImpl.cs index 69b946346e..d56cdc4e19 100644 --- a/src/Avalonia.Controls/Platform/IWindowImpl.cs +++ b/src/Avalonia.Controls/Platform/IWindowImpl.cs @@ -39,5 +39,9 @@ namespace Avalonia.Platform /// Sets the icon of this window. /// void SetIcon(IWindowIconImpl icon); + + + + void ShowTaskbarIcon(bool value); } } diff --git a/src/Gtk/Avalonia.Gtk/WindowImpl.cs b/src/Gtk/Avalonia.Gtk/WindowImpl.cs index d8555b4e05..4c0eacbcf5 100644 --- a/src/Gtk/Avalonia.Gtk/WindowImpl.cs +++ b/src/Gtk/Avalonia.Gtk/WindowImpl.cs @@ -127,5 +127,10 @@ namespace Avalonia.Gtk { Window.Icon = ((IconImpl)icon).Pixbuf; } + + public void ShowTaskbarIcon(bool value) + { + Window.SkipTaskbarHint = !value; + } } } diff --git a/src/Gtk/Avalonia.Gtk3/Interop/Native.cs b/src/Gtk/Avalonia.Gtk3/Interop/Native.cs index fb1a9955e3..c212807c6a 100644 --- a/src/Gtk/Avalonia.Gtk3/Interop/Native.cs +++ b/src/Gtk/Avalonia.Gtk3/Interop/Native.cs @@ -38,6 +38,9 @@ namespace Avalonia.Gtk3.Interop [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] public delegate void gtk_widget_hide(GtkWidget gtkWidget); + [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] + public delegate void gtk_widget_show(GtkWidget gtkWidget); + [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] public delegate void gtk_window_set_icon(GtkWindow window, Pixbuf pixbuf); @@ -75,7 +78,6 @@ namespace Avalonia.Gtk3.Interop [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gdk)] public delegate void gdk_window_resize(IntPtr gtkWindow, int width, int height); - [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] public delegate void gtk_widget_realize(GtkWidget gtkWidget); @@ -86,6 +88,13 @@ namespace Avalonia.Gtk3.Interop [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] public delegate void gtk_window_set_decorated(GtkWindow gtkWindow, bool decorated); + [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] + public delegate void gtk_window_set_skip_taskbar_hint(GtkWindow gtkWindow, bool setting); + [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] + public delegate void gtk_window_set_skip_pager_hint(GtkWindow gtkWindow, bool setting); + [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] + public delegate bool gtk_window_get_skip_taskbar_hint(GtkWindow gtkWindow); + [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] public delegate void gtk_window_get_size(GtkWindow gtkWindow, out int width, out int height); [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] @@ -271,6 +280,9 @@ namespace Avalonia.Gtk3.Interop public static D.gtk_window_set_decorated GtkWindowSetDecorated; + public static D.gtk_window_set_skip_taskbar_hint GtkWindowSetSkipTaskbarHint; + public static D.gtk_window_set_skip_pager_hint GtkWindowSetSkipPagerHint; + public static D.gtk_window_get_skip_taskbar_hint GtkWindowGetSkipTaskbarHint; public static D.gtk_window_set_title GtkWindowSetTitle; public static D.gtk_application_new GtkApplicationNew; public static D.gtk_main_iteration GtkMainIteration; @@ -280,6 +292,7 @@ namespace Avalonia.Gtk3.Interop public static D.gtk_init GtkInit; public static D.gtk_window_present GtkWindowPresent; public static D.gtk_widget_hide GtkWidgetHide; + public static D.gtk_widget_show GtkWidgetShow; public static D.gdk_get_native_handle GetNativeGdkWindowHandle; public static D.gtk_widget_get_window GtkWidgetGetWindow; public static D.gtk_widget_get_scale_factor GtkWidgetGetScaleFactor; diff --git a/src/Gtk/Avalonia.Gtk3/WindowImpl.cs b/src/Gtk/Avalonia.Gtk3/WindowImpl.cs index f083185a84..df834561d4 100644 --- a/src/Gtk/Avalonia.Gtk3/WindowImpl.cs +++ b/src/Gtk/Avalonia.Gtk3/WindowImpl.cs @@ -2,6 +2,7 @@ using Avalonia.Controls; using Avalonia.Gtk3.Interop; using Avalonia.Platform; +using System.Runtime.InteropServices; namespace Avalonia.Gtk3 { @@ -59,6 +60,11 @@ namespace Avalonia.Gtk3 //Why do we even have that? } + public void ShowTaskbarIcon(bool value) + { + Native.GtkWindowSetSkipTaskbarHint(GtkWidget, !value); + } + class EmptyDisposable : IDisposable { public void Dispose() diff --git a/src/Windows/Avalonia.Win32/WindowImpl.cs b/src/Windows/Avalonia.Win32/WindowImpl.cs index 4a30d48878..bb2d4e808c 100644 --- a/src/Windows/Avalonia.Win32/WindowImpl.cs +++ b/src/Windows/Avalonia.Win32/WindowImpl.cs @@ -750,5 +750,22 @@ namespace Avalonia.Win32 return (int)(ptr.ToInt64() & 0xffffffff); } + + public void ShowTaskbarIcon(bool value) + { + var style = (UnmanagedMethods.WindowStyles)UnmanagedMethods.GetWindowLong(_hwnd, -20); + + style &= ~(UnmanagedMethods.WindowStyles.WS_VISIBLE); + + style |= UnmanagedMethods.WindowStyles.WS_EX_TOOLWINDOW; + if (value) + style |= UnmanagedMethods.WindowStyles.WS_EX_APPWINDOW; + else + style &= ~(UnmanagedMethods.WindowStyles.WS_EX_APPWINDOW); + + UnmanagedMethods.ShowWindow(_hwnd, ShowWindowCommand.Hide); + UnmanagedMethods.SetWindowLong(_hwnd, -20, (uint)style); + UnmanagedMethods.ShowWindow(_hwnd, ShowWindowCommand.Show); + } } }