ewmh, tag: simplify ewmh_update_net_current_desktop

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2009-07-30 11:29:41 +02:00
parent 65260f5772
commit 2836c98ee5
3 changed files with 9 additions and 22 deletions

11
ewmh.c
View File

@ -187,18 +187,11 @@ ewmh_update_net_numbers_of_desktop(int phys_screen)
void
ewmh_update_net_current_desktop(int phys_screen)
{
tag_array_t *tags = &globalconf.screens.tab[phys_screen].tags;
uint32_t count = 0;
tag_t **curtags = tags_get_current( &globalconf.screens.tab[phys_screen]);
while(count < (uint32_t) tags->len && tags->tab[count] != curtags[0])
count++;
uint32_t idx = tags_get_first_selected_index(&globalconf.screens.tab[phys_screen]);
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
xutil_screen_get(globalconf.connection, phys_screen)->root,
_NET_CURRENT_DESKTOP, CARDINAL, 32, 1, &count);
p_delete(&curtags);
_NET_CURRENT_DESKTOP, CARDINAL, 32, 1, &idx);
}
void

18
tag.c
View File

@ -206,25 +206,19 @@ is_client_tagged(client_t *c, tag_t *t)
return false;
}
/** Get the current tags for the specified screen.
* Returned pointer must be p_delete'd after.
/** Get the index of the first selected tag.
* \param screen Screen.
* \return A double pointer of tag list finished with a NULL element.
* \return Its index.
*/
tag_t **
tags_get_current(screen_t *screen)
int
tags_get_first_selected_index(screen_t *screen)
{
tag_t **out = p_new(tag_t *, screen->tags.len + 1);
int n = 0;
foreach(tag, screen->tags)
if((*tag)->selected)
out[n++] = *tag;
return out;
return tag_array_indexof(&screen->tags, tag);
return 0;
}
/** Set a tag to be the only one viewed.
* \param target the tag to see
*/

2
tag.h
View File

@ -38,7 +38,7 @@ struct tag
client_array_t clients;
};
tag_t **tags_get_current(screen_t *);
int tags_get_first_selected_index(screen_t *);
void tag_client(client_t *);
void untag_client(client_t *, tag_t *);
bool is_client_tagged(client_t *, tag_t *);