Exemplo n.º 1
0
int main(int argc, char **argv) {

    display = wl_display_connect(NULL);
    if (display == NULL) {
        fprintf(stderr, "Can't connect to display\n");
        exit(1);
    }
    printf("connected to display\n");

    struct wl_registry *registry = wl_display_get_registry(display);
    wl_registry_add_listener(registry, &registry_listener, NULL);

    wl_display_dispatch(display);
    wl_display_roundtrip(display);

    if (compositor == NULL) {
        fprintf(stderr, "Can't find compositor\n");
        exit(1);
    } else {
        fprintf(stderr, "Found compositor\n");
    }

    surface = wl_compositor_create_surface(compositor);
    if (surface == NULL) {
        fprintf(stderr, "Can't create surface\n");
        exit(1);
    } else {
        fprintf(stderr, "Created surface\n");
    }

    shell_surface = wl_shell_get_shell_surface(shell, surface);
    if (shell_surface == NULL) {
        fprintf(stderr, "Can't create shell surface\n");
        exit(1);
    } else {
        fprintf(stderr, "Created shell surface\n");
    }
    wl_shell_surface_set_toplevel(shell_surface);

    wl_shell_surface_add_listener(shell_surface,
                                  &shell_surface_listener, NULL);


    create_window();
    paint_pixels();

    while (wl_display_dispatch(display) != -1) {
        ;
    }

    wl_display_disconnect(display);
    printf("disconnected from display\n");

    exit(0);
}
Exemplo n.º 2
0
int main(int argc, char *argv[])
{
	struct display *display;
	char buf[256], *p;
	int ret, fd;

	display = malloc(sizeof *display);
	assert(display);

	display->display = wl_display_connect(NULL);
	assert(display->display);

	display->registry = wl_display_get_registry(display->display);
	wl_registry_add_listener(display->registry,
				 &registry_listener, display);
	wl_display_dispatch(display->display);
	wl_display_dispatch(display->display);

	fd = 0;
	p = getenv("TEST_SOCKET");
	if (p)
		fd = strtol(p, NULL, 0);

	while (1) {
		ret = read(fd, buf, sizeof buf);
		if (ret == -1) {
			fprintf(stderr, "test-client: read error: fd %d, %m\n",
				fd);
			return -1;
		}

		fprintf(stderr, "test-client: got %.*s\n", ret - 1, buf);

		if (strncmp(buf, "bye\n", ret) == 0) {
			return 0;
		} else if (strncmp(buf, "create-surface\n", ret) == 0) {
			create_surface(fd, display);
		} else if (strncmp(buf, "send-state\n", ret) == 0) {
			send_state(fd, display);
		} else if (strncmp(buf, "send-button-state\n", ret) == 0) {
			send_button_state(fd, display);
		} else if (strncmp(buf, "send-keyboard-state\n", ret) == 0) {
			send_keyboard_state(fd, display);
		} else {
			fprintf(stderr, "test-client: unknown command %.*s\n",
				ret, buf);
			return -1;
		}
	}

	assert(0);
}
Exemplo n.º 3
0
	xdl_int initWayland() {

		//
		// Connect to the Wayland server.
		//
		display = wl_display_connect(nullptr);
		if(display == nullptr) {
			std::cerr << "## XdevLWindowWayland::wl_display_connect failed" << std::endl;
			return xdl::ERR_ERROR;
		}

		// We get the registry for the window which holds extension
		// of the wayland server.
		m_registry = wl_display_get_registry(display);
		if(m_registry == nullptr) {
			std::cerr << "## XdevLWindowWayland::wl_display_get_registry failed" << std::endl;
			return ERR_ERROR;
		}

		// Now we tell the registry that we want to listen to events.
		wl_registry_add_listener(m_registry, &registry_listener, nullptr);
		wl_display_dispatch(display);

		return ERR_OK;
	}
