remove duplicated code

This commit is contained in:
seanpringle
2012-09-05 00:37:21 +10:00
parent 80fc26a5fc
commit 9e39572194

20
xoat.c
View File

@@ -548,26 +548,18 @@ void client_active(client *c)
// real simple switcher/launcher // real simple switcher/launcher
void find_or_start(char *class) void find_or_start(char *class)
{ {
int i; client *c, *found = NULL; int i; client *c;
stack all; windows_visible(&all); stack all; windows_visible(&all);
for (i = 0; !found && i < all.depth; i++) for (i = 0; i < all.depth; i++)
{ {
XClassHint chint; if ((c = all.clients[i]) && c->manage && !strcasecmp(c->class, class))
if ((c = all.clients[i]) && c->manage && XGetClassHint(display, c->window, &chint))
{ {
if (!strcasecmp(chint.res_class, class) || !strcasecmp(chint.res_name, class)) client_raise(c);
found = c; client_active(c);
XFree(chint.res_class); return;
XFree(chint.res_name);
} }
} }
if (found)
{
client_raise(found);
client_active(found);
return;
}
exec_cmd(class); exec_cmd(class);
} }