diff --git a/src/backend.cpp b/src/backend.cpp index 456f5f5..7333884 100644 --- a/src/backend.cpp +++ b/src/backend.cpp @@ -788,12 +788,14 @@ void Default::Start(){ void Default::Stop(){ //cleanup - if(pcursorctx) - xcb_cursor_context_free(pcursorctx); + if(!standaloneComp){ + if(pcursorctx) + xcb_cursor_context_free(pcursorctx); + xcb_set_input_focus(pcon,XCB_NONE,XCB_INPUT_FOCUS_POINTER_ROOT,XCB_CURRENT_TIME); + } xcb_destroy_window(pcon,ewmh_window); xcb_ewmh_connection_wipe(&ewmh); - xcb_set_input_focus(pcon,XCB_NONE,XCB_INPUT_FOCUS_POINTER_ROOT,XCB_CURRENT_TIME); xcb_key_symbols_free(psymbols); diff --git a/src/config.cpp b/src/config.cpp index 544fd78..f65b977 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -425,24 +425,6 @@ ContainerConfig::~ContainerConfig(){ pcontainerInt->pcontainer = 0; } -/*template -BackendContainerConfig::BackendContainerConfig(ContainerInterface *_pcontainerInt, WManager::Container *_pParent, const WManager::Container::Setup &_setup, Backend::X11Backend *_pbackend) : T(_pParent,_setup,_pbackend), ContainerConfig(_pcontainerInt){ - // -} - -template -BackendContainerConfig::BackendContainerConfig(Backend::X11Backend *_pbackend) : T(_pbackend), ContainerConfig(){ - // - pcontainerInt->pcontainer = this; -} - -template -BackendContainerConfig::~BackendContainerConfig(){ - // -} - -class template BackendContainerConfig;*/ - X11ContainerConfig::X11ContainerConfig(ContainerInterface *_pcontainerInt, WManager::Container *_pParent, const WManager::Container::Setup &_setup, Backend::X11Backend *_pbackend) : Backend::X11Container(_pParent,_setup,_pbackend), ContainerConfig(_pcontainerInt,_pbackend){ // } diff --git a/src/main.cpp b/src/main.cpp index 7423660..bbcc98f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -101,6 +102,12 @@ void DebugPrintf(FILE *pf, const char *pfmt, ...){ va_end(args); } +static bool sigTerm = false; +void SignalHandler(int sig){ + if(sig == 15) + sigTerm = true; +} + typedef std::pair StackAppendixElement; class RunCompositor : public Config::CompositorConfig{ public: @@ -290,6 +297,19 @@ class RunBackend : public Config::BackendConfig{ } void ReleaseContainers(){ + for(auto &p : stackAppendix){ + if(p.second->pcontainer->GetParent() != 0){ //check that it's not a root container + const Config::ContainerConfig *pcontainer1 = dynamic_cast(p.second->pcontainer); + if(pcontainer1 && pcontainer1->pcontainerInt->pcontainer == p.second->pcontainer) + pcontainer1->pcontainerInt->pcontainer = 0; + + if(p.second->pcontainer) + delete p.second->pcontainer; + } + delete p.second; + } + stackAppendix.clear(); + // if(!WManager::Container::rootQueue.empty()){ WManager::Container *proot1 = WManager::Container::rootQueue.front(); WManager::Container *pRootNext = proot1->pRootNext; @@ -300,17 +320,6 @@ class RunBackend : public Config::BackendConfig{ pRootNext = pRootNext->pRootNext; }while(pRootNext != proot1); } - - for(auto &p : stackAppendix){ - const Config::ContainerConfig *pcontainer1 = dynamic_cast(p.second->pcontainer); - if(pcontainer1 && pcontainer1->pcontainerInt->pcontainer == p.second->pcontainer) - pcontainer1->pcontainerInt->pcontainer = 0; - - if(p.second->pcontainer) - delete p.second->pcontainer; - delete p.second; - } - stackAppendix.clear(); } void PrintTree(WManager::Container *pcontainer, uint level) const{ @@ -388,7 +397,7 @@ class DefaultBackend : public Backend::Default, public RunBackend{ containerCreateInfo.floating = (pcreateInfo->hints & Backend::X11Client::CreateInfo::HINT_FLOATING) != 0; if(pcreateInfo->mode == Backend::X11Client::CreateInfo::CREATE_AUTOMATIC){ - //create a temporary container through which OnSetupClient() can be called. The container is discarded as soon as the call has been made. + //create a temporary container through which (py) OnSetupClient() can be called. The container is discarded as soon as the call has been made. Config::ContainerInterface &containerInt = SetupContainer(&containerCreateInfo); containerInt.OnSetupClient(); @@ -1046,10 +1055,12 @@ int main(sint argc, const char **pargv){ pbackend->SetCompositor(pcomp); + signal(SIGTERM,SignalHandler); + for(;;){ //TODO: can we wait for vsync before handling the event? Might help with the stuttering sint result = pbackend11->HandleEvent(pcomp->IsAnimating()); - if(result == -1) + if(result == -1 || sigTerm) break; else if(result == 0 && !pcomp->IsAnimating())