예제 #1
0
pointer
xf86AddGeneralHandler(int fd, InputHandlerProc proc, pointer data)
{
    IHPtr ih = addInputHandler(fd, proc, data);

    if (ih)
        AddGeneralSocket(fd);
    return ih;
}
예제 #2
0
void
xf86EnableGeneralHandler(pointer handler)
{
    IHPtr ih;

    if (!handler)
	return;

    ih = handler;
    ih->enabled = TRUE;
    if (ih->fd >= 0)
	AddGeneralSocket(ih->fd);
}
예제 #3
0
/**
 * Attempt to connect to the system bus, and set a filter to deal with
 * disconnection (see message_filter above).
 *
 * @return 1 on success, 0 on failure.
 */
static int
connect_to_bus(void)
{
    DBusError error;
    struct dbus_core_hook *hook;

    dbus_error_init(&error);
    bus_info.connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
    if (!bus_info.connection || dbus_error_is_set(&error)) {
        LogMessage(X_ERROR, "dbus-core: error connecting to system bus: %s (%s)\n",
               error.name, error.message);
        goto err_begin;
    }

    /* Thankyou.  Really, thankyou. */
    dbus_connection_set_exit_on_disconnect(bus_info.connection, FALSE);

    if (!dbus_connection_get_unix_fd(bus_info.connection, &bus_info.fd)) {
        ErrorF("[dbus-core] couldn't get fd for system bus\n");
        goto err_unref;
    }

    if (!dbus_connection_add_filter(bus_info.connection, message_filter,
                                    &bus_info, NULL)) {
        ErrorF("[dbus-core] couldn't add filter: %s (%s)\n", error.name,
               error.message);
        goto err_fd;
    }

    dbus_error_free(&error);
    AddGeneralSocket(bus_info.fd);

    RegisterBlockAndWakeupHandlers(block_handler, wakeup_handler, &bus_info);

    for (hook = bus_info.hooks; hook; hook = hook->next) {
        if (hook->connect)
            hook->connect(bus_info.connection, hook->data);
    }

    return 1;

 err_fd:
    bus_info.fd = -1;
 err_unref:
    dbus_connection_unref(bus_info.connection);
    bus_info.connection = NULL;
 err_begin:
    dbus_error_free(&error);

    return 0;
}
예제 #4
0
void sna_acpi_init(struct sna *sna)
{
	if (sna->acpi.fd < 0)
		return;

	if (sna->flags & SNA_PERFORMANCE)
		return;

	DBG(("%s: attaching to acpid\n", __FUNCTION__));

	AddGeneralSocket(sna->acpi.fd);
	sna->acpi.remain = sizeof(sna->acpi.event) - 1;
	sna->acpi.offset = 0;

	/* Read initial states */
	if (read_power_state("/sys/class/power_supply") == 0) {
		DBG(("%s: AC adapter is currently offline\n", __FUNCTION__));
		sna->flags |= SNA_POWERSAVE;
	}
}