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 registry_handle_global(void *data, struct wl_registry *registry, uint32_t name, const char *interface, uint32_t version) { struct display *d = data; if (strcmp(interface, "wl_compositor") == 0) { d->compositor = wl_registry_bind(registry, name, &wl_compositor_interface, 1); } else if (strcmp(interface, "xdg_shell") == 0) { d->shell = wl_registry_bind(registry, name, &xdg_shell_interface, 1); xdg_shell_add_listener(d->shell, &xdg_shell_listener, d); xdg_shell_use_unstable_version(d->shell, XDG_VERSION); } else if (strcmp(interface, "wl_seat") == 0) { d->seat = wl_registry_bind(registry, name, &wl_seat_interface, 1); wl_seat_add_listener(d->seat, &seat_listener, d); } else if (strcmp(interface, "wl_shm") == 0) { d->shm = wl_registry_bind(registry, name, &wl_shm_interface, 1); d->cursor_theme = wl_cursor_theme_load(NULL, 32, d->shm); d->default_cursor = wl_cursor_theme_get_cursor(d->cursor_theme, "left_ptr"); } }
void XdgShellUnstableV5::Private::setupV5(xdg_shell *shell) { Q_ASSERT(shell); Q_ASSERT(!xdgshellv5); xdgshellv5.setup(shell); xdg_shell_use_unstable_version(xdgshellv5, 5); }
WaylandDisplay::WaylandDisplay() { m_display = wl_display_connect(nullptr); m_registry = wl_display_get_registry(m_display); wl_registry_add_listener(m_registry, &g_registryListener, &m_interfaces); wl_display_roundtrip(m_display); m_eventSource = g_source_new(&EventSource::sourceFuncs, sizeof(EventSource)); auto* source = reinterpret_cast<EventSource*>(m_eventSource); source->display = m_display; source->pfd.fd = wl_display_get_fd(m_display); source->pfd.events = G_IO_IN | G_IO_ERR | G_IO_HUP; source->pfd.revents = 0; g_source_add_poll(m_eventSource, &source->pfd); g_source_set_name(m_eventSource, "[WPE] WaylandDisplay"); g_source_set_priority(m_eventSource, G_PRIORITY_HIGH + 30); g_source_set_can_recurse(m_eventSource, TRUE); g_source_attach(m_eventSource, g_main_context_get_thread_default()); if (m_interfaces.xdg) { xdg_shell_add_listener(m_interfaces.xdg, &g_xdgShellListener, nullptr); xdg_shell_use_unstable_version(m_interfaces.xdg, 5); } wl_seat_add_listener(m_interfaces.seat, &g_seatListener, &m_seatData); m_seatData.xkb.context = xkb_context_new(XKB_CONTEXT_NO_FLAGS); m_seatData.xkb.composeTable = xkb_compose_table_new_from_locale(m_seatData.xkb.context, setlocale(LC_CTYPE, nullptr), XKB_COMPOSE_COMPILE_NO_FLAGS); if (m_seatData.xkb.composeTable) m_seatData.xkb.composeState = xkb_compose_state_new(m_seatData.xkb.composeTable, XKB_COMPOSE_STATE_NO_FLAGS); }
WaylandDisplay::WaylandDisplay() { m_display = wl_display_connect(nullptr); m_registry = wl_display_get_registry(m_display); wl_registry_add_listener(m_registry, &g_registryListener, &m_interfaces); wl_display_roundtrip(m_display); m_eventSource = g_source_new(&EventSource::sourceFuncs, sizeof(EventSource)); auto* source = reinterpret_cast<EventSource*>(m_eventSource); source->display = m_display; source->pfd.fd = wl_display_get_fd(m_display); source->pfd.events = G_IO_IN | G_IO_ERR | G_IO_HUP; source->pfd.revents = 0; g_source_add_poll(m_eventSource, &source->pfd); g_source_set_name(m_eventSource, "[WPE] WaylandDisplay"); g_source_set_priority(m_eventSource, G_PRIORITY_HIGH + 30); g_source_set_can_recurse(m_eventSource, TRUE); g_source_attach(m_eventSource, g_main_context_get_thread_default()); if (m_interfaces.xdg) { xdg_shell_add_listener(m_interfaces.xdg, &g_xdgShellListener, nullptr); xdg_shell_use_unstable_version(m_interfaces.xdg, 5); } }
static void gdk_registry_handle_global(void *data, struct wl_registry *registry, uint32_t id, const char *interface, uint32_t version) { GdkWaylandDisplay *display_wayland = data; GdkDisplay *gdk_display = GDK_DISPLAY_OBJECT (data); struct wl_seat *seat; struct wl_output *output; if (strcmp(interface, "wl_compositor") == 0) { display_wayland->compositor = wl_registry_bind(display_wayland->wl_registry, id, &wl_compositor_interface, MIN (version, 3)); display_wayland->compositor_version = MIN (version, 3); } else if (strcmp(interface, "wl_shm") == 0) { display_wayland->shm = wl_registry_bind(display_wayland->wl_registry, id, &wl_shm_interface, 1); /* SHM interface is prerequisite */ _gdk_wayland_display_load_cursor_theme(display_wayland); } else if (strcmp(interface, "xdg_shell") == 0) { display_wayland->xdg_shell = wl_registry_bind(display_wayland->wl_registry, id, &xdg_shell_interface, 1); xdg_shell_use_unstable_version(display_wayland->xdg_shell, XDG_SHELL_VERSION_CURRENT); xdg_shell_add_listener(display_wayland->xdg_shell, &xdg_shell_listener, display_wayland); } else if (strcmp(interface, "gtk_shell") == 0) { display_wayland->gtk_shell = wl_registry_bind(display_wayland->wl_registry, id, >k_shell_interface, 1); _gdk_wayland_screen_set_has_gtk_shell (display_wayland->screen); } else if (strcmp(interface, "wl_output") == 0) { output = wl_registry_bind(display_wayland->wl_registry, id, &wl_output_interface, MIN (version, 2)); _gdk_wayland_screen_add_output(display_wayland->screen, id, output, MIN (version, 2)); } else if (strcmp(interface, "wl_seat") == 0) { seat = wl_registry_bind(display_wayland->wl_registry, id, &wl_seat_interface, 4); _gdk_wayland_device_manager_add_seat (gdk_display->device_manager, id, seat); } else if (strcmp(interface, "wl_data_device_manager") == 0) { display_wayland->data_device_manager = wl_registry_bind(display_wayland->wl_registry, id, &wl_data_device_manager_interface, 1); } else if (strcmp (interface, "wl_subcompositor") == 0) { display_wayland->subcompositor = wl_registry_bind (display_wayland->wl_registry, id, &wl_subcompositor_interface, 1); } }
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 void gdk_registry_handle_global (void *data, struct wl_registry *registry, uint32_t id, const char *interface, uint32_t version) { GdkWaylandDisplay *display_wayland = data; struct wl_output *output; gboolean handled = TRUE; GDK_NOTE (MISC, g_message ("add global %u, interface %s, version %u", id, interface, version)); if (strcmp (interface, "wl_compositor") == 0) { display_wayland->compositor = wl_registry_bind (display_wayland->wl_registry, id, &wl_compositor_interface, MIN (version, 3)); display_wayland->compositor_version = MIN (version, 3); } else if (strcmp (interface, "wl_shm") == 0) { display_wayland->shm = wl_registry_bind (display_wayland->wl_registry, id, &wl_shm_interface, 1); } else if (strcmp (interface, "xdg_shell") == 0) { display_wayland->xdg_shell = wl_registry_bind (display_wayland->wl_registry, id, &xdg_shell_interface, 1); xdg_shell_use_unstable_version (display_wayland->xdg_shell, XDG_SHELL_VERSION_CURRENT); xdg_shell_add_listener (display_wayland->xdg_shell, &xdg_shell_listener, display_wayland); } else if (strcmp (interface, "gtk_shell1") == 0) { display_wayland->gtk_shell = wl_registry_bind(display_wayland->wl_registry, id, >k_shell1_interface, 1); _gdk_wayland_screen_set_has_gtk_shell (display_wayland->screen); display_wayland->gtk_shell_version = version; } else if (strcmp (interface, "wl_output") == 0) { output = wl_registry_bind (display_wayland->wl_registry, id, &wl_output_interface, MIN (version, 2)); _gdk_wayland_screen_add_output (display_wayland->screen, id, output, MIN (version, 2)); _gdk_wayland_display_async_roundtrip (display_wayland); } else if (strcmp (interface, "wl_seat") == 0) { static const char *required_device_manager_globals[] = { "wl_compositor", "wl_data_device_manager", NULL }; if (has_required_globals (display_wayland, required_device_manager_globals)) _gdk_wayland_display_add_seat (display_wayland, id, version); else { SeatAddedClosure *closure; closure = g_new0 (SeatAddedClosure, 1); closure->base.handler = seat_added_closure_run; closure->base.required_globals = required_device_manager_globals; closure->id = id; closure->version = version; postpone_on_globals_closure (display_wayland, &closure->base); } } else if (strcmp (interface, "wl_data_device_manager") == 0) { display_wayland->data_device_manager_version = MIN (version, 3); display_wayland->data_device_manager = wl_registry_bind (display_wayland->wl_registry, id, &wl_data_device_manager_interface, display_wayland->data_device_manager_version); } else if (strcmp (interface, "wl_subcompositor") == 0) { display_wayland->subcompositor = wl_registry_bind (display_wayland->wl_registry, id, &wl_subcompositor_interface, 1); } else if (strcmp (interface, "zwp_pointer_gestures_v1") == 0 && version == GDK_ZWP_POINTER_GESTURES_V1_VERSION) { display_wayland->pointer_gestures = wl_registry_bind (display_wayland->wl_registry, id, &zwp_pointer_gestures_v1_interface, version); } else if (strcmp (interface, "gtk_primary_selection_device_manager") == 0) { display_wayland->primary_selection_manager = wl_registry_bind(display_wayland->wl_registry, id, >k_primary_selection_device_manager_interface, 1); } else handled = FALSE; if (handled) g_hash_table_insert (display_wayland->known_globals, GUINT_TO_POINTER (id), g_strdup (interface)); process_on_globals_closures (display_wayland); }