From 418e5da5d308b4e440f28545eb139211066b48a4 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Mon, 7 Mar 2022 21:36:25 +0800 Subject: [PATCH] Correctly handle exposure in oldXMenu * oldXMenu/Activate.c (XMenuActivate): Call set expose_func if no pane was found. (XMenuActivateSetExposeFunction): New function. * oldXMenu/XMenu.h: New typedef `expose_func'. Update prototypes. * src/xmenu.c (x_menu_expose_event): New function. (x_menu_show): Set expose event handler. * src/xterm.c (x_dispatch_event): Make `static' only on GTK. * src/xterm.h: Expose `x_dispatch_event' on no-toolkit builds. --- oldXMenu/Activate.c | 10 ++++++++++ oldXMenu/XMenu.h | 2 ++ src/xmenu.c | 9 +++++++++ src/xterm.c | 8 +++++--- src/xterm.h | 2 +- 5 files changed, 27 insertions(+), 4 deletions(-) diff --git a/oldXMenu/Activate.c b/oldXMenu/Activate.c index 781c05bd026..e679c2ffed6 100644 --- a/oldXMenu/Activate.c +++ b/oldXMenu/Activate.c @@ -122,6 +122,7 @@ int x_menu_grab_keyboard = 1; static Wait_func wait_func; static void* wait_data; static Translate_func translate_func = NULL; +static Expose_func expose_func = NULL; void XMenuActivateSetWaitFunction (Wait_func func, void *data) @@ -136,6 +137,12 @@ XMenuActivateSetTranslateFunction (Translate_func func) translate_func = func; } +void +XMenuActivateSetExposeFunction (Expose_func func) +{ + expose_func = func; +} + int XMenuActivate( register Display *display, /* Display to put menu on. */ @@ -339,6 +346,9 @@ XMenuActivate( feq = feq_tmp; } else if (_XMEventHandler) (*_XMEventHandler)(&event); + + if (expose_func) + expose_func (&event); break; } if (event_xmp->activated) { diff --git a/oldXMenu/XMenu.h b/oldXMenu/XMenu.h index 2eee18a3844..54061235ae7 100644 --- a/oldXMenu/XMenu.h +++ b/oldXMenu/XMenu.h @@ -259,6 +259,7 @@ typedef void (*Wait_func)(void*); XPutBackEvent on an equivalent artificial core event on any function it wants to translate. */ typedef void (*Translate_func)(XEvent *); +typedef void (*Expose_func)(XEvent *); /* * XMenu library routine declarations. @@ -280,6 +281,7 @@ int XMenuLocate(Display *display, XMenu *menu, int p_num, int s_num, int x_pos, void XMenuSetFreeze(XMenu *menu, int freeze); void XMenuActivateSetWaitFunction(Wait_func func, void *data); void XMenuActivateSetTranslateFunction(Translate_func func); +void XMenuActivateSetExposeFunction(Expose_func func); int XMenuActivate(Display *display, XMenu *menu, int *p_num, int *s_num, int x_pos, int y_pos, unsigned int event_mask, char **data, void (*help_callback) (char const *, int, int)); char *XMenuPost(Display *display, XMenu *menu, int *p_num, int *s_num, int x_pos, int y_pos, int event_mask); int XMenuDeletePane(Display *display, XMenu *menu, int p_num); diff --git a/src/xmenu.c b/src/xmenu.c index e085fa1ace5..4d0e5bd81c2 100644 --- a/src/xmenu.c +++ b/src/xmenu.c @@ -280,6 +280,14 @@ x_menu_translate_generic_event (XEvent *event) } } #endif + +#if !defined USE_X_TOOLKIT && !defined USE_GTK +static void +x_menu_expose_event (XEvent *event) +{ + x_dispatch_event (event, event->xexpose.display); +} +#endif #endif /* ! MSDOS */ @@ -2638,6 +2646,7 @@ x_menu_show (struct frame *f, int x, int y, int menuflags, #ifdef HAVE_XINPUT2 XMenuActivateSetTranslateFunction (x_menu_translate_generic_event); #endif + XMenuActivateSetExposeFunction (x_menu_expose_event); #endif record_unwind_protect_ptr (pop_down_menu, diff --git a/src/xterm.c b/src/xterm.c index 6682d3c9a46..60cd57b8512 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -13520,14 +13520,17 @@ handle_one_xevent (struct x_display_info *dpyinfo, return count; } -#if defined USE_X_TOOLKIT || defined USE_MOTIF || defined USE_GTK - /* Handles the XEvent EVENT on display DISPLAY. This is used for event loops outside the normal event handling, i.e. looping while a popup menu or a dialog is posted. Returns the value handle_one_xevent sets in the finish argument. */ + +#ifdef USE_GTK +static int +#else int +#endif x_dispatch_event (XEvent *event, Display *display) { struct x_display_info *dpyinfo; @@ -13540,7 +13543,6 @@ x_dispatch_event (XEvent *event, Display *display) return finish; } -#endif /* Read events coming from the X server. Return as soon as there are no more events to be read. diff --git a/src/xterm.h b/src/xterm.h index 846df03277c..88949b30391 100644 --- a/src/xterm.h +++ b/src/xterm.h @@ -1320,7 +1320,7 @@ extern void x_clear_area (struct frame *f, int, int, int, int); extern void x_mouse_leave (struct x_display_info *); #endif -#if defined USE_X_TOOLKIT || defined USE_MOTIF +#ifndef USE_GTK extern int x_dispatch_event (XEvent *, Display *); #endif extern int x_x_to_emacs_modifiers (struct x_display_info *, int); -- 2.39.5