예제 #1
0
static int
property_handle_net_wm_opacity(uint8_t state,
                               xcb_window_t window)
{
    drawin_t *drawin = drawin_getbywin(window);

    if(drawin)
    {
        luaA_object_push(globalconf.L, drawin);
        window_set_opacity(globalconf.L, -1, xwindow_get_opacity(drawin->window));
        lua_pop(globalconf.L, -1);
    }
    else
    {
        client_t *c = client_getbywin(window);
        if(c)
        {
            luaA_object_push(globalconf.L, c);
            window_set_opacity(globalconf.L, -1, xwindow_get_opacity(c->window));
            lua_pop(globalconf.L, 1);
        }
    }

    return 0;
}
예제 #2
0
static int
property_handle_net_wm_opacity(uint8_t state,
                               xcb_window_t window,
                               xcb_atom_t name,
                               xcb_get_property_reply_t *reply)
{
    wibox_t *wibox = wibox_getbywin(window);

    if(wibox)
    {
        luaA_object_push(globalconf.L, wibox);
        wibox_set_opacity(globalconf.L, -1, window_opacity_get_from_reply(reply));
        lua_pop(globalconf.L, -1);
    }
    else
    {
        client_t *c = client_getbywin(window);
        if(c)
        {
            luaA_object_push(globalconf.L, c);
            client_set_opacity(globalconf.L, -1, window_opacity_get_from_reply(reply));
            lua_pop(globalconf.L, 1);
        }
    }

    return 0;
}
예제 #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");
}
예제 #4
0
static void
tag_client_emit_signal(lua_State *L, tag_t *t, client_t *c, const char *signame)
{
    luaA_object_push(L, c);
    luaA_object_push(L, t);
    /* emit signal on client, with new tag as argument */
    luaA_object_emit_signal(L, -2, signame, 1);
    /* re push tag */
    luaA_object_push(L, t);
    /* move tag before client */
    lua_insert(L, -2);
    luaA_object_emit_signal(L, -2, signame, 1);
    /* Remove tag */
    lua_pop(L, 1);
}
예제 #5
0
void
property_update_wm_transient_for(client_t *c, xcb_get_property_cookie_t cookie)
{
    xcb_window_t trans;
    int counter;
    client_t *tc, *tmp;

    if(!xcb_icccm_get_wm_transient_for_reply(globalconf.connection,
					     cookie,
					     &trans, NULL))
            return;

    tmp = tc = client_getbywin(trans);

    luaA_object_push(globalconf.L, c);
    client_set_type(globalconf.L, -1, WINDOW_TYPE_DIALOG);
    client_set_above(globalconf.L, -1, false);

    /* Verify that there are no loops in the transient_for relation after we are done */
    for(counter = 0; tmp != NULL && counter <= globalconf.stack.len; counter++)
    {
        if (tmp == c)
            /* We arrived back at the client we started from, so there is a loop */
            counter = globalconf.stack.len+1;
        tmp = tmp->transient_for;
    }
    if (counter <= globalconf.stack.len)
        client_set_transient_for(globalconf.L, -1, tc);

    lua_pop(globalconf.L, 1);
}
예제 #6
0
/** Update WM_CLASS of a client.
 * \param c The client.
 * \param reply The reply to get property request, or NULL if none.
 */
void
property_update_wm_class(client_t *c, xcb_get_property_reply_t *reply)
{
    xcb_icccm_get_wm_class_reply_t hint;

    if(reply)
    {
        if(!xcb_icccm_get_wm_class_from_reply(&hint, reply))
            return;
    }
    else
    {
        if(!xcb_icccm_get_wm_class_reply(globalconf.connection,
                                         xcb_icccm_get_wm_class_unchecked(globalconf.connection, c->window),
                                         &hint, NULL))
            return;
    }

    luaA_object_push(globalconf.L, c);
    client_set_class_instance(globalconf.L, -1, hint.class_name, hint.instance_name);
    lua_pop(globalconf.L, 1);

    /* only delete reply if we get it ourselves */
    if(!reply)
        xcb_icccm_get_wm_class_reply_wipe(&hint);
}
예제 #7
0
/** Update the WM hints of a client.
 * \param c The client.
 * \param reply (Optional) An existing reply.
 */
