clean some tag stuff

This commit is contained in:
Julien Danjou 2008-01-13 15:26:19 +01:00
parent 45ac9d24f4
commit 6fc766a847
4 changed files with 29 additions and 25 deletions

2
ewmh.c
View File

@ -310,7 +310,7 @@ ewmh_process_client_message(XClientMessageEvent *ev)
if(ev->message_type == net_current_desktop) if(ev->message_type == net_current_desktop)
for(screen = 0; screen < ScreenCount(globalconf.display); screen++) for(screen = 0; screen < ScreenCount(globalconf.display); screen++)
if(ev->window == RootWindow(globalconf.display, screen)) if(ev->window == RootWindow(globalconf.display, screen))
tag_view_byindex(screen, ev->data.l[0]); tag_view_only_byindex(screen, ev->data.l[0]);
if(ev->message_type == net_close_window) if(ev->message_type == net_close_window)
{ {

48
tag.c
View File

@ -272,26 +272,29 @@ uicb_tag_toggleview(int screen, char *arg)
widget_invalidate_cache(screen, WIDGET_CACHE_TAGS); widget_invalidate_cache(screen, WIDGET_CACHE_TAGS);
} }
void static void
tag_view_byindex(int screen, int dindex) tag_view_only(int screen, Tag *target)
{ {
Tag *target_tag, *tag; Tag *tag;
if(!target) return;
for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
tag->selected = False;
target->selected = True;
}
void
tag_view_only_byindex(int screen, int dindex)
{
Tag *tag;
if(dindex < 0) if(dindex < 0)
return; return;
for(target_tag = globalconf.screens[screen].tags; target_tag && dindex > 0; for(tag = globalconf.screens[screen].tags; tag && dindex > 0;
target_tag = target_tag->next, dindex--); tag = tag->next, dindex--);
if(target_tag) tag_view_only(screen, tag);
{
for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
tag->selected = False;
target_tag->selected = True;
}
saveawesomeprops(screen);
arrange(screen);
ewmh_update_net_current_desktop(get_phys_screen(screen));
widget_invalidate_cache(screen, WIDGET_CACHE_TAGS);
} }
/** View tag /** View tag
@ -305,16 +308,15 @@ uicb_tag_view(int screen, char *arg)
Tag *tag; Tag *tag;
if(arg) if(arg)
tag_view_byindex(screen, atoi(arg) - 1); tag_view_only_byindex(screen, atoi(arg) - 1);
else else
{
for(tag = globalconf.screens[screen].tags; tag; tag = tag->next) for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
tag->selected = True; tag->selected = True;
saveawesomeprops(screen);
arrange(screen); saveawesomeprops(screen);
ewmh_update_net_current_desktop(get_phys_screen(screen)); arrange(screen);
widget_invalidate_cache(screen, WIDGET_CACHE_TAGS); ewmh_update_net_current_desktop(get_phys_screen(screen));
} widget_invalidate_cache(screen, WIDGET_CACHE_TAGS);
} }
/** View previously selected tags /** View previously selected tags
@ -334,6 +336,7 @@ uicb_tag_prev_selected(int screen, char *arg __attribute__ ((unused)))
tag->selected = tag->was_selected; tag->selected = tag->was_selected;
tag->was_selected = t; tag->was_selected = t;
} }
saveawesomeprops(screen);
arrange(screen); arrange(screen);
ewmh_update_net_current_desktop(get_phys_screen(screen)); ewmh_update_net_current_desktop(get_phys_screen(screen));
widget_invalidate_cache(screen, WIDGET_CACHE_TAGS); widget_invalidate_cache(screen, WIDGET_CACHE_TAGS);
@ -382,6 +385,7 @@ uicb_tag_viewprev(int screen, char *arg __attribute__ ((unused)))
arrange(screen); arrange(screen);
} }
p_delete(&curtags); p_delete(&curtags);
saveawesomeprops(screen);
ewmh_update_net_current_desktop(get_phys_screen(screen)); ewmh_update_net_current_desktop(get_phys_screen(screen));
widget_invalidate_cache(screen, WIDGET_CACHE_TAGS); widget_invalidate_cache(screen, WIDGET_CACHE_TAGS);
} }

2
tag.h
View File

@ -33,7 +33,7 @@ void untag_client(Client *, Tag *);
Bool is_client_tagged(Client *, Tag *); Bool is_client_tagged(Client *, Tag *);
void tag_client_with_current_selected(Client *); void tag_client_with_current_selected(Client *);
void tag_client_with_rules(Client *); void tag_client_with_rules(Client *);
void tag_view_byindex(int, int); void tag_view_only_byindex(int, int);
Uicb uicb_client_tag; Uicb uicb_client_tag;
Uicb uicb_client_toggletag; Uicb uicb_client_toggletag;

View File

@ -190,7 +190,7 @@ tasklist_button_press(Widget *widget, XButtonPressedEvent *ev)
if(!client_isvisible(c, widget->statusbar->screen)) if(!client_isvisible(c, widget->statusbar->screen))
for(i = 0, tag = globalconf.screens[c->screen].tags; tag; tag = tag->next, i++) for(i = 0, tag = globalconf.screens[c->screen].tags; tag; tag = tag->next, i++)
if(is_client_tagged(c, tag)) if(is_client_tagged(c, tag))
tag_view_byindex(c->screen, i); tag_view_only_byindex(c->screen, i);
focus(c, True, widget->statusbar->screen); focus(c, True, widget->statusbar->screen);
} }