ewmh, tag: simplify ewmh_update_net_current_desktop
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
65260f5772
commit
2836c98ee5
11
ewmh.c
11
ewmh.c
|
@ -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
18
tag.c
|
@ -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
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue