static void create_surface(struct window *window) { struct display *display = window->display; EGLBoolean ret; window->surface = wl_compositor_create_surface(display->compositor); window->xdg_surface = xdg_shell_get_xdg_surface(display->shell, window->surface); xdg_surface_add_listener(window->xdg_surface, &xdg_surface_listener, window); window->native = wl_egl_window_create(window->surface, window->window_size.width, window->window_size.height); window->egl_surface = eglCreateWindowSurface(display->egl.dpy, display->egl.conf, window->native, NULL); xdg_surface_set_title(window->xdg_surface, "simple-egl"); ret = eglMakeCurrent(window->display->egl.dpy, window->egl_surface, window->egl_surface, window->display->egl.ctx); assert(ret == EGL_TRUE); if (!window->frame_sync) eglSwapInterval(display->egl.dpy, 0); xdg_surface_request_change_state(window->xdg_surface, XDG_SURFACE_STATE_FULLSCREEN, window->fullscreen, 0); }
XdgShellSurface *XdgShellUnstableV5::Private::getXdgSurface(Surface *surface, QObject *parent) { Q_ASSERT(isValid()); XdgShellSurface *s = new XdgShellSurfaceUnstableV5(parent); auto w = xdg_shell_get_xdg_surface(xdgshellv5, *surface); if (queue) { queue->addProxy(w); } s->setup(w); return s; }
static struct window * create_window(struct display *display, int width, int height) { struct window *window; window = calloc(1, sizeof *window); if (!window) return NULL; window->callback = NULL; window->display = display; window->width = width; window->height = height; window->surface = wl_compositor_create_surface(display->compositor); if (display->shell) { window->xdg_surface = xdg_shell_get_xdg_surface(display->shell, window->surface); assert(window->xdg_surface); xdg_surface_add_listener(window->xdg_surface, &xdg_surface_listener, window); xdg_surface_set_title(window->xdg_surface, "simple-shm"); } else if (display->fshell) { zwp_fullscreen_shell_v1_present_surface(display->fshell, window->surface, ZWP_FULLSCREEN_SHELL_V1_PRESENT_METHOD_DEFAULT, NULL); } else if (display->ivi_application ) { uint32_t id_ivisurf = IVI_SURFACE_ID + (uint32_t)getpid(); window->ivi_surface = ivi_application_surface_create(display->ivi_application, id_ivisurf, window->surface); if (window->ivi_surface == NULL) { fprintf(stderr, "Failed to create ivi_client_surface\n"); abort(); } ivi_surface_add_listener(window->ivi_surface, &ivi_surface_listener, window); } else { assert(0); } return window; }
static struct window * create_window(struct display *display, int width, int height) { struct window *window; int i; int ret; window = zalloc(sizeof *window); if (!window) return NULL; window->callback = NULL; window->display = display; window->width = width; window->height = height; window->surface = wl_compositor_create_surface(display->compositor); if (display->shell) { window->xdg_surface = xdg_shell_get_xdg_surface(display->shell, window->surface); assert(window->xdg_surface); xdg_surface_add_listener(window->xdg_surface, &xdg_surface_listener, window); xdg_surface_set_title(window->xdg_surface, "simple-dmabuf"); } else if (display->fshell) { zwp_fullscreen_shell_v1_present_surface(display->fshell, window->surface, ZWP_FULLSCREEN_SHELL_V1_PRESENT_METHOD_DEFAULT, NULL); } else { assert(0); } for (i = 0; i < 2; ++i) { ret = create_dmabuf_buffer(display, &window->buffers[i], width, height); if (ret < 0) return NULL; } return window; }
static struct window * create_window(struct display *display, int width, int height, enum wl_output_transform transform, int scale, enum window_flags flags) { struct window *window; if (display->compositor_version < 2 && (transform != WL_OUTPUT_TRANSFORM_NORMAL || flags & WINDOW_FLAG_ROTATING_TRANSFORM)) { fprintf(stderr, "wl_surface.buffer_transform unsupported in " "wl_surface version %d\n", display->compositor_version); exit(1); } if (display->compositor_version < 3 && (! (flags & WINDOW_FLAG_USE_VIEWPORT)) && scale != 1) { fprintf(stderr, "wl_surface.buffer_scale unsupported in " "wl_surface version %d\n", display->compositor_version); exit(1); } if (display->scaler == NULL && (flags & WINDOW_FLAG_USE_VIEWPORT)) { fprintf(stderr, "Compositor does not support wl_viewport"); exit(1); } window = calloc(1, sizeof *window); if (!window) return NULL; window->callback = NULL; window->display = display; window->width = width; window->height = height; window->border = 10; window->flags = flags; window->transform = transform; window->scale = scale; window_init_game(window); window->surface = wl_compositor_create_surface(display->compositor); if (window->flags & WINDOW_FLAG_USE_VIEWPORT) window->viewport = wl_scaler_get_viewport(display->scaler, window->surface); if (display->shell) { window->xdg_surface = xdg_shell_get_xdg_surface(display->shell, window->surface); assert(window->xdg_surface); xdg_surface_add_listener(window->xdg_surface, &xdg_surface_listener, window); xdg_surface_set_title(window->xdg_surface, "simple-damage"); } else if (display->fshell) { _wl_fullscreen_shell_present_surface(display->fshell, window->surface, _WL_FULLSCREEN_SHELL_PRESENT_METHOD_DEFAULT, NULL); } else { assert(0); } /* Initialise damage to full surface, so the padding gets painted */ wl_surface_damage(window->surface, 0, 0, INT32_MAX, INT32_MAX); return window; }
UwacWindow* UwacCreateWindowShm(UwacDisplay* display, uint32_t width, uint32_t height, enum wl_shm_format format) { UwacWindow* w; int allocSize, ret; if (!display) { return NULL; } w = zalloc(sizeof(*w)); if (!w) { display->last_error = UWAC_ERROR_NOMEMORY; return NULL; } w->display = display; w->format = format; w->width = width; w->height = height; w->stride = width * bppFromShmFormat(format); allocSize = w->stride * height; ret = UwacWindowShmAllocBuffers(w, UWAC_INITIAL_BUFFERS, allocSize, width, height, format); if (ret != UWAC_SUCCESS) { display->last_error = ret; goto out_error_free; } w->buffers[0].used = true; w->drawingBuffer = &w->buffers[0]; w->surface = wl_compositor_create_surface(display->compositor); if (!w->surface) { display->last_error = UWAC_ERROR_NOMEMORY; goto out_error_surface; } wl_surface_set_user_data(w->surface, w); if (display->xdg_shell) { w->xdg_surface = xdg_shell_get_xdg_surface(display->xdg_shell, w->surface); if (!w->xdg_surface) { display->last_error = UWAC_ERROR_NOMEMORY; goto out_error_shell; } assert(w->xdg_surface); xdg_surface_add_listener(w->xdg_surface, &xdg_surface_listener, w); #if BUILD_IVI } else if (display->ivi_application) { w->ivi_surface = ivi_application_surface_create(display->ivi_application, 1, w->surface); assert(w->ivi_surface); ivi_surface_add_listener(w->ivi_surface, &ivi_surface_listener, w); #endif #if BUILD_FULLSCREEN_SHELL } else if (display->fullscreen_shell) { _wl_fullscreen_shell_present_surface(display->fullscreen_shell, w->surface, _WL_FULLSCREEN_SHELL_PRESENT_METHOD_CENTER, NULL); #endif } else { w->shell_surface = wl_shell_get_shell_surface(display->shell, w->surface); assert(w->shell_surface); wl_shell_surface_add_listener(w->shell_surface, &shell_listener, w); wl_shell_surface_set_toplevel(w->shell_surface); } wl_list_insert(display->windows.prev, &w->link); display->last_error = UWAC_SUCCESS; return w; out_error_shell: wl_surface_destroy(w->surface); out_error_surface: UwacWindowDestroyBuffers(w); out_error_free: free(w); return NULL; }