From: Po Lu Date: Tue, 29 Mar 2022 01:08:22 +0000 (+0800) Subject: Don't loop through useless region when searching for DND toplevel X-Git-Tag: emacs-29.0.90~1931^2~878 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=d96db7b2e8c35ec2970d12c96e2328b684626f24;p=emacs.git 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. --- 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);