[effects] Allow Built-In Effects using xcbutils.h
xcbutils.h has quite a few inline only implementations such as Xcb::Atom, the Wrappers, Xcb::Window and the convenient methods. Thus there is nothing wrong with using it from the built-in Effects. Xcb::Atom is used in Glide and Logout Effect to get the atom. To keep the logic of the existing code it got extended by a bool isValid() which gets the reply and returns true if the atom is set. REVIEW: 117587
This commit is contained in:
parent
336a870f5e
commit
c1b4167598
6 changed files with 23 additions and 20 deletions
|
@ -1,3 +1,5 @@
|
|||
include_directories(${KWIN_SOURCE_DIR}) # for xcbutils.h
|
||||
|
||||
set(kwin_effect_OWN_LIBS
|
||||
kwineffects
|
||||
)
|
||||
|
|
|
@ -32,18 +32,13 @@ namespace KWin
|
|||
{
|
||||
|
||||
static const int IsGlideWindow = 0x22A982D4;
|
||||
static xcb_atom_t slideAtom;
|
||||
static const QByteArray s_slideAtomName = QByteArrayLiteral("_KDE_SLIDE");
|
||||
|
||||
GlideEffect::GlideEffect()
|
||||
: Effect()
|
||||
, m_atom(QByteArrayLiteral("_KDE_SLIDE"))
|
||||
{
|
||||
slideAtom = XCB_ATOM_NONE;
|
||||
xcb_connection_t *c = xcbConnection();
|
||||
const auto cookie = xcb_intern_atom(c, false, s_slideAtomName.length(), s_slideAtomName.constData());
|
||||
QScopedPointer<xcb_intern_atom_reply_t, QScopedPointerPodDeleter> atom(xcb_intern_atom_reply(c, cookie, nullptr));
|
||||
if (atom) {
|
||||
slideAtom = atom->atom;
|
||||
effects->registerPropertyType( slideAtom, true );
|
||||
if (m_atom.isValid()) {
|
||||
effects->registerPropertyType( m_atom, true );
|
||||
}
|
||||
reconfigure(ReconfigureAll);
|
||||
connect(effects, SIGNAL(windowAdded(KWin::EffectWindow*)), this, SLOT(slotWindowAdded(KWin::EffectWindow*)));
|
||||
|
@ -53,8 +48,8 @@ GlideEffect::GlideEffect()
|
|||
|
||||
GlideEffect::~GlideEffect()
|
||||
{
|
||||
if (slideAtom) {
|
||||
effects->registerPropertyType( slideAtom, false );
|
||||
if (m_atom.isValid()) {
|
||||
effects->registerPropertyType( m_atom, false );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -219,7 +214,7 @@ bool GlideEffect::isGlideWindow(EffectWindow* w)
|
|||
return false;
|
||||
if (w->data(IsGlideWindow).toBool())
|
||||
return true;
|
||||
if (slideAtom && !w->readProperty( slideAtom, slideAtom, 32 ).isNull())
|
||||
if (m_atom.isValid() && !w->readProperty( m_atom, m_atom, 32 ).isNull())
|
||||
return false;
|
||||
if (w->hasDecoration())
|
||||
return true;
|
||||
|
|
|
@ -24,6 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#define KWIN_GLIDE_H
|
||||
|
||||
#include <kwineffects.h>
|
||||
#include <xcbutils.h>
|
||||
|
||||
class QTimeLine;
|
||||
|
||||
|
@ -74,6 +75,7 @@ private:
|
|||
void glideIn(EffectWindow* w, WindowPaintData& data, const InfoHash::const_iterator &info);
|
||||
void glideOut(EffectWindow* w, WindowPaintData& data, const InfoHash::const_iterator &info);
|
||||
bool isGlideWindow(EffectWindow* w);
|
||||
Xcb::Atom m_atom;
|
||||
InfoHash windows;
|
||||
float duration;
|
||||
int angle;
|
||||
|
|
|
@ -41,20 +41,15 @@ LogoutEffect::LogoutEffect()
|
|||
, logoutWindow(NULL)
|
||||
, logoutWindowClosed(true)
|
||||
, logoutWindowPassed(false)
|
||||
, logoutAtom(XCB_ATOM_NONE)
|
||||
, logoutAtom(QByteArrayLiteral("_KDE_LOGGING_OUT"))
|
||||
, canDoPersistent(false)
|
||||
, ignoredWindows()
|
||||
, m_vignettingShader(NULL)
|
||||
, m_blurShader(NULL)
|
||||
, m_shadersDir(QStringLiteral("kwin/shaders/1.10/"))
|
||||
{
|
||||
xcb_connection_t *c = xcbConnection();
|
||||
const QByteArray &name = QByteArrayLiteral("_KDE_LOGGING_OUT");
|
||||
const auto cookie = xcb_intern_atom(c, false, name.length(), name.constData());
|
||||
QScopedPointer<xcb_intern_atom_reply_t, QScopedPointerPodDeleter> atom(xcb_intern_atom_reply(c, cookie, nullptr));
|
||||
if (atom) {
|
||||
if (logoutAtom.isValid()) {
|
||||
// Persistent effect
|
||||
logoutAtom = atom->atom;
|
||||
effects->registerPropertyType(logoutAtom, true);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#define KWIN_LOGOUT_H
|
||||
|
||||
#include <kwineffects.h>
|
||||
#include <xcbutils.h>
|
||||
|
||||
|
||||
namespace KWin
|
||||
|
@ -69,7 +70,7 @@ private:
|
|||
bool logoutWindowPassed;
|
||||
|
||||
// Persistent effect
|
||||
xcb_atom_t logoutAtom;
|
||||
Xcb::Atom logoutAtom;
|
||||
bool canDoPersistent;
|
||||
EffectWindowList ignoredWindows;
|
||||
|
||||
|
|
|
@ -472,6 +472,14 @@ public:
|
|||
(const_cast<Atom*>(this))->getReply();
|
||||
return m_atom;
|
||||
}
|
||||
bool isValid() {
|
||||
getReply();
|
||||
return m_atom != XCB_ATOM_NONE;
|
||||
}
|
||||
bool isValid() const {
|
||||
(const_cast<Atom*>(this))->getReply();
|
||||
return m_atom != XCB_ATOM_NONE;
|
||||
}
|
||||
|
||||
inline const QByteArray &name() const {
|
||||
return m_name;
|
||||
|
|
Loading…
Reference in a new issue