all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alex Gramiak <agrambot@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: [PATCH] Remove display member of glyph_string
Date: Thu, 09 May 2019 11:16:06 -0600	[thread overview]
Message-ID: <87sgtnczvt.fsf@gmail.com> (raw)
In-Reply-To: <834l63h87x.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 09 May 2019 20:02:26 +0300")

[-- Attachment #1: Type: text/plain, Size: 968 bytes --]

Eli Zaretskii <eliz@gnu.org> writes:

>> * src/msdos.h:
>> * src/nsgui.h:
>> * src/nsterm.h:
>> * src/w32term.h: Remove unused X-compatibility macros and typedefs.
>
> Please mention the macros and typedefs being removed explicitly, it is
> important for later forensics.

Okay, I've attached a reworded patch.

>>  src/image.c     | 24 ++----------------------
>>  src/msdos.h     |  1 -
>>  src/nsgui.h     |  1 -
>>  src/nsterm.h    |  6 ------
>>  src/nsterm.m    | 16 ++++++++++++++--
>>  src/termhooks.h |  8 ++++++++
>>  src/w32term.c   | 14 ++++++++++++++
>>  src/w32term.h   |  3 ---
>>  src/xterm.c     | 12 ++++++++++++
>>  9 files changed, 50 insertions(+), 35 deletions(-)
>
> There's one more instance of FRAME_X_DISPLAY in xdisp.c which was
> left, and it will fail compilation on non-X platforms.
>
> Otherwise, this LGTM, thanks.

I only see one such instance, and it's surrounded by:

 #if false && defined HAVE_X_WINDOWS

So it should be good, no?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: reworded --]
[-- Type: text/x-patch, Size: 9021 bytes --]

From c05ab038c280ba7c6041f81ceecf818ddb5bbf03 Mon Sep 17 00:00:00 2001
From: Alexander Gramiak <agrambot@gmail.com>
Date: Thu, 9 May 2019 09:37:50 -0600
Subject: [PATCH] Convert Free_Pixmap macro into terminal hook

* src/termhooks.h (terminal): New terminal hook free_pixmap.

* src/image.c: Replace Free_Pixmap with free_pixmap.

* src/msdos.h (FRAME_X_DISPLAY):
* src/nsgui.h (Display):
* src/nsterm.h (FRAME_NS_DISPLAY, FRAME_X_DISPLAY, FRAME_X_SCREEN)
(FRAME_X_VISUAL):
* src/w32term.h (FRAME_X_DISPLAY): Remove unused X-compatibility
macros and typedefs.

* src/nsterm.m:
* src/w32term.c:
* src/xterm.c: Implement and set free_pixmap hook.
---
 src/image.c     | 24 ++----------------------
 src/msdos.h     |  1 -
 src/nsgui.h     |  1 -
 src/nsterm.h    |  6 ------
 src/nsterm.m    | 16 ++++++++++++++--
 src/termhooks.h |  8 ++++++++
 src/w32term.c   | 14 ++++++++++++++
 src/w32term.h   |  3 ---
 src/xterm.c     | 12 ++++++++++++
 9 files changed, 50 insertions(+), 35 deletions(-)

diff --git a/src/image.c b/src/image.c
index e8cb434177..0779594989 100644
--- a/src/image.c
+++ b/src/image.c
@@ -1221,26 +1221,6 @@ four_corners_best (XImagePtr_or_DC ximg, int *corners,
   return best;
 }
 
-/* Portability macros */
-
-#ifdef HAVE_NTGUI
-
-#define Free_Pixmap(display, pixmap) \
-  DeleteObject (pixmap)
-
-#elif defined (HAVE_NS)
-
-#define Free_Pixmap(display, pixmap) \
-  ns_release_object (pixmap)
-
-#else
-
-#define Free_Pixmap(display, pixmap) \
-  XFreePixmap (display, pixmap)
-
-#endif /* !HAVE_NTGUI && !HAVE_NS */
-
-
 /* Return the `background' field of IMG.  If IMG doesn't have one yet,
    it is guessed heuristically.  If non-zero, XIMG is an existing
    XImage object (or device context with the image selected on W32) to
@@ -1328,7 +1308,7 @@ image_clear_image_1 (struct frame *f, struct image *img, int flags)
     {
       if (img->pixmap)
 	{
-	  Free_Pixmap (FRAME_X_DISPLAY (f), img->pixmap);
+	  FRAME_TERMINAL (f)->free_pixmap (f, img->pixmap);
 	  img->pixmap = NO_PIXMAP;
 	  /* NOTE (HAVE_NS): background color is NOT an indexed color! */
 	  img->background_valid = 0;
