Skip to content

Commit 616ce44

Browse files
committed
Convert Free_Pixmap macro into terminal hook
* src/termhooks.h (terminal) [HAVE_WINDOW_SYSTEM]: 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.
1 parent 6bfc5fc commit 616ce44

File tree

9 files changed

+51
-35
lines changed

9 files changed

+51
-35
lines changed

src/image.c

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,26 +1221,6 @@ four_corners_best (XImagePtr_or_DC ximg, int *corners,
12211221
return best;
12221222
}
12231223

1224-
/* Portability macros */
1225-
1226-
#ifdef HAVE_NTGUI
1227-
1228-
#define Free_Pixmap(display, pixmap) \
1229-
DeleteObject (pixmap)
1230-
1231-
#elif defined (HAVE_NS)
1232-
1233-
#define Free_Pixmap(display, pixmap) \
1234-
ns_release_object (pixmap)
1235-
1236-
#else
1237-
1238-
#define Free_Pixmap(display, pixmap) \
1239-
XFreePixmap (display, pixmap)
1240-
1241-
#endif /* !HAVE_NTGUI && !HAVE_NS */
1242-
1243-
12441224
/* Return the `background' field of IMG. If IMG doesn't have one yet,
12451225
it is guessed heuristically. If non-zero, XIMG is an existing
12461226
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)
13281308
{
13291309
if (img->pixmap)
13301310
{
1331-
Free_Pixmap (FRAME_X_DISPLAY (f), img->pixmap);
1311+
FRAME_TERMINAL (f)->free_pixmap (f, img->pixmap);
13321312
img->pixmap = NO_PIXMAP;
13331313
/* NOTE (HAVE_NS): background color is NOT an indexed color! */
13341314
img->background_valid = 0;
@@ -1347,7 +1327,7 @@ image_clear_image_1 (struct frame *f, struct image *img, int flags)
13471327
{
13481328
if (img->mask)
13491329
{
1350-
Free_Pixmap (FRAME_X_DISPLAY (f), img->mask);
1330+
FRAME_TERMINAL (f)->free_pixmap (f, img->mask);
13511331
img->mask = NO_PIXMAP;
13521332
img->background_transparent_valid = 0;
13531333
}

src/msdos.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ typedef struct tty_display_info Display_Info;
9595
extern struct tty_display_info the_only_display_info;
9696
extern struct tty_output the_only_tty_output;
9797

98-
#define FRAME_X_DISPLAY(f) ((Display *) 0)
9998
#define FRAME_FONT(f) ((f)->output_data.tty->font)
10099
#define FRAME_DISPLAY_INFO(f) (&the_only_display_info)
101100

src/nsgui.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ typedef NSColor * Color;
115115
typedef void * Color;
116116
#endif
117117
typedef int Window;
118-
typedef int Display;
119118

120119

121120
/* Some sort of attempt to normalize rectangle handling. Seems a bit

src/nsterm.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -997,12 +997,6 @@ struct x_output
997997
#define FRAME_NS_WINDOW(f) ((f)->output_data.ns->window_desc)
998998
#define FRAME_NATIVE_WINDOW(f) FRAME_NS_WINDOW (f)
999999

1000-
/* This is the `Display *' which frame F is on. */
1001-
#define FRAME_NS_DISPLAY(f) (0)
1002-
#define FRAME_X_DISPLAY(f) (0)
1003-
#define FRAME_X_SCREEN(f) (0)
1004-
#define FRAME_X_VISUAL(f) FRAME_DISPLAY_INFO(f)->visual
1005-
10061000
#define FRAME_FOREGROUND_COLOR(f) ((f)->output_data.ns->foreground_color)
10071001
#define FRAME_BACKGROUND_COLOR(f) ((f)->output_data.ns->background_color)
10081002

src/nsterm.m

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2515,8 +2515,7 @@ so some key presses (TAB) are swallowed by the system. */
25152515

25162516
/* Clear the mouse-moved flag for every frame on this display. */
25172517
FOR_EACH_FRAME (tail, frame)
2518-
if (FRAME_NS_P (XFRAME (frame))
2519-
&& FRAME_NS_DISPLAY (XFRAME (frame)) == FRAME_NS_DISPLAY (*fp))
2518+
if (FRAME_NS_P (XFRAME (frame)))
25202519
XFRAME (frame)->mouse_moved = 0;
25212520

25222521
dpyinfo->last_mouse_scroll_bar = nil;
@@ -4966,6 +4965,18 @@ in certain situations (rapid incoming events).
49664965
[eview updateFrameSize: NO];
49674966
}
49684967

