mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-02-24 18:16:58 +00:00
[X11] Set WM_CLASS property
This allows Ubuntu Unity and Gnome Shell to detect and display the correct application name.
This commit is contained in:
parent
47ffbe3501
commit
a79086bb20
|
@ -513,6 +513,9 @@ namespace OpenTK.Platform.X11
|
||||||
[DllImport("libX11")]
|
[DllImport("libX11")]
|
||||||
public static extern void XFreeEventData(IntPtr display, ref XGenericEventCookie cookie);
|
public static extern void XFreeEventData(IntPtr display, ref XGenericEventCookie cookie);
|
||||||
|
|
||||||
|
[DllImport("libX11")]
|
||||||
|
public static extern void XSetClassHint(IntPtr display, IntPtr window, ref XClassHint hint);
|
||||||
|
|
||||||
[DllImport("libXi")]
|
[DllImport("libXi")]
|
||||||
static extern int XISelectEvents(IntPtr dpy, Window win, [In] XIEventMask[] masks, int num_masks);
|
static extern int XISelectEvents(IntPtr dpy, Window win, [In] XIEventMask[] masks, int num_masks);
|
||||||
[DllImport("libXi")]
|
[DllImport("libXi")]
|
||||||
|
|
|
@ -748,6 +748,14 @@ namespace OpenTK.Platform.X11
|
||||||
public IntPtr nitems;
|
public IntPtr nitems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal struct XClassHint
|
||||||
|
{
|
||||||
|
[MarshalAs(UnmanagedType.LPStr)]
|
||||||
|
public string Name;
|
||||||
|
[MarshalAs(UnmanagedType.LPStr)]
|
||||||
|
public string Class;
|
||||||
|
}
|
||||||
|
|
||||||
internal enum XWindowClass
|
internal enum XWindowClass
|
||||||
{
|
{
|
||||||
InputOutput = 1,
|
InputOutput = 1,
|
||||||
|
|
|
@ -89,6 +89,8 @@ namespace OpenTK.Platform.X11
|
||||||
|
|
||||||
IntPtr _atom_net_frame_extents;
|
IntPtr _atom_net_frame_extents;
|
||||||
|
|
||||||
|
IntPtr _atom_wm_class;
|
||||||
|
|
||||||
readonly IntPtr _atom_xa_cardinal = new IntPtr(6);
|
readonly IntPtr _atom_xa_cardinal = new IntPtr(6);
|
||||||
|
|
||||||
//IntPtr _atom_motif_wm_hints;
|
//IntPtr _atom_motif_wm_hints;
|
||||||
|
@ -194,12 +196,20 @@ namespace OpenTK.Platform.X11
|
||||||
hints.base_width = width;
|
hints.base_width = width;
|
||||||
hints.base_height = height;
|
hints.base_height = height;
|
||||||
hints.flags = (IntPtr)(XSizeHintsFlags.PSize | XSizeHintsFlags.PPosition);
|
hints.flags = (IntPtr)(XSizeHintsFlags.PSize | XSizeHintsFlags.PPosition);
|
||||||
|
|
||||||
|
XClassHint class_hint = new XClassHint();
|
||||||
|
class_hint.Name = Assembly.GetEntryAssembly().GetName().Name.ToLower();
|
||||||
|
class_hint.Class = Assembly.GetEntryAssembly().GetName().Name;
|
||||||
|
|
||||||
using (new XLock(window.Display))
|
using (new XLock(window.Display))
|
||||||
{
|
{
|
||||||
Functions.XSetWMNormalHints(window.Display, window.Handle, ref hints);
|
Functions.XSetWMNormalHints(window.Display, window.Handle, ref hints);
|
||||||
|
|
||||||
// Register for window destroy notification
|
// Register for window destroy notification
|
||||||
Functions.XSetWMProtocols(window.Display, window.Handle, new IntPtr[] { _atom_wm_destroy }, 1);
|
Functions.XSetWMProtocols(window.Display, window.Handle, new IntPtr[] { _atom_wm_destroy }, 1);
|
||||||
|
|
||||||
|
// Set the window class hints
|
||||||
|
Functions.XSetClassHint(window.Display, window.Handle, ref class_hint);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the initial window size to ensure X, Y, Width, Height and the rest
|
// Set the initial window size to ensure X, Y, Width, Height and the rest
|
||||||
|
@ -296,7 +306,7 @@ namespace OpenTK.Platform.X11
|
||||||
|
|
||||||
_atom_net_frame_extents =
|
_atom_net_frame_extents =
|
||||||
Functions.XInternAtom(window.Display, "_NET_FRAME_EXTENTS", false);
|
Functions.XInternAtom(window.Display, "_NET_FRAME_EXTENTS", false);
|
||||||
|
|
||||||
// string[] atom_names = new string[]
|
// string[] atom_names = new string[]
|
||||||
// {
|
// {
|
||||||
// //"WM_TITLE",
|
// //"WM_TITLE",
|
||||||
|
|
Loading…
Reference in a new issue