static int property_handle_xrootpmap_id(uint8_t state, xcb_window_t window) { signal_object_emit(globalconf.L, &global_signals, "wallpaper_changed", 0); return 0; }
gint luaH_class_newindex_miss_property(lua_State *L, lua_object_t *obj) { (void) obj; signal_object_emit(L, globalconf.signals, "debug::newindex::miss", 3); return 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(); }
static void luakit_store_password(SoupURI *soup_uri, const gchar *login, const gchar *password) { lua_State *L = globalconf.L; gchar *uri = soup_uri_to_string(soup_uri, FALSE); lua_pushstring(L, uri); lua_pushstring(L, login); lua_pushstring(L, password); signal_object_emit(L, soup_class.signals, "store-password", 3, 0); g_free(uri); }
static void luakit_find_password(SoupURI *soup_uri, const gchar **login, const gchar **password) { lua_State *L = globalconf.L; gchar *uri = soup_uri_to_string(soup_uri, FALSE); lua_pushstring(L, uri); gint ret = signal_object_emit(L, soup_class.signals, "authenticate", 1, LUA_MULTRET); g_free(uri); if (ret >= 2) { *password = luaL_checkstring(L, -1); *login = luaL_checkstring(L, -2); } lua_pop(L, ret); }
/** XRandR event handler for RRNotify subtype XRROutputChangeNotifyEvent */ static void event_handle_randr_output_change_notify(xcb_randr_notify_event_t *ev) { if(ev->subCode == XCB_RANDR_NOTIFY_OUTPUT_CHANGE) { xcb_randr_output_t output = ev->u.oc.output; uint8_t connection = ev->u.oc.connection; char *output_name = NULL; const char *connection_str = NULL; xcb_randr_get_output_info_reply_t *info = NULL; lua_State *L = globalconf_get_lua_State(); info = xcb_randr_get_output_info_reply(globalconf.connection, xcb_randr_get_output_info_unchecked(globalconf.connection, output, XCB_CURRENT_TIME), NULL); if(!info) return; output_name = p_dup((char *)xcb_randr_get_output_info_name(info), xcb_randr_get_output_info_name_length(info)); switch(connection) { case XCB_RANDR_CONNECTION_CONNECTED: connection_str = "Connected"; break; case XCB_RANDR_CONNECTION_DISCONNECTED: connection_str = "Disconnected"; break; default: connection_str = "Unknown"; break; } lua_pushstring(L, output_name); lua_pushstring(L, connection_str); signal_object_emit(L, &global_signals, "screen::change", 2); p_delete(&output_name); p_delete(&info); /* The docs for RRSetOutputPrimary say we get this signal */ screen_update_primary(); } }
/** Call before exiting. */ void awesome_atexit(bool restart) { lua_pushboolean(globalconf.L, restart); signal_object_emit(globalconf.L, &global_signals, "exit", 1); a_dbus_cleanup(); systray_cleanup(); /* Close Lua */ lua_close(globalconf.L); xcb_flush(globalconf.connection); /* Disconnect *after* closing lua */ xcb_disconnect(globalconf.connection); ev_default_destroy(); }
static int luaA_dofunction_on_error(lua_State *L) { /* duplicate string error */ lua_pushvalue(L, -1); /* emit error signal */ signal_object_emit(L, &global_signals, "debug::error", 1); if(!luaL_dostring(L, "return debug.traceback(\"error while running function\", 3)")) { /* Move traceback before error */ lua_insert(L, -2); /* Insert sentence */ lua_pushliteral(L, "\nerror: "); /* Move it before error */ lua_insert(L, -2); lua_concat(L, 3); } return 1; }
UniqueResponse message_cb(UniqueApp *a, gint id, UniqueMessageData *message_data, guint time, gpointer data) { (void) a; (void) id; (void) time; if (message_data) { lua_State *L = (lua_State*)data; /* get message text */ gchar *text = unique_message_data_get_text(message_data); lua_pushstring(L, text); g_free(text); /* get message screen */ GdkScreen *screen = unique_message_data_get_screen(message_data); lua_pushlightuserdata(L, screen); /* emit signal */ signal_object_emit(L, unique_class.signals, "message", 2, 0); } return UNIQUE_RESPONSE_OK; }
static void request_started(SoupSessionFeature *feature, SoupSession *session, SoupMessage *msg, SoupSocket *socket) { (void) session; (void) socket; SoupCookieJar *sj = SOUP_COOKIE_JAR(feature); SoupURI *uri = soup_message_get_uri(msg); lua_State *L = globalconf.L; /* give user a chance to add cookies from other instances into the jar */ gchar *str = soup_uri_to_string(uri, FALSE); lua_pushstring(L, str); g_free(str); signal_object_emit(L, soupconf.signals, "request-started", 1, 0); /* generate cookie header */ gchar *header = soup_cookie_jar_get_cookies(sj, uri, TRUE); if (header) { soup_message_headers_replace(msg->request_headers, "Cookie", header); g_free(header); } else soup_message_headers_remove(msg->request_headers, "Cookie"); }
/** Emit a global signal. * \param L The Lua VM state. * \return The number of elements pushed on stack. * \luastack * \lparam A string with the event name. * \lparam The function to call. */ static int luaA_awesome_emit_signal(lua_State *L) { signal_object_emit(L, &global_signals, luaL_checkstring(L, 1), lua_gettop(L) - 1); return 0; }
/** Inform lua that the systray needs to be updated. */ void luaA_systray_invalidate(void) { lua_State *L = globalconf_get_lua_State(); signal_object_emit(L, &global_signals, "systray::update", 0); }
/** Inform lua that the systray needs to be updated. */ void luaA_systray_invalidate(void) { signal_object_emit(globalconf.L, &global_signals, "systray::update", 0); }
/* Emit a global signal. * \param L The Lua VM state. * \return The number of elements pushed on stack. * \luastack * \lparam A string with the event name. * \lparam The function to call. */ static gint luaH_luakit_emit_signal(lua_State *L) { signal_object_emit(L, globalconf.signals, luaL_checkstring(L, 1), lua_gettop(L) - 1); return 0; }
/** The property notify event handler handling xproperties. * \param ev The event. */ static void property_handle_propertynotify_xproperty(xcb_property_notify_event_t *ev) { xproperty_t *prop; xproperty_t lookup = { .atom = ev->atom }; buffer_t buf; void *obj; prop = xproperty_array_lookup(&globalconf.xproperties, &lookup); if(!prop) /* Property is not registered */ return; if (ev->window != globalconf.screen->root) { obj = client_getbywin(ev->window); if(!obj) obj = drawin_getbywin(ev->window); if(!obj) return; } else obj = NULL; /* Get us the name of the property */ buffer_inita(&buf, a_strlen(prop->name) + a_strlen("xproperty::") + 1); buffer_addf(&buf, "xproperty::%s", prop->name); /* And emit the right signal */ if (obj) { luaA_object_push(globalconf.L, obj); luaA_object_emit_signal(globalconf.L, -1, buf.s, 0); lua_pop(globalconf.L, 1); } else signal_object_emit(globalconf.L, &global_signals, buf.s, 0); buffer_wipe(&buf); } /** The property notify event handler. * \param ev The event. */ void property_handle_propertynotify(xcb_property_notify_event_t *ev) { int (*handler)(uint8_t state, xcb_window_t window) = NULL; globalconf.timestamp = ev->time; property_handle_propertynotify_xproperty(ev); /* Find the correct event handler */ #define HANDLE(atom_, cb) \ if (ev->atom == atom_) \ { \ handler = cb; \ } else #define END return /* Xembed stuff */ HANDLE(_XEMBED_INFO, property_handle_xembed_info) /* ICCCM stuff */ HANDLE(XCB_ATOM_WM_TRANSIENT_FOR, property_handle_wm_transient_for) HANDLE(WM_CLIENT_LEADER, property_handle_wm_client_leader) HANDLE(XCB_ATOM_WM_NORMAL_HINTS, property_handle_wm_normal_hints) HANDLE(XCB_ATOM_WM_HINTS, property_handle_wm_hints) HANDLE(XCB_ATOM_WM_NAME, property_handle_wm_name) HANDLE(XCB_ATOM_WM_ICON_NAME, property_handle_wm_icon_name) HANDLE(XCB_ATOM_WM_CLASS, property_handle_wm_class) HANDLE(WM_PROTOCOLS, property_handle_wm_protocols) HANDLE(XCB_ATOM_WM_CLIENT_MACHINE, property_handle_wm_client_machine) HANDLE(WM_WINDOW_ROLE, property_handle_wm_window_role) /* EWMH stuff */ HANDLE(_NET_WM_NAME, property_handle_net_wm_name) HANDLE(_NET_WM_ICON_NAME, property_handle_net_wm_icon_name) HANDLE(_NET_WM_STRUT_PARTIAL, property_handle_net_wm_strut_partial) HANDLE(_NET_WM_ICON, property_handle_net_wm_icon) HANDLE(_NET_WM_PID, property_handle_net_wm_pid) HANDLE(_NET_WM_WINDOW_OPACITY, property_handle_net_wm_opacity) /* background change */ HANDLE(_XROOTPMAP_ID, property_handle_xrootpmap_id) /* If nothing was found, return */ END; #undef HANDLE #undef END (*handler)(ev->state, ev->window); }
void luaA_emit_refresh() { lua_State *L = globalconf_get_lua_State(); signal_object_emit(L, &global_signals, "refresh", 0); }
void luaA_emit_refresh() { signal_object_emit(globalconf.L, &global_signals, "refresh", 0); }
int luaA_class_newindex_miss_property(lua_State *L, lua_object_t *obj) { signal_object_emit(L, &global_signals, "debug::newindex::miss", 3); return 0; }
void luaA_emit_startup() { lua_State *L = globalconf_get_lua_State(); signal_object_emit(L, &global_signals, "startup", 0); }