static void registry_handle_global (void *data, struct wl_registry *registry, uint32_t id, const char *interface, uint32_t version) { GstWlDisplay *self = data; if (g_strcmp0 (interface, "wl_compositor") == 0) { self->compositor = wl_registry_bind (registry, id, &wl_compositor_interface, MIN (version, 3)); } else if (g_strcmp0 (interface, "wl_subcompositor") == 0) { self->subcompositor = wl_registry_bind (registry, id, &wl_subcompositor_interface, 1); } else if (g_strcmp0 (interface, "wl_shell") == 0) { self->shell = wl_registry_bind (registry, id, &wl_shell_interface, 1); } else if (g_strcmp0 (interface, "wl_shm") == 0) { self->shm = wl_registry_bind (registry, id, &wl_shm_interface, 1); wl_shm_add_listener (self->shm, &shm_listener, self); } else if (g_strcmp0 (interface, "wp_viewporter") == 0) { self->viewporter = wl_registry_bind (registry, id, &wp_viewporter_interface, 1); } else if (g_strcmp0 (interface, "zwp_linux_dmabuf_v1") == 0) { self->dmabuf = wl_registry_bind (registry, id, &zwp_linux_dmabuf_v1_interface, 1); zwp_linux_dmabuf_v1_add_listener (self->dmabuf, &dmabuf_listener, self); } }
static void registry_handle_global(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version) { WLContextStruct* p_wlCtx = (WLContextStruct*)data; int ans_strcmp = 0; do { ans_strcmp = strcmp(interface, "wl_compositor"); if (0 == ans_strcmp) { p_wlCtx->wlCompositor = (struct wl_compositor*)wl_registry_bind(registry, name, &wl_compositor_interface, 1); break; } ans_strcmp = strcmp(interface, "wl_shm"); if (0 == ans_strcmp) { p_wlCtx->wlShm = wl_registry_bind(registry, name, &wl_shm_interface, 1); wl_shm_add_listener(p_wlCtx->wlShm, &shm_listenter, p_wlCtx); break; } ans_strcmp = strcmp(interface, "serverinfo"); if (0 == ans_strcmp) { p_wlCtx->wlExtServerinfo = (struct serverinfo*)wl_registry_bind(registry, name, &serverinfo_interface, 1); serverinfo_add_listener(p_wlCtx->wlExtServerinfo, &serverinfo_listener_list, data); serverinfo_get_connection_id(p_wlCtx->wlExtServerinfo); } } while(0); }
static void registry_handle_global(void *data, struct wl_registry *registry, uint32_t id, const char *interface, uint32_t version) { struct display *d = data; if (strcmp(interface, "wl_compositor") == 0) { d->compositor = wl_registry_bind(registry, id, &wl_compositor_interface, 1); } else if (strcmp(interface, "xdg_shell") == 0) { d->shell = wl_registry_bind(registry, id, &xdg_shell_interface, 1); xdg_shell_use_unstable_version(d->shell, XDG_VERSION); xdg_shell_add_listener(d->shell, &xdg_shell_listener, d); } else if (strcmp(interface, "zwp_fullscreen_shell_v1") == 0) { d->fshell = wl_registry_bind(registry, id, &zwp_fullscreen_shell_v1_interface, 1); } else if (strcmp(interface, "wl_shm") == 0) { d->shm = wl_registry_bind(registry, id, &wl_shm_interface, 1); wl_shm_add_listener(d->shm, &shm_listener, d); } else if (strcmp(interface, "ivi_application") == 0) { d->ivi_application = wl_registry_bind(registry, id, &ivi_application_interface, 1); } }
static void _eventd_nd_wl_registry_handle_global(void *data, struct wl_registry *registry, uint32_t name, const char *interface, uint32_t version) { EventdNdBackendContext *self = data; if ( g_strcmp0(interface, "wl_compositor") == 0 ) { self->global_names[EVENTD_ND_WL_GLOBAL_COMPOSITOR] = name; self->compositor = wl_registry_bind(registry, name, &wl_compositor_interface, MIN(version, WL_COMPOSITOR_INTERFACE_VERSION)); } else if ( g_strcmp0(interface, "zww_notification_area_v1") == 0 ) { self->global_names[EVENTD_ND_WL_GLOBAL_NOTIFICATION_DAEMON] = name; self->notification_area = wl_registry_bind(registry, name, &zww_notification_area_v1_interface, WW_NOTIFICATION_AREA_INTERFACE_VERSION); zww_notification_area_v1_add_listener(self->notification_area, &_eventd_nd_wl_notification_area_listener, self); } else if ( g_strcmp0(interface, "wl_shm") == 0 ) { self->global_names[EVENTD_ND_WL_GLOBAL_SHM] = name; self->shm = wl_registry_bind(registry, name, &wl_shm_interface, MIN(version, WL_SHM_INTERFACE_VERSION)); wl_shm_add_listener(self->shm, &_eventd_nd_wl_shm_listener, self); } else if ( g_strcmp0(interface, "wl_seat") == 0 ) { EventdNdWlSeat *seat = g_slice_new0(EventdNdWlSeat); seat->context = self; seat->global_name = name; seat->seat = wl_registry_bind(registry, name, &wl_seat_interface, MIN(version, WL_SEAT_INTERFACE_VERSION)); seat->link = self->seats = g_slist_prepend(self->seats, seat); wl_seat_add_listener(seat->seat, &_eventd_nd_wl_seat_listener, seat); } if ( ( self->cursor.theme == NULL ) && ( self->compositor != NULL ) && ( self->shm != NULL ) ) { self->cursor.theme = wl_cursor_theme_load(self->cursor.theme_name, 32, self->shm); if ( self->cursor.theme != NULL ) { const gchar * const *cname = (const gchar * const *) self->cursor.name; for ( cname = ( cname != NULL ) ? cname : _eventd_nd_cursor_names ; ( self->cursor.cursor == NULL ) && ( *cname != NULL ) ; ++cname ) self->cursor.cursor = wl_cursor_theme_get_cursor(self->cursor.theme, *cname); if ( self->cursor.cursor == NULL ) { wl_cursor_theme_destroy(self->cursor.theme); self->cursor.theme = NULL; } else self->cursor.surface = wl_compositor_create_surface(self->compositor); } } }
static void handle_global(void *data, struct wl_registry *registry, uint32_t id, const char *interface, uint32_t version) { struct client *client = data; struct input *input; struct output *output; struct test *test; struct global *global; global = xzalloc(sizeof *global); global->name = id; global->interface = strdup(interface); assert(interface); global->version = version; wl_list_insert(client->global_list.prev, &global->link); if (strcmp(interface, "wl_compositor") == 0) { client->wl_compositor = wl_registry_bind(registry, id, &wl_compositor_interface, 1); } else if (strcmp(interface, "wl_seat") == 0) { input = xzalloc(sizeof *input); input->wl_seat = wl_registry_bind(registry, id, &wl_seat_interface, 1); wl_seat_add_listener(input->wl_seat, &seat_listener, input); client->input = input; } else if (strcmp(interface, "wl_shm") == 0) { client->wl_shm = wl_registry_bind(registry, id, &wl_shm_interface, 1); wl_shm_add_listener(client->wl_shm, &shm_listener, client); } else if (strcmp(interface, "wl_output") == 0) { output = xzalloc(sizeof *output); output->wl_output = wl_registry_bind(registry, id, &wl_output_interface, 1); wl_output_add_listener(output->wl_output, &output_listener, output); client->output = output; } else if (strcmp(interface, "wl_test") == 0) { test = xzalloc(sizeof *test); test->wl_test = wl_registry_bind(registry, id, &wl_test_interface, 1); wl_test_add_listener(test->wl_test, &test_listener, test); client->test = test; } }
static void registry_handle_global (void *data, struct wl_registry *registry, uint32_t id, const char *interface, uint32_t version) { struct display *d = data; if (strcmp (interface, "wl_compositor") == 0) { d->compositor = wl_registry_bind (registry, id, &wl_compositor_interface, 1); } else if (strcmp (interface, "wl_shell") == 0) { d->shell = wl_registry_bind (registry, id, &wl_shell_interface, 1); } else if (strcmp (interface, "wl_shm") == 0) { d->shm = wl_registry_bind (registry, id, &wl_shm_interface, 1); wl_shm_add_listener (d->shm, &shm_listenter, d); } }
static void global_registry_handler(void *data, struct wl_registry *registry, uint32_t id, const char *interface, uint32_t version) { if (strcmp(interface, "wl_compositor") == 0) { compositor = (wl_compositor*)wl_registry_bind(registry, id, &wl_compositor_interface, 1); } else if (strcmp(interface, "wl_shell") == 0) { shell = (wl_shell*)wl_registry_bind(registry, id, &wl_shell_interface, 1); } else if (strcmp(interface, "wl_shm") == 0) { shm = (wl_shm*)wl_registry_bind(registry, id, &wl_shm_interface, 1); wl_shm_add_listener(shm, &shm_listener, NULL); } }
static void handle_global(void *data, struct wl_registry *registry, uint32_t name, const char *interface, uint32_t version) { struct touch *touch = data; if (strcmp(interface, "wl_compositor") == 0) { touch->compositor = wl_registry_bind(registry, name, &wl_compositor_interface, 1); } else if (strcmp(interface, "wl_shell") == 0) { touch->shell = wl_registry_bind(registry, name, &wl_shell_interface, 1); } else if (strcmp(interface, "wl_shm") == 0) { touch->shm = wl_registry_bind(registry, name, &wl_shm_interface, 1); wl_shm_add_listener(touch->shm, &shm_listener, touch); } else if (strcmp(interface, "wl_seat") == 0) { add_seat(touch, name, version); } }
static void global_registry_handler(void *data, struct wl_registry *registry, uint32_t id, const char *interface, uint32_t version) { printf("Got a registry event for %s id %d\n", interface, id); if(strcmp(interface, "wl_compositor") == 0) { if(nullptr == m_compositor) { m_compositor = (wl_compositor*)wl_registry_bind(registry, id, &wl_compositor_interface, 1); } } else if(strcmp(interface, "wl_shell") == 0) { if(nullptr == m_shell) { m_shell = (wl_shell*)wl_registry_bind(registry, id, &wl_shell_interface, 1); } } else if(strcmp(interface, "wl_shm") == 0) { if(nullptr == m_sharedMemory) { m_sharedMemory = (wl_shm*)wl_registry_bind(registry, id, &wl_shm_interface, 1); wl_shm_add_listener(m_sharedMemory, &shm_listener, nullptr); } } else if(strcmp(interface, "wl_seat") == 0) { if(m_seat == nullptr) { m_seat = (wl_seat*)wl_registry_bind(registry, id, &wl_seat_interface, 1); XdevLWindowEventServerWayland::setSeat(); } } }
static void registry_handle_global(void *data, struct wl_registry *registry, uint32_t id, const char *interface, uint32_t version) { struct display *d = data; if (strcmp(interface, "wl_compositor") == 0) { if (d->compositor_version > (int)version) { fprintf(stderr, "Compositor does not support " "wl_surface version %d\n", d->compositor_version); exit(1); } if (d->compositor_version < 0) d->compositor_version = version; d->compositor = wl_registry_bind(registry, id, &wl_compositor_interface, d->compositor_version); } else if (strcmp(interface, "wl_scaler") == 0 && version >= 2) { d->scaler = wl_registry_bind(registry, id, &wl_scaler_interface, 2); } else if (strcmp(interface, "xdg_shell") == 0) { d->shell = wl_registry_bind(registry, id, &xdg_shell_interface, 1); xdg_shell_use_unstable_version(d->shell, XDG_VERSION); xdg_shell_add_listener(d->shell, &xdg_shell_listener, d); } else if (strcmp(interface, "_wl_fullscreen_shell") == 0) { d->fshell = wl_registry_bind(registry, id, &_wl_fullscreen_shell_interface, 1); } else if (strcmp(interface, "wl_shm") == 0) { d->shm = wl_registry_bind(registry, id, &wl_shm_interface, 1); wl_shm_add_listener(d->shm, &shm_listener, d); } }
static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg, video_format_t *fmtp, vlc_video_context *context) { if (cfg->window->type != VOUT_WINDOW_TYPE_WAYLAND) return VLC_EGENERIC; vout_display_sys_t *sys = malloc(sizeof (*sys)); if (unlikely(sys == NULL)) return VLC_ENOMEM; vd->sys = sys; sys->embed = NULL; sys->eventq = NULL; sys->shm = NULL; sys->viewporter = NULL; sys->active_buffers = 0; sys->display_width = cfg->display.width; sys->display_height = cfg->display.height; sys->use_buffer_transform = false; /* Get window */ sys->embed = cfg->window; assert(sys->embed != NULL); struct wl_display *display = sys->embed->display.wl; sys->eventq = wl_display_create_queue(display); if (sys->eventq == NULL) goto error; struct wl_registry *registry = wl_display_get_registry(display); if (registry == NULL) goto error; wl_proxy_set_queue((struct wl_proxy *)registry, sys->eventq); wl_registry_add_listener(registry, ®istry_cbs, vd); wl_display_roundtrip_queue(display, sys->eventq); wl_registry_destroy(registry); if (sys->shm == NULL) goto error; wl_shm_add_listener(sys->shm, &shm_cbs, vd); wl_display_roundtrip_queue(display, sys->eventq); struct wl_surface *surface = sys->embed->handle.wl; if (sys->viewporter != NULL) sys->viewport = wp_viewporter_get_viewport(sys->viewporter, surface); else sys->viewport = NULL; /* Determine our pixel format */ static const enum wl_output_transform transforms[8] = { [ORIENT_TOP_LEFT] = WL_OUTPUT_TRANSFORM_NORMAL, [ORIENT_TOP_RIGHT] = WL_OUTPUT_TRANSFORM_FLIPPED, [ORIENT_BOTTOM_LEFT] = WL_OUTPUT_TRANSFORM_FLIPPED_180, [ORIENT_BOTTOM_RIGHT] = WL_OUTPUT_TRANSFORM_180, [ORIENT_LEFT_TOP] = WL_OUTPUT_TRANSFORM_FLIPPED_270, [ORIENT_LEFT_BOTTOM] = WL_OUTPUT_TRANSFORM_90, [ORIENT_RIGHT_TOP] = WL_OUTPUT_TRANSFORM_270, [ORIENT_RIGHT_BOTTOM] = WL_OUTPUT_TRANSFORM_FLIPPED_90, };
/* * Allow comfortably add listener into client structure * XXX Do it somehow else.. or let user manually add listeners */ void wit_client_add_listener(struct wit_client *cl, const char *interface, const void *listener) { assertf(cl); assert(interface); ifdbg(listener == NULL, "Adding NULL listener (%s)\n", interface); if (strcmp(interface, "wl_pointer") == 0) { ifdbg(cl->pointer.listener, "Rewriting pointer listener (%p)\n", cl->pointer.listener); cl->pointer.listener = listener; if (cl->pointer.proxy) wl_pointer_add_listener( (struct wl_pointer *) cl->pointer.proxy, (struct wl_pointer_listener *) cl->pointer.listener, cl); else dbg("Not adding listener." "Pointer proxy hasn't been created yet.\n"); } else if (strcmp(interface, "wl_keyboard") == 0) { ifdbg(cl->keyboard.listener, "Rewriting keyboard listener (%p)\n", cl->keyboard.listener); cl->keyboard.listener = listener; if (cl->keyboard.proxy) wl_keyboard_add_listener( (struct wl_keyboard *) cl->keyboard.proxy, (struct wl_keyboard_listener *) cl->keyboard.listener, cl); else dbg("Not adding listener." "Keyboard proxy hasn't been created yet.\n"); } else if (strcmp(interface, "wl_touch") == 0) { ifdbg(cl->touch.listener, "Rewriting touch listener (%p)\n", cl->touch.listener); cl->touch.listener = listener; if (cl->touch.proxy) wl_touch_add_listener( (struct wl_touch *) cl->touch.proxy, (struct wl_touch_listener *) cl->touch.listener, cl); else dbg("Not adding listener." "Touch proxy hasn't been created yet.\n"); } else if (strcmp(interface, "wl_seat") == 0) { ifdbg(cl->seat.listener, "Rewriting seat listener (%p)\n", cl->seat.listener); cl->seat.listener = listener; if (cl->seat.proxy) wl_seat_add_listener( (struct wl_seat *) cl->seat.proxy, (struct wl_seat_listener *) cl->seat.listener, cl); else dbg("Not adding listener." "seat proxy hasn't been created yet.\n"); } else if (strcmp(interface, "wl_shm") == 0) { ifdbg(cl->shm.listener, "Rewriting shm listener (%p)\n", cl->shm.listener); cl->shm.listener = listener; if (cl->shm.proxy) wl_shm_add_listener( (struct wl_shm *) cl->shm.proxy, (struct wl_shm_listener *) cl->shm.listener, cl); else dbg("Not adding listener." "shm proxy hasn't been created yet.\n"); } else if (strcmp(interface, "wl_registry") == 0) { ifdbg(cl->registry.listener, "Rewriting registry listener (%p)\n", cl->registry.listener); cl->registry.listener = listener; if (cl->registry.proxy) wl_registry_add_listener( (struct wl_registry *) cl->registry.proxy, (struct wl_registry_listener *) cl->registry.listener, cl); else dbg("Not adding listener." "registry proxy hasn't been created yet.\n"); } else { assertf(0, "Unknown type of interface"); } }