예제 #1
0
파일: launcher.c 프로젝트: Blei/weston
static int
weston_xserver_handle_event(int listen_fd, uint32_t mask, void *data)
{
	struct weston_xserver *mxs = data;
	char display[8], s[8];
	int sv[2], client_fd;

	if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, sv) < 0) {
		weston_log("socketpair failed\n");
		return 1;
	}

	mxs->process.pid = fork();
	switch (mxs->process.pid) {
	case 0:
		/* SOCK_CLOEXEC closes both ends, so we need to unset
		 * the flag on the client fd. */
		client_fd = dup(sv[1]);
		if (client_fd < 0)
			return 1;

		snprintf(s, sizeof s, "%d", client_fd);
		setenv("WAYLAND_SOCKET", s, 1);

		snprintf(display, sizeof display, ":%d", mxs->display);

		if (execl(XSERVER_PATH,
			  XSERVER_PATH,
			  display,
			  "-wayland",
			  "-rootless",
			  "-retro",
			  "-nolisten", "all",
			  "-terminate",
			  NULL) < 0)
			weston_log("exec failed: %m\n");
		exit(-1);

	default:
		weston_log("forked X server, pid %d\n", mxs->process.pid);

		close(sv[1]);
		mxs->client = wl_client_create(mxs->wl_display, sv[0]);

		weston_watch_process(&mxs->process);

		wl_event_source_remove(mxs->abstract_source);
		wl_event_source_remove(mxs->unix_source);
		break;

	case -1:
		weston_log( "failed to fork\n");
		break;
	}

	return 1;
}
예제 #2
0
파일: tty.c 프로젝트: anderco/weston
void
tty_destroy(struct tty *tty)
{
	if (tty->input_source)
		wl_event_source_remove(tty->input_source);

	wl_event_source_remove(tty->vt_source);

	tty_reset(tty);

	close(tty->fd);

	free(tty);
}
예제 #3
0
파일: tty.c 프로젝트: N8Fear/adwc
void
tty_destroy(struct tty *tty)
{
	struct vt_mode mode = { 0 };

        if(!tty)
                return;

	if (ioctl(tty->fd, KDSKBMODE, tty->kb_mode))
		fprintf(stderr, "failed to restore keyboard mode: %m\n");

	if (ioctl(tty->fd, KDSETMODE, KD_TEXT))
		fprintf(stderr,
			"failed to set KD_TEXT mode on tty: %m\n");

	if (tcsetattr(tty->fd, TCSANOW, &tty->terminal_attributes) < 0)
		fprintf(stderr,
			"could not restore terminal to canonical mode\n");

	mode.mode = VT_AUTO;
	if (ioctl(tty->fd, VT_SETMODE, &mode) < 0)
		fprintf(stderr, "could not reset vt handling\n");

	if (tty->has_vt && tty->vt != tty->starting_vt) {
		ioctl(tty->fd, VT_ACTIVATE, tty->starting_vt);
		ioctl(tty->fd, VT_WAITACTIVE, tty->starting_vt);
	}

	wl_event_source_remove(tty->vt_source);

	close(tty->fd);

	free(tty);
}
예제 #4
0
static int
clipboard_source_data(int fd, uint32_t mask, void *data)
{
	struct clipboard_source *source = data;
	struct clipboard *clipboard = source->clipboard;
	char *p;
	int len, size;

	if (source->contents.alloc - source->contents.size < 1024) {
		wl_array_add(&source->contents, 1024);
		source->contents.size -= 1024;
	}

	p = source->contents.data + source->contents.size;
	size = source->contents.alloc - source->contents.size;
	len = read(fd, p, size);
	if (len == 0) {
		wl_event_source_remove(source->event_source);
		close(fd);
		source->event_source = NULL;
	} else if (len < 0) {
		clipboard_source_unref(source);
		clipboard->source = NULL;
	} else {
		source->contents.size += len;
	}

	return 1;
}
예제 #5
0
static int
writable_callback(int fd, uint32_t mask, void *data)
{
	struct weston_wm *wm = data;
	unsigned char *property;
	int len, remainder;

	property = xcb_get_property_value(wm->property_reply);
	remainder = xcb_get_property_value_length(wm->property_reply) -
		wm->property_start;

	len = write(fd, property + wm->property_start, remainder);
	if (len == -1) {
		free(wm->property_reply);
		wm->property_reply = NULL;
		if (wm->property_source)
			wl_event_source_remove(wm->property_source);
		wm->property_source = NULL;
		close(fd);
		weston_log("write error to target fd: %m\n");
		return 1;
	}

	weston_log("wrote %d (chunk size %d) of %d bytes\n",
		wm->property_start + len,
		len, xcb_get_property_value_length(wm->property_reply));

	wm->property_start += len;
	if (len == remainder) {
		free(wm->property_reply);
		wm->property_reply = NULL;
		if (wm->property_source)
			wl_event_source_remove(wm->property_source);
		wm->property_source = NULL;

		if (wm->incr) {
			xcb_delete_property(wm->conn,
					    wm->selection_window,
					    wm->atom.wl_selection);
		} else {
			weston_log("transfer complete\n");
			close(fd);
		}
	}

	return 1;
}
예제 #6
0
파일: wlc.c 프로젝트: scarabeusiv/wlc
WLC_API void
wlc_event_source_remove(struct wlc_event_source *source)
{
   assert(source);

   if (wlc.display)
      wl_event_source_remove((struct wl_event_source*)source);
}
예제 #7
0
파일: dbus.c 프로젝트: ChristophHaag/weston
static void weston_dbus_unbind(DBusConnection *c, struct wl_event_source *ctx)
{
	dbus_connection_set_timeout_functions(c, NULL, NULL, NULL,
					      NULL, NULL);
	dbus_connection_set_watch_functions(c, NULL, NULL, NULL,
					    NULL, NULL);
	dbus_connection_unref(c);
	wl_event_source_remove(ctx);
}
예제 #8
0
파일: dbus.c 프로젝트: ChristophHaag/weston
static int weston_dbus_bind(struct wl_event_loop *loop, DBusConnection *c,
			    struct wl_event_source **ctx_out)
{
	bool b;
	int r, fd;

