This source file includes following definitions.
- NSColor
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 #include "dispextern.h"
23 #include "frame.h"
24 #include "character.h"
25 #include "font.h"
26 #include "sysselect.h"
27 #include "sysstdio.h"
28
29 #ifdef HAVE_NS
30 #ifdef __OBJC__
31
32
33
34
35 #ifdef NS_IMPL_COCOA
36 typedef CGFloat EmacsCGFloat;
37 #elif GNUSTEP_GUI_MAJOR_VERSION > 0 || GNUSTEP_GUI_MINOR_VERSION >= 22
38 typedef CGFloat EmacsCGFloat;
39 #else
40 typedef float EmacsCGFloat;
41 #endif
42
43
44
45
46 #if defined NS_IMPL_COCOA && MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
47 #define NS_USE_NSPasteboardTypeFileURL 1
48 #else
49 #define NS_USE_NSPasteboardTypeFileURL 0
50 #endif
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 #ifndef NSTRACE_ENABLED
143 #define NSTRACE_ENABLED 0
144 #endif
145
146 #if NSTRACE_ENABLED
147
148 #ifndef NSTRACE_ALL_GROUPS
149 #define NSTRACE_ALL_GROUPS 0
150 #endif
151
152 #ifndef NSTRACE_GROUP_EVENTS
153 #define NSTRACE_GROUP_EVENTS NSTRACE_ALL_GROUPS
154 #endif
155
156 #ifndef NSTRACE_GROUP_UPDATES
157 #define NSTRACE_GROUP_UPDATES NSTRACE_ALL_GROUPS
158 #endif
159
160 #ifndef NSTRACE_GROUP_FRINGE
161 #define NSTRACE_GROUP_FRINGE NSTRACE_ALL_GROUPS
162 #endif
163
164 #ifndef NSTRACE_GROUP_COLOR
165 #define NSTRACE_GROUP_COLOR NSTRACE_ALL_GROUPS
166 #endif
167
168 #ifndef NSTRACE_GROUP_GLYPHS
169 #define NSTRACE_GROUP_GLYPHS NSTRACE_ALL_GROUPS
170 #endif
171
172 #ifndef NSTRACE_GROUP_FOCUS
173 #define NSTRACE_GROUP_FOCUS NSTRACE_ALL_GROUPS
174 #endif
175
176 extern volatile int nstrace_num;
177 extern volatile int nstrace_depth;
178 extern volatile int nstrace_enabled_global;
179
180 void nstrace_leave(int *);
181 void nstrace_restore_global_trace_state(int *);
182 char const * nstrace_fullscreen_type_name (int);
183
184
185 #define NSTRACE_MSG_NO_DASHES(...) \
186 do \
187 { \
188 if (nstrace_enabled) \
189 { \
190 fprintf (stderr, "%-10s:%5d: [%5d]%.*s", \
191 __FILE__, __LINE__, nstrace_num++, \
192 2*nstrace_depth, " | | | | | | | | | | | | | | | .."); \
193 fprintf (stderr, __VA_ARGS__); \
194 putc ('\n', stderr); \
195 } \
196 } \
197 while(0)
198
199 #define NSTRACE_MSG(...) NSTRACE_MSG_NO_DASHES("+--- " __VA_ARGS__)
200
201
202
203
204
205
206
207
208 #define NSTRACE_FMT_SIZE "(W:%.0f H:%.0f)"
209 #define NSTRACE_ARG_SIZE(elt) (elt).width, (elt).height
210
211 #define NSTRACE_FMT_POINT "(X:%.0f Y:%.0f)"
212 #define NSTRACE_ARG_POINT(elt) (elt).x, (elt).y
213
214 #define NSTRACE_FMT_RECT NSTRACE_FMT_POINT "/" NSTRACE_FMT_SIZE
215 #define NSTRACE_ARG_RECT(elt) \
216 NSTRACE_ARG_POINT((elt).origin), NSTRACE_ARG_SIZE((elt).size)
217
218 #define NSTRACE_FMT_FSTYPE "%s"
219 #define NSTRACE_ARG_FSTYPE(elt) nstrace_fullscreen_type_name(elt)
220
221
222
223
224 #define NSTRACE_SIZE(str,size) \
225 NSTRACE_MSG (str ": " NSTRACE_FMT_SIZE, \
226 NSTRACE_ARG_SIZE (size));
227
228 #define NSTRACE_POINT(str,point) \
229 NSTRACE_MSG (str ": " NSTRACE_FMT_POINT, \
230 NSTRACE_ARG_POINT (point));
231
232 #define NSTRACE_RECT(str,rect) \
233 NSTRACE_MSG (str ": " NSTRACE_FMT_RECT, \
234 NSTRACE_ARG_RECT (rect));
235
236 #define NSTRACE_FSTYPE(str,fs_type) \
237 NSTRACE_MSG (str ": " NSTRACE_FMT_FSTYPE, \
238 NSTRACE_ARG_FSTYPE (fs_type));
239
240
241
242
243
244
245
246
247
248
249
250
251
252 #define NSTRACE_FMT_RETURN "->>"
253
254 #define NSTRACE_RETURN(...) \
255 NSTRACE_MSG_NO_DASHES ("+" NSTRACE_FMT_RETURN " " __VA_ARGS__)
256
257 #define NSTRACE_RETURN_SIZE(size) \
258 NSTRACE_RETURN(NSTRACE_FMT_SIZE, NSTRACE_ARG_SIZE(size))
259
260 #define NSTRACE_RETURN_POINT(point) \
261 NSTRACE_RETURN(NSTRACE_FMT_POINT, NSTRACE_ARG_POINT(point))
262
263 #define NSTRACE_RETURN_RECT(rect) \
264 NSTRACE_RETURN(NSTRACE_FMT_RECT, NSTRACE_ARG_RECT(rect))
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280 #define NSTRACE_WHEN(cond, ...) \
281 __attribute__((cleanup(nstrace_restore_global_trace_state))) \
282 int nstrace_saved_enabled_global = nstrace_enabled_global; \
283 __attribute__((cleanup(nstrace_leave))) \
284 int nstrace_enabled = nstrace_enabled_global && (cond); \
285 if (nstrace_enabled) { ++nstrace_depth; } \
286 else { nstrace_enabled_global = 0; } \
287 NSTRACE_MSG_NO_DASHES(__VA_ARGS__);
288
289
290
291
292
293 #define NSTRACE_UNSILENCE() do { nstrace_enabled_global = 1; } while(0)
294
295 #endif
296
297 #define NSTRACE(...) NSTRACE_WHEN(1, __VA_ARGS__)
298 #define NSTRACE_UNLESS(cond, ...) NSTRACE_WHEN(!(cond), __VA_ARGS__)
299
300
301 #ifndef NSTRACE_WHEN
302 #define NSTRACE_WHEN(...)
303 #endif
304
305 #ifndef NSTRACE_MSG
306 #define NSTRACE_MSG(...)
307 #endif
308
309 #ifndef NSTRACE_SIZE
310 #define NSTRACE_SIZE(str,size)
311 #endif
312
313 #ifndef NSTRACE_POINT
314 #define NSTRACE_POINT(str,point)
315 #endif
316
317 #ifndef NSTRACE_RECT
318 #define NSTRACE_RECT(str,rect)
319 #endif
320
321 #ifndef NSTRACE_FSTYPE
322 #define NSTRACE_FSTYPE(str,fs_type)
323 #endif
324
325 #ifndef NSTRACE_RETURN_SIZE
326 #define NSTRACE_RETURN_SIZE(size)
327 #endif
328
329 #ifndef NSTRACE_RETURN_POINT
330 #define NSTRACE_RETURN_POINT(point)
331 #endif
332
333 #ifndef NSTRACE_RETURN_RECT
334 #define NSTRACE_RETURN_RECT(rect)
335 #endif
336
337 #ifndef NSTRACE_RETURN_FSTYPE
338 #define NSTRACE_RETURN_FSTYPE(fs_type)
339 #endif
340
341 #ifndef NSTRACE_UNSILENCE
342 #define NSTRACE_UNSILENCE()
343 #endif
344
345
346
347 #ifndef NATIVE_OBJC_INSTANCETYPE
348 typedef id instancetype;
349 #endif
350
351
352
353
354
355
356
357 @interface NSColor (EmacsColor)
358 + (NSColor *)colorForEmacsRed:(CGFloat)red green:(CGFloat)green
359 blue:(CGFloat)blue alpha:(CGFloat)alpha;
360 + (NSColor *)colorWithUnsignedLong:(unsigned long)c;
361 - (NSColor *)colorUsingDefaultColorSpace;
362 - (unsigned long)unsignedLong;
363 @end
364
365
366 @interface NSString (EmacsString)
367 + (NSString *)stringWithLispString:(Lisp_Object)string;
368 - (Lisp_Object)lispString;
369 @end
370
371
372
373
374
375
376
377
378 @interface EmacsApp : NSApplication
379 {
380 #ifdef NS_IMPL_COCOA
381 BOOL shouldKeepRunning;
382 BOOL isFirst;
383 #endif
384 #ifdef NS_IMPL_GNUSTEP
385 BOOL applicationDidFinishLaunchingCalled;
386 #endif
387 @public
388 int nextappdefined;
389 }
390 - (void)logNotification: (NSNotification *)notification;
391 - (void)antialiasThresholdDidChange:(NSNotification *)notification;
392 - (void)sendEvent: (NSEvent *)theEvent;
393 - (void)showPreferencesWindow: (id)sender;
394 - (BOOL) openFile: (NSString *)fileName;
395 - (void)fd_handler: (id)unused;
396 - (void)timeout_handler: (NSTimer *)timedEntry;
397 - (BOOL)fulfillService: (NSString *)name withArg: (NSString *)arg;
398 #ifdef NS_IMPL_GNUSTEP
399 - (void)sendFromMainThread:(id)unused;
400 #endif
401 @end
402
403 #ifdef NS_IMPL_GNUSTEP
404
405 @interface EmacsDocument : NSDocument
406 {
407 }
408 @end
409 #endif
410
411 enum ns_return_frame_mode
412 {
413 RETURN_FRAME_NEVER,
414 RETURN_FRAME_EVENTUALLY,
415 RETURN_FRAME_NOW,
416 };
417
418
419 @interface EmacsWindow : NSWindow
420 {
421 NSPoint grabOffset;
422 NSEvent *last_drag_event;
423 NSDragOperation drag_op;
424 NSDragOperation selected_op;
425
426 struct frame *dnd_return_frame;
427 enum ns_return_frame_mode dnd_mode;
428 BOOL dnd_allow_same_frame;
429 BOOL dnd_move_tooltip_with_frame;
430 }
431
432 #ifdef NS_IMPL_GNUSTEP
433 - (NSInteger) orderedIndex;
434 #endif
435
436 - (instancetype) initWithEmacsFrame: (struct frame *) f;
437 - (instancetype) initWithEmacsFrame: (struct frame *) f
438 fullscreen: (BOOL) fullscreen
439 screen: (NSScreen *) screen;
440 - (void) createToolbar: (struct frame *) f;
441 - (void) setParentChildRelationships;
442 - (NSInteger) borderWidth;
443 - (BOOL) restackWindow: (NSWindow *) win above: (BOOL) above;
444 - (void) setAppearance;
445 - (void) setLastDragEvent: (NSEvent *) event;
446 - (NSDragOperation) beginDrag: (NSDragOperation) op
447 forPasteboard: (NSPasteboard *) pasteboard
448 withMode: (enum ns_return_frame_mode) mode
449 returnFrameTo: (struct frame **) frame_return
450 prohibitSame: (BOOL) prohibit_same_frame
451 followTooltip: (BOOL) follow_tooltip;
452 - (BOOL) mustNotDropOn: (NSView *) receiver;
453 @end
454
455
456
457
458
459
460
461
462 @class EmacsToolbar;
463 @class EmacsLayer;
464
465 #ifdef NS_IMPL_COCOA
466 @interface EmacsView : NSView <NSTextInput, NSWindowDelegate>
467 #else
468 @interface EmacsView : NSView <NSTextInput>
469 #endif
470 {
471 #ifdef NS_IMPL_COCOA
472 char *old_title;
473 BOOL maximizing_resize;
474 #endif
475 BOOL font_panel_active;
476 NSFont *font_panel_result;
477 BOOL windowClosing;
478 NSString *workingText;
479 BOOL processingCompose;
480 int fs_state, fs_before_fs, next_maximized;
481 int maximized_width, maximized_height;
482 EmacsWindow *nonfs_window;
483 BOOL fs_is_native;
484 @public
485 struct frame *emacsframe;
486 int scrollbarsNeedingUpdate;
487 NSRect ns_userRect;
488 }
489
490
491 - (instancetype)menuDown: (id)sender;
492 - (instancetype)toolbarClicked: (id)item;
493 - (instancetype)toggleToolbar: (id)sender;
494 - (void)keyDown: (NSEvent *)theEvent;
495 - (void)mouseDown: (NSEvent *)theEvent;
496 - (void)mouseUp: (NSEvent *)theEvent;
497 - (instancetype)setMiniwindowImage: (BOOL)setMini;
498
499
500 - (instancetype) initFrameFromEmacs: (struct frame *) f;
501 - (void) setWindowClosing: (BOOL)closing;
502 - (void) deleteWorkingText;
503 - (void) handleFS;
504 - (void) setFSValue: (int)value;
505 - (void) toggleFullScreen: (id) sender;
506 - (BOOL) fsIsNative;
507 - (BOOL) isFullscreen;
508 #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
509 - (void) updateCollectionBehavior;
510 #endif
511
512 #ifdef NS_IMPL_GNUSTEP
513 - (void)windowDidMove: (id)sender;
514 #endif
515 - (Lisp_Object) showFontPanel;
516 - (int)fullscreenState;
517
518 #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
519 - (void)lockFocus;
520 - (void)unlockFocus;
521 #endif
522 - (void)copyRect:(NSRect)srcRect to:(NSPoint)dest;
523
524
525 - (void)windowWillEnterFullScreen;
526 - (void)windowDidEnterFullScreen;
527 - (void)windowWillExitFullScreen;
528 - (void)windowDidExitFullScreen;
529 - (void)windowDidBecomeKey;
530 @end
531
532
533
534
535
536
537
538
539 @interface EmacsMenu : NSMenu <NSMenuDelegate>
540 {
541 BOOL needsUpdate;
542 }
543
544 - (void)menuNeedsUpdate: (NSMenu *)menu;
545 - (NSMenuItem *)addItemWithWidgetValue: (void *)wvptr
546 attributes: (NSDictionary *)attributes;
547 - (void)fillWithWidgetValue: (void *)wvptr;
548 - (EmacsMenu *)addSubmenuWithTitle: (const char *)title;
549 - (void) removeAllItems;
550 - (Lisp_Object)runMenuAt: (NSPoint)p forFrame: (struct frame *)f
551 keymaps: (bool)keymaps;
552 @end
553
554
555
556
557
558
559
560
561 @class EmacsImage;
562
563 #ifdef NS_IMPL_COCOA
564 @interface EmacsToolbar : NSToolbar <NSToolbarDelegate>
565 #else
566 @interface EmacsToolbar : NSToolbar
567 #endif
568 {
569 EmacsView *emacsView;
570 NSMutableDictionary *identifierToItem;
571 NSMutableArray *activeIdentifiers;
572 NSArray *prevIdentifiers;
573 unsigned long enablement, prevEnablement;
574 }
575 - (instancetype) initForView: (EmacsView *)view withIdentifier: (NSString *)identifier;
576 - (void) clearActive;
577 - (void) clearAll;
578 - (BOOL) changed;
579 - (void) addDisplayItemWithImage: (EmacsImage *)img
580 idx: (int)idx
581 tag: (int)tag
582 labelText: (NSString *)label
583 helpText: (NSString *)help
584 enabled: (BOOL)enabled;
585
586
587 - (NSToolbarItem *)toolbar: (NSToolbar *)toolbar
588 itemForItemIdentifier: (NSString *)itemIdentifier
589 willBeInsertedIntoToolbar: (BOOL)flag;
590 - (NSArray *)toolbarDefaultItemIdentifiers: (NSToolbar *)toolbar;
591 - (NSArray *)toolbarAllowedItemIdentifiers: (NSToolbar *)toolbar;
592 @end
593
594
595
596
597
598
599
600
601 @interface EmacsDialogPanel : NSPanel
602 {
603 NSTextField *command;
604 NSTextField *title;
605 NSMatrix *matrix;
606 int rows, cols;
607 BOOL timer_fired, window_closed;
608 Lisp_Object dialog_return;
609 }
610
611 - (instancetype) initWithTitle: (char *) title_str
612 isQuestion: (BOOL) is_question;
613 - (void) processMenuItems: (Lisp_Object) menu_items
614 used: (ptrdiff_t) menu_items_used
615 withErrorOutput: (const char **) error_name;
616
617 - (void) addButton: (char *) str
618 value: (NSInteger) tag
619 row: (int) row
620 enable: (BOOL) enable;
621 - (void) addString: (char *) str
622 row: (int) row;
623 - (void) addSplit;
624 - (void) resizeBoundsPriorToDisplay;
625
626 - (Lisp_Object) runDialogAt: (NSPoint) p;
627 - (void) timeout_handler: (NSTimer *) timedEntry;
628 @end
629
630 #ifdef NS_IMPL_COCOA
631 @interface EmacsTooltip : NSObject <NSWindowDelegate>
632 #else
633 @interface EmacsTooltip : NSObject
634 #endif
635 {
636 NSWindow *win;
637 NSTextField *textField;
638 NSTimer *timer;
639 }
640
641 - (instancetype) init;
642 - (void) setText: (char *) text;
643 - (void) setBackgroundColor: (NSColor *) col;
644 - (void) setForegroundColor: (NSColor *) col;
645 - (void) showAtX: (int) x Y: (int) y for: (int) seconds;
646 - (void) hide;
647 - (BOOL) isActive;
648 - (NSRect) frame;
649 - (void) moveTo: (NSPoint) screen_point;
650 @end
651
652
653 @interface EmacsFileDelegate : NSObject
654 {
655 }
656 - (BOOL)panel: (id)sender isValidFilename: (NSString *)filename;
657 - (BOOL)panel: (id)sender shouldShowFilename: (NSString *)filename;
658 - (NSString *)panel: (id)sender userEnteredFilename: (NSString *)filename
659 confirmed: (BOOL)okFlag;
660 @end
661
662
663
664
665
666
667
668
669 @interface EmacsImage : NSImage
670 {
671 NSBitmapImageRep *bmRep;
672 unsigned char *pixmapData[5];
673 NSColor *stippleMask;
674 @public
675 NSAffineTransform *transform;
676 BOOL smoothing;
677 }
678 + (instancetype)allocInitFromFile: (Lisp_Object)file;
679 - (void)dealloc;
680 - (instancetype)initFromXBM: (unsigned char *)bits width: (int)w height: (int)h
681 fg: (unsigned long)fg bg: (unsigned long)bg
682 reverseBytes: (BOOL)reverse;
683 - (instancetype)initForXPMWithDepth: (int)depth width: (int)width height: (int)height;
684 - (void)setPixmapData;
685 - (unsigned long)getPixelAtX: (int)x Y: (int)y;
686 - (void)setPixelAtX: (int)x Y: (int)y toRed: (unsigned char)r
687 green: (unsigned char)g blue: (unsigned char)b
688 alpha:(unsigned char)a;
689 - (void)setAlphaAtX: (int)x Y: (int)y to: (unsigned char)a;
690 - (NSColor *)stippleMask;
691 - (Lisp_Object)getMetadata;
692 - (BOOL)setFrame: (unsigned int) index;
693 - (void)setTransform: (double[3][3]) m;
694 - (void)setSmoothing: (BOOL)s;
695 - (size_t)sizeInBytes;
696 @end
697
698
699
700
701
702
703
704
705 @interface EmacsScroller : NSScroller
706 {
707 struct window *window;
708 struct frame *frame;
709 NSResponder *prevResponder;
710
711
712 CGFloat last_mouse_offset;
713 float min_portion;
714 int pixel_length;
715 enum scroll_bar_part last_hit_part;
716
717 BOOL condemned;
718
719 BOOL horizontal;
720
721
722 int em_position;
723 int em_portion;
724 int em_whole;
725 }
726
727 - (void) mark;
728 - (instancetype) initFrame: (NSRect )r window: (Lisp_Object)win;
729 - (void)setFrame: (NSRect)r;
730
731 - (instancetype) setPosition: (int) position portion: (int) portion whole: (int) whole;
732 - (int) checkSamePosition: (int)position portion: (int)portion
733 whole: (int)whole;
734 - (void) sendScrollEventAtLoc: (float)loc fromEvent: (NSEvent *)e;
735 - (instancetype)repeatScroll: (NSTimer *)sender;
736 - (instancetype)condemn;
737 - (instancetype)reprieve;
738 - (bool)judge;
739 + (CGFloat)scrollerWidth;
740 @end
741
742 #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
743 @interface EmacsLayer : CALayer
744 {
745 NSMutableArray *cache;
746 CGColorSpaceRef colorSpace;
747 IOSurfaceRef currentSurface;
748 CGContextRef context;
749 }
750 - (id) initWithColorSpace: (CGColorSpaceRef)cs;
751 - (void) setColorSpace: (CGColorSpaceRef)cs;
752 - (CGContextRef) getContext;
753 @end
754 #endif
755
756
757
758
759
760
761
762
763 extern NSArray *ns_send_types, *ns_return_types;
764 extern NSString *ns_app_name;
765 extern EmacsMenu *svcsMenu;
766
767
768 #if defined (NS_IMPL_COCOA)
769 @interface NSApplication (EmacsApp)
770 - (void)setAppleMenu: (NSMenu *)menu;
771 @end
772 #endif
773
774 #endif
775
776
777
778
779
780
781
782
783
784
785 #define KEY_NS_POWER_OFF ((1<<28)|(0<<16)|1)
786 #define KEY_NS_OPEN_FILE ((1<<28)|(0<<16)|2)
787 #define KEY_NS_OPEN_TEMP_FILE ((1<<28)|(0<<16)|3)
788 #define KEY_NS_CHANGE_FONT ((1<<28)|(0<<16)|7)
789 #define KEY_NS_OPEN_FILE_LINE ((1<<28)|(0<<16)|8)
790 #define KEY_NS_PUT_WORKING_TEXT ((1<<28)|(0<<16)|9)
791 #define KEY_NS_UNPUT_WORKING_TEXT ((1<<28)|(0<<16)|10)
792 #define KEY_NS_SPI_SERVICE_CALL ((1<<28)|(0<<16)|11)
793 #define KEY_NS_NEW_FRAME ((1<<28)|(0<<16)|12)
794 #define KEY_NS_TOGGLE_TOOLBAR ((1<<28)|(0<<16)|13)
795 #define KEY_NS_SHOW_PREFS ((1<<28)|(0<<16)|14)
796
797
798
799 struct ns_bitmap_record
800 {
801 #ifdef __OBJC__
802 EmacsImage *img;
803 #else
804 void *img;
805 #endif
806 char *file;
807 int refcount;
808 int height, width, depth;
809 };
810
811 #ifdef NS_IMPL_GNUSTEP
812
813 struct nsfont_info
814 {
815 struct font font;
816
817 char *name;
818
819
820
821 float width;
822 float height;
823 float underpos;
824 float underwidth;
825 float size;
826 #ifdef __OBJC__
827 NSFont *nsfont;
828 #else
829 void *nsfont;
830 #endif
831 char bold, ital;
832 char synthItal;
833 XCharStruct max_bounds;
834
835
836 unsigned int **glyphs;
837 struct font_metrics **metrics;
838 };
839 #endif
840
841
842 struct ns_display_info
843 {
844
845 struct ns_display_info *next;
846
847
848 struct terminal *terminal;
849
850
851 Lisp_Object name_list_element;
852
853
854 int n_fonts;
855
856
857 int smallest_char_width;
858
859
860 int smallest_font_height;
861
862 struct ns_bitmap_record *bitmaps;
863 ptrdiff_t bitmaps_size;
864 ptrdiff_t bitmaps_last;
865
866
867 double resx, resy;
868
869
870 int grabbed;
871
872 int n_planes;
873
874 int color_p;
875
876 Window root_window;
877
878
879 Lisp_Object rdb;
880
881
882 Emacs_Cursor vertical_scroll_bar_cursor;
883
884
885 Emacs_Cursor horizontal_scroll_bar_cursor;
886
887
888
889 Mouse_HLInfo mouse_highlight;
890
891 struct frame *highlight_frame;
892 struct frame *ns_focus_frame;
893
894
895 struct frame *last_mouse_frame;
896
897
898 struct frame *last_mouse_motion_frame;
899
900
901
902 int last_mouse_motion_x;
903 int last_mouse_motion_y;
904
905
906 NSRect last_mouse_glyph;
907
908
909 Time last_mouse_movement_time;
910
911
912 #ifdef __OBJC__
913 EmacsScroller *last_mouse_scroll_bar;
914 #else
915 void *last_mouse_scroll_bar;
916 #endif
917 };
918
919
920 extern struct ns_display_info *x_display_list;
921
922 struct ns_output
923 {
924 #ifdef __OBJC__
925 EmacsView *view;
926 id miniimage;
927 NSColor *cursor_color;
928 NSColor *foreground_color;
929 NSColor *background_color;
930 NSColor *relief_background_color;
931 NSColor *light_relief_color;
932 NSColor *dark_relief_color;
933 EmacsToolbar *toolbar;
934 #else
935 void *view;
936 void *miniimage;
937 void *cursor_color;
938 void *foreground_color;
939 void *background_color;
940 void *relief_background_color;
941 void *light_relief_color;
942 void *dark_relief_color;
943 void *toolbar;
944 #endif
945
946
947 Emacs_Cursor text_cursor;
948 Emacs_Cursor nontext_cursor;
949 Emacs_Cursor modeline_cursor;
950 Emacs_Cursor hand_cursor;
951 Emacs_Cursor hourglass_cursor;
952 Emacs_Cursor horizontal_drag_cursor;
953 Emacs_Cursor vertical_drag_cursor;
954 Emacs_Cursor left_edge_cursor;
955 Emacs_Cursor top_left_corner_cursor;
956 Emacs_Cursor top_edge_cursor;
957 Emacs_Cursor top_right_corner_cursor;
958 Emacs_Cursor right_edge_cursor;
959 Emacs_Cursor bottom_right_corner_cursor;
960 Emacs_Cursor bottom_edge_cursor;
961 Emacs_Cursor bottom_left_corner_cursor;
962
963
964 Emacs_Cursor current_pointer;
965
966
967 Window window_desc, parent_desc;
968 char explicit_parent;
969
970 struct font *font;
971 int baseline_offset;
972
973
974
975 int fontset;
976
977 int icon_top;
978 int icon_left;
979
980
981
982 int vertical_scroll_bar_extra;
983
984
985 int titlebar_height;
986
987
988 int toolbar_height;
989
990
991 struct ns_display_info *display_info;
992
993
994 int zooming;
995
996
997 int in_animation;
998
999 #ifdef NS_IMPL_GNUSTEP
1000
1001
1002 int tool_bar_adjusted;
1003 #endif
1004 };
1005
1006
1007 struct x_output
1008 {
1009 int unused;
1010 };
1011
1012
1013
1014 #define FRAME_DISPLAY_INFO(f) ((f)->output_data.ns->display_info)
1015 #define FRAME_OUTPUT_DATA(f) ((f)->output_data.ns)
1016 #define FRAME_NS_WINDOW(f) ((f)->output_data.ns->window_desc)
1017 #define FRAME_NATIVE_WINDOW(f) FRAME_NS_WINDOW (f)
1018
1019 #define FRAME_FOREGROUND_COLOR(f) ((f)->output_data.ns->foreground_color)
1020 #define FRAME_BACKGROUND_COLOR(f) ((f)->output_data.ns->background_color)
1021
1022 #define NS_FACE_FOREGROUND(f) ((f)->foreground)
1023 #define NS_FACE_BACKGROUND(f) ((f)->background)
1024
1025 #define FRAME_DEFAULT_FACE(f) FACE_FROM_ID_OR_NULL (f, DEFAULT_FACE_ID)
1026
1027 #define FRAME_NS_VIEW(f) ((f)->output_data.ns->view)
1028 #define FRAME_CURSOR_COLOR(f) ((f)->output_data.ns->cursor_color)
1029 #define FRAME_POINTER_TYPE(f) ((f)->output_data.ns->current_pointer)
1030
1031 #define FRAME_FONT(f) ((f)->output_data.ns->font)
1032
1033 #ifdef __OBJC__
1034 #define XNS_SCROLL_BAR(vec) ((id) xmint_pointer (vec))
1035 #else
1036 #define XNS_SCROLL_BAR(vec) xmint_pointer (vec)
1037 #endif
1038
1039
1040 #define FRAME_NS_TITLEBAR_HEIGHT(f) \
1041 (NSHeight([FRAME_NS_VIEW (f) frame]) == 0 ? \
1042 0 \
1043 : (int)(NSHeight([FRAME_NS_VIEW (f) window].frame) \
1044 - NSHeight([NSWindow contentRectForFrameRect: \
1045 [[FRAME_NS_VIEW (f) window] frame] \
1046 styleMask:[[FRAME_NS_VIEW (f) window] styleMask]])))
1047
1048
1049 #define FRAME_TOOLBAR_HEIGHT(f) \
1050 (([[FRAME_NS_VIEW (f) window] toolbar] == nil \
1051 || ! [[FRAME_NS_VIEW (f) window] toolbar].isVisible) ? \
1052 0 \
1053 : (int)(NSHeight([NSWindow contentRectForFrameRect: \
1054 [[FRAME_NS_VIEW (f) window] frame] \
1055 styleMask:[[FRAME_NS_VIEW (f) window] styleMask]]) \
1056 - NSHeight([[[FRAME_NS_VIEW (f) window] contentView] frame])))
1057
1058
1059 #define NS_SCROLL_BAR_WIDTH(f) \
1060 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
1061 ? rint (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) > 0 \
1062 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
1063 : (FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f))) \
1064 : 0)
1065
1066
1067 #define NS_SCROLL_BAR_HEIGHT(f) \
1068 (FRAME_HAS_HORIZONTAL_SCROLL_BARS (f) \
1069 ? rint (FRAME_CONFIG_SCROLL_BAR_HEIGHT (f) > 0 \
1070 ? FRAME_CONFIG_SCROLL_BAR_HEIGHT (f) \
1071 : (FRAME_SCROLL_BAR_LINES (f) * FRAME_LINE_HEIGHT (f))) \
1072 : 0)
1073
1074
1075
1076 #define NS_SCROLL_BAR_ADJUST(w, f) \
1077 (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w) ? \
1078 (FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f) \
1079 - NS_SCROLL_BAR_WIDTH (f)) : 0)
1080
1081
1082
1083 #define NS_SCROLL_BAR_ADJUST_HORIZONTALLY(w, f) \
1084 (WINDOW_HAS_HORIZONTAL_SCROLL_BARS (w) ? \
1085 (FRAME_SCROLL_BAR_LINES (f) * FRAME_LINE_HEIGHT (f) \
1086 - NS_SCROLL_BAR_HEIGHT (f)) : 0)
1087
1088 #define FRAME_NS_FONT_TABLE(f) (FRAME_DISPLAY_INFO (f)->font_table)
1089
1090 #define FRAME_FONTSET(f) ((f)->output_data.ns->fontset)
1091
1092 #define FRAME_BASELINE_OFFSET(f) ((f)->output_data.ns->baseline_offset)
1093 #define BLACK_PIX_DEFAULT(f) 0x000000
1094 #define WHITE_PIX_DEFAULT(f) 0xFFFFFF
1095
1096
1097
1098 #define FIRST_CHAR_POSITION(f) \
1099 (! (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f)) ? 0 \
1100 : FRAME_SCROLL_BAR_COLS (f))
1101
1102 extern struct ns_display_info *ns_term_init (Lisp_Object display_name);
1103 extern void ns_term_shutdown (int sig);
1104
1105
1106 #define NS_DUMPGLYPH_NORMAL 0
1107 #define NS_DUMPGLYPH_CURSOR 1
1108 #define NS_DUMPGLYPH_FOREGROUND 2
1109 #define NS_DUMPGLYPH_MOUSEFACE 3
1110
1111
1112 #ifdef NS_IMPL_GNUSTEP
1113
1114 extern void nsfont_make_fontset_for_font (Lisp_Object name,
1115 Lisp_Object font_object);
1116
1117
1118 struct glyph_string;
1119 void ns_dump_glyphstring (struct glyph_string *s) EXTERNALLY_VISIBLE;
1120 #endif
1121
1122
1123 extern Lisp_Object ns_list_fonts (struct frame *f, Lisp_Object pattern,
1124 int size, int maxnames);
1125 extern void ns_clear_frame (struct frame *f);
1126
1127 extern void ns_set_offset (struct frame *f, int xoff, int yoff,
1128 int change_grav);
1129
1130 extern const char *ns_xlfd_to_fontname (const char *xlfd);
1131
1132 extern Lisp_Object ns_map_event_to_object (void);
1133 #ifdef __OBJC__
1134 extern Lisp_Object ns_string_from_pasteboard (id pb);
1135 extern void ns_string_to_pasteboard (id pb, Lisp_Object str);
1136 #endif
1137 extern Lisp_Object ns_get_local_selection (Lisp_Object selection_name,
1138 Lisp_Object target_type);
1139 extern void nxatoms_of_nsselect (void);
1140 extern void ns_set_doc_edited (void);
1141
1142 extern bool
1143 ns_defined_color (struct frame *f,
1144 const char *name,
1145 Emacs_Color *color_def, bool alloc,
1146 bool makeIndex);
1147
1148 #ifdef __OBJC__
1149 extern int ns_lisp_to_color (Lisp_Object color, NSColor **col);
1150 extern const char *ns_get_pending_menu_title (void);
1151 #endif
1152
1153
1154 #ifdef __OBJC__
1155 extern void ns_move_tooltip_to_mouse_location (NSPoint);
1156 #endif
1157 extern void ns_implicitly_set_name (struct frame *f, Lisp_Object arg,
1158 Lisp_Object oldval);
1159 extern void ns_set_scroll_bar_default_width (struct frame *f);
1160 extern void ns_set_scroll_bar_default_height (struct frame *f);
1161 extern void ns_change_tab_bar_height (struct frame *f, int height);
1162 extern const char *ns_get_string_resource (void *_rdb,
1163 const char *name,
1164 const char *class);
1165
1166
1167 extern void ns_release_object (void *obj);
1168 extern void ns_retain_object (void *obj);
1169 extern void *ns_alloc_autorelease_pool (void);
1170 extern void ns_release_autorelease_pool (void *);
1171 extern const char *ns_get_defaults_value (const char *key);
1172 extern void ns_init_locale (void);
1173
1174
1175 extern void update_frame_tool_bar (struct frame *f);
1176 #ifdef __OBJC__
1177 extern void update_frame_tool_bar_1 (struct frame *f, EmacsToolbar *toolbar);
1178 #endif
1179
1180 extern void free_frame_tool_bar (struct frame *f);
1181 extern Lisp_Object find_and_return_menu_selection (struct frame *f,
1182 bool keymaps,
1183 void *client_data);
1184 extern Lisp_Object ns_popup_dialog (struct frame *, Lisp_Object header,
1185 Lisp_Object contents);
1186
1187 extern void ns_free_frame_resources (struct frame *);
1188
1189 #define NSAPP_DATA2_RUNASSCRIPT 10
1190 extern void ns_run_ascript (void);
1191
1192 #define NSAPP_DATA2_RUNFILEDIALOG 11
1193 extern void ns_run_file_dialog (void);
1194
1195 extern const char *ns_relocate (const char *epath);
1196 extern void syms_of_nsterm (void);
1197 extern void syms_of_nsfns (void);
1198 extern void syms_of_nsmenu (void);
1199 extern void syms_of_nsselect (void);
1200
1201
1202 struct image;
1203 extern bool ns_can_use_native_image_api (Lisp_Object type);
1204 extern void *ns_image_from_XBM (char *bits, int width, int height,
1205 unsigned long fg, unsigned long bg);
1206 extern void *ns_image_for_XPM (int width, int height, int depth);
1207 extern void *ns_image_from_file (Lisp_Object file);
1208 extern bool ns_load_image (struct frame *f, struct image *img,
1209 Lisp_Object spec_file, Lisp_Object spec_data);
1210 extern int ns_image_width (void *img);
1211 extern int ns_image_height (void *img);
1212 extern void ns_image_set_size (void *img, int width, int height);
1213 extern void ns_image_set_transform (void *img, double m[3][3]);
1214 extern void ns_image_set_smoothing (void *img, bool smooth);
1215 extern unsigned long ns_get_pixel (void *img, int x, int y);
1216 extern void ns_put_pixel (void *img, int x, int y, unsigned long argb);
1217 extern void ns_set_alpha (void *img, int x, int y, unsigned char a);
1218
1219 extern int ns_display_pixel_height (struct ns_display_info *);
1220 extern int ns_display_pixel_width (struct ns_display_info *);
1221 extern size_t ns_image_size_in_bytes (void *img);
1222
1223
1224 extern float ns_antialias_threshold;
1225 extern void ns_make_frame_visible (struct frame *f);
1226 extern void ns_make_frame_invisible (struct frame *f);
1227 extern void ns_iconify_frame (struct frame *f);
1228 extern void ns_set_undecorated (struct frame *f, Lisp_Object new_value,
1229 Lisp_Object old_value);
1230 extern void ns_set_parent_frame (struct frame *f, Lisp_Object new_value,
1231 Lisp_Object old_value);
1232 extern void ns_set_no_focus_on_map (struct frame *f, Lisp_Object new_value,
1233 Lisp_Object old_value);
1234 extern void ns_set_no_accept_focus (struct frame *f, Lisp_Object new_value,
1235 Lisp_Object old_value);
1236 extern void ns_set_z_group (struct frame *f, Lisp_Object new_value,
1237 Lisp_Object old_value);
1238 #ifdef NS_IMPL_COCOA
1239 extern void ns_set_appearance (struct frame *f, Lisp_Object new_value,
1240 Lisp_Object old_value);
1241 extern void ns_set_transparent_titlebar (struct frame *f,
1242 Lisp_Object new_value,
1243 Lisp_Object old_value);
1244 #endif
1245 extern int ns_select (int nfds, fd_set *readfds, fd_set *writefds,
1246 fd_set *exceptfds, struct timespec *timeout,
1247 sigset_t *sigmask);
1248 #ifdef HAVE_PTHREAD
1249 extern void ns_run_loop_break (void);
1250 #endif
1251 extern unsigned long ns_get_rgb_color (struct frame *f,
1252 float r, float g, float b, float a);
1253
1254 struct input_event;
1255 extern void ns_init_events (struct input_event *);
1256 extern void ns_finish_events (void);
1257
1258 extern double ns_frame_scale_factor (struct frame *);
1259
1260 #ifdef NS_IMPL_GNUSTEP
1261 extern char gnustep_base_version[];
1262 #endif
1263
1264 #define MINWIDTH 10
1265 #define MINHEIGHT 10
1266
1267
1268
1269 #define SCREENMAX 16000
1270
1271 #define NS_SCROLL_BAR_WIDTH_DEFAULT [EmacsScroller scrollerWidth]
1272 #define NS_SCROLL_BAR_HEIGHT_DEFAULT [EmacsScroller scrollerHeight]
1273
1274 #define NS_SELECTION_BG_COLOR_DEFAULT @"LightGoldenrod2";
1275 #define NS_SELECTION_FG_COLOR_DEFAULT @"Black";
1276 #define RESIZE_HANDLE_SIZE 12
1277
1278
1279 #define IN_BOUND(min, x, max) (((x) < (min)) \
1280 ? (min) : (((x)>(max)) ? (max) : (x)))
1281 #define SCREENMAXBOUND(x) (IN_BOUND (-SCREENMAX, x, SCREENMAX))
1282
1283
1284 #ifdef NS_IMPL_COCOA
1285
1286 #ifndef NSAppKitVersionNumber10_7
1287 #define NSAppKitVersionNumber10_7 1138
1288 #endif
1289
1290 #ifndef NSAppKitVersionNumber10_10
1291 #define NSAppKitVersionNumber10_10 1343
1292 #endif
1293 #endif
1294
1295
1296
1297 #if !defined (NS_IMPL_COCOA) || !defined (MAC_OS_X_VERSION_10_7)
1298 #define NSFullScreenWindowMask (1 << 14)
1299 #define NSWindowCollectionBehaviorFullScreenPrimary (1 << 7)
1300 #define NSWindowCollectionBehaviorFullScreenAuxiliary (1 << 8)
1301 #define NSApplicationPresentationFullScreen (1 << 10)
1302 #define NSApplicationPresentationAutoHideToolbar (1 << 11)
1303 #define NSAppKitVersionNumber10_7 1138
1304 #endif
1305
1306
1307 #if !defined (NS_IMPL_COCOA) || !defined (MAC_OS_X_VERSION_10_12)
1308 #define NSEventModifierFlagCommand NSCommandKeyMask
1309 #define NSEventModifierFlagControl NSControlKeyMask
1310 #define NSEventModifierFlagHelp NSHelpKeyMask
1311 #define NSEventModifierFlagNumericPad NSNumericPadKeyMask
1312 #define NSEventModifierFlagOption NSAlternateKeyMask
1313 #define NSEventModifierFlagShift NSShiftKeyMask
1314 #define NSCompositingOperationSourceOver NSCompositeSourceOver
1315 #define NSEventMaskApplicationDefined NSApplicationDefinedMask
1316 #define NSEventTypeApplicationDefined NSApplicationDefined
1317 #define NSEventTypeCursorUpdate NSCursorUpdate
1318 #define NSEventTypeMouseMoved NSMouseMoved
1319 #define NSEventTypeLeftMouseDown NSLeftMouseDown
1320 #define NSEventTypeRightMouseDown NSRightMouseDown
1321 #define NSEventTypeOtherMouseDown NSOtherMouseDown
1322 #define NSEventTypeLeftMouseUp NSLeftMouseUp
1323 #define NSEventTypeRightMouseUp NSRightMouseUp
1324 #define NSEventTypeOtherMouseUp NSOtherMouseUp
1325 #define NSEventTypeLeftMouseDragged NSLeftMouseDragged
1326 #define NSEventTypeRightMouseDragged NSRightMouseDragged
1327 #define NSEventTypeOtherMouseDragged NSOtherMouseDragged
1328 #define NSEventTypeScrollWheel NSScrollWheel
1329 #define NSEventTypeKeyDown NSKeyDown
1330 #define NSEventTypeKeyUp NSKeyUp
1331 #define NSEventTypeFlagsChanged NSFlagsChanged
1332 #define NSEventMaskAny NSAnyEventMask
1333 #define NSEventTypeSystemDefined NSSystemDefined
1334 #define NSWindowStyleMaskBorderless NSBorderlessWindowMask
1335 #define NSWindowStyleMaskClosable NSClosableWindowMask
1336 #define NSWindowStyleMaskFullScreen NSFullScreenWindowMask
1337 #define NSWindowStyleMaskMiniaturizable NSMiniaturizableWindowMask
1338 #define NSWindowStyleMaskResizable NSResizableWindowMask
1339 #define NSWindowStyleMaskTitled NSTitledWindowMask
1340 #define NSWindowStyleMaskUtilityWindow NSUtilityWindowMask
1341 #define NSAlertStyleCritical NSCriticalAlertStyle
1342 #define NSControlSizeRegular NSRegularControlSize
1343 #define NSCompositingOperationCopy NSCompositeCopy
1344 #define NSTextAlignmentRight NSRightTextAlignment
1345
1346
1347 #ifdef __OBJC__
1348 typedef NSUInteger NSWindowStyleMask;
1349 #endif
1350
1351
1352 enum NSWindowTabbingMode
1353 {
1354 NSWindowTabbingModeAutomatic,
1355 NSWindowTabbingModePreferred,
1356 NSWindowTabbingModeDisallowed
1357 };
1358 #endif
1359
1360 #if !defined (NS_IMPL_COCOA) || !defined (MAC_OS_X_VERSION_10_13)
1361
1362 #define NSPasteboardNameGeneral NSGeneralPboard
1363 #define NSPasteboardNameDrag NSDragPboard
1364 #endif
1365
1366 #if !defined (NS_IMPL_COCOA) || !defined (MAC_OS_X_VERSION_10_14)
1367
1368
1369
1370 #define NSPasteboardTypeString NSStringPboardType
1371 #define NSPasteboardTypeTabularText NSTabularTextPboardType
1372 #define NSPasteboardTypeURL NSURLPboardType
1373 #define NSPasteboardTypeHTML NSHTMLPboardType
1374 #define NSPasteboardTypePDF NSPDFPboardType
1375 #define NSPasteboardTypeRTF NSRTFPboardType
1376 #define NSPasteboardTypeRTFD NSRTFDPboardType
1377 #define NSPasteboardTypeTIFF NSTIFFPboardType
1378 #define NSControlStateValueOn NSOnState
1379 #define NSControlStateValueOff NSOffState
1380 #define NSBezelStyleRounded NSRoundedBezelStyle
1381 #define NSButtonTypeMomentaryPushIn NSMomentaryPushInButton
1382 #endif
1383
1384 extern void mark_nsterm (void);
1385
1386 #endif