get app from border now - no more zillions of params. also use wm command to

match


SVN revision: 25493
This commit is contained in:
Carsten Haitzler 2006-09-05 14:44:28 +00:00
parent 3fa7cc4df7
commit c2a232bf45
4 changed files with 37 additions and 22 deletions

View File

@ -919,31 +919,36 @@ e_app_launch_id_pid_find(int launch_id, pid_t pid)
}
EAPI E_App *
e_app_window_name_class_title_role_find(const char *name, const char *class,
const char *title, const char *role)
e_app_border_find(E_Border *bd)
{
Evas_List *l, *l_match = NULL;
int ok, match = 0;
E_App *a, *a_match = NULL;
char *title;
if ((!name) && (!class) && (!title) && (!role))
if ((!bd->client.icccm.name) && (!bd->client.icccm.class) &&
(!bd->client.icccm.title) && (bd->client.netwm.name) &&
(!bd->client.icccm.window_role) && (!bd->client.icccm.command.argv))
return NULL;
title = bd->client.netwm.name;
if (!title) title = bd->client.icccm.title;
for (l = _e_apps_list; l; l = l->next)
{
a = l->data;
ok = 0;
if ((a->win_name) || (a->win_class) || (a->win_title) || (a->win_role))
{
if ((a->win_name) && (a->win_class) && (name) && (class))
if ((a->win_name) && (a->win_class) &&
(bd->client.icccm.name) && (bd->client.icccm.class))
{
if ((e_util_glob_match(name, a->win_name)) &&
(e_util_glob_match(class, a->win_class)))
if ((e_util_glob_match(bd->client.icccm.name, a->win_name)) &&
(e_util_glob_match(bd->client.icccm.class, a->win_class)))
ok += 2;
}
else if ((a->win_class) && (class))
else if ((a->win_class) && (bd->client.icccm.class))
{
if (e_util_glob_match(class, a->win_class))
if (e_util_glob_match(bd->client.icccm.class, a->win_class))
ok += 2;
}
@ -951,8 +956,28 @@ e_app_window_name_class_title_role_find(const char *name, const char *class,
((a->win_title) && (title) && (e_util_glob_match(title, a->win_title))))
ok++;
if (//(!a->win_role) ||
((a->win_role) && (role) && (e_util_glob_match(role, a->win_role))))
((a->win_role) && (bd->client.icccm.window_role) && (e_util_glob_match(bd->client.icccm.window_role, a->win_role))))
ok++;
if (
(a->exe) && (bd->client.icccm.command.argv))
{
char *ts, *p;
ts = alloca(strlen(a->exe) + 1);
strcpy(ts, a->exe);
p = ts;
while (*p)
{
if (isspace(*p))
{
*p = 0;
break;
}
p++;
}
if (!strcmp(a->exe, ts))
ok++;
}
}
if (ok > match)
{

View File

@ -117,7 +117,7 @@ EAPI void e_app_change_callback_add (void (*func) (void *da
EAPI void e_app_change_callback_del (void (*func) (void *data, E_App *a, E_App_Change ch), void *data);
EAPI E_App *e_app_launch_id_pid_find (int launch_id, pid_t pid);
EAPI E_App *e_app_window_name_class_title_role_find (const char *name, const char *class, const char *title, const char *role);
EAPI E_App *e_app_border_find (E_Border *bd);
EAPI E_App *e_app_file_find (const char *file);
EAPI E_App *e_app_name_find (const char *name);
EAPI E_App *e_app_generic_find (const char *generic);

View File

@ -2586,14 +2586,7 @@ e_border_icon_add(E_Border *bd, Evas *evas)
{
if ((bd->client.icccm.name) && (bd->client.icccm.class))
{
char *title = "";
if (bd->client.netwm.name) title = bd->client.netwm.name;
else title = bd->client.icccm.title;
a = e_app_window_name_class_title_role_find(bd->client.icccm.name,
bd->client.icccm.class,
title,
bd->client.icccm.window_role);
a = e_app_border_find(bd);
}
if (!a)
{

View File

@ -1219,10 +1219,7 @@ _ibar_inst_cb_drop(void *data, const char *type, void *event_info)
if (!app)
{
app = e_app_window_name_class_title_role_find(bd->client.icccm.name,
bd->client.icccm.class,
e_border_name_get(bd),
bd->client.icccm.window_role);
app = e_app_border_find(bd);
}
if (!app)
{