diff options
Diffstat (limited to 'recordmydesktop')
-rw-r--r-- | recordmydesktop/src/rmd_cache.c | 8 | ||||
-rw-r--r-- | recordmydesktop/src/rmd_cache_frame.c | 2 | ||||
-rw-r--r-- | recordmydesktop/src/rmd_get_frame.c | 182 | ||||
-rw-r--r-- | recordmydesktop/src/rmd_init_encoder.c | 4 | ||||
-rw-r--r-- | recordmydesktop/src/rmd_poll_events.c | 74 | ||||
-rw-r--r-- | recordmydesktop/src/rmd_rectinsert.c | 398 | ||||
-rw-r--r-- | recordmydesktop/src/rmd_rectinsert.h | 4 | ||||
-rw-r--r-- | recordmydesktop/src/rmd_rescue.c | 15 | ||||
-rw-r--r-- | recordmydesktop/src/rmd_setbrwindow.c | 68 | ||||
-rw-r--r-- | recordmydesktop/src/rmd_specsfile.c | 8 | ||||
-rw-r--r-- | recordmydesktop/src/rmd_types.h | 18 | ||||
-rw-r--r-- | recordmydesktop/src/rmd_update_image.c | 22 | ||||
-rw-r--r-- | recordmydesktop/src/test-rectinsert-data.c | 16 | ||||
-rw-r--r-- | recordmydesktop/src/test-rectinsert-types.h | 2 | ||||
-rw-r--r-- | recordmydesktop/src/test-rectinsert.c | 34 |
15 files changed, 424 insertions, 431 deletions
diff --git a/recordmydesktop/src/rmd_cache.c b/recordmydesktop/src/rmd_cache.c index 5fe5207..536d217 100644 --- a/recordmydesktop/src/rmd_cache.c +++ b/recordmydesktop/src/rmd_cache.c @@ -132,10 +132,10 @@ void InitCacheData(ProgData *pdata, //we set the buffer only since there's //no need to initialize the encoder from now. - width=((pdata->brwin.rgeom.width + 15) >>4)<<4; - height=((pdata->brwin.rgeom.height + 15) >>4)<<4; - offset_x=((width-pdata->brwin.rgeom.width)/2)&~1; - offset_y=((height-pdata->brwin.rgeom.height)/2)&~1; + width=((pdata->brwin.rrect.width + 15) >>4)<<4; + height=((pdata->brwin.rrect.height + 15) >>4)<<4; + offset_x=((width-pdata->brwin.rrect.width)/2)&~1; + offset_y=((height-pdata->brwin.rrect.height)/2)&~1; (pdata)->enc_data=enc_data_t; diff --git a/recordmydesktop/src/rmd_cache_frame.c b/recordmydesktop/src/rmd_cache_frame.c index a702ef0..03e3506 100644 --- a/recordmydesktop/src/rmd_cache_frame.c +++ b/recordmydesktop/src/rmd_cache_frame.c @@ -266,7 +266,7 @@ void *CacheImageBuffer(ProgData *pdata){ { unsigned int bytes_per_pixel = pdata->specs.depth >= 24 ? 4 : 2; - unsigned int pixels_per_frame = pdata->brwin.rgeom.width * pdata->brwin.rgeom.height; + unsigned int pixels_per_frame = pdata->brwin.rrect.width * pdata->brwin.rrect.height; total_received_bytes = ((unsigned int)frameno) * bytes_per_pixel * pixels_per_frame; } diff --git a/recordmydesktop/src/rmd_get_frame.c b/recordmydesktop/src/rmd_get_frame.c index 786a078..acbb6e2 100644 --- a/recordmydesktop/src/rmd_get_frame.c +++ b/recordmydesktop/src/rmd_get_frame.c @@ -51,41 +51,41 @@ data_array[(k_tm*width_img+i_tm-1)*RMD_ULONG_SIZE_T+offset]+\ data_array[((k_tm-1)*width_img+i_tm-1)*RMD_ULONG_SIZE_T+offset])/4) -#define CLIP_DUMMY_POINTER_AREA(dummy_p_area,brwin,wgeom){\ - (wgeom)->x=((((dummy_p_area).x+\ - (dummy_p_area).width>=(brwin)->rgeom.x)&&\ - ((dummy_p_area).x<=(brwin)->rgeom.x+\ - (brwin)->rgeom.width))?\ - (((dummy_p_area).x<=(brwin)->rgeom.x)?\ - (brwin)->rgeom.x:(dummy_p_area).x):-1);\ - (wgeom)->y=((((dummy_p_area).y+\ - (dummy_p_area).height>=(brwin)->rgeom.y)&&\ - ((dummy_p_area).y<=(brwin)->rgeom.y+\ - (brwin)->rgeom.height))?\ - (((dummy_p_area).y<=(brwin)->rgeom.y)?\ - (brwin)->rgeom.y:(dummy_p_area).y):-1);\ - (wgeom)->width=((dummy_p_area).x<=(brwin)->rgeom.x)?\ +#define CLIP_DUMMY_POINTER_AREA(dummy_p_area,brwin,xrect){\ + (xrect)->x=((((dummy_p_area).x+\ + (dummy_p_area).width>=(brwin)->rrect.x)&&\ + ((dummy_p_area).x<=(brwin)->rrect.x+\ + (brwin)->rrect.width))?\ + (((dummy_p_area).x<=(brwin)->rrect.x)?\ + (brwin)->rrect.x:(dummy_p_area).x):-1);\ + (xrect)->y=((((dummy_p_area).y+\ + (dummy_p_area).height>=(brwin)->rrect.y)&&\ + ((dummy_p_area).y<=(brwin)->rrect.y+\ + (brwin)->rrect.height))?\ + (((dummy_p_area).y<=(brwin)->rrect.y)?\ + (brwin)->rrect.y:(dummy_p_area).y):-1);\ + (xrect)->width=((dummy_p_area).x<=(brwin)->rrect.x)?\ (dummy_p_area).width-\ - ((brwin)->rgeom.x-(dummy_p_area).x):\ - ((dummy_p_area).x<=(brwin)->rgeom.x+\ - (brwin)->rgeom.width)?\ - ((brwin)->rgeom.width-(dummy_p_area).x+\ - (brwin)->rgeom.x<(dummy_p_area).width)?\ - (brwin)->rgeom.width-(dummy_p_area).x+\ - (brwin)->rgeom.x:(dummy_p_area).width:-1;\ - (wgeom)->height=((dummy_p_area).y<=(brwin)->rgeom.y)?\ + ((brwin)->rrect.x-(dummy_p_area).x):\ + ((dummy_p_area).x<=(brwin)->rrect.x+\ + (brwin)->rrect.width)?\ + ((brwin)->rrect.width-(dummy_p_area).x+\ + (brwin)->rrect.x<(dummy_p_area).width)?\ + (brwin)->rrect.width-(dummy_p_area).x+\ + (brwin)->rrect.x:(dummy_p_area).width:0;\ + (xrect)->height=((dummy_p_area).y<=(brwin)->rrect.y)?\ (dummy_p_area).height-\ - ((brwin)->rgeom.y-(dummy_p_area).y):\ - ((dummy_p_area).y<=(brwin)->rgeom.y+\ - (brwin)->rgeom.height)?\ - ((brwin)->rgeom.height-(dummy_p_area).y+\ - (brwin)->rgeom.y<(dummy_p_area).height)?\ - (brwin)->rgeom.height-(dummy_p_area).y+\ - (brwin)->rgeom.y:(dummy_p_area).height:-1;\ - if((wgeom)->width>(brwin)->rgeom.width)\ - (wgeom)->width=(brwin)->rgeom.width;\ - if((wgeom)->height>(brwin)->rgeom.height)\ - (wgeom)->height=(brwin)->rgeom.height;\ + ((brwin)->rrect.y-(dummy_p_area).y):\ + ((dummy_p_area).y<=(brwin)->rrect.y+\ + (brwin)->rrect.height)?\ + ((brwin)->rrect.height-(dummy_p_area).y+\ + (brwin)->rrect.y<(dummy_p_area).height)?\ + (brwin)->rrect.height-(dummy_p_area).y+\ + (brwin)->rrect.y:(dummy_p_area).height:0;\ + if((xrect)->width>(brwin)->rrect.width)\ + (xrect)->width=(brwin)->rrect.width;\ + if((xrect)->height>(brwin)->rrect.height)\ + (xrect)->height=(brwin)->rrect.height;\ } #define XFIXES_POINTER_TO_YUV(yuv,\ @@ -210,17 +210,17 @@ static int FirstFrame(ProgData *pdata, ZPixmap, 0, *pxl_data, - pdata->brwin.rgeom.width, - pdata->brwin.rgeom.height, + pdata->brwin.rrect.width, + pdata->brwin.rrect.height, 8, 0); XInitImage((*image)); GetZPixmap(pdata->dpy,pdata->specs.root, (*image)->data, - pdata->brwin.rgeom.x, - pdata->brwin.rgeom.y, - pdata->brwin.rgeom.width, - pdata->brwin.rgeom.height); + pdata->brwin.rrect.x, + pdata->brwin.rrect.y, + pdata->brwin.rrect.width, + pdata->brwin.rrect.height); } else{ (*image)=XShmCreateImage(pdata->dpy, @@ -229,8 +229,8 @@ static int FirstFrame(ProgData *pdata, ZPixmap, *pxl_data, shminfo, - pdata->brwin.rgeom.width, - pdata->brwin.rgeom.height); + pdata->brwin.rrect.width, + pdata->brwin.rrect.height); (*shminfo).shmid=shmget(IPC_PRIVATE, (*image)->bytes_per_line* (*image)->height, @@ -249,15 +249,15 @@ static int FirstFrame(ProgData *pdata, XShmGetImage(pdata->dpy, pdata->specs.root, (*image), - pdata->brwin.rgeom.x, - pdata->brwin.rgeom.y, + pdata->brwin.rrect.x, + pdata->brwin.rrect.y, AllPlanes); } UPDATE_YUV_BUFFER((&pdata->enc_data->yuv), ((unsigned char*)((*image))->data),NULL, (pdata->enc_data->x_offset),(pdata->enc_data->y_offset), - (pdata->brwin.rgeom.width),(pdata->brwin.rgeom.height), + (pdata->brwin.rrect.width),(pdata->brwin.rrect.height), (pdata->args.no_quick_subsample), pdata->specs.depth); @@ -267,14 +267,14 @@ static int FirstFrame(ProgData *pdata, //make a deep copy static void BRWinCpy(BRWindow *target, BRWindow *source) { - target->geom.x=source->geom.x; - target->geom.y=source->geom.y; - target->geom.width=source->geom.width; - target->geom.height=source->geom.height; - target->rgeom.x=source->rgeom.x; - target->rgeom.y=source->rgeom.y; - target->rgeom.width=source->rgeom.width; - target->rgeom.height=source->rgeom.height; + target->rect.x=source->rect.x; + target->rect.y=source->rect.y; + target->rect.width=source->rect.width; + target->rect.height=source->rect.height; + target->rrect.x=source->rrect.x; + target->rrect.y=source->rrect.y; + target->rrect.width=source->rrect.width; + target->rrect.height=source->rrect.height; target->nbytes=source->nbytes; target->windowid=source->windowid; @@ -289,14 +289,14 @@ static void MoveCaptureArea(BRWindow *brwin, int height) { int t_x=0,t_y=0; - t_x=cursor_x-brwin->rgeom.width/2; + t_x=cursor_x-brwin->rrect.width/2; t_x=(t_x>>1)<<1; - brwin->rgeom.x=(t_x<0)?0:((t_x+brwin->rgeom.width>width)? - width-brwin->rgeom.width:t_x); - t_y=cursor_y-brwin->rgeom.height/2; + brwin->rrect.x=(t_x<0)?0:((t_x+brwin->rrect.width>width)? + width-brwin->rrect.width:t_x); + t_y=cursor_y-brwin->rrect.height/2; t_y=(t_y>>1)<<1; - brwin->rgeom.y=(t_y<0)?0:((t_y+brwin->rgeom.height>height)? - height-brwin->rgeom.height:t_y); + brwin->rrect.y=(t_y<0)?0:((t_y+brwin->rrect.height>height)? + height-brwin->rrect.height:t_y); } /** @@ -335,10 +335,10 @@ static void BlocksFromList (RectArea **root, while (temp != NULL) { - column_start = (temp->geom.x - x_offset) / Y_UNIT_WIDTH; - column_end = (temp->geom.x + (temp->geom.width - 1) - x_offset) / Y_UNIT_WIDTH; - row_start = (temp->geom.y - y_offset) / Y_UNIT_WIDTH; - row_end = (temp->geom.y + (temp->geom.height - 1) - y_offset) / Y_UNIT_WIDTH; + column_start = (temp->rect.x - x_offset) / Y_UNIT_WIDTH; + column_end = (temp->rect.x + (temp->rect.width - 1) - x_offset) / Y_UNIT_WIDTH; + row_start = (temp->rect.y - y_offset) / Y_UNIT_WIDTH; + row_end = (temp->rect.y + (temp->rect.height - 1) - y_offset) / Y_UNIT_WIDTH; for (i = row_start; i < row_end + 1; i++) { for (j = column_start; j < column_end + 1; j++) { @@ -358,7 +358,7 @@ void *GetFrame(ProgData *pdata){ blocknum_x=pdata->enc_data->yuv.y_width/Y_UNIT_WIDTH, blocknum_y=pdata->enc_data->yuv.y_height/Y_UNIT_WIDTH; unsigned int msk_ret; - WGeometry mouse_pos_abs,mouse_pos_rel,mouse_pos_temp; + XRectangle mouse_pos_abs,mouse_pos_rel,mouse_pos_temp; BRWindow temp_brwin; Window root_ret, child_ret; //Frame @@ -414,10 +414,10 @@ void *GetFrame(ProgData *pdata){ pdata->shaped_w=rmdFrameInit(pdata->dpy, pdata->specs.screen, pdata->specs.root, - pdata->brwin.rgeom.x, - pdata->brwin.rgeom.y, - pdata->brwin.rgeom.width, - pdata->brwin.rgeom.height); + pdata->brwin.rrect.x, + pdata->brwin.rrect.y, + pdata->brwin.rrect.width, + pdata->brwin.rrect.height); XSelectInput(pdata->dpy,pdata->shaped_w,ExposureMask); } @@ -486,8 +486,8 @@ void *GetFrame(ProgData *pdata){ XQueryPointer(pdata->dpy, pdata->specs.root, &root_ret,&child_ret, - &mouse_pos_abs.x,&mouse_pos_abs.y, - &mouse_pos_rel.x,&mouse_pos_rel.y,&msk_ret); + (int *)&mouse_pos_abs.x,(int *)&mouse_pos_abs.y, + (int *)&mouse_pos_rel.x,(int *)&mouse_pos_rel.y,&msk_ret); } CLIP_DUMMY_POINTER_AREA(mouse_pos_abs, &temp_brwin, &mouse_pos_temp); @@ -518,14 +518,14 @@ void *GetFrame(ProgData *pdata){ MARK_BUFFER_AREA( back_buff, (mouse_pos_temp.x- - temp_brwin.rgeom.x+ + temp_brwin.rrect.x+ pdata->enc_data->x_offset), (mouse_pos_temp.y- - temp_brwin.rgeom.y+ + temp_brwin.rrect.y+ pdata->enc_data->y_offset), mouse_pos_temp.width, mouse_pos_temp.height, - (temp_brwin.rgeom.width), + (temp_brwin.rrect.width), pdata->specs.depth) } } @@ -541,8 +541,8 @@ void *GetFrame(ProgData *pdata){ if(!pdata->args.noframe){ rmdMoveFrame(pdata->dpy, pdata->shaped_w, - temp_brwin.rgeom.x, - temp_brwin.rgeom.y); + temp_brwin.rrect.x, + temp_brwin.rrect.y); } } @@ -561,8 +561,8 @@ void *GetFrame(ProgData *pdata){ pdata->shm_opcode, pdata->args.no_quick_subsample); BlocksFromList(&pdata->rect_root, - temp_brwin.rgeom.x, - temp_brwin.rgeom.y, + temp_brwin.rrect.x, + temp_brwin.rrect.y, pdata->enc_data->yuv.y_width/Y_UNIT_WIDTH, pdata->enc_data->yuv.y_height/Y_UNIT_WIDTH); pthread_mutex_unlock(&pdata->yuv_mutex); @@ -577,17 +577,17 @@ void *GetFrame(ProgData *pdata){ if(!pdata->args.noshared){ XShmGetImage(pdata->dpy,pdata->specs.root, ((!img_sel)?image:image_back), - (temp_brwin.rgeom.x), - (temp_brwin.rgeom.y),AllPlanes); + (temp_brwin.rrect.x), + (temp_brwin.rrect.y),AllPlanes); } if(pdata->args.noshared){ GetZPixmap( pdata->dpy, pdata->specs.root, image->data, - temp_brwin.rgeom.x, - temp_brwin.rgeom.y, - temp_brwin.rgeom.width, - temp_brwin.rgeom.height); + temp_brwin.rrect.x, + temp_brwin.rrect.y, + temp_brwin.rrect.width, + temp_brwin.rrect.height); } pthread_mutex_lock(&pdata->yuv_mutex); for(i=0;i<blocknum_x*blocknum_y;i++){ @@ -597,8 +597,8 @@ void *GetFrame(ProgData *pdata){ front_buff,back_buff, (pdata->enc_data->x_offset), (pdata->enc_data->y_offset), - (temp_brwin.rgeom.width), - (temp_brwin.rgeom.height), + (temp_brwin.rrect.width), + (temp_brwin.rrect.height), pdata->args.no_quick_subsample, pdata->specs.depth); pthread_mutex_unlock(&pdata->yuv_mutex); @@ -625,10 +625,10 @@ void *GetFrame(ProgData *pdata){ XFIXES_POINTER_TO_YUV((&pdata->enc_data->yuv), ((unsigned char*)xcim->pixels), (mouse_pos_temp.x- - temp_brwin.rgeom.x+ + temp_brwin.rrect.x+ pdata->enc_data->x_offset), (mouse_pos_temp.y- - temp_brwin.rgeom.y+ + temp_brwin.rrect.y+ pdata->enc_data->y_offset), mouse_pos_temp.width, mouse_pos_temp.height, @@ -640,10 +640,10 @@ void *GetFrame(ProgData *pdata){ DUMMY_POINTER_TO_YUV((&pdata->enc_data->yuv), pdata->dummy_pointer, (mouse_pos_temp.x- - temp_brwin.rgeom.x+ + temp_brwin.rrect.x+ pdata->enc_data->x_offset), (mouse_pos_temp.y- - temp_brwin.rgeom.y+ + temp_brwin.rrect.y+ pdata->enc_data->y_offset), mouse_pos_temp.width, mouse_pos_temp.height, @@ -662,14 +662,14 @@ void *GetFrame(ProgData *pdata){ MARK_BUFFER_AREA( front_buff, (mouse_pos_temp.x- - temp_brwin.rgeom.x+ + temp_brwin.rrect.x+ pdata->enc_data->x_offset), (mouse_pos_temp.y- - temp_brwin.rgeom.y+ + temp_brwin.rrect.y+ pdata->enc_data->y_offset), mouse_pos_temp.width, mouse_pos_temp.height, - (temp_brwin.rgeom.width), + (temp_brwin.rrect.width), pdata->specs.depth) } diff --git a/recordmydesktop/src/rmd_init_encoder.c b/recordmydesktop/src/rmd_init_encoder.c index a41412a..2f71ba5 100644 --- a/recordmydesktop/src/rmd_init_encoder.c +++ b/recordmydesktop/src/rmd_init_encoder.c @@ -159,8 +159,8 @@ void InitEncoder(ProgData *pdata,EncData *enc_data_t,int buffer_ready){ theora_info_init(&enc_data_t->m_th_inf); - enc_data_t->m_th_inf.frame_width = pdata->brwin.rgeom.width; - enc_data_t->m_th_inf.frame_height = pdata->brwin.rgeom.height; + enc_data_t->m_th_inf.frame_width = pdata->brwin.rrect.width; + enc_data_t->m_th_inf.frame_height = pdata->brwin.rrect.height; enc_data_t->m_th_inf.width = ((enc_data_t->m_th_inf.frame_width + 15) >> 4) << 4; enc_data_t->m_th_inf.height = ((enc_data_t->m_th_inf.frame_height + 15) >> 4) << 4; enc_data_t->m_th_inf.offset_x = 0; diff --git a/recordmydesktop/src/rmd_poll_events.c b/recordmydesktop/src/rmd_poll_events.c index bfe96c9..5c29f04 100644 --- a/recordmydesktop/src/rmd_poll_events.c +++ b/recordmydesktop/src/rmd_poll_events.c @@ -41,42 +41,42 @@ #include "rmd_types.h" -#define CLIP_EVENT_AREA(e,brwin,wgeom){\ - if(((e)->area.x<=(brwin)->rgeom.x)&&((e)->area.y<=(brwin)->rgeom.y)&&\ - ((e)->area.width>=(brwin)->rgeom.width)&&\ - ((e)->area.height<(brwin)->rgeom.height)){\ - (wgeom)->x=(brwin)->rgeom.x;\ - (wgeom)->y=(brwin)->rgeom.y;\ - (wgeom)->width=(brwin)->rgeom.width;\ - (wgeom)->height=(brwin)->rgeom.height;\ +#define CLIP_EVENT_AREA(e,brwin,xrect){\ + if(((e)->area.x<=(brwin)->rrect.x)&&((e)->area.y<=(brwin)->rrect.y)&&\ + ((e)->area.width>=(brwin)->rrect.width)&&\ + ((e)->area.height<(brwin)->rrect.height)){\ + (xrect)->x=(brwin)->rrect.x;\ + (xrect)->y=(brwin)->rrect.y;\ + (xrect)->width=(brwin)->rrect.width;\ + (xrect)->height=(brwin)->rrect.height;\ }\ else{\ - (wgeom)->x=((((e)->area.x+(e)->area.width>=(brwin)->rgeom.x)&&\ - ((e)->area.x<=(brwin)->rgeom.x+(brwin)->rgeom.width))?\ - (((e)->area.x<=(brwin)->rgeom.x)?(brwin)->rgeom.x:(e)->area.x):-1);\ + (xrect)->x=((((e)->area.x+(e)->area.width>=(brwin)->rrect.x)&&\ + ((e)->area.x<=(brwin)->rrect.x+(brwin)->rrect.width))?\ + (((e)->area.x<=(brwin)->rrect.x)?(brwin)->rrect.x:(e)->area.x):-1);\ \ - (wgeom)->y=((((e)->area.y+(e)->area.height>=(brwin)->rgeom.y)&&\ - ((e)->area.y<=(brwin)->rgeom.y+(brwin)->rgeom.height))?\ - (((e)->area.y<=(brwin)->rgeom.y)?(brwin)->rgeom.y:(e)->area.y):-1);\ + (xrect)->y=((((e)->area.y+(e)->area.height>=(brwin)->rrect.y)&&\ + ((e)->area.y<=(brwin)->rrect.y+(brwin)->rrect.height))?\ + (((e)->area.y<=(brwin)->rrect.y)?(brwin)->rrect.y:(e)->area.y):-1);\ \ - (wgeom)->width=((e)->area.x<=(brwin)->rgeom.x)?\ - (e)->area.width-((brwin)->rgeom.x-(e)->area.x):\ - ((e)->area.x<=(brwin)->rgeom.x+(brwin)->rgeom.width)?\ - (((brwin)->rgeom.width-(e)->area.x+(brwin)->rgeom.x<(e)->area.width)?\ - (brwin)->rgeom.width-(e)->area.x+(brwin)->rgeom.x:e->area.width):-1;\ + (xrect)->width=((e)->area.x<=(brwin)->rrect.x)?\ + (e)->area.width-((brwin)->rrect.x-(e)->area.x):\ + ((e)->area.x<=(brwin)->rrect.x+(brwin)->rrect.width)?\ + (((brwin)->rrect.width-(e)->area.x+(brwin)->rrect.x<(e)->area.width)?\ + (brwin)->rrect.width-(e)->area.x+(brwin)->rrect.x:e->area.width):0;\ \ - (wgeom)->height=((e)->area.y<=(brwin)->rgeom.y)?\ - (e)->area.height-((brwin)->rgeom.y-(e)->area.y):\ - ((e)->area.y<=(brwin)->rgeom.y+(brwin)->rgeom.height)?\ - (((brwin)->rgeom.height-(e)->area.y+\ - (brwin)->rgeom.y<(e)->area.height)?\ - (brwin)->rgeom.height-(e)->area.y+\ - (brwin)->rgeom.y:(e)->area.height):-1;\ + (xrect)->height=((e)->area.y<=(brwin)->rrect.y)?\ + (e)->area.height-((brwin)->rrect.y-(e)->area.y):\ + ((e)->area.y<=(brwin)->rrect.y+(brwin)->rrect.height)?\ + (((brwin)->rrect.height-(e)->area.y+\ + (brwin)->rrect.y<(e)->area.height)?\ + (brwin)->rrect.height-(e)->area.y+\ + (brwin)->rrect.y:(e)->area.height):0;\ \ - if((wgeom)->width>(brwin)->rgeom.width)\ - (wgeom)->width=(brwin)->rgeom.width;\ - if((wgeom)->height>(brwin)->rgeom.height)\ - (wgeom)->height=(brwin)->rgeom.height;\ + if((xrect)->width>(brwin)->rrect.width)\ + (xrect)->width=(brwin)->rrect.width;\ + if((xrect)->height>(brwin)->rrect.height)\ + (xrect)->height=(brwin)->rrect.height;\ }\ } @@ -167,8 +167,8 @@ void EventLoop(ProgData *pdata){ rmdDrawFrame(pdata->dpy, pdata->specs.screen, pdata->shaped_w, - pdata->brwin.rgeom.width, - pdata->brwin.rgeom.height); + pdata->brwin.rrect.width, + pdata->brwin.rrect.height); } @@ -189,12 +189,12 @@ void EventLoop(ProgData *pdata){ } else if(event.type == pdata->damage_event + XDamageNotify ){ XDamageNotifyEvent *e =(XDamageNotifyEvent *)( &event ); - WGeometry wgeom; - CLIP_EVENT_AREA(e,&(pdata->brwin),&wgeom); - if((wgeom.x>=0)&&(wgeom.y>=0)&& - (wgeom.width>0)&&(wgeom.height>0)){ + XRectangle xrect; + CLIP_EVENT_AREA(e,&(pdata->brwin),&xrect); + if((xrect.x>=0)&&(xrect.y>=0)&& + (xrect.width>0)&&(xrect.height>0)){ - inserts+=RectInsert(&pdata->rect_root,&wgeom); + inserts+=RectInsert(&pdata->rect_root,&xrect); } } diff --git a/recordmydesktop/src/rmd_rectinsert.c b/recordmydesktop/src/rmd_rectinsert.c index bc70e44..1950d65 100644 --- a/recordmydesktop/src/rmd_rectinsert.c +++ b/recordmydesktop/src/rmd_rectinsert.c @@ -33,53 +33,53 @@ /** * Collide two rectangles and dictate most sane action for insertion, * as well as provide the updated rectangle(s) -* \param wgeom1 resident rectangle +* \param xrect1 resident rectangle * -* \param wgeom2 New rectangle +* \param xrect2 New rectangle * -* \param wgeom_return Pointer to rectangles to be inserted +* \param xrect_return Pointer to rectangles to be inserted * -* \param ngeoms number of entries in wgeom_return +* \param nrects number of entries in xrect_return * * \retval 0 No collision * -* \retval 1 wgeom1 is covered by wgeom2 +* \retval 1 xrect1 is covered by xrect2 * -* \retval 2 wgeom2 is covered by wgeom1 +* \retval 2 xrect2 is covered by xrect1 * -* \retval -1 wgeom1 was broken (new is picked up in wgeom_return) +* \retval -1 xrect1 was broken (new is picked up in xrect_return) * -* \retval -2 wgeom2 was broken (new is picked up in wgeom_return) +* \retval -2 xrect2 was broken (new is picked up in xrect_return) * -* \retval -10 Grouping the two geoms is possible +* \retval -10 Grouping the two rects is possible * */ -static int CollideRects(WGeometry *wgeom1, - WGeometry *wgeom2, - WGeometry wgeom_return[], - int *ngeoms) { +static int CollideRects(XRectangle *xrect1, + XRectangle *xrect2, + XRectangle xrect_return[], + int *nrects) { //1 fits in 2 - if((wgeom1->x>=wgeom2->x)&& - (wgeom1->x+wgeom1->width<=wgeom2->x+wgeom2->width)&& - (wgeom1->y>=wgeom2->y)&& - (wgeom1->y+wgeom1->height<=wgeom2->y+wgeom2->height)){ - *ngeoms=0; + if((xrect1->x>=xrect2->x)&& + (xrect1->x+xrect1->width<=xrect2->x+xrect2->width)&& + (xrect1->y>=xrect2->y)&& + (xrect1->y+xrect1->height<=xrect2->y+xrect2->height)){ + *nrects=0; return 1; } //2 fits in 1 - else if((wgeom2->x>=wgeom1->x)&& - (wgeom2->x+wgeom2->width<=wgeom1->x+wgeom1->width)&& - (wgeom2->y>=wgeom1->y)&& - (wgeom2->y+wgeom2->height<=wgeom1->y+wgeom1->height)){ - *ngeoms=0; + else if((xrect2->x>=xrect1->x)&& + (xrect2->x+xrect2->width<=xrect1->x+xrect1->width)&& + (xrect2->y>=xrect1->y)&& + (xrect2->y+xrect2->height<=xrect1->y+xrect1->height)){ + *nrects=0; return 2; } //no collision - else if((wgeom1->x+wgeom1->width<wgeom2->x)|| - (wgeom2->x+wgeom2->width<wgeom1->x)|| - (wgeom1->y+wgeom1->height<wgeom2->y)|| - (wgeom2->y+wgeom2->height<wgeom1->y)){ - *ngeoms=0; + else if((xrect1->x+xrect1->width<xrect2->x)|| + (xrect2->x+xrect2->width<xrect1->x)|| + (xrect1->y+xrect1->height<xrect2->y)|| + (xrect2->y+xrect2->height<xrect1->y)){ + *nrects=0; return 0; } else{ @@ -91,10 +91,10 @@ static int CollideRects(WGeometry *wgeom1, //function should always start at the next element(which is logical since //if any rect makes it to a points none of it's part collides with previous //nodes on the list, too) - int x1[2]={wgeom1->x,wgeom1->x+wgeom1->width}; - int y1[2]={wgeom1->y,wgeom1->y+wgeom1->height}; - int x2[2]={wgeom2->x,wgeom2->x+wgeom2->width}; - int y2[2]={wgeom2->y,wgeom2->y+wgeom2->height}; + int x1[2]={xrect1->x,xrect1->x+xrect1->width}; + int y1[2]={xrect1->y,xrect1->y+xrect1->height}; + int x2[2]={xrect2->x,xrect2->x+xrect2->width}; + int y2[2]={xrect2->y,xrect2->y+xrect2->height}; int enclosed[2][4],tot1,tot2; enclosed[0][0]=(((x1[0]>=x2[0])&&(x1[0]<=x2[1])&& (y1[0]>=y2[0])&&(y1[0]<=y2[1]))?1:0); @@ -117,223 +117,223 @@ static int CollideRects(WGeometry *wgeom1, if((tot1==2)&&(tot2==2)){//same width or height, which is the best case //group if((enclosed[1][0]&&enclosed[1][1])&& - (wgeom1->width==wgeom2->width)){ - *ngeoms=1; - wgeom_return[0].x = wgeom1->x; - wgeom_return[0].y = wgeom1->y; - wgeom_return[0].width = wgeom1->width; - wgeom_return[0].height = wgeom2->height + wgeom2->y - wgeom1->y; + (xrect1->width==xrect2->width)){ + *nrects=1; + xrect_return[0].x = xrect1->x; + xrect_return[0].y = xrect1->y; + xrect_return[0].width = xrect1->width; + xrect_return[0].height = xrect2->height + xrect2->y - xrect1->y; return -10; } else if((enclosed[1][0]&&enclosed[1][2])&& - (wgeom1->height==wgeom2->height)){ - *ngeoms=1; - wgeom_return[0].x = wgeom1->x; - wgeom_return[0].y = wgeom1->y; - wgeom_return[0].width = wgeom2->width + wgeom2->x - wgeom1->x; - wgeom_return[0].height = wgeom1->height; + (xrect1->height==xrect2->height)){ + *nrects=1; + xrect_return[0].x = xrect1->x; + xrect_return[0].y = xrect1->y; + xrect_return[0].width = xrect2->width + xrect2->x - xrect1->x; + xrect_return[0].height = xrect1->height; return -10; } else if((enclosed[1][3]&&enclosed[1][1])&& - (wgeom1->height==wgeom2->height)){ - *ngeoms=1; - wgeom_return[0].x = wgeom2->x; - wgeom_return[0].y = wgeom2->y; - wgeom_return[0].width = wgeom1->width + wgeom1->x - wgeom2->x; - wgeom_return[0].height = wgeom2->height; + (xrect1->height==xrect2->height)){ + *nrects=1; + xrect_return[0].x = xrect2->x; + xrect_return[0].y = xrect2->y; + xrect_return[0].width = xrect1->width + xrect1->x - xrect2->x; + xrect_return[0].height = xrect2->height; return -10; } else if((enclosed[1][3]&&enclosed[1][2])&& - (wgeom1->width==wgeom2->width)){ - *ngeoms=1; - wgeom_return[0].x = wgeom2->x; - wgeom_return[0].y = wgeom2->y; - wgeom_return[0].width = wgeom2->width; - wgeom_return[0].height = wgeom1->height + wgeom1->y - wgeom2->y; + (xrect1->width==xrect2->width)){ + *nrects=1; + xrect_return[0].x = xrect2->x; + xrect_return[0].y = xrect2->y; + xrect_return[0].width = xrect2->width; + xrect_return[0].height = xrect1->height + xrect1->y - xrect2->y; return -10; } //if control reaches here therewasn't a group and we go on } if(tot2==2){ - //break geom2 - wgeom_return[0].x = wgeom2->x; - wgeom_return[0].y = wgeom2->y; - wgeom_return[0].width = wgeom2->width; - wgeom_return[0].height = wgeom2->height; - *ngeoms=1; + //break rect2 + xrect_return[0].x = xrect2->x; + xrect_return[0].y = xrect2->y; + xrect_return[0].width = xrect2->width; + xrect_return[0].height = xrect2->height; + *nrects=1; if(enclosed[1][0]&&enclosed[1][1]){ - wgeom_return[0].y = y1[1]; - wgeom_return[0].height -= y1[1] - y2[0]; + xrect_return[0].y = y1[1]; + xrect_return[0].height -= y1[1] - y2[0]; } else if(enclosed[1][0]&&enclosed[1][2]){ - wgeom_return[0].x = x1[1]; - wgeom_return[0].width -= x1[1] - x2[0]; + xrect_return[0].x = x1[1]; + xrect_return[0].width -= x1[1] - x2[0]; } else if(enclosed[1][3]&&enclosed[1][1]) - wgeom_return[0].width -= x2[1] - x1[0]; + xrect_return[0].width -= x2[1] - x1[0]; else if(enclosed[1][3]&&enclosed[1][2]) - wgeom_return[0].height -= y2[1] - y1[0]; + xrect_return[0].height -= y2[1] - y1[0]; return -2; } else if(tot1==2){ //if the first one breaks(which is already inserted) //then we reenter the part that was left and the one //that was to be inserted - wgeom_return[1].x = wgeom2->x; - wgeom_return[1].y = wgeom2->y; - wgeom_return[1].width = wgeom2->width; - wgeom_return[1].height = wgeom2->height; - wgeom_return[0].x = wgeom1->x; - wgeom_return[0].y = wgeom1->y; - wgeom_return[0].width = wgeom1->width; - wgeom_return[0].height = wgeom1->height; - *ngeoms=1; + xrect_return[1].x = xrect2->x; + xrect_return[1].y = xrect2->y; + xrect_return[1].width = xrect2->width; + xrect_return[1].height = xrect2->height; + xrect_return[0].x = xrect1->x; + xrect_return[0].y = xrect1->y; + xrect_return[0].width = xrect1->width; + xrect_return[0].height = xrect1->height; + *nrects=1; if(enclosed[0][0]&&enclosed[0][1]){ - wgeom_return[0].y = y2[1]; - wgeom_return[0].height -= y2[1] - y1[0]; + xrect_return[0].y = y2[1]; + xrect_return[0].height -= y2[1] - y1[0]; } else if(enclosed[0][0]&&enclosed[0][2]){ - wgeom_return[0].x = x2[1]; - wgeom_return[0].width -= x2[1] - x1[0]; + xrect_return[0].x = x2[1]; + xrect_return[0].width -= x2[1] - x1[0]; } else if(enclosed[0][3]&&enclosed[0][1]) - wgeom_return[0].width -= x1[1] - x2[0]; + xrect_return[0].width -= x1[1] - x2[0]; else if(enclosed[0][3]&&enclosed[0][2]) - wgeom_return[0].height -= y1[1] - y2[0]; + xrect_return[0].height -= y1[1] - y2[0]; return -1; } else if(tot2==1){ //in which case there is also tot1==1 //but we rather not break that - //break geom2 in two - *ngeoms=2; + //break rect2 in two + *nrects=2; if(enclosed[1][0]){ //first - wgeom_return[0].x = x1[1]; - wgeom_return[0].y = y2[0]; - wgeom_return[0].width = wgeom2->width - x1[1] + x2[0]; - wgeom_return[0].height = wgeom2->height; + xrect_return[0].x = x1[1]; + xrect_return[0].y = y2[0]; + xrect_return[0].width = xrect2->width - x1[1] + x2[0]; + xrect_return[0].height = xrect2->height; //second - wgeom_return[1].x = x2[0]; - wgeom_return[1].y = y1[1]; - wgeom_return[1].width = x1[1] - x2[0]; - wgeom_return[1].height = wgeom2->height - y1[1] + y2[0]; + xrect_return[1].x = x2[0]; + xrect_return[1].y = y1[1]; + xrect_return[1].width = x1[1] - x2[0]; + xrect_return[1].height = xrect2->height - y1[1] + y2[0]; } else if(enclosed[1][1]){ //first - wgeom_return[0].x = x2[0]; - wgeom_return[0].y = y2[0]; - wgeom_return[0].width = wgeom2->width - x2[1] + x1[0]; - wgeom_return[0].height = wgeom2->height; + xrect_return[0].x = x2[0]; + xrect_return[0].y = y2[0]; + xrect_return[0].width = xrect2->width - x2[1] + x1[0]; + xrect_return[0].height = xrect2->height; //second - wgeom_return[1].x = x1[0]; - wgeom_return[1].y = y1[1]; - wgeom_return[1].width = x2[1] - x1[0]; - wgeom_return[1].height = wgeom2->height - y1[1] + y2[0]; + xrect_return[1].x = x1[0]; + xrect_return[1].y = y1[1]; + xrect_return[1].width = x2[1] - x1[0]; + xrect_return[1].height = xrect2->height - y1[1] + y2[0]; } else if(enclosed[1][2]){ //first(same as [1][0]) - wgeom_return[0].x = x1[1]; - wgeom_return[0].y = y2[0]; - wgeom_return[0].width = wgeom2->width - x1[1] + x2[0]; - wgeom_return[0].height = wgeom2->height; + xrect_return[0].x = x1[1]; + xrect_return[0].y = y2[0]; + xrect_return[0].width = xrect2->width - x1[1] + x2[0]; + xrect_return[0].height = xrect2->height; //second - wgeom_return[1].x = x2[0]; - wgeom_return[1].y = y2[0]; - wgeom_return[1].width = x1[1] - x2[0]; - wgeom_return[1].height = wgeom2->height - y2[1] + y1[0]; + xrect_return[1].x = x2[0]; + xrect_return[1].y = y2[0]; + xrect_return[1].width = x1[1] - x2[0]; + xrect_return[1].height = xrect2->height - y2[1] + y1[0]; } else if(enclosed[1][3]){ //first(same as [1][1]) - wgeom_return[0].x = x2[0]; - wgeom_return[0].y = y2[0]; - wgeom_return[0].width = wgeom2->width - x2[1] + x1[0]; - wgeom_return[0].height = wgeom2->height; + xrect_return[0].x = x2[0]; + xrect_return[0].y = y2[0]; + xrect_return[0].width = xrect2->width - x2[1] + x1[0]; + xrect_return[0].height = xrect2->height; //second - wgeom_return[1].x = x1[0]; - wgeom_return[1].y = y2[0]; - wgeom_return[1].width = x2[1] - x1[0]; - wgeom_return[1].height = wgeom2->height - y2[1] + y1[0]; + xrect_return[1].x = x1[0]; + xrect_return[1].y = y2[0]; + xrect_return[1].width = x2[1] - x1[0]; + xrect_return[1].height = xrect2->height - y2[1] + y1[0]; } return -2; } else{//polygons collide but no point of one is in the other - //so we just keep the two parts of geom2 that are outside geom1 + //so we just keep the two parts of rect2 that are outside rect1 - //break geom2 in two + //break rect2 in two //two cases: - //geom2 crossing vertically geom1 - //and geom2 crossing horizontally geom1 + //rect2 crossing vertically rect1 + //and rect2 crossing horizontally rect1 //The proper one can be found by simply checking x,y positions - *ngeoms=2; - if(wgeom2->y<wgeom1->y){ + *nrects=2; + if(xrect2->y<xrect1->y){ //common - wgeom_return[0].x = wgeom_return[1].x = x2[0]; - wgeom_return[0].width = wgeom_return[1].width = wgeom2->width; + xrect_return[0].x = xrect_return[1].x = x2[0]; + xrect_return[0].width = xrect_return[1].width = xrect2->width; - wgeom_return[0].y = y2[0]; - wgeom_return[0].height = wgeom2->height - y2[1] + y1[0]; - wgeom_return[1].y = y1[1]; - wgeom_return[1].height = y2[1] - y1[1]; + xrect_return[0].y = y2[0]; + xrect_return[0].height = xrect2->height - y2[1] + y1[0]; + xrect_return[1].y = y1[1]; + xrect_return[1].height = y2[1] - y1[1]; } else{ //common - wgeom_return[0].y = wgeom_return[1].y = y2[0]; - wgeom_return[0].height = wgeom_return[1].height = wgeom2->height; + xrect_return[0].y = xrect_return[1].y = y2[0]; + xrect_return[0].height = xrect_return[1].height = xrect2->height; - wgeom_return[0].x = x2[0]; - wgeom_return[0].width = wgeom2->width - x2[1] + x1[0]; - wgeom_return[1].x = x1[1]; - wgeom_return[1].width = x2[1] - x1[1]; + xrect_return[0].x = x2[0]; + xrect_return[0].width = xrect2->width - x2[1] + x1[0]; + xrect_return[1].x = x1[1]; + xrect_return[1].width = x2[1] - x1[1]; } return -2; } } } -int RectInsert(RectArea **root,WGeometry *wgeom){ +int RectInsert(RectArea **root,XRectangle *xrect){ int total_insertions=0; RectArea *temp=NULL,*newnode=(RectArea *)malloc(sizeof(RectArea)); //align //we do need to know boundaries - wgeom->width+=(wgeom->width%2)|(wgeom->x%2); - wgeom->height+=(wgeom->height%2)|(wgeom->y%2); - wgeom->width+=(wgeom->width%2); - wgeom->height+=(wgeom->height%2); - wgeom->x-=wgeom->x%2; - wgeom->y-=wgeom->y%2; -// fprintf(stderr," %d %d %d %d\n",wgeom->x, + xrect->width+=(xrect->width%2)|(xrect->x%2); + xrect->height+=(xrect->height%2)|(xrect->y%2); + xrect->width+=(xrect->width%2); + xrect->height+=(xrect->height%2); + xrect->x-=xrect->x%2; + xrect->y-=xrect->y%2; +// fprintf(stderr," %d %d %d %d\n",xrect->x, - newnode->geom.x=wgeom->x; - newnode->geom.y=wgeom->y; - newnode->geom.width=wgeom->width; - newnode->geom.height=wgeom->height; + newnode->rect.x=xrect->x; + newnode->rect.y=xrect->y; + newnode->rect.width=xrect->width; + newnode->rect.height=xrect->height; newnode->prev=newnode->next=NULL; if(*root==NULL){ *root=newnode; total_insertions=1; } else{ - WGeometry wgeom_return[2]; + XRectangle xrect_return[2]; - int ngeoms=0,insert_ok=1,i=0; + int nrects=0,insert_ok=1,i=0; temp=*root; while(insert_ok){ //if something is broken list does not procceed //(except on -1 collres case) - int collres = CollideRects(&temp->geom, wgeom, &wgeom_return[0], &ngeoms); + int collres = CollideRects(&temp->rect, xrect, &xrect_return[0], &nrects); if((!collres)) insert_ok=1; else{ - for(i=0;i<ngeoms;i++){ - wgeom_return[i].width += (wgeom_return[i].width % 2) | - (wgeom_return[i].x % 2); - wgeom_return[i].height += (wgeom_return[i].height % 2) | - (wgeom_return[i].y % 2); - wgeom_return[i].width += (wgeom_return[i].width % 2); - wgeom_return[i].height += (wgeom_return[i].height % 2); - wgeom_return[i].x -= wgeom_return[i].x % 2; - wgeom_return[i].y -= wgeom_return[i].y % 2; + for(i=0;i<nrects;i++){ + xrect_return[i].width += (xrect_return[i].width % 2) | + (xrect_return[i].x % 2); + xrect_return[i].height += (xrect_return[i].height % 2) | + (xrect_return[i].y % 2); + xrect_return[i].width += (xrect_return[i].width % 2); + xrect_return[i].height += (xrect_return[i].height % 2); + xrect_return[i].x -= xrect_return[i].x % 2; + xrect_return[i].y -= xrect_return[i].y % 2; } insert_ok=0; switch(collres){ @@ -345,8 +345,8 @@ int RectInsert(RectArea **root,WGeometry *wgeom){ temp->prev->next=temp->next; temp->next->prev=temp->prev; free(temp); - if((wgeom->width>0)&&(wgeom->height>0)) - total_insertions+=RectInsert(&temp1,wgeom); + if((xrect->width>0)&&(xrect->height>0)) + total_insertions+=RectInsert(&temp1,xrect); } else{ temp->prev->next=newnode; @@ -359,10 +359,10 @@ int RectInsert(RectArea **root,WGeometry *wgeom){ if((*root)->next!=NULL){ (*root)=(*root)->next; (*root)->prev=NULL; - if((wgeom->width>0)&&(wgeom->height>0)) - total_insertions+=RectInsert(root,wgeom); + if((xrect->width>0)&&(xrect->height>0)) + total_insertions+=RectInsert(root,xrect); } - else if((wgeom->width>0)&&(wgeom->height>0)){ + else if((xrect->width>0)&&(xrect->height>0)){ *root=newnode; total_insertions++; } @@ -379,12 +379,12 @@ int RectInsert(RectArea **root,WGeometry *wgeom){ case -1://current node is broken and reinserted //(in same pos) //newnode is also reinserted - if (wgeom_return[0].width > 0 && - wgeom_return[0].height > 0) { - temp->geom.x = wgeom_return[0].x; - temp->geom.y = wgeom_return[0].y; - temp->geom.width = wgeom_return[0].width; - temp->geom.height = wgeom_return[0].height; + if (xrect_return[0].width > 0 && + xrect_return[0].height > 0) { + temp->rect.x = xrect_return[0].x; + temp->rect.y = xrect_return[0].y; + temp->rect.width = xrect_return[0].width; + temp->rect.height = xrect_return[0].height; if(temp->next==NULL){ temp->next=newnode; newnode->prev=temp; @@ -412,49 +412,49 @@ int RectInsert(RectArea **root,WGeometry *wgeom){ temp->next->prev=temp->prev; temp->prev->next=temp->next; total_insertions+=RectInsert(&temp->next, - wgeom); + xrect); } free(temp); } break; case -2://new is broken and reinserted if(temp->next==NULL){ - total_insertions+=ngeoms; - newnode->geom.x = wgeom_return[0].x; - newnode->geom.y = wgeom_return[0].y; - newnode->geom.width = wgeom_return[0].width; - newnode->geom.height = wgeom_return[0].height; + total_insertions+=nrects; + newnode->rect.x = xrect_return[0].x; + newnode->rect.y = xrect_return[0].y; + newnode->rect.width = xrect_return[0].width; + newnode->rect.height = xrect_return[0].height; temp->next=newnode; newnode->prev=temp; - if(ngeoms>1){ + if(nrects>1){ RectArea *newnode1= (RectArea *)malloc(sizeof(RectArea)); - newnode1->geom.x = wgeom_return[1].x; - newnode1->geom.y = wgeom_return[1].y; - newnode1->geom.width = wgeom_return[1].width; - newnode1->geom.height = wgeom_return[1].height; + newnode1->rect.x = xrect_return[1].x; + newnode1->rect.y = xrect_return[1].y; + newnode1->rect.width = xrect_return[1].width; + newnode1->rect.height = xrect_return[1].height; newnode->next=newnode1; newnode1->prev=newnode; newnode1->next=NULL; } } else{ - for(i=0;i<ngeoms;i++){ - if(wgeom_return[i].width > 0 && - wgeom_return[i].height > 0) + for(i=0;i<nrects;i++){ + if(xrect_return[i].width > 0 && + xrect_return[i].height > 0) total_insertions+= - RectInsert(&temp->next, &wgeom_return[i]); + RectInsert(&temp->next, &xrect_return[i]); } } break; case -10://grouped if(temp->prev==NULL){ if(temp->next==NULL){//empty list - newnode->geom.x = wgeom_return[0].x; - newnode->geom.y = wgeom_return[0].y; - newnode->geom.width = wgeom_return[0].width; - newnode->geom.height = wgeom_return[0].height; + newnode->rect.x = xrect_return[0].x; + newnode->rect.y = xrect_return[0].y; + newnode->rect.width = xrect_return[0].width; + newnode->rect.height = xrect_return[0].height; *root=newnode; free(temp); @@ -464,17 +464,17 @@ int RectInsert(RectArea **root,WGeometry *wgeom){ *root=temp->next; (*root)->prev=NULL; free(temp); - if(wgeom_return[0].width > 0 && - wgeom_return[0].height > 0) + if(xrect_return[0].width > 0 && + xrect_return[0].height > 0) total_insertions+= - RectInsert(root, &wgeom_return[0]); + RectInsert(root, &xrect_return[0]); } } else if(temp->next==NULL){//last, enter anyway - newnode->geom.x = wgeom_return[0].x; - newnode->geom.y = wgeom_return[0].y; - newnode->geom.width = wgeom_return[0].width; - newnode->geom.height = wgeom_return[0].height; + newnode->rect.x = xrect_return[0].x; + newnode->rect.y = xrect_return[0].y; + newnode->rect.width = xrect_return[0].width; + newnode->rect.height = xrect_return[0].height; temp->prev->next=newnode; newnode->prev=temp->prev; free(temp); @@ -485,10 +485,10 @@ int RectInsert(RectArea **root,WGeometry *wgeom){ temp->prev->next=temp->next; temp->next->prev=temp->prev; free(temp); - if(wgeom_return[0].width > 0 && - wgeom_return[0].height > 0) + if(xrect_return[0].width > 0 && + xrect_return[0].height > 0) total_insertions+= - RectInsert(&temp1, &wgeom_return[0]); + RectInsert(&temp1, &xrect_return[0]); } break; } diff --git a/recordmydesktop/src/rmd_rectinsert.h b/recordmydesktop/src/rmd_rectinsert.h index 6f93cb6..9f26f7b 100644 --- a/recordmydesktop/src/rmd_rectinsert.h +++ b/recordmydesktop/src/rmd_rectinsert.h @@ -36,14 +36,14 @@ * with the existing ones * \param root Root entry of the list * -* \param wgeom New area to be inserted +* \param xrect New area to be inserted * * \returns Number of insertions during operation * * \note This function is reentrant and recursive. The number * of insertions takes this into account. */ -int RectInsert(RectArea **root, WGeometry *wgeom); +int RectInsert(RectArea **root, XRectangle *xrect); /** * Clean up a list of areas marked for update. diff --git a/recordmydesktop/src/rmd_rescue.c b/recordmydesktop/src/rmd_rescue.c index b017e92..2b48eb0 100644 --- a/recordmydesktop/src/rmd_rescue.c +++ b/recordmydesktop/src/rmd_rescue.c @@ -39,13 +39,14 @@ int rmdRescue(const char *path){ - + int i=0, - width, - height, offset_x, offset_y; + unsigned short width, + height; + ProgData pdata; EncData enc_data; CacheData cache_data; @@ -77,10 +78,10 @@ int rmdRescue(const char *path){ return 1; - width=((pdata.brwin.rgeom.width + 15) >>4)<<4; - height=((pdata.brwin.rgeom.height + 15) >>4)<<4; - offset_x=((width-pdata.brwin.rgeom.width)/2)&~1; - offset_y=((height-pdata.brwin.rgeom.height)/2)&~1; + width=((pdata.brwin.rrect.width + 15) >>4)<<4; + height=((pdata.brwin.rrect.height + 15) >>4)<<4; + offset_x=((width-pdata.brwin.rrect.width)/2)&~1; + offset_y=((height-pdata.brwin.rrect.height)/2)&~1; enc_data.yuv.y=(unsigned char *)malloc(height*width); diff --git a/recordmydesktop/src/rmd_setbrwindow.c b/recordmydesktop/src/rmd_setbrwindow.c index 5261514..431ff43 100644 --- a/recordmydesktop/src/rmd_setbrwindow.c +++ b/recordmydesktop/src/rmd_setbrwindow.c @@ -43,7 +43,7 @@ * * \note This is called separately for width and height. */ -static void SizePack2_8_16(int *start, int *size, int limit) { +static void SizePack2_8_16(short *start, unsigned short *size, unsigned short limit) { int octoffset,hexoffset; //align in two @@ -132,18 +132,18 @@ boolean SetBRWindow(Display *dpy, if(args->windowid==0){//root window //first set it up brwin->windowid=specs->root; - brwin->geom.x=brwin->geom.y=0; - brwin->geom.width=specs->width; - brwin->geom.height=specs->height; - brwin->rgeom.x=args->x; - brwin->rgeom.y=args->y; - brwin->rgeom.width=((args->width)? - args->width:specs->width-brwin->rgeom.x); - brwin->rgeom.height=((args->height)? - args->height:specs->height-brwin->rgeom.y); + brwin->rect.x=brwin->rect.y=0; + brwin->rect.width=specs->width; + brwin->rect.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); //and then check validity - if((brwin->rgeom.x+brwin->rgeom.width>specs->width)|| - (brwin->rgeom.y+brwin->rgeom.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); @@ -169,44 +169,44 @@ boolean SetBRWindow(Display *dpy, &transl_y, &wchid); - brwin->geom.x=attribs.x-transl_x; - brwin->geom.y=attribs.y-transl_y; - brwin->geom.width=attribs.width; - brwin->geom.height=attribs.height; - if((brwin->geom.x+brwin->geom.width>specs->width)|| - (brwin->geom.y+brwin->geom.height>specs->height)){ + brwin->rect.x=attribs.x-transl_x; + brwin->rect.y=attribs.y-transl_y; + brwin->rect.width=attribs.width; + brwin->rect.height=attribs.height; + if((brwin->rect.x+brwin->rect.width>specs->width)|| + (brwin->rect.y+brwin->rect.height>specs->height)){ fprintf(stderr,"Window must be on visible screen area!\n"); return FALSE; } - brwin->rgeom.x=brwin->geom.x+args->x; - brwin->rgeom.y=brwin->geom.y+args->y; - brwin->rgeom.width=((args->width)? - args->width:brwin->geom.width-args->x); - brwin->rgeom.height=((args->height)? - args->height:brwin->geom.height-args->y); - if((args->x+brwin->rgeom.width>brwin->geom.width)|| - (args->y+brwin->rgeom.height>brwin->geom.height)){ + brwin->rrect.x=brwin->rect.x+args->x; + brwin->rrect.y=brwin->rect.y+args->y; + brwin->rrect.width=((args->width)? + args->width:brwin->rect.width-args->x); + brwin->rrect.height=((args->height)? + args->height:brwin->rect.height-args->y); + if((args->x+brwin->rrect.width>brwin->rect.width)|| + (args->y+brwin->rrect.height>brwin->rect.height)){ fprintf(stderr,"Specified Area is larger than window!\n"); return FALSE; } } fprintf(stderr, "Initial recording window is set to:\n" "X:%d Y:%d Width:%d Height:%d\n", - brwin->rgeom.x,brwin->rgeom.y, - brwin->rgeom.width,brwin->rgeom.height); - SizePack2_8_16(&brwin->rgeom.x,&brwin->rgeom.width,specs->width); - SizePack2_8_16(&brwin->rgeom.y,&brwin->rgeom.height,specs->height); + brwin->rrect.x,brwin->rrect.y, + brwin->rrect.width,brwin->rrect.height); + SizePack2_8_16(&brwin->rrect.x,&brwin->rrect.width,specs->width); + SizePack2_8_16(&brwin->rrect.y,&brwin->rrect.height,specs->height); fprintf(stderr, "Adjusted recording window is set to:\n" "X:%d Y:%d Width:%d Height:%d\n", - brwin->rgeom.x,brwin->rgeom.y, - brwin->rgeom.width,brwin->rgeom.height); + brwin->rrect.x,brwin->rrect.y, + brwin->rrect.width,brwin->rrect.height); - brwin->nbytes=(((brwin->rgeom.width+15)>>4)<<4)* - (((brwin->rgeom.height+15)>>4)<<4)* + brwin->nbytes=(((brwin->rrect.width+15)>>4)<<4)* + (((brwin->rrect.height+15)>>4)<<4)* ((specs->depth==16)?2:4); return TRUE; diff --git a/recordmydesktop/src/rmd_specsfile.c b/recordmydesktop/src/rmd_specsfile.c index 13ec249..c168401 100644 --- a/recordmydesktop/src/rmd_specsfile.c +++ b/recordmydesktop/src/rmd_specsfile.c @@ -44,8 +44,8 @@ int WriteSpecsFile(ProgData *pdata){ else{ fprintf(fp,"recordMyDesktop = %s\n",VERSION); - fprintf(fp,"Width = %d\n",pdata->brwin.rgeom.width); - fprintf(fp,"Height = %d\n",pdata->brwin.rgeom.height); + fprintf(fp,"Width = %hu\n",pdata->brwin.rrect.width); + fprintf(fp,"Height = %hu\n",pdata->brwin.rrect.height); fprintf(fp,"Filename = %s\n",pdata->args.filename); fprintf(fp,"FPS = %f\n",pdata->args.fps); fprintf(fp,"NoSound = %d\n",pdata->args.nosound); @@ -91,11 +91,11 @@ int ReadSpecsFile(ProgData *pdata){ fprintf(stderr,"Error reading VERSION attribute!!!\n"); return 1; } - if(fscanf(fp,"Width = %d\n",&pdata->brwin.rgeom.width)!=1){ + if(fscanf(fp,"Width = %hu\n",&pdata->brwin.rrect.width)!=1){ fprintf(stderr,"Error reading Width attribute!!!\n"); return 1; } - if(fscanf(fp,"Height = %d\n",&pdata->brwin.rgeom.height)!=1){ + if(fscanf(fp,"Height = %hu\n",&pdata->brwin.rrect.height)!=1){ fprintf(stderr,"Error reading Height attribute!!!\n"); return 1; } diff --git a/recordmydesktop/src/rmd_types.h b/recordmydesktop/src/rmd_types.h index 404a495..213745d 100644 --- a/recordmydesktop/src/rmd_types.h +++ b/recordmydesktop/src/rmd_types.h @@ -87,29 +87,21 @@ typedef struct _ProgData ProgData; typedef struct _DisplaySpecs{ //this struct holds some basic information int screen; //about the display,needed mostly for - unsigned int width; //validity checks at startup - unsigned int height; + unsigned int width, height; //validity checks at startup Window root; Visual *visual; GC gc; int depth; }DisplaySpecs; -typedef struct _WGeometry{ //basic geometry of a window or area - int x; - int y; - int width; - int height; -}WGeometry; - typedef struct _RectArea{ //an area that has been damaged gets stored - WGeometry geom; //in a list comprised of structs of this type + XRectangle rect; //in a list comprised of structs of this type struct _RectArea *prev,*next; }RectArea; typedef struct _BRWindow{ //'basic recorded window' specs - WGeometry geom; //window attributes - WGeometry rgeom; //part of window that is recorded + XRectangle rect; //window attributes + XRectangle rrect; //part of window that is recorded int nbytes; //size of zpixmap when screenshoting Window windowid; //id }BRWindow; @@ -121,7 +113,7 @@ typedef struct _ProgArgs{ Window windowid; //window to record(default root) char *display; //display to connect(default :0) int x,y; //x,y offset(default 0,0) - int width,height; //defaults to window width and height + unsigned int width,height; //defaults to window width and height char *filename; //output file(default out.[ogg|*]) int cursor_color; //black or white=>1 or 0 int have_dummy_cursor; //disable/enable drawing of the dummy cursor diff --git a/recordmydesktop/src/rmd_update_image.c b/recordmydesktop/src/rmd_update_image.c index 0051e69..458172e 100644 --- a/recordmydesktop/src/rmd_update_image.c +++ b/recordmydesktop/src/rmd_update_image.c @@ -58,25 +58,25 @@ void UpdateImage(Display * dpy, GetZPixmap( dpy, specs->root, datatemp, - temp->geom.x, - temp->geom.y, - temp->geom.width, - temp->geom.height); + temp->rect.x, + temp->rect.y, + temp->rect.width, + temp->rect.height); } else{ GetZPixmapSHM(dpy, specs->root, shminfo, shm_opcode, - datatemp,temp->geom.x, - temp->geom.y, - temp->geom.width, - temp->geom.height); + datatemp,temp->rect.x, + temp->rect.y, + temp->rect.width, + temp->rect.height); } UPDATE_YUV_BUFFER(yuv,dtap,NULL, - (temp->geom.x-brwin->rgeom.x+enc->x_offset), - (temp->geom.y-brwin->rgeom.y+enc->y_offset), - (temp->geom.width),(temp->geom.height), + (temp->rect.x-brwin->rrect.x+enc->x_offset), + (temp->rect.y-brwin->rrect.y+enc->y_offset), + (temp->rect.width),(temp->rect.height), no_quick_subsample, specs->depth); temp=temp->next; diff --git a/recordmydesktop/src/test-rectinsert-data.c b/recordmydesktop/src/test-rectinsert-data.c index 15b567e..2bb5c4a 100644 --- a/recordmydesktop/src/test-rectinsert-data.c +++ b/recordmydesktop/src/test-rectinsert-data.c @@ -35,7 +35,7 @@ RectInsertTestdataEntry rectinsert_test_data[] = { // Test #1 - { "Put a geom in place", + { "Put a rect in place", { 2, 2, 2, 2 }, @@ -66,7 +66,7 @@ RectInsertTestdataEntry rectinsert_test_data[] = { // Test #2 - { "Put a geom in place and make sure it gets an even size and position", + { "Put a rect in place and make sure it gets an even size and position", { 15, 2, 4, 3 }, @@ -97,7 +97,7 @@ RectInsertTestdataEntry rectinsert_test_data[] = { // Test #3 - { "Put a new geom within an existing geom", + { "Put a new rect within an existing rect", { 14, 2, 4, 2 }, @@ -128,7 +128,7 @@ RectInsertTestdataEntry rectinsert_test_data[] = { // Test #4 - { "Put a new geom over an existing geom and make sure it beocomes even", + { "Put a new rect over an existing rect and make sure it beocomes even", { 1, 1, 3, 3 }, @@ -160,7 +160,7 @@ RectInsertTestdataEntry rectinsert_test_data[] = { // Test #5 - { "Put a new geom that partly covers an existing geom", + { "Put a new rect that partly covers an existing rect", { 10, 4, 6, 6 }, @@ -191,7 +191,7 @@ RectInsertTestdataEntry rectinsert_test_data[] = { // Test #6 - { "Put new small heighted but wide geom over an existing geom area", + { "Put new small heighted but wide rect over an existing rect area", { 0, 8, 20, 2 }, @@ -222,7 +222,7 @@ RectInsertTestdataEntry rectinsert_test_data[] = { // Test #7 - { "Put new small widthed but high geom over two existing geom areas", + { "Put new small widthed but high rect over two existing rect areas", { 2, 2, 2, 18 }, @@ -315,7 +315,7 @@ RectInsertTestdataEntry rectinsert_test_data[] = { // Test #10 - { "Put a geom that covers two separate geoms", + { "Put a rect that covers two separate rects", { 6, 12, 14, 8 }, diff --git a/recordmydesktop/src/test-rectinsert-types.h b/recordmydesktop/src/test-rectinsert-types.h index b9f0c32..b39322a 100644 --- a/recordmydesktop/src/test-rectinsert-types.h +++ b/recordmydesktop/src/test-rectinsert-types.h @@ -33,7 +33,7 @@ typedef struct RectInsertTestdataEntry { const char *description; - WGeometry new_geom; + XRectangle new_rect; boolean expected_state[STATE_WIDTH * STATE_HEIGHT]; } RectInsertTestdataEntry; diff --git a/recordmydesktop/src/test-rectinsert.c b/recordmydesktop/src/test-rectinsert.c index 28eb665..b63e5ce 100644 --- a/recordmydesktop/src/test-rectinsert.c +++ b/recordmydesktop/src/test-rectinsert.c @@ -51,11 +51,11 @@ static boolean GetPixel(boolean *state, int x, int y) { return state[y * STATE_WIDTH + x]; } -static void WriteGeomToState(WGeometry *geom, boolean *state) { +static void WriteGeomToState(XRectangle *rect, boolean *state) { int x, y; - for (y = geom->y; y < geom->y + geom->height; y++) { - for (x = geom->x; x < geom->x + geom->width; x++) { + for (y = rect->y; y < rect->y + rect->height; y++) { + for (x = rect->x; x < rect->x + rect->width; x++) { SetPixel(state, x, y, TRUE); } } @@ -71,19 +71,19 @@ static void ClearState(boolean *state) { } } -static void WarnIfNonOptimal(WGeometry *geom) { - if (geom->x < 0 || geom->x >= STATE_WIDTH || - geom->y < 0 || geom->y >= STATE_HEIGHT || - geom->width < 0 || geom->width > STATE_WIDTH || - geom->height < 0 || geom->height > STATE_HEIGHT) +static void WarnIfNonOptimal(XRectangle *rect) { + if (rect->x < 0 || rect->x >= STATE_WIDTH || + rect->y < 0 || rect->y >= STATE_HEIGHT || + rect->width == 0 || rect->width > STATE_WIDTH || + rect->height == 0 || rect->height > STATE_HEIGHT) { // The RectInsert() implementation is not optimal - printf(" Non-optimal geom (and RectInsert() implementation) encountered!\n" - " geom x = %d, y = %d, width = %d, height = %d\n", - geom->x, - geom->y, - geom->width, - geom->height); + printf(" Non-optimal rect (and RectInsert() implementation) encountered!\n" + " rect x = %d, y = %d, width = %hu, height = %hu\n", + rect->x, + rect->y, + rect->width, + rect->height); } } @@ -94,9 +94,9 @@ static void GetState(RectArea *root, boolean *state) { while (current) { - WarnIfNonOptimal(¤t->geom); + WarnIfNonOptimal(¤t->rect); - WriteGeomToState(¤t->geom, state); + WriteGeomToState(¤t->rect, state); current = current->next; } @@ -150,7 +150,7 @@ int main(int argc, char **argv) { while (rectinsert_test_data[i].description != NULL) { printf("Test #%d: %s\n", i + 1, rectinsert_test_data[i].description); - RectInsert(&root, &rectinsert_test_data[i].new_geom); + RectInsert(&root, &rectinsert_test_data[i].new_rect); GetState(root, current_state); if (!StatesEqual(current_state, rectinsert_test_data[i].expected_state)) { |