/** 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; }
/** Refresh all systrays registrations per physical screen */ void systray_refresh() { int nscreen = xcb_setup_roots_length(xcb_get_setup(globalconf.connection)); for(int phys_screen = 0; phys_screen < nscreen; phys_screen++) { bool has_systray = false; foreach(w, globalconf.wiboxes) if(phys_screen == (*w)->ctx.phys_screen && (*w)->has_systray) /* Can't use "break" with foreach() :( */ has_systray = true; if(has_systray) systray_register(phys_screen); else systray_cleanup(phys_screen); } }