/** View or unview a tag. * \param L The Lua VM state. * \param udx The index of the tag on the stack. * \param view Set visible or not. */ static void tag_view(lua_State *L, int udx, bool view) { tag_t *tag = luaA_checkudata(L, udx, &tag_class); if(tag->selected != view) { tag->selected = view; if(tag->screen) { int screen_index = screen_array_indexof(&globalconf.screens, tag->screen); banning_need_update(tag->screen); ewmh_update_net_current_desktop(screen_virttophys(screen_index)); if(globalconf.hooks.tags != LUA_REFNIL) { lua_pushnumber(globalconf.L, screen_index + 1); luaA_object_push(globalconf.L, tag); if(view) lua_pushliteral(globalconf.L, "select"); else lua_pushliteral(globalconf.L, "unselect"); luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.tags, 3, 0); } } luaA_object_emit_signal(L, udx, "property::selected", 0); } }
/** Tag a client with the tag on top of the stack. * \param c the client to tag */ void tag_client(client_t *c) { tag_t *t = luaA_object_ref_class(globalconf.L, -1, &tag_class); /* don't tag twice */ if(is_client_tagged(c, t)) { luaA_object_unref(globalconf.L, t); return; } client_array_append(&t->clients, c); ewmh_client_update_desktop(c); banning_need_update((c)->screen); /* call hook */ if(globalconf.hooks.tagged != LUA_REFNIL) { luaA_object_push(globalconf.L, c); luaA_object_push(globalconf.L, t); luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.tagged, 2, 0); } tag_client_emit_signal(globalconf.L, t, c, "tagged"); }
/** View or unview a tag. * \param L The Lua VM state. * \param udx The index of the tag on the stack. * \param view Set selected or not. */ static void tag_view(lua_State *L, int udx, bool view) { tag_t *tag = luaA_checkudata(L, udx, &tag_class); if(tag->selected != view) { tag->selected = view; banning_need_update(); ewmh_update_net_current_desktop(); luaA_object_emit_signal(L, udx, "property::selected", 0); } }
/** Untag a client with specified tag. * \param c the client to tag * \param t the tag to tag the client with */ void untag_client(client_t *c, tag_t *t) { for(int i = 0; i < t->clients.len; i++) if(t->clients.tab[i] == c) { lua_State *L = globalconf_get_lua_State(); client_array_take(&t->clients, i); banning_need_update(); ewmh_client_update_desktop(c); tag_client_emit_signal(t, c, "untagged"); luaA_object_unref(L, t); return; } }
/** Tag a client with the tag on top of the stack. * \param L The Lua VM state. * \param c the client to tag */ void tag_client(lua_State *L, client_t *c) { tag_t *t = luaA_object_ref_class(L, -1, &tag_class); /* don't tag twice */ if(is_client_tagged(c, t)) { luaA_object_unref(L, t); return; } client_array_append(&t->clients, c); ewmh_client_update_desktop(c); banning_need_update(); tag_client_emit_signal(t, c, "tagged"); }
/** Remove a tag from screen. Tag must be on a screen and have no clients. * \param tag The tag to remove. */ void tag_remove_from_screen(tag_t *tag) { if(!tag->screen) return; int screen_index = screen_array_indexof(&globalconf.screens, tag->screen); int phys_screen = screen_virttophys(screen_index); tag_array_t *tags = &tag->screen->tags; for(int i = 0; i < tags->len; i++) if(tags->tab[i] == tag) { tag_array_take(tags, i); break; } /* tag was selected? If so, reban */ if(tag->selected) banning_need_update(tag->screen); ewmh_update_net_numbers_of_desktop(phys_screen); ewmh_update_net_desktop_names(phys_screen); /* call hook */ if(globalconf.hooks.tags != LUA_REFNIL) { lua_pushnumber(globalconf.L, screen_index + 1); luaA_object_push(globalconf.L, tag); lua_pushliteral(globalconf.L, "remove"); luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.tags, 3, 0); } screen_t *s = tag->screen; tag->screen = NULL; luaA_object_push(globalconf.L, tag); luaA_object_emit_signal(globalconf.L, -1, "property::screen", 0); screen_emit_signal(globalconf.L, s, "tag::detach", 1); luaA_object_unref(globalconf.L, tag); }
/** Untag a client with specified tag. * \param c the client to tag * \param t the tag to tag the client with */ void untag_client(client_t *c, tag_t *t) { for(int i = 0; i < t->clients.len; i++) if(t->clients.tab[i] == c) { client_array_take(&t->clients, i); banning_need_update((c)->screen); ewmh_client_update_desktop(c); /* call hook */ if(globalconf.hooks.tagged != LUA_REFNIL) { luaA_object_push(globalconf.L, c); luaA_object_push(globalconf.L, t); luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.tagged, 2, 0); } tag_client_emit_signal(globalconf.L, t, c, "untagged"); luaA_object_unref(globalconf.L, t); return; } }