emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-25 ae16894: Enhance NSTRACE (trace output for NextSt


From: Anders Lindgren
Subject: [Emacs-diffs] emacs-25 ae16894: Enhance NSTRACE (trace output for NextStep).
Date: Sun, 15 Nov 2015 19:20:52 +0000

branch: emacs-25
commit ae16894d1e19601e19b1e70461dc0f69ae1f1059
Author: Anders Lindgren <address@hidden>
Commit: Anders Lindgren <address@hidden>

    Enhance NSTRACE (trace output for NextStep).
    
    Trace can be disabled for groups of functions. By default, event
    functions and functions that generate lots of output are disabled.
    
    Trace output of Objective-C functions now use the "[ClassName
    parameter:]" form.
    
    * src/nsterm.h (NSTRACE_ALL_GROUPS, NSTRACE_GROUP_EVENTS)
    (NSTRACE_GROUP_UPDATES, NSTRACE_GROUP_FRINGE, NSTRACE_GROUP_COLOR)
    (NSTRACE_GROUP_GLYPHS, NSTRACE_GROUP_FOCUS): New macros,
    controlling in which function groups trace should be active.
    (NSTRACE_WHEN): Support for silencing a function, this also
    silencing all called functions.
    (NSTRACE_UNSILENCE): New macro, used to re-enable trace.
    (NSTRACE_FMT_FSTYPE, NSTRACE_ARG_FSTYPE): New macros, used to
    print the full screen state in NSTRACE functions.
    
    * src/nsterm.m (nstrace_depth, nstrace_num): Made volatile as they
    can be accessed from multiple threads.
    (nstrace_enabled_global): New variable, when FALSE, trace is
    silenced.
    (nstrace_restore_global_trace_state): New function, used to
    restore `nstrace_enabled_global' at end of block.
    ([EmacsView setFrame:], [EmacsWindow setFrame:display:])
    ([EmacsWindow setFrame:display:animation:])
    ([EmacsWindow setFrameTopLeftPoint:]): New functions, print trace
    and call corresponding super function.
    (Many functions): Add or enhance trace output.
    
    * src/nsimage.m (ns_image_from_file): Enhanced trace output.
    
    * src/nsfns.m (x_set_tool_bar_lines): Add trace output.
    
    * src/nsmenu.m ([EmacsToolbar setVisible:]): New function, print trace
    and call corresponding super function.
---
 src/nsfns.m   |    4 +
 src/nsimage.m |    2 +-
 src/nsmenu.m  |    8 ++
 src/nsterm.h  |  169 +++++++++++++++++---------
 src/nsterm.m  |  376 +++++++++++++++++++++++++++++++++++---------------------
 5 files changed, 361 insertions(+), 198 deletions(-)

diff --git a/src/nsfns.m b/src/nsfns.m
index 94294de..434fd6a 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -655,6 +655,8 @@ x_set_tool_bar_lines (struct frame *f, Lisp_Object value, 
Lisp_Object oldval)
      `frame-inhibit-implied-resize'. */
   int nlines;
 
+  NSTRACE ("x_set_tool_bar_lines");
+
   if (FRAME_MINIBUF_ONLY_P (f))
     return;
 
@@ -703,6 +705,8 @@ x_set_tool_bar_lines (struct frame *f, Lisp_Object value, 
Lisp_Object oldval)
         ? 0
         : 2);
 
+    NSTRACE_MSG ("inhibit:%d", inhibit);
+
     frame_size_history_add (f, Qupdate_frame_tool_bar, 0, 0, Qnil);
     adjust_frame_size (f, -1, -1, inhibit, 0, Qtool_bar_lines);
   }
diff --git a/src/nsimage.m b/src/nsimage.m
index bdaf6a4..fad2538 100644
--- a/src/nsimage.m
+++ b/src/nsimage.m
@@ -66,7 +66,7 @@ ns_image_for_XPM (int width, int height, int depth)
 void *
 ns_image_from_file (Lisp_Object file)
 {
-  NSTRACE ("ns_image_from_bitmap_file");
+  NSTRACE ("ns_image_from_file");
   return [EmacsImage allocInitFromFile: file];
 }
 
diff --git a/src/nsmenu.m b/src/nsmenu.m
index ddc5dc2..3cb61e5 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -1293,6 +1293,14 @@ update_frame_tool_bar (struct frame *f)
   //return [identifierToItem allKeys];
 }
 
+- (void)setVisible:(BOOL)shown
+{
+  NSTRACE ("[EmacsToolbar setVisible:%d]", shown);
+
+  [super setVisible:shown];
+}
+
+
 /* optional and unneeded */
 /* - toolbarWillAddItem: (NSNotification *)notification { } */
 /* - toolbarDidRemoveItem: (NSNotification *)notification { } */
diff --git a/src/nsterm.h b/src/nsterm.h
index 7828af7..7a61814 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -67,12 +67,27 @@ typedef float EmacsCGFloat;
 
 /* Uncomment the following line to enable trace.
 
+   Uncomment suitable NSTRACE_GROUP_xxx lines to trace more.
+
    Hint: keep the trailing whitespace -- the version control system
    will reject accidental commits. */
 
 /* #define NSTRACE_ENABLED 1          */
 
 
+/* When non-zero, trace output is enbled for all parts, except those
+   explicitly disabled. */
+/* #define NSTRACE_ALL_GROUPS     1     */
+
+/* When non-zero, trace output is enabled in the corresponding part. */
+/* #define NSTRACE_GROUP_EVENTS  1     */
+/* #define NSTRACE_GROUP_UPDATES 1     */
+/* #define NSTRACE_GROUP_FRINGE  1     */
+/* #define NSTRACE_GROUP_COLOR   1     */
+/* #define NSTRACE_GROUP_GLYPHS  1     */
+/* #define NSTRACE_GROUP_FOCUS   1     */
+
+
 /* Print a call tree containing all annotated functions.
 
    The call structure of the functions is represented using
@@ -87,60 +102,94 @@ typedef float EmacsCGFloat;
    The first column contains the file name, the second the line
    number, and the third a number increasing for each trace line.
 
+   Note, when trace output from several threads are mixed, the output
+   can become misaligned, as all threads (currently) share one state.
+   This is post prominent when the EVENTS part is enabled.
+
    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 annotated (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. */
+   "cleanup" extension. */
+
+/*   For example, the following is the output of `M-x
+     toggle-frame-maximized RET'.
+
+     (Long lines manually split to reduced width):
+
+nsterm.m  : 1608: [  354]  ns_fullscreen_hook
+nsterm.m  : 7180: [  355]  | [EmacsView handleFS]
+nsterm.m  : 7209: [  356]  | +--- FULLSCREEN_MAXIMIZED
+nsterm.m  : 7706: [  357]  | | [EmacsWindow performZoom:]
+nsterm.m  : 7715: [  358]  | | | [EmacsWindow zoom:]
+nsterm.m  :  882: [  359]  | | | | ns_update_auto_hide_menu_bar
+nsterm.m  : 6752: [  360]  | | | |
+  [EmacsView windowWillUseStandardFrame:defaultFrame:(X:0 Y:0)/(W:1600 H:1177)]
+nsterm.m  : 6753: [  361]  | | | | +--- fs_state: FULLSCREEN_NONE
+nsterm.m  : 6754: [  362]  | | | | +--- fs_before_fs: -1
+nsterm.m  : 6755: [  363]  | | | | +--- next_maximized: FULLSCREEN_MAXIMIZED
+nsterm.m  : 6756: [  364]  | | | | +--- ns_userRect: (X:0 Y:0)/(W:0 H:0)
+nsterm.m  : 6757: [  365]  | | | | +---
+                                      [sender frame]: (X:0 Y:626)/(W:595 H:551)
+nsterm.m  : 6781: [  366]  | | | | +---
+                                     ns_userRect (2): (X:0 Y:626)/(W:595 H:551)
+nsterm.m  : 6821: [  367]  | | | | +--- FULLSCREEN_MAXIMIZED
+nsterm.m  : 7232: [  368]  | | | | |
+                                    [EmacsView setFSValue:FULLSCREEN_MAXIMIZED]
+nsterm.m  : 6848: [  369]  | | | | +---
+                                   Final ns_userRect: (X:0 Y:626)/(W:595 H:551)
+nsterm.m  : 6849: [  370]  | | | | +--- Final maximized_width: 1600
+nsterm.m  : 6850: [  371]  | | | | +--- Final maximized_height: 1177
+nsterm.m  : 6851: [  372]  | | | | +--- Final next_maximized: -1
+nsterm.m  : 6322: [  373]  | | | | |
+                           [EmacsView windowWillResize:toSize: (W:1600 H:1177)]
+nsterm.m  : 6323: [  374]  | | | | | +---
+                                      [sender frame]: (X:0 Y:626)/(W:595 H:551)
+nsterm.m  : 6324: [  375]  | | | | | +--- fs_state: FULLSCREEN_MAXIMIZED
+nsterm.m  : 7027: [  376]  | | | | | | [EmacsView isFullscreen]
+nsterm.m  : 6387: [  377]  | | | | | +--- cols: 223  rows: 79
+nsterm.m  : 6412: [  378]  | | | | | +->> (W:1596 H:1167)
+nsterm.m  : 6855: [  379]  | | | | +->> (X:0 Y:0)/(W:1600 H:1177)
+*/
 
 #ifndef NSTRACE_ENABLED
 #define NSTRACE_ENABLED 0
 #endif
 
 #if NSTRACE_ENABLED
