Example #1
0
/** Call before exiting.
 */
void
awesome_atexit(bool restart)
{
    int screen_nbr, nscreens;

    if(globalconf.hooks.exit != LUA_REFNIL)
        luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.exit, 0, 0);

    lua_pushboolean(globalconf.L, restart);
    signal_object_emit(globalconf.L, &global_signals, "exit", 1);

    a_dbus_cleanup();

    /* do this only for real screen */
    const xcb_setup_t *setup = xcb_get_setup(globalconf.connection);
    nscreens = setup ? xcb_setup_roots_length(setup) : -1;
    for(screen_nbr = 0;
        screen_nbr < nscreens;
        screen_nbr++)
        systray_cleanup(0, screen_nbr); //FIXME: Clean physical screens

    /* Close Lua */
    lua_close(globalconf.L);

    xcb_flush(globalconf.connection);

    /* Disconnect *after* closing lua */
    xcb_disconnect(globalconf.connection);

    ev_default_destroy();
}
Example #2
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);
    }
}
Example #3
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");
}
Example #4
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);
}
Example #5
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)
        {
            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;
        }
}
Example #6
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);
}
Example #7
0
void
luaA_on_timer(EV_P_ ev_timer *w, int revents)
{
    if(globalconf.hooks.timer != LUA_REFNIL)
        luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.timer, 0, 0);
}