summaryrefslogtreecommitdiff
path: root/ElmSharp/Interop/Interop.Elementary.Win.cs
blob: a04a6d5185d803e1e1c2364d4e366723e77964e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
/*
 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
 *
 * Licensed under the Apache License, Version 2.0 (the License);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

using ElmSharp;
using System;
using System.Runtime.InteropServices;

internal static partial class Interop
{
    internal static partial class Elementary
    {
        [DllImport(Libraries.Elementary)]
        internal static extern IntPtr elm_win_add(IntPtr parent, string name, int type);

        [DllImport(Libraries.Elementary)]
        internal static extern IntPtr elm_win_util_standard_add(string name, string title);

        [DllImport(Libraries.Elementary)]
        internal static extern void elm_win_activate(IntPtr obj);

        [DllImport(Libraries.Elementary)]
        internal static extern void elm_win_title_set(IntPtr obj, string title);

        [DllImport(Libraries.Elementary, EntryPoint = "elm_win_title_get", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, CharSet = CharSet.Ansi)]
        internal static extern IntPtr _elm_win_title_get(IntPtr obj);

        internal static string elm_win_title_get(IntPtr obj)
        {
            var text = _elm_win_title_get(obj);
            return Marshal.PtrToStringAnsi(text);
        }

        [DllImport(Libraries.Elementary)]
        internal static extern void elm_win_screen_size_get(IntPtr obj, out int x, out int y, out int w, out int h);

        [DllImport(Libraries.Elementary)]
        internal static extern void elm_win_resize_object_del(IntPtr obj, IntPtr subobj);

        [DllImport(Libraries.Elementary)]
        internal static extern void elm_win_resize_object_add(IntPtr obj, IntPtr subobj);

        [DllImport(Libraries.Elementary)]
        internal static extern void elm_win_raise(IntPtr obj);

        [DllImport(Libraries.Elementary)]
        internal static extern void elm_win_lower(IntPtr obj);

        [DllImport(Libraries.Elementary)]
        internal static extern bool elm_win_alpha_get(IntPtr obj);

        [DllImport(Libraries.Elementary)]
        internal static extern void elm_win_alpha_set(IntPtr obj, bool alpha);

        [DllImport(Libraries.Elementary)]
        internal static extern IntPtr _elm_win_role_get(IntPtr obj);

        internal static string elm_win_role_get(IntPtr obj)
        {
            var text = _elm_win_role_get(obj);
            return Marshal.PtrToStringAnsi(text);
        }

        [DllImport(Libraries.Elementary)]
        internal static extern void elm_win_role_set(IntPtr obj, string role);

        [DllImport(Libraries.Elementary)]
        internal static extern string elm_win_focus_highlight_style_get(IntPtr obj);

        [DllImport(Libraries.Elementary)]
        internal static extern void elm_win_focus_highlight_style_set(IntPtr obj, string style);

        [DllImport(Libraries.Elementary)]
        internal static extern void elm_win_borderless_set(IntPtr obj, bool borderless);

        [DllImport(Libraries.Elementary)]
        internal static extern void elm_win_focus_highlight_enabled_set(IntPtr obj, bool enabled);

        [DllImport(Libraries.Elementary)]
        internal static extern bool elm_win_focus_highlight_enabled_get(IntPtr obj);

        [DllImport(Libraries.Elementary)]
        internal static extern void elm_win_autodel_set(IntPtr obj, bool autodel);

        [DllImport(Libraries.Elementary)]
        internal static extern bool elm_win_autodel_get(IntPtr obj);

        [DllImport(Libraries.Elementary)]
        internal static extern void elm_win_override_set(IntPtr obj, bool isOverride);

        [DllImport(Libraries.Elementary)]
        internal static extern void elm_win_indicator_opacity_set(IntPtr obj, int opacity);

        [DllImport(Libraries.Elementary)]
        internal static extern int elm_win_indicator_opacity_get(IntPtr obj);

        [DllImport(Libraries.Elementary)]
        internal static extern void elm_win_indicator_mode_set(IntPtr obj, IndicatorMode mode);

        [DllImport(Libraries.Elementary)]
        internal static extern IndicatorMode elm_win_indicator_mode_get(IntPtr obj);

        [DllImport(Libraries.Elementary)]
        internal static extern void elm_win_demand_attention_set(IntPtr obj, bool demandAttention);

        [DllImport(Libraries.Elementary)]
        internal static extern void elm_win_conformant_set(IntPtr obj, bool conformant);

        [DllImport(Libraries.Elementary)]
        internal static extern bool elm_win_fullscreen_get(IntPtr obj);

        [DllImport(Libraries.Elementary)]
        internal static extern void elm_win_fullscreen_set(IntPtr obj, bool fullscreen);

        [DllImport(Libraries.Elementary)]
        internal static extern void elm_win_rotation_set(IntPtr obj, int rotation);

        [DllImport(Libraries.Elementary)]
        internal static extern int elm_win_rotation_get(IntPtr obj);

        [DllImport(Libraries.Elementary)]
        internal static extern void elm_win_rotation_with_resize_set(IntPtr obj, int rotation);

        [DllImport(Libraries.Elementary)]
        internal static extern void elm_win_prop_focus_skip_set(IntPtr obj, bool skip);

        [DllImport(Libraries.Elementary)]
        internal static extern bool elm_win_wm_rotation_supported_get(IntPtr obj);

        [DllImport(Libraries.Elementary)]
        internal static extern bool elm_win_focus_get(IntPtr obj);

        [DllImport(Libraries.Elementary, EntryPoint = "elm_win_wm_rotation_available_rotations_set")]
        internal static extern void _elm_win_wm_rotation_available_rotations_set(IntPtr obj, IntPtr rotations, uint count);

        internal static void elm_win_wm_rotation_available_rotations_set(IntPtr obj, int[] rotations)
        {
            IntPtr pRotations = Marshal.AllocHGlobal(Marshal.SizeOf<int>() * rotations.Length);
            Marshal.Copy(rotations, 0, pRotations, rotations.Length);
            _elm_win_wm_rotation_available_rotations_set(obj, pRotations, (uint)rotations.Length);
            Marshal.FreeHGlobal(pRotations);
        }

        [DllImport(Libraries.Elementary, EntryPoint = "elm_win_wm_rotation_available_rotations_get")]
        internal static extern bool _elm_win_wm_rotation_available_rotations_get(IntPtr obj, out IntPtr rotations, out int count);

        internal static bool elm_win_wm_rotation_available_rotations_get(IntPtr obj, out int[] rotations)
        {
            IntPtr rotationArrPtr;
            int count;
            if (_elm_win_wm_rotation_available_rotations_get(obj, out rotationArrPtr, out count))
            {
                rotations = new int[count];
                Marshal.Copy(rotationArrPtr, rotations, 0, count);
                Libc.Free(rotationArrPtr);
                return true;
            }
            rotations = null;
            return false;
        }

        [DllImport(Libraries.Elementary)]
        internal static extern void elm_win_layer_set(IntPtr obj, int layer);

        [DllImport(Libraries.Elementary)]
        internal static extern void elm_win_sticky_set(IntPtr obj, bool sticky);

        [DllImport(Libraries.Elementary)]
        internal static extern void elm_win_screen_dpi_get(IntPtr obj, out int xdpi, out int ydpi);

        [DllImport(Libraries.Elementary)]
        internal static extern void elm_win_iconified_set(IntPtr obj, bool iconified);

        [DllImport(Libraries.Elementary)]
        [return: MarshalAs(UnmanagedType.U1)]
        internal static extern bool elm_win_iconified_get(IntPtr obj);

        [DllImport(Libraries.Elementary)]
        internal static extern void elm_win_floating_mode_set(IntPtr obj, bool floating);

        [DllImport(Libraries.Elementary)]
        [return: MarshalAs(UnmanagedType.U1)]
        internal static extern bool elm_win_keygrab_set(IntPtr obj, string key, ulong  modifiers, ulong notModifiers, int proirity, KeyGrabMode grabMode);

        [DllImport(Libraries.Elementary)]
        [return: MarshalAs(UnmanagedType.U1)]
        internal static extern bool elm_win_keygrab_unset(IntPtr obj, string key, ulong modifiers, ulong notModifiers);

        [DllImport(Libraries.Eext)]
        internal static extern bool eext_win_keygrab_set(IntPtr obj, string key);

        [DllImport(Libraries.Eext)]
        internal static extern bool eext_win_keygrab_unset(IntPtr obj, string key);

        [DllImport(Libraries.Elementary)]
        internal static extern void elm_win_keyboard_win_set(IntPtr obj, bool isKeyboard);

        [DllImport(Libraries.Elementary)]
        internal static extern void elm_win_keyboard_mode_set(IntPtr obj, Elm_Win_Keyboard_Mode mode);

        internal enum Elm_Win_Keyboard_Mode
        {
            ELM_WIN_KEYBOARD_UNKNOWN,
            ELM_WIN_KEYBOARD_OFF,
            ELM_WIN_KEYBOARD_ON,
            ELM_WIN_KEYBOARD_ALPHA,
            ELM_WIN_KEYBOARD_NUMERIC,
            ELM_WIN_KEYBOARD_PIN,
            ELM_WIN_KEYBOARD_PHONE_NUMBER,
            ELM_WIN_KEYBOARD_HEX,
            ELM_WIN_KEYBOARD_TERMINAL,
            ELM_WIN_KEYBOARD_PASSWORD,
            ELM_WIN_KEYBOARD_IP,
            ELM_WIN_KEYBOARD_HOST,
            ELM_WIN_KEYBOARD_FILE,
            ELM_WIN_KEYBOARD_URL,
            ELM_WIN_KEYBOARD_KEYPAD,
            ELM_WIN_KEYBOARD_J2ME,
        }
    }
}