@@ -1347,7 +1327,7 @@ image_clear_image_1 (struct frame *f, struct image *img, int flags)
     {
       if (img->mask)
 	{
-	  Free_Pixmap (FRAME_X_DISPLAY (f), img->mask);
+	  FRAME_TERMINAL (f)->free_pixmap (f, img->mask);
 	  img->mask = NO_PIXMAP;
 	  img->background_transparent_valid = 0;
 	}
diff --git a/src/msdos.h b/src/msdos.h
index 0d15df7a33..90ceea8e3d 100644
--- a/src/msdos.h
+++ b/src/msdos.h
@@ -95,7 +95,6 @@ typedef struct tty_display_info Display_Info;
 extern struct tty_display_info the_only_display_info;
 extern struct tty_output the_only_tty_output;
 
-#define FRAME_X_DISPLAY(f) ((Display *) 0)
 #define FRAME_FONT(f) ((f)->output_data.tty->font)
 #define FRAME_DISPLAY_INFO(f) (&the_only_display_info)
 
diff --git a/src/nsgui.h b/src/nsgui.h
index c147f4dec4..ab6cdff1e5 100644
--- a/src/nsgui.h
+++ b/src/nsgui.h
@@ -115,7 +115,6 @@ typedef NSColor * Color;
 typedef void * Color;
 #endif
 typedef int Window;
-typedef int Display;
 
 
 /* Some sort of attempt to normalize rectangle handling.  Seems a bit
diff --git a/src/nsterm.h b/src/nsterm.h
index 683f2dd934..ffaf809785 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -997,12 +997,6 @@ struct x_output
 #define FRAME_NS_WINDOW(f) ((f)->output_data.ns->window_desc)
 #define FRAME_NATIVE_WINDOW(f) FRAME_NS_WINDOW (f)
 
-/* This is the `Display *' which frame F is on.  */
-#define FRAME_NS_DISPLAY(f) (0)
-#define FRAME_X_DISPLAY(f) (0)
-#define FRAME_X_SCREEN(f) (0)
-#define FRAME_X_VISUAL(f) FRAME_DISPLAY_INFO(f)->visual
-
 #define FRAME_FOREGROUND_COLOR(f) ((f)->output_data.ns->foreground_color)
 #define FRAME_BACKGROUND_COLOR(f) ((f)->output_data.ns->background_color)
 
diff --git a/src/nsterm.m b/src/nsterm.m
index ffb7b7692b..d688aceca5 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -2515,8 +2515,7 @@ so some key presses (TAB) are swallowed by the system.  */
 
   /* Clear the mouse-moved flag for every frame on this display.  */
   FOR_EACH_FRAME (tail, frame)
-    if (FRAME_NS_P (XFRAME (frame))
-        && FRAME_NS_DISPLAY (XFRAME (frame)) == FRAME_NS_DISPLAY (*fp))
+    if (FRAME_NS_P (XFRAME (frame)))
       XFRAME (frame)->mouse_moved = 0;
 
   dpyinfo->last_mouse_scroll_bar = nil;
@@ -4966,6 +4965,18 @@ in certain situations (rapid incoming events).
     [eview updateFrameSize: NO];
 }
 
+/* ==========================================================================
+
+    Image Hooks
+
+   ========================================================================== */
+
+static void
+ns_free_pixmap (struct frame *_f, Pixmap pixmap)
+{
+  ns_release_object (pixmap);
+}
+
 /* ==========================================================================
 
     Initialization
@@ -5196,6 +5207,7 @@ static Lisp_Object ns_new_font (struct frame *f, Lisp_Object font_object,
   terminal->redeem_scroll_bar_hook = ns_redeem_scroll_bar;
   terminal->judge_scroll_bars_hook = ns_judge_scroll_bars;
   terminal->get_string_resource_hook = ns_get_string_resource;
+  terminal->free_pixmap = ns_free_pixmap;
   terminal->delete_frame_hook = ns_destroy_window;
   terminal->delete_terminal_hook = ns_delete_terminal;
   /* Other hooks are NULL by default.  */
diff --git a/src/termhooks.h b/src/termhooks.h
index 54f09e0303..617df86c5c 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -741,6 +741,14 @@ struct terminal
                                             const char *name,
                                             const char *class);
 \f
