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.
This commit is contained in:
Anders Lindgren 2015-10-23 07:58:02 +02:00
parent 3768304c6a
commit ba24d35a3e
5 changed files with 877 additions and 327 deletions

View file

@ -49,13 +49,6 @@ Updated by Christian Limpach (chris@nice.ch)
#include "macfont.h"
#endif
#if 0
int fns_trace_num = 1;
#define NSTRACE(x) fprintf (stderr, "%s:%d: [%d] " #x "\n", \
__FILE__, __LINE__, ++fns_trace_num)
#else
#define NSTRACE(x)
#endif
#ifdef HAVE_NS
@ -364,7 +357,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side
x_set_icon_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
{
NSView *view = FRAME_NS_VIEW (f);
NSTRACE (x_set_icon_name);
NSTRACE ("x_set_icon_name");
/* see if it's changed */
if (STRINGP (arg))
@ -436,7 +429,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side
static void
ns_set_name (struct frame *f, Lisp_Object name, int explicit)
{
NSTRACE (ns_set_name);
NSTRACE ("ns_set_name");
/* Make sure that requests from lisp code override requests from
Emacs redisplay code. */
@ -477,7 +470,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side
static void
x_explicitly_set_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
{
NSTRACE (x_explicitly_set_name);
NSTRACE ("x_explicitly_set_name");
ns_set_name (f, arg, 1);
}
@ -488,7 +481,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side
void
x_implicitly_set_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
{
NSTRACE (x_implicitly_set_name);
NSTRACE ("x_implicitly_set_name");
/* Deal with NS specific format t. */
if (FRAME_NS_P (f) && ((FRAME_ICONIFIED_P (f) && EQ (Vicon_title_format, Qt))
@ -505,7 +498,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side
static void
x_set_title (struct frame *f, Lisp_Object name, Lisp_Object old_name)
{
NSTRACE (x_set_title);
NSTRACE ("x_set_title");
/* Don't change the title if it's already NAME. */
if (EQ (name, f->title))
return;
@ -533,7 +526,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side
NSAutoreleasePool *pool;
Lisp_Object encoded_name, encoded_filename;
NSString *str;
NSTRACE (ns_set_name_as_filename);
NSTRACE ("ns_set_name_as_filename");
if (f->explicit_name || ! NILP (f->title))
return;
@ -729,7 +722,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side
NSAutoreleasePool *pool;
BOOL setMini = YES;
NSTRACE (ns_implicitly_set_icon_type);
NSTRACE ("ns_implicitly_set_icon_type");
block_input ();
pool = [[NSAutoreleasePool alloc] init];
@ -797,7 +790,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side
id image = nil;
BOOL setMini = YES;
NSTRACE (x_set_icon_type);
NSTRACE ("x_set_icon_type");
if (!NILP (arg) && SYMBOLP (arg))
{

View file

@ -35,14 +35,6 @@ Updated by Christian Limpach (chris@nice.ch)
#include "frame.h"
#include "coding.h"
/* call tracing */
#if 0
int image_trace_num = 0;
#define NSTRACE(x) fprintf (stderr, "%s:%d: [%d] " #x "\n", \
__FILE__, __LINE__, ++image_trace_num)
#else
#define NSTRACE(x)
#endif
/* ==========================================================================
@ -57,7 +49,7 @@ Updated by Christian Limpach (chris@nice.ch)
ns_image_from_XBM (unsigned char *bits, int width, int height,
unsigned long fg, unsigned long bg)
{
NSTRACE (ns_image_from_XBM);
NSTRACE ("ns_image_from_XBM");
return [[EmacsImage alloc] initFromXBM: bits
width: width height: height
fg: fg bg: bg];
@ -66,7 +58,7 @@ Updated by Christian Limpach (chris@nice.ch)
void *
ns_image_for_XPM (int width, int height, int depth)
{
NSTRACE (ns_image_for_XPM);
NSTRACE ("ns_image_for_XPM");
return [[EmacsImage alloc] initForXPMWithDepth: depth
width: width height: height];
}
@ -74,7 +66,7 @@ Updated by Christian Limpach (chris@nice.ch)
void *
ns_image_from_file (Lisp_Object file)
{
NSTRACE (ns_image_from_bitmap_file);
NSTRACE ("ns_image_from_bitmap_file");
return [EmacsImage allocInitFromFile: file];
}
@ -85,7 +77,7 @@ Updated by Christian Limpach (chris@nice.ch)
EmacsImage *eImg = nil;
NSSize size;
NSTRACE (ns_load_image);
NSTRACE ("ns_load_image");
if (STRINGP (spec_file))
{

View file

@ -45,13 +45,6 @@
#include <sys/types.h>
#endif
#if 0
int menu_trace_num = 0;
#define NSTRACE(x) fprintf (stderr, "%s:%d: [%d] " #x "\n", \
__FILE__, __LINE__, ++menu_trace_num)
#else
#define NSTRACE(x)
#endif
#if 0
/* Include lisp -> C common menu parsing code */
@ -121,7 +114,7 @@
long t;
#endif
NSTRACE (ns_update_menubar);
NSTRACE ("ns_update_menubar");
if (f != SELECTED_FRAME ())
return;
@ -801,6 +794,8 @@ - (Lisp_Object)runMenuAt: (NSPoint)p forFrame: (struct frame *)f
widget_value *wv, *first_wv = 0;
bool keymaps = (menuflags & MENU_KEYMAPS);
NSTRACE ("ns_menu_show");
block_input ();
p.x = x; p.y = y;
@ -1423,7 +1418,7 @@ - (NSRect) frame
BOOL isQ;
NSAutoreleasePool *pool;
NSTRACE (x-popup-dialog);
NSTRACE ("ns_popup_dialog");
isQ = NILP (header);

View file

@ -59,6 +59,240 @@ typedef CGFloat EmacsCGFloat;
typedef float EmacsCGFloat;
#endif
/* ==========================================================================
Trace support
========================================================================== */
/* Uncomment the following line to enable trace. */
/* #define NSTRACE_ENABLED 1 */
/* Print a call tree containing all annotated functions.
The call structure of the functions is represented using
indentation and vertical lines. Extra information is printed using
horizontal lines that connect to the vertical line.
The return value is represented using the arrow "->>". For simple
functions, the arrow can be printed on the same line as the
function name. If more output is printed, it is connected to the
vertical line of the function.
The first column contains the file name, the second the line
number, and the third a number increasing for each trace line.
Note that the trace system, when enabled, use the GCC/Clang
"cleanup" extension.
For example (long lines manually split to reduce width):
nsterm.m : 1600: [ 4428] ns_fullscreen_hook
nsterm.m : 7006: [ 4429] | handleFS
nsterm.m : 7035: [ 4430] | +--- FULLSCREEN_MAXIMIZED
nsterm.m : 7627: [ 4431] | | performZoom
nsterm.m : 7636: [ 4432] | | | zoom
nsterm.m : 874: [ 4433] | | | | ns_update_auto_hide_menu_bar
nsterm.m : 6615: [ 4434] | | | | [windowWillUseStandardFrame:
defaultFrame:(X:0 Y:0)/(W:1600 H:1177)]
nsterm.m : 99: [ 4435] | | | | +--- fs_state: FULLSCREEN_NONE
nsterm.m : 119: [ 4436] | | | | +--- fs_before_fs: -1
nsterm.m : 115: [ 4437] | | | | +--- next_maximized: FULLSCREEN_MAXIMIZED
nsterm.m : 6619: [ 4438] | | | | +--- ns_userRect: (X:0 Y:0)/(W:0 H:0)
nsterm.m : 6620: [ 4439] | | | | +--- [sender frame]:
(X:0 Y:626)/(W:595 H:551)
nsterm.m : 6644: [ 4440] | | | | +--- ns_userRect (2):
(X:0 Y:626)/(W:595 H:551)
nsterm.m : 6684: [ 4441] | | | | +--- FULLSCREEN_MAXIMIZED
nsterm.m : 7057: [ 4442] | | | | | setFSValue
nsterm.m : 115: [ 4443] | | | | | +--- value: FULLSCREEN_MAXIMIZED
nsterm.m : 6711: [ 4444] | | | | +--- Final ns_userRect:
(X:0 Y:626)/(W:595 H:551)
nsterm.m : 6712: [ 4445] | | | | +--- Final maximized_width: 1600
nsterm.m : 6713: [ 4446] | | | | +--- Final maximized_height: 1177
nsterm.m : 119: [ 4447] | | | | +--- Final next_maximized: -1
nsterm.m : 6209: [ 4448] | | | | | windowWillResize: toSize: (W:1600 H:1177)
nsterm.m : 6210: [ 4449] | | | | | +--- [sender frame]:
(X:0 Y:626)/(W:595 H:551)
nsterm.m : 115: [ 4450] | | | | | +--- fs_state: FULLSCREEN_MAXIMIZED
nsterm.m : 6274: [ 4451] | | | | | +--- cols: 223 rows: 79
nsterm.m : 6299: [ 4452] | | | | | +->> (W:1596 H:1167)
nsterm.m : 6718: [ 4453] | | | | +->> (X:0 Y:0)/(W:1600 H:1177)
Here, "ns_fullscreen_hook" calls "handleFS", which is turn calls
"performZoom". This function calls "[super performZoom]", which
isn't annoted (so it doesn't show up in the trace). However, it
calls "zoom" which is annotated so it is part of the call trace.
Later, the method "windowWillUseStandardFrame" and the function
"setFSValue" are called. The lines with "+---" contain extra
information and lines containing "->>" represent return values. */
#ifndef NSTRACE_ENABLED
#define NSTRACE_ENABLED 0
#endif
#if NSTRACE_ENABLED
extern int nstrace_num;
extern int nstrace_depth;
void nstrace_leave(int *);
/* printf-style trace output. Output is aligned with contained heading. */
#define NSTRACE_MSG_NO_DASHES(...) \
do \
{ \
if (nstrace_enabled) \
{ \
fprintf (stderr, "%-10s:%5d: [%5d]%.*s", \
__FILE__, __LINE__, ++nstrace_num, \
2*nstrace_depth, " | | | | | | | | | | | | | | | .."); \
fprintf (stderr, __VA_ARGS__); \
fprintf (stderr, "\n"); \
} \
} \
while(0)
#define NSTRACE_MSG(...) NSTRACE_MSG_NO_DASHES("+--- " __VA_ARGS__)
/* Macros for printing complex types.
NSTRACE_FMT_what -- Printf format string for "what".
NSTRACE_ARG_what(x) -- Printf argument for "what". */
#define NSTRACE_FMT_SIZE "(W:%.0f H:%.0f)"
#define NSTRACE_ARG_SIZE(elt) (elt).width, (elt).height
#define NSTRACE_FMT_POINT "(X:%.0f Y:%.0f)"
#define NSTRACE_ARG_POINT(elt) (elt).x, (elt).y
#define NSTRACE_FMT_RECT NSTRACE_FMT_POINT "/" NSTRACE_FMT_SIZE
#define NSTRACE_ARG_RECT(elt) \
NSTRACE_ARG_POINT((elt).origin), NSTRACE_ARG_SIZE((elt).size)
/* Macros for printing complex types as extra information. */
#define NSTRACE_SIZE(str,size) \
NSTRACE_MSG (str ": " NSTRACE_FMT_SIZE, \
NSTRACE_ARG_SIZE (size));
#define NSTRACE_POINT(str,point) \
NSTRACE_MSG (str ": " NSTRACE_FMT_POINT, \
NSTRACE_ARG_POINT (point));
#define NSTRACE_RECT(str,rect) \
NSTRACE_MSG (str ": " NSTRACE_FMT_RECT, \
NSTRACE_ARG_RECT (rect));
#define NSTRACE_FSTYPE(str,fs_type) \
do \
{ \
if (nstrace_enabled) \
{ \
ns_print_fullscreen_type_name(str, fs_type); \
} \
} \
while(0)
/* Return value macros.
NSTRACE_RETURN(fmt, ...) - Print a return value, support printf-style
format string and arguments.
NSTRACE_RETURN_what(obj) - Print a return value of kind WHAT.
NSTRACE_FMT_RETURN - A string literal representing a returned
value. Useful when creating a format string
to printf-like constructs like NSTRACE(). */
#define NSTRACE_FMT_RETURN "->>"
#define NSTRACE_RETURN(...) \
NSTRACE_MSG_NO_DASHES ("+" NSTRACE_FMT_RETURN " " __VA_ARGS__)
#define NSTRACE_RETURN_SIZE(size) \
NSTRACE_RETURN(NSTRACE_FMT_SIZE, NSTRACE_ARG_SIZE(size))
#define NSTRACE_RETURN_POINT(point) \
NSTRACE_RETURN(NSTRACE_FMT_POINT, NSTRACE_ARG_POINT(point))
#define NSTRACE_RETURN_RECT(rect) \
NSTRACE_RETURN(NSTRACE_FMT_RECT, NSTRACE_ARG_RECT(rect))
/* Function enter macros.
NSTRACE (fmt, ...) -- Enable trace output in curent block
(typically a function). Accepts printf-style
arguments.
NSTRACE_WHEN (cond, fmt, ...) -- Enable trace output when COND is true.
NSTRACE_UNLESS (cond, fmt, ...) -- Enable trace output unless COND is
true. */
#define NSTRACE_WHEN(cond, ...) \
__attribute__((cleanup(nstrace_leave))) \
int nstrace_enabled = (cond); \
if (nstrace_enabled) { ++nstrace_depth; } \
NSTRACE_MSG_NO_DASHES(__VA_ARGS__);
#endif /* NSTRACE_ENABLED */
#define NSTRACE(...) NSTRACE_WHEN(1, __VA_ARGS__)
#define NSTRACE_UNLESS(cond, ...) NSTRACE_WHEN(!(cond), __VA_ARGS__)
/* Non-trace replacement versions. */
#ifndef NSTRACE_WHEN
#define NSTRACE_WHEN(...)
#endif
#ifndef NSTRACE_MSG
#define NSTRACE_MSG(...)
#endif
#ifndef NSTRACE_SIZE
#define NSTRACE_SIZE(str,size)
#endif
#ifndef NSTRACE_POINT
#define NSTRACE_POINT(str,point)
#endif
#ifndef NSTRACE_RECT
#define NSTRACE_RECT(str,rect)
#endif
#ifndef NSTRACE_FSTYPE
#define NSTRACE_FSTYPE(str,fs_type)
#endif
#ifndef NSTRACE_RETURN_SIZE
#define NSTRACE_RETURN_SIZE(size)
#endif
#ifndef NSTRACE_RETURN_POINT
#define NSTRACE_RETURN_POINT(point)
#endif
#ifndef NSTRACE_RETURN_RECT
#define NSTRACE_RETURN_RECT(rect)
#endif
#ifndef NSTRACE_RETURN_FSTYPE
#define NSTRACE_RETURN_FSTYPE(fs_type)
#endif
/* ==========================================================================
NSColor, EmacsColor category.
@ -174,6 +408,7 @@ typedef float EmacsCGFloat;
#ifdef NS_IMPL_GNUSTEP
- (void)windowDidMove: (id)sender;
#endif
- (int)fullscreenState;
@end

File diff suppressed because it is too large Load diff