From d96db7b2e8c35ec2970d12c96e2328b684626f24 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Tue, 29 Mar 2022 09:08:22 +0800 Subject: [PATCH] Don't loop through useless region when searching for DND toplevel * src/xterm.c (x_dnd_compute_toplevels): Optimize for the bounding rect being the window dimensions. --- src/xterm.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/xterm.c b/src/xterm.c index 443009c0dba..28311f94e96 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -1278,6 +1278,30 @@ x_dnd_compute_toplevels (struct x_display_info *dpyinfo) xfree (tem->input_rects); tem->n_input_rects = -1; } + + /* And the common case where there is no input rect and the + bouding rect equals the window dimensions. */ + + if (tem->n_input_rects == -1 + && tem->n_bounding_rects == 1 +#ifdef USE_XCB + && tem->bounding_rects[0].width == (geometry_reply->width + + geometry_reply->border_width) + && tem->bounding_rects[0].height == (geometry_reply->height + + geometry_reply->border_width) + && tem->bounding_rects[0].x == -geometry_reply->border_width + && tem->bounding_rects[0].y == -geometry_reply->border_width +#else + && tem->bounding_rects[0].width == attrs.width + attrs.border_width + && tem->bounding_rects[0].height == attrs.height + attrs.border_width + && tem->bounding_rects[0].x == -attrs.border_width + && tem->bounding_rects[0].y == -attrs.border_width +#endif + ) + { + xfree (tem->bounding_rects); + tem->n_bounding_rects = -1; + } #endif x_catch_errors (dpyinfo->display); -- 2.39.5