From e36f1f6c5b17b08317d585309ca1bd6a31969928 Mon Sep 17 00:00:00 2001 From: "Pierre-Loup A. Griffais" Date: Wed, 20 Nov 2019 22:52:01 -0800 Subject: [PATCH] Fix up frame cadence ordering a bit. --- src/main.cpp | 27 +++++++++++++++++++++++++++ src/steamcompmgr.c | 15 +++++++++++---- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index c865604..f3ce86b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,3 +1,5 @@ +#include + #include #include #include @@ -17,11 +19,15 @@ struct waffle_display *dpy; struct waffle_window *window; struct waffle_context *ctx; +Display *XWLDpy; + int main(int argc, char **argv) { ac = argc; av = argv; + XInitThreads(); + initOutput(); rootston_init(argc, argv); @@ -90,6 +96,27 @@ void wayland_PushSurface(struct wlr_surface *surf, struct wlr_dmabuf_attributes .attribs = *attribs }; g_vecResListEntries.push_back( newEntry ); + + static bool bHasNestedDisplay = false; + + if ( bHasNestedDisplay == false ) + { + // This should open the nested XWayland display as our environment changed during Xwayland init + XWLDpy = XOpenDisplay( nullptr ); + + bHasNestedDisplay = true; + } + + static XEvent XWLExposeEvent = { + .xexpose { + .type = Expose, + .window = DefaultRootWindow( XWLDpy ), + .width = 1, + .height = 1 + } + }; + + XSendEvent( XWLDpy , DefaultRootWindow( XWLDpy ), True, ExposureMask, &XWLExposeEvent); } int steamCompMgr_PullSurface( struct ResListEntry_t *pResEntry ) diff --git a/src/steamcompmgr.c b/src/steamcompmgr.c index 2494160..f6d47e8 100644 --- a/src/steamcompmgr.c +++ b/src/steamcompmgr.c @@ -759,8 +759,16 @@ paint_all (Display *dpy) overlayDamaged = True; } - if (!w) + if ( !w ) + { return; + } + + // If the window has never been rendered to, there isn't much we can do here, wait a bit. + if ( !w->validContents ) + { + return; + } // Don't pump new frames if no animation on the focus window, unless we're fading if (!w->damaged && !overlayDamaged && !fadeOutWindow.id) @@ -1622,8 +1630,6 @@ void check_new_wayland_res(void) w->damaged = 1; w->validContents = True; - // TODO tickle the frame loop here somehow if we stay multi-threaded like now - bFound = True; } } @@ -1823,7 +1829,6 @@ steamcompmgr_main (int argc, char **argv) focusDirty = False; do { - check_new_wayland_res(); XNextEvent (dpy, &ev); if ((ev.type & 0x7f) != KeymapNotify) discard_ignore (dpy, ev.xany.serial); @@ -2068,6 +2073,8 @@ steamcompmgr_main (int argc, char **argv) struct timespec now; clock_gettime(CLOCK_MONOTONIC, &now); + check_new_wayland_res(); + paint_all(dpy); // If we're in the middle of a fade, pump an event into the loop to