void
property_update_wm_hints(client_t *c, xcb_get_property_reply_t *reply)
{
    xcb_icccm_wm_hints_t wmh;

    if(reply)
    {
        if(!xcb_icccm_get_wm_hints_from_reply(&wmh, reply))
            return;
    }
    else
    {
        if(!xcb_icccm_get_wm_hints_reply(globalconf.connection,
                                         xcb_icccm_get_wm_hints_unchecked(globalconf.connection, c->window),
                                         &wmh, NULL))
            return;
    }

    luaA_object_push(globalconf.L, c);
    client_set_urgent(globalconf.L, -1, xcb_icccm_wm_hints_get_urgency(&wmh));
    if(wmh.flags & XCB_ICCCM_WM_HINT_STATE &&
       wmh.initial_state == XCB_ICCCM_WM_STATE_WITHDRAWN)
        client_set_border_width(globalconf.L, -1, 0);

    if(wmh.flags & XCB_ICCCM_WM_HINT_INPUT)
        c->nofocus = !wmh.input;

    if(wmh.flags & XCB_ICCCM_WM_HINT_WINDOW_GROUP)
        client_set_group_window(globalconf.L, -1, wmh.window_group);

#ifdef LAB126
    /* pop client */
    lua_pop(globalconf.L, 1);
#endif
}
예제 #8
0
void
property_update_wm_transient_for(client_t *c, xcb_get_property_reply_t *reply)
{
    xcb_window_t trans;

    if(reply)
    {
        if(!xcb_icccm_get_wm_transient_for_from_reply(&trans, reply))
            return;
    }
    else
    {
        if(!xcb_icccm_get_wm_transient_for_reply(globalconf.connection,
                                            xcb_icccm_get_wm_transient_for_unchecked(globalconf.connection,
                                                                                     c->window),
                                            &trans, NULL))
            return;
    }

    luaA_object_push(globalconf.L, c);
    client_set_type(globalconf.L, -1, WINDOW_TYPE_DIALOG);
    client_set_above(globalconf.L, -1, false);
    client_set_transient_for(globalconf.L, -1, client_getbywin(trans));
    lua_pop(globalconf.L, 1);
}
예제 #9
0
void
signal_object_emit(lua_State *L, signal_array_t *arr, const char *name, int nargs)
{
    signal_t *sigfound = signal_array_getbyid(arr,
                                              a_strhash((const unsigned char *) name));

    if(sigfound)
    {
        int nbfunc = sigfound->sigfuncs.len;
        luaL_checkstack(L, lua_gettop(L) + nbfunc + nargs + 1, "too much signal");
        /* Push all functions and then execute, because this list can change
         * while executing funcs. */
        foreach(func, sigfound->sigfuncs)
            luaA_object_push(L, (void *) *func);

        for(int i = 0; i < nbfunc; i++)
        {
            /* push all args */
            for(int j = 0; j < nargs; j++)
                lua_pushvalue(L, - nargs - nbfunc + i);
            /* push first function */
            lua_pushvalue(L, - nargs - nbfunc + i);
            /* remove this first function */
            lua_remove(L, - nargs - nbfunc - 1 + i);
            luaA_dofunction(L, nargs, 0);
        }
    }
    /* remove args */
    lua_pop(L, nargs);
}
예제 #10
0
파일: root.c 프로젝트: klug/awesome
/** Get or set global key bindings.
 * This binding will be available when you'll press keys on root window.
 * \param L The Lua VM state.
 * \return The number of element pushed on stack.
 * \luastack
 * \lparam An array of key bindings objects, or nothing.
 * \lreturn The array of key bindings objects of this client.
 */
