From 90caddc98605e6dbf46be721f4a9ac8a72e8d7ac Mon Sep 17 00:00:00 2001 From: Po Lu Date: Fri, 28 Oct 2022 19:55:18 +0800 Subject: [PATCH] Clean up some xwidgets code * src/xterm.c (handle_one_xevent): [HAVE_XWIDGETS]: Fix coding style and remove extra ifdefs. Also avoid redundant frame lookups in some cases. --- src/xterm.c | 74 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 31 deletions(-) diff --git a/src/xterm.c b/src/xterm.c index c8ac30c72c7..f2d6be5d46b 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -18962,11 +18962,12 @@ handle_one_xevent (struct x_display_info *dpyinfo, goto OTHER; case Expose: - f = x_window_to_frame (dpyinfo, event->xexpose.window); + #ifdef HAVE_XWIDGETS { - struct xwidget_view *xv = - xwidget_view_from_window (event->xexpose.window); + struct xwidget_view *xv; + + xv = xwidget_view_from_window (event->xexpose.window); if (xv) { @@ -18975,6 +18976,8 @@ handle_one_xevent (struct x_display_info *dpyinfo, } } #endif + + f = x_window_to_frame (dpyinfo, event->xexpose.window); if (f) { if (!FRAME_VISIBLE_P (f)) @@ -19778,28 +19781,16 @@ handle_one_xevent (struct x_display_info *dpyinfo, case EnterNotify: x_display_set_last_user_time (dpyinfo, event->xcrossing.time, - event->xcrossing.send_event, false); - -#ifdef HAVE_XINPUT2 - /* For whatever reason, the X server continues to deliver - EnterNotify and LeaveNotify events despite us selecting for - related XI_Enter and XI_Leave events. It's not just our - problem, since windows created by "xinput test-xi2" suffer - from the same defect. Simply ignore all such events while - the input extension is enabled. (bug#57468) */ - - if (dpyinfo->supports_xi2) - goto OTHER; -#endif - - if (x_top_window_to_frame (dpyinfo, event->xcrossing.window)) - x_detect_focus_change (dpyinfo, any, event, &inev.ie); + event->xcrossing.send_event, + false); #ifdef HAVE_XWIDGETS { - struct xwidget_view *xvw = xwidget_view_from_window (event->xcrossing.window); + struct xwidget_view *xvw; Mouse_HLInfo *hlinfo; + xvw = xwidget_view_from_window (event->xcrossing.window); + if (xvw) { xwidget_motion_or_crossing (xvw, event); @@ -19813,14 +19804,28 @@ handle_one_xevent (struct x_display_info *dpyinfo, } if (any_help_event_p) - { - do_help = -1; - } + do_help = -1; + goto OTHER; } } #endif +#ifdef HAVE_XINPUT2 + /* For whatever reason, the X server continues to deliver + EnterNotify and LeaveNotify events despite us selecting for + related XI_Enter and XI_Leave events. It's not just our + problem, since windows created by "xinput test-xi2" suffer + from the same defect. Simply ignore all such events while + the input extension is enabled. (bug#57468) */ + + if (dpyinfo->supports_xi2) + goto OTHER; +#endif + + if (x_top_window_to_frame (dpyinfo, event->xcrossing.window)) + x_detect_focus_change (dpyinfo, any, event, &inev.ie); + f = any; if (f && event->xcrossing.window == FRAME_X_WINDOW (f)) @@ -19931,7 +19936,9 @@ handle_one_xevent (struct x_display_info *dpyinfo, #ifdef HAVE_XWIDGETS { - struct xwidget_view *xvw = xwidget_view_from_window (event->xcrossing.window); + struct xwidget_view *xvw; + + xvw = xwidget_view_from_window (event->xcrossing.window); if (xvw) { @@ -20291,7 +20298,9 @@ handle_one_xevent (struct x_display_info *dpyinfo, f = 0; #endif #ifdef HAVE_XWIDGETS - struct xwidget_view *xvw = xwidget_view_from_window (event->xmotion.window); + struct xwidget_view *xvw; + + xvw = xwidget_view_from_window (event->xmotion.window); if (xvw) xwidget_motion_or_crossing (xvw, event); @@ -20742,7 +20751,9 @@ handle_one_xevent (struct x_display_info *dpyinfo, event->xbutton.send_event, true); #ifdef HAVE_XWIDGETS - struct xwidget_view *xvw = xwidget_view_from_window (event->xbutton.window); + struct xwidget_view *xvw; + + xvw = xwidget_view_from_window (event->xbutton.window); if (xvw) { @@ -21407,10 +21418,10 @@ handle_one_xevent (struct x_display_info *dpyinfo, { #ifdef HAVE_XWIDGETS - struct xwidget_view *xwidget_view = xwidget_view_from_window (enter->event); -#endif + struct xwidget_view *xwidget_view; + + xwidget_view = xwidget_view_from_window (enter->event); -#ifdef HAVE_XWIDGETS if (xwidget_view) { xwidget_motion_or_crossing (xwidget_view, event); @@ -21544,8 +21555,9 @@ handle_one_xevent (struct x_display_info *dpyinfo, #ifdef HAVE_XWIDGETS { - struct xwidget_view *xvw - = xwidget_view_from_window (leave->event); + struct xwidget_view *xvw; + + xvw = xwidget_view_from_window (leave->event); if (xvw) { -- 2.39.5