diff --git a/LFSDock/ChangeLog b/LFSDock/ChangeLog index 6092aaa..89d5d7f 100644 --- a/LFSDock/ChangeLog +++ b/LFSDock/ChangeLog @@ -1,4 +1,5 @@ 0.2.0 +fixed random bouncing of launchers. Fixed trying to open dock on non existant monitor. Added a couple of background examples. UI updates. diff --git a/LFSDock/LFSDock/src/callbacks.cpp b/LFSDock/LFSDock/src/callbacks.cpp index 97e7136..ae11b33 100644 --- a/LFSDock/LFSDock/src/callbacks.cpp +++ b/LFSDock/LFSDock/src/callbacks.cpp @@ -20,8 +20,8 @@ #include "globals.h" -LFSTK_windowClass *launcherContextWindow; -LFSTK_windowClass *taskContextWindow; +//LFSTK_windowClass *launcherContextWindow=NULL; +LFSTK_windowClass *taskContextWindow=NULL; int cnt=0; int cnt2=0; @@ -98,10 +98,10 @@ bool timerCB(LFSTK_applicationClass *p,void* ud) if((useTaskBar==true) && (currentTask!=NULL)) cnt2++; - if((gotLaunchers==true) && (launcherContextWindow->isVisible==false) && (launcherContextWindow->popupFromGadget!=NULL)) + if((gotLaunchers==true) && (launcherContextWC->isVisible==false) && (launcherContextWC->popupFromGadget!=NULL)) { - launcherExitCB(launcherContextWindow->popupFromGadget,(void*)1); - launcherContextWindow->popupFromGadget=NULL; + launcherExitCB(launcherContextWC->popupFromGadget,(void*)1); + launcherContextWC->popupFromGadget=NULL; currentLauncher=NULL;; } @@ -109,7 +109,7 @@ bool timerCB(LFSTK_applicationClass *p,void* ud) { cnt=0; launcherExitCB(currentLauncher,(void*)1); - launcherContextWindow->popupFromGadget=NULL; + launcherContextWC->popupFromGadget=NULL; currentLauncher=NULL;; } @@ -147,52 +147,52 @@ void readMsg(void) buffer.mText[0]=0; } -bool contextCB(void *p,void* ud) -{ - int winnum; - LFSTK_windowClass *lwc=static_cast(p)->wc; - long unsigned int whatbutton=(long unsigned int)ud; - launcherDataStruct lds=launchersArray.at((long unsigned int)lwc->popupFromGadget->userData); - - if(p!=NULL) - { - winnum=lwc->app->LFSTK_findWindow(lwc); - lwc->app->windows->at(winnum).loopFlag=false; - - switch(whatbutton) - { - case BUTTONQUIT: - realMainLoop=false; - apc->mainLoop=false; - break; - case BUTTONLAUNCH: - launcherCB(NULL,lwc->popupFromGadget->userData); - break; - case BUTTONREMOVE: - sendNotify("Removing ",lds.name); - XSync(apc->display,false); - sleep(1); - unlink(lds.path.c_str()); - apc->exitValue=0; - apc->mainLoop=false; - - break; - case BUTTONPREFS: - { - std::string com; - com="lfsdockprefs -d "+whatDock+" &"; - system(com.c_str()); - } - break; - } - - launcherExitCB(lwc->popupFromGadget,ud); - lwc->popupFromGadget=NULL; - dockWindow->LFSTK_clearWindow(true); - //XSync(apc->display,false); - } - return(true); -} +//bool contextCB(void *p,void* ud) +//{ +// int winnum; +// LFSTK_windowClass *lwc=static_cast(p)->wc; +// long unsigned int whatbutton=(long unsigned int)ud; +// launcherDataStruct lds=launchersArray.at((long unsigned int)lwc->popupFromGadget->userData); +// +// if(p!=NULL) +// { +// winnum=lwc->app->LFSTK_findWindow(lwc); +// lwc->app->windows->at(winnum).loopFlag=false; +// +// switch(whatbutton) +// { +// case BUTTONQUIT: +// realMainLoop=false; +// apc->mainLoop=false; +// break; +// case BUTTONLAUNCH: +// launcherCB(NULL,lwc->popupFromGadget->userData); +// break; +// case BUTTONREMOVE: +// sendNotify("Removing ",lds.name); +// XSync(apc->display,false); +// sleep(1); +// unlink(lds.path.c_str()); +// apc->exitValue=0; +// apc->mainLoop=false; +// +// break; +// case BUTTONPREFS: +// { +// std::string com; +// com="lfsdockprefs -d "+whatDock+" &"; +// system(com.c_str()); +// } +// break; +// } +// +// launcherExitCB(lwc->popupFromGadget,ud); +// lwc->popupFromGadget=NULL; +// dockWindow->LFSTK_clearWindow(true); +// //XSync(apc->display,false); +// } +// return(true); +//} void showhidetActionList(LFSTK_gadgetClass *bc,LFSTK_windowClass *winc,LFSTK_listGadgetClass *list) { @@ -200,7 +200,7 @@ void showhidetActionList(LFSTK_gadgetClass *bc,LFSTK_windowClass *winc,LFSTK_lis unsigned long d; const geometryStruct *wingeom; - if(bc!=NULL) + if(bc!=NULL && bc->gadgetType==BUTTONGADGET) { wingeom=winc->LFSTK_getWindowGeom(); d=(unsigned long)bc->userData; @@ -214,8 +214,8 @@ void showhidetActionList(LFSTK_gadgetClass *bc,LFSTK_windowClass *winc,LFSTK_lis winc->LFSTK_moveWindow(geom.x+(geom.w/2)-(list->LFSTK_getListMaxWidth()/2),geom.y-wingeom->h+extraSpace,true); break; } - winc->LFSTK_setKeepAbove(true); winc->LFSTK_showWindow(true); + winc->LFSTK_setKeepAbove(true); winc->LFSTK_redrawAllGadgets(); apc->windows->at(apc->LFSTK_findWindow(winc)).showing=true; } @@ -246,7 +246,7 @@ bool popActionListEnterCB(LFSTK_gadgetClass*p,void* ud) bool popActionListExitCB(LFSTK_gadgetClass*p,void* ud) { showhidetActionList(NULL,popActionWindow,popActionList); - inSomeWindow=false; + inSomeWindow=true; return(true); } @@ -263,9 +263,6 @@ bool popActionWindowSelect(void *object,void* userdata)//TODO// wud=(unsigned long)popActionWindow->userData; switch(wud) { - case LAUNCHER: - launcherCB(bc,(void*)bc->userData); - break; case TASKSWITCHER: { LFSTK_gadgetClass *bc=static_cast(object);; diff --git a/LFSDock/LFSDock/src/callbacks.h b/LFSDock/LFSDock/src/callbacks.h index 255427a..bfc89c1 100644 --- a/LFSDock/LFSDock/src/callbacks.h +++ b/LFSDock/LFSDock/src/callbacks.h @@ -23,12 +23,12 @@ enum {BUTTONLAUNCH=0,BUTTONREMOVE,BUTTONPREFS,BUTTONQUIT,NOMOREBUTONS}; -extern LFSTK_windowClass *launcherContextWindow; +//extern LFSTK_windowClass *launcherContextWindow; extern LFSTK_windowClass *taskContextWindow; void sendClientMessage(Window win,const char *msg,unsigned long data0,unsigned long data1,unsigned long data2,unsigned long data3,unsigned long data4); -bool contextCB(void *p,void* ud); +//bool contextCB(void *p,void* ud); bool gadgetDrop(void *lwc,propertyStruct *data,void* ud); bool timerCB(LFSTK_applicationClass *p,void* ud); void readMsg(void); diff --git a/LFSDock/LFSDock/src/globals.cpp b/LFSDock/LFSDock/src/globals.cpp index e7d9356..03babbe 100644 --- a/LFSDock/LFSDock/src/globals.cpp +++ b/LFSDock/LFSDock/src/globals.cpp @@ -29,8 +29,8 @@ std::string whatDock; int iconWidth=16; int iconHeight=24; -int normalY; -int activeY; +int normalY=0; +int activeY=0; int extraSpace=16; int deskCount=1; @@ -62,7 +62,7 @@ LFSTK_windowClass *popActionWindow=NULL; LFSTK_listGadgetClass *popActionList=NULL; bool inSomeWindow=false; bool gotLaunchers=false; -int popActionWindowYOffset=1; +int popActionWindowYOffset=0; LFSTK_buttonClass *bgrs=NULL; LFSTK_buttonClass *bgls=NULL; int sidewid=0; @@ -95,7 +95,7 @@ void sendNotify(std::string name,std::string message)//TODO//could be better { #ifdef _GOTNOTIFYSEND_ std::string com=std::string("notify-send -u low -t 2000 -i stock_dialog-info \"" + name + " " + message + " ...\""); - fprintf(stderr,"sendNotify com=>>%s<<\n",com.c_str()); + //fprintf(stderr,"sendNotify com=>>%s<<\n",com.c_str()); system(com.c_str()); #endif } diff --git a/LFSDock/LFSDock/src/globals.h b/LFSDock/LFSDock/src/globals.h index 8a0edd1..9b53755 100644 --- a/LFSDock/LFSDock/src/globals.h +++ b/LFSDock/LFSDock/src/globals.h @@ -45,7 +45,7 @@ #define MAXTASKBUTTONS 32 enum PANELGRAVITY {PANELNORTH=1,PANELSOUTH=2}; -enum WHATSORT {LAUNCHER=100,DESKTOPSWITCHER,TASKSWITCHER}; +enum WHATSORT {DESKTOPSWITCHER=100,TASKSWITCHER}; struct launcherDataStruct { diff --git a/LFSDock/LFSDock/src/launchers.cpp b/LFSDock/LFSDock/src/launchers.cpp index 3330845..ad12590 100644 --- a/LFSDock/LFSDock/src/launchers.cpp +++ b/LFSDock/LFSDock/src/launchers.cpp @@ -29,90 +29,109 @@ std::vector launchersArray; LFSTK_findClass *findlaunchers=NULL; LFSTK_gadgetClass *currentLauncher=NULL; -bool launcherEnterCB(LFSTK_gadgetClass* p,void* ud) +LFSTK_windowClass *launcherContextWC=NULL; +LFSTK_windowClass *tooltiptWC=NULL; +LFSTK_labelClass *ttLabel=NULL; + +bool launcherContextCB(void *p,void* ud) { + int winnum; + LFSTK_windowClass *lwc=static_cast(p)->wc; + long unsigned int whatbutton=(long unsigned int)ud; + launcherDataStruct lds=launchersArray.at((long unsigned int)lwc->popupFromGadget->userData); + if(p!=NULL) { - std::string label; - infoDataStruct ls; - const geometryStruct *wingeom; - launcherDataStruct lds=launchersArray.at((long unsigned int)ud); - int offy; + tooltiptWC->LFSTK_moveWindow(-1000,1000,true); + winnum=lwc->app->LFSTK_findWindow(lwc); + lwc->app->windows->at(winnum).loopFlag=false; - currentLauncher=p; - setGadgetPosition(p,true); - popActionList->LFSTK_freeList(); - ls.label=lds.name; - ls.imageType=NOTHUMB; - ls.imagePath; - 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); - - p->contextYOffset=popActionWindowYOffset; - showhidetActionList(p,popActionWindow,popActionList); - - inSomeWindow=true; + switch(whatbutton) + { + case BUTTONQUIT: + realMainLoop=false; + apc->mainLoop=false; + break; + case BUTTONLAUNCH: + launcherCB(NULL,lwc->popupFromGadget->userData); + break; + case BUTTONREMOVE: + sendNotify("Removing ",lds.name); + XSync(apc->display,false); + sleep(1); + unlink(lds.path.c_str()); + apc->exitValue=0; + apc->mainLoop=false; + + break; + case BUTTONPREFS: + { + std::string com; + com="lfsdockprefs -d "+whatDock+" &"; + system(com.c_str()); + } + break; + } } return(true); } -bool launcherExitCB(LFSTK_gadgetClass *p,void* ud) +bool launcherEnterCB(LFSTK_gadgetClass* p,void* ud) { if(p!=NULL) { - currentLauncher=NULL; - setGadgetPosition(p,false); - inSomeWindow=false; - popActionListExitCB(NULL,(void*)1); - dockWindow->LFSTK_clearWindow(true); + launcherDataStruct lds=launchersArray.at((long unsigned int)ud); + XEvent event; + geometryStruct geom; + currentLauncher=p; + setGadgetPosition(p,true); + + ttLabel->LFSTK_setLabel(lds.name,true); + ttLabel->LFSTK_setCairoFontDataParts("sB",14); + ttLabel->LFSTK_setTile(NULL,0); + + tooltiptWC->LFSTK_resizeWindow(ttLabel->LFSTK_getTextRealWidth(lds.name),GADGETHITE); + tooltiptWC->LFSTK_setWindowColourName(NORMALCOLOUR,"#c0808080"); + p->LFSTK_getGeomWindowRelative(&geom,apc->rootWindow); + + switch(dockGravity) + { + case PANELNORTH: + tooltiptWC->LFSTK_moveWindow(geom.x+(geom.w/2)-(ttLabel->LFSTK_getTextRealWidth(lds.name)/2),dockWindow->h,true); + break; + case PANELSOUTH: + tooltiptWC->LFSTK_moveWindow(geom.x+(geom.w/2)-(ttLabel->LFSTK_getTextRealWidth(lds.name)/2),geom.y-GADGETHITE+extraSpace,true); + break; + } + XRaiseWindow(apc->display,tooltiptWC->window); } + XSync(apc->display,false); + return(true); +} + +bool launcherExitCB(LFSTK_gadgetClass* p,void* ud) +{ + if(p!=NULL) + { + currentLauncher=NULL; + setGadgetPosition(p,false); + dockWindow->LFSTK_redrawAllGadgets(); + tooltiptWC->LFSTK_moveWindow(-1000,1000,true); + XRaiseWindow(apc->display,launcherContextWC->window); + XRaiseWindow(apc->display,launcherContextWC->window); + } + XSync(apc->display,false); return(true); } bool launcherCB(void *p,void* ud) { launcherDataStruct lds=launchersArray.at((long unsigned int)ud); - Window win=None; - std::string ex=lds.exec; std::size_t found; std::string command; std::string args; std::string str; - propReturn pr; - - showhidetActionList(NULL,popActionWindow,popActionList); - - if(p!=NULL) - { - win=getWindowByClass(lds.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(lds.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); - } - } + std::string ex=lds.exec; found=ex.find(std::string(" ")); if(found!=std::string::npos) @@ -183,22 +202,21 @@ int addLaunchers(int x,int y,int grav) findlaunchers->LFSTK_sortByName(); win=apc->LFSTK_getDefaultWInit(); - win->windowType=apc->appAtomsHashed.at(LFSTK_UtilityClass::LFSTK_hashFromKey("_NET_WM_WINDOW_TYPE_DIALOG")); + win->windowType=apc->appAtomsHashed.at(LFSTK_UtilityClass::LFSTK_hashFromKey("_NET_WM_WINDOW_TYPE_MENU")); win->decorated=false; win->level=ABOVEALL; apc->LFSTK_addWindow(win,"Context"); - launcherContextWindow=apc->windows->back().window; - launcherContextWindow->LFSTK_setWindowColourName(NORMALCOLOUR,lc.c_str()); + launcherContextWC=apc->windows->back().window; + launcherContextWC->LFSTK_setWindowColourName(NORMALCOLOUR,lc.c_str()); for(int j=BUTTONLAUNCH;jLFSTK_setMouseCallBack(NULL,contextCB,(void*)(long)(j)); - iconpath=launcherContextWindow->globalLib->LFSTK_findThemedIcon("gnome",contextThemeIconData[j],""); + contextButtons[j]=new LFSTK_buttonClass(launcherContextWC,contextLabelData[j],0,sy,GADGETWIDTH*2,24,NorthWestGravity); + contextButtons[j]->LFSTK_setMouseCallBack(NULL,launcherContextCB,(void*)(long)(j)); + iconpath=launcherContextWC->globalLib->LFSTK_findThemedIcon("gnome",contextThemeIconData[j],""); contextButtons[j]->LFSTK_setImageFromPath(iconpath,LEFT,true); setGadgetDetails(contextButtons[j]); - contextButtons[j]->LFSTK_setCairoFontDataParts("sB",20); contextButtons[j]->LFSTK_setTile(NULL,0); contextButtons[j]->LFSTK_setFontString(prefs.LFSTK_getCString("font"),true); contextButtons[j]->LFSTK_setLabelAutoColour(true); @@ -208,7 +226,13 @@ int addLaunchers(int x,int y,int grav) sy+=GADGETHITE; } ww=contextButtons[0]->LFSTK_getTextRealWidth(contextLabelData[1]); - launcherContextWindow->LFSTK_resizeWindow(ww+contextButtons[0]->imageWidth+8,sy,true); + launcherContextWC->LFSTK_resizeWindow(ww+contextButtons[0]->imageWidth+8,sy,true); + launcherContextWC->LFSTK_setKeepAbove(true); + tooltiptWC=new LFSTK_toolWindowClass(apc->display,dockWindow,apc->appAtomsHashed.at(LFSTK_UtilityClass::LFSTK_hashFromKey("_NET_WM_WINDOW_TYPE_DOCK")),0,0,200,100,"lfstkpopup",apc); + ttLabel=new LFSTK_labelClass(tooltiptWC,"XXX",0,0,GADGETWIDTH*8,GADGETHITE,WestGravity); + + tooltiptWC->LFSTK_moveWindow(-1000,-1000,true); + tooltiptWC->LFSTK_showWindow(); LFSTK_buttonClass *bc=NULL; launcherDataStruct lds; @@ -219,7 +243,7 @@ int addLaunchers(int x,int y,int grav) lds.pid=0; bc=new LFSTK_buttonClass(dockWindow,"",xpos,normalY,iconWidth,iconHeight); - bc->LFSTK_setContextWindow(launcherContextWindow); + bc->LFSTK_setContextWindow(launcherContextWC); if(dockGravity==PANELSOUTH) bc->contextWindowPos=CONTEXTABOVECENTRE; diff --git a/LFSDock/LFSDock/src/launchers.h b/LFSDock/LFSDock/src/launchers.h index 28d3feb..5b015ac 100644 --- a/LFSDock/LFSDock/src/launchers.h +++ b/LFSDock/LFSDock/src/launchers.h @@ -27,10 +27,10 @@ extern std::vector launchersArray; extern LFSTK_findClass *findlaunchers; extern LFSTK_gadgetClass *currentLauncher; +extern LFSTK_windowClass *launcherContextWC; -bool launcherEnterCB(LFSTK_gadgetClass*p,void* ud); -bool launcherExitCB(LFSTK_gadgetClass*p,void* ud); -bool launcherCB(void *p,void* ud); -int addLaunchers(int x,int y,int grav); +bool launcherCB(void *p,void* ud); +int addLaunchers(int x,int y,int grav); +bool launcherExitCB(LFSTK_gadgetClass* p,void* ud); #endif diff --git a/LFSDock/LFSDock/src/main.cpp b/LFSDock/LFSDock/src/main.cpp index 6da385a..a083cef 100644 --- a/LFSDock/LFSDock/src/main.cpp +++ b/LFSDock/LFSDock/src/main.cpp @@ -377,6 +377,9 @@ int main(int argc,char **argv) if(useTaskBar==true) updateTaskBar(true); + showhidetActionList(NULL,popActionWindow,popActionList); + XSync(apc->display,true); + int retval=apc->LFSTK_runApp(); calendarIsUp=false; diff --git a/LFSToolKit/LFSToolKit/lfstk/LFSTKLib.cpp b/LFSToolKit/LFSToolKit/lfstk/LFSTKLib.cpp index 4572261..0c41329 100644 --- a/LFSToolKit/LFSToolKit/lfstk/LFSTKLib.cpp +++ b/LFSToolKit/LFSToolKit/lfstk/LFSTKLib.cpp @@ -419,9 +419,12 @@ bool LFSTK_lib::LFSTK_gadgetEvent(void *self,XEvent *e,int type) case CONTEXTATMOUSE: break; } - + XRaiseWindow(gadget->wc->app->display,lwc->window); + XSync(gadget->wc->app->display,false); gadget->wc->app->LFSTK_runWindowLoop(lwc); + gadget->mouseExit(&e->xbutton); //lwc->popupFromGadget=NULL; + retval=true; break; } diff --git a/LFSToolKit/examples/basic.cpp b/LFSToolKit/examples/basic.cpp index 46e0908..423b3af 100755 --- a/LFSToolKit/examples/basic.cpp +++ b/LFSToolKit/examples/basic.cpp @@ -41,6 +41,7 @@ LFSTK_buttonClass *leftButton=NULL; LFSTK_buttonClass *centreButton=NULL; LFSTK_buttonClass *rightButton=NULL; LFSTK_buttonClass *dropButton=NULL; +LFSTK_labelClass *poplabel=NULL; bool show=true; @@ -107,7 +108,9 @@ bool moveCB(LFSTK_gadgetClass*p,void* ud) printf(">>>Mouse In %s<<<\n",(const char*)ud); p->LFSTK_getGeomWindowRelative(&geom,apc->rootWindow); - popWindow->LFSTK_moveWindow(geom.x,geom.y-GADGETHITE,true); + //popWindow->LFSTK_moveWindow(geom.x,geom.y-GADGETHITE,true); + popWindow->LFSTK_moveWindow(geom.x+(geom.w/2)-(poplabel->LFSTK_getTextRealWidth("This is a mouse enter callback")/2),geom.y-GADGETHITE,true); + popWindow->LFSTK_showWindow(); popWindow->LFSTK_clearWindow(true); } @@ -302,7 +305,7 @@ int main(int argc, char **argv) popWindow=new LFSTK_toolWindowClass(apc->display,wc,apc->appAtomsHashed.at(LFSTK_UtilityClass::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=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 69f95a5..5496916 100755 --- a/LFSToolKit/examples/image.cpp +++ b/LFSToolKit/examples/image.cpp @@ -75,6 +75,7 @@ bool contextCB(void *p,void* ud) //printf("data=%p\n win=%i",ud,static_cast(p)->windowNumber); //apc->windows->at(static_cast(p)->windowNumber).loopFlag=false; printf("ud=%p gadget=%p tux=%p\n",ud,lwc->popupFromGadget,tux); + diskWindow->LFSTK_hideWindow(); } return(true); }