static int
luaA_root_keys(lua_State *L)
{
    if(lua_gettop(L) == 1)
    {
        luaA_checktable(L, 1);

        foreach(key, globalconf.keys)
            luaA_object_unref(globalconf.L, *key);

        key_array_wipe(&globalconf.keys);
        key_array_init(&globalconf.keys);

        lua_pushnil(L);
        while(lua_next(L, 1))
            key_array_append(&globalconf.keys, luaA_object_ref_class(L, -1, &key_class));

        xcb_screen_t *s = globalconf.screen;
        xcb_ungrab_key(globalconf.connection, XCB_GRAB_ANY, s->root, XCB_BUTTON_MASK_ANY);
        xwindow_grabkeys(s->root, &globalconf.keys);

        return 1;
    }

    lua_createtable(L, globalconf.keys.len, 0);
    for(int i = 0; i < globalconf.keys.len; i++)
    {
        luaA_object_push(L, globalconf.keys.tab[i]);
        lua_rawseti(L, -2, i + 1);
    }

    return 1;
}
예제 #11
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);
    }
}
예제 #12
0
파일: root.c 프로젝트: paul/awesome
/** Get or set global mouse bindings.
 * This binding will be available when you'll click on root window.
 * \param L The Lua VM state.
 * \return The number of element pushed on stack.
 * \luastack
 * \lparam An array of mouse button bindings objects, or nothing.
 * \lreturn The array of mouse button bindings objects.
 */
static int
luaA_root_buttons(lua_State *L)
{
    if(lua_gettop(L) == 1)
    {
        luaA_checktable(L, 1);

        foreach(button, globalconf.buttons)
            luaA_object_unref(globalconf.L, *button);

        button_array_wipe(&globalconf.buttons);
        button_array_init(&globalconf.buttons);

        lua_pushnil(L);
        while(lua_next(L, 1))
            button_array_append(&globalconf.buttons, luaA_object_ref(L, -1));

        return 1;
    }

    lua_createtable(L, globalconf.buttons.len, 0);
    for(int i = 0; i < globalconf.buttons.len; i++)
    {
        luaA_object_push(L, globalconf.buttons.tab[i]);
        lua_rawseti(L, -2, i + 1);
    }

    return 1;
}
예제 #13
0
void
property_update_net_wm_pid(client_t *c,
                           xcb_get_property_reply_t *reply)
{
    bool no_reply = !reply;

    if(no_reply)
    {
        xcb_get_property_cookie_t prop_c =
            xcb_get_property_unchecked(globalconf.connection, false, c->window, _NET_WM_PID, XCB_ATOM_CARDINAL, 0L, 1L);
        reply = xcb_get_property_reply(globalconf.connection, prop_c, NULL);
    }

    if(reply && reply->value_len)
    {
        uint32_t *rdata = xcb_get_property_value(reply);
        if(rdata)
        {
            luaA_object_push(globalconf.L, c);
            client_set_pid(globalconf.L, -1, *rdata);
            lua_pop(globalconf.L, 1);
        }
    }

    if(no_reply)
        p_delete(&reply);
}
예제 #14
0
파일: event.c 프로젝트: 8ware/awesome
/** The client message event handler.
 * \param ev The event.
 */
static void
event_handle_clientmessage(xcb_client_message_event_t *ev)
{
    /* check for startup notification messages */
    if(sn_xcb_display_process_event(globalconf.sndisplay, (xcb_generic_event_t *) ev))
        return;

    if(ev->type == WM_CHANGE_STATE)
    {
        client_t *c;
        if((c = client_getbywin(ev->window))
           && ev->format == 32
           && ev->data.data32[0] == XCB_ICCCM_WM_STATE_ICONIC)
        {
            lua_State *L = globalconf_get_lua_State();
            luaA_object_push(L, c);
            client_set_minimized(L, -1, true);
            lua_pop(L, 1);
        }
    }
    else if(ev->type == _XEMBED)
        xembed_process_client_message(ev);
    else if(ev->type == _NET_SYSTEM_TRAY_OPCODE)
        systray_process_client_message(ev);
    else
        ewmh_process_client_message(ev);
}
예제 #15
0
/** Update the WM hints of a client.
 * \param c The client.
 * \param cookie Cookie returned by property_get_wm_hints.
 */