-extern int nstrace_num;
-extern int nstrace_depth;
+
+#ifndef NSTRACE_ALL_GROUPS
+#define NSTRACE_ALL_GROUPS 0
+#endif
+
+#ifndef NSTRACE_GROUP_EVENTS
+#define NSTRACE_GROUP_EVENTS NSTRACE_ALL_GROUPS
+#endif
+
+#ifndef NSTRACE_GROUP_UPDATES
+#define NSTRACE_GROUP_UPDATES NSTRACE_ALL_GROUPS
+#endif
+
+#ifndef NSTRACE_GROUP_FRINGE
+#define NSTRACE_GROUP_FRINGE NSTRACE_ALL_GROUPS
+#endif
+
+#ifndef NSTRACE_GROUP_COLOR
+#define NSTRACE_GROUP_COLOR NSTRACE_ALL_GROUPS
+#endif
+
+#ifndef NSTRACE_GROUP_GLYPHS
+#define NSTRACE_GROUP_GLYPHS NSTRACE_ALL_GROUPS
+#endif
+
+#ifndef NSTRACE_GROUP_FOCUS
+#define NSTRACE_GROUP_FOCUS NSTRACE_ALL_GROUPS
+#endif
+
+extern volatile int nstrace_num;
+extern volatile int nstrace_depth;
+extern volatile int nstrace_enabled_global;
 
 void nstrace_leave(int *);
+void nstrace_restore_global_trace_state(int *);
+char const * nstrace_fullscreen_type_name (int);
 
 /* printf-style trace output.  Output is aligned with contained heading. */
 #define NSTRACE_MSG_NO_DASHES(...)                                          \
@@ -149,7 +198,7 @@ void nstrace_leave(int *);
       if (nstrace_enabled)                                                  \
         {                                                                   \
           fprintf (stderr, "%-10s:%5d: [%5d]%.*s",                          \
-                   __FILE__, __LINE__, ++nstrace_num,                       \
+                   __FILE__, __LINE__, nstrace_num++,                       \
                    2*nstrace_depth, "  | | | | | | | | | | | | | | | ..");  \
           fprintf (stderr, __VA_ARGS__);                                    \
           fprintf (stderr, "\n");                                           \
@@ -176,6 +225,9 @@ void nstrace_leave(int *);
 #define NSTRACE_ARG_RECT(elt)   \
   NSTRACE_ARG_POINT((elt).origin), NSTRACE_ARG_SIZE((elt).size)
 
+#define NSTRACE_FMT_FSTYPE      "%s"
+#define NSTRACE_ARG_FSTYPE(elt) nstrace_fullscreen_type_name(elt)
+
 
 /* Macros for printing complex types as extra information. */
 
@@ -192,14 +244,8 @@ void nstrace_leave(int *);
                NSTRACE_ARG_RECT (rect));
 
 #define NSTRACE_FSTYPE(str,fs_type)                                     \
-  do                                                                    \
-    {                                                                   \
-      if (nstrace_enabled)                                              \
-        {                                                               \
-          ns_print_fullscreen_type_name(str, fs_type);                  \
-        }                                                               \
-    }                                                                   \
-  while(0)
+  NSTRACE_MSG (str ": " NSTRACE_FMT_FSTYPE,                             \
+               NSTRACE_ARG_FSTYPE (fs_type));
 
 
 /* Return value macros.
@@ -242,17 +288,25 @@ void nstrace_leave(int *);
 
 
 #define NSTRACE_WHEN(cond, ...)                                         \
+  __attribute__((cleanup(nstrace_restore_global_trace_state)))          \
+  int nstrace_saved_enabled_global = nstrace_enabled_global;            \
   __attribute__((cleanup(nstrace_leave)))                               \
-  int nstrace_enabled = (cond);                                         \
+  int nstrace_enabled = nstrace_enabled_global && (cond);               \
   if (nstrace_enabled) { ++nstrace_depth; }                             \
+  else { nstrace_enabled_global = 0; }                                  \
   NSTRACE_MSG_NO_DASHES(__VA_ARGS__);
 
+/* Unsilence called functions.
+
+   Concretely, this us used to allow "event" functions to be silenced
+   while trace output can be printed for functions they call. */
+#define NSTRACE_UNSILENCE() do { nstrace_enabled_global = 1; } while(0)
+
 #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(...)
@@ -294,6 +348,9 @@ void nstrace_leave(int *);
 #define NSTRACE_RETURN_FSTYPE(fs_type)
 #endif
 
+#ifndef NSTRACE_UNSILENCE
+#define NSTRACE_UNSILENCE()
+#endif
 
 
 /* ==========================================================================
diff --git a/src/nsterm.m b/src/nsterm.m
index 397ade1..58ace48 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -72,9 +72,26 @@ GNUstep port and post-20 update by Adrian Robert 
(address@hidden)
 extern NSString *NSMenuDidBeginTrackingNotification;
 
 
+/* ==========================================================================
+
+   NSTRACE, Trace support.
+
+   ========================================================================== 
*/
+
 #if NSTRACE_ENABLED
-int nstrace_num = 0;
-int nstrace_depth = 0;
+
+/* The following use "volatile" since they can be accessed from
+   parallel threads. */
+volatile int nstrace_num = 0;
+volatile int nstrace_depth = 0;
+
+/* When 0, no trace is emitted.  This is used by NSTRACE_WHEN and
+   NSTRACE_UNLESS to silence functions called.
+
+   TODO: This should really be a thread-local variable, to avoid that
+   a function with disabled trace thread silence trace output in
+   another.  However, in practice this seldom is a problem. */
+volatile int nstrace_enabled_global = 1;
 
 /* Called when nstrace_enabled goes out of scope. */
 void nstrace_leave(int * pointer_to_nstrace_enabled)
@@ -86,38 +103,24 @@ void nstrace_leave(int * pointer_to_nstrace_enabled)
 }
 
 
-void ns_print_fullscreen_type_name (char const * s, int fs_type)
+/* Called when nstrace_saved_enabled_global goes out of scope. */
+void nstrace_restore_global_trace_state(int * pointer_to_saved_enabled_global)
 {
-  // This is a support function for the NSTRACE system, don't add a
-  // NSTRACE () here.  However, a local `nstrace_enabled' variable is
-  // needed by the NSTRACE_MSG macros.
-  int nstrace_enabled = 1;
+  nstrace_enabled_global = *pointer_to_saved_enabled_global;
+}
 
+
+char const * nstrace_fullscreen_type_name (int fs_type)
+{
   switch (fs_type)
     {
-    case FULLSCREEN_NONE:
-      NSTRACE_MSG ("%s: FULLSCREEN_NONE", s);
-      break;
-
-    case FULLSCREEN_WIDTH:
-      NSTRACE_MSG ("%s: FULLSCREEN_WIDTH", s);
-      break;
-
-    case FULLSCREEN_HEIGHT:
-      NSTRACE_MSG ("%s: FULLSCREEN_HEIGHT", s);
-      break;
-
-    case FULLSCREEN_BOTH:
-      NSTRACE_MSG ("%s: FULLSCREEN_BOTH", s);
-      break;
-
-    case FULLSCREEN_MAXIMIZED:
-      NSTRACE_MSG ("%s: FULLSCREEN_MAXIMIZED", s);
-      break;
-
-    default:
-      NSTRACE_MSG ("%s: %d", s, fs_type);
-      break;
+    case -1:                   return "-1";
+    case FULLSCREEN_NONE:      return "FULLSCREEN_NONE";
+    case FULLSCREEN_WIDTH:     return "FULLSCREEN_WIDTH";
+    case FULLSCREEN_HEIGHT:    return "FULLSCREEN_HEIGHT";
+    case FULLSCREEN_BOTH:      return "FULLSCREEN_BOTH";
+    case FULLSCREEN_MAXIMIZED: return "FULLSCREEN_MAXIMIZED";
+    default:                   return "FULLSCREEN_?????";
     }
 }
 #endif
