I really want explain about SDL2 with XLib/X11

Hello everyone,

I have readden very old forum by meuchel,

I have replaced to new version of SDL2

Please remember that:
Ccreate variable or static variable to xdisplay and xwindow
Make SDL_CreateTransparentWindow() or whatever do you want create oen function with instance of SDL_Window
Make sure for closing / destroying
like this:

(Create some variable)
(Make functions with SDL_Window or other)
(If you want make Event then you should have methods for Event with XLib/X11)
(Closing / destroying)

void SDL_Quit_XLib(void)
{
    .... // example rootwindow or multiple window etc...
    if (xdisplay && xwindow)
    {
        XDestroyWindow(xdisplay, xwindow);
        if (xdisplay)
            XCloseDisplay(xdisplay);
    }
} 

I hope I help you good.

For C# also

Example:

using System;
using static SDL2.SDL; // By Ethan Lee
using static XLib.X11; // My own XLib Wrapper

namespace SDL2Exts
{
    public static class SDL2Extensions
    {
        private static IntPtr xdisplay;
        private static IntPtr xwindow;
        //  .... any variables if you need... like Instances of VisualInfo, Colormap or GC etc...

        public static IntPtr SDL_DesktopRootWindow()
        {
            xdisplay = XOpenDisplay(string.Empty);
            xwindow = XRootWindow(xdisplay, XDefaultScreen(xdisplay));

            XMapWindow(xdisplay, xwindow);
            XFlush(xdisplay);

            return SDL_CreateWindowFrom(xwindow);
        }

        //  .... Any custom SDL_Window Creations like SDL_CreateMultipleiWindow or whateverr

        public static void SDL_Event_XLib()
        {
            //  .... If you have our XLib need to access Event then you need write it.
        }

        public static void SDL_Quit_XLib()
        {
            if (xdisplay != IntPtr.Zero && xwindow != IntPtr.Zero)
            {
                XDestroyWindow(xdisplay, xwindow);
                if (xdisplay != IntPtr.Zero)
                {
                    XCloseDisplay(xdisplay);
                    Environment.Exit(0);
                }
            }
        }


    }
}

And create SDL2 app for C#

using System;
using SDL2Exts;
namespace SDL2App
{
    public class SDL2Main
    {
        static int Main()
        {
            SDL_Init(SDL_INIT_EVERYTHING);

            IntPtr rootwin = SDL2Extensions.SDL_DesktopRootWindow();

            SDL_ShowWindow(rootwin);

            //  ...

            SDL_Quit();
            SDL2Extensions.SDL_Quit_XLib();

            return 0;
        }
    }
}

That is all.
// EDIT:
If you use cross platform then you need switch-case or if-else statements like this

switch(Environment.OSVersion.Platform)
{
    case PlatformID.MacOSX:
        // API of Cocoa or AppKit
        break;
    case PlatformID.Unix:
        // API of XLib, GLib/GDK or Wayland etc
        break;
    case PlatformID.Win32NT:
        // API of WinAPI
        break;
}

// -- OR --

if (Environment.OSVersion.Platform == PlatformID.MacOSX)
{
    // API of Cocoa or AppKit
}
else if (Environment.OSVersion.Platform == PlatformID.Unix)
{
    // API of XLib, GLib/GDK or Wayland etc
}
else if (Environment.OSVersion.Platform == PlatformID.Win32NT)
{
    // API of WinAPI
}

I hope you understand how do I create simple “Advanced SDL2 Window Manager”