Exemplo n.º 4
0
int
main(int argc, char **argv)
{
	struct sigaction sigint;
	struct display *display;
	struct window *window;
	int ret = 0;

	display = create_display();
	window = create_window(display, 250, 250);
	if (!window)
		return 1;

	sigint.sa_handler = signal_int;
	sigemptyset(&sigint.sa_mask);
	sigint.sa_flags = SA_RESETHAND;
	sigaction(SIGINT, &sigint, NULL);

	/* Initialise damage to full surface, so the padding gets painted */
	wl_surface_damage(window->surface, 0, 0,
			  window->width, window->height);

	redraw(window, NULL, 0);

	while (running && ret != -1)
		ret = wl_display_dispatch(display->display);

	fprintf(stderr, "simple-dmabuf exiting\n");
	destroy_window(window);
	destroy_display(display);

	return 0;
}
Exemplo n.º 5
0
WaylandEventQueue::WaylandEventQueue(IOLoop &_io_loop, EventQueue &_queue)
  :io_loop(_io_loop), queue(_queue),
   display(wl_display_connect(nullptr))
{
  if (display == nullptr) {
    fprintf(stderr, "wl_display_connect() failed\n");
    exit(EXIT_FAILURE);
  }

  auto registry = wl_display_get_registry(display);
  wl_registry_add_listener(registry, &registry_listener, this);

  wl_display_dispatch(display);
  wl_display_roundtrip(display);

  if (compositor == nullptr) {
    fprintf(stderr, "No Wayland compositor found\n");
    exit(EXIT_FAILURE);
  }

  if (seat == nullptr) {
    fprintf(stderr, "No Wayland seat found\n");
    exit(EXIT_FAILURE);
  }

  if (shell == nullptr) {
    fprintf(stderr, "No Wayland shell found\n");
    exit(EXIT_FAILURE);
  }

  io_loop.Add(FileDescriptor(wl_display_get_fd(display)), io_loop.READ, *this);
}
Exemplo n.º 6
0
int main(int argc, char **argv)
{
    Helper helper;

    helper.display = wl_display_connect(nullptr);

    helper.registry = wl_display_get_registry(helper.display);
    static const wl_registry_listener registryListener = {
        wrapInterface(&Helper::global),
        wrapInterface(&Helper::globalRemove)
    };
    wl_registry_add_listener(helper.registry, &registryListener, &helper);

    wl_display_roundtrip(helper.display);
    if (!helper.helper) {
        qWarning("No orbital_authorizer_helper interface.");
        exit(1);
    }

    int ret = 0;
    while (ret != -1)
        ret = wl_display_dispatch(helper.display);

    return 0;
}
Exemplo n.º 7
0
static int createWLContext()
{
    t_ilm_bool result = ILM_TRUE;

    g_wlContextStruct.wlDisplay = wl_display_connect(NULL);
    if (NULL == g_wlContextStruct.wlDisplay)
    {
        printf("Error: wl_display_connect() failed.\n");
    }

    g_wlContextStruct.wlRegistry = wl_display_get_registry(g_wlContextStruct.wlDisplay);
    wl_registry_add_listener(g_wlContextStruct.wlRegistry, &registry_listener, &g_wlContextStruct);
    wl_display_dispatch(g_wlContextStruct.wlDisplay);
    wl_display_roundtrip(g_wlContextStruct.wlDisplay);

    g_wlContextStruct.wlSurface = wl_compositor_create_surface(g_wlContextStruct.wlCompositor);
    if (NULL == g_wlContextStruct.wlSurface)
    {
        printf("Error: wl_compositor_create_surface failed.\n");
        destroyWLContext();
    }

    createShmBuffer();

    return result;
}
Exemplo n.º 8
0
bool cWaylandInterface::Initialize(void *config)
{
	if (!GLWin.wl_display) {
		printf("Error: couldn't open wayland display\n");
		return false;
	}

	GLWin.pointer.wl_pointer = nullptr;
	GLWin.keyboard.wl_keyboard = nullptr;

	GLWin.keyboard.xkb.context = xkb_context_new((xkb_context_flags) 0);
	if (GLWin.keyboard.xkb.context == nullptr) {
		fprintf(stderr, "Failed to create XKB context\n");
		return nullptr;
	}

	GLWin.wl_registry = wl_display_get_registry(GLWin.wl_display);
	wl_registry_add_listener(GLWin.wl_registry,
				 &registry_listener, nullptr);

	while (!GLWin.wl_compositor)
		wl_display_dispatch(GLWin.wl_display);

	GLWin.wl_cursor_surface =
		wl_compositor_create_surface(GLWin.wl_compositor);

	return true;
}
Exemplo n.º 9
0
Arquivo: main.c Projeto: Zeirison/sway
void wl_dispatch_events() {
	wl_display_flush(registry->display);
	if (wl_display_dispatch(registry->display) == -1) {
		sway_log(L_ERROR, "failed to run wl_display_dispatch");
		exit(1);
	}
}
Exemplo n.º 10
0
static int
get_registry_objects()
{
	struct wl_registry *registry = wl_display_get_registry(g_wl_display);
	wl_registry_add_listener(registry, &registry_listener, NULL);
	
	wl_display_dispatch(g_wl_display);
	wl_display_roundtrip(g_wl_display);
	
	if (!g_wl_compositor) {
		p_log("Failed to get a proxy compositor (wl_compositor) object.\n");
		return (-1);
	}
	
	if (!g_wl_shm) {
		p_log("Failed to get a proxy shared memory (wl_shm) object.\n");
		return (-1);
	}
	
	if (!g_wl_shell) {
		p_log("Failed to get a proxy shell (wl_shell) object.\n");
	}
	
	return (0);
}
Exemplo n.º 11
0
GdkDisplay *
_gdk_wayland_display_open (const gchar *display_name)
{
  struct wl_display *wl_display;
  GdkDisplay *display;
  GdkWaylandDisplay *display_wayland;

  GDK_NOTE (MISC, g_message ("opening display %s", display_name ? display_name : ""));

  /* If this variable is unset then wayland initialisation will surely
   * fail, logging a fatal error in the process.  Save ourselves from
   * that.
   */
  if (g_getenv ("XDG_RUNTIME_DIR") == NULL)
    return NULL;

  wl_log_set_handler_client (log_handler);

  wl_display = wl_display_connect (display_name);
  if (!wl_display)
    return NULL;

  display = g_object_new (GDK_TYPE_WAYLAND_DISPLAY, NULL);
  display->device_manager = _gdk_wayland_device_manager_new (display);

  display_wayland = GDK_WAYLAND_DISPLAY (display);
  display_wayland->wl_display = wl_display;
  display_wayland->screen = _gdk_wayland_screen_new (display);
  display_wayland->event_source = _gdk_wayland_display_event_source_new (display);

  display_wayland->known_globals =
    g_hash_table_new_full (NULL, NULL, NULL, g_free);

  _gdk_wayland_display_init_cursors (display_wayland);
  _gdk_wayland_display_prepare_cursor_themes (display_wayland);

  display_wayland->wl_registry = wl_display_get_registry (display_wayland->wl_display);
  wl_registry_add_listener (display_wayland->wl_registry, &registry_listener, display_wayland);

  _gdk_wayland_display_async_roundtrip (display_wayland);

  /* Wait for initializing to complete. This means waiting for all
   * asynchrounous roundtrips that were triggered during initial roundtrip. */
  while (g_list_length (display_wayland->async_roundtrips) > 0)
    {
      if (wl_display_dispatch (display_wayland->wl_display) < 0)
        {
          g_object_unref (display);
          return NULL;
        }
    }

  gdk_input_init (display);

  display_wayland->selection = gdk_wayland_selection_new ();

  g_signal_emit_by_name (display, "opened");

  return display;
}
Exemplo n.º 12
0
void
frame_callback_wait(struct client *client, int *done)
{
	while (!*done) {
		assert(wl_display_dispatch(client->wl_display) >= 0);
	}
}
Exemplo n.º 13
0
void flush_wayland_fd(void *data)
{
   struct pollfd fd = {0};
   input_ctx_wayland_data_t *wl = (input_ctx_wayland_data_t*)data;

   wl_display_dispatch_pending(wl->dpy);
   wl_display_flush(wl->dpy);

   fd.fd     = wl->fd;
   fd.events = POLLIN | POLLOUT | POLLERR | POLLHUP;

   if (poll(&fd, 1, 0) > 0)
   {
      if (fd.revents & (POLLERR | POLLHUP))
      {
         close(wl->fd);
         frontend_driver_set_signal_handler_state(1);
      }

      if (fd.revents & POLLIN)
         wl_display_dispatch(wl->dpy);
      if (fd.revents & POLLOUT)
         wl_display_flush(wl->dpy);
   }
}
Exemplo n.º 14
0
int
main(int argc, char **argv)
{
	struct sigaction sigint;
	struct display *display;
	struct window *window;
	int ret = 0;

	display = create_display();
	window = create_window(display, 250, 250);
	if (!window)
		return 1;

	sigint.sa_handler = signal_int;
	sigemptyset(&sigint.sa_mask);
	sigint.sa_flags = SA_RESETHAND;
	sigaction(SIGINT, &sigint, NULL);

	/* Here we retrieve the linux-dmabuf objects, or error */
	wl_display_roundtrip(display->display);

	if (!running)
		return 1;

	redraw(window, NULL, 0);

	while (running && ret != -1)
		ret = wl_display_dispatch(display->display);

	fprintf(stderr, "simple-dmabuf exiting\n");
	destroy_window(window);
	destroy_display(display);

	return 0;
}
Exemplo n.º 15
0
int
main(int argc, char **argv)
{
  struct nested_client *client;
  int ret = 0;

  if (getenv("WAYLAND_SOCKET") == NULL) {
    fprintf(stderr, "must be run by nested, don't run standalone\n");
    return -1;
  }

  //  printf ("client: program started\n");

  client = nested_client_create(400, 300);

  while (ret != -1) {
    ret = wl_display_dispatch(client->display);
  }

  nested_client_destroy(client);

  //  printf ("client: program finished\n");

  return 0;
}
Exemplo n.º 16
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);
			}
		}
	}
}
Exemplo n.º 17
0
void* display_dispatch_thread(void* p)
{
    int ret = 0;
    while (ret != -1) {
        ret = wl_display_dispatch(window->p_wl_display);
    }
    
    return 0;
}
void QWaylandEventThread::readWaylandEvents()
{
    if (wl_display_dispatch(m_display) < 0) {
        checkError();
        m_readNotifier->setEnabled(false);
        emit fatalError();
        return;
    }

    emit newEventsRead();
}
Exemplo n.º 19
0
struct client *
client_create(int x, int y, int width, int height)
{
	struct client *client;
	struct surface *surface;

	wl_log_set_handler_client(log_handler);

	/* connect to display */
	client = xzalloc(sizeof *client);
	client->wl_display = wl_display_connect(NULL);
	assert(client->wl_display);
	wl_list_init(&client->global_list);

	/* setup registry so we can bind to interfaces */
	client->wl_registry = wl_display_get_registry(client->wl_display);
	wl_registry_add_listener(client->wl_registry, &registry_listener, client);

	/* trigger global listener */
	wl_display_dispatch(client->wl_display);
	wl_display_roundtrip(client->wl_display);

	/* must have WL_SHM_FORMAT_ARGB32 */
	assert(client->has_argb);

	/* must have wl_test interface */
	assert(client->test);

	/* must have an output */
	assert(client->output);

	/* initialize the client surface */
	surface = xzalloc(sizeof *surface);
	surface->wl_surface =
		wl_compositor_create_surface(client->wl_compositor);
	assert(surface->wl_surface);

	wl_surface_add_listener(surface->wl_surface, &surface_listener,
				surface);

	client->surface = surface;
	wl_surface_set_user_data(surface->wl_surface, surface);

	surface->width = width;
	surface->height = height;
	surface->wl_buffer = create_shm_buffer(client, width, height,
					       &surface->data);

	memset(surface->data, 64, width * height * 4);

	move_client(client, x, y);

	return client;
}
Exemplo n.º 20
0
Arquivo: main.c Projeto: sce/sway
int main(int argc, char **argv) {
	init_log(L_INFO);
	surfaces = create_list();
	registry = registry_poll();

	if (argc < 4) {
		sway_abort("Do not run this program manually. See man 5 sway and look for output options.");
	}

	if (!registry->desktop_shell) {
		sway_abort("swaybg requires the compositor to support the desktop-shell extension.");
	}

	int desired_output = atoi(argv[1]);
	sway_log(L_INFO, "Using output %d of %d", desired_output, registry->outputs->length);
	int i;
	struct output_state *output = registry->outputs->items[desired_output];
	struct window *window = window_setup(registry, 100, 100, false);
	if (!window) {
		sway_abort("Failed to create surfaces.");
	}
	window->width = output->width;
	window->height = output->height;
	desktop_shell_set_background(registry->desktop_shell, output->output, window->surface);
	list_add(surfaces, window);

	char *scaling_mode = argv[3];
	cairo_surface_t *image = cairo_image_surface_create_from_png(argv[2]);
	double width = cairo_image_surface_get_width(image);
	double height = cairo_image_surface_get_height(image);

	for (i = 0; i < surfaces->length; ++i) {
		struct window *window = surfaces->items[i];
		if (window_prerender(window) && window->cairo) {
			cairo_scale(window->cairo, window->width / width, window->height / height);
			cairo_set_source_surface(window->cairo, image, 0, 0);
			cairo_paint(window->cairo);

			window_render(window);
		}
	}

	while (wl_display_dispatch(registry->display) != -1);

	for (i = 0; i < surfaces->length; ++i) {
		struct window *window = surfaces->items[i];
		window_teardown(window);
	}
	list_free(surfaces);
	registry_teardown(registry);
	return 0;
}
Exemplo n.º 21
0
int
main(int argc, char **argv)
{
	struct touch *touch;
	int ret = 0;

	touch = touch_create(600, 500);

	while (ret != -1)
		ret = wl_display_dispatch(touch->display);

	return 0;
}
Exemplo n.º 22
0
void WaylandCore::waitEvents() {
  if( mDisplay == NULL || mRegistry == NULL ) {
    mShouldClose = true;
    return;
  }
  int ret = wl_display_dispatch(mDisplay);
  if( ret == -1 ) {
    mShouldClose = true;
    return;
  }
  
  return;
}
Exemplo n.º 23
0
static void Wayland_MainLoop()
{
	// Wait for display to be initialized
	while (!GLWin.wl_display)
		usleep(20000);

	GLWin.running = 1;

	while (GLWin.running)
		wl_display_dispatch(GLWin.wl_display);

	if (GLWin.wl_display)
		wl_display_disconnect(GLWin.wl_display);
}
Exemplo n.º 24
0
int main(void)
{
        struct sigaction   sigint;
        struct my_display *display;
        struct my_window  *window;

        /* Connect to the display */
        printf("Connecting to display\n");
        display = create_display();
        printf("Connected!\n");

        /* Create a window */
        printf("Creating a window\n");
        window = create_window(display, MIN_WIDTH, MIN_HEIGHT);
        if (!window)
                return 1;
        printf("Window created\n");

        /* Set up singal handler. So SIGINT allows us to cleanly die. */
        sigint.sa_handler = signal_int;
        sigemptyset(&sigint.sa_mask);
        sigint.sa_flags = SA_RESETHAND;
        sigaction(SIGINT, &sigint, NULL);

        printf("Initialising buffers\n");
        /* Initialize */
        wl_surface_damage(window->surface, 0, 0, window->width, window->height);
        /* Draw first screen which allocates buffer(s). */
        draw(window, NULL, 0);
       
        printf("Starting loop\n");
        /* Main loop */
        while (running) {
                if (wl_display_dispatch(display->display) == -1) {
                        running = 0;
                }
        }
        printf("Loop exited\n");
        
        /* Destroy the display */
        printf("Destroying window\n");
        destroy_window(window); window = NULL;
        printf("Disconnecting display\n");
        destroy_display(display); display = NULL;
        printf("Done\n");

        return 0;
}
Exemplo n.º 25
0
static struct touch *
touch_create(int width, int height)
{
	struct touch *touch;

	touch = malloc(sizeof *touch);
	if (touch == NULL) {
		fprintf(stderr, "out of memory\n");
		exit(1);
	}
	touch->display = wl_display_connect(NULL);
	assert(touch->display);

	touch->has_argb = 0;
	touch->registry = wl_display_get_registry(touch->display);
	wl_registry_add_listener(touch->registry, &registry_listener, touch);
	wl_display_dispatch(touch->display);
	wl_display_roundtrip(touch->display);

	if (!touch->has_argb) {
		fprintf(stderr, "WL_SHM_FORMAT_ARGB32 not available\n");
		exit(1);
	}

	touch->width = width;
	touch->height = height;
	touch->surface = wl_compositor_create_surface(touch->compositor);
	touch->shell_surface = wl_shell_get_shell_surface(touch->shell,
							  touch->surface);
	create_shm_buffer(touch);

	if (touch->shell_surface) {
		wl_shell_surface_add_listener(touch->shell_surface,
					      &shell_surface_listener, touch);
		wl_shell_surface_set_toplevel(touch->shell_surface);
	}

	wl_surface_set_user_data(touch->surface, touch);
	wl_shell_surface_set_title(touch->shell_surface, "simple-touch");

	memset(touch->data, 64, width * height * 4);
	wl_surface_attach(touch->surface, touch->buffer, 0, 0);
	wl_surface_damage(touch->surface, 0, 0, width, height);
	wl_surface_commit(touch->surface);

	return touch;
}
Exemplo n.º 26
0
void
_gdk_wayland_display_queue_events (GdkDisplay *display)
{
  GdkWaylandDisplay *display_wayland;
  GdkWaylandEventSource *source;

  display_wayland = GDK_WAYLAND_DISPLAY (display);
  source = (GdkWaylandEventSource *) display_wayland->event_source;
  if (source->pfd.revents & G_IO_IN)
    {
	wl_display_dispatch(display_wayland->wl_display);
	source->pfd.revents = 0;
    }

  if (source->pfd.revents & (G_IO_ERR | G_IO_HUP))
    g_error ("Lost connection to wayland compositor");
}
Exemplo n.º 27
0
static int
client_main(void)
{
   struct client_test client;
   client_test_create(&client, "fullscreen", 320, 320);
   surface_create(&client);
   shell_surface_create(&client);
   client_test_roundtrip(&client);
   client_test_roundtrip(&client);

   struct output *o;
   assert((o = chck_iter_pool_get(&client.outputs, 0)));
   wl_shell_surface_set_fullscreen(client.view.ssurface, 0, 0, o->output);
   wl_surface_commit(client.view.surface);
   while (wl_display_dispatch(client.display) != -1);
   return client_test_end(&client);
}
Exemplo n.º 28
0
int
main(int argc, char **argv)
{
    int i, ret = 0, cursor_count = argc - 3;
    struct sigaction sigint;
    struct cursor_viewer *viewer;
    struct cursor_surface **cursors;

    if (argc < 4) {
        printf("Usage: %s CURSOR_THEME SIZE CURSOR_NAMES...\n", argv[0]);
        exit(EXIT_FAILURE);
    }

    sigint.sa_handler = signal_int;
    sigemptyset(&sigint.sa_mask);
    sigint.sa_flags = SA_RESETHAND;
    sigaction(SIGINT, &sigint, NULL);

    viewer = cursor_viewer_create();

    viewer->cursor_theme =
        wl_cursor_theme_load(argv[1], atoi(argv[2]), viewer->shm);
    if (!viewer->cursor_theme)
        die("Failed to load default cursor theme\n");

    cursors = calloc(1, sizeof (struct cursor_surface *) * cursor_count);

    for (i = 3; i < argc; ++i) {
        struct cursor_surface *cursor =
            cursor_viewer_show_cursor(viewer, argv[i]);

        cursors[i - 3] = cursor;
    }

    while (running && ret != -1)
        ret = wl_display_dispatch(viewer->display);

    for (i = 0; i < cursor_count; ++i)
        cursor_surface_destroy(cursors[i]);
    free(cursors);

    cursor_viewer_destroy(viewer);

    exit(EXIT_SUCCESS);
}
Exemplo n.º 29
0
bool
WLContext::InitWLContext(const struct wl_pointer_listener* wlPointerListener,
                         const struct wl_keyboard_listener* wlKeyboardListener,
                         const struct wl_touch_listener* wlTouchListener)
{
    m_wlPointerListener = const_cast<wl_pointer_listener*>(wlPointerListener);
    m_wlKeyboardListener = const_cast<wl_keyboard_listener*>(wlKeyboardListener);
    m_wlTouchListener = const_cast<wl_touch_listener*>(wlTouchListener);

    m_wlDisplay = wl_display_connect(NULL);

    m_wlRegistry = wl_display_get_registry(m_wlDisplay);
    wl_registry_add_listener(m_wlRegistry, &registryListener, this);
    wl_display_dispatch(m_wlDisplay);
    wl_display_roundtrip(m_wlDisplay);

    return true;
}
Exemplo n.º 30
0
static int
wayland_compositor_handle_event(int fd, uint32_t mask, void *data)
{
	struct wayland_compositor *c = data;
	int count = 0;

	if (mask & WL_EVENT_READABLE)
		count = wl_display_dispatch(c->parent.wl_display);
	if (mask & WL_EVENT_WRITABLE)
		wl_display_flush(c->parent.wl_display);

	if (mask == 0) {
		count = wl_display_dispatch_pending(c->parent.wl_display);
		wl_display_flush(c->parent.wl_display);
	}

	return count;
}