@@ -919,7 +922,7 @@ ns_update_begin (struct frame *f)
    -------------------------------------------------------------------------- 
*/
 {
   EmacsView *view = FRAME_NS_VIEW (f);
-  NSTRACE ("ns_update_begin");
+  NSTRACE_WHEN (NSTRACE_GROUP_UPDATES, "ns_update_begin");
 
   ns_update_auto_hide_menu_bar ();
 
@@ -976,7 +979,7 @@ ns_update_window_begin (struct window *w)
   struct frame *f = XFRAME (WINDOW_FRAME (w));
   Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
 
-  NSTRACE ("ns_update_window_begin");
+  NSTRACE_WHEN (NSTRACE_GROUP_UPDATES, "ns_update_window_begin");
   w->output_cursor = w->cursor;
 
   block_input ();
@@ -1006,7 +1009,7 @@ ns_update_window_end (struct window *w, bool cursor_on_p,
    external (RIF) call; for one window called before update_end
    -------------------------------------------------------------------------- 
*/
 {
-  NSTRACE ("update_window_end");
+  NSTRACE_WHEN (NSTRACE_GROUP_UPDATES, "ns_update_window_end");
 
   /* note: this fn is nearly identical in all terms */
   if (!w->pseudo_window_p)
@@ -1045,7 +1048,7 @@ ns_update_end (struct frame *f)
 {
   EmacsView *view = FRAME_NS_VIEW (f);
 
-  NSTRACE ("ns_update_end");
+  NSTRACE_WHEN (NSTRACE_GROUP_UPDATES, "ns_update_end");
 
 /*   if (f == MOUSE_HL_INFO (f)->mouse_face_mouse_frame) */
   MOUSE_HL_INFO (f)->mouse_face_defer = 0;
@@ -1070,11 +1073,11 @@ ns_focus (struct frame *f, NSRect *r, int n)
      the entire window.
    -------------------------------------------------------------------------- 
*/
 {
-//  NSTRACE ("ns_focus");
-/* static int c =0;
-   fprintf (stderr, "focus: %d", c++);
-   if (r) fprintf (stderr, " (%.0f, %.0f : %.0f x %.0f)", r->origin.x, 
r->origin.y, r->size.width, r->size.height);
-   fprintf (stderr, "\n"); */
+  NSTRACE_WHEN (NSTRACE_GROUP_FOCUS, "ns_focus");
+  if (r != NULL)
+    {
+      NSTRACE_RECT ("r", *r);
+    }
 
   if (f != ns_updating_frame)
     {
@@ -1114,7 +1117,7 @@ ns_unfocus (struct frame *f)
      Internal: Remove focus on given frame
    -------------------------------------------------------------------------- 
*/
 {
-//  NSTRACE ("ns_unfocus");
+  NSTRACE_WHEN (NSTRACE_GROUP_FOCUS, "ns_unfocus");
 
   if (gsaved)
     {
@@ -1220,6 +1223,7 @@ ns_raise_frame (struct frame *f)
    -------------------------------------------------------------------------- 
*/
 {
   NSView *view;
+
   check_window_system (f);
   view = FRAME_NS_VIEW (f);
   block_input ();
@@ -1236,6 +1240,7 @@ ns_lower_frame (struct frame *f)
    -------------------------------------------------------------------------- 
*/
 {
   NSView *view;
+
   check_window_system (f);
   view = FRAME_NS_VIEW (f);
   block_input ();
@@ -1510,8 +1515,8 @@ x_set_window_size (struct frame *f,
     return;
 
   NSTRACE_RECT ("current", wr);
-
-/*fprintf (stderr, "\tsetWindowSize: %d x %d, pixelwise %d, font size %d x 
%d\n", width, height, pixelwise, FRAME_COLUMN_WIDTH (f), FRAME_LINE_HEIGHT 
(f));*/
+  NSTRACE_MSG ("Width:%d Height:%d Pixelwise:%d", width, height, pixelwise);
+  NSTRACE_MSG ("Font %d x %d", FRAME_COLUMN_WIDTH (f), FRAME_LINE_HEIGHT (f));
 
   block_input ();
 
@@ -1571,7 +1576,6 @@ x_set_window_size (struct frame *f,
           make_number (FRAME_NS_TITLEBAR_HEIGHT (f)),
           make_number (FRAME_TOOLBAR_HEIGHT (f))));
 
-  NSTRACE_RECT ("setFrame", wr);
   [window setFrame: wr display: YES];
 
   /* This is a trick to compensate for Emacs' managing the scrollbar area
@@ -1586,7 +1590,7 @@ x_set_window_size (struct frame *f,
       ? NSMakePoint (FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f)
                      - NS_SCROLL_BAR_WIDTH (f), 0)
       : NSMakePoint (0, 0);
-    NSTRACE_RECT ("setFrame", wr);
+
     [view setFrame: NSMakeRect (0, 0, pixelwidth, pixelheight)];
     [view setBoundsOrigin: origin];
   }
@@ -1728,7 +1732,8 @@ ns_get_color (const char *name, NSColor **col)
   float r = -1.0, g, b;
   NSString *nsname = [NSString stringWithUTF8String: name];
 
-/*fprintf (stderr, "ns_get_color: '%s'\n", name); */
+  NSTRACE ("ns_get_color(%s, **)", name);
+
   block_input ();
 
   if ([nsname isEqualToString: @"ns_selection_bg_color"])
@@ -1935,7 +1940,7 @@ ns_defined_color (struct frame *f,
    -------------------------------------------------------------------------- 
*/
 {
   NSColor *col;
-  NSTRACE ("ns_defined_color");
+  NSTRACE_WHEN (NSTRACE_GROUP_COLOR, "ns_defined_color");
 
   block_input ();
   if (ns_get_color (name, &col) != 0) /* Color not found  */
@@ -1961,6 +1966,8 @@ x_set_frame_alpha (struct frame *f)
   double alpha = 1.0;
   double alpha_min = 1.0;
 
+  NSTRACE ("x_set_frame_alpha");
+
   if (dpyinfo->x_highlight_frame == f)
     alpha = f->alpha[0];
   else
@@ -2097,7 +2104,7 @@ ns_mouse_position (struct frame **fp, int insist, 
Lisp_Object *bar_window,
       position = [view convertPoint: position fromView: nil];
       remember_mouse_glyph (f, position.x, position.y,
                             &dpyinfo->last_mouse_glyph);
-/*fprintf (stderr, "ns_mouse_position: %.0f, %.0f\n", position.x, position.y); 
*/
+      NSTRACE_POINT ("position", position);
 
       if (bar_window) *bar_window = Qnil;
       if (part) *part = scroll_bar_above_handle;
@@ -2120,7 +2127,7 @@ ns_frame_up_to_date (struct frame *f)
     Can't use FRAME_MOUSE_UPDATE due to ns_frame_begin and ns_frame_end calls.
    -------------------------------------------------------------------------- 
*/
 {
-  NSTRACE ("ns_frame_up_to_date");
+  NSTRACE_WHEN (NSTRACE_GROUP_UPDATES, "ns_frame_up_to_date");
 
   if (FRAME_NS_P (f))
     {
@@ -2231,7 +2238,7 @@ ns_clear_frame (struct frame *f)
   NSView *view = FRAME_NS_VIEW (f);
   NSRect r;
 
-  NSTRACE ("ns_clear_frame");
+  NSTRACE_WHEN (NSTRACE_GROUP_UPDATES, "ns_clear_frame");
 
  /* comes on initial frame because we have
     after-make-frame-functions = select-frame */
@@ -2267,7 +2274,7 @@ ns_clear_frame_area (struct frame *f, int x, int y, int 
width, int height)
   if (!view || !face)
     return;
 
-  NSTRACE ("ns_clear_frame_area");
+  NSTRACE_WHEN (NSTRACE_GROUP_UPDATES, "ns_clear_frame_area");
 
   r = NSIntersectionRect (r, [view frame]);
   ns_focus (f, &r, 1);
@@ -2360,7 +2367,7 @@ ns_after_update_window_line (struct window *w, struct 
glyph_row *desired_row)
   struct frame *f;
   int width, height;
 
-  NSTRACE ("ns_after_update_window_line");
+  NSTRACE_WHEN (NSTRACE_GROUP_UPDATES, "ns_after_update_window_line");
 
   /* begin copy from other terms */
   eassert (w);
@@ -2485,7 +2492,7 @@ ns_draw_fringe_bitmap (struct window *w, struct glyph_row 
*row,
   static EmacsImage **bimgs = NULL;
   static int nBimgs = 0;
 
-  NSTRACE ("ns_draw_fringe_bitmap");
+  NSTRACE_WHEN (NSTRACE_GROUP_FRINGE, "ns_draw_fringe_bitmap");
   NSTRACE_MSG ("which:%d cursor:%d overlay:%d width:%d height:%d period:%d",
                p->which, p->cursor_p, p->overlay_p, p->wd, p->h, p->dh);
 
@@ -2602,7 +2609,7 @@ ns_draw_window_cursor (struct window *w, struct glyph_row 
*glyph_row,
      in mini-buffer windows when switching between echo area glyphs
      and mini-buffer.  */
 
-  NSTRACE ("dumpcursor");
+  NSTRACE ("ns_draw_window_cursor");
 
   if (!on_p)
     return;
@@ -3519,7 +3526,7 @@ ns_draw_glyph_string (struct glyph_string *s)
   struct font *font = s->face->font;
   if (! font) font = FRAME_FONT (s->f);
 
-  NSTRACE ("ns_draw_glyph_string");
+  NSTRACE_WHEN (NSTRACE_GROUP_GLYPHS, "ns_draw_glyph_string");
 
   if (s->next && s->right_overhang && !s->for_overlaps/*&&s->hl!=DRAW_CURSOR*/)
     {
@@ -3677,7 +3684,7 @@ ns_send_appdefined (int value)
               recognize and take as a command to halt the event loop.
    -------------------------------------------------------------------------- 
*/
 {
-  NSTRACE ("ns_send_appdefined");
+  NSTRACE_WHEN (NSTRACE_GROUP_EVENTS, "ns_send_appdefined(%d)", value);
 
 #ifdef NS_IMPL_GNUSTEP
   // GNUstep needs postEvent to happen on the main thread.
@@ -3851,7 +3858,7 @@ ns_read_socket (struct terminal *terminal, struct 
input_event *hold_quit)
   struct input_event ev;
   int nevents;
 
-/* NSTRACE ("ns_read_socket"); */
+  NSTRACE_WHEN (NSTRACE_GROUP_EVENTS, "ns_read_socket");
 
 #ifdef HAVE_NATIVE_FS
   check_native_fs ();
@@ -3935,7 +3942,7 @@ ns_select (int nfds, fd_set *readfds, fd_set *writefds,
   struct input_event event;
   char c;
 
-/*  NSTRACE ("ns_select"); */
+  NSTRACE_WHEN (NSTRACE_GROUP_EVENTS, "ns_select");
 
 #ifdef HAVE_NATIVE_FS
   check_native_fs ();
@@ -4905,7 +4912,7 @@ ns_term_shutdown (int sig)
 
 - (void)stop: (id)sender
 {
-  NSTRACE ("[EmacsApp stop]");
+  NSTRACE ("[EmacsApp stop:]");
 
     shouldKeepRunning = NO;
     // Stop possible dialog also.  Noop if no dialog present.
@@ -4916,7 +4923,7 @@ ns_term_shutdown (int sig)
 
 - (void)logNotification: (NSNotification *)notification
 {
-  NSTRACE ("[EmacsApp logNotification]");
+  NSTRACE ("[EmacsApp logNotification:]");
 
   const char *name = [[notification name] UTF8String];
   if (!strstr (name, "Update") && !strstr (name, "NSMenu")
@@ -4934,8 +4941,8 @@ ns_term_shutdown (int sig)
   int type = [theEvent type];
   NSWindow *window = [theEvent window];
 
-  NSTRACE ("[EmacsApp sendEvent]");
-/*fprintf (stderr, "received event of type %d\t%d\n", type);*/
+  NSTRACE_WHEN (NSTRACE_GROUP_EVENTS, "[EmacsApp sendEvent:]");
+  NSTRACE_MSG ("Type: %d", type);
 
 #ifdef NS_IMPL_GNUSTEP
   // Keyboard events aren't propagated to file dialogs for some reason.
@@ -5021,6 +5028,8 @@ ns_term_shutdown (int sig)
     }
 #endif
 
+  NSTRACE_UNSILENCE();
+
   [super sendEvent: theEvent];
 }
 
@@ -5041,7 +5050,7 @@ ns_term_shutdown (int sig)
 
 - (void)newFrame: (id)sender
 {
-  NSTRACE ("[EmacsApp newFrame]");
+  NSTRACE ("[EmacsApp newFrame:]");
 
   struct frame *emacsframe = SELECTED_FRAME ();
   NSEvent *theEvent = [NSApp currentEvent];
@@ -5058,7 +5067,7 @@ ns_term_shutdown (int sig)
 /* Open a file (used by below, after going into queue read by ns_read_socket) 
*/
 - (BOOL) openFile: (NSString *)fileName
 {
-  NSTRACE ("[EmacsApp openFile]");
+  NSTRACE ("[EmacsApp openFile:]");
 
   struct frame *emacsframe = SELECTED_FRAME ();
   NSEvent *theEvent = [NSApp currentEvent];
@@ -5088,7 +5097,7 @@ ns_term_shutdown (int sig)
      When application is loaded, terminate event loop in ns_term_init
    -------------------------------------------------------------------------- 
*/
 {
-  NSTRACE ("[EmacsApp applicationDidFinishLaunching]");
+  NSTRACE ("[EmacsApp applicationDidFinishLaunching:]");
 
 #ifdef NS_IMPL_GNUSTEP
   ((EmacsApp *)self)->applicationDidFinishLaunchingCalled = YES;
@@ -5138,7 +5147,7 @@ ns_term_shutdown (int sig)
 
 - (void) terminate: (id)sender
 {
-  NSTRACE ("[EmacsApp terminate]");
+  NSTRACE ("[EmacsApp terminate:]");
 
   struct frame *emacsframe = SELECTED_FRAME ();
 
@@ -5176,7 +5185,7 @@ runAlertPanel(NSString *title,
 
 - (NSApplicationTerminateReply)applicationShouldTerminate: (id)sender
 {
-  NSTRACE ("[EmacsApp applicationShouldTerminate]");
+  NSTRACE ("[EmacsApp applicationShouldTerminate:]");
 
   bool ret;
 
@@ -5257,13 +5266,13 @@ not_in_argv (NSString *arg)
 /* TODO: these may help w/IO switching btwn terminal and NSApp */
 - (void)applicationWillBecomeActive: (NSNotification *)notification
 {
-  NSTRACE ("[EmacsApp applicationWillBecomeActive]");
+  NSTRACE ("[EmacsApp applicationWillBecomeActive:]");
   //ns_app_active=YES;
 }
 
 - (void)applicationDidBecomeActive: (NSNotification *)notification
 {
-  NSTRACE ("[EmacsApp applicationDidBecomeActive]");
+  NSTRACE ("[EmacsApp applicationDidBecomeActive:]");
 
 #ifdef NS_IMPL_GNUSTEP
   if (! applicationDidFinishLaunchingCalled)
@@ -5277,7 +5286,7 @@ not_in_argv (NSString *arg)
 }
 - (void)applicationDidResignActive: (NSNotification *)notification
 {
-  NSTRACE ("[EmacsApp applicationDidResignActive]");
+  NSTRACE ("[EmacsApp applicationDidResignActive:]");
 
   //ns_app_active=NO;
   ns_send_appdefined (-1);
@@ -5422,6 +5431,8 @@ not_in_argv (NSString *arg)
   struct frame *emacsframe = SELECTED_FRAME ();
   NSEvent *theEvent = [NSApp currentEvent];
 
+  NSTRACE ("[EmacsApp fulfillService:withArg:]");
+
   if (!emacs_event)
     return NO;
 
@@ -5452,13 +5463,15 @@ not_in_argv (NSString *arg)
 /* needed to inform when window closed from LISP */
 - (void) setWindowClosing: (BOOL)closing
 {
+  NSTRACE ("[EmacsView setWindowClosing:%d]", closing);
+
   windowClosing = closing;
 }
 
 
 - (void)dealloc
 {
-  NSTRACE ("EmacsView_dealloc");
+  NSTRACE ("[EmacsView dealloc]");
   [toolbar release];
   if (fs_state == FULLSCREEN_BOTH)
     [nonfs_window release];
@@ -5476,7 +5489,7 @@ not_in_argv (NSString *arg)
   CGFloat size;
   NSFont *nsfont;
 
-  NSTRACE ("changeFont");
+  NSTRACE ("[EmacsView changeFont:]");
 
   if (!emacs_event)
     return;
@@ -5506,7 +5519,7 @@ not_in_argv (NSString *arg)
 
 - (BOOL)acceptsFirstResponder
 {
-  NSTRACE ("acceptsFirstResponder");
+  NSTRACE ("[EmacsView acceptsFirstResponder]");
   return YES;
 }
 
@@ -5515,7 +5528,7 @@ not_in_argv (NSString *arg)
 {
   NSRect visible = [self visibleRect];
   NSCursor *currentCursor = FRAME_POINTER_TYPE (emacsframe);
-  NSTRACE ("resetCursorRects");
+  NSTRACE ("[EmacsView resetCursorRects]");
 
   if (currentCursor == nil)
     currentCursor = [NSCursor arrowCursor];
@@ -5540,7 +5553,7 @@ not_in_argv (NSString *arg)
   int left_is_none;
   unsigned int flags = [theEvent modifierFlags];
 
-  NSTRACE ("keyDown");
+  NSTRACE ("[EmacsView keyDown:]");
 
   /* Rhapsody and OS X give up and down events for the arrow keys */
   if (ns_fake_keydown == YES)
@@ -5785,6 +5798,9 @@ not_in_argv (NSString *arg)
 {
   int flags = [theEvent modifierFlags];
   int code = [theEvent keyCode];
+
+  NSTRACE ("[EmacsView keyUp:]");
+
   if (floor (NSAppKitVersionNumber) <= 824 /*NSAppKitVersionNumber10_4*/ &&
       code == 0x30 && (flags & NSControlKeyMask) && !(flags & 
NSCommandKeyMask))
     {
@@ -5809,6 +5825,8 @@ not_in_argv (NSString *arg)
   int len = [(NSString *)aString length];
   int i;
 
+  NSTRACE ("[EmacsView insertText:]");
+
   if (NS_KEYLOG)
     NSLog (@"insertText '%@'\tlen = %d", aString, len);
   processingCompose = NO;
@@ -5842,6 +5860,9 @@ not_in_argv (NSString *arg)
 {
   NSString *str = [aString respondsToSelector: @selector (string)] ?
     [aString string] : aString;
+
+  NSTRACE ("[EmacsView setMarkedText:selectedRange:]");
+
   if (NS_KEYLOG)
     NSLog (@"setMarkedText '%@' len =%lu range %lu from %lu",
            str, (unsigned long)[str length],
@@ -5869,6 +5890,8 @@ not_in_argv (NSString *arg)
 /* delete display of composing characters [not in <NSTextInput>] */
 - (void)deleteWorkingText
 {
+  NSTRACE ("[EmacsView deleteWorkingText]");
+
   if (workingText == nil)
     return;
   if (NS_KEYLOG)
@@ -5888,12 +5911,16 @@ not_in_argv (NSString *arg)
 
 - (BOOL)hasMarkedText
 {
+  NSTRACE ("[EmacsView hasMarkedText]");
+
   return workingText != nil;
 }
 
 
 - (NSRange)markedRange
 {
+  NSTRACE ("[EmacsView markedRange]");
+
   NSRange rng = workingText != nil
     ? NSMakeRange (0, [workingText length]) : NSMakeRange (NSNotFound, 0);
   if (NS_KEYLOG)
@@ -5904,6 +5931,8 @@ not_in_argv (NSString *arg)
 
 - (void)unmarkText
 {
+  NSTRACE ("[EmacsView unmarkText]");
+
   if (NS_KEYLOG)
     NSLog (@"unmark (accept) text");
   [self deleteWorkingText];
@@ -5917,6 +5946,9 @@ not_in_argv (NSString *arg)
   NSRect rect;
   NSPoint pt;
   struct window *win = XWINDOW (FRAME_SELECTED_WINDOW (emacsframe));
+
+  NSTRACE ("[EmacsView firstRectForCharacterRange:]");
+
   if (NS_KEYLOG)
     NSLog (@"firstRectForCharRange request");
 
@@ -5941,6 +5973,8 @@ not_in_argv (NSString *arg)
 
 - (void)doCommandBySelector: (SEL)aSelector
 {
+  NSTRACE ("[EmacsView doCommandBySelector:]");
+
   if (NS_KEYLOG)
     NSLog (@"doCommandBySelector: %@", NSStringFromSelector (aSelector));
 
@@ -6003,7 +6037,7 @@ not_in_argv (NSString *arg)
   struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (emacsframe);
   NSPoint p = [self convertPoint: [theEvent locationInWindow] fromView: nil];
 
-  NSTRACE ("mouseDown");
+  NSTRACE ("[EmacsView mouseDown:]");
 
   [self deleteWorkingText];
 
@@ -6024,7 +6058,7 @@ not_in_argv (NSString *arg)
           delta = [theEvent deltaX];
           if (delta == 0)
             {
-              NSTRACE ("deltaIsZero");
+              NSTRACE_MSG ("deltaIsZero");
               return;
             }
           emacs_event->kind = HORIZ_WHEEL_EVENT;
@@ -6051,42 +6085,42 @@ not_in_argv (NSString *arg)
 
 - (void)rightMouseDown: (NSEvent *)theEvent
 {
-  NSTRACE ("rightMouseDown");
+  NSTRACE ("[EmacsView rightMouseDown:]");
   [self mouseDown: theEvent];
 }
 
 
 - (void)otherMouseDown: (NSEvent *)theEvent
 {
-  NSTRACE ("otherMouseDown");
+  NSTRACE ("[EmacsView otherMouseDown:]");
   [self mouseDown: theEvent];
 }
 
 
 - (void)mouseUp: (NSEvent *)theEvent
 {
-  NSTRACE ("mouseUp");
+  NSTRACE ("[EmacsView mouseUp:]");
   [self mouseDown: theEvent];
 }
 
 
 - (void)rightMouseUp: (NSEvent *)theEvent
 {
-  NSTRACE ("rightMouseUp");
+  NSTRACE ("[EmacsView rightMouseUp:]");
   [self mouseDown: theEvent];
 }
 
 
 - (void)otherMouseUp: (NSEvent *)theEvent
 {
-  NSTRACE ("otherMouseUp");
+  NSTRACE ("[EmacsView otherMouseUp:]");
   [self mouseDown: theEvent];
 }
 
 
 - (void) scrollWheel: (NSEvent *)theEvent
 {
-  NSTRACE ("scrollWheel");
+  NSTRACE ("[EmacsView scrollWheel:]");
   [self mouseDown: theEvent];
 }
 
@@ -6099,7 +6133,7 @@ not_in_argv (NSString *arg)
   Lisp_Object frame;
   NSPoint pt;
 
-//  NSTRACE ("mouseMoved");
+  NSTRACE_WHEN (NSTRACE_GROUP_EVENTS, "[EmacsView mouseMoved:]");
 
   dpyinfo->last_mouse_movement_time = EV_TIMESTAMP (e);
   pt = [self convertPoint: [e locationInWindow] fromView: nil];
@@ -6119,7 +6153,7 @@ not_in_argv (NSString *arg)
 
   if (!NILP (Vmouse_autoselect_window))
     {
-      NSTRACE ("mouse_autoselect_window");
+      NSTRACE_MSG ("mouse_autoselect_window");
       static Lisp_Object last_mouse_window;
       Lisp_Object window
        = window_from_coordinates (emacsframe, pt.x, pt.y, 0, 0);
@@ -6131,7 +6165,7 @@ not_in_argv (NSString *arg)
               || (EQ (XWINDOW (window)->frame,
                       XWINDOW (selected_window)->frame))))
         {
-          NSTRACE ("in_window");
+          NSTRACE_MSG ("in_window");
           emacs_event->kind = SELECT_WINDOW_EVENT;
           emacs_event->frame_or_window = window;
           EV_TRAILER2 (e);
@@ -6161,21 +6195,21 @@ not_in_argv (NSString *arg)
 
 - (void)mouseDragged: (NSEvent *)e
 {
-  NSTRACE ("mouseDragged");
+  NSTRACE ("[EmacsView mouseDragged:]");
   [self mouseMoved: e];
 }
 
 
 - (void)rightMouseDragged: (NSEvent *)e
 {
-  NSTRACE ("rightMouseDragged");
+  NSTRACE ("[EmacsView rightMouseDragged:]");
   [self mouseMoved: e];
 }
 
 
 - (void)otherMouseDragged: (NSEvent *)e
 {
-  NSTRACE ("otherMouseDragged");
+  NSTRACE ("[EmacsView otherMouseDragged:]");
   [self mouseMoved: e];
 }
 
@@ -6184,7 +6218,7 @@ not_in_argv (NSString *arg)
 {
   NSEvent *e =[[self window] currentEvent];
 
-  NSTRACE ("windowShouldClose");
+  NSTRACE ("[EmacsView windowShouldClose:]");
   windowClosing = YES;
   if (!emacs_event)
     return NO;
@@ -6206,7 +6240,7 @@ not_in_argv (NSString *arg)
   int oldh = FRAME_PIXEL_HEIGHT (emacsframe);
   int neww, newh;
 
-  NSTRACE ("updateFrameSize");
+  NSTRACE ("[EmacsView updateFrameSize:]");
   NSTRACE_SIZE ("Original size", NSMakeSize (oldw, oldh));
   NSTRACE_RECT ("Original frame", wr);
   NSTRACE_MSG  ("Original columns: %d", cols);
@@ -6249,8 +6283,8 @@ not_in_argv (NSString *arg)
   if (rows < MINHEIGHT)
     rows = MINHEIGHT;
 
-  NSTRACE_MSG  ("New columns: %d", cols);
-  NSTRACE_MSG  ("New rows: %d", rows);
+  NSTRACE_MSG ("New columns: %d", cols);
+  NSTRACE_MSG ("New rows: %d", rows);
 
   if (oldr != rows || oldc != cols || neww != oldw || newh != oldh)
     {
@@ -6265,8 +6299,9 @@ not_in_argv (NSString *arg)
       cancel_mouse_face (emacsframe);
 
       wr = NSMakeRect (0, 0, neww, newh);
-      NSTRACE_RECT ("setFrame", wr);
+
       [view setFrame: wr];
+
       // to do: consider using [NSNotificationCenter postNotificationName:].
       [self windowDidMove: // Update top/left.
              [NSNotification notificationWithName:NSWindowDidMoveNotification
@@ -6283,7 +6318,7 @@ not_in_argv (NSString *arg)
 {
   int extra = 0;
 
-  NSTRACE ("windowWillResize: toSize: " NSTRACE_FMT_SIZE,
+  NSTRACE ("[EmacsView windowWillResize:toSize: " NSTRACE_FMT_SIZE "]",
            NSTRACE_ARG_SIZE (frameSize));
   NSTRACE_RECT   ("[sender frame]", [sender frame]);
   NSTRACE_FSTYPE ("fs_state", fs_state);
@@ -6382,7 +6417,7 @@ not_in_argv (NSString *arg)
 
 - (void)windowDidResize: (NSNotification *)notification
 {
-  NSTRACE ("windowDidResize");
+  NSTRACE ("[EmacsView windowDidResize:]");
   if (!FRAME_LIVE_P (emacsframe))
     {
       NSTRACE_MSG ("Ignored (frame dead)");
@@ -6425,6 +6460,8 @@ not_in_argv (NSString *arg)
 #ifdef NS_IMPL_COCOA
 - (void)viewDidEndLiveResize
 {
+  NSTRACE ("[EmacsView viewDidEndLiveResize]");
+
   [super viewDidEndLiveResize];
   if (old_title != 0)
     {
@@ -6449,7 +6486,7 @@ not_in_argv (NSString *arg)
   struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (emacsframe);
   struct frame *old_focus = dpyinfo->x_focus_frame;
 
-  NSTRACE ("windowDidBecomeKey");
+  NSTRACE ("[EmacsView windowDidBecomeKey]");
 
   if (emacsframe != old_focus)
     dpyinfo->x_focus_frame = emacsframe;
@@ -6469,7 +6506,7 @@ not_in_argv (NSString *arg)
 {
   struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (emacsframe);
   BOOL is_focus_frame = dpyinfo->x_focus_frame == emacsframe;
-  NSTRACE ("windowDidResignKey");
+  NSTRACE ("[EmacsView windowDidResignKey:]");
 
   if (is_focus_frame)
     dpyinfo->x_focus_frame = 0;
@@ -6504,7 +6541,16 @@ not_in_argv (NSString *arg)
 
 - (void)windowWillMiniaturize: sender
 {
-  NSTRACE ("windowWillMiniaturize");
+  NSTRACE ("[EmacsView windowWillMiniaturize:]");
+}
+
+
+- (void)setFrame:(NSRect)frameRect;
+{
+  NSTRACE ("[EmacsView setFrame:" NSTRACE_FMT_RECT "]",
+           NSTRACE_ARG_RECT (frameRect));
+
+  [super setFrame:(NSRect)frameRect];
 }
 
 
@@ -6528,7 +6574,8 @@ not_in_argv (NSString *arg)
   NSColor *col;
   NSString *name;
 
-  NSTRACE ("initFrameFromEmacs");
+  NSTRACE ("[EmacsView initFrameFromEmacs:]");
+  NSTRACE_MSG ("cols:%d lines:%d\n", f->text_cols, f->text_lines);
 
   windowClosing = NO;
   processingCompose = NO;
@@ -6543,8 +6590,6 @@ not_in_argv (NSString *arg)
   maximized_width = maximized_height = -1;
   nonfs_window = nil;
 
-/*fprintf (stderr,"init with %d, %d\n",f->text_cols, f->text_lines); */
-
   ns_userRect = NSMakeRect (0, 0, 0, 0);
   r = NSMakeRect (0, 0, FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, f->text_cols),
                  FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, f->text_lines));
@@ -6632,8 +6677,6 @@ not_in_argv (NSString *arg)
            IN_BOUND (-SCREENMAX,
                      [screen frame].size.height - NS_TOP_POS (f), SCREENMAX));
 
-        NSTRACE_POINT ("setFrameTopLeftPoint", pt);
-
         [win setFrameTopLeftPoint: pt];
 
         NSTRACE_RECT ("new frame", [win frame]);
@@ -6667,7 +6710,7 @@ not_in_argv (NSString *arg)
   NSArray *screens = [NSScreen screens];
   NSScreen *screen = [screens objectAtIndex: 0];
 
-  NSTRACE ("windowDidMove");
+  NSTRACE ("[EmacsView windowDidMove:]");
 
   if (!emacsframe->output_data.ns)
     return;
@@ -6685,7 +6728,7 @@ not_in_argv (NSString *arg)
    location so set_window_size moves the frame. */
 - (BOOL)windowShouldZoom: (NSWindow *)sender toFrame: (NSRect)newFrame
 {
-  NSTRACE (("[windowShouldZoom:win toFrame:" NSTRACE_FMT_RECT "]"
+  NSTRACE (("[EmacsView windowShouldZoom:toFrame:" NSTRACE_FMT_RECT "]"
             NSTRACE_FMT_RETURN "YES"),
            NSTRACE_ARG_RECT (newFrame));
 
@@ -6704,7 +6747,7 @@ not_in_argv (NSString *arg)
   // all paths.
   NSRect result = [sender frame];
 
-  NSTRACE (("[windowWillUseStandardFrame: defaultFrame:"
+  NSTRACE (("[EmacsView windowWillUseStandardFrame:defaultFrame:"
             NSTRACE_FMT_RECT "]"),
            NSTRACE_ARG_RECT (defaultFrame));
   NSTRACE_FSTYPE ("fs_state", fs_state);
@@ -6817,7 +6860,7 @@ not_in_argv (NSString *arg)
 
 - (void)windowDidDeminiaturize: sender
 {
-  NSTRACE ("windowDidDeminiaturize");
+  NSTRACE ("[EmacsView windowDidDeminiaturize:]");
   if (!emacsframe->output_data.ns)
     return;
 
@@ -6835,7 +6878,7 @@ not_in_argv (NSString *arg)
 
 - (void)windowDidExpose: sender
 {
-  NSTRACE ("windowDidExpose");
+  NSTRACE ("[EmacsView windowDidExpose:]");
   if (!emacsframe->output_data.ns)
     return;
 
@@ -6849,7 +6892,7 @@ not_in_argv (NSString *arg)
 
 - (void)windowDidMiniaturize: sender
 {
-  NSTRACE ("windowDidMiniaturize");
+  NSTRACE ("[EmacsView windowDidMiniaturize:]");
   if (!emacsframe->output_data.ns)
     return;
 
@@ -6874,22 +6917,24 @@ not_in_argv (NSString *arg)
 
 - (void)windowWillEnterFullScreen:(NSNotification *)notification
 {
+  NSTRACE ("[EmacsView windowWillEnterFullScreen:]");
   [self windowWillEnterFullScreen];
 }
 - (void)windowWillEnterFullScreen /* provided for direct calls */
 {
-  NSTRACE ("windowWillEnterFullScreen");
+  NSTRACE ("[EmacsView windowWillEnterFullScreen]");
   fs_before_fs = fs_state;
 }
 
 - (void)windowDidEnterFullScreen:(NSNotification *)notification
 {
+  NSTRACE ("[EmacsView windowDidEnterFullScreen:]");
   [self windowDidEnterFullScreen];
 }
 
 - (void)windowDidEnterFullScreen /* provided for direct calls */
 {
-  NSTRACE ("windowDidEnterFullScreen");
+  NSTRACE ("[EmacsView windowDidEnterFullScreen]");
   [self setFSValue: FULLSCREEN_BOTH];
   if (! [self fsIsNative])
     {
@@ -6923,12 +6968,13 @@ not_in_argv (NSString *arg)
 
 - (void)windowWillExitFullScreen:(NSNotification *)notification
 {
+  NSTRACE ("[EmacsView windowWillExitFullScreen:]");
   [self windowWillExitFullScreen];
 }
 
 - (void)windowWillExitFullScreen /* provided for direct calls */
 {
-  NSTRACE ("windowWillExitFullScreen");
+  NSTRACE ("[EmacsView windowWillExitFullScreen]");
   if (!FRAME_LIVE_P (emacsframe))
     {
       NSTRACE_MSG ("Ignored (frame dead)");
@@ -6940,12 +6986,13 @@ not_in_argv (NSString *arg)
 
 - (void)windowDidExitFullScreen:(NSNotification *)notification
 {
+  NSTRACE ("[EmacsView windowDidExitFullScreen:]");
   [self windowDidExitFullScreen];
 }
 
 - (void)windowDidExitFullScreen /* provided for direct calls */
 {
-  NSTRACE ("windowDidExitFullScreen");
+  NSTRACE ("[EamcsView windowDidExitFullScreen]");
   if (!FRAME_LIVE_P (emacsframe))
     {
       NSTRACE_MSG ("Ignored (frame dead)");
@@ -6977,6 +7024,8 @@ not_in_argv (NSString *arg)
 
 - (BOOL)isFullscreen
 {
+  NSTRACE ("[EmacsView isFullscreen]");
+
   if (! fs_is_native) return nonfs_window != nil;
 #ifdef HAVE_NATIVE_FS
   return ([[self window] styleMask] & NSFullScreenWindowMask) != 0;
@@ -6988,6 +7037,8 @@ not_in_argv (NSString *arg)
 #ifdef HAVE_NATIVE_FS
 - (void)updateCollectionBehavior
 {
+  NSTRACE ("[EmacsView updateCollectionBehavior]");
+
   if (! [self isFullscreen])
     {
       NSWindow *win = [self window];
@@ -7011,7 +7062,7 @@ not_in_argv (NSString *arg)
   NSRect r, wr;
   NSColor *col;
 
-  NSTRACE ("toggleFullScreen");
+  NSTRACE ("[EmacsView toggleFullScreen:]");
 
   if (fs_is_native)
     {
@@ -7126,7 +7177,7 @@ not_in_argv (NSString *arg)
 
 - (void)handleFS
 {
-  NSTRACE ("handleFS");
+  NSTRACE ("[EmacsView handleFS]");
 
   if (fs_state != emacsframe->want_fullscreen)
     {
@@ -7177,8 +7228,8 @@ not_in_argv (NSString *arg)
 
 - (void) setFSValue: (int)value
 {
-  NSTRACE ("setFSValue");
-  NSTRACE_FSTYPE ("value", value);
+  NSTRACE ("[EmacsView setFSValue:" NSTRACE_FMT_FSTYPE "]",
+           NSTRACE_ARG_FSTYPE(value));
 
   Lisp_Object lval = Qnil;
   switch (value)
@@ -7202,7 +7253,7 @@ not_in_argv (NSString *arg)
 
 - (void)mouseEntered: (NSEvent *)theEvent
 {
-  NSTRACE ("mouseEntered");
+  NSTRACE ("[EmacsView mouseEntered:]");
   if (emacsframe)
     FRAME_DISPLAY_INFO (emacsframe)->last_mouse_movement_time
       = EV_TIMESTAMP (theEvent);
@@ -7213,7 +7264,7 @@ not_in_argv (NSString *arg)
 {
   Mouse_HLInfo *hlinfo = emacsframe ? MOUSE_HL_INFO (emacsframe) : NULL;
 
-  NSTRACE ("mouseExited");
+  NSTRACE ("[EmacsView mouseExited:]");
 
   if (!hlinfo)
     return;
@@ -7231,7 +7282,7 @@ not_in_argv (NSString *arg)
 
 - menuDown: sender
 {
-  NSTRACE ("menuDown");
+  NSTRACE ("[EmacsView menuDown:]");
   if (context_menu_value == -1)
     context_menu_value = [sender tag];
   else
@@ -7259,7 +7310,7 @@ not_in_argv (NSString *arg)
   NSEvent *theEvent;
   int idx = [item tag] * TOOL_BAR_ITEM_NSLOTS;
 
-  NSTRACE ("toolbarClicked");
+  NSTRACE ("[EmacsView toolbarClicked:]");
 
   if (!emacs_event)
     return self;
@@ -7282,6 +7333,8 @@ not_in_argv (NSString *arg)
 
 - toggleToolbar: (id)sender
 {
+  NSTRACE ("[EmacsView toggleToolbar:]");
+
   if (!emacs_event)
     return self;
 
@@ -7297,8 +7350,8 @@ not_in_argv (NSString *arg)
   int x = NSMinX (rect), y = NSMinY (rect);
   int width = NSWidth (rect), height = NSHeight (rect);
 
-  NSTRACE ("drawRect");
-  NSTRACE_RECT ("input", rect);
+  NSTRACE ("[EmacsView drawRect:" NSTRACE_FMT_RECT "]",
+           NSTRACE_ARG_RECT(rect));
 
   if (!emacsframe || !emacsframe->output_data.ns)
     return;
@@ -7324,7 +7377,7 @@ not_in_argv (NSString *arg)
 
 -(NSDragOperation) draggingEntered: (id <NSDraggingInfo>) sender
 {
-  NSTRACE ("draggingEntered");
+  NSTRACE ("[EmacsView draggingEntered:]");
   return NSDragOperationGeneric;
 }
 
@@ -7345,7 +7398,7 @@ not_in_argv (NSString *arg)
   NSDragOperation op = [sender draggingSourceOperationMask];
   int modifiers = 0;
 
-  NSTRACE ("performDragOperation");
+  NSTRACE ("[EmacsView performDragOperation:]");
 
   if (!emacs_event)
     return NO;
@@ -7445,7 +7498,7 @@ not_in_argv (NSString *arg)
 - (id) validRequestorForSendType: (NSString *)typeSent
                       returnType: (NSString *)typeReturned
 {
-  NSTRACE ("validRequestorForSendType");
+  NSTRACE ("[EmacsView validRequestorForSendType:returnType:]");
   if (typeSent != nil && [ns_send_types indexOfObject: typeSent] != NSNotFound
       && typeReturned == nil)
     {
@@ -7478,6 +7531,8 @@ not_in_argv (NSString *arg)
   NSArray *typesDeclared;
   Lisp_Object val;
 
+  NSTRACE ("[EmacsView writeSelectionToPasteboard:types:]");
+
   /* We only support NSStringPboardType */
   if ([types containsObject:NSStringPboardType] == NO) {
     return NO;
@@ -7507,7 +7562,7 @@ not_in_argv (NSString *arg)
 - setMiniwindowImage: (BOOL) setMini
 {
   id image = [[self window] miniwindowImage];
-  NSTRACE ("setMiniwindowImage");
+  NSTRACE ("[EmacsView setMiniwindowImage:%d]", setMini);
 
   /* NOTE: under Cocoa miniwindowImage always returns nil, documentation
      about "AppleDockIconEnabled" notwithstanding, however the set message
@@ -7555,6 +7610,8 @@ not_in_argv (NSString *arg)
   struct frame *f = SELECTED_FRAME ();
   struct buffer *curbuf = XBUFFER (XWINDOW (f->selected_window)->contents);
 
+  NSTRACE ("[EmacsWindow accessibilityAttributeValue:]");
+
   if ([attribute isEqualToString:NSAccessibilityRoleAttribute])
     return NSAccessibilityTextFieldRole;
 
@@ -7623,7 +7680,7 @@ not_in_argv (NSString *arg)
    large screen). */
 - (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen
 {
-  NSTRACE ("constrainFrameRect:" NSTRACE_FMT_RECT " toScreen:",
+  NSTRACE ("[EmacsWindow constrainFrameRect:" NSTRACE_FMT_RECT " toScreen:]",
              NSTRACE_ARG_RECT (frameRect));
 
 #ifdef NS_IMPL_COCOA
@@ -7646,7 +7703,7 @@ not_in_argv (NSString *arg)
 
 - (void)performZoom:(id)sender
 {
-  NSTRACE ("performZoom");
+  NSTRACE ("[EmacsWindow performZoom:]");
 
   return [super performZoom:sender];
 }
@@ -7655,7 +7712,7 @@ not_in_argv (NSString *arg)
 {
   struct frame * f = SELECTED_FRAME ();
 
-  NSTRACE ("zoom");
+  NSTRACE ("[EmacsWindow zoom:]");
 
   ns_update_auto_hide_menu_bar();
 
@@ -7714,7 +7771,7 @@ not_in_argv (NSString *arg)
           || newWr.origin.x    != wr.origin.x
           || newWr.origin.y    != wr.origin.y)
         {
-          NSTRACE_RECT ("Corrected rect", newWr);
+          NSTRACE_MSG ("New frame different");
           [self setFrame: newWr display: NO];
         }
     }
@@ -7734,6 +7791,33 @@ not_in_argv (NSString *arg)
 #endif
 }
 
+- (void)setFrame:(NSRect)windowFrame
+         display:(BOOL)displayViews
+{
+  NSTRACE ("[EmacsWindow setFrame:" NSTRACE_FMT_RECT " display:%d]",
+           NSTRACE_ARG_RECT (windowFrame), displayViews);
+
+  [super setFrame:windowFrame display:displayViews];
+}
+
+- (void)setFrame:(NSRect)windowFrame
+         display:(BOOL)displayViews
+         animate:(BOOL)performAnimation
+{
+  NSTRACE ("[EmacsWindow setFrame:" NSTRACE_FMT_RECT
+           " display:%d performAnimation:%d]",
+           NSTRACE_ARG_RECT (windowFrame), displayViews, performAnimation);
+
+  [super setFrame:windowFrame display:displayViews animate:performAnimation];
+}
+
+- (void)setFrameTopLeftPoint:(NSPoint)point
+{
+  NSTRACE ("[EmacsWindow setFrameTopLeftPoint:" NSTRACE_FMT_POINT "]",
+           NSTRACE_ARG_POINT (point));
+
+  [super setFrameTopLeftPoint:point];
+}
 @end /* EmacsWindow */
 
 
@@ -7782,7 +7866,7 @@ not_in_argv (NSString *arg)
 
 - initFrame: (NSRect )r window: (Lisp_Object)nwin
 {
-  NSTRACE ("EmacsScroller_initFrame");
+  NSTRACE ("[EmacsScroller initFrame: window:]");
 
   r.size.width = [EmacsScroller scrollerWidth];
   [super initWithFrame: r/*NSMakeRect (0, 0, 0, 0)*/];
@@ -7828,7 +7912,8 @@ not_in_argv (NSString *arg)
 
 - (void)setFrame: (NSRect)newRect
 {
-  NSTRACE ("EmacsScroller_setFrame");
+  NSTRACE ("[EmacsScroller setFrame:]");
+
 /*  block_input (); */
   pixel_height = NSHeight (newRect);
   if (pixel_height == 0) pixel_height = 1;
@@ -7840,7 +7925,7 @@ not_in_argv (NSString *arg)
 
 - (void)dealloc
 {
-  NSTRACE ("EmacsScroller_dealloc");
+  NSTRACE ("[EmacsScroller dealloc]");
   if (window)
     wset_vertical_scroll_bar (window, Qnil);
   window = 0;
@@ -7850,7 +7935,7 @@ not_in_argv (NSString *arg)
 
 - condemn
 {
-  NSTRACE ("condemn");
+  NSTRACE ("[EmacsScroller condemn]");
   condemned =YES;
   return self;
 }
@@ -7858,7 +7943,7 @@ not_in_argv (NSString *arg)
 
 - reprieve
 {
-  NSTRACE ("reprieve");
+  NSTRACE ("[EmacsScroller reprieve]");
   condemned =NO;
   return self;
 }
@@ -7866,7 +7951,7 @@ not_in_argv (NSString *arg)
 
 -(bool)judge
 {
-  NSTRACE ("judge");
+  NSTRACE ("[EmacsScroller judge]");
   bool ret = condemned;
   if (condemned)
     {
@@ -7890,7 +7975,7 @@ not_in_argv (NSString *arg)
 - (void)resetCursorRects
 {
   NSRect visible = [self visibleRect];
-  NSTRACE ("resetCursorRects");
+  NSTRACE ("[EmacsScroller resetCursorRects]");
 
   if (!NSIsEmptyRect (visible))
     [self addCursorRect: visible cursor: [NSCursor arrowCursor]];
@@ -7908,7 +7993,7 @@ not_in_argv (NSString *arg)
 
 - setPosition: (int)position portion: (int)portion whole: (int)whole
 {
-  NSTRACE ("setPosition");
+  NSTRACE ("[EmacsScroller setPosition:portion:whole:]");
 
   em_position = position;
   em_portion = portion;
@@ -7945,6 +8030,9 @@ not_in_argv (NSString *arg)
 - (void) sendScrollEventAtLoc: (float)loc fromEvent: (NSEvent *)e
 {
   Lisp_Object win;
+
+  NSTRACE ("[EmacsScroller sendScrollEventAtLoc:fromEvent:]");
+
   if (!emacs_event)
     return;
 
@@ -7978,6 +8066,8 @@ not_in_argv (NSString *arg)
   NSPoint p =  [[self window] mouseLocationOutsideOfEventStream];
   BOOL inKnob = [self testPart: p] == NSScrollerKnob;
 
+  NSTRACE ("[EmacsScroller repeatScroll:]");
+
   /* clear timer if need be */
   if (inKnob || [scroll_repeat_entry timeInterval] == SCROLL_BAR_FIRST_DELAY)
     {
@@ -8013,7 +8103,7 @@ not_in_argv (NSString *arg)
   CGFloat inc = 0.0, loc, kloc, pos;
   int edge = 0;
 
-  NSTRACE ("EmacsScroller_mouseDown");
+  NSTRACE ("[EmacsScroller mouseDown:]");
 
   switch (part)
     {
@@ -8110,7 +8200,7 @@ not_in_argv (NSString *arg)
     NSRect sr;
     double loc, pos;
 
-    NSTRACE ("EmacsScroller_mouseDragged");
+    NSTRACE ("[EmacsScroller mouseDragged:]");
 
       sr = [self convertRect: [self rectForPart: NSScrollerKnobSlot]
                       toView: nil];
@@ -8132,6 +8222,8 @@ not_in_argv (NSString *arg)
 
 - (void)mouseUp: (NSEvent *)e
 {
+  NSTRACE ("[EmacsScroller mouseUp:]");
+
   if (scroll_repeat_entry)
     {
       [scroll_repeat_entry invalidate];
@@ -8145,6 +8237,8 @@ not_in_argv (NSString *arg)
 /* treat scrollwheel events in the bar as though they were in the main window 
*/
 - (void) scrollWheel: (NSEvent *)theEvent
 {
+  NSTRACE ("[EmacsScroller scrollWheel:]");
+
   EmacsView *view = (EmacsView *)FRAME_NS_VIEW (frame);
   [view mouseDown: theEvent];
 }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]