Exemple #1
0
void bar_run(struct bar *bar) {
	int pfds = bar->outputs->length + 2;
	struct pollfd *pfd = malloc(pfds * sizeof(struct pollfd));
	bool dirty = true;

	pfd[0].fd = bar->ipc_event_socketfd;
	pfd[0].events = POLLIN;
	pfd[1].fd = bar->status_read_fd;
	pfd[1].events = POLLIN;

	int i;
	for (i = 0; i < bar->outputs->length; ++i) {
		struct output *output = bar->outputs->items[i];
		pfd[i+2].fd = wl_display_get_fd(output->registry->display);
		pfd[i+2].events = POLLIN;
	}

	while (1) {
		if (dirty) {
			int i;
			for (i = 0; i < bar->outputs->length; ++i) {
				struct output *output = bar->outputs->items[i];
				if (window_prerender(output->window) && output->window->cairo) {
					render(output, bar->config, bar->status);
					window_render(output->window);
					wl_display_flush(output->registry->display);
				}
			}
		}

		dirty = false;

		poll(pfd, pfds, -1);

		if (pfd[0].revents & POLLIN) {
			sway_log(L_DEBUG, "Got IPC event.");
			dirty = handle_ipc_event(bar);
		}

		if (bar->config->status_command && pfd[1].revents & POLLIN) {
			sway_log(L_DEBUG, "Got update from status command.");
			dirty = handle_status_line(bar);
		}

		// dispatch wl_display events
		for (i = 0; i < bar->outputs->length; ++i) {
			struct output *output = bar->outputs->items[i];
			if (pfd[i+2].revents & POLLIN) {
				if (wl_display_dispatch(output->registry->display) == -1) {
					sway_log(L_ERROR, "failed to dispatch wl: %d", errno);
				}
			} else {
				wl_display_dispatch_pending(output->registry->display);
			}
		}
	}
}
Exemple #2
0
void bar_run(struct bar *bar) {
	fd_set readfds;
	int activity;
	bool dirty = true;

	while (1) {
		if (dirty) {
			struct output *output = bar->output;
			if (window_prerender(output->window) && output->window->cairo) {
				render(output, bar->config, bar->status);
				window_render(output->window);
				if (wl_display_dispatch(output->registry->display) == -1) {
					break;
				}
			}
		}

		dirty = false;
		FD_ZERO(&readfds);
		FD_SET(bar->ipc_event_socketfd, &readfds);
		FD_SET(bar->status_read_fd, &readfds);

		activity = select(FD_SETSIZE, &readfds, NULL, NULL, NULL);
		if (activity < 0) {
			sway_log(L_ERROR, "polling failed: %d", errno);
		}

		if (FD_ISSET(bar->ipc_event_socketfd, &readfds)) {
			sway_log(L_DEBUG, "Got IPC event.");
			dirty = handle_ipc_event(bar);
		}

		if (bar->config->status_command && FD_ISSET(bar->status_read_fd, &readfds)) {
			sway_log(L_DEBUG, "Got update from status command.");
			dirty = handle_status_line(bar);
		}
	}
}
Exemple #3
0
/* The main processing function as used by the runner.  */
static gpg_error_t
encfs_handler (void *opaque, runner_t runner, const char *status_line)
{
  encfs_parm_t parm = opaque;
  gpg_error_t err;

  if (!parm || !runner)
    return gpg_error (GPG_ERR_BUG);
  if (!status_line)
    {
      /* Runner requested internal flushing - nothing to do here. */
      return 0;
    }

  err = handle_status_line (runner, status_line, parm->cmd, parm->tuples);
  if (gpg_err_code (err) == GPG_ERR_UNFINISHED
      && gpg_err_source (err) == GPG_ERR_SOURCE_DEFAULT)
    {
      err = 0;
      /* No more need for the tuples.  */
      destroy_tupledesc (parm->tuples);
      parm->tuples = NULL;

      if (parm->cmd == ENCFS_CMD_CREATE)
        {
          /* The encfs tool keeps on running after creation of the
             container.  We don't want that and thus need to stop the
             encfs process. */
          run_umount_helper (parm->mountpoint);
          /* In case the umount helper does not work we try to kill
             the engine.  FIXME: We should figure out how to make
             fusermount work.  */
          runner_cancel (runner);
        }
    }

  return err;
}