Skip to content

Commit

Permalink
Standalone compositor 4. #1
Browse files Browse the repository at this point in the history
  • Loading branch information
jaelpark committed Jan 31, 2023
1 parent 037e757 commit 283b32a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 34 deletions.
8 changes: 5 additions & 3 deletions src/backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
18 changes: 0 additions & 18 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,24 +425,6 @@ ContainerConfig::~ContainerConfig(){
pcontainerInt->pcontainer = 0;
}

/*template<typename T>
BackendContainerConfig<T>::BackendContainerConfig(ContainerInterface *_pcontainerInt, WManager::Container *_pParent, const WManager::Container::Setup &_setup, Backend::X11Backend *_pbackend) : T(_pParent,_setup,_pbackend), ContainerConfig(_pcontainerInt){
//
}
template<typename T>
BackendContainerConfig<T>::BackendContainerConfig(Backend::X11Backend *_pbackend) : T(_pbackend), ContainerConfig(){
//
pcontainerInt->pcontainer = this;
}
template<typename T>
BackendContainerConfig<T>::~BackendContainerConfig(){
//
}
class template BackendContainerConfig<Backend::X11Container>;*/

X11ContainerConfig::X11ContainerConfig(ContainerInterface *_pcontainerInt, WManager::Container *_pParent, const WManager::Container::Setup &_setup, Backend::X11Backend *_pbackend) : Backend::X11Container(_pParent,_setup,_pbackend), ContainerConfig(_pcontainerInt,_pbackend){
//
}
Expand Down
37 changes: 24 additions & 13 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include <args.hxx>
#include <iostream>
#include <csignal>

#include <boost/filesystem.hpp>
#include <wordexp.h>
Expand Down Expand Up @@ -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<const WManager::Client *, WManager::Client *> StackAppendixElement;
class RunCompositor : public Config::CompositorConfig{
public:
Expand Down Expand Up @@ -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<const Config::ContainerConfig *>(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;
Expand All @@ -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<const Config::ContainerConfig *>(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{
Expand Down Expand Up @@ -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<Config::X11ContainerConfig,DefaultBackend>(&containerCreateInfo);

containerInt.OnSetupClient();
Expand Down Expand Up @@ -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())
Expand Down

0 comments on commit 283b32a

Please sign in to comment.