diff --git a/config/config.py b/config/config.py index e944484..e60cbdc 100644 --- a/config/config.py +++ b/config/config.py @@ -654,6 +654,7 @@ def OnKeyRelease(self, keyId): self.shiftFocus = None; def OnTimer(self): + #NOTE: OnTimer() calls currently disabled. battery = psutil.sensors_battery(); try: if not battery.power_plugged: @@ -677,7 +678,9 @@ def OnTimer(self): self.batteryAlarmLevel = 0; class Compositor(chamfer.Compositor): - pass + def OnRedirectExternal(self, title, className): + #Used only in standalone compositor mode. Return False to filter out incompatible WM/UI components. + return True; backend = Backend(); chamfer.BindBackend(backend); diff --git a/src/backend.cpp b/src/backend.cpp index ad0a725..5335a6d 100644 --- a/src/backend.cpp +++ b/src/backend.cpp @@ -1359,7 +1359,13 @@ sint Default::HandleEvent(bool forcePoll){ if(!standaloneComp){ const WManager::Container *proot = pclient->pcontainer->GetRoot(); StackClients(proot); - }else{ + + netClientList.clear(); + for(auto &p : clients) + netClientList.push_back(p.first->window); + xcb_change_property(pcon,XCB_PROP_MODE_REPLACE,pscr->root,ewmh._NET_CLIENT_LIST,XCB_ATOM_WINDOW,32,netClientList.size(),netClientList.data()); + }else + if(ApproveExternal(&wmName,&wmClass)){ //clientStack won't get cleared in standalone compositor mode if(std::get<2>(*mrect) != 0){ //!= XCB_NONE auto m = std::find_if(clientStack.begin(),clientStack.end(),[&](auto &p)->bool{ @@ -1367,11 +1373,6 @@ sint Default::HandleEvent(bool forcePoll){ }); clientStack.insert(m+1,pclient); }else clientStack.push_front(pclient); - - netClientList.clear(); - for(auto &p : clients) - netClientList.push_back(p.first->window); - xcb_change_property(pcon,XCB_PROP_MODE_REPLACE,pscr->root,ewmh._NET_CLIENT_LIST,XCB_ATOM_WINDOW,32,netClientList.size(),netClientList.data()); } } diff --git a/src/backend.h b/src/backend.h index 2136d63..dc67083 100644 --- a/src/backend.h +++ b/src/backend.h @@ -178,6 +178,7 @@ friend class Compositor::TexturePixmap; }; virtual X11Client * FindClient(xcb_window_t, MODE) const = 0; virtual void TimerEvent() = 0; + virtual bool ApproveExternal(const BackendStringProperty *, const BackendStringProperty *) = 0; //void * GetProperty(xcb_atom_t, xcb_atom_t) const; //void FreeProperty(...) const; protected: diff --git a/src/config.cpp b/src/config.cpp index e8cbca6..6da4221 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -707,6 +707,10 @@ CompositorInterface::~CompositorInterface(){ // } +bool CompositorInterface::OnRedirectExternal(std::string title, std::string className){ + return true; +} + void CompositorInterface::Bind(boost::python::object obj){ CompositorInterface &compositorInt = boost::python::extract(obj)(); pcompositorInt = &compositorInt; @@ -724,6 +728,21 @@ CompositorProxy::~CompositorProxy(){ // } +bool CompositorProxy::OnRedirectExternal(std::string title, std::string className){ + boost::python::override ovr = this->get_override("OnRedirectExternal"); + if(ovr){ + try{ + return ovr(title,className); + }catch(boost::python::error_already_set &){ + PyErr_Print(); + // + boost::python::handle_exception(); + PyErr_Clear(); + } + } + return CompositorInterface::OnRedirectExternal(title,className); +} + CompositorConfig::CompositorConfig(CompositorInterface *_pcompositorInt) : pcompositorInt(_pcompositorInt){ pcompositorInt->pcompositor = this; } @@ -1126,6 +1145,7 @@ BOOST_PYTHON_MODULE(chamfer){ .value("USER_BIT",Compositor::ClientFrame::SHADER_FLAG_USER_BIT); boost::python::class_("Compositor") + .def("OnRedirectExternal",&CompositorInterface::OnRedirectExternal) .def_readwrite("deviceIndex",&CompositorInterface::deviceIndex) .def_readwrite("debugLayers",&CompositorInterface::debugLayers) .def_readwrite("scissoring",&CompositorInterface::scissoring) diff --git a/src/config.h b/src/config.h index 438e185..0a2a3e7 100644 --- a/src/config.h +++ b/src/config.h @@ -179,7 +179,8 @@ class BackendConfig{ class CompositorInterface{ public: CompositorInterface(); - ~CompositorInterface(); + virtual ~CompositorInterface(); + virtual bool OnRedirectExternal(std::string, std::string); sint deviceIndex; bool debugLayers; @@ -204,6 +205,7 @@ class CompositorProxy : public CompositorInterface, public boost::python::wrappe public: CompositorProxy(); ~CompositorProxy(); + bool OnRedirectExternal(std::string, std::string); }; class CompositorConfig{ diff --git a/src/main.cpp b/src/main.cpp index 99ab3d8..295a85b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -665,6 +665,10 @@ class DefaultBackend : public Backend::Default, public RunBackend{ // Config::BackendInterface::pbackendInt->OnTimer(); } + + bool ApproveExternal(const Backend::BackendStringProperty *pwmName, const Backend::BackendStringProperty *pwmClass){ + return Config::CompositorInterface::pcompositorInt->OnRedirectExternal(pwmName->pstr,pwmClass->pstr); + } }; //TODO: some of these functions can be templated and shared with the DefaultBackend @@ -785,6 +789,10 @@ class DebugBackend : public Backend::Debug, public RunBackend{ void TimerEvent(){ // } + + bool ApproveExternal(const Backend::BackendStringProperty *pwmName, const Backend::BackendStringProperty *pwmClass){ + return true; + } }; class DefaultCompositor : public Compositor::X11Compositor, public RunCompositor{