Fix up frame cadence ordering a bit.

This commit is contained in:
Pierre-Loup A. Griffais 2019-11-20 22:52:01 -08:00 committed by Pierre-Loup A. Griffais
parent 825db84b13
commit e36f1f6c5b
2 changed files with 38 additions and 4 deletions

View file

@ -1,3 +1,5 @@
#include <X11/Xlib.h>
#include <thread> #include <thread>
#include <mutex> #include <mutex>
#include <vector> #include <vector>
@ -17,11 +19,15 @@ struct waffle_display *dpy;
struct waffle_window *window; struct waffle_window *window;
struct waffle_context *ctx; struct waffle_context *ctx;
Display *XWLDpy;
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
ac = argc; ac = argc;
av = argv; av = argv;
XInitThreads();
initOutput(); initOutput();
rootston_init(argc, argv); rootston_init(argc, argv);
@ -90,6 +96,27 @@ void wayland_PushSurface(struct wlr_surface *surf, struct wlr_dmabuf_attributes
.attribs = *attribs .attribs = *attribs
}; };
g_vecResListEntries.push_back( newEntry ); 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 ) int steamCompMgr_PullSurface( struct ResListEntry_t *pResEntry )

View file

@ -759,8 +759,16 @@ paint_all (Display *dpy)
overlayDamaged = True; overlayDamaged = True;
} }
if (!w) if ( !w )
{
return; 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 // Don't pump new frames if no animation on the focus window, unless we're fading
if (!w->damaged && !overlayDamaged && !fadeOutWindow.id) if (!w->damaged && !overlayDamaged && !fadeOutWindow.id)
@ -1622,8 +1630,6 @@ void check_new_wayland_res(void)
w->damaged = 1; w->damaged = 1;
w->validContents = True; w->validContents = True;
// TODO tickle the frame loop here somehow if we stay multi-threaded like now
bFound = True; bFound = True;
} }
} }
@ -1823,7 +1829,6 @@ steamcompmgr_main (int argc, char **argv)
focusDirty = False; focusDirty = False;
do { do {
check_new_wayland_res();
XNextEvent (dpy, &ev); XNextEvent (dpy, &ev);
if ((ev.type & 0x7f) != KeymapNotify) if ((ev.type & 0x7f) != KeymapNotify)
discard_ignore (dpy, ev.xany.serial); discard_ignore (dpy, ev.xany.serial);
@ -2068,6 +2073,8 @@ steamcompmgr_main (int argc, char **argv)
struct timespec now; struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now); clock_gettime(CLOCK_MONOTONIC, &now);
check_new_wayland_res();
paint_all(dpy); paint_all(dpy);
// If we're in the middle of a fade, pump an event into the loop to // If we're in the middle of a fade, pump an event into the loop to