void
property_update_wm_hints(client_t *c, xcb_get_property_cookie_t cookie)
{
    xcb_icccm_wm_hints_t wmh;

    if(!xcb_icccm_get_wm_hints_reply(globalconf.connection,
				     cookie,
				     &wmh, NULL))
        return;

    luaA_object_push(globalconf.L, c);
    client_set_urgent(globalconf.L, -1, xcb_icccm_wm_hints_get_urgency(&wmh));

    if(wmh.flags & XCB_ICCCM_WM_HINT_INPUT)
        c->nofocus = !wmh.input;

    if(wmh.flags & XCB_ICCCM_WM_HINT_WINDOW_GROUP)
        client_set_group_window(globalconf.L, -1, wmh.window_group);

    if(!c->have_ewmh_icon)
    {
        if(wmh.flags & XCB_ICCCM_WM_HINT_ICON_PIXMAP)
        {
            if(wmh.flags & XCB_ICCCM_WM_HINT_ICON_MASK)
                client_set_icon_from_pixmaps(c, wmh.icon_pixmap, wmh.icon_mask);
            else
                client_set_icon_from_pixmaps(c, wmh.icon_pixmap, XCB_NONE);
        }
        else
            client_set_icon(c, NULL);
    }

    lua_pop(globalconf.L, 1);
}
예제 #16
0
파일: event.c 프로젝트: 8ware/awesome
/** Record that the given drawable contains the pointer.
 */
void
event_drawable_under_mouse(lua_State *L, int ud)
{
    void *d;

    lua_pushvalue(L, ud);
    d = luaA_object_ref(L, -1);

    if (d == globalconf.drawable_under_mouse)
    {
        /* Nothing to do */
        luaA_object_unref(L, d);
        return;
    }

    if (globalconf.drawable_under_mouse != NULL)
    {
        /* Emit leave on previous drawable */
        luaA_object_push(L, globalconf.drawable_under_mouse);
        luaA_object_emit_signal(L, -1, "mouse::leave", 0);
        lua_pop(L, 1);

        /* Unref the previous drawable */
        luaA_object_unref(L, globalconf.drawable_under_mouse);
        globalconf.drawable_under_mouse = NULL;
    }
    if (d != NULL)
    {
        /* Reference the drawable for leave event later */
        globalconf.drawable_under_mouse = d;

        /* Emit enter */
        luaA_object_emit_signal(L, ud, "mouse::enter", 0);
    }
}
예제 #17
0
파일: event.c 프로젝트: 8ware/awesome
/** The key press event handler.
 * \param ev The event.
 */
static void
event_handle_key(xcb_key_press_event_t *ev)
{
    lua_State *L = globalconf_get_lua_State();
    globalconf.timestamp = ev->time;

    if(globalconf.keygrabber != LUA_REFNIL)
    {
        if(keygrabber_handlekpress(L, ev))
        {
            lua_rawgeti(L, LUA_REGISTRYINDEX, globalconf.keygrabber);

            if(!luaA_dofunction(L, 3, 0))
            {
                warn("Stopping keygrabber.");
                luaA_keygrabber_stop(L);
            }
        }
    }
    else
    {
        /* get keysym ignoring all modifiers */
        xcb_keysym_t keysym = xcb_key_symbols_get_keysym(globalconf.keysyms, ev->detail, 0);
        client_t *c;
        if((c = client_getbywin(ev->event)) || (c = client_getbynofocuswin(ev->event)))
        {
            luaA_object_push(L, c);
            event_key_callback(ev, &c->keys, L, -1, 1, &keysym);
        }
        else
            event_key_callback(ev, &globalconf.keys, L, 0, 0, &keysym);
    }
}
예제 #18
0
파일: event.c 프로젝트: 8ware/awesome
/** The leave notify event handler.
 * \param ev The event.
 */
