Mirror of Awesome WM window manager
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

luaa.c 36KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346
  1. /*
  2. * luaa.c - Lua configuration management
  3. *
  4. * Copyright © 2008-2009 Julien Danjou <julien@danjou.info>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. */
  21. /** AwesomeWM lifecycle API.
  22. *
  23. * This module contains the functions and signal to manage the lifecycle of the
  24. * AwesomeWM process. It allows to execute code at specific point from the early
  25. * initialization all the way to the last events before exiting or restarting.
  26. *
  27. * Additionally it handles signals for spawn and keyboard related events.
  28. *
  29. * @author Julien Danjou &lt;julien@danjou.info&gt;
  30. * @copyright 2008-2009 Julien Danjou
  31. * @coreclassmod awesome
  32. */
  33. /** Register a new xproperty.
  34. *
  35. * @tparam string name The name of the X11 property.
  36. * @tparam string type One of "string", "number" or "boolean".
  37. * @staticfct register_xproperty
  38. */
  39. #define _GNU_SOURCE
  40. #include "luaa.h"
  41. #include "globalconf.h"
  42. #include "awesome.h"
  43. #include "common/backtrace.h"
  44. #include "common/version.h"
  45. #include "config.h"
  46. #include "event.h"
  47. #include "objects/client.h"
  48. #include "objects/drawable.h"
  49. #include "objects/drawin.h"
  50. #include "objects/selection_getter.h"
  51. #include "objects/screen.h"
  52. #include "objects/selection_acquire.h"
  53. #include "objects/selection_transfer.h"
  54. #include "objects/selection_watcher.h"
  55. #include "objects/tag.h"
  56. #include "property.h"
  57. #include "selection.h"
  58. #include "spawn.h"
  59. #include "systray.h"
  60. #include "xkb.h"
  61. #include "xrdb.h"
  62. #include <lua.h>
  63. #include <lauxlib.h>
  64. #include <lualib.h>
  65. /* for strings and Unicode handling */
  66. #include <glib.h>
  67. #include <stdlib.h>
  68. #include <string.h>
  69. #include <basedir_fs.h>
  70. #include <xcb/xcb_atom.h>
  71. #include <xcb/xcb_aux.h>
  72. #include "xkb_utf32_to_keysym.c"
  73. #include <unistd.h> /* for gethostname() */
  74. #ifdef WITH_DBUS
  75. extern const struct luaL_Reg awesome_dbus_lib[];
  76. #endif
  77. extern const struct luaL_Reg awesome_keygrabber_lib[];
  78. extern const struct luaL_Reg awesome_mousegrabber_lib[];
  79. extern const struct luaL_Reg awesome_mouse_methods[];
  80. extern const struct luaL_Reg awesome_mouse_meta[];
  81. extern const struct luaL_Reg awesome_root_methods[];
  82. extern const struct luaL_Reg awesome_root_meta[];
  83. signal_array_t global_signals;
  84. /** A call into the Lua code aborted with an error.
  85. *
  86. * This signal is used in the example configuration, @{05-awesomerc.md},
  87. * to let a notification box pop up.
  88. * @param err Table with the error object, can be converted to a string with
  89. * `tostring(err)`.
  90. * @signal debug::error
  91. */
  92. /** A deprecated Lua function was called.
  93. *
  94. * @tparam string hint String with a hint on what to use instead of the
  95. * deprecated functionality.
  96. * @tparam[opt=nil] string|nil see The name of the newer API
  97. * @tparam[opt=nil] table|nil args The name of the newer API
  98. * @signal debug::deprecation
  99. */
  100. /** An invalid key was read from an object.
  101. *
  102. * This can happen if `foo` in an `c.foo` access does not exist.
  103. * @param unknown1 Class?
  104. * @param unknown2 Key?
  105. * @signal debug::index::miss
  106. */
  107. /** An invalid key was written to an object.
  108. *
  109. * This can happen if `foo` in an `c.foo = "bar"` assignment doesn't exist.
  110. * @param unknown1 Class?
  111. * @param unknown2 Key?
  112. * @param unknown3 Value?
  113. * @signal debug::newindex::miss
  114. */
  115. /** The systray should be updated.
  116. *
  117. * This signal is used in `wibox.widget.systray`.
  118. * @signal systray::update
  119. */
  120. /** The wallpaper has changed.
  121. *
  122. * This signal is used for pseudo-transparency in `wibox.drawable` if no
  123. * composite manager is running.
  124. * @signal wallpaper_changed
  125. */
  126. /** Keyboard map has changed.
  127. *
  128. * This signal is sent after the new keymap has been loaded. It is used in
  129. * `awful.widget.keyboardlayout` to redraw the layout.
  130. * @signal xkb::map_changed
  131. */
  132. /** Keyboard group has changed.
  133. *
  134. * It's used in `awful.widget.keyboardlayout` to redraw the layout.
  135. * @param group Integer containing the changed group
  136. * @signal xkb::group_changed.
  137. */
  138. /** Refresh.
  139. *
  140. * This signal is emitted as a kind of idle signal in the event loop.
  141. * One example usage is in `gears.timer` to executed delayed calls.
  142. * @signal refresh
  143. */
  144. /** AwesomeWM is about to enter the event loop.
  145. *
  146. * This means all initialization has been done.
  147. * @signal startup
  148. */
  149. /** AwesomeWM is exiting / about to restart.
  150. *
  151. * This signal is emitted in the `atexit` handler as well when awesome
  152. * restarts.
  153. * @param reason_restart Boolean value is true if the signal was sent
  154. * because of a restart.
  155. * @signal exit
  156. */
  157. /** The output status of a screen has changed.
  158. *
  159. * @tparam string output String containing which output has changed.
  160. * @tparam string connection_state String containing the connection status of
  161. * the output: It will be either "Connected", "Disconnected" or
  162. * "Unknown".
  163. * @signal screen::change
  164. */
  165. /** Path to config file */
  166. static char *conffile;
  167. /** Check whether a composite manager is running.
  168. * \return True if such a manager is running.
  169. */
  170. static bool
  171. composite_manager_running(void)
  172. {
  173. xcb_intern_atom_reply_t *atom_r;
  174. xcb_get_selection_owner_reply_t *selection_r;
  175. char *atom_name;
  176. bool result;
  177. if(!(atom_name = xcb_atom_name_by_screen("_NET_WM_CM", globalconf.default_screen)))
  178. {
  179. warn("error getting composite manager atom");
  180. return false;
  181. }
  182. atom_r = xcb_intern_atom_reply(globalconf.connection,
  183. xcb_intern_atom_unchecked(globalconf.connection, false,
  184. a_strlen(atom_name), atom_name),
  185. NULL);
  186. p_delete(&atom_name);
  187. if(!atom_r)
  188. return false;
  189. selection_r = xcb_get_selection_owner_reply(globalconf.connection,
  190. xcb_get_selection_owner_unchecked(globalconf.connection,
  191. atom_r->atom),
  192. NULL);
  193. p_delete(&atom_r);
  194. result = selection_r != NULL && selection_r->owner != XCB_NONE;
  195. p_delete(&selection_r);
  196. return result;
  197. }
  198. /** Quit awesome.
  199. * @tparam[opt=0] integer code The exit code to use when exiting.
  200. * @staticfct quit
  201. */
  202. static int
  203. luaA_quit(lua_State *L)
  204. {
  205. if (!lua_isnoneornil(L, 1))
  206. globalconf.exit_code = luaL_checkinteger(L, 1);
  207. if (globalconf.loop == NULL)
  208. globalconf.loop = g_main_loop_new(NULL, FALSE);
  209. g_main_loop_quit(globalconf.loop);
  210. return 0;
  211. }
  212. /** Execute another application, probably a window manager, to replace
  213. * awesome.
  214. *
  215. * @param cmd The command line to execute.
  216. * @staticfct exec
  217. */
  218. static int
  219. luaA_exec(lua_State *L)
  220. {
  221. const char *cmd = luaL_checkstring(L, 1);
  222. awesome_atexit(false);
  223. a_exec(cmd);
  224. return 0;
  225. }
  226. /** Restart awesome.
  227. * @staticfct restart
  228. */
  229. static int
  230. luaA_restart(lua_State *L)
  231. {
  232. awesome_restart();
  233. return 0;
  234. }
  235. /** Send a signal to a process.
  236. * @tparam integer pid Process identifier. 0 and negative values have special
  237. * meaning. See `man 3 kill`.
  238. * @tparam integer sig Signal number.
  239. * See `awesome.unix_signal` for a list of signals.
  240. * @treturn boolean true if the signal was successfully sent, else false
  241. * @staticfct kill
  242. */
  243. static int
  244. luaA_kill(lua_State *L)
  245. {
  246. int pid = luaL_checknumber(L, 1);
  247. int sig = luaA_checknumber_range(L, 2, 0, INT_MAX);
  248. int result = kill(pid, sig);
  249. lua_pushboolean(L, result == 0);
  250. return 1;
  251. }
  252. /** Synchronize with the X11 server. This is needed in the test suite to avoid
  253. * some race conditions. You should never need to use this function.
  254. * @staticfct sync
  255. */
  256. static int
  257. luaA_sync(lua_State *L)
  258. {
  259. xcb_aux_sync(globalconf.connection);
  260. return 0;
  261. }
  262. /** Translate a GdkPixbuf to a cairo image surface..
  263. *
  264. * @param pixbuf The pixbuf as a light user datum.
  265. * @param path The pixbuf origin path
  266. * @return A cairo surface as light user datum.
  267. * @staticfct pixbuf_to_surface
  268. */
  269. static int
  270. luaA_pixbuf_to_surface(lua_State *L)
  271. {
  272. GdkPixbuf *pixbuf = (GdkPixbuf *) lua_touserdata(L, 1);
  273. cairo_surface_t *surface = draw_surface_from_pixbuf(pixbuf);
  274. /* lua has to make sure to free the ref or we have a leak */
  275. lua_pushlightuserdata(L, surface);
  276. return 1;
  277. }
  278. /** Load an image from a given path.
  279. *
  280. * @param name The file name.
  281. * @return[1] A cairo surface as light user datum.
  282. * @return[2] nil
  283. * @treturn[2] string Error message
  284. * @staticfct load_image
  285. */
  286. static int
  287. luaA_load_image(lua_State *L)
  288. {
  289. /* TODO: Deprecate this function, Lua can use GdkPixbuf directly plus
  290. * awesome.pixbuf_to_surface
  291. */
  292. GError *error = NULL;
  293. const char *filename = luaL_checkstring(L, 1);
  294. cairo_surface_t *surface = draw_load_image(L, filename, &error);
  295. if (!surface) {
  296. lua_pushnil(L);
  297. lua_pushstring(L, error->message);
  298. g_error_free(error);
  299. return 2;
  300. }
  301. /* lua has to make sure to free the ref or we have a leak */
  302. lua_pushlightuserdata(L, surface);
  303. return 1;
  304. }
  305. /** Set the preferred size for client icons.
  306. *
  307. * The closest equal or bigger size is picked if present, otherwise the closest
  308. * smaller size is picked. The default is 0 pixels, ie. the smallest icon.
  309. *
  310. * @param size The size of the icons in pixels.
  311. * @staticfct set_preferred_icon_size
  312. */
  313. static int
  314. luaA_set_preferred_icon_size(lua_State *L)
  315. {
  316. globalconf.preferred_icon_size = luaA_checkinteger_range(L, 1, 0, UINT32_MAX);
  317. return 0;
  318. }
  319. /** UTF-8 aware string length computing.
  320. * \param L The Lua VM state.
  321. * \return The number of elements pushed on stack.
  322. */
  323. static int
  324. luaA_mbstrlen(lua_State *L)
  325. {
  326. const char *cmd = luaL_checkstring(L, 1);
  327. lua_pushinteger(L, (ssize_t) mbstowcs(NULL, NONULL(cmd), 0));
  328. return 1;
  329. }
  330. /** Enhanced type() function which recognize awesome objects.
  331. * \param L The Lua VM state.
  332. * \return The number of arguments pushed on the stack.
  333. */
  334. static int
  335. luaAe_type(lua_State *L)
  336. {
  337. luaL_checkany(L, 1);
  338. lua_pushstring(L, luaA_typename(L, 1));
  339. return 1;
  340. }
  341. /** Replace various standards Lua functions with our own.
  342. * \param L The Lua VM state.
  343. */
  344. static void
  345. luaA_fixups(lua_State *L)
  346. {
  347. /* export string.wlen */
  348. lua_getglobal(L, "string");
  349. lua_pushcfunction(L, luaA_mbstrlen);
  350. lua_setfield(L, -2, "wlen");
  351. lua_pop(L, 1);
  352. /* replace type */
  353. lua_pushcfunction(L, luaAe_type);
  354. lua_setglobal(L, "type");
  355. }
  356. static const char *
  357. get_modifier_name(int map_index)
  358. {
  359. switch (map_index) {
  360. case XCB_MAP_INDEX_SHIFT: return "Shift";
  361. case XCB_MAP_INDEX_LOCK: return "Lock";
  362. case XCB_MAP_INDEX_CONTROL: return "Control";
  363. case XCB_MAP_INDEX_1: return "Mod1"; /* Alt */
  364. case XCB_MAP_INDEX_2: return "Mod2";
  365. case XCB_MAP_INDEX_3: return "Mod3";
  366. case XCB_MAP_INDEX_4: return "Mod4";
  367. case XCB_MAP_INDEX_5: return "Mod5";
  368. }
  369. return 0; /* \0 */
  370. }
  371. /* Helper function for luaA_get_key_name() below.
  372. * Will return the UTF-32 codepoint IF AND ONLY IF the input is exactly one
  373. * valid UTF-8 character. Otherwise, it will return zero.
  374. */
  375. static uint32_t
  376. one_utf8_to_utf32(const char* input, const size_t length) {
  377. gunichar character = g_utf8_get_char_validated(input, length);
  378. // Return 0 if there is more than one UTF-8 character:
  379. if (g_unichar_to_utf8(character, NULL) != (gint)length)
  380. return 0;
  381. // Return 0 if the character is invalid.
  382. if (character == (gunichar)-1 || character == (gunichar)-2)
  383. return 0;
  384. return character;
  385. }
  386. /* Get X11 keysym and a one-character representation from an Awesome keycode.
  387. *
  388. * A "one-character representation" is a single UTF-8 representing the typical
  389. * output from that keysym in a text editor (e.g. " " for space, "ñ" for
  390. * n_tilde, "Ā" for A_macron). It usually matches the main engraving of the key
  391. * for level-0 symbols (but lowercase).
  392. *
  393. * Keycodes may be given in a string in any valid format for `awful.key`:
  394. * "#" + keycode, the symkey name and the UTF-8 representation will all work.
  395. *
  396. * If no suitable keysym is found, or a malformed keycode is given as an
  397. * argument, this function will return (nil, nil)
  398. *
  399. * @treturn[1] string keysym The keysym name
  400. * @treturn[1] nil keysym If no valid keysym is found
  401. * @treturn[2] string printsymbol The xkb_keysym_to_utf8 result
  402. * @treturn[2] nil printsymbol If the keysym has no printable representation.
  403. * @staticfct awful.keyboard.get_key_name
  404. */
  405. static int
  406. luaA_get_key_name(lua_State *L)
  407. {
  408. // check if argument is valid
  409. if (lua_gettop(L) > 1 || lua_type(L, 1) != LUA_TSTRING)
  410. {
  411. return 0;
  412. }
  413. const char* input = luaL_checkstring(L, 1);
  414. const xkb_keysym_t *keysyms;
  415. xkb_keysym_t keysym = XKB_KEY_NoSymbol;
  416. const size_t length = strlen(input);
  417. uint32_t ucs;
  418. /* Checking for the three possible syntaxes awful.key uses:
  419. * 1: #keycode (#8 to #255, any other is invalid)
  420. * 2: the symbol itself (the result of xkb_keysym_to_utf8, e.g. @ for at).
  421. * 3: the keysym
  422. */
  423. if (input[0] == '#' && input[1] != '\0' && length < 5) // syntax #1
  424. {
  425. int keycode_from_hash = atoi(input+1);
  426. // We discard keycodes with invalid values:
  427. const xcb_setup_t *setup = xcb_get_setup(globalconf.connection);
  428. if (keycode_from_hash < setup->min_keycode ||
  429. keycode_from_hash > setup->max_keycode)
  430. return 0;
  431. xkb_keycode_t keycode = (xkb_keycode_t) keycode_from_hash;
  432. struct xkb_keymap *keymap = xkb_state_get_keymap(globalconf.xkb_state);
  433. xkb_keymap_key_get_syms_by_level(keymap, keycode, 0, 0, &keysyms);
  434. keysym = keysyms[0];
  435. }
  436. else if ((ucs = one_utf8_to_utf32(input, length)) > 0) //syntax #2
  437. keysym = xkb_utf32_to_keysym(ucs);
  438. else //syntax #3
  439. keysym = xkb_keysym_from_name(input, XKB_KEYSYM_NO_FLAGS);
  440. if (keysym == XKB_KEY_NoSymbol)
  441. return 0;
  442. else
  443. {
  444. char *name = key_get_keysym_name(keysym);
  445. lua_pushstring(L, name);
  446. char utfname[8];
  447. if (xkb_keysym_to_utf8(keysym, utfname, 8) > 0)
  448. lua_pushstring(L, utfname);
  449. else
  450. return 1; // this will make the second returned value a nil
  451. }
  452. return 2;
  453. }
  454. /* Undocumented */
  455. /*
  456. * The table of keybindings modifiers.
  457. *
  458. * Each modifier has zero to many entries depending on the keyboard layout.
  459. * For example, `Shift` usually both has a left and right variant. Each
  460. * modifier entry has a `keysym` and `keycode` entry. For the US PC 105
  461. * keyboard, it looks like:
  462. *
  463. * awesome.modifiers = {
  464. * Shift = {
  465. * {keycode = 50 , keysym = 'Shift_L' },
  466. * {keycode = 62 , keysym = 'Shift_R' },
  467. * },
  468. * Lock = {},
  469. * Control = {
  470. * {keycode = 37 , keysym = 'Control_L' },
  471. * {keycode = 105, keysym = 'Control_R' },
  472. * },
  473. * Mod1 = {
  474. * {keycode = 64 , keysym = 'Alt_L' },
  475. * {keycode = 108, keysym = 'Alt_R' },
  476. * },
  477. * Mod2 = {
  478. * {keycode = 77 , keysym = 'Num_Lock' },
  479. * },
  480. * Mod3 = {},
  481. * Mod4 = {
  482. * {keycode = 133, keysym = 'Super_L' },
  483. * {keycode = 134, keysym = 'Super_R' },
  484. * },
  485. * Mod5 = {
  486. * {keycode = 203, keysym = 'Mode_switch'},
  487. * },
  488. * };
  489. *
  490. * @tfield table modifiers
  491. * @tparam table modifiers.Shift The Shift modifiers.
  492. * @tparam table modifiers.Lock The Lock modifiers.
  493. * @tparam table modifiers.Control The Control modifiers.
  494. * @tparam table modifiers.Mod1 The Mod1 (Alt) modifiers.
  495. * @tparam table modifiers.Mod2 The Mod2 modifiers.
  496. * @tparam table modifiers.Mod3 The Mod3 modifiers.
  497. * @tparam table modifiers.Mod4 The Mod4 modifiers.
  498. * @tparam table modifiers.Mod5 The Mod5 modifiers.
  499. */
  500. /*
  501. * Modifiers can change over time, given they are currently not tracked, just
  502. * query them each time. Use with moderation.
  503. */
  504. static int luaA_get_modifiers(lua_State *L)
  505. {
  506. xcb_get_modifier_mapping_reply_t *mods = xcb_get_modifier_mapping_reply(globalconf.connection,
  507. xcb_get_modifier_mapping(globalconf.connection), NULL);
  508. if (!mods)
  509. return 0;
  510. xcb_keycode_t *mappings = xcb_get_modifier_mapping_keycodes(mods);
  511. struct xkb_keymap *keymap = xkb_state_get_keymap(globalconf.xkb_state);
  512. lua_newtable(L);
  513. /* This get the MAPPED modifiers, not all of them are */
  514. for (int i = XCB_MAP_INDEX_SHIFT; i <= XCB_MAP_INDEX_5; i++) {
  515. lua_pushstring(L, get_modifier_name(i));
  516. lua_newtable(L);
  517. for (int j = 0; j < mods->keycodes_per_modifier; j++) {
  518. const xkb_keysym_t *keysyms;
  519. const xcb_keycode_t key_code = mappings[i * mods->keycodes_per_modifier + j];
  520. xkb_keymap_key_get_syms_by_level(keymap, key_code, 0, 0, &keysyms);
  521. if (keysyms != NULL) {
  522. /* The +1 because j starts at zero and Lua at 1 */
  523. lua_pushinteger(L, j+1);
  524. lua_newtable(L);
  525. lua_pushstring(L, "keycode");
  526. lua_pushinteger(L, key_code);
  527. lua_settable(L, -3);
  528. /* Technically it is possible to get multiple keysyms here,
  529. * but... we just use the first one.
  530. */
  531. lua_pushstring(L, "keysym");
  532. char *string = key_get_keysym_name(keysyms[0]);
  533. lua_pushstring(L, string);
  534. p_delete(&string);
  535. lua_settable(L, -3);
  536. lua_settable(L, -3);
  537. }
  538. }
  539. lua_settable(L, -3);
  540. }
  541. free(mods);
  542. return 0;
  543. }
  544. /* Undocumented */
  545. /*
  546. * A table with the currently active modifier names.
  547. *
  548. * @tfield table _active_modifiers
  549. */
  550. static int luaA_get_active_modifiers(lua_State *L)
  551. {
  552. int count = 1;
  553. lua_newtable(L);
  554. for (int i = XCB_MAP_INDEX_SHIFT; i <= XCB_MAP_INDEX_5; i++) {
  555. const int active = xkb_state_mod_index_is_active (globalconf.xkb_state, i,
  556. XKB_STATE_MODS_DEPRESSED | XKB_STATE_MODS_EFFECTIVE
  557. );
  558. if (active) {
  559. lua_pushstring(L, get_modifier_name(i));
  560. lua_rawseti(L,-2, count++);
  561. }
  562. }
  563. return 0;
  564. }
  565. /**
  566. * The AwesomeWM version.
  567. * @tfield string version
  568. */
  569. /**
  570. * The AwesomeWM release name.
  571. * @tfield string release
  572. */
  573. /**
  574. * The AwesomeWM API level.
  575. *
  576. * By default, this matches the major version (first component of the version).
  577. *
  578. * API levels are used to allow newer version of AwesomeWM to alter the behavior
  579. * and subset deprecated APIs. Using an older API level than the current major
  580. * version allows to use legacy `rc.lua` with little porting. However, they wont
  581. * be able to use all the new features. Attempting to use a newer feature along
  582. * with an older API level is not and will not be supported, even if it almost
  583. * works. Keeping up to date with the newer API levels is highly recommended.
  584. *
  585. * Going the other direction, setting an higher API level allows to take
  586. * advantage of experimental feature. It will also be much harsher when it comes
  587. * to deprecation. Setting the API level value beyond `current+3` will treat
  588. * using APIs currently pending deprecation as fatal errors. All new code
  589. * submitted to the upstream AwesomeWM codebase is forbidden to use deprecated
  590. * APIs. Testing your patches with mode and the default config is recommended
  591. * before submitting a patch.
  592. *
  593. * You can use the `-l` command line option or `api-level` modeline key to set
  594. * the API level for your `rc.lua`. This setting is global and read only,
  595. * individual modules cannot set their own API level.
  596. *
  597. * @tfield string api_level
  598. */
  599. /**
  600. * The configuration file which has been loaded.
  601. * @tfield string conffile
  602. */
  603. /**
  604. * True if we are still in startup, false otherwise.
  605. * @tfield boolean startup
  606. */
  607. /**
  608. * Error message for errors that occured during
  609. * startup.
  610. * @tfield string startup_errors
  611. */
  612. /**
  613. * True if a composite manager is running.
  614. * @tfield boolean composite_manager_running
  615. */
  616. /**
  617. * Table mapping between signal numbers and signal identifiers.
  618. * @tfield table unix_signal
  619. */
  620. /**
  621. * The hostname of the computer on which we are running.
  622. * @tfield string hostname
  623. */
  624. /**
  625. * The path where themes were installed to.
  626. * @tfield string themes_path
  627. */
  628. /**
  629. * The path where icons were installed to.
  630. * @tfield string icon_path
  631. */
  632. static int
  633. luaA_awesome_index(lua_State *L)
  634. {
  635. if(luaA_usemetatable(L, 1, 2))
  636. return 1;
  637. const char *buf = luaL_checkstring(L, 2);
  638. if(A_STREQ(buf, "conffile"))
  639. {
  640. lua_pushstring(L, conffile);
  641. return 1;
  642. }
  643. if(A_STREQ(buf, "version"))
  644. {
  645. lua_pushstring(L, awesome_version_string());
  646. return 1;
  647. }
  648. if(A_STREQ(buf, "release"))
  649. {
  650. lua_pushstring(L, awesome_release_string());
  651. return 1;
  652. }
  653. if(A_STREQ(buf, "api_level"))
  654. {
  655. lua_pushinteger(L, globalconf.api_level);
  656. return 1;
  657. }
  658. if(A_STREQ(buf, "startup"))
  659. {
  660. lua_pushboolean(L, globalconf.loop == NULL);
  661. return 1;
  662. }
  663. if(A_STREQ(buf, "_modifiers"))
  664. {
  665. luaA_get_modifiers(L);
  666. return 1;
  667. }
  668. if(A_STREQ(buf, "_active_modifiers"))
  669. {
  670. luaA_get_active_modifiers(L);
  671. return 1;
  672. }
  673. if(A_STREQ(buf, "startup_errors"))
  674. {
  675. if (globalconf.startup_errors.len == 0)
  676. return 0;
  677. lua_pushstring(L, globalconf.startup_errors.s);
  678. return 1;
  679. }
  680. if(A_STREQ(buf, "composite_manager_running"))
  681. {
  682. lua_pushboolean(L, composite_manager_running());
  683. return 1;
  684. }
  685. if(A_STREQ(buf, "hostname"))
  686. {
  687. /* No good way to handle failures... */
  688. char hostname[256] = "";
  689. gethostname(&hostname[0], countof(hostname));
  690. hostname[countof(hostname) - 1] = '\0';
  691. lua_pushstring(L, hostname);
  692. return 1;
  693. }
  694. if(A_STREQ(buf, "themes_path"))
  695. {
  696. lua_pushliteral(L, AWESOME_THEMES_PATH);
  697. return 1;
  698. }
  699. if(A_STREQ(buf, "icon_path"))
  700. {
  701. lua_pushliteral(L, AWESOME_ICON_PATH);
  702. return 1;
  703. }
  704. return luaA_default_index(L);
  705. }
  706. /** Add a global signal.
  707. *
  708. * @param name A string with the event name.
  709. * @param func The function to call.
  710. * @staticfct connect_signal
  711. */
  712. static int
  713. luaA_awesome_connect_signal(lua_State *L)
  714. {
  715. const char *name = luaL_checkstring(L, 1);
  716. luaA_checkfunction(L, 2);
  717. signal_connect(&global_signals, name, luaA_object_ref(L, 2));
  718. return 0;
  719. }
  720. /** Remove a global signal.
  721. *
  722. * @param name A string with the event name.
  723. * @param func The function to call.
  724. * @staticfct disconnect_signal
  725. */
  726. static int
  727. luaA_awesome_disconnect_signal(lua_State *L)
  728. {
  729. const char *name = luaL_checkstring(L, 1);
  730. luaA_checkfunction(L, 2);
  731. const void *func = lua_topointer(L, 2);
  732. if (signal_disconnect(&global_signals, name, func))
  733. luaA_object_unref(L, (void *) func);
  734. return 0;
  735. }
  736. /** Emit a global signal.
  737. *
  738. * @param name A string with the event name.
  739. * @param ... The signal arguments.
  740. * @staticfct emit_signal
  741. */
  742. static int
  743. luaA_awesome_emit_signal(lua_State *L)
  744. {
  745. signal_object_emit(L, &global_signals, luaL_checkstring(L, 1), lua_gettop(L) - 1);
  746. return 0;
  747. }
  748. static int
  749. luaA_panic(lua_State *L)
  750. {
  751. warn("unprotected error in call to Lua API (%s)",
  752. lua_tostring(L, -1));
  753. buffer_t buf;
  754. backtrace_get(&buf);
  755. warn("dumping backtrace\n%s", buf.s);
  756. warn("restarting awesome");
  757. awesome_restart();
  758. return 0;
  759. }
  760. #if LUA_VERSION_NUM >= 502
  761. static const char *
  762. luaA_tolstring(lua_State *L, int idx, size_t *len)
  763. {
  764. return luaL_tolstring(L, idx, len);
  765. }
  766. #else
  767. static const char *
  768. luaA_tolstring(lua_State *L, int idx, size_t *len)
  769. {
  770. /* Try using the metatable. If that fails, push the value itself onto
  771. * the stack.
  772. */
  773. if (!luaL_callmeta(L, idx, "__tostring"))
  774. lua_pushvalue(L, idx);
  775. switch (lua_type(L, -1)) {
  776. case LUA_TSTRING:
  777. lua_pushvalue(L, -1);
  778. break;
  779. case LUA_TBOOLEAN:
  780. if (lua_toboolean(L, -1))
  781. lua_pushliteral(L, "true");
  782. else
  783. lua_pushliteral(L, "false");
  784. break;
  785. case LUA_TNUMBER:
  786. lua_pushfstring(L, "%f", lua_tonumber(L, -1));
  787. break;
  788. case LUA_TNIL:
  789. lua_pushstring(L, "nil");
  790. break;
  791. default:
  792. lua_pushfstring(L, "%s: %p",
  793. lua_typename(L, lua_type(L, -1)),
  794. lua_topointer(L, -1));
  795. break;
  796. }
  797. lua_remove(L, -2);
  798. return lua_tolstring(L, -1, len);
  799. }
  800. #endif
  801. static int
  802. luaA_dofunction_on_error(lua_State *L)
  803. {
  804. /* Convert error to string, to prevent a follow-up error with lua_concat. */
  805. luaA_tolstring(L, -1, NULL);
  806. /* duplicate string error */
  807. lua_pushvalue(L, -1);
  808. /* emit error signal */
  809. signal_object_emit(L, &global_signals, "debug::error", 1);
  810. if(!luaL_dostring(L, "return debug.traceback(\"error while running function!\", 3)"))
  811. {
  812. /* Move traceback before error */
  813. lua_insert(L, -2);
  814. /* Insert sentence */
  815. lua_pushliteral(L, "\nerror: ");
  816. /* Move it before error */
  817. lua_insert(L, -2);
  818. lua_concat(L, 3);
  819. }
  820. return 1;
  821. }
  822. static void
  823. setup_awesome_signals(lua_State *L)
  824. {
  825. lua_getglobal(L, "awesome");
  826. lua_pushstring(L, "unix_signal");
  827. lua_newtable(L);
  828. #define SETUP_SIGNAL(sig) \
  829. do { \
  830. /* Set awesome.unix_signal["SIGSTOP"] = 42 */ \
  831. lua_pushinteger(L, sig); \
  832. lua_setfield(L, -2, #sig); \
  833. /* Set awesome.unix_signal[42] = "SIGSTOP" */ \
  834. lua_pushinteger(L, sig); \
  835. lua_pushstring(L, #sig); \
  836. lua_settable(L, -3); \
  837. } while (0)
  838. /* Non-standard signals. These are first so that e.g. (on my system)
  839. * signals[29] is SIGPOLL and not SIGIO (the value gets overwritten).
  840. */
  841. #ifdef SIGIOT
  842. SETUP_SIGNAL(SIGIOT);
  843. #endif
  844. #ifdef SIGEMT
  845. SETUP_SIGNAL(SIGEMT);
  846. #endif
  847. #ifdef SIGSTKFLT
  848. SETUP_SIGNAL(SIGSTKFLT);
  849. #endif
  850. #ifdef SIGIO
  851. SETUP_SIGNAL(SIGIO);
  852. #endif
  853. #ifdef SIGCLD
  854. SETUP_SIGNAL(SIGCLD);
  855. #endif
  856. #ifdef SIGPWR
  857. SETUP_SIGNAL(SIGPWR);
  858. #endif
  859. #ifdef SIGINFO
  860. SETUP_SIGNAL(SIGINFO);
  861. #endif
  862. #ifdef SIGLOST
  863. SETUP_SIGNAL(SIGLOST);
  864. #endif
  865. #ifdef SIGWINCH
  866. SETUP_SIGNAL(SIGWINCH);
  867. #endif
  868. #ifdef SIGUNUSED
  869. SETUP_SIGNAL(SIGUNUSED);
  870. #endif
  871. /* POSIX.1-1990, according to man 7 signal */
  872. SETUP_SIGNAL(SIGHUP);
  873. SETUP_SIGNAL(SIGINT);
  874. SETUP_SIGNAL(SIGQUIT);
  875. SETUP_SIGNAL(SIGILL);
  876. SETUP_SIGNAL(SIGABRT);
  877. SETUP_SIGNAL(SIGFPE);
  878. SETUP_SIGNAL(SIGKILL);
  879. SETUP_SIGNAL(SIGSEGV);
  880. SETUP_SIGNAL(SIGPIPE);
  881. SETUP_SIGNAL(SIGALRM);
  882. SETUP_SIGNAL(SIGTERM);
  883. SETUP_SIGNAL(SIGUSR1);
  884. SETUP_SIGNAL(SIGUSR2);
  885. SETUP_SIGNAL(SIGCHLD);
  886. SETUP_SIGNAL(SIGCONT);
  887. SETUP_SIGNAL(SIGSTOP);
  888. SETUP_SIGNAL(SIGTSTP);
  889. SETUP_SIGNAL(SIGTTIN);
  890. SETUP_SIGNAL(SIGTTOU);
  891. /* POSIX.1-2001, according to man 7 signal */
  892. SETUP_SIGNAL(SIGBUS);
  893. /* Some Operating Systems doesn't have SIGPOLL (e.g. FreeBSD) */
  894. #ifdef SIGPOLL
  895. SETUP_SIGNAL(SIGPOLL);
  896. #endif
  897. SETUP_SIGNAL(SIGPROF);
  898. SETUP_SIGNAL(SIGSYS);
  899. SETUP_SIGNAL(SIGTRAP);
  900. SETUP_SIGNAL(SIGURG);
  901. SETUP_SIGNAL(SIGVTALRM);
  902. SETUP_SIGNAL(SIGXCPU);
  903. SETUP_SIGNAL(SIGXFSZ);
  904. #undef SETUP_SIGNAL
  905. /* Set awesome.signal to the table we just created, key was already pushed */
  906. lua_rawset(L, -3);
  907. /* Pop "awesome" */
  908. lua_pop(L, 1);
  909. }
  910. /* Add things to the string on top of the stack */
  911. static void
  912. add_to_search_path(lua_State *L, string_array_t *searchpath, bool for_lua)
  913. {
  914. if (LUA_TSTRING != lua_type(L, -1))
  915. {
  916. warn("package.path is not a string");
  917. return;
  918. }
  919. foreach(entry, *searchpath)
  920. {
  921. int components;
  922. size_t len = a_strlen(*entry);
  923. lua_pushliteral(L, ";");
  924. lua_pushlstring(L, *entry, len);
  925. if (for_lua)
  926. lua_pushliteral(L, "/?.lua");
  927. else
  928. lua_pushliteral(L, "/?.so");
  929. lua_concat(L, 3);
  930. if (for_lua)
  931. {
  932. lua_pushliteral(L, ";");
  933. lua_pushlstring(L, *entry, len);
  934. lua_pushliteral(L, "/?/init.lua");
  935. lua_concat(L, 3);
  936. components = 2;
  937. } else {
  938. components = 1;
  939. }
  940. lua_concat(L, components + 1); /* concatenate with string on top of the stack */
  941. }
  942. /* add Lua lib path (/usr/share/awesome/lib by default) */
  943. if (for_lua)
  944. {
  945. lua_pushliteral(L, ";" AWESOME_LUA_LIB_PATH "/?.lua");
  946. lua_pushliteral(L, ";" AWESOME_LUA_LIB_PATH "/?/init.lua");
  947. lua_concat(L, 3); /* concatenate with thing on top of the stack when we were called */
  948. } else {
  949. lua_pushliteral(L, ";" AWESOME_LUA_LIB_PATH "/?.so");
  950. lua_concat(L, 2); /* concatenate with thing on top of the stack when we were called */
  951. }
  952. }
  953. /** Initialize the Lua VM
  954. * \param xdg An xdg handle to use to get XDG basedir.
  955. */
  956. void
  957. luaA_init(xdgHandle* xdg, string_array_t *searchpath)
  958. {
  959. lua_State *L;
  960. static const struct luaL_Reg awesome_lib[] =
  961. {
  962. { "quit", luaA_quit },
  963. { "exec", luaA_exec },
  964. { "spawn", luaA_spawn },
  965. { "restart", luaA_restart },
  966. { "connect_signal", luaA_awesome_connect_signal },
  967. { "disconnect_signal", luaA_awesome_disconnect_signal },
  968. { "emit_signal", luaA_awesome_emit_signal },
  969. { "systray", luaA_systray },
  970. { "load_image", luaA_load_image },
  971. { "pixbuf_to_surface", luaA_pixbuf_to_surface },
  972. { "set_preferred_icon_size", luaA_set_preferred_icon_size },
  973. { "register_xproperty", luaA_register_xproperty },
  974. { "set_xproperty", luaA_set_xproperty },
  975. { "get_xproperty", luaA_get_xproperty },
  976. { "__index", luaA_awesome_index },
  977. { "__newindex", luaA_default_newindex },
  978. { "xkb_set_layout_group", luaA_xkb_set_layout_group},
  979. { "xkb_get_layout_group", luaA_xkb_get_layout_group},
  980. { "xkb_get_group_names", luaA_xkb_get_group_names},
  981. { "xrdb_get_value", luaA_xrdb_get_value},
  982. { "kill", luaA_kill},
  983. { "sync", luaA_sync},
  984. { "_get_key_name", luaA_get_key_name},
  985. { NULL, NULL }
  986. };
  987. L = globalconf.L.real_L_dont_use_directly = luaL_newstate();
  988. /* Set panic function */
  989. lua_atpanic(L, luaA_panic);
  990. /* Set error handling function */
  991. lualib_dofunction_on_error = luaA_dofunction_on_error;
  992. luaL_openlibs(L);
  993. luaA_fixups(L);
  994. luaA_object_setup(L);
  995. /* Export awesome lib */
  996. luaA_openlib(L, "awesome", awesome_lib, awesome_lib);
  997. setup_awesome_signals(L);
  998. /* Export root lib */
  999. luaA_openlib(L, "root", awesome_root_methods, awesome_root_meta);
  1000. #ifdef WITH_DBUS
  1001. /* Export D-Bus lib */
  1002. luaA_registerlib(L, "dbus", awesome_dbus_lib);
  1003. lua_pop(L, 1); /* luaA_registerlib() leaves the table on stack */
  1004. #endif
  1005. /* Export keygrabber lib */
  1006. luaA_registerlib(L, "keygrabber", awesome_keygrabber_lib);
  1007. lua_pop(L, 1); /* luaA_registerlib() leaves the table on stack */
  1008. /* Export mousegrabber lib */
  1009. luaA_registerlib(L, "mousegrabber", awesome_mousegrabber_lib);
  1010. lua_pop(L, 1); /* luaA_registerlib() leaves the table on stack */
  1011. /* Export mouse */
  1012. luaA_openlib(L, "mouse", awesome_mouse_methods, awesome_mouse_meta);
  1013. /* Export screen */
  1014. screen_class_setup(L);
  1015. /* Export button */
  1016. button_class_setup(L);
  1017. /* Export tag */
  1018. tag_class_setup(L);
  1019. /* Export window */
  1020. window_class_setup(L);
  1021. /* Export drawable */
  1022. drawable_class_setup(L);
  1023. /* Export drawin */
  1024. drawin_class_setup(L);
  1025. /* Export client */
  1026. client_class_setup(L);
  1027. /* Export selection getter */
  1028. selection_getter_class_setup(L);
  1029. /* Export keys */
  1030. key_class_setup(L);
  1031. /* Export selection acquire */
  1032. selection_acquire_class_setup(L);
  1033. /* Export selection transfer */
  1034. selection_transfer_class_setup(L);
  1035. /* Export selection watcher */
  1036. selection_watcher_class_setup(L);
  1037. /* Setup the selection interface */
  1038. selection_setup(L);
  1039. /* add Lua search paths */
  1040. lua_getglobal(L, "package");
  1041. if (LUA_TTABLE != lua_type(L, 1))
  1042. {
  1043. warn("package is not a table");
  1044. return;
  1045. }
  1046. lua_getfield(L, 1, "path");
  1047. add_to_search_path(L, searchpath, true);
  1048. lua_setfield(L, 1, "path"); /* package.path = "concatenated string" */
  1049. lua_getfield(L, 1, "cpath");
  1050. add_to_search_path(L, searchpath, false);
  1051. lua_setfield(L, 1, "cpath"); /* package.cpath = "concatenated string" */
  1052. lua_pop(L, 1); /* pop "package" */
  1053. }
  1054. static void
  1055. luaA_startup_error(const char *err)
  1056. {
  1057. if (globalconf.startup_errors.len > 0)
  1058. buffer_addsl(&globalconf.startup_errors, "\n\n");
  1059. buffer_adds(&globalconf.startup_errors, err);
  1060. }
  1061. static bool
  1062. luaA_loadrc(const char *confpath)
  1063. {
  1064. lua_State *L = globalconf_get_lua_State();
  1065. if(luaL_loadfile(L, confpath))
  1066. {
  1067. const char *err = lua_tostring(L, -1);
  1068. luaA_startup_error(err);
  1069. fprintf(stderr, "%s\n", err);
  1070. lua_pop(L, 1);
  1071. return false;
  1072. }
  1073. /* Set the conffile right now so it can be used inside the
  1074. * configuration file. */
  1075. conffile = a_strdup(confpath);
  1076. /* Move error handling function before function */
  1077. lua_pushcfunction(L, luaA_dofunction_on_error);
  1078. lua_insert(L, -2);
  1079. if(!lua_pcall(L, 0, 0, -2))
  1080. {
  1081. /* Pop luaA_dofunction_on_error */
  1082. lua_pop(L, 1);
  1083. return true;
  1084. }
  1085. const char *err = lua_tostring(L, -1);
  1086. luaA_startup_error(err);
  1087. fprintf(stderr, "%s\n", err);
  1088. /* An error happened, so reset this. */
  1089. conffile = NULL;
  1090. /* Pop luaA_dofunction_on_error() and the error message */
  1091. lua_pop(L, 2);
  1092. return false;
  1093. }
  1094. /** Load a configuration file.
  1095. * \param xdg An xdg handle to use to get XDG basedir.
  1096. * \param confpatharg The configuration file to load.
  1097. * \param run Run the configuration file.
  1098. */
  1099. bool
  1100. luaA_parserc(xdgHandle* xdg, const char *confpatharg)
  1101. {
  1102. const char *confpath = luaA_find_config(xdg, confpatharg, luaA_loadrc);
  1103. bool ret = confpath != NULL;
  1104. p_delete(&confpath);
  1105. return ret;
  1106. }
  1107. /** Find a config file for which the given callback returns true.
  1108. * \param xdg An xdg handle to use to get XDG basedir.
  1109. * \param confpatharg The configuration file to load.
  1110. * \param callback The callback to call.
  1111. */
  1112. const char *
  1113. luaA_find_config(xdgHandle* xdg, const char *confpatharg, luaA_config_callback *callback)
  1114. {
  1115. char *confpath = NULL;
  1116. if(confpatharg && callback(confpatharg))
  1117. {
  1118. return a_strdup(confpatharg);
  1119. }
  1120. confpath = xdgConfigFind("awesome/rc.lua", xdg);
  1121. char *tmp = confpath;
  1122. /* confpath is "string1\0string2\0string3\0\0" */
  1123. while(*tmp)
  1124. {
  1125. if(callback(tmp))
  1126. {
  1127. const char *ret = a_strdup(tmp);
  1128. p_delete(&confpath);
  1129. return ret;
  1130. }
  1131. tmp += a_strlen(tmp) + 1;
  1132. }
  1133. p_delete(&confpath);
  1134. if(callback(AWESOME_DEFAULT_CONF))
  1135. {
  1136. return a_strdup(AWESOME_DEFAULT_CONF);
  1137. }
  1138. return NULL;
  1139. }
  1140. int
  1141. luaA_class_index_miss_property(lua_State *L, lua_object_t *obj)
  1142. {
  1143. signal_object_emit(L, &global_signals, "debug::index::miss", 2);
  1144. return 0;
  1145. }
  1146. int
  1147. luaA_class_newindex_miss_property(lua_State *L, lua_object_t *obj)
  1148. {
  1149. signal_object_emit(L, &global_signals, "debug::newindex::miss", 3);
  1150. return 0;
  1151. }
  1152. void
  1153. luaA_emit_startup()
  1154. {
  1155. lua_State *L = globalconf_get_lua_State();
  1156. signal_object_emit(L, &global_signals, "startup", 0);
  1157. }
  1158. void
  1159. luaA_emit_refresh()
  1160. {
  1161. lua_State *L = globalconf_get_lua_State();
  1162. signal_object_emit(L, &global_signals, "refresh", 0);
  1163. }
  1164. int
  1165. luaA_default_index(lua_State *L)
  1166. {
  1167. return luaA_class_index_miss_property(L, NULL);
  1168. }
  1169. int
  1170. luaA_default_newindex(lua_State *L)
  1171. {
  1172. return luaA_class_newindex_miss_property(L, NULL);
  1173. }
  1174. // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80