示例#1
0
文件: tag.c 项目: kanru/awesome
/** Remove a tag from screen. Tag must be on a screen and have no clients.
 * \param tag The tag to remove.
 */
static void
tag_remove_from_screen(tag_t *tag)
{
    int screen = tag->screen;
    int phys_screen = screen_virttophys(tag->screen);
    tag_array_t *tags = &globalconf.screens[tag->screen].tags;

    for(int i = 0; i < tags->len; i++)
        if(tags->tab[i] == tag)
        {
            tag_array_take(tags, i);
            break;
        }
    ewmh_update_net_numbers_of_desktop(phys_screen);
    ewmh_update_net_desktop_names(phys_screen);
    ewmh_update_workarea(phys_screen);
    tag->screen = SCREEN_UNDEF;
    tag_unref(&tag);

    /* resave tag prop of all clients so the number of tag will be the
     * same */
    for(client_t *c = globalconf.clients; c; c = c->next)
        client_saveprops_tags(c);

    /* call hook */
    if(globalconf.hooks.tags != LUA_REFNIL)
    {
        lua_pushnumber(globalconf.L, screen + 1);
        luaA_dofunction(globalconf.L, globalconf.hooks.tags, 1, 0);
    }
}
示例#2
0
文件: tag.c 项目: kanru/awesome
/** View or unview a tag.
 * \param tag the tag
 * \param view set visible or not
 */
static void
tag_view(tag_t *tag, bool view)
{
    tag->selected = view;
    ewmh_update_net_current_desktop(screen_virttophys(tag->screen));
    globalconf.screens[tag->screen].need_arrange = true;
}
示例#3
0
文件: tag.c 项目: azuwis/awesome
/** Remove a tag from screen. Tag must be on a screen and have no clients.
 * \param tag The tag to remove.
 */
static void
tag_remove_from_screen(tag_t *tag)
{
    int screen = tag->screen;
    int phys_screen = screen_virttophys(tag->screen);
    tag_array_t *tags = &globalconf.screens[tag->screen].tags;

    for(int i = 0; i < tags->len; i++)
        if(tags->tab[i] == tag)
        {
            tag_array_take(tags, i);
            break;
        }
    ewmh_update_net_numbers_of_desktop(phys_screen);
    ewmh_update_net_desktop_names(phys_screen);
    ewmh_update_workarea(phys_screen);
    tag->screen = SCREEN_UNDEF;

    /* call hook */
    if(globalconf.hooks.tags != LUA_REFNIL)
    {
        lua_pushnumber(globalconf.L, screen + 1);
        tag_push(globalconf.L, tag);
        lua_pushliteral(globalconf.L, "remove");
        luaA_dofunction(globalconf.L, globalconf.hooks.tags, 3, 0);
    }

    tag_unref(globalconf.L, tag);
}
示例#4
0
/** 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);
    }
}
示例#5
0
/** 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);
}
示例#6
0
static area_t
systray_extents(lua_State *L, widget_t *widget)
{
    int screen = luaL_optnumber(L, -1, 1) - 1;
    luaA_checkscreen(screen);

    area_t geometry;
    int phys_screen = screen_virttophys(screen), n = 0;
    systray_data_t *d = widget->data;

    for(int i = 0; i < globalconf.embedded.len; i++)
        if(globalconf.embedded.tab[i].phys_screen == phys_screen)
            n++;

    /** \todo use class hints */
    geometry.width  = d->height * n;
    geometry.height = d->height;
    geometry.x      = geometry.y = 0;

    return geometry;
}
示例#7
0
文件: tag.c 项目: azuwis/awesome
/** Append a tag which on top of the stack to a screen.
 * \param screen the screen id
 */
void
tag_append_to_screen(screen_t *s)
{
    int phys_screen = screen_virttophys(s->index);
    tag_t *tag = tag_ref(globalconf.L);

    tag->screen = s->index;
    tag_array_append(&s->tags, tag);
    ewmh_update_net_numbers_of_desktop(phys_screen);
    ewmh_update_net_desktop_names(phys_screen);
    ewmh_update_workarea(phys_screen);

    /* call hook */
    if(globalconf.hooks.tags != LUA_REFNIL)
    {
        lua_pushnumber(globalconf.L, s->index + 1);
        tag_push(globalconf.L, tag);
        lua_pushliteral(globalconf.L, "add");
        luaA_dofunction(globalconf.L, globalconf.hooks.tags, 3, 0);
    }
}
示例#8
0
文件: tag.c 项目: kanru/awesome
/** Append a tag to a screen.
 * \param tag the tag to append
 * \param screen the screen id
 */
void
tag_append_to_screen(tag_t *tag, screen_t *s)
{
    int phys_screen = screen_virttophys(s->index);

    tag->screen = s->index;
    tag_array_append(&s->tags, tag_ref(&tag));
    ewmh_update_net_numbers_of_desktop(phys_screen);
    ewmh_update_net_desktop_names(phys_screen);
    ewmh_update_workarea(phys_screen);

    /* resave tag prop of all clients so the number of tag will be the
     * same */
    for(client_t *c = globalconf.clients; c; c = c->next)
        client_saveprops_tags(c);

    /* call hook */
    if(globalconf.hooks.tags != LUA_REFNIL)
    {
        lua_pushnumber(globalconf.L, s->index + 1);
        luaA_dofunction(globalconf.L, globalconf.hooks.tags, 1, 0);
    }
}
示例#9
0
/** Append a tag to a screen.
 * \param L The Lua VM state.
 * \param udx The tag index on the stack.
 * \param s The screen.
 */
void
tag_append_to_screen(lua_State *L, int udx, screen_t *s)
{
    tag_t *tag = luaA_checkudata(globalconf.L, udx, &tag_class);

    /* can't attach a tag twice */
    if(tag->screen)
    {
        lua_remove(L, udx);
        return;
    }

    int screen_index = screen_array_indexof(&globalconf.screens, s);
    int phys_screen = screen_virttophys(screen_index);

    tag->screen = s;
    tag_array_append(&s->tags, luaA_object_ref_class(globalconf.L, udx, &tag_class));
    ewmh_update_net_numbers_of_desktop(phys_screen);
    ewmh_update_net_desktop_names(phys_screen);

    luaA_object_push(globalconf.L, tag);
    luaA_object_emit_signal(L, -1, "property::screen", 0);
    lua_pop(L, 1);

    /* 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, "add");
        luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.tags, 3, 0);
    }

    luaA_object_push(globalconf.L, tag);
    screen_emit_signal(globalconf.L, s, "tag::attach", 1);
}