diff options
author | Luca Barbato | 2014-08-27 04:43:48 +0200 |
---|---|---|
committer | Diego Biurrun | 2014-08-28 15:20:12 +0200 |
commit | 20e82b41fcad23ebbb18d89948aebfcc53921198 (patch) | |
tree | 4d3fc6ad2ecdb4be06e24d524d3dd8fff012f111 /libavdevice | |
parent | f07a4290a0e8f31796e348edd3ed06b8d15132d8 (diff) |
x11grab: Small near-cosmetic refactorings
Signed-off-by: Diego Biurrun <diego@biurrun.de>
Diffstat (limited to 'libavdevice')
-rw-r--r-- | libavdevice/x11grab.c | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/libavdevice/x11grab.c b/libavdevice/x11grab.c index 0ff5a31d8d..c707ae82ac 100644 --- a/libavdevice/x11grab.c +++ b/libavdevice/x11grab.c @@ -95,11 +95,9 @@ static void x11grab_draw_region_win(struct x11grab *s) { Display *dpy = s->dpy; Window win = s->region_win; - int screen; - GC gc; + int screen = DefaultScreen(dpy); + GC gc = XCreateGC(dpy, win, 0, 0); - screen = DefaultScreen(dpy); - gc = XCreateGC(dpy, win, 0, 0); XSetForeground(dpy, gc, WhitePixel(dpy, screen)); XSetBackground(dpy, gc, BlackPixel(dpy, screen)); XSetLineAttributes(dpy, gc, REGION_WIN_BORDER, LineDoubleDash, 0, 0); @@ -117,12 +115,10 @@ static void x11grab_draw_region_win(struct x11grab *s) static void x11grab_region_win_init(struct x11grab *s) { Display *dpy = s->dpy; - int screen; - XSetWindowAttributes attribs; XRectangle rect; + XSetWindowAttributes attribs = { .override_redirect = True }; + int screen = DefaultScreen(dpy); - screen = DefaultScreen(dpy); - attribs.override_redirect = True; s->region_win = XCreateWindow(dpy, RootWindow(dpy, screen), s->x_off - REGION_WIN_BORDER, s->y_off - REGION_WIN_BORDER, @@ -160,12 +156,8 @@ static int x11grab_read_header(AVFormatContext *s1) AVStream *st = NULL; enum AVPixelFormat input_pixfmt; XImage *image; - int x_off = 0; - int y_off = 0; - int screen; - int use_shm; + int x_off = 0, y_off = 0, ret = 0, screen, use_shm; char *param, *offset; - int ret = 0; AVRational framerate; param = av_strdup(s1->filename); @@ -179,12 +171,15 @@ static int x11grab_read_header(AVFormatContext *s1) *offset = 0; } - if ((ret = av_parse_video_size(&x11grab->width, &x11grab->height, - x11grab->video_size)) < 0) { + ret = av_parse_video_size(&x11grab->width, &x11grab->height, + x11grab->video_size); + if (ret < 0) { av_log(s1, AV_LOG_ERROR, "Couldn't parse video size.\n"); goto out; } - if ((ret = av_parse_video_rate(&framerate, x11grab->framerate)) < 0) { + + ret = av_parse_video_rate(&framerate, x11grab->framerate); + if (ret < 0) { av_log(s1, AV_LOG_ERROR, "Could not parse framerate: %s.\n", x11grab->framerate); goto out; @@ -531,10 +526,10 @@ static int x11grab_read_packet(AVFormatContext *s1, AVPacket *pkt) if (s->show_region) { if (s->region_win) { - XEvent evt; - // clean up the events, and do the initinal draw or redraw. - for (evt.type = NoEventMask; - XCheckMaskEvent(dpy, ExposureMask | StructureNotifyMask, &evt);) + XEvent evt = { .type = NoEventMask }; + // Clean up the events, and do the initial draw or redraw. + while (XCheckMaskEvent(dpy, ExposureMask | StructureNotifyMask, + &evt)) ; if (evt.type) x11grab_draw_region_win(s); |