From 9d12f43dc14facdf18b3aa021dca1bba387e562f Mon Sep 17 00:00:00 2001 From: K D Hedger Date: Wed, 18 Oct 2023 14:29:38 +0100 Subject: [PATCH] fixes ... --- LFSPanel/ChangeLog | 1 + LFSPanel/LFSPanel/src/windowlist.cpp | 40 +++++++++++++++------------- LFSWM2/LFSWM2/src/eventsClass.cpp | 37 +++++++++++++++++++++++-- LFSWM2/LFSWM2/src/lfswm2Class.h | 2 +- 4 files changed, 59 insertions(+), 21 deletions(-) diff --git a/LFSPanel/ChangeLog b/LFSPanel/ChangeLog index 9c4309c..6215873 100644 --- a/LFSPanel/ChangeLog +++ b/LFSPanel/ChangeLog @@ -1,4 +1,5 @@ 0.2.0 +Fixed occasional segfault in window menu. Fixed menu items from bad window names. Fixed segfault on window list. Fixed blank window names on window list. diff --git a/LFSPanel/LFSPanel/src/windowlist.cpp b/LFSPanel/LFSPanel/src/windowlist.cpp index 20e73e0..ecf556c 100644 --- a/LFSPanel/LFSPanel/src/windowlist.cpp +++ b/LFSPanel/LFSPanel/src/windowlist.cpp @@ -206,6 +206,7 @@ Window doTreeWalk(Window wind,bool thisdesktop) thewin=children[j]; winid=children[j]; st=XFetchName(mainwind->app->display,children[j],&wname); + break; } thewin=None; @@ -222,32 +223,35 @@ Window doTreeWalk(Window wind,bool thisdesktop) break; } - if(winid!=-1) + if(wname!=NULL) { - ptr=NULL; - count=32; - n=0; - - if(strlen(wname)==0) + if(winid!=-1) { - 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); + 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); + } + + 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; } - 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; diff --git a/LFSWM2/LFSWM2/src/eventsClass.cpp b/LFSWM2/LFSWM2/src/eventsClass.cpp index a368876..11925fc 100644 --- a/LFSWM2/LFSWM2/src/eventsClass.cpp +++ b/LFSWM2/LFSWM2/src/eventsClass.cpp @@ -672,6 +672,7 @@ void LFSWM2_eventsClass::LFSWM2_restack(void)//TODO// still dont like this code if(this->mainClass->mainWindowClass->windowIDList.size()==0) return; + //fprintf(stderr,"crapwin=0x%x\n",crapwin); v=(Atom*)this->mainClass->mainWindowClass->LFSWM2_getProp(this->mainClass->rootWindow,this->mainClass->atomshashed.at(this->mainClass->prefs.LFSTK_hashFromKey("_NET_ACTIVE_WINDOW")),XA_WINDOW,&nitems_return); @@ -809,6 +810,7 @@ void LFSWM2_eventsClass::LFSWM2_restack(void)//TODO// still dont like this code } if((this->mainClass->mainWindowClass->LFSWM2_getWindowType(wid)==MENUWINDOW)) { + XRaiseWindow(this->mainClass->display,wid); move(framel,j,0); } } @@ -823,6 +825,7 @@ void LFSWM2_eventsClass::LFSWM2_restack(void)//TODO// still dont like this code if(this->mainClass->mainWindowClass->LFSWM2_hasState(wid,this->mainClass->atomshashed.at(this->mainClass->prefs.LFSTK_hashFromKey("_NET_WM_STATE_BELOW")))) { move(framel,j,framel.size()-1); + XLowerWindow(this->mainClass->display,wid); } } @@ -845,6 +848,26 @@ void LFSWM2_eventsClass::LFSWM2_restack(void)//TODO// still dont like this code #endif //above //TODO// + for(int j=0;jmainClass->mainWindowClass->LFSWM2_getClientClass(framel.at(j)); + if(cc!=NULL) + { + wid=cc->contentWindow; + } + else + { + wid=framel.at(j); + //XRaiseWindow(this->mainClass->display,wid); + } + if(this->mainClass->mainWindowClass->LFSWM2_hasState(wid,this->mainClass->atomshashed.at(this->mainClass->prefs.LFSTK_hashFromKey("_NET_WM_STATE_ABOVE")))) + { + //XRaiseWindow(this->mainClass->display,wid); + move(framel,j,0); + //move(framel,j,framel.size()-1); + } + } + for(int j=0;jmainClass->mainWindowClass->LFSWM2_getClientClass(framel.at(j)); @@ -852,10 +875,20 @@ void LFSWM2_eventsClass::LFSWM2_restack(void)//TODO// still dont like this code wid=cc->contentWindow; else wid=framel.at(j); - if(this->mainClass->mainWindowClass->LFSWM2_hasState(wid,this->mainClass->atomshashed.at(this->mainClass->prefs.LFSTK_hashFromKey("_NET_WM_STATE_ABOVE")))) - move(framel,j,0); + + if((this->mainClass->mainWindowClass->LFSWM2_getWindowType(wid)==MENUWINDOW)) + { + XRaiseWindow(this->mainClass->display,wid); + //move(framel,j,0); + // move(framel,j,framel.size()-1); + } } + + + + + //framel.erase(framel.begin()+framel.size()-1); XRestackWindows(this->mainClass->display,framel.data(),framel.size()); diff --git a/LFSWM2/LFSWM2/src/lfswm2Class.h b/LFSWM2/LFSWM2/src/lfswm2Class.h index b57e690..aa93feb 100644 --- a/LFSWM2/LFSWM2/src/lfswm2Class.h +++ b/LFSWM2/LFSWM2/src/lfswm2Class.h @@ -46,7 +46,7 @@ #include "config.h" -#define __DEBUG__ +//#define __DEBUG__ #ifdef __DEBUG__ #define MOVEKEYS (Mod4Mask|ControlMask) #else