[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kde-workspace/frameworks-scratch] kwin: Introduce a wrapper class for InternAtom
From: Martin_Gräßlin <mgraesslin () kde ! org>
Date: 2013-09-10 13:31:08
Message-ID: E1VJO28-0002fr-Fv () scm ! kde ! org
[Download RAW message or body]
Git commit 6c04b1cc76282ed64f80fb08f9fbc0a252298b6b by Martin Gräßlin.
Committed on 10/09/2013 at 11:06.
Pushed by graesslin into branch 'frameworks-scratch'.
Introduce a wrapper class for InternAtom
Not extending Xcb::Wrapper as it does not operate on a window.
Instead it is a specified class for the specific usecase.
M +43 -0 kwin/xcbutils.h
http://commits.kde.org/kde-workspace/6c04b1cc76282ed64f80fb08f9fbc0a252298b6b
diff --git a/kwin/xcbutils.h b/kwin/xcbutils.h
index 047885e..9495d89 100644
--- a/kwin/xcbutils.h
+++ b/kwin/xcbutils.h
@@ -159,6 +159,49 @@ private:
Reply *m_reply;
};
+class Atom
+{
+public:
+ explicit Atom(const QByteArray &name, bool onlyIfExists = false)
+ : m_retrieved(false)
+ , m_cookie(xcb_intern_atom_unchecked(connection(), onlyIfExists, \
name.length(), name.constData())) + , m_atom(XCB_ATOM_NONE)
+ , m_name(name)
+ {
+ }
+
+ ~Atom() {
+ if (!m_retrieved && m_cookie.sequence) {
+ xcb_discard_reply(connection(), m_cookie.sequence);
+ }
+ }
+
+ operator xcb_atom_t() const {
+ (const_cast<Atom*>(this))->getReply();
+ return m_atom;
+ }
+
+ inline const QByteArray &name() const {
+ return m_name;
+ }
+
+private:
+ void getReply() {
+ if (m_retrieved || !m_cookie.sequence) {
+ return;
+ }
+ ScopedCPointer<xcb_intern_atom_reply_t> \
reply(xcb_intern_atom_reply(connection(), m_cookie, nullptr)); + if \
(!reply.isNull()) { + m_atom = reply->atom;
+ }
+ m_retrieved = true;
+ }
+ bool m_retrieved;
+ xcb_intern_atom_cookie_t m_cookie;
+ xcb_atom_t m_atom;
+ QByteArray m_name;
+};
+
typedef Wrapper<xcb_get_window_attributes_reply_t, \
xcb_get_window_attributes_cookie_t, &xcb_get_window_attributes_reply, \
&xcb_get_window_attributes_unchecked> WindowAttributes; typedef \
Wrapper<xcb_composite_get_overlay_window_reply_t, \
xcb_composite_get_overlay_window_cookie_t, &xcb_composite_get_overlay_window_reply, \
&xcb_composite_get_overlay_window_unchecked> OverlayWindow;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic