aboutsummaryrefslogtreecommitdiffstats
path: root/src/androidgui.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/androidgui.h')
-rw-r--r--src/androidgui.h315
1 files changed, 315 insertions, 0 deletions
diff --git a/src/androidgui.h b/src/androidgui.h
new file mode 100644
index 00000000000..43ccc86e5c7
--- /dev/null
+++ b/src/androidgui.h
@@ -0,0 +1,315 @@
1/* Android window system support.
2 Copyright (C) 2023 Free Software Foundation, Inc.
3
4This file is part of GNU Emacs.
5
6GNU Emacs is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation, either version 3 of the License, or (at
9your option) any later version.
10
11GNU Emacs is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
18
19#ifndef _ANDROID_GUI_H_
20#define _ANDROID_GUI_H_
21
22struct android_char_struct
23{
24 int rbearing;
25 int lbearing;
26 int width;
27 int ascent;
28 int descent;
29};
30
31typedef struct android_char_struct XCharStruct;
32
33typedef unsigned short android_handle;
34
35typedef android_handle android_pixmap, Emacs_Pixmap;
36typedef android_handle android_window, Emacs_Window;
37typedef android_handle android_gcontext, GContext;
38typedef android_handle android_drawable, Drawable;
39
40typedef unsigned int android_time;
41
42struct android_rectangle
43{
44 int x, y;
45 unsigned width, height;
46};
47
48struct android_point
49{
50 int x, y;
51};
52
53/* Keep this in sync with EmacsGC.java! */
54
55enum android_gc_function
56 {
57 ANDROID_GC_COPY = 0,
58 ANDROID_GC_XOR = 1,
59 };
60
61enum android_gc_value_mask
62 {
63 ANDROID_GC_FOREGROUND = (1 << 0),
64 ANDROID_GC_BACKGROUND = (1 << 1),
65 ANDROID_GC_FUNCTION = (1 << 2),
66 ANDROID_GC_CLIP_X_ORIGIN = (1 << 3),
67 ANDROID_GC_CLIP_Y_ORIGIN = (1 << 4),
68 ANDROID_GC_CLIP_MASK = (1 << 5),
69 ANDROID_GC_STIPPLE = (1 << 6),
70 ANDROID_GC_FILL_STYLE = (1 << 7),
71 ANDROID_GC_TILE_STIP_X_ORIGIN = (1 << 8),
72 ANDROID_GC_TILE_STIP_Y_ORIGIN = (1 << 9),
73 };
74
75enum android_fill_style
76 {
77 ANDROID_FILL_SOLID = 0,
78 ANDROID_FILL_OPAQUE_STIPPLED = 1,
79 };
80
81enum android_window_value_mask
82 {
83 ANDROID_CW_BACK_PIXEL = (1 << 1),
84 };
85
86struct android_set_window_attributes
87{
88 /* The background pixel. */
89 unsigned long background_pixel;
90};
91
92struct android_gc_values
93{
94 /* The foreground and background. */
95 unsigned long foreground, background;
96
97 /* The function. */
98 enum android_gc_function function;
99
100 /* The fill style. */
101 enum android_fill_style fill_style;
102
103 /* The clip X and Y origin. */
104 int clip_x_origin, clip_y_origin;
105
106 /* The clip mask image and stipple. */
107 android_pixmap clip_mask, stipple;
108
109 /* The tile-stipple X and Y origins. */
110 int ts_x_origin, ts_y_origin;
111};
112
113/* X-like graphics context structure. This is implemented in
114 EmacsGC.java, but a copy is kept here to avoid sending changes all
115 the time. */
116
117struct android_gc
118{
119 /* The Java-side handle. */
120 android_gcontext gcontext;
121};
122
123enum android_swap_action
124 {
125 ANDROID_COPIED,
126 };
127
128enum android_shape
129 {
130 ANDROID_CONVEX,
131 };
132
133enum android_coord_mode
134 {
135 ANDROID_COORD_MODE_ORIGIN,
136 };
137
138struct android_swap_info
139{
140 /* The window to swap. */
141 android_window swap_window;
142
143 /* Unused field present only for consistency with X. */
144 enum android_swap_action swap_action;
145};
146
147/* Android doesn't support cursors, so define this to something
148 unused. */
149typedef char Emacs_Cursor;
150
151#define NativeRectangle Emacs_Rectangle
152#define CONVERT_TO_NATIVE_RECT(xr, nr) ((xr) = (nr))
153#define CONVERT_FROM_EMACS_RECT(xr, nr) ((nr) = (xr))
154
155#define STORE_NATIVE_RECT(nr, rx, ry, rwidth, rheight) \
156 ((nr).x = (rx), (nr).y = (ry), \
157 (nr).width = (rwidth), (nr).height = (rheight)) \
158
159#define ForgetGravity 0
160#define NorthWestGravity 1
161#define NorthGravity 2
162#define NorthEastGravity 3
163#define WestGravity 4
164#define CenterGravity 5
165#define EastGravity 6
166#define SouthWestGravity 7
167#define SouthGravity 8
168#define SouthEastGravity 9
169#define StaticGravity 10
170
171#define NoValue 0x0000
172#define XValue 0x0001
173#define YValue 0x0002
174#define WidthValue 0x0004
175#define HeightValue 0x0008
176#define AllValues 0x000F
177#define XNegative 0x0010
178#define YNegative 0x0020
179
180#define USPosition (1L << 0) /* user specified x, y */
181#define USSize (1L << 1) /* user specified width, height */
182#define PPosition (1L << 2) /* program specified position */
183#define PSize (1L << 3) /* program specified size */
184#define PMinSize (1L << 4) /* program specified minimum size */
185#define PMaxSize (1L << 5) /* program specified maximum size */
186#define PResizeInc (1L << 6) /* program specified resize increments */
187#define PAspect (1L << 7) /* program specified min, max aspect ratios */
188#define PBaseSize (1L << 8) /* program specified base for incrementing */
189#define PWinGravity (1L << 9) /* program specified window gravity */
190
191#ifndef ANDROID_STUBIFY
192
193/* Universal NULL handle. */
194static const int ANDROID_NONE;
195
196/* Keep these as conceptually close to X as possible: that makes
197 synchronizing code between the ports much easier. */
198
199enum android_event_type
200 {
201 ANDROID_KEY_PRESS,
202 ANDROID_KEY_RELEASE,
203 ANDROID_CONFIGURE_NOTIFY,
204 };
205
206struct android_any_event
207{
208 enum android_event_type type;
209 android_window window;
210};
211
212struct android_key_event
213{
214 enum android_event_type type;
215 android_window window;
216 android_time time;
217 unsigned int state;
218 unsigned int keycode;
219};
220
221struct android_configure_event
222{
223 enum android_event_type type;
224 android_window window;
225 android_time time;
226 int x, y;
227 int width, height;
228};
229
230union android_event
231{
232 enum android_event_type type;
233 struct android_any_event xany;
234 struct android_key_event xkey;
235 struct android_configure_event xconfigure;
236};
237
238extern int android_pending (void);
239extern void android_next_event (union android_event *);
240
241extern android_window android_create_window (android_window, int,
242 int, int, int,
243 enum android_window_value_mask,
244 struct
245 android_set_window_attributes *);
246extern void android_change_window_attributes (android_window,
247 enum android_window_value_mask,
248 struct
249 android_set_window_attributes *);
250extern void android_set_window_background (android_window, unsigned long);
251extern void android_destroy_window (android_window);
252extern void android_reparent_window (android_window, android_window,
253 int, int);
254extern void android_set_clip_rectangles (struct android_gc *,
255 int, int,
256 struct android_rectangle *,
257 int);
258extern void android_change_gc (struct android_gc *,
259 enum android_gc_value_mask,
260 struct android_gc_values *);
261
262extern void android_clear_window (android_window);
263extern void android_map_window (android_window);
264extern void android_unmap_window (android_window);
265extern void android_resize_window (android_window, unsigned int,
266 unsigned int);
267extern void android_move_window (android_window, int, int);
268extern void android_swap_buffers (struct android_swap_info *, int);
269extern void android_get_gc_values (struct android_gc *,
270 enum android_gc_value_mask,
271 struct android_gc_values *);
272extern void android_set_foreground (struct android_gc *,
273 unsigned long);
274extern void android_fill_rectangle (android_drawable, struct android_gc *,
275 int, int, unsigned int, unsigned int);
276extern android_pixmap android_create_pixmap_from_bitmap_data (char *,
277 unsigned int,
278 unsigned int,
279 unsigned long,
280 unsigned long,
281 unsigned int);
282extern void android_set_clip_mask (struct android_gc *, android_pixmap);
283extern void android_set_fill_style (struct android_gc *,
284 enum android_fill_style);
285extern void android_copy_area (android_drawable, android_drawable,
286 struct android_gc *, int, int,
287 unsigned int, unsigned int, int, int);
288extern void android_free_pixmap (android_drawable);
289
290extern void android_set_background (struct android_gc *, unsigned long);
291extern void android_fill_polygon (android_drawable, struct android_gc *,
292 struct android_point *, int,
293 enum android_shape,
294 enum android_coord_mode);
295extern void android_draw_rectangle (android_drawable, struct android_gc *,
296 int, int, unsigned int, unsigned int);
297extern void android_draw_point (android_window, struct android_gc *,
298 int, int);
299extern void android_draw_line (android_window, struct android_gc *,
300 int, int, int, int);
301extern android_pixmap android_create_pixmap (unsigned int, unsigned int,
302 int);
303extern void android_set_ts_origin (struct android_gc *, int, int);
304extern void android_clear_area (android_window, int, int, unsigned int,
305 unsigned int);
306
307#endif
308
309/* X emulation stuff also needed while building stubs. */
310
311extern struct android_gc *android_create_gc (enum android_gc_value_mask,
312 struct android_gc_values *);
313extern void android_free_gc (struct android_gc *);
314
315#endif /* _ANDROID_GUI_H_ */