static void
event_handle_leavenotify(xcb_leave_notify_event_t *ev)
{
    lua_State *L = globalconf_get_lua_State();
    client_t *c;

    globalconf.timestamp = ev->time;

    if(ev->mode != XCB_NOTIFY_MODE_NORMAL)
        return;

    /* Ignore leave with detail inferior (we were left for a window contained in
     * our window, so technically the pointer is still inside of this window).
     */
    if(ev->detail != XCB_NOTIFY_DETAIL_INFERIOR && (c = client_getbyframewin(ev->event)))
    {
        luaA_object_push(L, c);
        luaA_object_emit_signal(L, -1, "mouse::leave", 0);
        lua_pop(L, 1);
    }

    lua_pushnil(L);
    event_drawable_under_mouse(L, -1);
    lua_pop(L, 1);
}
예제 #19
0
파일: timer.c 프로젝트: GinoM/awesome
static gboolean
timer_emit_signal(gpointer data)
{
    luaA_object_push(globalconf.L, data);
    luaA_object_emit_signal(globalconf.L, -1, "timeout", 0);
    lua_pop(globalconf.L, 1);
    return TRUE;
}
예제 #20
0
파일: event.c 프로젝트: 8ware/awesome
/** The enter notify event handler.
 * \param ev The event.
 */
static void
event_handle_enternotify(xcb_enter_notify_event_t *ev)
{
    lua_State *L = globalconf_get_lua_State();
    client_t *c;
    drawin_t *drawin;

    globalconf.timestamp = ev->time;

    if(ev->mode != XCB_NOTIFY_MODE_NORMAL)
        return;

    if((drawin = drawin_getbywin(ev->event)))
    {
        luaA_object_push(L, drawin);
        luaA_object_push_item(L, -1, drawin->drawable);
        event_drawable_under_mouse(L, -1);
        lua_pop(L, 2);
    }

    if((c = client_getbyframewin(ev->event)))
    {
        luaA_object_push(L, c);
        /* Ignore enter with detail inferior: The pointer was previously inside
         * of a child window, so technically this isn't a 'real' enter.
         */
        if (ev->detail != XCB_NOTIFY_DETAIL_INFERIOR)
            luaA_object_emit_signal(L, -1, "mouse::enter", 0);

        drawable_t *d = client_get_drawable(c, ev->event_x, ev->event_y);
        if (d)
        {
            luaA_object_push_item(L, -1, d);
            event_drawable_under_mouse(L, -1);
            lua_pop(L, 1);
        }
        lua_pop(L, 1);
    }
    else if (ev->event == globalconf.screen->root) {
        /* When there are multiple X screens with awesome running separate
         * instances, reset focus.
         */
        globalconf.focus.need_update = true;
    }
}
예제 #21
0
파일: event.c 프로젝트: 8ware/awesome
/** The motion notify event handler.
 * \param ev The event.
 */
