1 /* -*- c-basic-offset:2; tab-width:2; indent-tabs-mode:nil -*- */
2 
3 #ifndef ___UI_H__
4 #define ___UI_H__
5 
6 /* If MAX_OS_X_VERSION_MAX_ALLOWED is defined, <Cocoa/Cocoa.h> has been already included. */
7 #if defined(COCOA_TOUCH) || !defined(MAC_OS_X_VERSION_MAX_ALLOWED)
8 
9 /* NSText.h */
10 
11 /* Various important Unicode code points */
12 enum {
13   NSEnterCharacter = 0x0003,
14   NSBackspaceCharacter = 0x0008,
15   NSTabCharacter = 0x0009,
16   NSNewlineCharacter = 0x000a,
17   NSFormFeedCharacter = 0x000c,
18   NSCarriageReturnCharacter = 0x000d,
19   NSBackTabCharacter = 0x0019,
20   NSDeleteCharacter = 0x007f,
21   NSLineSeparatorCharacter = 0x2028,
22   NSParagraphSeparatorCharacter = 0x2029
23 };
24 
25 /* NSObjCRuntime.h */
26 
27 #include <limits.h>
28 #define NSUIntegerMax ULONG_MAX
29 
30 /* NSEvent.h */
31 
32 enum { /* various types of events */
33   NSLeftMouseDown = 1,
34   NSLeftMouseUp = 2,
35   NSRightMouseDown = 3,
36   NSRightMouseUp = 4,
37   NSMouseMoved = 5,
38   NSLeftMouseDragged = 6,
39   NSRightMouseDragged = 7,
40   NSMouseEntered = 8,
41   NSMouseExited = 9,
42   NSKeyDown = 10,
43   NSKeyUp = 11,
44   NSFlagsChanged = 12,
45   NSAppKitDefined = 13,
46   NSSystemDefined = 14,
47   NSApplicationDefined = 15,
48   NSPeriodic = 16,
49   NSCursorUpdate = 17,
50   NSScrollWheel = 22,
51 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
52   NSTabletPoint = 23,
53   NSTabletProximity = 24,
54 #endif
55   NSOtherMouseDown = 25,
56   NSOtherMouseUp = 26,
57   NSOtherMouseDragged = 27,
58 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
59   /* The following event types are available on some hardware on 10.5.2 and later */
60   NSEventTypeGesture = 29,
61   NSEventTypeMagnify = 30,
62   NSEventTypeSwipe = 31,
63   NSEventTypeRotate = 18,
64   NSEventTypeBeginGesture = 19,
65   NSEventTypeEndGesture = 20
66 #endif
67 };
68 
69 enum { /* masks for the types of events */
70   NSLeftMouseDownMask = 1 << NSLeftMouseDown,
71   NSLeftMouseUpMask = 1 << NSLeftMouseUp,
72   NSRightMouseDownMask = 1 << NSRightMouseDown,
73   NSRightMouseUpMask = 1 << NSRightMouseUp,
74   NSMouseMovedMask = 1 << NSMouseMoved,
75   NSLeftMouseDraggedMask = 1 << NSLeftMouseDragged,
76   NSRightMouseDraggedMask = 1 << NSRightMouseDragged,
77   NSMouseEnteredMask = 1 << NSMouseEntered,
78   NSMouseExitedMask = 1 << NSMouseExited,
79   NSKeyDownMask = 1 << NSKeyDown,
80   NSKeyUpMask = 1 << NSKeyUp,
81   NSFlagsChangedMask = 1 << NSFlagsChanged,
82   NSAppKitDefinedMask = 1 << NSAppKitDefined,
83   NSSystemDefinedMask = 1 << NSSystemDefined,
84   NSApplicationDefinedMask = 1 << NSApplicationDefined,
85   NSPeriodicMask = 1 << NSPeriodic,
86   NSCursorUpdateMask = 1 << NSCursorUpdate,
87   NSScrollWheelMask = 1 << NSScrollWheel,
88 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
89   NSTabletPointMask = 1 << NSTabletPoint,
90   NSTabletProximityMask = 1 << NSTabletProximity,
91 #endif
92   NSOtherMouseDownMask = 1 << NSOtherMouseDown,
93   NSOtherMouseUpMask = 1 << NSOtherMouseUp,
94   NSOtherMouseDraggedMask = 1 << NSOtherMouseDragged,
95 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
96   /* The following event masks are available on some hardware on 10.5.2 and later */
97   NSEventMaskGesture = 1 << NSEventTypeGesture,
98   NSEventMaskMagnify = 1 << NSEventTypeMagnify,
99   NSEventMaskSwipe = 1U << NSEventTypeSwipe,
100   NSEventMaskRotate = 1 << NSEventTypeRotate,
101   NSEventMaskBeginGesture = 1 << NSEventTypeBeginGesture,
102   NSEventMaskEndGesture = 1 << NSEventTypeEndGesture,
103 #endif
104   NSAnyEventMask = NSUIntegerMax
105 };
106 
107 /* Device-independent bits found in event modifier flags */
108 enum {
109   NSAlphaShiftKeyMask = 1 << 16,
110   NSShiftKeyMask = 1 << 17,
111   NSControlKeyMask = 1 << 18,
112   NSAlternateKeyMask = 1 << 19,
113   NSCommandKeyMask = 1 << 20,
114   NSNumericPadKeyMask = 1 << 21,
115   NSHelpKeyMask = 1 << 22,
116   NSFunctionKeyMask = 1 << 23,
117 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
118   NSDeviceIndependentModifierFlagsMask = 0xffff0000UL
119 #endif
120 };
121 
122 /* Unicodes we reserve for function keys on the keyboard,  OpenStep reserves the
123  * range 0xF700-0xF8FF for this purpose.  The availability of various keys will
124  * be system dependent. */
125 enum {
126   NSUpArrowFunctionKey = 0xF700,
127   NSDownArrowFunctionKey = 0xF701,
128   NSLeftArrowFunctionKey = 0xF702,
129   NSRightArrowFunctionKey = 0xF703,
130   NSF1FunctionKey = 0xF704,
131   NSF2FunctionKey = 0xF705,
132   NSF3FunctionKey = 0xF706,
133   NSF4FunctionKey = 0xF707,
134   NSF5FunctionKey = 0xF708,
135   NSF6FunctionKey = 0xF709,
136   NSF7FunctionKey = 0xF70A,
137   NSF8FunctionKey = 0xF70B,
138   NSF9FunctionKey = 0xF70C,
139   NSF10FunctionKey = 0xF70D,
140   NSF11FunctionKey = 0xF70E,
141   NSF12FunctionKey = 0xF70F,
142   NSF13FunctionKey = 0xF710,
143   NSF14FunctionKey = 0xF711,
144   NSF15FunctionKey = 0xF712,
145   NSF16FunctionKey = 0xF713,
146   NSF17FunctionKey = 0xF714,
147   NSF18FunctionKey = 0xF715,
148   NSF19FunctionKey = 0xF716,
149   NSF20FunctionKey = 0xF717,
150   NSF21FunctionKey = 0xF718,
151   NSF22FunctionKey = 0xF719,
152   NSF23FunctionKey = 0xF71A,
153   NSF24FunctionKey = 0xF71B,
154   NSF25FunctionKey = 0xF71C,
155   NSF26FunctionKey = 0xF71D,
156   NSF27FunctionKey = 0xF71E,
157   NSF28FunctionKey = 0xF71F,
158   NSF29FunctionKey = 0xF720,
159   NSF30FunctionKey = 0xF721,
160   NSF31FunctionKey = 0xF722,
161   NSF32FunctionKey = 0xF723,
162   NSF33FunctionKey = 0xF724,
163   NSF34FunctionKey = 0xF725,
164   NSF35FunctionKey = 0xF726,
165   NSInsertFunctionKey = 0xF727,
166   NSDeleteFunctionKey = 0xF728,
167   NSHomeFunctionKey = 0xF729,
168   NSBeginFunctionKey = 0xF72A,
169   NSEndFunctionKey = 0xF72B,
170   NSPageUpFunctionKey = 0xF72C,
171   NSPageDownFunctionKey = 0xF72D,
172   NSPrintScreenFunctionKey = 0xF72E,
173   NSScrollLockFunctionKey = 0xF72F,
174   NSPauseFunctionKey = 0xF730,
175   NSSysReqFunctionKey = 0xF731,
176   NSBreakFunctionKey = 0xF732,
177   NSResetFunctionKey = 0xF733,
178   NSStopFunctionKey = 0xF734,
179   NSMenuFunctionKey = 0xF735,
180   NSUserFunctionKey = 0xF736,
181   NSSystemFunctionKey = 0xF737,
182   NSPrintFunctionKey = 0xF738,
183   NSClearLineFunctionKey = 0xF739,
184   NSClearDisplayFunctionKey = 0xF73A,
185   NSInsertLineFunctionKey = 0xF73B,
186   NSDeleteLineFunctionKey = 0xF73C,
187   NSInsertCharFunctionKey = 0xF73D,
188   NSDeleteCharFunctionKey = 0xF73E,
189   NSPrevFunctionKey = 0xF73F,
190   NSNextFunctionKey = 0xF740,
191   NSSelectFunctionKey = 0xF741,
192   NSExecuteFunctionKey = 0xF742,
193   NSUndoFunctionKey = 0xF743,
194   NSRedoFunctionKey = 0xF744,
195   NSFindFunctionKey = 0xF745,
196   NSHelpFunctionKey = 0xF746,
197   NSModeSwitchFunctionKey = 0xF747
198 };
199 
200 #endif
201 
202 typedef struct { int fd; } Display;
203 
204 typedef int XIC;
205 typedef int XID;
206 typedef void *Window; /* NSView */
207 typedef int Drawable;
208 typedef struct CGImage *Pixmap;
209 typedef struct CGImage *PixmapMask;
210 typedef int GC;
211 typedef int Font;
212 #ifndef __QUICKDRAWTYPES__
213 typedef int Cursor;
214 #endif
215 typedef int KeyCode;
216 typedef int KeySym;
217 
218 typedef struct /* Same as definition in X11/X.h */ {
219   int max_keypermod;
220   KeyCode *modifiermap;
221 
222 } XModifierKeymap;
223 
224 typedef struct /* Same as definition in X11/X.h */ {
225   unsigned char byte1;
226   unsigned char byte2;
227 
228 } XChar2b;
229 
230 #define UI_FOCUS_IN 1
231 #define UI_FOCUS_OUT 2
232 #define UI_BUTTON_PRESS 3
233 #define UI_BUTTON_RELEASE 4
234 #define UI_BUTTON_MOTION 5
235 #define UI_KEY_PRESS 6
236 #define UI_EXPOSE 7
237 #define UI_SELECTION_REQUESTED 8
238 #define UI_CLOSE_WINDOW 9
239 #define UI_KEY_FOCUS_IN 10
240 #define UI_SELECTION_NOTIFIED 11
241 #define UI_POINTER_MOTION 12
242 
243 typedef struct { int type; } XEvent;
244 
245 typedef struct {
246   int type;
247   unsigned int state;
248   KeySym keysym;
249   const char *utf8;
250 
251 } XKeyEvent;
252 
253 typedef unsigned long Time; /* Same as definition in X11/X.h */
254 typedef unsigned long Atom; /* Same as definition in X11/X.h */
255 
256 typedef struct {
257   int type;
258   int time;
259   int x;
260   int y;
261   unsigned int state;
262   unsigned int button;
263   int click_count;
264 
265 } XButtonEvent;
266 
267 typedef struct {
268   int type;
269   int time;
270   int x;
271   int y;
272   unsigned int state;
273 
274 } XMotionEvent;
275 
276 typedef struct {
277   int type;
278   int x;
279   int y;
280   unsigned int width;
281   unsigned int height;
282   int force_expose;
283 
284 } XExposeEvent;
285 
286 typedef struct {
287   int type;
288   void *sender;
289 
290 } XSelectionRequestEvent;
291 
292 typedef struct {
293   int type;
294   char *data;
295   unsigned int len;
296 
297 } XSelectionNotifyEvent;
298 
299 typedef struct {
300   void *cg_font;
301   unsigned int size;
302   int is_italic;
303 
304 } XFontStruct;
305 
306 typedef int XFontSet; /* dummy */
307 
308 #define None 0L     /* Same as definition in X11/X.h */
309 #define NoSymbol 0L /* Same as definition in X11/X.h */
310 
311 #define CurrentTime 0L /* Same as definition in X11/X.h */
312 
313 /* Same as definition in X11/X.h */
314 #define NoEventMask 0L
315 #define KeyPressMask (1L << 0)
316 #define KeyReleaseMask (1L << 1)
317 #define ButtonPressMask (1L << 2)
318 #define ButtonReleaseMask (1L << 3)
319 #define EnterWindowMask (1L << 4)
320 #define LeaveWindowMask (1L << 5)
321 #define PointerMotionMask (1L << 6)
322 #define PointerMotionHintMask (1L << 7)
323 #define Button1MotionMask (1L << 8)
324 #define Button2MotionMask (1L << 9)
325 #define Button3MotionMask (1L << 10)
326 #define Button4MotionMask (1L << 11)
327 #define Button5MotionMask (1L << 12)
328 #define ButtonMotionMask (1L << 13)
329 #define KeymapStateMask (1L << 14)
330 #define ExposureMask (1L << 15)
331 #define VisibilityChangeMask (1L << 16)
332 #define StructureNotifyMask (1L << 17)
333 #define ResizeRedirectMask (1L << 18)
334 #define SubstructureNotifyMask (1L << 19)
335 #define SubstructureRedirectMask (1L << 20)
336 #define FocusChangeMask (1L << 21)
337 #define PropertyChangeMask (1L << 22)
338 #define ColormapChangeMask (1L << 23)
339 #define OwnerGrabButtonMask (1L << 24)
340 #define ShiftMask NSShiftKeyMask
341 #define LockMask 0
342 #define ControlMask NSControlKeyMask
343 #define Mod1Mask NSAlternateKeyMask
344 #define Mod2Mask NSCommandKeyMask
345 #define Mod3Mask 0
346 #define Mod4Mask 0
347 #define Mod5Mask 0
348 #define CommandMask NSCommandKeyMask
349 #define Button1Mask NSLeftMouseDownMask
350 #define Button2Mask 0
351 #define Button3Mask NSRightMouseDownMask
352 #define Button4Mask 0
353 #define Button5Mask 0
354 #define Button1 1
355 #define Button2 2
356 #define Button3 3
357 #define Button4 4
358 #define Button5 5
359 
360 #define XK_Super_L 0xfffe /* dummy */
361 #define XK_Super_R 0xfffd /* dummy */
362 #define XK_Hyper_L 0xfffc /* dummy */
363 #define XK_Hyper_R 0xfffb /* dummy */
364 #define XK_BackSpace NSDeleteCharacter
365 #define XK_Tab NSTabCharacter
366 #define XK_Clear NSClearDisplayFunctionKey
367 #define XK_Linefeed 0xfffa /* dummy */
368 #define XK_Return NSCarriageReturnCharacter
369 
370 #define XK_Shift_L 0xfff9   /* dummy */
371 #define XK_Control_L 0xfff8 /* dummy */
372 #define XK_Alt_L 0xfff7     /* dummy */
373 #define XK_Shift_R 0xfff6   /* dummy */
374 #define XK_Control_R 0xfff5 /* dummy */
375 #define XK_Alt_R 0xfff4     /* dummy */
376 
377 #define XK_Meta_L 0xfff3 /* dummy */
378 #define XK_Meta_R 0xfff2 /* dummy */
379 
380 #define XK_Pause NSPauseFunctionKey
381 #define XK_Shift_Lock 0xfff1 /* dummy */
382 #define XK_Caps_Lock 0xfff0  /* dummy */
383 #define XK_Escape 0x1b
384 #define XK_Prior NSPageUpFunctionKey
385 #define XK_Next NSPageDownFunctionKey
386 #define XK_End NSEndFunctionKey
387 #define XK_Home NSHomeFunctionKey
388 #define XK_Left NSLeftArrowFunctionKey
389 #define XK_Up NSUpArrowFunctionKey
390 #define XK_Right NSRightArrowFunctionKey
391 #define XK_Down NSDownArrowFunctionKey
392 #define XK_Select NSSelectFunctionKey
393 #define XK_Print NSPrintFunctionKey
394 #define XK_Execute NSExecuteFunctionKey
395 #define XK_Insert NSHelpFunctionKey
396 #define XK_Delete NSDeleteFunctionKey
397 #define XK_Help NSHelpFunctionKey
398 #define XK_F1 NSF1FunctionKey
399 #define XK_F2 NSF2FunctionKey
400 #define XK_F3 NSF3FunctionKey
401 #define XK_F4 NSF4FunctionKey
402 #define XK_F5 NSF5FunctionKey
403 #define XK_F6 NSF6FunctionKey
404 #define XK_F7 NSF7FunctionKey
405 #define XK_F8 NSF8FunctionKey
406 #define XK_F9 NSF9FunctionKey
407 #define XK_F10 NSF10FunctionKey
408 #define XK_F11 NSF11FunctionKey
409 #define XK_F12 NSF12FunctionKey
410 #define XK_F13 NSF13FunctionKey
411 #define XK_F14 NSF14FunctionKey
412 #define XK_F15 NSF15FunctionKey
413 #define XK_F16 NSF16FunctionKey
414 #define XK_F17 NSF17FunctionKey
415 #define XK_F18 NSF18FunctionKey
416 #define XK_F19 NSF19FunctionKey
417 #define XK_F20 NSF20FunctionKey
418 #define XK_F21 NSF21FunctionKey
419 #define XK_F22 NSF22FunctionKey
420 #define XK_F23 NSF23FunctionKey
421 #define XK_F24 NSF24FunctionKey
422 #define XK_FMAX XK_F24
423 #define XK_Num_Lock 0xffef /* dummy */
424 #define XK_Scroll_Lock NSScrollLockFunctionKey
425 #define XK_Find NSFindFunctionKey
426 #define XK_Menu NSMenuFunctionKey
427 #define XK_Begin NSBeginFunctionKey
428 #define XK_Muhenkan 0xffee        /* dummy */
429 #define XK_Henkan_Mode 0xffed     /* dummy */
430 #define XK_Zenkaku_Hankaku 0xffec /* dummy */
431 
432 #define XK_KP_Prior 0xffe8     /* dummy */
433 #define XK_KP_Next 0xffe7      /* dummy */
434 #define XK_KP_End 0xffe6       /* dummy */
435 #define XK_KP_Home 0xffe5      /* dummy */
436 #define XK_KP_Left 0xffe4      /* dummy */
437 #define XK_KP_Up 0xffe3        /* dummy */
438 #define XK_KP_Right 0xffe2     /* dummy */
439 #define XK_KP_Down 0xffe1      /* dummy */
440 #define XK_KP_Insert 0xffe0    /* dummy */
441 #define XK_KP_Delete 0xffdf    /* dummy */
442 #define XK_KP_F1 0xffde        /* dummy */
443 #define XK_KP_F2 0xffdd        /* dummy */
444 #define XK_KP_F3 0xffdc        /* dummy */
445 #define XK_KP_F4 0xffdb        /* dummy */
446 #define XK_KP_Begin 0xffda     /* dummy */
447 #define XK_KP_Multiply 0xffd9  /* dummy */
448 #define XK_KP_Add 0xffd8       /* dummy */
449 #define XK_KP_Separator 0xffd7 /* dummy */
450 #define XK_KP_Subtract 0xffd6  /* dummy */
451 #define XK_KP_Decimal 0xffd5   /* dummy */
452 #define XK_KP_Divide 0xffd4    /* dummy */
453 #define XK_KP_0 0xffd3         /* dummy */
454 #define XK_KP_1 0xffd2         /* dummy */
455 #define XK_KP_2 0xffd1         /* dummy */
456 #define XK_KP_3 0xffd0         /* dummy */
457 #define XK_KP_4 0xffcf         /* dummy */
458 #define XK_KP_5 0xffce         /* dummy */
459 #define XK_KP_6 0xffcd         /* dummy */
460 #define XK_KP_7 0xffcc         /* dummy */
461 #define XK_KP_8 0xffcb         /* dummy */
462 #define XK_KP_9 0xffca         /* dummy */
463 
464 #define IsKeypadKey(ksym) (0)
465 #define IsModifierKey(ksym) (0)
466 
467 #define XK_ISO_Left_Tab NSBackTabCharacter
468 
469 /* XPoint(short x, short y) in Xlib. POINT(float x, float y) in win32. */
470 #define XPoint NSPoint
471 
472 /* XXX dummy */
473 #define XKeysymToKeycode(disp, ks) (ks)
474 #define XKeycodeToKeysym(disp, kc, i) (kc)
475 #define XKeysymToString(ks) ""
476 #define DefaultScreen(disp) (0)
477 
478 #define BlackPixel(disp, screen) (0xff000000)
479 #define WhitePixel(disp, screen) (0xffffffff)
480 
481 /* Same as definition in X11/cursorfont.h */
482 #define XC_xterm 152
483 #define XC_left_ptr 68
484 
485 /* Same as definition in X11/Xutil.h */
486 #define NoValue 0x0000
487 #define XValue 0x0001
488 #define YValue 0x0002
489 #define WidthValue 0x0004
490 #define HeightValue 0x0008
491 #define AllValues 0x000F
492 #define XNegative 0x0010
493 #define YNegative 0x0020
494 
495 int XParseGeometry(char *str, int *x, int *y, unsigned int *width, unsigned int *height);
496 
497 KeySym XStringToKeysym(char *str);
498 
499 /* === Platform dependent options === */
500 
501 #undef UI_COLOR_HAS_RGB
502 #define SUPPORT_TRUE_TRANSPARENT_BG
503 #define TYPE_XCORE_SCALABLE
504 #undef MANAGE_ROOT_WINDOWS_BY_MYSELF
505 #undef MANAGE_SUB_WINDOWS_BY_MYSELF
506 #undef INLINE_PICTURE_MOVABLE_BETWEEN_DISPLAYS
507 #define SUPPORT_POINT_SIZE_FONT
508 #undef XIM_SPOT_IS_LINE_TOP
509 #undef USE_GC
510 #undef CHANGEABLE_CURSOR
511 #undef PLUGIN_MODULE_SUFFIX
512 #undef KEY_REPEAT_BY_MYSELF
513 #undef ROTATABLE_DISPLAY
514 #undef PSEUDO_COLOR_DISPLAY
515 #undef WALL_PICTURE_SIXEL_REPLACES_SYSTEM_PALETTE
516 #define SUPPORT_URGENT_BELL
517 #define FORCE_UNICODE
518 #undef NEED_DISPLAY_SYNC_EVERY_TIME
519 #undef DRAW_SCREEN_IN_PIXELS
520 #define NO_DRAW_IMAGE_STRING
521 /* libpthread is not linked to mlterm explicitly for now. */
522 #undef HAVE_PTHREAD
523 #undef COMPOSE_DECSP_FONT
524 #undef USE_REAL_VERTICAL_FONT
525 #undef NO_DISPLAY_FD
526 #ifdef COCOA_TOUCH
527 #define FLICK_SCROLL
528 #else
529 #undef FLICK_SCROLL
530 #endif
531 #define UIWINDOW_SUPPORTS_PREEDITING
532 
533 #endif
534