4968+
/* ==========================================================================
4969+
4970+
Image Hooks
4971+
4972+
========================================================================== */
4973+
4974+
static void
4975+
ns_free_pixmap (struct frame *_f, Pixmap pixmap)
4976+
{
4977+
ns_release_object (pixmap);
4978+
}
4979+
49694980
/* ==========================================================================
49704981
49714982
Initialization
@@ -5196,6 +5207,7 @@ static Lisp_Object ns_new_font (struct frame *f, Lisp_Object font_object,
51965207
terminal->redeem_scroll_bar_hook = ns_redeem_scroll_bar;
51975208
terminal->judge_scroll_bars_hook = ns_judge_scroll_bars;
51985209
terminal->get_string_resource_hook = ns_get_string_resource;
5210+
terminal->free_pixmap = ns_free_pixmap;
51995211
terminal->delete_frame_hook = ns_destroy_window;
52005212
terminal->delete_terminal_hook = ns_delete_terminal;
52015213
/* Other hooks are NULL by default. */

src/termhooks.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,15 @@ struct terminal
741741
const char *name,
742742
const char *class);
743743

744+
/* Image hooks */
745+
#ifdef HAVE_WINDOW_SYSTEM
746+
/* Free the pixmap PIXMAP on F. */
747+
void (*free_pixmap) (struct frame *f, Pixmap pixmap);
748+
749+
#endif
750+
751+
/* Deletion hooks */
752+
744753
/* Called to delete the device-specific portions of a frame that is
745754
on this terminal device. */
746755
void (*delete_frame_hook) (struct frame *);

src/w32term.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6869,6 +6869,7 @@ w32_wm_set_size_hint (struct frame *f, long flags, bool user_position)
68696869
leave_crit ();
68706870
}
68716871

6872+
68726873
/***********************************************************************
68736874
Fonts
68746875
***********************************************************************/
@@ -6940,6 +6941,18 @@ w32_toggle_invisible_pointer (struct frame *f, bool invisible)
69406941
unblock_input ();
69416942
}
69426943

6944+
6945+
/***********************************************************************
6946+
Image Hooks
6947+
***********************************************************************/
6948+
6949+
static void
6950+
w32_free_pixmap (struct frame *_f, Pixmap pixmap)
6951+
{
6952+
DeleteObject (pixmap);
6953+
}
6954+
6955+
69436956
/***********************************************************************
69446957
Initialization
69456958
***********************************************************************/
@@ -7119,6 +7132,7 @@ w32_create_terminal (struct w32_display_info *dpyinfo)
71197132
terminal->redeem_scroll_bar_hook = w32_redeem_scroll_bar;
71207133
terminal->judge_scroll_bars_hook = w32_judge_scroll_bars;
71217134
terminal->get_string_resource_hook = w32_get_string_resource;
7135+
terminal->free_pixmap = w32_free_pixmap;
71227136
terminal->delete_frame_hook = w32_destroy_window;
71237137
terminal->delete_terminal_hook = w32_delete_terminal;
71247138
/* Other hooks are NULL by default. */

src/w32term.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,9 +420,6 @@ extern struct w32_output w32term_display;
420420
/* This gives the w32_display_info structure for the display F is on. */
421421
#define FRAME_DISPLAY_INFO(f) ((void) (f), (&one_w32_display_info))
422422

423-
/* This is the `Display *' which frame F is on. */
424-
#define FRAME_X_DISPLAY(f) (0)
425-
426423
#define FRAME_NORMAL_PLACEMENT(F) ((F)->output_data.w32->normal_placement)
427424
#define FRAME_PREV_FSMODE(F) ((F)->output_data.w32->prev_fsmode)
428425

src/xterm.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12180,6 +12180,17 @@ x_check_font (struct frame *f, struct font *font)
1218012180

1218112181
#endif /* GLYPH_DEBUG */
1218212182

12183+
12184+
/***********************************************************************
12185+
Image Hooks
12186+
***********************************************************************/
12187+
12188+
static void
12189+
x_free_pixmap (struct frame *f, Pixmap pixmap)
12190+
{
12191+
XFreePixmap (FRAME_X_DISPLAY (f), pixmap);
12192+
}
12193+
1218312194

1218412195
/***********************************************************************
1218512196
Initialization
@@ -13257,6 +13268,7 @@ x_create_terminal (struct x_display_info *dpyinfo)
1325713268
terminal->redeem_scroll_bar_hook = XTredeem_scroll_bar;
1325813269
terminal->judge_scroll_bars_hook = XTjudge_scroll_bars;
1325913270
terminal->get_string_resource_hook = x_get_string_resource;
13271+
terminal->free_pixmap = x_free_pixmap;
1326013272
terminal->delete_frame_hook = x_destroy_window;
1326113273
terminal->delete_terminal_hook = x_delete_terminal;
1326213274
/* Other hooks are NULL by default. */

0 commit comments

Comments
 (0)