Index: src/core/window.c
===================================================================
--- src/core/window.c	(revision 4239)
+++ src/core/window.c	(working copy)
@@ -7535,13 +7535,16 @@
 meta_window_same_application (MetaWindow *window,
                               MetaWindow *other_window)
 {
-  MetaGroup *group       = meta_window_get_group (window);
-  MetaGroup *other_group = meta_window_get_group (other_window);
+  MetaGroup *group        = meta_window_get_group (window);
+  MetaGroup *other_group  = meta_window_get_group (other_window);
+  Window     leader       = window->xclient_leader;
+  Window     other_leader = other_window->xclient_leader;
 
   return
-    group!=NULL &&
-    other_group!=NULL &&
-    group==other_group;
+    (group!=NULL &&
+     group==other_group) ||
+    (leader!=None &&
+     leader==other_leader);
 }
 
 void
