emacs-diffs
[Top][All Lists]
Advanced

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

scratch/igc a884b7cdd17: Remove special code to handle NS EmacsScroller


From: Gerd Moellmann
Subject: scratch/igc a884b7cdd17: Remove special code to handle NS EmacsScroller
Date: Thu, 18 Jul 2024 03:01:18 -0400 (EDT)

branch: scratch/igc
commit a884b7cdd1723c308baf6e52ac7424e5dbc98fb8
Author: Gerd Möllmann <gerd@gnu.org>
Commit: Gerd Möllmann <gerd@gnu.org>

    Remove special code to handle NS EmacsScroller
---
 src/igc.c    |  7 ------
 src/nsterm.h | 33 +++++++++++++------------
 src/nsterm.m | 78 +++++++++++++++++++++++++++++-------------------------------
 3 files changed, 54 insertions(+), 64 deletions(-)

diff --git a/src/igc.c b/src/igc.c
index dae1caeb60b..1498a07f331 100644
--- a/src/igc.c
+++ b/src/igc.c
@@ -2009,13 +2009,6 @@ fix_window (mps_ss_t ss, struct window *w)
       IGC_FIX_CALL (ss, fix_glyph_matrix (ss, w->desired_matrix));
     IGC_FIX12_OBJ (ss, &w->prev_buffers);
     IGC_FIX12_OBJ (ss, &w->next_buffers);
-
-#ifdef HAVE_NS
-    void *pr[4];
-    int n = ns_emacs_scroller_refs (w, pr, ARRAYELTS (pr));
-    for (int i = 0; i < n; ++i)
-      IGC_FIX12_RAW (ss, pr[i]);
-#endif
   }
   MPS_SCAN_END (ss);
   return MPS_RES_OK;
diff --git a/src/nsterm.h b/src/nsterm.h
index b9ed9f8eb8d..99dbb9c2ec5 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -704,27 +704,27 @@ enum ns_return_frame_mode
 
 @interface EmacsScroller : NSScroller
 {
-   NSResponder *prevResponder;
+  NSResponder *prevResponder;
 
-   /* offset to the bottom of knob of last mouse down */
-   CGFloat last_mouse_offset;
-   float min_portion;
-   int pixel_length;
-   enum scroll_bar_part last_hit_part;
+  /* offset to the bottom of knob of last mouse down */
+  CGFloat last_mouse_offset;
+  float min_portion;
+  int pixel_length;
+  enum scroll_bar_part last_hit_part;
 
-   BOOL condemned;
+  BOOL condemned;
 
-   BOOL horizontal;
+  BOOL horizontal;
 
-   /* optimize against excessive positioning calls generated by emacs */
-   int em_position;
-   int em_portion;
-   int em_whole;
-  @public
-   struct window *window;
-   struct frame *frame;
-   }
+  /* optimize against excessive positioning calls generated by emacs */
+  int em_position;
+  int em_portion;
+  int em_whole;
+  struct window **m_lisp_window;
+}
 
+- (struct window *) lispWindow;
+- (struct frame *) lispFrame;
 - (void) mark;
 - (instancetype) initFrame: (NSRect )r window: (Lisp_Object)win;
 - (void)setFrame: (NSRect)r;
@@ -1399,6 +1399,5 @@ enum NSWindowTabbingMode
 #endif
 
 extern void mark_nsterm (void);
-int ns_emacs_scroller_refs (struct window *w, void **refs, size_t n);
 
 #endif /* HAVE_NS */
diff --git a/src/nsterm.m b/src/nsterm.m
index 4c15876acfc..c6313dbc2d8 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -8483,7 +8483,7 @@ ns_in_echo_area (void)
   BOOL onFirstScreen;
   struct frame *f;
   NSRect r;
-  NSColor *col;
+   NSColor *col;
 
   NSTRACE ("[EmacsView toggleFullScreen:]");
 
@@ -10076,9 +10076,24 @@ nswindow_orderedIndex_sort (id w1, id w2, void *c)
   return r;
 }
 
