diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2022-02-05 08:19:03 -0800 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2022-02-05 08:27:38 -0800 |
commit | 1004781e00cf4e231e59d8ef6342de044bf0b5ce (patch) | |
tree | 448baccf0b19f290c58065deb4d5a9289c7db2cc /src | |
parent | 4dbf8f54a5d98a10708b20416b9a4a1282865f97 (diff) |
setbrwindow: wait for window instead of exiting
When --windowid specifies a window that hasn't yet been mapped
this thing would just exit.
But in scripted invocations where a window of interest is created
and mapped by the client immediately prior to launching
recordMyDesktop, there's a good chance the window manager hasn't
yet handled the MapRequest before recordMyDesktop launched and
attempted to get the window's attributes.
This change subscribes to the window's visibility and structure
events when the attributes show it's not yet mapped and visible,
entering into an event loop waiting for the window.
No timeout has been added at this time.
Some interesting directions to go from here:
- Pause recording on unmap, resume recording on map
- Follow the window if it moves
- It'd be nice if recording could handle window resizes, but
especially for on-the-fly encoding this seems awkward at best.
For cached recordings the encode could start with the largest
dimensions and simply pad out any smaller frames.
I'll have to look at Theora to see if there is any support for
variable sized video streams.
Fixes https://github.com/recordmydesktop/recordmydesktop/issues/7
Diffstat (limited to 'src')
-rw-r--r-- | src/rmd_setbrwindow.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/rmd_setbrwindow.c b/src/rmd_setbrwindow.c index 846abe6..08d0997 100644 --- a/src/rmd_setbrwindow.c +++ b/src/rmd_setbrwindow.c @@ -63,11 +63,15 @@ boolean rmdSetBRWindow( Display *dpy, Window wchid; XWindowAttributes attribs; + XSelectInput(dpy, args->windowid, VisibilityChangeMask | StructureNotifyMask); XGetWindowAttributes(dpy, args->windowid, &attribs); - if (attribs.map_state == IsUnviewable || attribs.map_state == IsUnmapped) { - fprintf(stderr, "Window must be mapped and visible!\n"); - return FALSE; + while (attribs.map_state == IsUnviewable || attribs.map_state == IsUnmapped) { + XEvent ev; + + fprintf(stderr, "Waiting for window to be mapped and visible!\n"); + XWindowEvent(dpy, args->windowid, VisibilityChangeMask|StructureNotifyMask, &ev); + XGetWindowAttributes(dpy, args->windowid, &attribs); } XTranslateCoordinates( dpy, |