]> git.eshelyaron.com Git - emacs.git/commitdiff
Don't loop through useless region when searching for DND toplevel
authorPo Lu <luangruo@yahoo.com>
Tue, 29 Mar 2022 01:08:22 +0000 (09:08 +0800)
committerPo Lu <luangruo@yahoo.com>
Tue, 29 Mar 2022 01:08:22 +0000 (09:08 +0800)
* src/xterm.c (x_dnd_compute_toplevels): Optimize for the
bounding rect being the window dimensions.

src/xterm.c

index 443009c0dba3363022c45e637d9304c8c479a681..28311f94e9618e66369390428f979864cbfa7888 100644 (file)
@@ -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);