	/* Idle events cannot reschedule themselves, therefore we use a dummy
	 * event-fd and mark it for post-dispatch. Hence, the dbus
	 * dispatcher is called after every dispatch-round.
	 * This is required as dbus doesn't allow dispatching events from
	 * within its own event sources. */
	fd = eventfd(0, EFD_CLOEXEC);
	if (fd < 0)
		return -errno;

	*ctx_out = wl_event_loop_add_fd(loop, fd, 0, weston_dbus_dispatch, c);
	close(fd);

	if (!*ctx_out)
		return -ENOMEM;

	wl_event_source_check(*ctx_out);

	b = dbus_connection_set_watch_functions(c,
						weston_dbus_add_watch,
						weston_dbus_remove_watch,
						weston_dbus_toggle_watch,
						loop,
						NULL);
	if (!b) {
		r = -ENOMEM;
		goto error;
	}

	b = dbus_connection_set_timeout_functions(c,
						  weston_dbus_add_timeout,
						  weston_dbus_remove_timeout,
						  weston_dbus_toggle_timeout,
						  loop,
						  NULL);
	if (!b) {
		r = -ENOMEM;
		goto error;
	}

	dbus_connection_ref(c);
	return 0;

error:
	dbus_connection_set_timeout_functions(c, NULL, NULL, NULL,
					      NULL, NULL);
	dbus_connection_set_watch_functions(c, NULL, NULL, NULL,
					    NULL, NULL);
	wl_event_source_remove(*ctx_out);
	*ctx_out = NULL;
	return r;
}
예제 #9
0
파일: drm.c 프로젝트: ibab/swc
void swc_drm_finalize()
{
    if (drm.global)
        wl_global_destroy(drm.global);
    wl_event_source_remove(drm.event_source);
    wld_destroy_renderer(swc.drm->renderer);
    wld_destroy_context(swc.drm->context);
    close(swc.drm->fd);
}
예제 #10
0
void
weston_launcher_destroy(struct weston_launcher *launcher)
{
	if (launcher->logind) {
		weston_logind_destroy(launcher->logind);
	} else if (launcher->fd != -1) {
		close(launcher->fd);
		wl_event_source_remove(launcher->source);
	} else {
		weston_launcher_restore(launcher);
		wl_event_source_remove(launcher->vt_source);
	}

	if (launcher->tty >= 0)
		close(launcher->tty);

	free(launcher);
}
예제 #11
0
static void
headless_output_destroy(struct weston_output *output_base)
{
	struct headless_output *output = (struct headless_output *) output_base;

	wl_event_source_remove(output->finish_frame_timer);
	free(output);

	return;
}
예제 #12
0
파일: launcher.c 프로젝트: Blei/weston
static void
weston_xserver_shutdown(struct weston_xserver *wxs)
{
	char path[256];

	snprintf(path, sizeof path, "/tmp/.X%d-lock", wxs->display);
	unlink(path);
	snprintf(path, sizeof path, "/tmp/.X11-unix/X%d", wxs->display);
	unlink(path);
	if (wxs->process.pid == 0) {
		wl_event_source_remove(wxs->abstract_source);
		wl_event_source_remove(wxs->unix_source);
	}
	close(wxs->abstract_fd);
	close(wxs->unix_fd);
	if (wxs->wm)
		weston_wm_destroy(wxs->wm);
	wxs->loop = NULL;
}
예제 #13
0
파일: dbus.c 프로젝트: ChristophHaag/weston
static void weston_dbus_remove_timeout(DBusTimeout *timeout, void *data)
{
	struct wl_event_source *s;

	s = dbus_timeout_get_data(timeout);
	if (!s)
		return;

	wl_event_source_remove(s);
}
예제 #14
0
파일: dbus.c 프로젝트: ChristophHaag/weston
static void weston_dbus_remove_watch(DBusWatch *watch, void *data)
{
	struct wl_event_source *s;

	s = dbus_watch_get_data(watch);
	if (!s)
		return;

	wl_event_source_remove(s);
}
예제 #15
0
static int
free_source_callback(int fd, uint32_t mask, void *data)
{
	struct free_source_context *context = data;

	context->count++;

	/* Remove other source */
	if (fd == context->p1[0]) {
		wl_event_source_remove(context->source2);
		context->source2 = NULL;
	} else if (fd == context->p2[0]) {
		wl_event_source_remove(context->source1);
		context->source1 = NULL;
	} else {
		assert(0);
	}

	return 1;
}
예제 #16
0
파일: dbus.cpp 프로젝트: nyorain/iro
void DBusHandler::Callbacks::removeTimeout(DBusTimeout* timeout, void* data)
{
	wl_event_source* s = (wl_event_source*) dbus_timeout_get_data(timeout);
    if(!s)
    {
		ny::sendWarning("dbusRemoveTimeout: dbus timeout has no data");
        return;
    }

    wl_event_source_remove(s);
}
예제 #17
0
파일: dbus.cpp 프로젝트: nyorain/iro
void DBusHandler::Callbacks::removeWatch(DBusWatch* watch, void* data)
{
   wl_event_source* s = nullptr;
   if (!(s = (wl_event_source*) dbus_watch_get_data(watch)))
   {
		ny::sendWarning("dbusRemoveWatch: dbus watch has no data");
        return;
   }

   wl_event_source_remove(s);
}
예제 #18
0
파일: main.cpp 프로젝트: nyorain/iro
void idleSwitch(void* data)
{
    if(!idleSwitchSource || !data || !vtSwitchTo) return;

    auto* th = static_cast<iro::TerminalHandler*>(data);
    th->activate(vtSwitchTo);
    vtSwitchTo = 0;

    wl_event_source_remove(idleSwitchSource);
    idleSwitchSource = 0;
}
예제 #19
0
파일: udev.c 프로젝트: Azarn/wlc
static bool
input_set_event_loop(struct wl_event_loop *loop)
{
   if (input.event_source) {
      wl_event_source_remove(input.event_source);
      input.event_source = NULL;
   }

   if (input.handle && loop && !(input.event_source = wl_event_loop_add_fd(loop, libinput_get_fd(input.handle), WL_EVENT_READABLE, input_event, &input)))
      return false;
   return true;
}
예제 #20
0
WL_EXPORT void
wl_event_loop_dispatch_idle(struct wl_event_loop *loop)
{
	struct wl_event_source_idle *source;

	while (!wl_list_empty(&loop->idle_list)) {
		source = container_of(loop->idle_list.next,
				      struct wl_event_source_idle, base.link);
		source->func(source->base.data);
		wl_event_source_remove(&source->base);
	}
}
예제 #21
0
static int
handle_sigusr1(int signal_number, void *data)
{
	struct weston_xserver *wxs = data;

	/* We'd be safer if we actually had the struct
	 * signalfd_siginfo from the signalfd data and could verify
	 * this came from Xwayland.*/
	wxs->wm = weston_wm_create(wxs, wxs->wm_fd);
	wl_event_source_remove(wxs->sigusr1_source);

	return 1;
}
예제 #22
0
static void
launcher_direct_destroy(struct weston_launcher *launcher_base)
{
	struct launcher_direct *launcher = wl_container_of(launcher_base, launcher, base);

	launcher_direct_restore(&launcher->base);
	wl_event_source_remove(launcher->vt_source);

	if (launcher->tty >= 0)
		close(launcher->tty);

	free(launcher);
}
예제 #23
0
파일: x11.cpp 프로젝트: nyorain/iro
X11Backend::~X11Backend()
{
	for(auto& outp : outputs_)
		destroyOutput(*outp);

	if(eglContext_)
	{
		eglContext_->unbindWlDisplay(compositor_->wlDisplay());
		eglContext_.reset();
	}

    if(inputEventSource_)wl_event_source_remove(inputEventSource_);
	if(xDisplay_) XCloseDisplay(xDisplay_);
}
예제 #24
0
static void
weston_compositor_destroy_listener(struct wl_listener *listener, void *data)
{
	struct systemd_notifier *notifier;

	sd_notify(0, "STOPPING=1");

	notifier = container_of(listener,
				struct systemd_notifier,
				compositor_destroy_listener);

	if (notifier->watchdog_source)
		wl_event_source_remove(notifier->watchdog_source);

	wl_list_remove(&notifier->compositor_destroy_listener.link);
	free(notifier);
}
예제 #25
0
파일: evdev.c 프로젝트: anderco/weston
void
evdev_device_destroy(struct evdev_device *device)
{
	struct evdev_dispatch *dispatch;

	dispatch = device->dispatch;
	if (dispatch)
		dispatch->interface->destroy(dispatch);

	wl_event_source_remove(device->source);
	wl_list_remove(&device->link);
	if (device->mtdev)
		mtdev_close_delete(device->mtdev);
	close(device->fd);
	free(device->devname);
	free(device->devnode);
	free(device);
}
예제 #26
0
파일: clipboard.c 프로젝트: anderco/weston
static void
clipboard_source_unref(struct clipboard_source *source)
{
	char **s;

	source->refcount--;
	if (source->refcount > 0)
		return;

	if (source->event_source)
		wl_event_source_remove(source->event_source);
	wl_signal_emit(&source->base.resource.destroy_signal,
		       &source->base.resource);
	s = source->base.mime_types.data;
	free(*s);
	wl_array_release(&source->base.mime_types);
	wl_array_release(&source->contents);
	free(source);
}
예제 #27
0
파일: dbus.c 프로젝트: ChristophHaag/weston
static dbus_bool_t weston_dbus_add_timeout(DBusTimeout *timeout, void *data)
{
	struct wl_event_loop *loop = data;
	struct wl_event_source *s;
	int r;

	s = wl_event_loop_add_timer(loop, weston_dbus_dispatch_timeout,
				    timeout);
	if (!s)
		return FALSE;

	r = weston_dbus_adjust_timeout(timeout, s);
	if (r < 0) {
		wl_event_source_remove(s);
		return FALSE;
	}

	dbus_timeout_set_data(timeout, s, NULL);
	return TRUE;
}
예제 #28
0
static void
headless_output_destroy(struct weston_output *output_base)
{
	struct headless_output *output = (struct headless_output *) output_base;
	struct headless_backend *b =
			(struct headless_backend *) output->base.compositor->backend;

	wl_event_source_remove(output->finish_frame_timer);

	if (b->use_pixman) {
		pixman_renderer_output_destroy(&output->base);
		pixman_image_unref(output->image);
		free(output->image_buf);
	}

	weston_output_destroy(&output->base);

	free(output);

	return;
}
예제 #29
0
파일: dbus.cpp 프로젝트: nyorain/iro
unsigned int DBusHandler::Callbacks::addTimeout(DBusTimeout* timeout, void* data)
{
	if(!data) return 0;
	auto& loop = static_cast<DBusHandler*>(data)->compositor().wlEventLoop();

    wl_event_source* source;
    if(!(source = wl_event_loop_add_timer(&loop, dispatchTimeout, timeout)))
    {
		ny::sendWarning("dbusAddTimeout: failed to add wl_event_loop_timer");
        return 0;
    }

    if(adjustTimeout(timeout, source) < 0)
    {
		ny::sendWarning("dbusAddTimeout: failed to adjust timeout");
        wl_event_source_remove(source);
        return 0;
    }

    dbus_timeout_set_data(timeout, source, nullptr);
    return true;
}
예제 #30
0
WaylandInputEvent::~WaylandInputEvent()
{
    if (!m_wlEventSource)
        wl_event_source_remove(m_wlEventSource);

    if (m_xkbInfo.keymap)
        xkb_map_unref(m_xkbInfo.keymap);

    if (m_xkbInfo.keymap_area)
        munmap(m_xkbInfo.keymap_area, m_xkbInfo.keymap_size);

    if (m_xkbInfo.keymap_fd >= 0)
        close(m_xkbInfo.keymap_fd);

    xkb_context_unref(m_xkbContext);

    free((char*)m_xkbNames.rules);
    free((char*)m_xkbNames.model);
    free((char*)m_xkbNames.layout);
    free((char*)m_xkbNames.variant);
    free((char*)m_xkbNames.options);
}