Skip to content

Commit b23dbf2

Browse files
committed
code clean
1 parent d4d356d commit b23dbf2

5 files changed

Lines changed: 31 additions & 49 deletions

File tree

LFSToolKit/LFSToolKit/lfstk/LFSTKGadget.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ void LFSTK_gadgetClass::LFSTK_resizeWindow(int w,int h)
803803
this->gadgetDetails.gadgetGeom.w=w;
804804
this->gadgetDetails.gadgetGeom.h=h;
805805
XResizeWindow(this->wc->app->display,this->window,this->gadgetGeom.w,this->gadgetGeom.h);
806-
this->wc->globalLib->LFSTK_setCairoSurface(this->wc->app->display,this->window,this->wc->app->visual,&this->sfc,&this->cr,w,h);
806+
this->resizeCairoParts(w,h);
807807

808808
this->LFSTK_clearWindow();
809809
}
@@ -1609,6 +1609,18 @@ void LFSTK_gadgetClass::LFSTK_setShowIndicator(bool show)
16091609
this->showIndicator=show;
16101610
}
16111611

1612+
/**
1613+
* Resize cairo surface and context to gadget size.
1614+
* \param int width.
1615+
* \param int height.
1616+
*/
1617+
void LFSTK_gadgetClass::resizeCairoParts(int width,int height)
1618+
{
1619+
cairo_xlib_surface_set_size(this->sfc,width,height);
1620+
cairo_destroy(this->cr);
1621+
this->cr=cairo_create(this->sfc);
1622+
}
1623+
16121624
/**
16131625
* Set gadget size.
16141626
* \param int width.
@@ -1621,10 +1633,7 @@ void LFSTK_gadgetClass::LFSTK_setGadgetSize(int width,int height)
16211633
this->gadgetDetails.gadgetGeom.h=height;
16221634
this->gadgetGeom.w=width;
16231635
this->gadgetGeom.h=height;
1624-
1625-
cairo_xlib_surface_set_size(this->sfc,width,height);
1626-
cairo_destroy(this->cr);
1627-
this->cr=cairo_create(this->sfc);
1636+
this->resizeCairoParts(width,height);
16281637
}
16291638

16301639
/**

LFSToolKit/LFSToolKit/lfstk/LFSTKGadget.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ class LFSTK_gadgetClass
192192
void selectBevel(bool mousedown);
193193
cairo_surface_t *link=NULL;
194194
cairo_surface_t *broken=NULL;
195+
void resizeCairoParts(int width,int height);
195196

196197
protected:
197198
mappedListener *ml=NULL;

LFSToolKit/LFSToolKit/lfstk/LFSTKLib.cpp

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,6 @@ unsigned long LFSTK_lib::LFSTK_getColourFromName(Display *display,Colormap cm,co
812812
* \param int width.
813813
* \param int height.
814814
*/
815-
#if 1
816815
void LFSTK_lib::LFSTK_setCairoSurface(Display *display,Window window,Visual *visual,cairo_surface_t **sfc,cairo_t **cr,int width,int height)
817816
{
818817
if((height<1) || (width<1))
@@ -828,44 +827,6 @@ void LFSTK_lib::LFSTK_setCairoSurface(Display *display,Window window,Visual *vis
828827

829828
*cr=cairo_create(*sfc);
830829
}
831-
#else
832-
void LFSTK_lib::LFSTK_setCairoSurface(Display *display,Window window,Visual *visual,cairo_surface_t **sfc,cairo_t **cr,int width,int height)
833-
{
834-
if((height<1) || (width<1))
835-
return;
836-
fprintf(stderr,"srfc=%p\n",*sfc);
837-
//if(*sfc!=NULL)
838-
// fprintf(stderr,"cw=%i ch=%i\n",cairo_xlib_surface_get_width (*sfc),cairo_xlib_surface_get_height (*sfc));
839-
840-
if((sfc!=NULL) && (*sfc!=NULL))
841-
{
842-
fprintf(stderr,"00000\n");
843-
cairo_surface_destroy (*sfc);
844-
845-
846-
//sfc=cairo_xlib_surface_create(display,window,visual,width,height);
847-
*sfc=NULL;
848-
}
849-
850-
if(*sfc==NULL)
851-
//{
852-
*sfc=cairo_xlib_surface_create(display,window,visual,width,height);
853-
// }
854-
else
855-
cairo_xlib_surface_set_size(*sfc,width,height);
856-
857-
//fprintf(stderr,"cw=%i ch=%i\n",cairo_xlib_surface_get_width (*sfc),cairo_xlib_surface_get_height (*sfc));
858-
859-
if((cr!=NULL) && (*cr!=NULL))
860-
{
861-
cairo_destroy (*cr);
862-
*cr=NULL;
863-
}
864-
//else
865-
if(*cr==NULL)
866-
*cr=cairo_create(*sfc);
867-
}
868-
#endif
869830

870831
/**
871832
* Get mime type of file.

LFSToolKit/LFSToolKit/lfstk/LFSTKWindow.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,18 @@ void LFSTK_windowClass::LFSTK_clearWindow(bool cleargadgets)
370370
}
371371
}
372372

373+
/**
374+
* Resize cairo surface and context to window size.
375+
* \param int width.
376+
* \param int height.
377+
*/
378+
void LFSTK_windowClass::resizeCairoParts(int width,int height)
379+
{
380+
cairo_xlib_surface_set_size(this->sfc,width,height);
381+
cairo_destroy(this->cr);
382+
this->cr=cairo_create(this->sfc);
383+
}
384+
373385
/**
374386
* Resize window.
375387
* \param w New width.
@@ -382,8 +394,8 @@ void LFSTK_windowClass::LFSTK_resizeWindow(int w,int h,bool tellx)
382394
this->setWindowGeom(0,0,w,h,WINDSETWH);
383395
if(tellx==true)
384396
XResizeWindow(this->app->display,this->window,w,h);
385-
386-
this->globalLib->LFSTK_setCairoSurface(this->app->display,this->window,this->visual,&this->sfc,&this->cr,w,h);
397+
398+
this->resizeCairoParts(w,h);
387399
this->w=w;
388400
this->h=h;
389401
this->LFSTK_clearWindow(true);
@@ -418,7 +430,7 @@ void LFSTK_windowClass::LFSTK_moveResizeWindow(int x,int y,int w,int h,bool tell
418430
if(tellx==true)
419431
XMoveResizeWindow(this->app->display,this->window,x,y,w,h);
420432

421-
this->globalLib->LFSTK_setCairoSurface(this->app->display,this->window,this->visual,&this->sfc,&this->cr,w,h);
433+
this->resizeCairoParts(w,h);
422434
this->w=w;
423435
this->h=h;
424436
this->LFSTK_clearWindow();
@@ -1008,7 +1020,6 @@ void LFSTK_windowClass::LFSTK_setTile(const char *path,int size)
10081020
return;
10091021
}
10101022

1011-
10121023
if(this->cr!=NULL)
10131024
cairo_destroy(this->cr);
10141025
if(this->sfc!=NULL)

LFSToolKit/LFSToolKit/lfstk/LFSTKWindow.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ class LFSTK_windowClass
190190

191191
protected:
192192
bool isActive;
193-
//char *windowName=NULL;
194193
std::string windowName="LFSTK Window";
195194
void initWindow(bool loadvars);
196195

@@ -199,6 +198,7 @@ class LFSTK_windowClass
199198
void windowClassInitCommon(windowInitStruct *wi);
200199
void loadGlobalColours(void);
201200
void sendUTF8(XSelectionRequestEvent *sev);
201+
void resizeCairoParts(int width,int height);
202202

203203
//DnD routines
204204
void LFSTK_dropData(propertyStruct* data);

0 commit comments

Comments
 (0)