diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2019-12-12 06:05:21 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2019-12-12 06:05:21 +0000 |
commit | dff4a3473cbf3db68b2fa5b43e51f8c05ae6b029 (patch) | |
tree | ae898a699dbc977738010eaae623435d2ccee50a /xserver/hw/xwayland | |
parent | 005295117c63143b3bf6d69d4503b360e660cf49 (diff) |
Update to X server 1.20.6. Tested by naddy@
Diffstat (limited to 'xserver/hw/xwayland')
-rw-r--r-- | xserver/hw/xwayland/xwayland-cursor.c | 2 | ||||
-rw-r--r-- | xserver/hw/xwayland/xwayland-glamor-eglstream.c | 1 | ||||
-rw-r--r-- | xserver/hw/xwayland/xwayland-glamor-gbm.c | 38 | ||||
-rw-r--r-- | xserver/hw/xwayland/xwayland-glamor.c | 1 | ||||
-rw-r--r-- | xserver/hw/xwayland/xwayland-input.c | 1 | ||||
-rw-r--r-- | xserver/hw/xwayland/xwayland-output.c | 39 | ||||
-rw-r--r-- | xserver/hw/xwayland/xwayland.c | 159 | ||||
-rw-r--r-- | xserver/hw/xwayland/xwayland.h | 2 |
8 files changed, 201 insertions, 42 deletions
diff --git a/xserver/hw/xwayland/xwayland-cursor.c b/xserver/hw/xwayland/xwayland-cursor.c index cf8395f1d..66720bcc0 100644 --- a/xserver/hw/xwayland/xwayland-cursor.c +++ b/xserver/hw/xwayland/xwayland-cursor.c @@ -188,6 +188,8 @@ xwl_tablet_tool_set_cursor(struct xwl_tablet_tool *xwl_tablet_tool) zwp_tablet_tool_v2_set_cursor(xwl_tablet_tool->tool, xwl_tablet_tool->proximity_in_serial, NULL, 0, 0); + clear_cursor_frame_callback(xwl_cursor); + xwl_cursor->needs_update = FALSE; return; } diff --git a/xserver/hw/xwayland/xwayland-glamor-eglstream.c b/xserver/hw/xwayland/xwayland-glamor-eglstream.c index c62c0d2ac..36b749aaf 100644 --- a/xserver/hw/xwayland/xwayland-glamor-eglstream.c +++ b/xserver/hw/xwayland/xwayland-glamor-eglstream.c @@ -33,6 +33,7 @@ #include "wayland-eglstream-controller-client-protocol.h" #define MESA_EGL_NO_X11_HEADERS +#define EGL_NO_X11 #include <glamor_egl.h> #include <glamor.h> #include <glamor_transform.h> diff --git a/xserver/hw/xwayland/xwayland-glamor-gbm.c b/xserver/hw/xwayland/xwayland-glamor-gbm.c index a211e0915..febc0b910 100644 --- a/xserver/hw/xwayland/xwayland-glamor-gbm.c +++ b/xserver/hw/xwayland/xwayland-glamor-gbm.c @@ -36,6 +36,7 @@ #include <drm_fourcc.h> #define MESA_EGL_NO_X11_HEADERS +#define EGL_NO_X11 #include <gbm.h> #include <glamor_egl.h> @@ -169,6 +170,8 @@ xwl_glamor_gbm_create_pixmap_for_bo(ScreenPtr screen, struct gbm_bo *bo, xwl_screen->egl_context, EGL_NATIVE_PIXMAP_KHR, xwl_pixmap->bo, NULL); + if (xwl_pixmap->image == EGL_NO_IMAGE_KHR) + goto error; glGenTextures(1, &xwl_pixmap->texture); glBindTexture(GL_TEXTURE_2D, xwl_pixmap->texture); @@ -176,14 +179,31 @@ xwl_glamor_gbm_create_pixmap_for_bo(ScreenPtr screen, struct gbm_bo *bo, glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, xwl_pixmap->image); - glBindTexture(GL_TEXTURE_2D, 0); + if (eglGetError() != EGL_SUCCESS) + goto error; - xwl_pixmap_set_private(pixmap, xwl_pixmap); + glBindTexture(GL_TEXTURE_2D, 0); glamor_set_pixmap_texture(pixmap, xwl_pixmap->texture); + /* `set_pixmap_texture()` may fail silently if the FBO creation failed, + * so we check again the texture to be sure it worked. + */ + if (!glamor_get_pixmap_texture(pixmap)) + goto error; + glamor_set_pixmap_type(pixmap, GLAMOR_TEXTURE_DRM); + xwl_pixmap_set_private(pixmap, xwl_pixmap); return pixmap; + +error: + if (xwl_pixmap->image != EGL_NO_IMAGE_KHR) + eglDestroyImageKHR(xwl_screen->egl_display, xwl_pixmap->image); + if (pixmap) + glamor_destroy_pixmap(pixmap); + free(xwl_pixmap); + + return NULL; } static PixmapPtr @@ -194,6 +214,7 @@ xwl_glamor_gbm_create_pixmap(ScreenPtr screen, struct xwl_screen *xwl_screen = xwl_screen_get(screen); struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen); struct gbm_bo *bo; + PixmapPtr pixmap = NULL; if (width > 0 && height > 0 && depth >= 15 && (hint == 0 || @@ -218,11 +239,18 @@ xwl_glamor_gbm_create_pixmap(ScreenPtr screen, GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING); } - if (bo) - return xwl_glamor_gbm_create_pixmap_for_bo(screen, bo, depth); + if (bo) { + pixmap = xwl_glamor_gbm_create_pixmap_for_bo(screen, bo, depth); + + if (!pixmap) + gbm_bo_destroy(bo); + } } - return glamor_create_pixmap(screen, width, height, depth, hint); + if (!pixmap) + pixmap = glamor_create_pixmap(screen, width, height, depth, hint); + + return pixmap; } static Bool diff --git a/xserver/hw/xwayland/xwayland-glamor.c b/xserver/hw/xwayland/xwayland-glamor.c index 7ea6def61..48e330a0f 100644 --- a/xserver/hw/xwayland/xwayland-glamor.c +++ b/xserver/hw/xwayland/xwayland-glamor.c @@ -26,6 +26,7 @@ #include "xwayland.h" #define MESA_EGL_NO_X11_HEADERS +#define EGL_NO_X11 #include <glamor_egl.h> #include <glamor.h> diff --git a/xserver/hw/xwayland/xwayland-input.c b/xserver/hw/xwayland/xwayland-input.c index fbbcb39cc..fa46ac3e7 100644 --- a/xserver/hw/xwayland/xwayland-input.c +++ b/xserver/hw/xwayland/xwayland-input.c @@ -2667,6 +2667,7 @@ xwl_pointer_warp_emulator_maybe_lock(struct xwl_pointer_warp_emulator *warp_emul */ if (pointer_grab && !pointer_grab->ownerEvents && + sprite && XYToWindow(sprite, x, y) != xwl_seat->focus_window->window) return; diff --git a/xserver/hw/xwayland/xwayland-output.c b/xserver/hw/xwayland/xwayland-output.c index cc68f0340..aa6f37864 100644 --- a/xserver/hw/xwayland/xwayland-output.c +++ b/xserver/hw/xwayland/xwayland-output.c @@ -171,6 +171,40 @@ approximate_mmpd(struct xwl_screen *xwl_screen) return 25.4 / DEFAULT_DPI; } +static int +xwl_set_pixmap_visit_window(WindowPtr window, void *data) +{ + ScreenPtr screen = window->drawable.pScreen; + + if (screen->GetWindowPixmap(window) == data) { + screen->SetWindowPixmap(window, screen->GetScreenPixmap(screen)); + return WT_WALKCHILDREN; + } + + return WT_DONTWALKCHILDREN; +} + +static void +update_backing_pixmaps(struct xwl_screen *xwl_screen, int width, int height) +{ + ScreenPtr pScreen = xwl_screen->screen; + WindowPtr pRoot = pScreen->root; + PixmapPtr old_pixmap, new_pixmap; + + old_pixmap = pScreen->GetScreenPixmap(pScreen); + new_pixmap = pScreen->CreatePixmap(pScreen, width, height, + pScreen->rootDepth, + CREATE_PIXMAP_USAGE_BACKING_PIXMAP); + pScreen->SetScreenPixmap(new_pixmap); + + if (old_pixmap) { + TraverseTree(pRoot, xwl_set_pixmap_visit_window, old_pixmap); + pScreen->DestroyPixmap(old_pixmap); + } + + pScreen->ResizeWindow(pRoot, 0, 0, width, height, NULL); +} + static void update_screen_size(struct xwl_output *xwl_output, int width, int height) { @@ -180,6 +214,9 @@ update_screen_size(struct xwl_output *xwl_output, int width, int height) if (xwl_screen->root_clip_mode == ROOT_CLIP_FULL) SetRootClip(xwl_screen->screen, ROOT_CLIP_NONE); + if (!xwl_screen->rootless && xwl_screen->screen->root) + update_backing_pixmaps (xwl_screen, width, height); + xwl_screen->width = width; xwl_screen->height = height; xwl_screen->screen->width = width; @@ -439,7 +476,7 @@ xwl_screen_init_output(struct xwl_screen *xwl_screen) if (!RRScreenInit(xwl_screen->screen)) return FALSE; - RRScreenSetSizeRange(xwl_screen->screen, 320, 200, 8192, 8192); + RRScreenSetSizeRange(xwl_screen->screen, 16, 16, 32767, 32767); rp = rrGetScrPriv(xwl_screen->screen); rp->rrGetInfo = xwl_randr_get_info; diff --git a/xserver/hw/xwayland/xwayland.c b/xserver/hw/xwayland/xwayland.c index 7e6e0ab25..baa08d87b 100644 --- a/xserver/hw/xwayland/xwayland.c +++ b/xserver/hw/xwayland/xwayland.c @@ -125,6 +125,7 @@ ddxProcessArgument(int argc, char *argv[], int i) static DevPrivateKeyRec xwl_window_private_key; static DevPrivateKeyRec xwl_screen_private_key; static DevPrivateKeyRec xwl_pixmap_private_key; +static DevPrivateKeyRec xwl_damage_private_key; static struct xwl_window * xwl_window_get(WindowPtr window) @@ -367,8 +368,14 @@ xwl_cursor_confined_to(DeviceIntPtr device, static void damage_report(DamagePtr pDamage, RegionPtr pRegion, void *data) { - struct xwl_window *xwl_window = data; - struct xwl_screen *xwl_screen = xwl_window->xwl_screen; + WindowPtr window = data; + struct xwl_window *xwl_window = xwl_window_get(window); + struct xwl_screen *xwl_screen; + + if (!xwl_window) + return; + + xwl_screen = xwl_window->xwl_screen; #ifdef GLAMOR_HAS_GBM if (xwl_window->present_flipped) { @@ -390,6 +397,47 @@ damage_destroy(DamagePtr pDamage, void *data) { } +static Bool +register_damage(WindowPtr window) +{ + DamagePtr damage; + + damage = DamageCreate(damage_report, damage_destroy, DamageReportNonEmpty, + FALSE, window->drawable.pScreen, window); + if (damage == NULL) { + ErrorF("Failed creating damage\n"); + return FALSE; + } + + DamageRegister(&window->drawable, damage); + DamageSetReportAfterOp(damage, TRUE); + + dixSetPrivate(&window->devPrivates, &xwl_damage_private_key, damage); + + return TRUE; +} + +static void +unregister_damage(WindowPtr window) +{ + DamagePtr damage; + + damage = dixLookupPrivate(&window->devPrivates, &xwl_damage_private_key); + if (!damage) + return; + + DamageUnregister(damage); + DamageDestroy(damage); + + dixSetPrivate(&window->devPrivates, &xwl_damage_private_key, NULL); +} + +static DamagePtr +window_get_damage(WindowPtr window) +{ + return dixLookupPrivate(&window->devPrivates, &xwl_damage_private_key); +} + static void shell_surface_ping(void *data, struct wl_shell_surface *shell_surface, uint32_t serial) @@ -470,36 +518,25 @@ send_surface_id_event(struct xwl_window *xwl_window) } static Bool -xwl_realize_window(WindowPtr window) +ensure_surface_for_window(WindowPtr window) { ScreenPtr screen = window->drawable.pScreen; struct xwl_screen *xwl_screen; struct xwl_window *xwl_window; struct wl_region *region; - Bool ret; - - xwl_screen = xwl_screen_get(screen); - - screen->RealizeWindow = xwl_screen->RealizeWindow; - ret = (*screen->RealizeWindow) (window); - xwl_screen->RealizeWindow = screen->RealizeWindow; - screen->RealizeWindow = xwl_realize_window; - if (xwl_screen->rootless && !window->parent) { - BoxRec box = { 0, 0, xwl_screen->width, xwl_screen->height }; + if (xwl_window_get(window)) + return TRUE; - RegionReset(&window->winSize, &box); - RegionNull(&window->clipList); - RegionNull(&window->borderClip); - } + xwl_screen = xwl_screen_get(screen); if (xwl_screen->rootless) { if (window->redirectDraw != RedirectDrawManual) - return ret; + return TRUE; } else { if (window->parent) - return ret; + return TRUE; } xwl_window = calloc(1, sizeof *xwl_window); @@ -545,25 +582,14 @@ xwl_realize_window(WindowPtr window) wl_surface_set_user_data(xwl_window->surface, xwl_window); - xwl_window->damage = - DamageCreate(damage_report, damage_destroy, DamageReportNonEmpty, - FALSE, screen, xwl_window); - if (xwl_window->damage == NULL) { - ErrorF("Failed creating damage\n"); - goto err_surf; - } - compRedirectWindow(serverClient, window, CompositeRedirectManual); - DamageRegister(&window->drawable, xwl_window->damage); - DamageSetReportAfterOp(xwl_window->damage, TRUE); - dixSetPrivate(&window->devPrivates, &xwl_window_private_key, xwl_window); xorg_list_init(&xwl_window->link_damage); xwl_window_init_allow_commits(xwl_window); - return ret; + return TRUE; err_surf: if (xwl_window->shell_surface) @@ -575,6 +601,42 @@ err: } static Bool +xwl_realize_window(WindowPtr window) +{ + ScreenPtr screen = window->drawable.pScreen; + struct xwl_screen *xwl_screen; + Bool ret; + + xwl_screen = xwl_screen_get(screen); + + screen->RealizeWindow = xwl_screen->RealizeWindow; + ret = (*screen->RealizeWindow) (window); + xwl_screen->RealizeWindow = screen->RealizeWindow; + screen->RealizeWindow = xwl_realize_window; + + if (!ret) + return FALSE; + + if (xwl_screen->rootless && !window->parent) { + BoxRec box = { 0, 0, xwl_screen->width, xwl_screen->height }; + + RegionReset(&window->winSize, &box); + RegionNull(&window->clipList); + RegionNull(&window->borderClip); + } + + if (xwl_screen->rootless ? + (window->drawable.class == InputOutput && + window->parent == window->drawable.pScreen->root) : + !window->parent) { + if (!register_damage(window)) + return FALSE; + } + + return ensure_surface_for_window(window); +} + +static Bool xwl_unrealize_window(WindowPtr window) { ScreenPtr screen = window->drawable.pScreen; @@ -620,8 +682,8 @@ xwl_unrealize_window(WindowPtr window) wl_surface_destroy(xwl_window->surface); xorg_list_del(&xwl_window->link_damage); - DamageUnregister(xwl_window->damage); - DamageDestroy(xwl_window->damage); + unregister_damage(window); + if (xwl_window->frame_callback) wl_callback_destroy(xwl_window->frame_callback); @@ -638,6 +700,26 @@ xwl_save_screen(ScreenPtr pScreen, int on) } static void +xwl_set_window_pixmap(WindowPtr window, + PixmapPtr pixmap) +{ + ScreenPtr screen = window->drawable.pScreen; + struct xwl_screen *xwl_screen; + + xwl_screen = xwl_screen_get(screen); + + screen->SetWindowPixmap = xwl_screen->SetWindowPixmap; + (*screen->SetWindowPixmap) (window, pixmap); + xwl_screen->SetWindowPixmap = screen->SetWindowPixmap; + screen->SetWindowPixmap = xwl_set_window_pixmap; + + if (!RegionNotEmpty(&window->winSize)) + return; + + ensure_surface_for_window(window); +} + +static void frame_callback(void *data, struct wl_callback *callback, uint32_t time) @@ -689,7 +771,7 @@ xwl_window_post_damage(struct xwl_window *xwl_window) assert(!xwl_window->frame_callback); - region = DamageRegion(xwl_window->damage); + region = DamageRegion(window_get_damage(xwl_window->window)); pixmap = (*xwl_screen->screen->GetWindowPixmap) (xwl_window->window); #ifdef XWL_HAS_GLAMOR @@ -726,7 +808,7 @@ xwl_window_post_damage(struct xwl_window *xwl_window) wl_callback_add_listener(xwl_window->frame_callback, &frame_listener, xwl_window); wl_surface_commit(xwl_window->surface); - DamageEmpty(xwl_window->damage); + DamageEmpty(window_get_damage(xwl_window->window)); xorg_list_del(&xwl_window->link_damage); } @@ -962,6 +1044,8 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv) return FALSE; if (!dixRegisterPrivateKey(&xwl_pixmap_private_key, PRIVATE_PIXMAP, 0)) return FALSE; + if (!dixRegisterPrivateKey(&xwl_damage_private_key, PRIVATE_WINDOW, 0)) + return FALSE; dixSetPrivate(&pScreen->devPrivates, &xwl_screen_private_key, xwl_screen); xwl_screen->screen = pScreen; @@ -1121,6 +1205,11 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv) xwl_screen->CloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = xwl_close_screen; + if (xwl_screen->rootless) { + xwl_screen->SetWindowPixmap = pScreen->SetWindowPixmap; + pScreen->SetWindowPixmap = xwl_set_window_pixmap; + } + pScreen->CursorWarpedTo = xwl_cursor_warped_to; pScreen->CursorConfinedTo = xwl_cursor_confined_to; diff --git a/xserver/hw/xwayland/xwayland.h b/xserver/hw/xwayland/xwayland.h index 463622669..0854df456 100644 --- a/xserver/hw/xwayland/xwayland.h +++ b/xserver/hw/xwayland/xwayland.h @@ -133,6 +133,7 @@ struct xwl_screen { UnrealizeWindowProcPtr UnrealizeWindow; DestroyWindowProcPtr DestroyWindow; XYToWindowProcPtr XYToWindow; + SetWindowPixmapProcPtr SetWindowPixmap; struct xorg_list output_list; struct xorg_list seat_list; @@ -178,7 +179,6 @@ struct xwl_window { struct wl_surface *surface; struct wl_shell_surface *shell_surface; WindowPtr window; - DamagePtr damage; struct xorg_list link_damage; struct wl_callback *frame_callback; Bool allow_commits; |