diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2020-07-11 12:21:54 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2020-07-11 13:36:42 -0700 |
commit | f650c8838e7382cb38e27c4147fa8e69328cdfa0 (patch) | |
tree | e866ff7fd07c5923bc14a09d97960e0f6eb6e8fd /recordmydesktop | |
parent | 5b7026676952fffe82ece362f21d190f8aac66a0 (diff) |
setbrwindow: formatting cleanups
Nothing significant changed
Diffstat (limited to 'recordmydesktop')
-rw-r--r-- | recordmydesktop/src/rmd_setbrwindow.c | 70 |
1 files changed, 39 insertions, 31 deletions
diff --git a/recordmydesktop/src/rmd_setbrwindow.c b/recordmydesktop/src/rmd_setbrwindow.c index 34bde1d..9ad30b8 100644 --- a/recordmydesktop/src/rmd_setbrwindow.c +++ b/recordmydesktop/src/rmd_setbrwindow.c @@ -36,33 +36,37 @@ boolean rmdSetBRWindow( Display *dpy, ProgArgs *args) { //before we start recording we have to make sure the ranges are valid - if (args->windowid==0) {//root window + if (args->windowid == 0) {//root window //first set it up - brwin->windowid=specs->root; - brwin->winrect.x=brwin->winrect.y=0; - brwin->winrect.width=specs->width; - brwin->winrect.height=specs->height; - brwin->rrect.x=args->x; - brwin->rrect.y=args->y; - brwin->rrect.width=((args->width)? args->width:specs->width-brwin->rrect.x); - brwin->rrect.height=((args->height)? args->height:specs->height-brwin->rrect.y); + brwin->windowid = specs->root; + brwin->winrect.x = 0; + brwin->winrect.y = 0; + brwin->winrect.width = specs->width; + brwin->winrect.height = specs->height; + + brwin->rrect.x = args->x; + brwin->rrect.y = args->y; + brwin->rrect.width = args->width ? args->width : brwin->winrect.width - args->x; + brwin->rrect.height = args->height ? args->height : brwin->winrect.height - args->y; + //and then check validity - if ((brwin->rrect.x+brwin->rrect.width>specs->width)|| - (brwin->rrect.y+brwin->rrect.height>specs->height)) { + if ( brwin->rrect.x + brwin->rrect.width > specs->width || + brwin->rrect.y + brwin->rrect.height > specs->height) { + fprintf(stderr, "Window size specification out of bounds!" "(current resolution:%dx%d)\n", - specs->width,specs->height); + specs->width, specs->height); return FALSE; } } else { - Window wchid; - int transl_x,transl_y; + int transl_x, transl_y; + Window wchid; + XWindowAttributes attribs; - XWindowAttributes attribs; - XGetWindowAttributes(dpy,args->windowid,&attribs); + XGetWindowAttributes(dpy, args->windowid, &attribs); - if ((attribs.map_state==IsUnviewable)||(attribs.map_state==IsUnmapped)) { - fprintf(stderr,"Window must be mapped and visible!\n"); + if (attribs.map_state == IsUnviewable || attribs.map_state == IsUnmapped) { + fprintf(stderr, "Window must be mapped and visible!\n"); return FALSE; } @@ -75,25 +79,29 @@ boolean rmdSetBRWindow( Display *dpy, &transl_y, &wchid); - brwin->winrect.x=attribs.x-transl_x; - brwin->winrect.y=attribs.y-transl_y; - brwin->winrect.width=attribs.width; - brwin->winrect.height=attribs.height; + brwin->winrect.x = attribs.x - transl_x; + brwin->winrect.y = attribs.y - transl_y; + brwin->winrect.width = attribs.width; + brwin->winrect.height = attribs.height; + + /* XXX FIXME: this check is partial at best, surely windows can be off the low + * sides of the screen too... + */ + if ( brwin->winrect.x + brwin->winrect.width > specs->width || + brwin->winrect.y + brwin->winrect.height > specs->height) { - if ((brwin->winrect.x+brwin->winrect.width>specs->width)|| - (brwin->winrect.y+brwin->winrect.height>specs->height)) { fprintf(stderr,"Window must be on visible screen area!\n"); return FALSE; } - brwin->rrect.x=brwin->winrect.x+args->x; - brwin->rrect.y=brwin->winrect.y+args->y; - brwin->rrect.width=((args->width)? args->width:brwin->winrect.width-args->x); - brwin->rrect.height=((args->height)? args->height:brwin->winrect.height-args->y); + brwin->rrect.x = brwin->winrect.x + args->x; + brwin->rrect.y = brwin->winrect.y + args->y; + brwin->rrect.width = args->width ? args->width : brwin->winrect.width - args->x; + brwin->rrect.height = args->height ? args->height : brwin->winrect.height - args->y; - if ((args->x+brwin->rrect.width>brwin->winrect.width)|| - (args->y+brwin->rrect.height>brwin->winrect.height)) { - fprintf(stderr,"Specified Area is larger than window!\n"); + if ( args->x + brwin->rrect.width > brwin->winrect.width || + args->y + brwin->rrect.height > brwin->winrect.height) { + fprintf(stderr, "Specified Area is larger than window!\n"); return FALSE; } } |