+- (struct window *)lispWindow
+{
+  return *m_lisp_window;
+}
+
+- (struct frame *)lispFrame
+{
+  return XFRAME ((*m_lisp_window)->frame);
+}
+
 - (instancetype)initFrame: (NSRect )r window: (Lisp_Object)nwin
 {
   NSTRACE ("[EmacsScroller initFrame: window:]");
+#ifdef HAVE_MPS
+  m_lisp_window = igc_xalloc_raw_exact (1);
+#else
+  m_lisp_window = xzalloc (sizeof *m_lisp_window);
+#endif
 
   if (r.size.width > r.size.height)
       horizontal = YES;
@@ -10098,7 +10113,7 @@ nswindow_orderedIndex_sort (id w1, id w2, void *c)
   [self setAutoresizingMask: NSViewMinXMargin | NSViewHeightSizable];
 #endif
 
-  window = XWINDOW (nwin);
+  *m_lisp_window = XWINDOW (nwin);
   condemned = NO;
   if (horizontal)
     pixel_length = NSWidth (r);
@@ -10107,11 +10122,11 @@ nswindow_orderedIndex_sort (id w1, id w2, void *c)
   if (pixel_length == 0) pixel_length = 1;
   min_portion = 20 / pixel_length;
 
-  frame = XFRAME (window->frame);
-  if (FRAME_LIVE_P (frame))
+  struct frame *f = [self lispFrame];
+  if (FRAME_LIVE_P (f))
     {
       int i;
-      EmacsView *view = FRAME_NS_VIEW (frame);
+      EmacsView *view = FRAME_NS_VIEW (f);
       NSView *sview = [[view window] contentView];
       NSArray *subs = [sview subviews];
 
@@ -10148,14 +10163,20 @@ nswindow_orderedIndex_sort (id w1, id w2, void *c)
 - (void)dealloc
 {
   NSTRACE ("[EmacsScroller dealloc]");
-  if (window)
+  struct window *w = [self lispWindow];
+  if (w)
     {
       if (horizontal)
-        wset_horizontal_scroll_bar (window, Qnil);
+        wset_horizontal_scroll_bar (w, Qnil);
       else
-        wset_vertical_scroll_bar (window, Qnil);
+        wset_vertical_scroll_bar (w, Qnil);
     }
-  window = 0;
+  *m_lisp_window = NULL;
+#ifdef HAVE_MPS
+  igc_xfree (m_lisp_window);
+#else
+  xfree (m_lisp_window);
+#endif
   [super dealloc];
 }
 
@@ -10185,17 +10206,18 @@ nswindow_orderedIndex_sort (id w1, id w2, void *c)
       EmacsView *view;
       block_input ();
       /* Ensure other scrollbar updates after deletion.  */
-      view = (EmacsView *)FRAME_NS_VIEW (frame);
+      struct frame *f = [self lispFrame];
+      view = (EmacsView *)FRAME_NS_VIEW (f);
       if (view != nil)
         view->scrollbarsNeedingUpdate++;
-      if (window)
+      if (*m_lisp_window)
         {
           if (horizontal)
-            wset_horizontal_scroll_bar (window, Qnil);
+            wset_horizontal_scroll_bar (*m_lisp_window, Qnil);
           else
-            wset_vertical_scroll_bar (window, Qnil);
+            wset_vertical_scroll_bar (*m_lisp_window, Qnil);
         }
-      window = 0;
+      *m_lisp_window = NULL;
       [self removeFromSuperview];
       [self release];
       unblock_input ();
@@ -10290,7 +10312,7 @@ nswindow_orderedIndex_sort (id w1, id w2, void *c)
   emacs_event->part = last_hit_part;
   emacs_event->code = 0;
   emacs_event->modifiers = EV_MODIFIERS (e) | down_modifier;
-  XSETWINDOW (win, window);
+  XSETWINDOW (win, m_lisp_window);
   emacs_event->frame_or_window = win;
   emacs_event->timestamp = EV_TIMESTAMP (e);
   emacs_event->arg = Qnil;
@@ -10541,7 +10563,7 @@ nswindow_orderedIndex_sort (id w1, id w2, void *c)
 {
   NSTRACE ("[EmacsScroller scrollWheel:]");
 
-  EmacsView *view = (EmacsView *)FRAME_NS_VIEW (frame);
+  EmacsView *view = (EmacsView *)FRAME_NS_VIEW ([self lispFrame]);
   [view mouseDown: theEvent];
 }
 
@@ -11221,27 +11243,3 @@ respectively.  */);
   last_known_monitors = Qnil;
   staticpro (&last_known_monitors);
 }
-
-int
-ns_emacs_scroller_refs (struct window *w, void **refs, size_t n)
-{
-  eassert (n >= 4);
-  int i = 0;
-  if (!NILP (w->vertical_scroll_bar)
-      && WINDOW_HAS_VERTICAL_SCROLL_BAR (w))
-    {
-      EmacsScroller *bar = XNS_SCROLL_BAR (w->vertical_scroll_bar);
-      refs[i++] = &bar->window;
-      refs[i++] = &bar->frame;
-    }
-
-  if (!NILP (w->horizontal_scroll_bar)
-      && WINDOW_HAS_HORIZONTAL_SCROLL_BAR (w))
-    {
-      EmacsScroller *bar = XNS_SCROLL_BAR (w->horizontal_scroll_bar);
-      refs[i++] = &bar->window;
-      refs[i++] = &bar->frame;
-    }
-
-  return i;
-}



reply via email to

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