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.
This commit is contained in:
Po Lu 2022-03-07 21:36:25 +08:00
parent 8a7df412a6
commit 418e5da5d3
5 changed files with 27 additions and 4 deletions

View file

@ -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) {

View file

@ -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);

View file

@ -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,

View file

@ -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.

View file

@ -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);