diff --git a/src/shell-window-tracker.c b/src/shell-window-tracker.c
index 09653e4..d69df23 100644
--- a/src/shell-window-tracker.c
+++ b/src/shell-window-tracker.c
@@ -227,15 +227,15 @@ get_app_from_window_wmclass (MetaWindow  *window)
      StartupWMClass=crx_blpcfgokakmgnkcojhhkbfbldkacnbeo
   */
 
-  /* first try a match from WM_CLASS to StartupWMClass */
-  wm_class = meta_window_get_wm_class (window);
-  app = shell_app_system_lookup_startup_wmclass (appsys, wm_class);
+  /* first try a match from WM_CLASS (instance part) to StartupWMClass */
+  wm_instance = meta_window_get_wm_class_instance (window);
+  app = shell_app_system_lookup_startup_wmclass (appsys, wm_instance);
   if (app != NULL)
     return g_object_ref (app);
 
-  /* then try a match from WM_CLASS (instance part) to StartupWMClass */
-  wm_instance = meta_window_get_wm_class_instance (window);
-  app = shell_app_system_lookup_startup_wmclass (appsys, wm_instance);
+  /* then try a match from WM_CLASS to StartupWMClass */
+  wm_class = meta_window_get_wm_class (window);
+  app = shell_app_system_lookup_startup_wmclass (appsys, wm_class);
   if (app != NULL)
     return g_object_ref (app);
 
