1 #pragma warning disable 1591
4 using System.Runtime.InteropServices;
5 using System.Threading;
7 using static Efl.UnsafeNativeMethods;
11 static class UnsafeNativeMethods {
13 private delegate void init_func_delegate();
14 [DllImport(efl.Libs.Ecore)] public static extern void ecore_init();
15 [DllImport(efl.Libs.Ecore)] public static extern void ecore_shutdown();
16 // dotnet loads libraries from DllImport with RTLD_LOCAL. Due to the
17 // way evas modules are built with meson, currently they do not link directly
18 // with libevas, leading to symbol not found errors when trying to open them.
19 // The call to FunctionWrapper makes sure evas is loaded with RTLD_GLOBAL,
20 // allowing the symbols to remain visible for the modules until the build
22 private static Efl.Eo.FunctionWrapper<init_func_delegate> _evas_init;
23 [DllImport(efl.Libs.Evas)] public static extern void evas_shutdown();
24 [DllImport(efl.Libs.Elementary)] public static extern int elm_init(int argc, IntPtr argv);
25 [DllImport(efl.Libs.Elementary)] public static extern void elm_policy_set(int policy, int policy_detail);
26 [DllImport(efl.Libs.Elementary)] public static extern void elm_shutdown();
27 [DllImport(efl.Libs.Elementary)] public static extern void elm_run();
28 [DllImport(efl.Libs.Elementary)] public static extern void elm_exit();
30 static UnsafeNativeMethods() {
31 _evas_init = new Efl.Eo.FunctionWrapper<init_func_delegate>("evas", "evas_init");
33 public static void evas_init()
35 _evas_init.Value.Delegate();
39 public enum Components {
44 public static class All {
45 private static bool InitializedUi = false;
47 public static void Init(Efl.Components components=Components.Basic) {
54 if (components == Components.Ui) {
60 /// <summary>Shutdowns all EFL subsystems.</summary>
61 public static void Shutdown() {
62 // Try to cleanup everything before actually shutting down.
64 System.GC.WaitForPendingFinalizers();
67 Efl.Ui.Config.Shutdown();
68 eldbus.Config.Shutdown();
71 Efl.Eo.Config.Shutdown();
72 Eina.Config.Shutdown();
76 // Placeholder. Will move to elm_config.cs later
79 public static class Config {
80 public static void Init() {
81 // TODO Support elm command line arguments
82 #if WIN32 // Not a native define, we define it in our build system
83 // Ecore_Win32 uses OleInitialize, which requires single thread apartments
84 if (System.Threading.Thread.CurrentThread.GetApartmentState() != ApartmentState.STA)
85 throw new InvalidOperationException("UI Applications require STAThreadAttribute in Main()");
87 elm_init(0, IntPtr.Zero);
89 elm_policy_set((int)Elm.Policy.Quit, (int)Elm.PolicyQuit.LastWindowHidden);
91 public static void Shutdown() {
95 public static void Run() {
99 public static void Exit() {