aboutsummaryrefslogtreecommitdiffstats
path: root/src/nsterm.h
diff options
context:
space:
mode:
authorAnders Lindgren2015-10-23 07:58:02 +0200
committerAnders Lindgren2015-10-23 07:58:02 +0200
commitba24d35a3e82cdeba4be5bd794f7f48bbfa5498e (patch)
treeafd99e3b51d9773d178bdc1b972ddd6a367385e3 /src/nsterm.h
parent3768304c6a501fb5bc90ed9e21a63aebd314a44e (diff)
downloademacs-ba24d35a3e82cdeba4be5bd794f7f48bbfa5498e.tar.gz
emacs-ba24d35a3e82cdeba4be5bd794f7f48bbfa5498e.zip
NextSten maximization and NSTRACE rewrite.
Full-height, full-width, and maximized windows now cover the entire screen (except the menu bar), including the part where the system dock is placed. The system zoom animation is no longer used. Made NonMaximized->FullWidth->FullHeight->NonMaximized restore the original size. * nsterm.m (ns_menu_bar_height): New function, return height of the menu bar, or 0 when it's hidden. * nsterm.m (constrain_frame_rect): New function for constraining a frame. * nsterm.m (ns_constrain_all_frames): Set frame size explicitly rather than relying on the system doing it for us by writing back the current frame size. * nsterm.m (windowWillUseStandardFrame): Register non-maximized width or height as new user size. When entering full width or height, the other size component is taken from the user size. * nsterm.m (fullscreenState): New method for accessing the fullscreen state. * nsterm.m (constrainFrameRect): Restrict frame to be placed under the menu bar, if present. The old version, sometimes, restricted the height of a frame to the screen, this version never does this. * nsterm.m (zoom): Perform zoom by setting the frame to the full size of the screen (minus the menu bar). The default system function, with the zoom animation, is no longer used, as the final frame size doesn't cover the entire screen. Rework how to constrain resizing to the character grid. The old system used "resizeIncrements" in NSWindows. However, once a frame was resized so that it was not aligned to the text grid, it remained unaligned even after a resize. In addition, it conflicted when resizing a fullheight window. * nsterm.m (windowWillResize): Restrict frame size to text grid, unless when pixelwise frame resizing is enabled. * nsterm.m (updateFrameSize, initFrameFromEmacs) (toggleFullScreen, handleFS): Don't set resizeIncrements. Redesign the NS trace system. The call structure is represented using indentations and vertical lines. The NSTRACE macro accepts printf-style arguments. New macros for printing various information. * nsterm.h (NSTRACE_ENABLED): Macro to enable trace system. * nsterm.h (NSTRACE, NSTRACE_WHEN, NSTRACE_UNLESS): Macros to start a new block (typically a function), accept printf-style arguments. * nsterm.h (NSTRACE_MSG): Macro for extra information, accepts printf-style arguments. * nsterm.h (NSTRACE_what): Macros for printing various types. * nsterm.h (NSTRACE_FMT_what): Macro with printf format string snippets. * nsterm.h (NSTRACE_ARG_what): Macros for passing printf-style arguments, corresponds to NSTRACE_FMT_what. * nsterm.h (NSTRACE_RETURN): Macro to print return value, accept printf-style arguments. * nsterm.h (NSTRACE_RETURN_what): Macros to print return value for various types. * nsterm.m: Remove old NSTRACE macro. * nsterm.m (nstrace_num): Trace counter. * nsterm.m (nstrace_depth): Current call depth. * nsterm.m (nstrace_leave): NSTRACE support function, called when the local variable "nstrace_enabled" goes out of scope using the "cleanup" extension. * nsterm.m (ns_print_fullscreen_type_name): NSTRACE_FSTYPE support function. * nsterm.m (constrain_frame_rect, ns_constrain_all_frames) (ns_update_auto_hide_menu_bar, ns_update_begin) (ns_update_window_begin, update_window_end, ns_update_end) (ns_focus, ns_unfocus, ns_ring_bell, ns_frame_raise_lower) (ns_frame_rehighlight, x_make_frame_visible) (x_make_frame_invisible, x_iconify_frame, x_free_frame_resources) (x_destroy_window, x_set_offset, x_set_window_size) (ns_fullscreen_hook, ns_lisp_to_color, ns_color_to_lisp) (ns_defined_color, frame_set_mouse_pixel_position) (note_mouse_movement, ns_mouse_position, ns_frame_up_to_date) (ns_define_frame_cursor, x_get_keysym_name, ns_redraw_scroll_bars) (ns_clear_frame, ns_clear_frame_area, ns_scroll_run) (ns_after_update_window_line, ns_shift_glyphs_for_insert) (dumpcursor, ns_draw_vertical_window_border) (ns_draw_window_divider, ns_draw_relief) (ns_dumpglyphs_box_or_relief, ns_maybe_dumpglyphs_background) (ns_dumpglyphs_image, ns_draw_glyph_string, ns_send_appdefined) (ns_read_socket, ns_select, ns_set_vertical_scroll_bar) (ns_set_horizontal_scroll_bar, ns_condemn_scroll_bars) (ns_redeem_scroll_bar, ns_judge_scroll_bars, ns_delete_terminal) (ns_create_terminal, ns_term_init, sendEvent) (applicationDidFinishLaunching, applicationDidBecomeActive) (timeout_handler, fd_handler, EmacsView_dealloc, changeFont) (acceptsFirstResponder, resetCursorRects, keyDown, mouseDown) (deltaIsZero, rightMouseDown, otherMouseDown, mouseUp) (rightMouseUp, otherMouseUp, scrollWheel, mouseMoved) (mouse_autoselect_window, in_window, mouseDragged) (rightMouseDragged, otherMouseDragged, windowShouldClose) (updateFrameSize, windowWillResize, windowDidResize) (windowDidBecomeKey, windowDidResignKey, windowWillMiniaturize) (initFrameFromEmacs, windowDidMove, windowDidDeminiaturize) (windowDidExpose, windowDidMiniaturize, windowWillEnterFullScreen) (windowDidEnterFullScreen, windowWillExitFullScreen) (windowDidExitFullScreen, toggleFullScreen, handleFS, setFSValue) (mouseEntered, mouseExited, menuDown, toolbarClicked, drawRect) (draggingEntered, performDragOperation, validRequestorForSendType) (setMiniwindowImage, constrainFrameRect, performZoom, zoom) (EmacsScroller_initFrame, EmacsScroller_setFrame) (EmacsScroller_dealloc, condemn, reprieve, judge) (resetCursorRects, setPosition, EmacsScroller_mouseDown) (EmacsScroller_mouseDragged, syms_of_nsterm): Use new trace system. * nsfns.m: Remove old NSTRACE macro. * nsfns.m (x_set_icon_name, ns_set_name, x_explicitly_set_name) (x_implicitly_set_name, x_set_title, ns_set_name_as_filename) (ns_implicitly_set_icon_type, x_set_icon_type): Use new trace system. * nsimage.m: Remove old NSTRACE macro. * nsimage.m (ns_image_from_XBM, ns_image_for_XPM) (ns_image_from_bitmap_file, ns_load_image): Use new trace system. * nsmenu.m: Remove old NSTRACE macro. * nsmenu.m (ns_update_menubar, ns_menu_show, ns_popup_dialog): Use new trace system.
Diffstat (limited to 'src/nsterm.h')
-rw-r--r--src/nsterm.h235
1 files changed, 235 insertions, 0 deletions
diff --git a/src/nsterm.h b/src/nsterm.h
index c06b7c49a6d..8d52dc642ed 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -61,6 +61,240 @@ typedef float EmacsCGFloat;
61 61
62/* ========================================================================== 62/* ==========================================================================
63 63
64 Trace support
65
66 ========================================================================== */
67
68/* Uncomment the following line to enable trace. */
69
70/* #define NSTRACE_ENABLED 1 */
71
72
73/* Print a call tree containing all annotated functions.
74
75 The call structure of the functions is represented using
76 indentation and vertical lines. Extra information is printed using
77 horizontal lines that connect to the vertical line.
78
79 The return value is represented using the arrow "->>". For simple
80 functions, the arrow can be printed on the same line as the
81 function name. If more output is printed, it is connected to the
82 vertical line of the function.
83
84 The first column contains the file name, the second the line
85 number, and the third a number increasing for each trace line.
86
87 Note that the trace system, when enabled, use the GCC/Clang
88 "cleanup" extension.
89
90 For example (long lines manually split to reduce width):
91
92nsterm.m : 1600: [ 4428] ns_fullscreen_hook
93nsterm.m : 7006: [ 4429] | handleFS
94nsterm.m : 7035: [ 4430] | +--- FULLSCREEN_MAXIMIZED
95nsterm.m : 7627: [ 4431] | | performZoom
96nsterm.m : 7636: [ 4432] | | | zoom
97nsterm.m : 874: [ 4433] | | | | ns_update_auto_hide_menu_bar
98nsterm.m : 6615: [ 4434] | | | | [windowWillUseStandardFrame:
99 defaultFrame:(X:0 Y:0)/(W:1600 H:1177)]
100nsterm.m : 99: [ 4435] | | | | +--- fs_state: FULLSCREEN_NONE
101nsterm.m : 119: [ 4436] | | | | +--- fs_before_fs: -1
102nsterm.m : 115: [ 4437] | | | | +--- next_maximized: FULLSCREEN_MAXIMIZED
103nsterm.m : 6619: [ 4438] | | | | +--- ns_userRect: (X:0 Y:0)/(W:0 H:0)
104nsterm.m : 6620: [ 4439] | | | | +--- [sender frame]:
105 (X:0 Y:626)/(W:595 H:551)
106nsterm.m : 6644: [ 4440] | | | | +--- ns_userRect (2):
107 (X:0 Y:626)/(W:595 H:551)
108nsterm.m : 6684: [ 4441] | | | | +--- FULLSCREEN_MAXIMIZED
109nsterm.m : 7057: [ 4442] | | | | | setFSValue
110nsterm.m : 115: [ 4443] | | | | | +--- value: FULLSCREEN_MAXIMIZED
111nsterm.m : 6711: [ 4444] | | | | +--- Final ns_userRect:
112 (X:0 Y:626)/(W:595 H:551)
113nsterm.m : 6712: [ 4445] | | | | +--- Final maximized_width: 1600
114nsterm.m : 6713: [ 4446] | | | | +--- Final maximized_height: 1177
115nsterm.m : 119: [ 4447] | | | | +--- Final next_maximized: -1
116nsterm.m : 6209: [ 4448] | | | | | windowWillResize: toSize: (W:1600 H:1177)
117nsterm.m : 6210: [ 4449] | | | | | +--- [sender frame]:
118 (X:0 Y:626)/(W:595 H:551)
119nsterm.m : 115: [ 4450] | | | | | +--- fs_state: FULLSCREEN_MAXIMIZED
120nsterm.m : 6274: [ 4451] | | | | | +--- cols: 223 rows: 79
121nsterm.m : 6299: [ 4452] | | | | | +->> (W:1596 H:1167)
122nsterm.m : 6718: [ 4453] | | | | +->> (X:0 Y:0)/(W:1600 H:1177)
123
124 Here, "ns_fullscreen_hook" calls "handleFS", which is turn calls
125 "performZoom". This function calls "[super performZoom]", which
126 isn't annoted (so it doesn't show up in the trace). However, it
127 calls "zoom" which is annotated so it is part of the call trace.
128 Later, the method "windowWillUseStandardFrame" and the function
129 "setFSValue" are called. The lines with "+---" contain extra
130 information and lines containing "->>" represent return values. */
131
132#ifndef NSTRACE_ENABLED
133#define NSTRACE_ENABLED 0
134#endif
135
136#if NSTRACE_ENABLED
137extern int nstrace_num;
138extern int nstrace_depth;
139
140void nstrace_leave(int *);
141
142/* printf-style trace output. Output is aligned with contained heading. */
143#define NSTRACE_MSG_NO_DASHES(...) \
144 do \
145 { \
146 if (nstrace_enabled) \
147 { \
148 fprintf (stderr, "%-10s:%5d: [%5d]%.*s", \
149 __FILE__, __LINE__, ++nstrace_num, \
150 2*nstrace_depth, " | | | | | | | | | | | | | | | .."); \
151 fprintf (stderr, __VA_ARGS__); \
152 fprintf (stderr, "\n"); \
153 } \
154 } \
155 while(0)
156
157#define NSTRACE_MSG(...) NSTRACE_MSG_NO_DASHES("+--- " __VA_ARGS__)
158
159
160
161/* Macros for printing complex types.
162
163 NSTRACE_FMT_what -- Printf format string for "what".
164 NSTRACE_ARG_what(x) -- Printf argument for "what". */
165
166#define NSTRACE_FMT_SIZE "(W:%.0f H:%.0f)"
167#define NSTRACE_ARG_SIZE(elt) (elt).width, (elt).height
168
169#define NSTRACE_FMT_POINT "(X:%.0f Y:%.0f)"
170#define NSTRACE_ARG_POINT(elt) (elt).x, (elt).y
171
172#define NSTRACE_FMT_RECT NSTRACE_FMT_POINT "/" NSTRACE_FMT_SIZE
173#define NSTRACE_ARG_RECT(elt) \
174 NSTRACE_ARG_POINT((elt).origin), NSTRACE_ARG_SIZE((elt).size)
175
176
177/* Macros for printing complex types as extra information. */
178
179#define NSTRACE_SIZE(str,size) \
180 NSTRACE_MSG (str ": " NSTRACE_FMT_SIZE, \
181 NSTRACE_ARG_SIZE (size));
182
183#define NSTRACE_POINT(str,point) \
184 NSTRACE_MSG (str ": " NSTRACE_FMT_POINT, \
185 NSTRACE_ARG_POINT (point));
186
187#define NSTRACE_RECT(str,rect) \
188 NSTRACE_MSG (str ": " NSTRACE_FMT_RECT, \
189 NSTRACE_ARG_RECT (rect));
190
191#define NSTRACE_FSTYPE(str,fs_type) \
192 do \
193 { \
194 if (nstrace_enabled) \
195 { \
196 ns_print_fullscreen_type_name(str, fs_type); \
197 } \
198 } \
199 while(0)
200
201
202/* Return value macros.
203
204 NSTRACE_RETURN(fmt, ...) - Print a return value, support printf-style
205 format string and arguments.
206
207 NSTRACE_RETURN_what(obj) - Print a return value of kind WHAT.
208
209 NSTRACE_FMT_RETURN - A string literal representing a returned
210 value. Useful when creating a format string
211 to printf-like constructs like NSTRACE(). */
212
213#define NSTRACE_FMT_RETURN "->>"
214
215#define NSTRACE_RETURN(...) \
216 NSTRACE_MSG_NO_DASHES ("+" NSTRACE_FMT_RETURN " " __VA_ARGS__)
217
218#define NSTRACE_RETURN_SIZE(size) \
219 NSTRACE_RETURN(NSTRACE_FMT_SIZE, NSTRACE_ARG_SIZE(size))
220
221#define NSTRACE_RETURN_POINT(point) \
222 NSTRACE_RETURN(NSTRACE_FMT_POINT, NSTRACE_ARG_POINT(point))
223
224#define NSTRACE_RETURN_RECT(rect) \
225 NSTRACE_RETURN(NSTRACE_FMT_RECT, NSTRACE_ARG_RECT(rect))
226
227
228/* Function enter macros.
229
230 NSTRACE (fmt, ...) -- Enable trace output in curent block
231 (typically a function). Accepts printf-style
232 arguments.
233
234 NSTRACE_WHEN (cond, fmt, ...) -- Enable trace output when COND is true.
235
236 NSTRACE_UNLESS (cond, fmt, ...) -- Enable trace output unless COND is
237 true. */
238
239
240
241#define NSTRACE_WHEN(cond, ...) \
242 __attribute__((cleanup(nstrace_leave))) \
243 int nstrace_enabled = (cond); \
244 if (nstrace_enabled) { ++nstrace_depth; } \
245 NSTRACE_MSG_NO_DASHES(__VA_ARGS__);
246
247#endif /* NSTRACE_ENABLED */
248
249#define NSTRACE(...) NSTRACE_WHEN(1, __VA_ARGS__)
250#define NSTRACE_UNLESS(cond, ...) NSTRACE_WHEN(!(cond), __VA_ARGS__)
251
252
253/* Non-trace replacement versions. */
254#ifndef NSTRACE_WHEN
255#define NSTRACE_WHEN(...)
256#endif
257
258#ifndef NSTRACE_MSG
259#define NSTRACE_MSG(...)
260#endif
261
262#ifndef NSTRACE_SIZE
263#define NSTRACE_SIZE(str,size)
264#endif
265
266#ifndef NSTRACE_POINT
267#define NSTRACE_POINT(str,point)
268#endif
269
270#ifndef NSTRACE_RECT
271#define NSTRACE_RECT(str,rect)
272#endif
273
274#ifndef NSTRACE_FSTYPE
275#define NSTRACE_FSTYPE(str,fs_type)
276#endif
277
278#ifndef NSTRACE_RETURN_SIZE
279#define NSTRACE_RETURN_SIZE(size)
280#endif
281
282#ifndef NSTRACE_RETURN_POINT
283#define NSTRACE_RETURN_POINT(point)
284#endif
285
286#ifndef NSTRACE_RETURN_RECT
287#define NSTRACE_RETURN_RECT(rect)
288#endif
289
290#ifndef NSTRACE_RETURN_FSTYPE
291#define NSTRACE_RETURN_FSTYPE(fs_type)
292#endif
293
294
295
296/* ==========================================================================
297
64 NSColor, EmacsColor category. 298 NSColor, EmacsColor category.
65 299
66 ========================================================================== */ 300 ========================================================================== */
@@ -174,6 +408,7 @@ typedef float EmacsCGFloat;
174#ifdef NS_IMPL_GNUSTEP 408#ifdef NS_IMPL_GNUSTEP
175- (void)windowDidMove: (id)sender; 409- (void)windowDidMove: (id)sender;
176#endif 410#endif
411- (int)fullscreenState;
177@end 412@end
178 413
179 414