+  /* Image hooks */
+
+  /* Free the pixmap PIXMAP on F.  */
+  void (*free_pixmap) (struct frame *f, Pixmap pixmap);
+
+\f
+  /* Deletion hooks */
+
   /* Called to delete the device-specific portions of a frame that is
      on this terminal device. */
   void (*delete_frame_hook) (struct frame *);
diff --git a/src/w32term.c b/src/w32term.c
index 0abec3d92a..435455e1a6 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -6869,6 +6869,7 @@ w32_wm_set_size_hint (struct frame *f, long flags, bool user_position)
   leave_crit ();
 }
 
+\f
 /***********************************************************************
 				Fonts
  ***********************************************************************/
@@ -6940,6 +6941,18 @@ w32_toggle_invisible_pointer (struct frame *f, bool invisible)
   unblock_input ();
 }
 
+\f
+/***********************************************************************
+			     Image Hooks
+ ***********************************************************************/
+
+static void
+w32_free_pixmap (struct frame *_f, Pixmap pixmap)
+{
+  DeleteObject (pixmap);
+}
+
+\f
 /***********************************************************************
 			    Initialization
  ***********************************************************************/
@@ -7119,6 +7132,7 @@ w32_create_terminal (struct w32_display_info *dpyinfo)
   terminal->redeem_scroll_bar_hook = w32_redeem_scroll_bar;
   terminal->judge_scroll_bars_hook = w32_judge_scroll_bars;
   terminal->get_string_resource_hook = w32_get_string_resource;
+  terminal->free_pixmap = w32_free_pixmap;
   terminal->delete_frame_hook = w32_destroy_window;
   terminal->delete_terminal_hook = w32_delete_terminal;
   /* Other hooks are NULL by default.  */
diff --git a/src/w32term.h b/src/w32term.h
index de372d7e5d..a03b9fd331 100644
--- a/src/w32term.h
+++ b/src/w32term.h
@@ -420,9 +420,6 @@ extern struct w32_output w32term_display;
 /* This gives the w32_display_info structure for the display F is on.  */
 #define FRAME_DISPLAY_INFO(f) ((void) (f), (&one_w32_display_info))
 
-/* This is the `Display *' which frame F is on.  */
-#define FRAME_X_DISPLAY(f) (0)
-
 #define FRAME_NORMAL_PLACEMENT(F) ((F)->output_data.w32->normal_placement)
 #define FRAME_PREV_FSMODE(F)      ((F)->output_data.w32->prev_fsmode)
 
diff --git a/src/xterm.c b/src/xterm.c
index 7bedcabe98..a7b84f46cf 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -12181,6 +12181,17 @@ x_check_font (struct frame *f, struct font *font)
 #endif /* GLYPH_DEBUG */
 
 \f
+/***********************************************************************
+                             Image Hooks
+ ***********************************************************************/
+
+static void
+x_free_pixmap (struct frame *f, Pixmap pixmap)
+{
+  XFreePixmap (FRAME_X_DISPLAY (f), pixmap);
+}
+
+\f
 /***********************************************************************
 			    Initialization
  ***********************************************************************/
@@ -13257,6 +13268,7 @@ x_create_terminal (struct x_display_info *dpyinfo)
   terminal->redeem_scroll_bar_hook = XTredeem_scroll_bar;
   terminal->judge_scroll_bars_hook = XTjudge_scroll_bars;
   terminal->get_string_resource_hook = x_get_string_resource;
+  terminal->free_pixmap = x_free_pixmap;
   terminal->delete_frame_hook = x_destroy_window;
   terminal->delete_terminal_hook = x_delete_terminal;
   /* Other hooks are NULL by default.  */
-- 
2.21.0


  reply	other threads:[~2019-05-09 17:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-09  3:52 [PATCH] Remove display member of glyph_string Alex Gramiak
2019-05-09  5:50 ` Eli Zaretskii
2019-05-09 16:07   ` Alex Gramiak
2019-05-09 17:02     ` Eli Zaretskii
2019-05-09 17:16       ` Alex Gramiak [this message]
2019-05-09 17:59         ` Eli Zaretskii
2019-05-09 18:21           ` Alex Gramiak
2019-05-10  5:30             ` Eli Zaretskii
2019-05-11  4:20               ` Alex Gramiak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sgtnczvt.fsf@gmail.com \
    --to=agrambot@gmail.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.