static void
event_handle_motionnotify(xcb_motion_notify_event_t *ev)
{
    lua_State *L = globalconf_get_lua_State();
    drawin_t *w;
    client_t *c;

    globalconf.timestamp = ev->time;

    if(event_handle_mousegrabber(ev->root_x, ev->root_y, ev->state))
        return;

    if((c = client_getbyframewin(ev->event)))
    {
        luaA_object_push(L, c);
        lua_pushinteger(L, ev->event_x);
        lua_pushinteger(L, ev->event_y);
        luaA_object_emit_signal(L, -3, "mouse::move", 2);

        /* now check if a titlebar was "hit" */
        int x = ev->event_x, y = ev->event_y;
        drawable_t *d = client_get_drawable_offset(c, &x, &y);
        if (d)
        {
            luaA_object_push_item(L, -1, d);
            event_drawable_under_mouse(L, -1);
            lua_pushinteger(L, x);
            lua_pushinteger(L, y);
            luaA_object_emit_signal(L, -3, "mouse::move", 2);
            lua_pop(L, 1);
        }
        lua_pop(L, 1);
    }

    if((w = drawin_getbywin(ev->event)))
    {
        luaA_object_push(L, w);
        luaA_object_push_item(L, -1, w->drawable);
        event_drawable_under_mouse(L, -1);
        lua_pushinteger(L, ev->event_x);
        lua_pushinteger(L, ev->event_y);
        luaA_object_emit_signal(L, -3, "mouse::move", 2);
        lua_pop(L, 2);
    }
}
예제 #22
0
파일: systray.c 프로젝트: mcm3c/configs
/** Update the systray
 * \param L The Lua VM state.
 * \return The number of elements pushed on stack.
 * \luastack
 * \lparam The drawin to display the systray in.
 * \lparam x X position for the systray.
 * \lparam y Y position for the systray.
 * \lparam base_size The size (width and height) each systray item gets.
 * \lparam horiz If true, the systray is horizontal, else vertical.
 * \lparam bg Color of the systray background.
 * \lparam revers If true, the systray icon order will be reversed, else default.
 * \lparam spacing The size of the spacing between icons.
 */
int
luaA_systray(lua_State *L)
{
    systray_register();

    if(lua_gettop(L) != 0)
    {
        size_t bg_len;
        drawin_t *w = luaA_checkudata(L, 1, &drawin_class);
        int x = luaL_checkinteger(L, 2);
        int y = luaL_checkinteger(L, 3);
        int base_size = luaL_checkinteger(L, 4);
        bool horiz = lua_toboolean(L, 5);
        const char *bg = luaL_checklstring(L, 6, &bg_len);
        bool revers = lua_toboolean(L, 7);
        int spacing = luaL_checkinteger(L, 8);
        color_t bg_color;

        if(color_init_reply(color_init_unchecked(&bg_color, bg, bg_len)))
        {
            uint32_t config_back[] = { bg_color.pixel };
            xcb_change_window_attributes(globalconf.connection,
                                         globalconf.systray.window,
                                         XCB_CW_BACK_PIXEL, config_back);
        }

        if(globalconf.systray.parent != w)
            xcb_reparent_window(globalconf.connection,
                                globalconf.systray.window,
                                w->window,
                                x, y);
        else
        {
            uint32_t config_vals[2] = { x, y };
            xcb_configure_window(globalconf.connection,
                                 globalconf.systray.window,
                                 XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y,
                                 config_vals);
        }

        globalconf.systray.parent = w;

        if(globalconf.embedded.len != 0)
        {
            systray_update(base_size, horiz, revers, spacing);
            xcb_map_window(globalconf.connection,
                           globalconf.systray.window);
        }
        else
            xcb_unmap_window(globalconf.connection,
                             globalconf.systray.window);
    }

    lua_pushinteger(L, globalconf.embedded.len);
    luaA_object_push(L, globalconf.systray.parent);
    return 2;
}
예제 #23
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);
}
예제 #24
0
/** Get the client which is under the pointer.
 * \param L The Lua VM state.
 * \return The number of elements pushed on stack.
 * \luastack
 * \lreturn A client or nil.
 */
static int
luaA_mouse_object_under_pointer(lua_State *L)
{
    int16_t mouse_x, mouse_y;
    xcb_window_t child;

    if(!mouse_query_pointer_root(&mouse_x, &mouse_y, &child, NULL))
        return 0;

    drawin_t *drawin;
    client_t *client;

    if((drawin = drawin_getbywin(child)))
        return luaA_object_push(L, drawin);

    if((client = client_getbyframewin(child)))
        return luaA_object_push(globalconf.L, client);

    return 0;
}
예제 #25
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;
        }
}
예제 #26
0
파일: event.c 프로젝트: 8ware/awesome
/** The map request event handler.
 * \param ev The event.
 */
