зеркало из https://github.com/AvaloniaUI/Avalonia.git
Added ShowTaskbarIcon implementation
This commit is contained in:
Родитель
7605909c79
Коммит
d278c5ddeb
|
@ -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()
|
||||
|
|
|
@ -39,5 +39,9 @@ namespace Avalonia.Platform
|
|||
/// Sets the icon of this window.
|
||||
/// </summary>
|
||||
void SetIcon(IWindowIconImpl icon);
|
||||
|
||||
|
||||
|
||||
void ShowTaskbarIcon(bool value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -127,5 +127,10 @@ namespace Avalonia.Gtk
|
|||
{
|
||||
Window.Icon = ((IconImpl)icon).Pixbuf;
|
||||
}
|
||||
|
||||
public void ShowTaskbarIcon(bool value)
|
||||
{
|
||||
Window.SkipTaskbarHint = !value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче