From be6f68e90e1647bcd08f774b58d2a6695238162e Mon Sep 17 00:00:00 2001 From: K D Hedger Date: Sat, 9 Dec 2023 14:15:33 +0000 Subject: [PATCH] various library and dock fixes, see change logs --- .../LFSApplications/app/apps.local | 12 ++ LFSDesktop/LFSDesktop/src/main.cpp | 40 ++-- LFSDock/ChangeLog | 2 + LFSDock/LFSDock/app/lfsdock.local | 7 + LFSDock/LFSDock/src/callbacks.cpp | 84 ++++++-- LFSDock/LFSDock/src/callbacks.h | 5 +- LFSDock/LFSDock/src/clock.cpp | 4 +- LFSDock/LFSDock/src/desktopSwitcher.cpp | 156 ++++----------- LFSDock/LFSDock/src/desktopSwitcher.h | 2 +- LFSDock/LFSDock/src/globals.cpp | 187 ++---------------- LFSDock/LFSDock/src/globals.h | 26 ++- LFSDock/LFSDock/src/launchers.cpp | 95 ++++----- LFSDock/LFSDock/src/launchers.h | 2 - LFSDock/LFSDock/src/main.cpp | 183 ++++++++--------- LFSDock/LFSDock/src/slider.cpp | 24 +-- LFSDock/LFSDock/src/taskBar.cpp | 136 ++++--------- LFSDock/LFSDock/src/taskBar.h | 11 +- LFSDock/README.md | 2 +- LFSPanel/LFSPanel/src/slider.cpp | 24 +-- LFSToolKit/ChangeLog | 2 + .../LFSToolKit/lfstk/LFSTKApplication.cpp | 146 ++++++++++++-- .../LFSToolKit/lfstk/LFSTKApplication.h | 13 +- .../LFSToolKit/lfstk/LFSTKFileDialog.cpp | 34 ++-- .../LFSToolKit/lfstk/LFSTKFindClass.cpp | 5 +- .../LFSToolKit/lfstk/LFSTKFontDialog.cpp | 22 +-- LFSToolKit/LFSToolKit/lfstk/LFSTKGadget.cpp | 24 +-- LFSToolKit/LFSToolKit/lfstk/LFSTKGadget.h | 2 - LFSToolKit/LFSToolKit/lfstk/LFSTKGlobals.h | 13 +- LFSToolKit/LFSToolKit/lfstk/LFSTKLib.cpp | 28 +-- LFSToolKit/LFSToolKit/lfstk/LFSTKLineEdit.cpp | 13 +- .../LFSToolKit/lfstk/LFSTKListGadget.cpp | 9 +- LFSToolKit/LFSToolKit/lfstk/LFSTKListGadget.h | 6 +- LFSToolKit/LFSToolKit/lfstk/LFSTKMenu.cpp | 22 ++- LFSToolKit/LFSToolKit/lfstk/LFSTKMenuItem.cpp | 5 +- .../LFSToolKit/lfstk/LFSTKMultiLineEdit.cpp | 8 +- .../LFSToolKit/lfstk/LFSTKScrollBar.cpp | 10 +- .../LFSToolKit/lfstk/LFSTKToggleButton.cpp | 4 +- .../LFSToolKit/lfstk/LFSTKToolWindow.cpp | 28 +-- LFSToolKit/LFSToolKit/lfstk/LFSTKToolWindow.h | 4 +- LFSToolKit/LFSToolKit/lfstk/LFSTKWindow.cpp | 67 ++++--- LFSToolKit/LFSToolKit/lfstk/LFSTKWindow.h | 9 +- LFSToolKit/examples/basic.cpp | 5 +- LFSToolKit/examples/image.cpp | 8 +- LFSToolKit/examples/imagebutton.cpp | 5 +- LFSToolKit/examples/subwindowtest.cpp | 8 +- LFSToolKit/examples/toggle.cpp | 11 +- LFSWM2/LFSWM2/app/lfswm2.local | 12 ++ README.md | 14 +- makeall | 3 +- 49 files changed, 760 insertions(+), 782 deletions(-) create mode 100755 LFSApplications/LFSApplications/app/apps.local create mode 100755 LFSWM2/LFSWM2/app/lfswm2.local diff --git a/LFSApplications/LFSApplications/app/apps.local b/LFSApplications/LFSApplications/app/apps.local new file mode 100755 index 0000000..6b4aa26 --- /dev/null +++ b/LFSApplications/LFSApplications/app/apps.local @@ -0,0 +1,12 @@ +#!/bin/bash -e + +#©keithhedger Mon 27 Nov 12:09:16 GMT 2023 kdhedger68713@gmail.com + +if [[ $1 = "conf" ]];then + pushd ../../../ + sudo BUILDFOR="LFSApplications" ./makeall ownit + BUILDFOR="LFSApplications" ./makeall makelocal + popd +fi + +LD_LIBRARY_PATH="../../../LFSToolKit/LFSToolKit/app/.libs" ./$@ diff --git a/LFSDesktop/LFSDesktop/src/main.cpp b/LFSDesktop/LFSDesktop/src/main.cpp index dd43d99..fea7bfa 100644 --- a/LFSDesktop/LFSDesktop/src/main.cpp +++ b/LFSDesktop/LFSDesktop/src/main.cpp @@ -145,7 +145,8 @@ int main(int argc, char **argv) udev=udev_new(); windowInitStruct *wi=new windowInitStruct; - wi->windowType="_NET_WM_DESKTOP"; + wi->windowType=apc->appAtomsHashed.at(apc->globalLib->prefs.LFSTK_hashFromKey("_NET_WM_WINDOW_TYPE_DESKTOP")); + wi->app=apc; wi->overRide=true; wi->level=BELOWALL; wi->decorated=false; @@ -153,7 +154,8 @@ int main(int argc, char **argv) apc->LFSTK_addWindow(wi,"Desktop"); wc=apc->mainWindow; wc->passEventToRoot=true; -Atom xa; + +Atom xa;//TODO// Atom xa_prop[3]; xa=XInternAtom(apc->display,"_NET_WM_ALLOWED_ACTIONS",False); @@ -162,15 +164,12 @@ Atom xa_prop[3]; if(xa!=None) XChangeProperty(apc->display,wc->window,xa,XA_ATOM,32,PropModeReplace,(unsigned char *)&xa_prop,2); -//fprintf(stderr,"win=0x%x\n",wc->window); - - - xa=XInternAtom(apc->display,"_NET_WM_STATE",False); - xa_prop[0]=XInternAtom(apc->display,"_NET_WM_STATE_BELOW",False); - if(xa!=None) - XChangeProperty(apc->display,wc->window,xa,XA_ATOM,32,PropModeReplace,(unsigned char *)&xa_prop,1); - XLowerWindow(apc->display,wc->window); + xa=XInternAtom(apc->display,"_NET_WM_STATE",False); + xa_prop[0]=XInternAtom(apc->display,"_NET_WM_STATE_BELOW",False); + if(xa!=None) + XChangeProperty(apc->display,wc->window,xa,XA_ATOM,32,PropModeReplace,(unsigned char *)&xa_prop,1); + XLowerWindow(apc->display,wc->window); //TODO//debug to go @@ -178,7 +177,7 @@ Atom xa_prop[3]; button=new LFSTK_buttonClass(wc,"quit",0,0,GADGETWIDTH,GADGETHITE);//TODO// button->LFSTK_setMouseCallBack(NULL,doQuit,NULL); #endif -apc->globalLib->LFSTK_setUseTheme(false); + apc->globalLib->LFSTK_setUseTheme(false); wc->LFSTK_setWindowPixmap(apc->globalLib->LFSTK_getWindowPixmap(apc->display,apc->rootWindow),apc->displayWidth,apc->displayHeight); asprintf(&cachePath,"%s/lfsdesktop/cache",apc->configDir.c_str()); asprintf(&command,"mkdir -p %s 2>&1 >/dev/null",cachePath); @@ -193,7 +192,6 @@ apc->globalLib->LFSTK_setUseTheme(false); asprintf(&prefsPath,"%s/lfsdesktop.rc",apc->configDir.c_str()); loadPrefs(); - apc->LFSTK_setTimer(refreshRate); apc->LFSTK_setTimerCallBack(timerCB,NULL); @@ -202,12 +200,13 @@ apc->globalLib->LFSTK_setUseTheme(false); windowInitStruct *win; - win=new windowInitStruct; - win->app=apc; - win->name=""; + win=apc->LFSTK_getDefaultWInit(); + //new windowInitStruct; + //win->app=apc; + win->windowName=""; win->loadVars=true; win->wc=wc; - win->windowType="_NET_WM_WINDOW_TYPE_MENU"; + win->windowType=apc->appAtomsHashed.at(apc->globalLib->prefs.LFSTK_hashFromKey("_NET_WM_WINDOW_TYPE_MENU")); win->decorated=false; win->overRide=true; win->level=ABOVEALL; @@ -226,12 +225,13 @@ apc->globalLib->LFSTK_setUseTheme(false); } fileWindow->LFSTK_resizeWindow(GADGETWIDTH+16,sy,true); - win=new windowInitStruct; - win->app=apc; - win->name=""; + //win=new windowInitStruct; + win=apc->LFSTK_getDefaultWInit(); + //win->app=apc; + win->windowName=""; win->loadVars=true; win->wc=wc; - win->windowType="_NET_WM_WINDOW_TYPE_MENU"; + win->windowType=apc->appAtomsHashed.at(apc->globalLib->prefs.LFSTK_hashFromKey("_NET_WM_WINDOW_TYPE_MENU")); win->decorated=false; win->overRide=true; win->level=ABOVEALL; diff --git a/LFSDock/ChangeLog b/LFSDock/ChangeLog index bc86531..5c510fd 100644 --- a/LFSDock/ChangeLog +++ b/LFSDock/ChangeLog @@ -1,4 +1,6 @@ 0.1.0 +Gui fixes. +Compacted code. Various gui fixes. Added taskbar gadget. Added right click to launchers for simple context menu. diff --git a/LFSDock/LFSDock/app/lfsdock.local b/LFSDock/LFSDock/app/lfsdock.local index 2d884fb..d761c7d 100755 --- a/LFSDock/LFSDock/app/lfsdock.local +++ b/LFSDock/LFSDock/app/lfsdock.local @@ -2,4 +2,11 @@ #©keithhedger Mon 27 Nov 12:09:16 GMT 2023 kdhedger68713@gmail.com +if [[ $1 = "conf" ]];then + pushd ../../../ + sudo BUILDFOR="LFSDock" ./makeall ownit + BUILDFOR="LFSDock" ./makeall makelocal + popd +fi + LD_LIBRARY_PATH="../../../LFSToolKit/LFSToolKit/app/.libs" ./lfsdock diff --git a/LFSDock/LFSDock/src/callbacks.cpp b/LFSDock/LFSDock/src/callbacks.cpp index 104f4d0..5b69a3d 100644 --- a/LFSDock/LFSDock/src/callbacks.cpp +++ b/LFSDock/LFSDock/src/callbacks.cpp @@ -30,7 +30,7 @@ void sendClientMessage(Window win,const char *msg,unsigned long data0,unsigned l event.xclient.type=ClientMessage; event.xclient.serial=0; event.xclient.send_event=True; - event.xclient.message_type=XInternAtom(mainwind->app->display,msg,False); + event.xclient.message_type=XInternAtom(dockWindow->app->display,msg,False); event.xclient.window=win; event.xclient.format=32; event.xclient.data.l[0]=data0; @@ -38,7 +38,7 @@ void sendClientMessage(Window win,const char *msg,unsigned long data0,unsigned l event.xclient.data.l[2]=data2; event.xclient.data.l[3]=data3; event.xclient.data.l[4]=data4; - XSendEvent(mainwind->app->display,mainwind->app->rootWindow,False,mask,&event); + XSendEvent(dockWindow->app->display,dockWindow->app->rootWindow,False,mask,&event); } bool gadgetDrop(void *lwc,propertyStruct *data,void* ud) @@ -66,7 +66,7 @@ bool gadgetDrop(void *lwc,propertyStruct *data,void* ud) asprintf(&command,"%s %s \"%s\" &",prefs.LFSTK_getCString("termcommand"),launcher->entry.exec,line.c_str()); sendNotify(launcher->entry.name,line.c_str()); system(command); - free(command); + freeAndNull(&command); } } } @@ -83,15 +83,17 @@ bool timerCB(LFSTK_applicationClass *p,void* ud) if(scwindow!=NULL) updateSlider(); - if(switchButton!=NULL)//TODO// - updateSwitcher(); - if((contextWindow->isVisible==false) && (contextWindow->popupFromGadget!=NULL)) { launcherExitCB(contextWindow->popupFromGadget,(void*)1); contextWindow->popupFromGadget=NULL; } + if((popActionWindow->isVisible==true) && (inSomeWindow==false) && (popActionWindow->inWindow==false)) + { + popActionListExitCB(NULL,(void*)1); + } + if(useTaskBar==true) updateTaskBar(); @@ -141,22 +143,24 @@ bool contextCB(void *p,void* ud) return(true); } -void showhidetActionList(LFSTK_buttonClass *bc,LFSTK_windowClass *winc,LFSTK_listGadgetClass *list) +void showhidetActionList(LFSTK_gadgetClass *bc,LFSTK_windowClass *winc,LFSTK_listGadgetClass *list) { - geometryStruct geom; - unsigned long d; + geometryStruct geom; + unsigned long d; + const geometryStruct *wingeom; if(bc!=NULL) - { + { + wingeom=winc->LFSTK_getWindowGeom(); d=(unsigned long)bc->userData; bc->LFSTK_getGeomWindowRelative(&geom,apc->rootWindow); switch(panelGravity) { case PANELNORTH: - winc->LFSTK_moveWindow(geom.x+(geom.w/2)-(list->LFSTK_getListMaxWidth()/2),geom.y+geom.h,true); + winc->LFSTK_moveWindow(geom.x+(geom.w/2)-(list->LFSTK_getListMaxWidth()/2),geom.y+geom.h-extraSpace,true); break; case PANELSOUTH: - winc->LFSTK_moveWindow(geom.x+(geom.w/2)-(list->LFSTK_getListMaxWidth()/2),geom.y-(GADGETHITE*(filltasks.at(d).tasks.size()+1)),true); + winc->LFSTK_moveWindow(geom.x+(geom.w/2)-(list->LFSTK_getListMaxWidth()/2),geom.y-wingeom->h+extraSpace,true); break; } winc->LFSTK_showWindow(true); @@ -168,4 +172,58 @@ void showhidetActionList(LFSTK_buttonClass *bc,LFSTK_windowClass *winc,LFSTK_lis winc->LFSTK_hideWindow(); apc->windows->at(apc->LFSTK_findWindow(winc)).showing=false; } -} \ No newline at end of file +} + +void setGadgetPosition(LFSTK_gadgetClass *gadg,bool active) +{ + geometryStruct geom; + + gadg->LFSTK_getGeom(&geom); + + if(active==true) + gadg->LFSTK_moveGadget(geom.x,activeY); + else + gadg->LFSTK_moveGadget(geom.x,normalY); +} + +bool popActionListEnterCB(LFSTK_gadgetClass*p,void* ud) +{ +//fprintf(stderr,"popActionListEnterCB\n"); + return(true); +} + +bool popActionListExitCB(LFSTK_gadgetClass*p,void* ud) +{ +//fprintf(stderr,"popActionListExitCB\n"); + showhidetActionList(NULL,popActionWindow,popActionList); + return(true); +} + +bool popActionWindowSelect(void *object,void* userdata)//TODO// +{ + listLabelStruct ls; + unsigned long wud=0; + + LFSTK_listGadgetClass *list=static_cast(object); + ls=list->listDataArray->at(list->LFSTK_getCurrentListItem()); + + LFSTK_gadgetClass *bc=static_cast(ls.userData);; + + wud=(unsigned long)popActionWindow->userData; + switch(wud) + { + case LAUNCHER: + launcherCB(bc,(void*)bc->userData); + break; + case TASKSWITCHER: + { + LFSTK_gadgetClass *bc=static_cast(object);; + taskSelect(bc,(void*)ls.userData); + } + break; + case DESKTOPSWITCHER: + desktopSelect(NULL,NULL); + break; + } + return(true); +} diff --git a/LFSDock/LFSDock/src/callbacks.h b/LFSDock/LFSDock/src/callbacks.h index 462e780..49870d0 100644 --- a/LFSDock/LFSDock/src/callbacks.h +++ b/LFSDock/LFSDock/src/callbacks.h @@ -30,6 +30,9 @@ bool contextCB(void *p,void* ud); bool gadgetDrop(void *lwc,propertyStruct *data,void* ud); bool timerCB(LFSTK_applicationClass *p,void* ud); void readMsg(void); -void showhidetActionList(LFSTK_buttonClass *bc,LFSTK_windowClass winc,LFSTK_listGadgetClass *list); +void showhidetActionList(LFSTK_gadgetClass *bc,LFSTK_windowClass *winc,LFSTK_listGadgetClass *list); +bool popActionListEnterCB(LFSTK_gadgetClass*p,void* ud); +bool popActionListExitCB(LFSTK_gadgetClass*p,void* ud); +bool popActionWindowSelect(void *object,void* userdata); #endif diff --git a/LFSDock/LFSDock/src/clock.cpp b/LFSDock/LFSDock/src/clock.cpp index 9fb89af..89c78aa 100644 --- a/LFSDock/LFSDock/src/clock.cpp +++ b/LFSDock/LFSDock/src/clock.cpp @@ -45,7 +45,7 @@ int addClock(int x,int y,int grav) return(0); } - clockButton=new LFSTK_buttonClass(mainwind,"--:--:--",x,y+(iconSize/2)-(GADGETHITE/2),iconSize,GADGETHITE); + clockButton=new LFSTK_buttonClass(dockWindow,"--:--:--",x,y+(iconWidth/2)-(GADGETHITE/2),iconWidth,GADGETHITE); setGadgetDetails(clockButton); clockButton->LFSTK_setFontString(prefs.LFSTK_getCString(prefs.LFSTK_hashFromKey("font")),true); clockButton->LFSTK_setIgnores(false,false); @@ -56,5 +56,5 @@ int addClock(int x,int y,int grav) clockButton->drawLabelBG=true; clockButton->autoLabelBGColour=true; - return(iconSize); + return(iconWidth); } diff --git a/LFSDock/LFSDock/src/desktopSwitcher.cpp b/LFSDock/LFSDock/src/desktopSwitcher.cpp index 008107f..73acf12 100644 --- a/LFSDock/LFSDock/src/desktopSwitcher.cpp +++ b/LFSDock/LFSDock/src/desktopSwitcher.cpp @@ -21,81 +21,40 @@ #include "globals.h" LFSTK_buttonClass *switchButton; -//bool switchIsUp=false; -LFSTK_listGadgetClass *switchList=NULL; -LFSTK_windowClass *switchWindow=NULL; +std::vector deskNames; bool deskSwitcherExitCB(LFSTK_gadgetClass*p,void* ud) { - geometryStruct geom2; - - if((apc->windows->at(apc->LFSTK_findWindow(switchWindow)).showing==true) && (switchWindow->inWindow==true)) - return(true); - p->LFSTK_getGeom(&geom2); - p->LFSTK_moveGadget(geom2.x,normalY); - //switchIsUp=false; + setGadgetPosition(p,false); + inSomeWindow=false; return(true); } -bool deskListCB(void* p,void* ud) -{ - LFSTK_toggleButtonClass *bc=static_cast(p); - geometryStruct geom; - int x,y; - Window dw; - - if(p!=NULL) - { - //if(bc->LFSTK_getValue()==true) - if((unsigned long)ud==1) - { - bc->LFSTK_getGeomWindowRelative(&geom,apc->rootWindow); - switch(panelGravity) - { - case PANELNORTH: - switchWindow->LFSTK_moveWindow(geom.x+(geom.w/2)-(switchList->LFSTK_getListMaxWidth()/2),geom.y+geom.h,true); - break; - case PANELSOUTH: - switchWindow->LFSTK_moveWindow(geom.x+(geom.w/2)-(switchList->LFSTK_getListMaxWidth()/2),geom.y-(GADGETHITE*deskCount),true); - break; - } - switchWindow->LFSTK_showWindow(true); - switchWindow->LFSTK_redrawAllGadgets(); - apc->windows->at(apc->LFSTK_findWindow(switchWindow)).showing=true; - } - else - { - switchWindow->LFSTK_hideWindow(); - apc->windows->at(apc->LFSTK_findWindow(switchWindow)).showing=false; - } - } - return(true); -} - -void updateSwitcher(void) -{ - //if((switchButton->inWindow==false) && (switchButton->LFSTK_getValue()==1) && (switchWindow->inWindow==false)) - if((switchButton->inWindow==false) && (switchWindow->inWindow==false)) - { - // switchButton->LFSTK_setValue(false); - switchWindow->LFSTK_hideWindow(); - apc->windows->at(apc->LFSTK_findWindow(switchWindow)).showing=false; - deskSwitcherExitCB(switchButton,NULL); - } -} - bool deskSwitcherEnterCB(LFSTK_gadgetClass*p,void* ud) { - geometryStruct geom; + std::string label; + listLabelStruct ls; - //if(switchIsUp==true) - // return(true); + setGadgetPosition(p,true); + popActionList->LFSTK_freeList(); + + for(int j=0;jLFSTK_appendToList(ls); + } + + popActionList->LFSTK_updateList(); + popActionList->LFSTK_moveGadget(-1,-1); + popActionWindow->userData=USERDATA(DESKTOPSWITCHER); + popActionWindow->LFSTK_resizeWindow(popActionList->LFSTK_getListMaxWidth()-2,(GADGETHITE*deskCount)-4); + showhidetActionList(p,popActionWindow,popActionList); + inSomeWindow=true; - p->LFSTK_getGeom(&geom); - p->LFSTK_moveGadget(geom.x,activeY); - //switchIsUp=true; - //switchButton->LFSTK_setValue(true); - deskListCB(switchButton,USERDATA(1)); return(true); } @@ -114,16 +73,13 @@ void sendPropNotifyMessage(Window win,Atom msg) XSendEvent(apc->display,apc->rootWindow,False,mask,&event); } -bool switchSelect(void *object,void* userdata) +bool desktopSelect(void *object,void* userdata) { - LFSTK_listGadgetClass *list=static_cast(object); - unsigned long d=list->LFSTK_getCurrentListItem(); + unsigned long d=popActionList->LFSTK_getCurrentListItem(); XChangeProperty(apc->display,apc->rootWindow,NET_CURRENT_DESKTOP,XA_CARDINAL,32,PropModeReplace,(const unsigned char*)&d,1); sendPropNotifyMessage(apc->rootWindow,NET_CURRENT_DESKTOP); - //switchButton->LFSTK_setValue(false); - deskListCB(switchButton,NULL); - deskSwitcherExitCB(switchButton,NULL); + showhidetActionList(NULL,popActionWindow,popActionList); return(true); } @@ -145,66 +101,28 @@ int addDesktopSwitcer(int x,int y,int grav) return(0); } + switchButton=new LFSTK_buttonClass(dockWindow,"",x,normalY,iconWidth,iconHeight); + setGadgetDetails(switchButton); + switchButton->LFSTK_setAlpha(1.0); + switchButton->LFSTK_setStyle(BEVELNONE); + switchButton->LFSTK_setMouseMoveCallBack(deskSwitcherEnterCB,deskSwitcherExitCB,NULL); - switchButton=new LFSTK_buttonClass(mainwind,"",x,normalY,iconSize,iconSize); - setGadgetDetails(switchButton); - switchButton->LFSTK_setAlpha(1.0); - switchButton->LFSTK_setMouseCallBack(NULL,deskListCB,NULL); - switchButton->LFSTK_setMouseMoveCallBack(deskSwitcherEnterCB,deskSwitcherExitCB,NULL); - - -// switchButton=new LFSTK_toggleButtonClass(mainwind,"",x,y,iconSize,iconSize); -// switchButton->LFSTK_setToggleStyle(TOGGLENORMAL); -// switchButton->LFSTK_setMouseCallBack(NULL,deskListCB,NULL); -// switchButton->LFSTK_setMouseMoveCallBack(deskSwitcherEnterCB,deskSwitcherExitCB,NULL); -// -// setGadgetDetails(switchButton); -// switchButton->LFSTK_setAlpha(1.0); -// switchButton->LFSTK_setStyle(BEVELNONE); -// switchButton->LFSTK_setGadgetColours(GADGETBG,panelBGColour,panelBGColour,panelBGColour,panelBGColour); -// switchButton->LFSTK_setGadgetColours(GADGETFG,panelTextColour,panelTextColour,panelTextColour,panelTextColour); - - icon=mainwind->globalLib->LFSTK_findThemedIcon(desktopTheme,"remote-desktop",""); + icon=dockWindow->globalLib->LFSTK_findThemedIcon(desktopTheme,"remote-desktop",""); if(icon!=NULL) { switchButton->LFSTK_setImageFromPath(icon,LEFT,true); - free(icon); + freeAndNull(&icon); } else switchButton->LFSTK_setImageFromPath(DATADIR "/pixmaps/windows.png",LEFT,true); - win->x=0; - win->y=0; - win->w=1; - win->h=1; - apc->LFSTK_addToolWindow(win); - switchWindow=apc->windows->back().window; - switchList=new LFSTK_listGadgetClass(switchWindow,"list",0,0,2000,2000); - - switchList->LFSTK_setStyle(BEVELNONE); - switchList->LFSTK_setLabelAutoColour(true); - switchList->LFSTK_setListItemsColours(GADGETBG,lc,pc,ac,lc); - switchList->LFSTK_setListItemsColours(GADGETFG,"red","red","red","red"); - switchList->LFSTK_setGadgetColourPair(NORMALCOLOUR,lc,"red"); - - switchList->LFSTK_setMouseCallBack(NULL,switchSelect,NULL); - - pr=apc->globalLib->LFSTK_getSingleProp(apc->display,apc->rootWindow,XInternAtom(apc->display,"_NET_DESKTOP_NAMES",false),XInternAtom(apc->display,"UTF8_STRING",false)); for(int j=0;jLFSTK_appendToList(ls); + deskNames.push_back(pr.strlist.at(j)); } - switchList->LFSTK_moveGadget(-1,-1); - switchWindow->LFSTK_resizeWindow(switchList->LFSTK_getListMaxWidth()-2,(GADGETHITE*deskCount)-4); - - return(iconSize); + return(iconWidth); } diff --git a/LFSDock/LFSDock/src/desktopSwitcher.h b/LFSDock/LFSDock/src/desktopSwitcher.h index 0dbc0c6..a0076a4 100644 --- a/LFSDock/LFSDock/src/desktopSwitcher.h +++ b/LFSDock/LFSDock/src/desktopSwitcher.h @@ -26,6 +26,6 @@ extern LFSTK_buttonClass *switchButton; int addDesktopSwitcer(int x,int y,int grav); -void updateSwitcher(void); +bool desktopSelect(void *object,void* userdata); #endif diff --git a/LFSDock/LFSDock/src/globals.cpp b/LFSDock/LFSDock/src/globals.cpp index 3fc8197..937e48e 100644 --- a/LFSDock/LFSDock/src/globals.cpp +++ b/LFSDock/LFSDock/src/globals.cpp @@ -25,22 +25,18 @@ LFSTK_prefsClass prefs; std::string configDir; std::string launchersDir; std::string configFile; -LFSTK_windowClass *popWindow=NULL; -LFSTK_labelClass *popLabel=NULL; launcherList *ll=NULL; -int iconSize=16; +int iconWidth=16; +int iconHeight=24; int normalY; int activeY; int extraSpace=16; int deskCount=1; -std::vector filltasks; -std::vector tasks; - int panelSize=2; const monitorStruct *mons=NULL; int onMonitor=0; -int panelGravity=PANELNORTH; +int panelGravity=PANELSOUTH; const char *panelTextColour=""; const char *panelBGColour=""; @@ -50,19 +46,22 @@ msgBuffer buffer; const char *desktopTheme=NULL; bool realMainLoop=true; -int refreshRate=1; +int refreshRate=500000; //panel window LFSTK_applicationClass *apc=NULL; -LFSTK_windowClass *mainwind=NULL; -int launcherSide=NOLAUNCHERS; +LFSTK_windowClass *dockWindow=NULL; +LFSTK_windowClass *popActionWindow=NULL; +LFSTK_listGadgetClass *popActionList=NULL; +bool inSomeWindow=false; +bool gotLaunchers=false; //atoms Atom WM_STATE=None; Atom NET_WM_WINDOW_TYPE_NORMAL=None; Atom NET_WM_STATE_HIDDEN=None; Atom NET_WM_WINDOW_TYPE_DIALOG=None; -Atom NET_WM_DESKTOP=None; +//Atom NET_WM_DESKTOP=None; Atom NET_WM_WINDOW_TYPE=None; Atom NET_WM_STATE=None; Atom NET_WM_NAME=None; @@ -71,6 +70,7 @@ Atom NET_CURRENT_DESKTOP=None; Atom WM_CLASS=None; Atom NET_WM_PID=None; Atom NET_NUMBER_OF_DESKTOPS=None; +Atom NET_ACTIVE_WINDOW=None; const char *possibleError="Unknown"; @@ -104,10 +104,10 @@ void dropDesktopFile(const char *data,launcherList *launcher) ptr=strrchr(cleanstr,'/'); sendNotify("Adding launcher ",++ptr); system(command); - free(command); + freeAndNull(&command); apc->exitValue=0; apc->mainLoop=false; - free(cleanstr); + freeAndNull(&cleanstr); return; } @@ -119,8 +119,8 @@ void dropDesktopFile(const char *data,launcherList *launcher) asprintf(&command,"%s %s \"%s\" &",prefs.LFSTK_getCString("termcommand"),launcher->entry.exec,cleanstr); sendNotify("Running ",launcher->entry.exec); system(command); - free(cleanstr); - free(command); + freeAndNull(&cleanstr); + freeAndNull(&command); } } } @@ -166,136 +166,6 @@ bool isVisible(Window win) return ok; } -Window doTreeWalk(Window wind,bool thisdesktop,std::string namecheck) -{ - Window root,parent; - Window *children; - Window thewin; - unsigned int n_children; - int i; - unsigned long winid; - char *wname; - void *ptr=NULL; - unsigned long count=32; - Atom rtype; - int rfmt; - unsigned long rafter; - unsigned long n=0; - XTextProperty textpropreturn; - Status st; - - if (!XQueryTree(mainwind->app->display,wind,&root,&parent,&children,&n_children)) - return None; - - if (!children) - return None; - - /* Check each child for WM_STATE and other validity */ - thewin=None; - wname=NULL; - winid=-1; - - for (int j=n_children-1;j>=0; j--) - { - if((thisdesktop==true) && (isVisible(children[j])==false)) - { - children[j]=None; /* Don't bother descending into this one */ - continue; - } - if (!hasProp(children[j],WM_STATE)) - continue; - -// propReturn LFSTK_getSingleProp(Display *display,Window win,Atom prop,Atom wanttype); - if (hasProp(children[j],WM_CLASS)) - { - //fprintf(stderr,"got class\n"); - propReturn pr=apc->globalLib->LFSTK_getSingleProp(apc->display,children[j],XInternAtom(apc->display,"WM_CLASS",false),XA_STRING); -if(namecheck.length()>0) -{ - //if(namecheck.compare(pr.strlist.at(0))==0) - if(strcasecmp(namecheck.c_str(),pr.strlist.at(0).c_str())==0) - { -fprintf(stderr,"strlist=%>>%s<< winid=%p\n",pr.strlist.at(0).c_str(),children[j]); - if(wname!=NULL) - XFree(wname); - XFree(ptr); - XFree(children); - return children[j]; - } -} - } - - /* Got one */ - thewin=children[j]; - winid=children[j]; - st=XFetchName(mainwind->app->display,children[j],&wname); - fprintf(stderr,"wname=>>%s<<\n",wname); - - break; - } - - thewin=None; - /* No children matched, now descend into each child */ - for (i=(int) n_children - 1; i >= 0; i--) - { - if (children[i]==None) - continue; -// if (isHidden(children[i])==true) -// continue; - - thewin=doTreeWalk(children[i],thisdesktop,namecheck); - if (thewin != None) - { - return(thewin); - break; - } - } - - if(wname!=NULL) - { - // fprintf(stderr,"wname=>>%s<<\n",wname); - if(winid!=-1) - { - ptr=NULL; - count=32; - n=0; - - if(strlen(wname)==0) - { - st=XGetWindowProperty( mainwind->app->display,winid,NET_WM_NAME,0,count,false,UTF8_STRING,&rtype,&rfmt,&n,&rafter,(unsigned char **)&ptr); - if(st==Success && n != 0 && ptr != NULL) - wname=strdup((char*)ptr); - } - -if(namecheck.length()>0) -{ - if(namecheck.compare(wname)==0) - { - if(wname!=NULL) - XFree(wname); - XFree(ptr); - XFree(children); - return thewin; - } -} -// for(int j=0;japp->display,winid,NET_WM_DESKTOP,0L,count,false,XA_CARDINAL,&rtype,&rfmt,&n,&rafter,(unsigned char **)&ptr); -// windowList[windowListCnt]=new menuStruct; -// windowList[windowListCnt]->label=strdup(wname); -// windowList[windowListCnt++]->userData=(void*)winid; - } - } - - if(wname!=NULL) - XFree(wname); - XFree(ptr); - XFree(children); - return thewin; -} - Window doTreeWalkForClass(Window wind,std::string namecheck) { Window root; @@ -305,7 +175,7 @@ Window doTreeWalkForClass(Window wind,std::string namecheck) unsigned int n_children; unsigned long winid; - if (!XQueryTree(mainwind->app->display,wind,&root,&parent,&children,&n_children)) + if (!XQueryTree(dockWindow->app->display,wind,&root,&parent,&children,&n_children)) return None; if (!children) @@ -371,7 +241,7 @@ Window doTreeWalkForPID(Window wind,unsigned long pid) unsigned int n_children; unsigned long winid; - if (!XQueryTree(mainwind->app->display,wind,&root,&parent,&children,&n_children)) + if (!XQueryTree(dockWindow->app->display,wind,&root,&parent,&children,&n_children)) return None; if (!children) @@ -424,17 +294,6 @@ Window doTreeWalkForPID(Window wind,unsigned long pid) return thewin; } -Window getNamedWindow(std::string name) -{ - Window win=None; - win=doTreeWalk(apc->rootWindow,true,name); - if(win!=None) - { - fprintf(stderr,"go win named %s at %p\n",name.c_str(),win); - } -return(win); -} - Window getWindowByClass(std::string name) { Window win=None; @@ -457,21 +316,16 @@ void moveDock(int extra) psize=windowWidth+extra; px=mons->x; py=mons->y; + switch(panelGravity) { case PANELSOUTH: - py=mons->y+mons->h-iconSize-extraSpace; + py=mons->y+mons->h-iconWidth-extraSpace; case PANELNORTH: px=((mons->w/2)-(psize/2))+mons->x; break; } - - -// if(posMultiplier==1) -// mainwind->LFSTK_moveWindow(px,py-extraSpace,true); - mainwind->LFSTK_moveWindow(px,py,true); -// else -// mainwind->LFSTK_moveWindow(px,py,true); + dockWindow->LFSTK_moveWindow(px,py,true); } std::string getWindowName(Window winid) @@ -495,7 +349,6 @@ std::string getWindowName(Window winid) XFree(wname); } } - return(returnval); } diff --git a/LFSDock/LFSDock/src/globals.h b/LFSDock/LFSDock/src/globals.h index 1d45768..7816d11 100644 --- a/LFSDock/LFSDock/src/globals.h +++ b/LFSDock/LFSDock/src/globals.h @@ -39,9 +39,8 @@ #ifndef _GLOBALS_ #define _GLOBALS_ -enum PANELXPOS {PANELLEFT=-1,PANELCENTRE=-2,PANELRIGHT=-3}; -enum PANELSIZE {PANELFULL=-1,PANELSHRINK=-2}; enum PANELGRAVITY {PANELNORTH=1,PANELSOUTH=2}; +enum WHATSORT {LAUNCHER=100,DESKTOPSWITCHER,TASKSWITCHER}; struct menuEntryStruct { @@ -71,25 +70,20 @@ struct taskStruct }; -enum {NOLAUNCHERS,LAUNCHERINLEFT}; - //prefs extern LFSTK_prefsClass prefs; extern std::string configDir; extern std::string launchersDir; extern std::string configFile; -extern LFSTK_windowClass *popWindow; -extern LFSTK_labelClass *popLabel; extern launcherList *ll; -extern int iconSize; +extern int iconWidth; +extern int iconHeight; + extern int normalY; extern int activeY; extern int extraSpace; extern int deskCount; -extern std::vector filltasks; -extern std::vector tasks; - extern int panelSize; extern const monitorStruct *mons; extern int onMonitor; @@ -110,19 +104,22 @@ extern int windowWidth; extern GKeyFile *kf; extern LFSTK_findClass *gFind; extern bool useTaskBar; +extern bool gotLaunchers; //panel window extern LFSTK_applicationClass *apc; -extern LFSTK_windowClass *mainwind; -extern int launcherSide; +extern LFSTK_windowClass *dockWindow; +extern LFSTK_windowClass *popActionWindow; +extern LFSTK_listGadgetClass *popActionList; +extern bool inSomeWindow; //atoms extern Atom WM_STATE; extern Atom NET_WM_WINDOW_TYPE_NORMAL; extern Atom NET_WM_STATE_HIDDEN; extern Atom NET_WM_WINDOW_TYPE_DIALOG; -extern Atom NET_WM_DESKTOP; +//extern Atom NET_WM_DESKTOP; extern Atom NET_WM_WINDOW_TYPE; extern Atom NET_WM_STATE; extern Atom NET_WM_NAME; @@ -131,6 +128,7 @@ extern Atom NET_CURRENT_DESKTOP; extern Atom WM_CLASS; extern Atom NET_WM_PID; extern Atom NET_NUMBER_OF_DESKTOPS; +extern Atom NET_ACTIVE_WINDOW; extern const char *possibleError; @@ -139,7 +137,6 @@ void dropDesktopFile(const char *data,launcherList *launcher); void sendNotify(const char *message1,const char *message2); void setGadgetDetails(LFSTK_gadgetClass *gadget); bool hasProp(Window win,Atom atom); -Window getNamedWindow(std::string name); Window getWindowByClass(std::string name); Window getWindowByPID(unsigned long pid); @@ -148,5 +145,6 @@ Window doTreeWalkForPID(Window wind,unsigned long pid); void moveDock(int extra); std::string getWindowName(Window winid); +void setGadgetPosition(LFSTK_gadgetClass *gadg,bool active); #endif diff --git a/LFSDock/LFSDock/src/launchers.cpp b/LFSDock/LFSDock/src/launchers.cpp index d8c7779..955cf6f 100644 --- a/LFSDock/LFSDock/src/launchers.cpp +++ b/LFSDock/LFSDock/src/launchers.cpp @@ -33,41 +33,37 @@ bool launcherEnterCB(LFSTK_gadgetClass*p,void* ud) if(ud!=NULL) { geometryStruct geom; - launcherList *ll; + launcherList *launchlist; int width; + std::string label; + listLabelStruct ls; - ll=(launcherList*)ud; + launchlist=(launcherList*)ud; - p->LFSTK_getGeom(&geom); - p->LFSTK_moveGadget(geom.x,activeY); - popLabel->LFSTK_setLabel(ll->entry.name); - popLabel->LFSTK_setFontString(prefs.LFSTK_getCString(prefs.LFSTK_hashFromKey("font")),true); - width=popLabel->LFSTK_getTextRealWidth(ll->entry.name); - p->LFSTK_getGeomWindowRelative(&geom,apc->rootWindow); - popWindow->LFSTK_resizeWindow(width,GADGETHITE); - p->LFSTK_getGeomWindowRelative(&geom,apc->rootWindow); - - if(panelGravity==PANELSOUTH) - popWindow->LFSTK_moveWindow(geom.x-(width/2)+(geom.w/2),geom.y-(GADGETHITE),true); - else - popWindow->LFSTK_moveWindow(geom.x-(width/2)+(geom.w/2),geom.y+iconSize,true); - - popWindow->LFSTK_showWindow(); - popWindow->LFSTK_clearWindow(true); + setGadgetPosition(p,true); + popActionList->LFSTK_freeList(); + label=launchlist->entry.name; + ls.label=strdup((char*)label.c_str()); + ls.imageType=NOTHUMB; + ls.data.imagePath=NULL; + ls.userData=USERDATA(p); + popActionList->LFSTK_appendToList(ls); + popActionList->LFSTK_updateList(); + popActionList->LFSTK_moveGadget(-1,-1); + popActionWindow->userData=USERDATA(LAUNCHER); + popActionWindow->LFSTK_resizeWindow(popActionList->LFSTK_getListMaxWidth()-2,GADGETHITE-2); + showhidetActionList(p,popActionWindow,popActionList); + inSomeWindow=true; } return(true); } -bool launcherExitCB(LFSTK_gadgetClass*p,void* ud) +bool launcherExitCB(LFSTK_gadgetClass *p,void* ud) { if(ud!=NULL) { - launcherList *ll; - ll=(launcherList*)ud; - geometryStruct geom2; - p->LFSTK_getGeom(&geom2); - p->LFSTK_moveGadget(geom2.x,normalY); - popWindow->LFSTK_hideWindow(); + setGadgetPosition(p,false); + inSomeWindow=false; } return(true); } @@ -82,21 +78,35 @@ bool launcherCB(void *p,void* ud) std::string args; std::string str; std::string whch; + propReturn pr; if(launcher==NULL) return(true); + showhidetActionList(NULL,popActionWindow,popActionList); + if(p!=NULL) { win=getWindowByClass(launcher->entry.name); if(win!=None) { + pr=apc->globalLib->LFSTK_getSingleProp(apc->display,apc->rootWindow,NET_ACTIVE_WINDOW,XA_WINDOW); + if(pr.window==win) + { + XUnmapWindow(apc->display,win); + return(true); + } sendClientMessage(win,"_NET_ACTIVE_WINDOW",0,0,0,0,0); return(true); } win=getWindowByPID(launcher->pid); if(win!=None) { + if(pr.window==win) + { + XUnmapWindow(apc->display,win); + return(true); + } sendClientMessage(win,"_NET_ACTIVE_WINDOW",0,0,0,0,0); return(true); } @@ -159,7 +169,7 @@ void addALAuncher(const char *fpath,menuEntryStruct *entry) while((start_pos=str.find(from,start_pos))!=std::string::npos) str.replace(start_pos, from.length(),""); entry->exec=strdup(str.c_str()); - free(execstring); + freeAndNull(&execstring); } g_key_file_free(kf); } @@ -202,13 +212,13 @@ int launcherBuildCB(const char *fpath,const struct stat *sb,int typeflag) else { if(entry.name!=NULL) - free(entry.name); + freeAndNull(&entry.name); if(entry.exec!=NULL) - free(entry.exec); + freeAndNull(&entry.exec); if(entry.icon!=NULL) - free(entry.icon); + freeAndNull(&entry.icon); if(icon!=NULL) - free(icon); + freeAndNull(&icon); } return(0); } @@ -231,27 +241,22 @@ int addLaunchers(int x,int y,int grav) asprintf(&launchers,"%s/launchers-DOCK",apc->configDir.c_str()); ftw(launchers,launcherBuildCB,16); - popWindow=new LFSTK_toolWindowClass(apc->display,mainwind,"_NET_WM_WINDOW_TYPE_MENU",0,0,100,100,"lfstkpopup",apc); - popLabel=new LFSTK_labelClass(popWindow,"ANAME",0,0,GADGETWIDTH*8,GADGETHITE,WestGravity); - popLabel->LFSTK_setCairoFontDataParts("sB",20); - popLabel->LFSTK_setTile(NULL,0); - popWindow->LFSTK_setWindowColourName(NORMALCOLOUR,lc.c_str()); - win=new windowInitStruct; win->app=apc; - win->name=""; + win->windowName=""; win->loadVars=true; win->x=100; win->y=100; win->w=200; win->h=200; - win->wc=mainwind; - win->windowType="_NET_WM_WINDOW_TYPE_DOCK"; + win->wc=dockWindow; + win->windowType=apc->appAtomsHashed.at(apc->globalLib->prefs.LFSTK_hashFromKey("_NET_WM_WINDOW_TYPE_DOCK")); + win->app=apc; win->decorated=false; win->overRide=true; win->level=ABOVEALL; - apc->LFSTK_addWindow(win,"hello"); + apc->LFSTK_addWindow(win,""); contextWindow=apc->windows->back().window; contextWindow->LFSTK_setWindowColourName(NORMALCOLOUR,lc.c_str()); @@ -270,7 +275,7 @@ int addLaunchers(int x,int y,int grav) contextButtons[j]->LFSTK_setGadgetColours(GADGETBG,lc,pc,ac,lc); contextButtons[j]->LFSTK_setGadgetColours(GADGETFG,lc,pc,ac,lc); - free(iconpath); + freeAndNull(&iconpath); sy+=GADGETHITE; } ww=contextButtons[0]->LFSTK_getTextRealWidth(contextLabelData[1]); @@ -280,7 +285,7 @@ int addLaunchers(int x,int y,int grav) while(loopll!=NULL) { icon=NULL; - loopll->bc=new LFSTK_buttonClass(mainwind,"",xpos,ypos,iconSize,iconSize); + loopll->bc=new LFSTK_buttonClass(dockWindow,"",xpos,normalY,iconWidth,iconHeight); loopll->bc->LFSTK_setContextWindow(contextWindow); if(panelGravity==PANELSOUTH) loopll->bc->contextWindowPos=CONTEXTABOVECENTRE; @@ -302,11 +307,11 @@ int addLaunchers(int x,int y,int grav) setGadgetDetails(loopll->bc); if(icon!=NULL) - free(icon); + freeAndNull(&icon); loopll=loopll->next; - xpos+=iconSize; + xpos+=iconWidth; } - free(launchers); + freeAndNull(&launchers); return(xpos); } diff --git a/LFSDock/LFSDock/src/launchers.h b/LFSDock/LFSDock/src/launchers.h index 95ed8e5..765a953 100644 --- a/LFSDock/LFSDock/src/launchers.h +++ b/LFSDock/LFSDock/src/launchers.h @@ -24,8 +24,6 @@ #include "globals.h" #include "callbacks.h" -extern launcherList *ll; - bool launcherEnterCB(LFSTK_gadgetClass*p,void* ud); bool launcherExitCB(LFSTK_gadgetClass*p,void* ud); bool launcherCB(void *p,void* ud); diff --git a/LFSDock/LFSDock/src/main.cpp b/LFSDock/LFSDock/src/main.cpp index 8756749..3f2d2d4 100644 --- a/LFSDock/LFSDock/src/main.cpp +++ b/LFSDock/LFSDock/src/main.cpp @@ -56,9 +56,9 @@ void addGadgets(void) offset+=8; break; case 'L': - if(launcherSide==NOLAUNCHERS) + if(gotLaunchers==false) { - launcherSide=LAUNCHERINLEFT; + gotLaunchers=true; offset+=addLaunchers(offset,normalY,panelGravity); } else @@ -71,29 +71,7 @@ void addGadgets(void) offset+=addDesktopSwitcer(offset,normalY,panelGravity); break; case 'T': - { - windowInitStruct *win=new windowInitStruct; - std::string lc="#a0f0f0f0"; - std::string pc="#60a0a0a0"; - std::string ac="#60404040"; - - win->x=0; - win->y=0; - win->w=1; - win->h=1; - apc->LFSTK_addToolWindow(win); - taskWindow=apc->windows->back().window; - taskList=new LFSTK_listGadgetClass(taskWindow,"list",0,0,2000,2000); - - taskList->LFSTK_setStyle(BEVELNONE); - taskList->LFSTK_setLabelAutoColour(true); - taskList->LFSTK_setListItemsColours(GADGETBG,lc,pc,ac,lc); - taskList->LFSTK_setListItemsColours(GADGETFG,"red","red","red","red"); - taskList->LFSTK_setGadgetColourPair(NORMALCOLOUR,lc,"red"); - taskList->LFSTK_moveGadget(-1,-1); - taskList->LFSTK_setMouseCallBack(NULL,taskSelect,NULL); - useTaskBar=true; - } + useTaskBar=true; break; } } @@ -101,7 +79,7 @@ void addGadgets(void) windowWidth=offset; for(int j=0;j<20;j++) { - taskbuttons[j]=new LFSTK_buttonClass(mainwind,"",windowWidth+(j*iconSize),normalY,iconSize,iconSize); + taskbuttons[j]=new LFSTK_buttonClass(dockWindow,"",windowWidth+(j*iconWidth),normalY,iconWidth,iconHeight); setGadgetDetails(taskbuttons[j]); taskbuttons[j]->LFSTK_setAlpha(1.0); taskbuttons[j]->LFSTK_setMouseCallBack(NULL,taskListCB,NULL); @@ -164,15 +142,15 @@ void sanityCheck(void) int main(int argc,char **argv) { - char *env; - XEvent event; - int psize; - int thold; - int px,py; - timeval tv={0,0}; - int key=666; - int refreshmulti=0; - propReturn pr; + char *env; + int psize; + int key=666; + propReturn pr; + windowInitStruct *win=new windowInitStruct;; + std::string lc="#a0f0f0f0"; + std::string pc="#60a0a0a0"; + std::string ac="#60404040"; + launcherList *freell; configDir=getenv("HOME") + std::string("/.config/LFS/"); launchersDir=configDir + std::string("launchers-DOCK"); @@ -193,40 +171,62 @@ int main(int argc,char **argv) XSetErrorHandler(errHandler); kf=g_key_file_new(); + while(realMainLoop==true) + { gFind=new LFSTK_findClass; gFind->LFSTK_setDepth(1,1); gFind->LFSTK_setFileTypes(".desktop"); gFind->LFSTK_setFullPath(true); gFind->LFSTK_findFiles("/usr/share/applications",false); - while(realMainLoop==true) - { apc=new LFSTK_applicationClass(); apc->LFSTK_addWindow(NULL,NULL); - mainwind=apc->mainWindow; - mainwind->LFSTK_initDnD(true); - mainwind->LFSTK_setWindowDropCallBack(windowDrop,(void*)0xdeadbeef); + dockWindow=apc->mainWindow; + dockWindow->LFSTK_initDnD(true); + dockWindow->LFSTK_setWindowDropCallBack(windowDrop,(void*)0xdeadbeef); - WM_STATE=XInternAtom(mainwind->app->display,"WM_STATE",False); - NET_WM_WINDOW_TYPE_NORMAL=XInternAtom(mainwind->app->display,"_NET_WM_WINDOW_TYPE_NORMAL",False); - NET_WM_STATE_HIDDEN=XInternAtom(mainwind->app->display,"_NET_WM_STATE_HIDDEN",False); - NET_WM_WINDOW_TYPE_DIALOG=XInternAtom(mainwind->app->display,"_NET_WM_WINDOW_TYPE_DIALOG",False); - NET_WM_DESKTOP=XInternAtom(mainwind->app->display,"_NET_WM_DESKTOP",False); - NET_WM_WINDOW_TYPE=XInternAtom(mainwind->app->display,"_NET_WM_WINDOW_TYPE",False); - NET_WM_STATE=XInternAtom(mainwind->app->display,"_NET_WM_STATE",False); - NET_WM_NAME=XInternAtom(mainwind->app->display,"_NET_WM_NAME",False); - UTF8_STRING=XInternAtom(mainwind->app->display,"UTF8_STRING",False); - NET_CURRENT_DESKTOP=XInternAtom(mainwind->app->display,"_NET_CURRENT_DESKTOP",False); - WM_CLASS=XInternAtom(mainwind->app->display,"WM_CLASS",False); - NET_WM_PID=XInternAtom(mainwind->app->display,"_NET_WM_PID",False); - NET_NUMBER_OF_DESKTOPS=XInternAtom(mainwind->app->display,"_NET_NUMBER_OF_DESKTOPS",False); + win->x=0; + win->y=0; + win->w=1; + win->h=1; + win->app=apc; + win->windowType=apc->appAtomsHashed.at(apc->globalLib->prefs.LFSTK_hashFromKey("_NET_WM_WINDOW_TYPE_MENU")); + win->wc=dockWindow; + + apc->LFSTK_addToolWindow(win); + popActionWindow=apc->windows->back().window; + popActionList=new LFSTK_listGadgetClass(popActionWindow,"list",0,0,2000,2000); - env=mainwind->globalLib->LFSTK_oneLiner("sed -n '2p' %s/lfsappearance.rc",apc->configDir.c_str()); + popActionList->LFSTK_setStyle(BEVELNONE); + popActionList->LFSTK_setLabelAutoColour(true); + popActionList->LFSTK_setListItemsColours(GADGETBG,lc,pc,ac,lc); + popActionList->LFSTK_setListItemsColours(GADGETFG,"red","red","red","red"); + popActionList->LFSTK_setGadgetColourPair(NORMALCOLOUR,lc,"red"); + popActionList->LFSTK_setMouseCallBack(NULL,popActionWindowSelect,NULL); + //popActionList->LFSTK_setMouseMoveCallBack(popActionListEnterCB,popActionListExitCB,NULL); + +//TODO// + WM_STATE=XInternAtom(dockWindow->app->display,"WM_STATE",False); + NET_WM_WINDOW_TYPE_NORMAL=XInternAtom(dockWindow->app->display,"_NET_WM_WINDOW_TYPE_NORMAL",False); + NET_WM_STATE_HIDDEN=XInternAtom(dockWindow->app->display,"_NET_WM_STATE_HIDDEN",False); + NET_WM_WINDOW_TYPE_DIALOG=XInternAtom(dockWindow->app->display,"_NET_WM_WINDOW_TYPE_DIALOG",False); + //NET_WM_DESKTOP=XInternAtom(dockWindow->app->display,"_NET_WM_DESKTOP",False); + NET_WM_WINDOW_TYPE=XInternAtom(dockWindow->app->display,"_NET_WM_WINDOW_TYPE",False); + NET_WM_STATE=XInternAtom(dockWindow->app->display,"_NET_WM_STATE",False); + NET_WM_NAME=XInternAtom(dockWindow->app->display,"_NET_WM_NAME",False); + UTF8_STRING=XInternAtom(dockWindow->app->display,"UTF8_STRING",False); + NET_CURRENT_DESKTOP=XInternAtom(dockWindow->app->display,"_NET_CURRENT_DESKTOP",False); + WM_CLASS=XInternAtom(dockWindow->app->display,"WM_CLASS",False); + NET_WM_PID=XInternAtom(dockWindow->app->display,"_NET_WM_PID",False); + NET_NUMBER_OF_DESKTOPS=XInternAtom(dockWindow->app->display,"_NET_NUMBER_OF_DESKTOPS",False); + NET_ACTIVE_WINDOW=XInternAtom(dockWindow->app->display,"_NET_ACTIVE_WINDOW",False); + + env=dockWindow->globalLib->LFSTK_oneLiner("sed -n '2p' %s/lfsappearance.rc",apc->configDir.c_str()); key=atoi(env); freeAndNull(&env); - apc->LFSTK_setTimer(refreshRate); + apc->LFSTK_setTimer(refreshRate,true); apc->LFSTK_setTimerCallBack(timerCB,NULL); if((queueID=msgget(key,IPC_CREAT|0660))==-1) @@ -235,43 +235,46 @@ int main(int argc,char **argv) asprintf(&env,"%s",configFile.c_str()); loadPrefs(env); - if(panelGravity==1) - { - normalY=0; - activeY=extraSpace; - } - else - { - normalY=extraSpace; - activeY=0; - } + freeAndNull(&env); switch(panelSize) { case 2: - iconSize=48; + iconWidth=48; break; case 3: - iconSize=64; + iconWidth=64; break; case 4: - iconSize=96; + iconWidth=96; break; default: - iconSize=32; + iconWidth=32; } - desktopTheme=mainwind->globalLib->desktopIconTheme.c_str(); - mons=apc->LFSTK_getMonitorData(onMonitor); + iconHeight=iconWidth+(iconWidth/2); + extraSpace=iconWidth/4; - mainwind->LFSTK_setTile(NULL,0); - mainwind->LFSTK_setWindowColourName(NORMALCOLOUR,"#00000000"); + if(panelGravity==1) + { + normalY=-extraSpace; + activeY=0; + } + else + { + normalY=0; + activeY=-extraSpace; + } + + desktopTheme=dockWindow->globalLib->desktopIconTheme.c_str(); + mons=apc->LFSTK_getMonitorData(onMonitor); + dockWindow->LFSTK_setTile(NULL,0); + dockWindow->LFSTK_setWindowColourName(NORMALCOLOUR,"#00000000"); windowWidth=0; pr=apc->globalLib->LFSTK_getSingleProp(apc->display,apc->rootWindow,NET_NUMBER_OF_DESKTOPS,XA_CARDINAL); deskCount=pr.integer; addGadgets(); - if(windowWidth==0) { fprintf(stderr,"Not using empty dock ...\n"); @@ -280,37 +283,41 @@ int main(int argc,char **argv) psize=windowWidth; - mainwind->LFSTK_resizeWindow(psize,iconSize+extraSpace,true); + dockWindow->LFSTK_resizeWindow(psize,iconWidth+extraSpace,true); moveDock(0); - mainwind->LFSTK_showWindow(true); - mainwind->LFSTK_setKeepAbove(true); + dockWindow->LFSTK_showWindow(true); + dockWindow->LFSTK_setKeepAbove(true); + +updateTaskBar(true); int retval=apc->LFSTK_runApp(); - - free(env); - - launcherList *freell; while(ll!=NULL) { freell=ll; if(ll->icon!=NULL) - free(ll->icon); + freeAndNull(&ll->icon); if(ll->entry.name!=NULL) - free(ll->entry.name); + freeAndNull(&ll->entry.name); if(ll->entry.exec!=NULL) - free(ll->entry.exec); + freeAndNull(&ll->entry.exec); ll=ll->next; delete freell; } - free(iconL); - free(iconM); - free(iconH); + freeAndNull(&iconL); + freeAndNull(&iconM); + freeAndNull(&iconH); clockButton=NULL; switchButton=NULL; - launcherSide=NOLAUNCHERS; + gotLaunchers=false; + useTaskBar=false; + holdtasks.clear(); + filltasks.clear(); + tasks.clear(); + delete apc; + ll=NULL; } cairo_debug_reset_static_data(); g_key_file_free(kf); diff --git a/LFSDock/LFSDock/src/slider.cpp b/LFSDock/LFSDock/src/slider.cpp index 340bb64..a6f3094 100644 --- a/LFSDock/LFSDock/src/slider.cpp +++ b/LFSDock/LFSDock/src/slider.cpp @@ -33,6 +33,7 @@ char *iconZ=NULL; int oldVolVal=-1; char label[32]; bool sliderIsUp=false; +int iconSize=48; void setLabel(void) { @@ -165,7 +166,7 @@ bool volExitCB(LFSTK_gadgetClass*p,void* ud) if(volumeButton->LFSTK_getValue()==1) return(true); p->LFSTK_getGeom(&geom2); - p->LFSTK_moveGadget(geom2.x,normalY); + p->LFSTK_moveGadget(geom2.x,normalY+extraSpace); sliderIsUp=false; return(true); } @@ -178,22 +179,22 @@ bool volMoveCB(LFSTK_gadgetClass*p,void* ud) return(true); p->LFSTK_getGeom(&geom); - p->LFSTK_moveGadget(geom.x,activeY); + p->LFSTK_moveGadget(geom.x,activeY+extraSpace); sliderIsUp=true; return(true); } int addSlider(int x,int y,int grav) { - char *vol=mainwind->globalLib->LFSTK_oneLiner("amixer get Master|tail -n1|awk '{print $3}'"); - char *label=mainwind->globalLib->LFSTK_oneLiner("amixer get Master|tail -n1|awk '{print \"%s \" $4}'|tr -d '[]'",SLIDERLABEL);//TODO// + char *vol=dockWindow->globalLib->LFSTK_oneLiner("amixer get Master|tail -n1|awk '{print $3}'"); + char *label=dockWindow->globalLib->LFSTK_oneLiner("amixer get Master|tail -n1|awk '{print \"%s \" $4}'|tr -d '[]'",SLIDERLABEL);//TODO// windowInitStruct *win=new windowInitStruct;; int w,h; bool direction=false; getAlsaVolume(false,-1); - volumeButton=new LFSTK_toggleButtonClass(mainwind,label,x,y,iconSize,iconSize); + volumeButton=new LFSTK_toggleButtonClass(dockWindow,label,x,y+extraSpace,iconSize,iconSize); volumeButton->LFSTK_setToggleStyle(TOGGLENORMAL); volumeButton->LFSTK_setMouseCallBack(NULL,sliderCB,(void*)volumeButton->LFSTK_getLabel()); volumeButton->LFSTK_setMouseMoveCallBack(volMoveCB,volExitCB,USERDATA(0)); @@ -208,10 +209,10 @@ int addSlider(int x,int y,int grav) volumeButton->drawLabelBG=true; volumeButton->autoLabelBGColour=true; - iconH=mainwind->globalLib->LFSTK_findThemedIcon(desktopTheme,"volume-high",""); - iconM=mainwind->globalLib->LFSTK_findThemedIcon(desktopTheme,"volume-medium",""); - iconL=mainwind->globalLib->LFSTK_findThemedIcon(desktopTheme,"volume-low",""); - iconZ=mainwind->globalLib->LFSTK_findThemedIcon(desktopTheme,"volume-zero",""); + iconH=dockWindow->globalLib->LFSTK_findThemedIcon(desktopTheme,"volume-high",""); + iconM=dockWindow->globalLib->LFSTK_findThemedIcon(desktopTheme,"volume-medium",""); + iconL=dockWindow->globalLib->LFSTK_findThemedIcon(desktopTheme,"volume-low",""); + iconZ=dockWindow->globalLib->LFSTK_findThemedIcon(desktopTheme,"volume-zero",""); win->x=100; win->y=100; @@ -219,6 +220,7 @@ int addSlider(int x,int y,int grav) h=16; win->w=w; win->h=h; + win->app=apc; apc->LFSTK_addToolWindow(win); scwindow=apc->windows->back().window; @@ -230,8 +232,8 @@ int addSlider(int x,int y,int grav) vsb->reverse=direction; volumeButton->LFSTK_setImageFromPath(iconL,TOOLBAR,true); volumeButton->LFSTK_clearWindow(); - free(vol); - free(label); + freeAndNull(&vol); + freeAndNull(&label); return(iconSize); } diff --git a/LFSDock/LFSDock/src/taskBar.cpp b/LFSDock/LFSDock/src/taskBar.cpp index 32420b1..6b653d0 100644 --- a/LFSDock/LFSDock/src/taskBar.cpp +++ b/LFSDock/LFSDock/src/taskBar.cpp @@ -22,78 +22,33 @@ int oldwidth=0; std::vector holdtasks; -LFSTK_listGadgetClass *taskList=NULL; -LFSTK_windowClass *taskWindow=NULL; -bool taskSwitchIsUp=false; - -bool showhidetTaskList(LFSTK_buttonClass *bc,bool what) -{ - geometryStruct geom; - - if((bc!=NULL) && (what==true)) - { - unsigned long d=(unsigned long)bc->userData; - bc->LFSTK_getGeomWindowRelative(&geom,apc->rootWindow); - switch(panelGravity) - { - case PANELNORTH: - taskWindow->LFSTK_moveWindow(geom.x+(geom.w/2)-(taskList->LFSTK_getListMaxWidth()/2),geom.y+geom.h,true); - break; - case PANELSOUTH: - taskWindow->LFSTK_moveWindow(geom.x+(geom.w/2)-(taskList->LFSTK_getListMaxWidth()/2),geom.y-(GADGETHITE*(filltasks.at(d).tasks.size()+1)),true); - break; - } - taskWindow->LFSTK_showWindow(true); - taskWindow->LFSTK_redrawAllGadgets(); - apc->windows->at(apc->LFSTK_findWindow(taskWindow)).showing=true; - } - else - { - taskWindow->LFSTK_hideWindow(); - apc->windows->at(apc->LFSTK_findWindow(taskWindow)).showing=false; - } - return(true); -} +std::vector filltasks; +std::vector tasks; bool taskSwitcherExitCB(LFSTK_gadgetClass*p,void* ud) { - geometryStruct geom2; - //int y; - -// if(panelGravity==PANELNORTH) -// y=0; -// else -// y=extraSpace; - - p->LFSTK_getGeom(&geom2); - //p->LFSTK_moveGadget(geom2.x,y); - p->LFSTK_moveGadget(geom2.x,normalY); - taskSwitchIsUp=false; + setGadgetPosition(p,false); + inSomeWindow=false; return(true); } bool taskSwitcherEnterCB(LFSTK_gadgetClass*p,void* ud) { - geometryStruct geom; - LFSTK_buttonClass *bc=static_cast(p); std::string label; - listLabelStruct ls; unsigned long d; + listLabelStruct ls; + LFSTK_buttonClass *bc=static_cast(p); - if(taskSwitchIsUp==true) - return(true); + setGadgetPosition(p,true); + popActionList->LFSTK_freeList(); - p->LFSTK_getGeom(&geom); - p->LFSTK_moveGadget(geom.x,activeY); - taskSwitchIsUp=true; - taskList->LFSTK_freeList(); d=(unsigned long)bc->userData; label=filltasks.at(d).taskName; ls.label=strdup((char*)label.c_str()); ls.imageType=NOTHUMB; ls.data.imagePath=NULL; ls.userData=USERDATA(filltasks.at(d).winid); - taskList->LFSTK_appendToList(ls); + popActionList->LFSTK_appendToList(ls); for(int j=0;jLFSTK_appendToList(ls); + popActionList->LFSTK_appendToList(ls); } - taskList->LFSTK_moveGadget(-1,-1); - taskWindow->LFSTK_resizeWindow(taskList->LFSTK_getListMaxWidth()-2,(GADGETHITE*(filltasks.at(d).tasks.size()+1))-4); - showhidetTaskList(bc,true); + popActionList->LFSTK_updateList(); + popActionList->LFSTK_moveGadget(-1,-1); + popActionWindow->userData=USERDATA(TASKSWITCHER); + popActionWindow->LFSTK_resizeWindow(popActionList->LFSTK_getListMaxWidth()-2,(GADGETHITE*(filltasks.at(d).tasks.size()+1))-4); + showhidetActionList(p,popActionWindow,popActionList); + inSomeWindow=true; + return(true); } bool taskSelect(void *object,void* userdata) { - LFSTK_listGadgetClass *list=static_cast(object); - unsigned long d=list->LFSTK_getCurrentListItem(); - - sendClientMessage((Window)list->listDataArray->at(list->LFSTK_getCurrentListItem()).userData,"_NET_ACTIVE_WINDOW",0,0,0,0,0); - showhidetTaskList(NULL,false); + unsigned long d=popActionList->LFSTK_getCurrentListItem(); + XMapWindow(apc->display,(Window)popActionList->listDataArray->at(popActionList->LFSTK_getCurrentListItem()).userData); + sendClientMessage((Window)popActionList->listDataArray->at(popActionList->LFSTK_getCurrentListItem()).userData,"_NET_ACTIVE_WINDOW",0,0,0,0,0); + inSomeWindow=false; + showhidetActionList(NULL,popActionWindow,popActionList); return(true); } bool taskListCB(void* p,void* ud) { - LFSTK_buttonClass *bc=static_cast(p); + LFSTK_buttonClass *bc=static_cast(p); if(bc!=NULL) sendClientMessage((Window)filltasks.at((unsigned long)bc->userData).winid,"_NET_ACTIVE_WINDOW",0,0,0,0,0); return(true); } -Window doTreeWalk(Window wind) +Window doTreeWalkForTasks(Window wind) { Window root,parent; Window *children; @@ -203,7 +162,7 @@ Window doTreeWalk(Window wind) if (children[i]==None) continue; - thewin=doTreeWalk(children[i]); + thewin=doTreeWalkForTasks(children[i]); if (thewin != None) break; } @@ -215,7 +174,7 @@ Window doTreeWalk(Window wind) return thewin; } -void updateTaskBar() +void updateTaskBar(bool force) { int cnt=0; bool skipflag=false; @@ -225,11 +184,8 @@ void updateTaskBar() char *keyicon=NULL; bool unequal=false; - - if(taskWindow->inWindow==false) - showhidetTaskList(NULL,false); tasks.clear(); - doTreeWalk(apc->rootWindow); + doTreeWalkForTasks(apc->rootWindow); if(tasks.size()==holdtasks.size())//TODO// { for(int j=0;jglobalLib->LFSTK_findThemedIcon(desktopTheme,filltasks.at(j).taskClass[0].c_str(),""); + icon=dockWindow->globalLib->LFSTK_findThemedIcon(desktopTheme,filltasks.at(j).taskClass[0].c_str(),""); if(icon==NULL) - icon=mainwind->globalLib->LFSTK_findThemedIcon(desktopTheme,filltasks.at(j).taskClass[1].c_str(),""); + icon=dockWindow->globalLib->LFSTK_findThemedIcon(desktopTheme,filltasks.at(j).taskClass[1].c_str(),""); if(icon!=NULL) { if(taskbuttons[j]->imagePath!=icon) taskbuttons[j]->LFSTK_setImageFromPath(icon,LEFT,true); - free(icon); + freeAndNull(&icon); } else { @@ -311,12 +255,12 @@ void updateTaskBar() keyicon=g_key_file_get_string(kf,"Desktop Entry",G_KEY_FILE_DESKTOP_KEY_ICON,NULL); if(keyicon!=NULL) { - icon=mainwind->globalLib->LFSTK_findThemedIcon(desktopTheme,keyicon,""); + icon=dockWindow->globalLib->LFSTK_findThemedIcon(desktopTheme,keyicon,""); if(icon!=NULL) { if(taskbuttons[j]->imagePath!=icon) taskbuttons[j]->LFSTK_setImageFromPath(icon,LEFT,true); - free(icon); + freeAndNull(&icon); } g_free(keyicon); } @@ -334,12 +278,12 @@ void updateTaskBar() keyicon=g_key_file_get_string(kf,"Desktop Entry",G_KEY_FILE_DESKTOP_KEY_ICON,NULL); if(keyicon!=NULL) { - icon=mainwind->globalLib->LFSTK_findThemedIcon(desktopTheme,keyicon,""); + icon=dockWindow->globalLib->LFSTK_findThemedIcon(desktopTheme,keyicon,""); if(icon!=NULL) { if(taskbuttons[j]->imagePath!=icon) taskbuttons[j]->LFSTK_setImageFromPath(icon,LEFT,true); - free(icon); + freeAndNull(&icon); } g_free(keyicon); } @@ -351,12 +295,12 @@ void updateTaskBar() taskbuttons[j]->userData=USERDATA(j); } - if(oldwidth!=windowWidth+(iconSize*filltasks.size())) + if(oldwidth!=windowWidth+(iconWidth*filltasks.size())) { - moveDock(filltasks.size()*iconSize); - mainwind->LFSTK_resizeWindow(windowWidth+(iconSize*filltasks.size()),iconSize+extraSpace,true); - oldwidth=windowWidth+(iconSize*filltasks.size()); - mainwind->LFSTK_clearWindow(true); + moveDock(filltasks.size()*iconWidth); + dockWindow->LFSTK_resizeWindow(windowWidth+(iconWidth*filltasks.size()),iconWidth+extraSpace,true); + oldwidth=windowWidth+(iconWidth*filltasks.size()); + dockWindow->LFSTK_clearWindow(true); XSync(apc->display,false); } } diff --git a/LFSDock/LFSDock/src/taskBar.h b/LFSDock/LFSDock/src/taskBar.h index 7ee864c..5f88003 100644 --- a/LFSDock/LFSDock/src/taskBar.h +++ b/LFSDock/LFSDock/src/taskBar.h @@ -24,14 +24,15 @@ #include "globals.h" #include "callbacks.h" -extern LFSTK_listGadgetClass *taskList; -extern LFSTK_windowClass *taskWindow; +extern std::vector holdtasks; +extern std::vector filltasks; +extern std::vector tasks; bool taskSwitcherEnterCB(LFSTK_gadgetClass*p,void* ud); -bool taskSelect(void *object,void* userdata); bool taskSwitcherExitCB(LFSTK_gadgetClass*p,void* ud); - -void updateTaskBar(); +bool taskSelect(void *object,void* userdata); bool taskListCB(void* p,void* ud); +void updateTaskBar(bool force=false); + #endif diff --git a/LFSDock/README.md b/LFSDock/README.md index dae2ab3..8175195 100644 --- a/LFSDock/README.md +++ b/LFSDock/README.md @@ -1,5 +1,5 @@ This will be a simple dock.
-Far from finished yet, usable but can only launch apps.
+Far from finished yet, but usable.
Much more to come!.
Getting functionality working first, fancy graphics later.
diff --git a/LFSPanel/LFSPanel/src/slider.cpp b/LFSPanel/LFSPanel/src/slider.cpp index 9b0fb4a..7e42182 100644 --- a/LFSPanel/LFSPanel/src/slider.cpp +++ b/LFSPanel/LFSPanel/src/slider.cpp @@ -168,12 +168,16 @@ void updateSlider(void) int addSlider(int x,int y,int grav,bool fromleft) { - int xpos=x; - int ypos=y; - int width=0; - int height=0; - int thisgrav=grav; - int iconsize=16; + int xpos=x; + int ypos=y; + int width=0; + int height=0; + int thisgrav=grav; + int iconsize=16; + windowInitStruct *win; + int w,h; + char *vol; + bool direction=false; char *label=mainwind->globalLib->LFSTK_oneLiner("amixer get Master|tail -n1|awk '{print \"%s \" $4}'|tr -d '[]'",SLIDERLABEL); getAlsaVolume(false,-1); @@ -190,15 +194,13 @@ int addSlider(int x,int y,int grav,bool fromleft) iconL=mainwind->globalLib->LFSTK_findThemedIcon(desktopTheme,"volume-low",""); iconZ=mainwind->globalLib->LFSTK_findThemedIcon(desktopTheme,"volume-zero",""); - char *vol=mainwind->globalLib->LFSTK_oneLiner("amixer get Master|tail -n1|awk '{print $3}'"); - - windowInitStruct *win; - int w,h; + vol=mainwind->globalLib->LFSTK_oneLiner("amixer get Master|tail -n1|awk '{print $3}'"); win=new windowInitStruct; win->x=100; win->y=100; - bool direction=false; + win->app=apc; + win->windowType=apc->appAtomsHashed.at(apc->globalLib->prefs.LFSTK_hashFromKey("_NET_WM_WINDOW_TYPE_TOOL")); if((panelGravity==PANELWEST) || (panelGravity==PANELEAST)) { diff --git a/LFSToolKit/ChangeLog b/LFSToolKit/ChangeLog index b1c2df7..683a351 100644 --- a/LFSToolKit/ChangeLog +++ b/LFSToolKit/ChangeLog @@ -1,4 +1,6 @@ 0.6.0 +GUI fixes. +Removed some od legacy code. Added CONTEXTCENTRE to gadget context menu. Fixed segfault with LFSTK_getSingleProp. List gadget visual fixes. diff --git a/LFSToolKit/LFSToolKit/lfstk/LFSTKApplication.cpp b/LFSToolKit/LFSToolKit/lfstk/LFSTKApplication.cpp index e41ae37..d9495ab 100644 --- a/LFSToolKit/LFSToolKit/lfstk/LFSTKApplication.cpp +++ b/LFSToolKit/LFSToolKit/lfstk/LFSTKApplication.cpp @@ -25,6 +25,7 @@ */ LFSTK_applicationClass::~LFSTK_applicationClass() { + for(int j=0;jwindows->size();j++) delete this->windows->at(j).window; delete this->globalLib; @@ -33,17 +34,19 @@ LFSTK_applicationClass::~LFSTK_applicationClass() #ifdef _ENABLEDEBUG_ cairo_debug_reset_static_data(); #endif - free(this->monitors); + freeAndNull((char**)&this->monitors); } /** * Set timer -* \param seconds trigger callback every seconds. +* \param int delay trigger callback every seconds. +* \param bool usemicroseconds use micro seconds instead of seconds. */ -void LFSTK_applicationClass::LFSTK_setTimer(int seconds) +void LFSTK_applicationClass::LFSTK_setTimer(int delay,bool usemicroseconds) { - this->timer=seconds; + this->timer=delay; this->useTimer=true; + this->useMicroSeconds=usemicroseconds; } /** @@ -55,6 +58,7 @@ LFSTK_applicationClass::LFSTK_applicationClass() XVisualInfo visual_template; XVisualInfo *visual_list=NULL; int nxvisuals=0; + int cnt; this->display=XOpenDisplay(NULL); if(this->display==NULL) @@ -93,6 +97,81 @@ LFSTK_applicationClass::LFSTK_applicationClass() this->userHome=getenv("HOME"); this->configDir=this->userHome + std::string("/.config/LFS"); this->iconThemeName=this->globalLib->LFSTK_oneLiner("cat '%s'/lfsdesktop.rc|grep -i icontheme|awk '{print $2}'",this->configDir.c_str()); + +/* + NET_ACTIVE_WINDOW=XInternAtom(dockWindow->app->display,"_NET_ACTIVE_WINDOW",False); + +*/ +//set up atoms + const char *appAtomNames[]={ + "_NET_WM_WINDOW_TYPE_DESKTOP", + "_NET_WM_WINDOW_TYPE_DOCK", + "_NET_WM_WINDOW_TYPE_NORMAL", + "_NET_WM_WINDOW_TYPE_DIALOG", + "_NET_WM_WINDOW_TYPE_TOOL", + "_NET_WM_STATE_SKIP_TASKBAR", + "_NET_WM_WINDOW_TYPE_MENU", + "_NET_WM_WINDOW_TYPE_TOOLBAR", + "_NET_WM_WINDOW_TYPE_UTILITY", + "_NET_WM_WINDOW_TYPE_SPLASH", + "_NET_WM_WINDOW_TYPE", + + "_NET_WM_STATE", + "_NET_WM_STATE_STICKY", + "_NET_WM_STATE_ABOVE", + "_NET_WM_STATE_BELOW", + "_NET_WM_STATE_HIDDEN", + + "_NET_WM_ALLOWED_ACTIONS", + "_NET_WM_ACTION_CHANGE_DESKTOP", + "_NET_WM_PID", + "_NET_WM_NAME", + + "_NET_ACTIVE_WINDOW", + "_NET_CURRENT_DESKTOP", + "_NET_NUMBER_OF_DESKTOPS", + + "WM_CLASS", + "WM_STATE", + "WM_DELETE_WINDOW", + "WM_PROTOCOLS", + "_MOTIF_WM_HINTS", + "UTF8_STRING", + NULL}; + cnt=0; + while(appAtomNames[cnt]!=NULL) + { + this->appAtomsHashed[this->globalLib->prefs.LFSTK_hashFromKey(appAtomNames[cnt])]=XInternAtom(this->display,appAtomNames[cnt],false); + //fprintf(stderr,"atom=%p atom name=%s\n",this->appAtomsHashed.at(this->globalLib->prefs.LFSTK_hashFromKey(appAtomNames[cnt])),appAtomNames[cnt]); + cnt++; + } +} + +/** +* Return a default windowInitStruct filled in. +* \return inititialized structure. +*/ +windowInitStruct* LFSTK_applicationClass::LFSTK_getDefaultWInit(void) +{ + windowInitStruct *wininit=new windowInitStruct; + + wininit->x=0; + wininit->y=0; + wininit->w=1; + wininit->h=1; + wininit->windowName="LFSTK Window"; + wininit->appName="LFSTKApplication"; + wininit->className="LFSTKApplication"; + wininit->overRide=false; + wininit->loadVars=true; + wininit->shutDisplayOnExit=false; + wininit->windowType=this->appAtomsHashed.at(this->globalLib->prefs.LFSTK_hashFromKey("_NET_WM_WINDOW_TYPE_NORMAL")); + wininit->decorated=true; + wininit->level=NORMAL; + wininit->display=this->display; + wininit->wc=NULL; + wininit->app=this; + return(wininit); } /** @@ -103,28 +182,33 @@ LFSTK_applicationClass::LFSTK_applicationClass() * \note name can be NULL, if window is set to 1px size and type to _NET_WM_WINDOW_TYPE_DOCK. * \note class take ownership of wi don't delete. */ -void LFSTK_applicationClass::LFSTK_addWindow(windowInitStruct *wi,const char *name) +void LFSTK_applicationClass::LFSTK_addWindow(windowInitStruct *wi,const char *name)//TODO// { windowInitStruct *win; if(wi==NULL) - win=new windowInitStruct; + { + win=this->LFSTK_getDefaultWInit(); + //win=new windowInitStruct; + //win->windowType=this->appAtomsHashed.at(this->globalLib->prefs.LFSTK_hashFromKey("_NET_WM_WINDOW_TYPE_NORMAL")); + } else win=wi; - win->app=this; + //win->app=this; if(name==NULL) { - win->name=""; + win->windowName=""; win->x=-1; win->y=-1; win->overRide=true; - win->windowType="_NET_WM_WINDOW_TYPE_DOCK"; + //win->windowType="_NET_WM_WINDOW_TYPE_DOCK"; + win->windowType=this->appAtomsHashed.at(this->globalLib->prefs.LFSTK_hashFromKey("_NET_WM_WINDOW_TYPE_DOCK")); win->decorated=false; } else - win->name=name; - win->loadVars=true; + win->windowName=name; +// win->loadVars=true; this->windows->push_back({new LFSTK_windowClass(win,this),false,false}); if(this->windows->size()==1) this->mainWindow=this->windows->back().window; @@ -143,19 +227,33 @@ void LFSTK_applicationClass::LFSTK_addToolWindow(windowInitStruct *wi) windowInitStruct *win; if(wi==NULL) - win=new windowInitStruct; + { + win=this->LFSTK_getDefaultWInit(); +// win=new windowInitStruct; +// win->app=this; + win->windowType=this->appAtomsHashed.at(this->globalLib->prefs.LFSTK_hashFromKey("_NET_WM_WINDOW_TYPE_DOCK")); + } else - win=wi; + { + win=wi; + } - win->app=this; - win->name=""; + win->windowName="";//TODO// win->loadVars=true; - win->windowType="_NET_WM_WINDOW_TYPE_DOCK"; + //win->windowType="_NET_WM_WINDOW_TYPE_DOCK"; + //win->windowType=this->appAtomsHashed.at(this->globalLib->prefs.LFSTK_hashFromKey("_NET_WM_WINDOW_TYPE_DOCK")); win->decorated=false; win->overRide=true; win->level=ABOVEALL; - this->windows->push_back({new LFSTK_toolWindowClass(win,this),false,false}); + LFSTK_toolWindowClass *tw=new LFSTK_toolWindowClass(win,this); + + windowData wd; + + wd.window=tw; + wd.loopFlag=false; + wd.showing=false; + this->windows->push_back(wd); delete win; } @@ -184,7 +282,12 @@ int LFSTK_applicationClass::LFSTK_runApp(void) fd_set readfd; struct timeval tv={0,0}; - tv.tv_sec=this->timer; + + if(this->useMicroSeconds==false) + tv.tv_usec=this->timer*1000000; + else + tv.tv_usec=this->timer; + FD_ZERO(&readfd); FD_SET(this->displayNum,&readfd); // Main loop @@ -235,7 +338,10 @@ int LFSTK_applicationClass::LFSTK_runApp(void) retval=this->callBacks.timerCallback(this,this->mainWindow->userData); if(retval==true) { - tv.tv_sec=this->timer;; + if(this->useMicroSeconds==false) + tv.tv_usec=this->timer*1000000; + else + tv.tv_usec=this->timer; FD_SET(this->displayNum,&readfd); } else @@ -338,7 +444,7 @@ void LFSTK_applicationClass::LFSTK_loadMonitorData(void)//TODO// XineramaScreenInfo *p=NULL; if(this->monitors!=NULL) - free(this->monitors); + freeAndNull((char**)&this->monitors); cnt=ScreenCount(this->display); p=XineramaQueryScreens(this->display,&cnt); diff --git a/LFSToolKit/LFSToolKit/lfstk/LFSTKApplication.h b/LFSToolKit/LFSToolKit/lfstk/LFSTKApplication.h index ad72273..4ec181d 100644 --- a/LFSToolKit/LFSToolKit/lfstk/LFSTKApplication.h +++ b/LFSToolKit/LFSToolKit/lfstk/LFSTKApplication.h @@ -27,10 +27,10 @@ struct monitorStruct { - int x; - int y; - int w; - int h; + int x; + int y; + int w; + int h; }; struct windowData @@ -52,6 +52,7 @@ class LFSTK_applicationClass int LFSTK_runWindowLoop(int window); int LFSTK_runWindowLoop(LFSTK_windowClass *win); int LFSTK_findWindow(LFSTK_windowClass *win); + windowInitStruct *LFSTK_getDefaultWInit(void); //monitors void LFSTK_loadMonitorData(void); @@ -60,7 +61,7 @@ class LFSTK_applicationClass const monitorStruct *LFSTK_getMonitors(void); //timers - void LFSTK_setTimer(int seconds); + void LFSTK_setTimer(int delay,bool usemicroseconds=false); void LFSTK_setTimerCallBack(bool (*timer)(LFSTK_applicationClass*,void*),void* ud); //gui @@ -89,10 +90,12 @@ class LFSTK_applicationClass std::string configDir=""; std::string userHome=""; std::string iconThemeName=""; + std::map appAtomsHashed; private: int displayNum; bool useTimer=false; + bool useMicroSeconds=false; int timer=-1; callbackStruct callBacks; }; diff --git a/LFSToolKit/LFSToolKit/lfstk/LFSTKFileDialog.cpp b/LFSToolKit/LFSToolKit/lfstk/LFSTKFileDialog.cpp index 2a31ee4..9d57b9a 100644 --- a/LFSToolKit/LFSToolKit/lfstk/LFSTKFileDialog.cpp +++ b/LFSToolKit/LFSToolKit/lfstk/LFSTKFileDialog.cpp @@ -29,11 +29,11 @@ LFSTK_fileDialogClass::~LFSTK_fileDialogClass(void) { if(this->currentDir!=NULL) - free(this->currentDir); + freeAndNull(&this->currentDir); if(this->currentFile!=NULL) - free(this->currentFile); + freeAndNull(&this->currentFile); if(this->currentPath!=NULL) - free(this->currentPath); + freeAndNull(&this->currentPath); freeAndNull(&this->filter); cairo_surface_destroy(this->fileImage); @@ -53,7 +53,7 @@ void LFSTK_fileDialogClass::cleanDirPath(void) rp=realpath(this->currentDir,NULL); if(this->currentDir!=NULL) - free(this->currentDir); + freeAndNull(&this->currentDir); this->currentDir=rp; } @@ -171,7 +171,7 @@ void LFSTK_fileDialogClass::LFSTK_setWorkingDir(const char *dir) holddir=strdup(dir); if(this->currentDir!=NULL) - free(this->currentDir); + freeAndNull(&this->currentDir); this->currentDir=holddir; this->cleanDirPath(); @@ -258,9 +258,9 @@ LFSTK_fileDialogClass::LFSTK_fileDialogClass(LFSTK_windowClass* parentwc,const c windowInitStruct *win; - win=new windowInitStruct; + win=new windowInitStruct;//TODO// win->app=parentwc->app; - win->name=label; + win->windowName=label; win->loadVars=true; win->w=dwidth; win->h=hite; @@ -424,7 +424,7 @@ void LFSTK_fileDialogClass::setPreviewData(bool fromlist) this->previewSize->LFSTK_setLabel(previewlabel.c_str()); asprintf(&statdata,"Mode:%o",info.fileMode); this->previewMode->LFSTK_setLabel(statdata); - free(statdata); + freeAndNull(&statdata); if(info.isLink==true) this->previewIsLink->LFSTK_setLabel("Symlink"); @@ -434,7 +434,7 @@ void LFSTK_fileDialogClass::setPreviewData(bool fromlist) this->wc->LFSTK_clearWindow(); this->tux->LFSTK_clearWindow(); this->wc->LFSTK_clearWindow(); - free(mt); + freeAndNull(&mt); } /** @@ -443,11 +443,11 @@ void LFSTK_fileDialogClass::setPreviewData(bool fromlist) void LFSTK_fileDialogClass::LFSTK_getLastFolder(void) { if(this->currentDir!=NULL) - free(this->currentDir); + freeAndNull(&this->currentDir); this->currentDir=this->wc->app->globalLib->LFSTK_oneLiner("grep -i '%s' '%s/dialoglast.rc'|awk -F= '{print $NF}'",this->recentsName,this->wc->app->configDir.c_str()); if(strlen(this->currentDir)<2) { - free(this->currentDir); + freeAndNull(&this->currentDir); this->currentDir=strdup(this->wc->app->userHome.c_str());//TODO// } } @@ -541,13 +541,13 @@ void LFSTK_fileDialogClass::LFSTK_showFileDialog(void) { this->apply=false; this->LFSTK_setWorkingDir(buf); - free(buf); + freeAndNull(&buf); break; } if(this->dialogType==FOLDERDIALOG) { - free(buf); + freeAndNull(&buf); this->apply=true; this->mainLoop=false; this->setFileData(); @@ -556,7 +556,7 @@ void LFSTK_fileDialogClass::LFSTK_showFileDialog(void) this->apply=true; this->setFileData(); this->mainLoop=false; - free(buf); + freeAndNull(&buf); break; } @@ -602,13 +602,13 @@ void LFSTK_fileDialogClass::setFileData(void) this->currentDir=strdup(dirname(filestr)); else this->currentDir=strdup(filestr); - free(filestr); + freeAndNull(&filestr); //file filestr=strdup(this->dirEdit->LFSTK_getCStr()); if(this->currentFile!=NULL) freeAndNull(&this->currentFile); this->currentFile=strdup(basename(filestr)); - free(filestr); + freeAndNull(&filestr); //path if(this->currentPath!=NULL) freeAndNull(&this->currentPath); @@ -616,7 +616,7 @@ void LFSTK_fileDialogClass::setFileData(void) asprintf(&lastdir,"sed -i '/%s=/d' '%s/dialoglast.rc';echo '%s=%s'|cat - '%s/dialoglast.rc'|sort -uo '%s/dialoglast.rc'",this->recentsName,this->wc->app->configDir.c_str(),this->recentsName,this->currentDir,this->wc->app->configDir.c_str(),this->wc->app->configDir.c_str()); system(lastdir); - free(lastdir); + freeAndNull(&lastdir); } } diff --git a/LFSToolKit/LFSToolKit/lfstk/LFSTKFindClass.cpp b/LFSToolKit/LFSToolKit/lfstk/LFSTKFindClass.cpp index c4c568a..50eb8d2 100644 --- a/LFSToolKit/LFSToolKit/lfstk/LFSTKFindClass.cpp +++ b/LFSToolKit/LFSToolKit/lfstk/LFSTKFindClass.cpp @@ -21,6 +21,7 @@ #include #include +#include "lfstk/LFSTKGlobals.h" #include "LFSTKFindClass.h" LFSTK_findClass *fc; @@ -45,7 +46,7 @@ LFSTK_findClass::~LFSTK_findClass() { this->deleteData(); if(this->fileTypes!=NULL) - free(this->fileTypes); + freeAndNull(&this->fileTypes); } /** @@ -436,7 +437,7 @@ void LFSTK_findClass::LFSTK_findFiles(const char *dir,bool multi) closedir(dirhandle); } this->dataCnt=this->data.size(); - free(filepath); + freeAndNull(&filepath); } diff --git a/LFSToolKit/LFSToolKit/lfstk/LFSTKFontDialog.cpp b/LFSToolKit/LFSToolKit/lfstk/LFSTKFontDialog.cpp index ddd2f61..5884ef6 100644 --- a/LFSToolKit/LFSToolKit/lfstk/LFSTKFontDialog.cpp +++ b/LFSToolKit/LFSToolKit/lfstk/LFSTKFontDialog.cpp @@ -27,10 +27,10 @@ LFSTK_fontDialogClass::~LFSTK_fontDialogClass() { for(int j=0;jmaxFonts;j++) { - free(this->fontsAZ[j]); + freeAndNull(&this->fontsAZ[j]); } delete[] this->fontsAZ; - free(this->fontData.fontString); + freeAndNull(&this->fontData.fontString); delete this->dialog; } @@ -68,7 +68,7 @@ void LFSTK_fontDialogClass::buildFontString(void) this->selectedFontNumber=fontlist->LFSTK_getCurrentListItem(); if(this->fontData.fontString!=NULL) - free(this->fontData.fontString); + freeAndNull(&this->fontData.fontString); asprintf(&this->fontData.fontString,"%s:size=%s%s%s",this->fontsAZ[this->selectedFontNumber],this->fontsize->LFSTK_getCStr(),boldstr,italicstr); asprintf(&formatstring,"ns%s%s",dobold,doitalic); this->preview->LFSTK_setCairoFontDataParts(formatstring,this->fontsAZ[selectedFontNumber],atoi(this->fontsize->LFSTK_getCStr())); @@ -77,7 +77,7 @@ void LFSTK_fontDialogClass::buildFontString(void) this->fontData.fontString; this->fontData.fontName=this->fontsAZ[selectedFontNumber]; this->fontData.isValid=true; - free(formatstring); + freeAndNull(&formatstring); this->preview->LFSTK_clearWindow(); } @@ -131,7 +131,7 @@ void LFSTK_fontDialogClass::loadFontStrings(void) else { fontcnt=atoi(out); - free(out); + freeAndNull(&out); } fontsAZ=new char*[fontcnt]; @@ -149,7 +149,7 @@ void LFSTK_fontDialogClass::loadFontStrings(void) } pclose(fp); } - free(command); + freeAndNull(&command); } /* @@ -199,18 +199,18 @@ void LFSTK_fontDialogClass::parseFontString(const char *fontstr) if(font!=NULL) { this->fontlist->LFSTK_findByLabel(font); - free(font); + freeAndNull(&font); } if(fontsize!=NULL) { this->fontsize->LFSTK_setBuffer(fontsize); - free(fontsize); + freeAndNull(&fontsize); } this->boldcheck->LFSTK_setValue(bold); this->italiccheck->LFSTK_setValue(italic); } this->LFSTK_getFontData(true); - free(string); + freeAndNull(&string); } /* @@ -280,14 +280,14 @@ void LFSTK_fontDialogClass::buildDialog(void) char *sizestr[4]={0,}; listLabelStruct ls; - windowInitStruct *win; + windowInitStruct *win;//TODO// win=new windowInitStruct; win->app=this->wc->app; win->loadVars=true; win->w=DIALOGWIDTH; win->h=DIALOGHITE; win->wc=this->wc; - win->name="Font Selector"; + win->windowName="Font Selector"; this->dialog=new LFSTK_windowClass(win,this->wc->app); delete win; diff --git a/LFSToolKit/LFSToolKit/lfstk/LFSTKGadget.cpp b/LFSToolKit/LFSToolKit/lfstk/LFSTKGadget.cpp index 2d44793..155163f 100644 --- a/LFSToolKit/LFSToolKit/lfstk/LFSTKGadget.cpp +++ b/LFSToolKit/LFSToolKit/lfstk/LFSTKGadget.cpp @@ -30,7 +30,7 @@ LFSTK_gadgetClass::~LFSTK_gadgetClass() { if(this->label!=NULL) - free(this->label); + freeAndNull(&this->label); if(this->isMapped==true) this->LFSTK_reParentWindow(this->wc->window,0,0); @@ -45,12 +45,13 @@ LFSTK_gadgetClass::~LFSTK_gadgetClass() } if(this->fontString!=NULL) - free(this->fontString); + freeAndNull(&this->fontString); if(this->labelBGColour.isValid==true) XFreeColors(this->wc->app->display,this->wc->app->cm,(long unsigned int*)&this->labelBGColour.pixel,1,0); - cairo_destroy(this->cr); + if(this->cr!=NULL) + cairo_destroy(this->cr); if(this->cImage!=NULL) cairo_surface_destroy(this->cImage); @@ -64,10 +65,11 @@ LFSTK_gadgetClass::~LFSTK_gadgetClass() if(this->broken!=NULL) cairo_surface_destroy(this->broken); - cairo_surface_destroy(this->sfc); + if(this->sfc!=NULL) + cairo_surface_destroy(this->sfc); if(this->fontName!=NULL) - free(this->fontName); + freeAndNull(&this->fontName); XFreeGC(this->wc->app->display,this->gc); } @@ -97,7 +99,7 @@ Window LFSTK_gadgetClass::LFSTK_getWindow(void) void LFSTK_gadgetClass::LFSTK_setFontString(const char *s,bool setfontdata) { if(this->fontString!=NULL) - free(this->fontString); + freeAndNull(&this->fontString); this->fontString=strdup(s); if(setfontdata==true) @@ -974,7 +976,7 @@ void LFSTK_gadgetClass::LFSTK_setCairoFontData(void) this->fontSize=10; if(this->fontName!=NULL) - free(this->fontName); + freeAndNull(&this->fontName); this->fontName=strdup("Sans"); str=strtok(string,":"); @@ -1002,12 +1004,12 @@ void LFSTK_gadgetClass::LFSTK_setCairoFontData(void) if(found==false) { if(this->fontName!=NULL) - free(this->fontName); + freeAndNull(&this->fontName); this->fontName=strdup(str); } str=strtok(NULL,":"); } - free(string); + freeAndNull(&string); cairo_save(this->cr); cairo_select_font_face(this->cr,this->fontName,this->slant,this->weight); @@ -1085,7 +1087,7 @@ void LFSTK_gadgetClass::LFSTK_setCairoFontDataParts(const char* fmt,...) { case 'n': if(this->fontName!=NULL) - free(this->fontName); + freeAndNull(&this->fontName); this->fontName=strdup(va_arg(ap,char*)); break; case 'I': @@ -1125,7 +1127,7 @@ void LFSTK_gadgetClass::LFSTK_setCairoFontDataParts(const char* fmt,...) void LFSTK_gadgetClass::LFSTK_setLabel(const char *newlabel,bool clearwindow) { if(this->label!=NULL) - free(this->label); + freeAndNull(&this->label); this->label=strdup(newlabel); this->LFSTK_setCairoFontData(); if(clearwindow==true) diff --git a/LFSToolKit/LFSToolKit/lfstk/LFSTKGadget.h b/LFSToolKit/LFSToolKit/lfstk/LFSTKGadget.h index 06ef95a..015be48 100644 --- a/LFSToolKit/LFSToolKit/lfstk/LFSTKGadget.h +++ b/LFSToolKit/LFSToolKit/lfstk/LFSTKGadget.h @@ -208,7 +208,6 @@ int imageWidth=0; char *fontName=NULL; double maxTextHeight; -// bool inWindow; bool isActive; bool autoLabelColour=false; int labelGravity; @@ -223,7 +222,6 @@ int imageWidth=0; cairo_surface_t *cImage=NULL; cairo_pattern_t *pattern=NULL; -// int imageWidth=0; int imageHeight=0; int imageGravity=CENTRE; float ratio; diff --git a/LFSToolKit/LFSToolKit/lfstk/LFSTKGlobals.h b/LFSToolKit/LFSToolKit/lfstk/LFSTKGlobals.h index 85b3423..40c3280 100644 --- a/LFSToolKit/LFSToolKit/lfstk/LFSTKGlobals.h +++ b/LFSToolKit/LFSToolKit/lfstk/LFSTKGlobals.h @@ -351,17 +351,26 @@ struct gadgetStruct }; class LFSTK_applicationClass; + +/** +* Set various options for windows. +* +* \note If this structure is supplied you MUST set windowType and app. +*/ struct windowInitStruct { int x=0; int y=0; int w=1; int h=1; - const char *name=""; + //const char *name=""; + std::string appName; + std::string className; + std::string windowName; bool overRide=false; bool loadVars=true; bool shutDisplayOnExit=false; - const char *windowType="_NET_WM_WINDOW_TYPE_NORMAL"; + Atom windowType; bool decorated=true; int level=NORMAL; Display *display=NULL; diff --git a/LFSToolKit/LFSToolKit/lfstk/LFSTKLib.cpp b/LFSToolKit/LFSToolKit/lfstk/LFSTKLib.cpp index c272a0c..407cefe 100644 --- a/LFSToolKit/LFSToolKit/lfstk/LFSTKLib.cpp +++ b/LFSToolKit/LFSToolKit/lfstk/LFSTKLib.cpp @@ -289,7 +289,7 @@ void LFSTK_lib::LFSTK_reloadPrefs(void) asprintf(&env,"%s/.config/LFS/lfstoolkit.rc",getenv("HOME")); this->prefs.LFSTK_loadVarsFromFile(env); - free(env); + freeAndNull(&env); this->LFSTK_loadDesktopIconTheme(); } @@ -597,7 +597,7 @@ char* LFSTK_lib::LFSTK_findThemedIcon(const char *theme,const char *icon,const c if((iconpath!=NULL) && (strlen(iconpath)>1)) goto breakReturn; if(iconpath!=NULL) - free(iconpath); + freeAndNull(&iconpath); iconpath=NULL; } } @@ -610,13 +610,13 @@ char* LFSTK_lib::LFSTK_findThemedIcon(const char *theme,const char *icon,const c if((iconpath!=NULL) && (strlen(iconpath)>1)) goto breakReturn; if(iconpath!=NULL) - free(iconpath); + freeAndNull(&iconpath); iconpath=NULL; } } breakReturn: - free(holdicon); + freeAndNull(&holdicon); return(iconpath); } @@ -677,7 +677,7 @@ std::string LFSTK_lib::LFSTK_oneLiner(const std::string fmt,...) pclose(fp); str=buffer; } - free(buffer); + freeAndNull(&buffer); return(str); } @@ -739,10 +739,10 @@ char* LFSTK_lib::LFSTK_oneLiner(const char* fmt,...) buffer[strlen(buffer)-1]=0; } pclose(fp); - free(subbuffer); + freeAndNull(&subbuffer); return(strdup(buffer)); } - free(subbuffer); + freeAndNull(&subbuffer); return(NULL); } @@ -1045,13 +1045,13 @@ char* LFSTK_lib::LFSTK_cleanString(const char *str) if(uristr!=NULL) { cleanstr=g_filename_from_uri((const char*)g_strstrip(localstr),NULL,NULL); - free(uristr); + freeAndNull(&uristr); } else { cleanstr=strdup((const char*)g_strstrip(localstr)); } - free(localstr); + freeAndNull(&localstr); return(cleanstr); } @@ -1141,7 +1141,7 @@ void LFSTK_lib::LFSTK_getFileInfo(const char* path,fileInformation* info) info->themeName=this->desktopIconTheme; icon=this->LFSTK_findThemedIcon(info->themeName.c_str(),"application-octet-stream",""); info->iconPath=icon; - free(icon); + freeAndNull(&icon); return; } @@ -1175,7 +1175,7 @@ void LFSTK_lib::LFSTK_getFileInfo(const char* path,fileInformation* info) if(icon!=NULL) { info->iconPath=icon; - free(icon); + freeAndNull(&icon); } else { @@ -1185,7 +1185,7 @@ void LFSTK_lib::LFSTK_getFileInfo(const char* path,fileInformation* info) if(icon!=NULL) { info->iconPath=icon; - free(icon); + freeAndNull(&icon); } } @@ -1202,9 +1202,9 @@ void LFSTK_lib::LFSTK_getFileInfo(const char* path,fileInformation* info) if(iconpath!=NULL) { info->iconPath=iconpath; - free(iconpath); + freeAndNull(&iconpath); } - free(iiconpath); + freeAndNull(&iiconpath); } g_key_file_free(kf); } diff --git a/LFSToolKit/LFSToolKit/lfstk/LFSTKLineEdit.cpp b/LFSToolKit/LFSToolKit/lfstk/LFSTKLineEdit.cpp index 22ba063..f1070e8 100644 --- a/LFSToolKit/LFSToolKit/lfstk/LFSTKLineEdit.cpp +++ b/LFSToolKit/LFSToolKit/lfstk/LFSTKLineEdit.cpp @@ -123,16 +123,17 @@ LFSTK_lineEditClass::LFSTK_lineEditClass(LFSTK_windowClass* parentwc,const char* int sy=0; LFSTK_buttonClass *btn; - win=new windowInitStruct; + win=new windowInitStruct;//TODO// win->app=this->wc->app; - win->name=""; + win->windowName=""; win->loadVars=true; win->x=100; win->y=100; win->w=200; win->h=200; win->wc=this->wc; - win->windowType="_NET_WM_WINDOW_TYPE_MENU"; + //win->windowType="_NET_WM_WINDOW_TYPE_MENU"; + win->windowType=this->wc->app->appAtomsHashed.at(this->wc->app->globalLib->prefs.LFSTK_hashFromKey("_NET_WM_WINDOW_TYPE_MENU")); win->decorated=false; win->overRide=true; win->level=ABOVEALL; @@ -358,8 +359,8 @@ void LFSTK_lineEditClass::drawLabel(void) cairo_set_source_rgba(this->cr,this->newGadgetFGColours.at(NORMALCOLOUR).RGBAColour.r,this->newGadgetFGColours.at(NORMALCOLOUR).RGBAColour.g,this->newGadgetFGColours.at(NORMALCOLOUR).RGBAColour.b,this->newGadgetFGColours.at(NORMALCOLOUR).RGBAColour.a); cairo_show_text(this->cr,aftercursor); - free(data); - free(aftercursor); + freeAndNull(&data); + freeAndNull(&aftercursor); cairo_restore(this->cr); } @@ -564,7 +565,7 @@ void LFSTK_lineEditClass::LFSTK_dropData(propertyStruct* data) char *ret; ret=this->wc->app->globalLib->LFSTK_cleanString((const char*)data->data); this->LFSTK_setFormatedText((const char*)ret,true); - free(ret); + freeAndNull(&ret); } if(this->callBacks.validCallbacks & GADGETDROPCB) diff --git a/LFSToolKit/LFSToolKit/lfstk/LFSTKListGadget.cpp b/LFSToolKit/LFSToolKit/lfstk/LFSTKListGadget.cpp index 53e93c6..39317c8 100644 --- a/LFSToolKit/LFSToolKit/lfstk/LFSTKListGadget.cpp +++ b/LFSToolKit/LFSToolKit/lfstk/LFSTKListGadget.cpp @@ -118,7 +118,7 @@ void LFSTK_listGadgetClass::LFSTK_setListFromFile(const char *filepath,bool incl { lines=this->wc->app->globalLib->LFSTK_oneLiner("wc -l %s",filepath); linecnt=atoi(lines); - free(lines); + freeAndNull(&lines); file=fopen(filepath,"r"); if(file!=NULL) { @@ -147,7 +147,7 @@ void LFSTK_listGadgetClass::LFSTK_setListFromFile(const char *filepath,bool incl } } } - free(buffer); + freeAndNull(&buffer); userdata++; } fclose(file); @@ -182,6 +182,7 @@ void LFSTK_listGadgetClass::LFSTK_updateList(void) if(jmaxShowing) { this->labelsArray->at(j)->LFSTK_setLabel(this->listDataArray->at(j+this->listOffset).label); + this->labelsArray->at(j)->LFSTK_setStyle(BEVELNONE); this->labelsArray->at(j)->userData=USERDATA(j+this->listOffset); this->labelsArray->at(j)->LFSTK_setActive(true); if(this->listDataArray->at(j+this->listOffset).imageType==NOTHUMB) @@ -352,11 +353,11 @@ void LFSTK_listGadgetClass::freeList(void) { for(int j=0;jlistDataArray->size();j++) { - free(this->listDataArray->at(j).label); + freeAndNull(&this->listDataArray->at(j).label); if((this->listDataArray->at(j).imageType==CAIROTHUMB) && (this->listDataArray->at(j).data.surface!=NULL) && (this->freeCairoImages==true)) cairo_surface_destroy(this->listDataArray->at(j).data.surface); if((this->listDataArray->at(j).imageType==FILETHUMB) && (this->listDataArray->at(j).data.imagePath!=NULL)) - free(this->listDataArray->at(j).data.imagePath); + freeAndNull(&this->listDataArray->at(j).data.imagePath); } this->listDataArray->clear(); } diff --git a/LFSToolKit/LFSToolKit/lfstk/LFSTKListGadget.h b/LFSToolKit/LFSToolKit/lfstk/LFSTKListGadget.h index 34bdbe6..5e315a1 100644 --- a/LFSToolKit/LFSToolKit/lfstk/LFSTKListGadget.h +++ b/LFSToolKit/LFSToolKit/lfstk/LFSTKListGadget.h @@ -34,13 +34,13 @@ enum {NOTHUMB=0,CAIROTHUMB,FILETHUMB}; struct listLabelStruct { - char *label; + char *label; int imageType; - void *userData; + void *userData; int listPos; union imageData { - char *imagePath=NULL; + char *imagePath=NULL; cairo_surface_t *surface; } data; }; diff --git a/LFSToolKit/LFSToolKit/lfstk/LFSTKMenu.cpp b/LFSToolKit/LFSToolKit/lfstk/LFSTKMenu.cpp index ad766b3..6608fc9 100644 --- a/LFSToolKit/LFSToolKit/lfstk/LFSTKMenu.cpp +++ b/LFSToolKit/LFSToolKit/lfstk/LFSTKMenu.cpp @@ -27,7 +27,7 @@ LFSTK_menuClass::~LFSTK_menuClass() delete this->subwindows; LFSTK_freeMenus(this->mainMenu,this->mainMenuCnt); - free(this->fontName); + freeAndNull(&this->fontName); } LFSTK_menuClass::LFSTK_menuClass(LFSTK_windowClass *wc,int x,int y,unsigned w,unsigned h) @@ -373,9 +373,11 @@ void LFSTK_menuClass::LFSTK_addMainMenus(menuStruct **menus,int menucnt) windowInitStruct *win; - win=new windowInitStruct; + win=new windowInitStruct;//TODO// win->app=this->parentwc->app; - win->name="lfstkmenu"; + win->windowName="LFSTKMenu"; + win->className="LFSTKMenu"; + win->appName="LFSTKApplication"; win->loadVars=true; win->x=this->x; win->y=this->y; @@ -390,7 +392,9 @@ void LFSTK_menuClass::LFSTK_addMainMenus(menuStruct **menus,int menucnt) else this->isScrollable=false; win->wc=this->parentwc; - win->windowType="_NET_WM_WINDOW_TYPE_MENU"; + //win->windowType="_NET_WM_WINDOW_TYPE_MENU"; + win->windowType=this->parentwc->app->appAtomsHashed.at(this->parentwc->app->globalLib->prefs.LFSTK_hashFromKey("_NET_WM_WINDOW_TYPE_MENU")); + win->decorated=false; win->overRide=true; win->level=ABOVEALL; @@ -435,9 +439,9 @@ void LFSTK_menuClass::LFSTK_freeMenus(menuStruct **menus,int menucnt) if(menus[j]->imageType==CAIROTHUMB) cairo_surface_destroy(menus[j]->data.surface); if(menus[j]->imageType==FILETHUMB) - free(menus[j]->data.imagePath); + freeAndNull(&menus[j]->data.imagePath); if(menus[j]->label!=NULL) - free(menus[j]->label); + freeAndNull(&menus[j]->label); if(menus[j]->hasSubMenu==true) { this->LFSTK_freeMenus(menus[j]->subMenus,menus[j]->subMenuCnt); @@ -468,7 +472,7 @@ int LFSTK_menuClass::LFSTK_getTextWidthForFont(const char *text) fontSize=10; if(this->fontName!=NULL) - free(this->fontName); + freeAndNull(&this->fontName); this->fontName=strdup("sans"); str=strtok(string,":"); @@ -497,12 +501,12 @@ int LFSTK_menuClass::LFSTK_getTextWidthForFont(const char *text) if(found==false) { if(this->fontName!=NULL) - free(this->fontName); + freeAndNull(&this->fontName); this->fontName=strdup(str); } str=strtok(NULL,":"); } - free(string); + freeAndNull(&string); this->parentwc->globalLib->LFSTK_setCairoSurface(this->parentwc->app->display,this->parentwc->window,this->parentwc->app->visual,&sfc,&cr,1,1); cairo_select_font_face(cr,this->fontName,this->slant,this->weight); diff --git a/LFSToolKit/LFSToolKit/lfstk/LFSTKMenuItem.cpp b/LFSToolKit/LFSToolKit/lfstk/LFSTKMenuItem.cpp index 14048a1..8958e40 100644 --- a/LFSToolKit/LFSToolKit/lfstk/LFSTKMenuItem.cpp +++ b/LFSToolKit/LFSToolKit/lfstk/LFSTKMenuItem.cpp @@ -215,7 +215,10 @@ bool LFSTK_menuItemClass::mouseEnter(XButtonEvent *e) else maxtxtwid+=gotsubmenu; this->w=maxtxtwid; - this->subwc=new LFSTK_toolWindowClass(this->wc->app->display,this->wc,"_NET_WM_WINDOW_TYPE_MENU",this->gadgetGeom.x,this->gadgetGeom.y,maxtxtwid,GADGETHITE*this->menuData->subMenuCnt-winshrink,"menu window",this->wc->app); + // win->windowType=this->wc->app->appAtomsHashed.at(this->globalLib->prefs.LFSTK_hashFromKey("_NET_WM_WINDOW_TYPE_MENU")); + + //this->subwc=new LFSTK_toolWindowClass(this->wc->app->display,this->wc,"_NET_WM_WINDOW_TYPE_MENU",this->gadgetGeom.x,this->gadgetGeom.y,maxtxtwid,GADGETHITE*this->menuData->subMenuCnt-winshrink,"menu window",this->wc->app); + this->subwc=new LFSTK_toolWindowClass(this->wc->app->display,this->wc,this->wc->app->appAtomsHashed.at(this->wc->app->globalLib->prefs.LFSTK_hashFromKey("_NET_WM_WINDOW_TYPE_MENU")),this->gadgetGeom.x,this->gadgetGeom.y,maxtxtwid,GADGETHITE*this->menuData->subMenuCnt-winshrink,"menu window",this->wc->app); for(int j=0; jmenuData->subMenuCnt; j++) { diff --git a/LFSToolKit/LFSToolKit/lfstk/LFSTKMultiLineEdit.cpp b/LFSToolKit/LFSToolKit/lfstk/LFSTKMultiLineEdit.cpp index c2d4b9a..2f3f0b6 100644 --- a/LFSToolKit/LFSToolKit/lfstk/LFSTKMultiLineEdit.cpp +++ b/LFSToolKit/LFSToolKit/lfstk/LFSTKMultiLineEdit.cpp @@ -36,7 +36,7 @@ LFSTK_multiLineEditClass::~LFSTK_multiLineEditClass() { for (int i=0; iline); + freeAndNull(&lines.at(i)->line); delete lines.at(i); } this->lines.clear(); @@ -312,7 +312,7 @@ void LFSTK_multiLineEditClass::drawText(void) if(lines.at(j)->cursorPosline)) cairo_show_text(this->cr,aftercursor); - free(data); + freeAndNull(&data); } else { @@ -528,7 +528,7 @@ void LFSTK_multiLineEditClass::LFSTK_dropData(propertyStruct* data) char *ret; ret=this->wc->app->globalLib->LFSTK_cleanString((const char*)data->data); this->LFSTK_setFormatedText((const char*)ret,true); - free(ret); + freeAndNull(&ret); } if(this->callBacks.validCallbacks & GADGETDROPCB) @@ -552,7 +552,7 @@ void LFSTK_multiLineEditClass::setDisplayLines(void) for (int i=0; iline); + freeAndNull(&lines.at(i)->line); delete lines.at(i); } this->lines.clear(); diff --git a/LFSToolKit/LFSToolKit/lfstk/LFSTKScrollBar.cpp b/LFSToolKit/LFSToolKit/lfstk/LFSTKScrollBar.cpp index 35ca55e..27ea027 100644 --- a/LFSToolKit/LFSToolKit/lfstk/LFSTKScrollBar.cpp +++ b/LFSToolKit/LFSToolKit/lfstk/LFSTKScrollBar.cpp @@ -115,7 +115,7 @@ LFSTK_scrollBarClass::LFSTK_scrollBarClass(LFSTK_windowClass* parentwc,bool vert else this->upLeft->LFSTK_setImageFromPath(LFSTKPIXMAPSDIR "/left.png",CENTRE,true); - free(pathtobit); + freeAndNull(&pathtobit); //rite this->downRight=new LFSTK_buttonClass(parentwc,"",0,0,h,h,gravity); this->downRight->LFSTK_reParentWindow(this->window,w-h,0); @@ -124,7 +124,7 @@ LFSTK_scrollBarClass::LFSTK_scrollBarClass(LFSTK_windowClass* parentwc,bool vert this->downRight->LFSTK_setImageFromPath(pathtobit,CENTRE,true); else this->downRight->LFSTK_setImageFromPath(LFSTKPIXMAPSDIR "/rite.png",CENTRE,true); - free(pathtobit); + freeAndNull(&pathtobit); } else { @@ -141,7 +141,7 @@ LFSTK_scrollBarClass::LFSTK_scrollBarClass(LFSTK_windowClass* parentwc,bool vert this->upLeft->LFSTK_setImageFromPath(pathtobit,CENTRE,true); else this->upLeft->LFSTK_setImageFromPath(LFSTKPIXMAPSDIR "/up.png",CENTRE,true); - free(pathtobit); + freeAndNull(&pathtobit); //down this->downRight=new LFSTK_buttonClass(parentwc,"",x,y+h-w,w,w,gravity); this->downRight->LFSTK_reParentWindow(this->window,0,h-w); @@ -150,7 +150,7 @@ LFSTK_scrollBarClass::LFSTK_scrollBarClass(LFSTK_windowClass* parentwc,bool vert this->downRight->LFSTK_setImageFromPath(pathtobit,CENTRE,true); else this->downRight->LFSTK_setImageFromPath(LFSTKPIXMAPSDIR "/down.png",CENTRE,true); - free(pathtobit); + freeAndNull(&pathtobit); } asprintf(&pathtobit,"%s/thumb.png",this->wc->globalLib->LFSTK_getThemePath()); @@ -158,7 +158,7 @@ LFSTK_scrollBarClass::LFSTK_scrollBarClass(LFSTK_windowClass* parentwc,bool vert this->thumb->LFSTK_setImageFromPath(pathtobit,CENTRE,true); else this->thumb->LFSTK_setImageFromPath(LFSTKPIXMAPSDIR "/thumb.png",CENTRE,true); - free(pathtobit); + freeAndNull(&pathtobit); this->thumb->LFSTK_setCanDrag(true); this->thumb->LFSTK_setMouseCallBack(this->startThumbDrag,this->thumbClicked,(void*)this); diff --git a/LFSToolKit/LFSToolKit/lfstk/LFSTKToggleButton.cpp b/LFSToolKit/LFSToolKit/lfstk/LFSTKToggleButton.cpp index e3631c0..1ce7fd8 100644 --- a/LFSToolKit/LFSToolKit/lfstk/LFSTKToggleButton.cpp +++ b/LFSToolKit/LFSToolKit/lfstk/LFSTKToggleButton.cpp @@ -81,12 +81,12 @@ LFSTK_toggleButtonClass::LFSTK_toggleButtonClass(LFSTK_windowClass* parentwc,con if(access(pathtobit,F_OK)==0) { this->checkOn=this->wc->globalLib->LFSTK_createSurfaceFromPath(pathtobit); - free(pathtobit); + freeAndNull(&pathtobit); asprintf(&pathtobit,"%s/checkoff.png",this->wc->globalLib->LFSTK_getThemePath()); if(access(pathtobit,F_OK)==0) this->checkOff=this->wc->globalLib->LFSTK_createSurfaceFromPath(pathtobit); } - free(pathtobit); + freeAndNull(&pathtobit); gadgetDetails={&this->wc->windowColourNames[NORMALCOLOUR],BEVELOUT,CHECK,NORMALCOLOUR,CHECKBOXSIZE,false,{0,0,w,h},{2,(int)((h/2)-(CHECKBOXSIZE/2)),CHECKBOXSIZE,CHECKBOXSIZE},true,false,true}; } diff --git a/LFSToolKit/LFSToolKit/lfstk/LFSTKToolWindow.cpp b/LFSToolKit/LFSToolKit/lfstk/LFSTKToolWindow.cpp index e7b3f39..0dd264c 100644 --- a/LFSToolKit/LFSToolKit/lfstk/LFSTKToolWindow.cpp +++ b/LFSToolKit/LFSToolKit/lfstk/LFSTKToolWindow.cpp @@ -49,11 +49,10 @@ void LFSTK_toolWindowClass::windowClassInitCommon(windowInitStruct *wi) wa.override_redirect=wi->overRide; wm_delete_window=XInternAtom(this->app->display,"WM_DELETE_WINDOW",0); - XMatchVisualInfo(this->app->display, DefaultScreen(this->app->display), 32, TrueColor, &vinfo); + XMatchVisualInfo(this->app->display, DefaultScreen(this->app->display),32,TrueColor,&vinfo); this->visual=vinfo.visual; - this->cmap=XCreateColormap(this->app->display, DefaultRootWindow(this->app->display), this->visual, AllocNone); - + this->cmap=XCreateColormap(this->app->display,DefaultRootWindow(this->app->display),this->visual,AllocNone); if(wi->app->gotARGB==true) { @@ -80,10 +79,14 @@ void LFSTK_toolWindowClass::windowClassInitCommon(windowInitStruct *wi) XChangeProperty(this->app->display,this->window,xa,XA_ATOM,32,PropModeAppend,(unsigned char *)&xa_prop,4); this->LFSTK_setWindowType(wi->windowType); - this->windowName=strdup(wi->name); - XStoreName(this->app->display,this->window,this->windowName); - classHint.res_name=this->windowName; - classHint.res_class=(char*)"LFSToolKit"; +// if(wi->name!=NULL) +// this->windowName=strdup(wi->name); + this->windowName=wi->windowName; +// else +// this->windowName=strdup("LFSToolWindow"); + XStoreName(this->app->display,this->window,this->windowName.c_str()); + classHint.res_name=(char*)wi->appName.c_str(); + classHint.res_class=(char*)wi->className.c_str(); XSetClassHint(this->app->display,this->window,&classHint); unsigned long pid=getpid(); this->LFSTK_setXProperty(XInternAtom(this->app->display,"_NET_WM_PID",False),XA_CARDINAL,32,(void *)&pid,1); @@ -93,7 +96,6 @@ void LFSTK_toolWindowClass::windowClassInitCommon(windowInitStruct *wi) this->LFSTK_setDecorated(wi->decorated); this->initWindow(wi->loadVars); - if(this->globalLib->LFSTK_getUseTheme()==true) this->LFSTK_setTile(this->globalLib->LFSTK_getGlobalString(-1,TYPEWINDOWTILE),-1); else @@ -119,14 +121,16 @@ LFSTK_toolWindowClass::LFSTK_toolWindowClass(windowInitStruct *wi,LFSTK_applicat this->gadgetMap.clear(); } -LFSTK_toolWindowClass::LFSTK_toolWindowClass(Display *disp,LFSTK_windowClass *wc,const char *windowtype,int x,int y,int w,int h,const char* name,LFSTK_applicationClass *app) +//LFSTK_toolWindowClass::LFSTK_toolWindowClass(Display *disp,LFSTK_windowClass *wc,const char *windowtype,int x,int y,int w,int h,const char* name,LFSTK_applicationClass *app) +LFSTK_toolWindowClass::LFSTK_toolWindowClass(Display *disp,LFSTK_windowClass *wc,Atom windowtype,int x,int y,int w,int h,const char* name,LFSTK_applicationClass *app) { - windowInitStruct *wi=new windowInitStruct; + windowInitStruct *wi=app->LFSTK_getDefaultWInit();//TODO// + //new windowInitStruct;//TODO// wi->x=x; wi->y=y; wi->w=w; wi->h=h; - wi->name=name; + wi->windowName=name; wi->overRide=true; wi->loadVars=true; wi->shutDisplayOnExit=false; @@ -135,7 +139,7 @@ LFSTK_toolWindowClass::LFSTK_toolWindowClass(Display *disp,LFSTK_windowClass *wc wi->level=ABOVEALL; wi->display=disp; wi->wc=wc; - wi->app=app; + //wi->app=app; this->windowClassInitCommon(wi); this->gadgetMap.clear(); diff --git a/LFSToolKit/LFSToolKit/lfstk/LFSTKToolWindow.h b/LFSToolKit/LFSToolKit/lfstk/LFSTKToolWindow.h index e9dc4e3..dcbb6cd 100644 --- a/LFSToolKit/LFSToolKit/lfstk/LFSTKToolWindow.h +++ b/LFSToolKit/LFSToolKit/lfstk/LFSTKToolWindow.h @@ -31,11 +31,9 @@ class LFSTK_toolWindowClass : public LFSTK_windowClass ~LFSTK_toolWindowClass(); LFSTK_toolWindowClass(); - LFSTK_toolWindowClass(Display *disp,LFSTK_windowClass *wc,const char *windowtype,int x,int y,int w,int h,const char* name,LFSTK_applicationClass *app); + LFSTK_toolWindowClass(Display *disp,LFSTK_windowClass *wc,Atom windowtype,int x,int y,int w,int h,const char* name,LFSTK_applicationClass *app); LFSTK_toolWindowClass(windowInitStruct *wi,LFSTK_applicationClass *app); -//int globaly=0; - protected: private: void windowClassInitCommon(windowInitStruct *wi); diff --git a/LFSToolKit/LFSToolKit/lfstk/LFSTKWindow.cpp b/LFSToolKit/LFSToolKit/lfstk/LFSTKWindow.cpp index aceb68d..80ea065 100644 --- a/LFSToolKit/LFSToolKit/lfstk/LFSTKWindow.cpp +++ b/LFSToolKit/LFSToolKit/lfstk/LFSTKWindow.cpp @@ -109,10 +109,11 @@ int LFSTK_windowClass::LFSTK_gadgetCount(void) */ void LFSTK_windowClass::LFSTK_setWindowTitle(const char *title) { - if(this->windowName!=NULL) - free(this->windowName); - this->windowName=strdup(title); - XStoreName(this->app->display,this->window,this->windowName); + //if(this->windowName!=NULL) + // freeAndNull(&this->windowName); + //this->windowName=strdup(title); + this->windowName=title; + XStoreName(this->app->display,this->window,(char*)this->windowName.c_str()); } /** @@ -156,7 +157,7 @@ void LFSTK_windowClass::LFSTK_reloadGlobals(void) this->loadGlobalColours(); this->isActive=true; this->LFSTK_clearWindow(); - free(env); + freeAndNull(&env); } /** @@ -170,11 +171,13 @@ LFSTK_windowClass::~LFSTK_windowClass() if(this->pattern!=NULL) cairo_pattern_destroy(this->pattern); - cairo_destroy(this->cr); - cairo_surface_destroy(this->sfc); + if(this->cr!=NULL) + cairo_destroy(this->cr); + if(this->sfc!=NULL) + cairo_surface_destroy(this->sfc); if(this->fontString!=NULL) - free(this->fontString); + freeAndNull(&this->fontString); //TODO// for(int j=0; jwindowColourNames[j].isValid==true) XFreeColors(this->app->display,this->app->cm,(long unsigned int*)&this->windowColourNames[j].pixel,1,0); if(this->fontColourNames[j]!=NULL) - free(this->fontColourNames[j]); + freeAndNull(&this->fontColourNames[j]); } - if(this->windowName!=NULL) - free(this->windowName); + //if(this->windowName!=NULL) + // freeAndNull(&this->windowName); if(this->app==NULL) delete this->globalLib; @@ -415,7 +418,7 @@ void LFSTK_windowClass::LFSTK_moveWindow(int x,int y,bool tellx) void LFSTK_windowClass::LFSTK_setFontString(const char *s) { if(this->fontString!=NULL) - free(this->fontString); + freeAndNull(&this->fontString); this->fontString=strdup(s); } @@ -499,7 +502,7 @@ void LFSTK_windowClass::LFSTK_setDecorations(bool canmax,bool canmin,bool canres void LFSTK_windowClass::LFSTK_setFontColourName(int p,const char *colour) { if(this->fontColourNames[p]!=NULL) - free(this->fontColourNames[p]); + freeAndNull(&this->fontColourNames[p]); this->fontColourNames[p]=strdup(colour); } @@ -578,13 +581,17 @@ void LFSTK_windowClass::LFSTK_setSticky(bool set) * Set window type. * \param type Window type string. */ -void LFSTK_windowClass::LFSTK_setWindowType(const char *type) +//void LFSTK_windowClass::LFSTK_setWindowType(const char *type) +void LFSTK_windowClass::LFSTK_setWindowType(Atom type) { Atom xa; Atom xa_prop[1]; + //win->windowType=this->wc->app->appAtomsHashed.at(this->wc->app->globalLib->prefs.LFSTK_hashFromKey("_NET_WM_WINDOW_TYPE_MENU")); - xa=XInternAtom(this->app->display,"_NET_WM_WINDOW_TYPE",False); - xa_prop[0]=XInternAtom(this->app->display,type,False); + //xa=XInternAtom(this->app->display,"_NET_WM_WINDOW_TYPE",False); + xa=this->app->appAtomsHashed.at(this->app->globalLib->prefs.LFSTK_hashFromKey("_NET_WM_WINDOW_TYPE")); + //xa_prop[0]=XInternAtom(this->app->display,type,False); + xa_prop[0]=type; if(xa!=None) XChangeProperty(this->app->display,this->window,xa,XA_ATOM,32,PropModeReplace,(unsigned char *)&xa_prop,1); @@ -751,13 +758,15 @@ void LFSTK_windowClass::windowClassInitCommon(windowInitStruct *wi) XChangeProperty(this->app->display,this->window,xa,XA_ATOM,32,PropModeAppend,(unsigned char *)&xa_prop,4); this->LFSTK_setWindowType(wi->windowType); - this->windowName=strdup(wi->name); - XStoreName(this->app->display,this->window,this->windowName); - classHint.res_name=this->windowName; - classHint.res_class=(char*)"LFSToolKit"; + //this->windowName=strdup(wi->name); + this->windowName=wi->windowName; + XStoreName(this->app->display,this->window,(char*)this->windowName.c_str());//TODO// + classHint.res_name=(char*)wi->appName.c_str(); + classHint.res_class=(char*)wi->className.c_str(); XSetClassHint(this->app->display,this->window,&classHint); unsigned long pid=getpid(); - this->LFSTK_setXProperty(XInternAtom(this->app->display,"_NET_WM_PID",False),XA_CARDINAL,32,(void *)&pid,1); + //this->LFSTK_setXProperty(XInternAtom(this->app->display,"_NET_WM_PID",False),XA_CARDINAL,32,(void *)&pid,1); + this->LFSTK_setXProperty(this->app->appAtomsHashed.at(this->app->globalLib->prefs.LFSTK_hashFromKey("_NET_WM_PID")),XA_CARDINAL,32,(void *)&pid,1); this->gc=XCreateGC(this->app->display,this->window,0,NULL); this->LFSTK_setFontString((char*)DEFAULTFONT); @@ -842,10 +851,11 @@ LFSTK_windowClass::LFSTK_windowClass(windowInitStruct *wi,LFSTK_applicationClass XChangeProperty(this->app->display,this->window,xa,XA_ATOM,32,PropModeAppend,(unsigned char *)&xa_prop,4); this->LFSTK_setWindowType(wi->windowType); - this->windowName=strdup(wi->name); - XStoreName(this->app->display,this->window,this->windowName); - classHint.res_name=this->windowName; - classHint.res_class=(char*)"LFSToolKit"; + //this->windowName=strdup(wi->name); + this->windowName=wi->windowName; + XStoreName(this->app->display,this->window,(char*)this->windowName.c_str());//TODO// + classHint.res_name=(char*)wi->appName.c_str(); + classHint.res_class=(char*)wi->className.c_str(); XSetClassHint(this->app->display,this->window,&classHint); unsigned long pid=getpid(); this->LFSTK_setXProperty(XInternAtom(this->app->display,"_NET_WM_PID",False),XA_CARDINAL,32,(void *)&pid,1); @@ -901,12 +911,13 @@ LFSTK_windowClass::LFSTK_windowClass(windowInitStruct *wi) */ LFSTK_windowClass::LFSTK_windowClass(int x,int y,int w,int h,const char* name,bool override,bool loadvars,bool shutdisplayonexit) { - windowInitStruct *wi=new windowInitStruct; + windowInitStruct *wi=this->app->LFSTK_getDefaultWInit();//TODO// +// =new windowInitStruct; wi->x=x; wi->y=y; wi->w=w; wi->h=h; - wi->name=name; + wi->windowName=name; wi->overRide=override; wi->loadVars=loadvars; wi->shutDisplayOnExit=shutdisplayonexit; @@ -1212,7 +1223,7 @@ void LFSTK_windowClass::LFSTK_dropData(propertyStruct* data) this->droppedData.type=DROPINVALID; if(this->droppedData.data!=NULL) - free(this->droppedData.data); + freeAndNull(&this->droppedData.data); this->droppedData.data=NULL; if(strcasecmp(data->mimeType,"text/plain")==0) diff --git a/LFSToolKit/LFSToolKit/lfstk/LFSTKWindow.h b/LFSToolKit/LFSToolKit/lfstk/LFSTKWindow.h index 76268d6..1ca014b 100644 --- a/LFSToolKit/LFSToolKit/lfstk/LFSTKWindow.h +++ b/LFSToolKit/LFSToolKit/lfstk/LFSTKWindow.h @@ -98,7 +98,9 @@ class LFSTK_windowClass bool LFSTK_getActive(void); void LFSTK_setSticky(bool set); bool LFSTK_getSticky(void); - void LFSTK_setWindowType(const char *type); +// void LFSTK_setWindowType(const char *type); + void LFSTK_setWindowType(Atom type); + void LFSTK_setTransientFor(Window w); void LFSTK_reloadGlobals(void); @@ -139,7 +141,7 @@ class LFSTK_windowClass Visual *visual; Colormap cmap; - char *fontString; + char *fontString=NULL; char *fontColourNames[MAXCOLOURS]={NULL,}; colourStruct windowColourNames[MAXCOLOURS]={{},};// {{NULL,0,{0,0,0,0}},}; bool autoLabelColour=false; @@ -179,7 +181,8 @@ class LFSTK_windowClass protected: bool isActive; - char *windowName; + //char *windowName=NULL; + std::string windowName="LFSTK Window"; void initWindow(bool loadvars); private: diff --git a/LFSToolKit/examples/basic.cpp b/LFSToolKit/examples/basic.cpp index 0fb0e6d..50f6364 100755 --- a/LFSToolKit/examples/basic.cpp +++ b/LFSToolKit/examples/basic.cpp @@ -291,10 +291,11 @@ int main(int argc, char **argv) //wc->LFSTK_showWindow(); printf("Number of gadgets in window=%i\n",wc->LFSTK_gadgetCount()); - apc->LFSTK_setTimer(2); + apc->LFSTK_setTimer(1000000,true); apc->LFSTK_setTimerCallBack(timerCB,NULL); - popWindow=new LFSTK_toolWindowClass(apc->display,wc,"_NET_WM_WINDOW_TYPE_MENU",0,0,200,100,"lfstkpopup",apc); + popWindow=new LFSTK_toolWindowClass(apc->display,wc,apc->appAtomsHashed.at(apc->globalLib->prefs.LFSTK_hashFromKey("_NET_WM_WINDOW_TYPE_MENU")),0,0,200,100,"lfstkpopup",apc); + LFSTK_labelClass *poplabel=new LFSTK_labelClass(popWindow,"This is a mouse enter callback",0,0,GADGETWIDTH*8,GADGETHITE,WestGravity); poplabel->LFSTK_setCairoFontDataParts("sB",20); poplabel->LFSTK_setTile(NULL,0); diff --git a/LFSToolKit/examples/image.cpp b/LFSToolKit/examples/image.cpp index fb39a9d..09279f0 100755 --- a/LFSToolKit/examples/image.cpp +++ b/LFSToolKit/examples/image.cpp @@ -66,7 +66,7 @@ bool contextCB(void *p,void* ud) int winnum; if(p!=NULL) { - winnum=lwc->app->LFSTK_findWindow(lwc); + //winnum=lwc->app->LFSTK_findWindow(lwc); lwc->app->windows->at(winnum).loopFlag=false; //wc->popupLoop=false; //printf("data=%p\n win=%i",ud,static_cast(p)->windowNumber); @@ -158,14 +158,16 @@ int main(int argc, char **argv) win=new windowInitStruct; win->app=apc; - win->name=""; + win->windowName=""; win->loadVars=true; win->x=100; win->y=100; win->w=200; win->h=200; win->wc=wc; - win->windowType="_NET_WM_WINDOW_TYPE_MENU"; + //win->windowType="_NET_WM_WINDOW_TYPE_MENU"; + win->windowType=apc->appAtomsHashed.at(apc->globalLib->prefs.LFSTK_hashFromKey("_NET_WM_WINDOW_TYPE_TOOL")); + win->decorated=false; win->overRide=true; win->level=ABOVEALL; diff --git a/LFSToolKit/examples/imagebutton.cpp b/LFSToolKit/examples/imagebutton.cpp index ee64502..e88d247 100755 --- a/LFSToolKit/examples/imagebutton.cpp +++ b/LFSToolKit/examples/imagebutton.cpp @@ -27,7 +27,7 @@ LFSTK_labelClass *copyrite=NULL; LFSTK_buttonClass *imagebuttonL=NULL; LFSTK_buttonClass *imagebuttonC=NULL; LFSTK_buttonClass *imagebuttonR=NULL; -LFSTK_buttonClass *imagebuttonT=NULL; +LFSTK_toggleButtonClass *imagebuttonT=NULL; LFSTK_buttonClass *imagebuttonNA=NULL; LFSTK_buttonClass *seperator=NULL; LFSTK_buttonClass *quit=NULL; @@ -67,7 +67,8 @@ int main(int argc, char **argv) sy+=YSPACING; //image button toolbutton - imagebuttonT=new LFSTK_buttonClass(wc,"Tool Button",DIALOGMIDDLE-GADGETWIDTH,sy,GADGETWIDTH*2,GADGETHITE*2,BUTTONGRAV); + imagebuttonT=new LFSTK_toggleButtonClass(wc,"Toggle/Tool Button",DIALOGMIDDLE-GADGETWIDTH,sy,GADGETWIDTH*2,GADGETHITE*2,BUTTONGRAV); + imagebuttonT->LFSTK_setToggleStyle(TOGGLENORMAL); imagebuttonT->LFSTK_setMouseCallBack(NULL,buttonCB,USERDATA(0xdeadbeef0)); imagebuttonT->LFSTK_setImageFromPath("./AspellGUI.png",TOOLBAR,true); sy+=YSPACING*2; diff --git a/LFSToolKit/examples/subwindowtest.cpp b/LFSToolKit/examples/subwindowtest.cpp index 7acc7c7..fb8257b 100755 --- a/LFSToolKit/examples/subwindowtest.cpp +++ b/LFSToolKit/examples/subwindowtest.cpp @@ -99,7 +99,7 @@ int main(int argc, char **argv) apc->windows->back().window->LFSTK_resizeWindow(400,400,true); apc->windows->back().window->userData=USERDATA("Sub Window"); button=new LFSTK_buttonClass(apc->windows->back().window,"Close",200-HALFGADGETWIDTH,200,GADGETWIDTH,GADGETHITE,BUTTONGRAV); - button->LFSTK_setMouseCallBack(NULL,doSubQuit,(void*)apc->windows->size()-1); + button->LFSTK_setMouseCallBack(NULL,doSubQuit,(void*)(apc->windows->size()-1)); apc->LFSTK_addWindow(NULL,"TRANSPARENT SUB WINDOW"); apc->windows->back().window->LFSTK_resizeWindow(400,400,true); @@ -112,7 +112,7 @@ int main(int argc, char **argv) label->LFSTK_setTile(NULL,0); button=new LFSTK_buttonClass(apc->windows->back().window,"Close",200-HALFGADGETWIDTH,200,GADGETWIDTH,GADGETHITE,BUTTONGRAV); - button->LFSTK_setMouseCallBack(NULL,doTransSubQuit,(void*)apc->windows->size()-1); + button->LFSTK_setMouseCallBack(NULL,doTransSubQuit,(void*)(apc->windows->size()-1)); //button->LFSTK_setColourName(NORMALCOLOUR,"#20ffff00"); button->LFSTK_setTile(NULL,0); @@ -135,11 +135,11 @@ int main(int argc, char **argv) //test test=new LFSTK_buttonClass(wc,"Sub-Window",DIALOGMIDDLE-GADGETWIDTH,sy,GADGETWIDTH*2,GADGETHITE,BUTTONGRAV); - test->LFSTK_setMouseCallBack(NULL,buttonCB,(void*)apc->windows->size()-2); + test->LFSTK_setMouseCallBack(NULL,buttonCB,(void*)(apc->windows->size()-2)); sy+=YSPACING; transtest=new LFSTK_buttonClass(wc,"Transparent Sub-Window",DIALOGMIDDLE-GADGETWIDTH,sy,GADGETWIDTH*2,GADGETHITE,BUTTONGRAV); - transtest->LFSTK_setMouseCallBack(NULL,transButtonCB,(void*)apc->windows->size()-1); + transtest->LFSTK_setMouseCallBack(NULL,transButtonCB,(void*)(apc->windows->size()-1)); sy+=YSPACING; //quit diff --git a/LFSToolKit/examples/toggle.cpp b/LFSToolKit/examples/toggle.cpp index eb92af0..5c96080 100755 --- a/LFSToolKit/examples/toggle.cpp +++ b/LFSToolKit/examples/toggle.cpp @@ -136,19 +136,20 @@ int main(int argc, char **argv) windowInitStruct *win; - win=new windowInitStruct; + win=new windowInitStruct;//TODO// win->x=100; win->y=100; win->w=16; win->h=100; //win->wc=wc; // win->windowType="_NET_WM_WINDOW_TYPE_DOCK"; -// win->decorated=true; -// win->overRide=true; + win->decorated=false; + win->overRide=true; // win->level=ABOVEALL; - + win->app=apc; + win->windowType=apc->appAtomsHashed.at(apc->globalLib->prefs.LFSTK_hashFromKey("_NET_WM_WINDOW_TYPE_TOOL")); apc->LFSTK_addToolWindow(win); - scwindow=apc->windows->back().window; + scwindow=apc->windows->back().window;//TODO// //XReparentWindow(apc->display,scwindow->window,wc->window,20,20); vsb=new LFSTK_scrollBarClass(scwindow,true,0,0,16,100); diff --git a/LFSWM2/LFSWM2/app/lfswm2.local b/LFSWM2/LFSWM2/app/lfswm2.local new file mode 100755 index 0000000..0176a7b --- /dev/null +++ b/LFSWM2/LFSWM2/app/lfswm2.local @@ -0,0 +1,12 @@ +#!/bin/bash -e + +#©keithhedger Mon 27 Nov 12:09:16 GMT 2023 kdhedger68713@gmail.com + +if [[ $1 = "conf" ]];then + pushd ../../../ + sudo BUILDFOR="LFSWM2" ./makeall ownit + BUILDFOR="LFSWM2" ./makeall makelocal + popd +fi + +LD_LIBRARY_PATH="../../../LFSToolKit/LFSToolKit/app/.libs" ./lfswm2 diff --git a/README.md b/README.md index 94ae7a0..ef7c4e2 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ -# LFSDesktopProject +# LFSDesktopProject
A low resource/dependency desktop for Linux From Scratch -Although designed for Linux From Scratch has been tested on Slackware adn XUbuntu briefly. +Although designed for Linux From Scratch has been tested on Slackware and XUbuntu briefly. -Documentation is autogenerated by doxygen. -CD to LFSDesktopProject/LFSToolKit/LFSToolKit/lfstk and run: -doxygen +Documentation is autogenerated by doxygen.
+CD to LFSDesktopProject/LFSToolKit/LFSToolKit/lfstk and run:
+doxygen
to update docs. https://keithdhedger.github.io/LFSDesktopProject/ @@ -15,3 +15,7 @@ LFSWM2 Should be used in place of LFSWManager. Non essential files have been removed from the repo, you now need to use ( for example )./autogen --prefix=/usr --libdir=/usr/lib64 +The best way to do a full install is to use the "makeall" script in this folder ie:
+sudo ./makeall deploy + +There are other options to the script but they are mainly for my use whilst developing, use at your own risk. \ No newline at end of file diff --git a/makeall b/makeall index 2c9e2f1..4b8bb14 100755 --- a/makeall +++ b/makeall @@ -36,6 +36,7 @@ MAKEFLAGS=${MAKEFLAGS:-"-j3"} export MAKEFLAGS export PATH BUILDOLDWM=0 +CWD=$(pwd) if [ $BUILDOLDWM -eq 1 ];then BUILDLFSWMANAGER="LFSWManager" @@ -118,7 +119,7 @@ makelocal () #runCommand "./autogen.sh --prefix=/usr --libdir=/usr/lib${LIBDIRSUFFIX}" : else - CFLAGS="-Wfatal-errors -I../LFSToolKit/LFSToolKit/lfstk -L../LFSToolKit/LFSToolKit/app/.libs" + CFLAGS="-Wfatal-errors -I${CWD}/LFSToolKit/LFSToolKit/lfstk/ -L${CWD}/LFSToolKit/LFSToolKit/app/.libs" CXXFLAGS="$CFLAGS" export CFLAGS CXXFLAGS runCommand "./autogen.sh --prefix=/usr"