static void
event_handle_maprequest(xcb_map_request_event_t *ev)
{
    client_t *c;
    xcb_get_window_attributes_cookie_t wa_c;
    xcb_get_window_attributes_reply_t *wa_r;
    xcb_get_geometry_cookie_t geom_c;
    xcb_get_geometry_reply_t *geom_r;

    wa_c = xcb_get_window_attributes_unchecked(globalconf.connection, ev->window);

    if(!(wa_r = xcb_get_window_attributes_reply(globalconf.connection, wa_c, NULL)))
        return;

    if(wa_r->override_redirect)
        goto bailout;

    if(xembed_getbywin(&globalconf.embedded, ev->window))
    {
        xcb_map_window(globalconf.connection, ev->window);
        xembed_window_activate(globalconf.connection, ev->window);
    }
    else if((c = client_getbywin(ev->window)))
    {
        /* Check that it may be visible, but not asked to be hidden */
        if(client_on_selected_tags(c) && !c->hidden)
        {
            lua_State *L = globalconf_get_lua_State();
            luaA_object_push(L, c);
            client_set_minimized(L, -1, false);
            lua_pop(L, 1);
            /* it will be raised, so just update ourself */
            client_raise(c);
        }
    }
    else
    {
        geom_c = xcb_get_geometry_unchecked(globalconf.connection, ev->window);

        if(!(geom_r = xcb_get_geometry_reply(globalconf.connection, geom_c, NULL)))
        {
            goto bailout;
        }

        client_manage(ev->window, geom_r, wa_r);

        p_delete(&geom_r);
    }

bailout:
    p_delete(&wa_r);
}
예제 #27
0
파일: root.c 프로젝트: paul/awesome
/** Get the wiboxes attached to a screen.
 * \param L The Lua VM state.
 * \return The number of element pushed on stack.
 * \luastack
 * \lreturn A table with all wiboxes.
 */
static int
luaA_root_wiboxes(lua_State *L)
{
    lua_createtable(L, globalconf.wiboxes.len, 0);

    for(int i = 0; i < globalconf.wiboxes.len; i++)
    {
        luaA_object_push(L, globalconf.wiboxes.tab[i]);
        lua_rawseti(L, -2, i + 1);
    }

    return 1;
}
예제 #28
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);
}
예제 #29
0
파일: event.c 프로젝트: 8ware/awesome
/** The shape notify event handler.
 * \param ev The event.
 */
static void
event_handle_shape_notify(xcb_shape_notify_event_t *ev)
{
    client_t *c = client_getbywin(ev->affected_window);
    if (c)
    {
        lua_State *L = globalconf_get_lua_State();
        luaA_object_push(L, c);
        if (ev->shape_kind == XCB_SHAPE_SK_BOUNDING)
            luaA_object_emit_signal(L, -1, "property::shape_client_bounding", 0);
        if (ev->shape_kind == XCB_SHAPE_SK_CLIP)
            luaA_object_emit_signal(L, -1, "property::shape_client_clip", 0);
        lua_pop(L, 1);
    }
}
예제 #30
0
/** Update WM_CLASS of a client.
 * \param c The client.
 * \param cookie Cookie returned by property_get_wm_class.
 */
void
property_update_wm_class(client_t *c, xcb_get_property_cookie_t cookie)
{
    xcb_icccm_get_wm_class_reply_t hint;

    if(!xcb_icccm_get_wm_class_reply(globalconf.connection,
				     cookie,
				     &hint, NULL))
        return;

    luaA_object_push(globalconf.L, c);
    client_set_class_instance(globalconf.L, -1, hint.class_name, hint.instance_name);
    lua_pop(globalconf.L, 1);

    xcb_icccm_get_wm_class_reply_wipe(&hint);
}