File indexing completed on 2024-05-05 05:39:02
0001 /* 0002 SPDX-FileCopyrightText: 2012, 2013 Martin Graesslin <mgraesslin@kde.org> 0003 SPDX-FileCopyrightText: 2015 David Edmudson <davidedmundson@kde.org> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #pragma once 0009 0010 #include <xcb/composite.h> 0011 #include <xcb/damage.h> 0012 #include <xcb/randr.h> 0013 #include <xcb/shm.h> 0014 #include <xcb/xcb.h> 0015 #include <xcb/xcb_atom.h> 0016 #include <xcb/xcb_event.h> 0017 0018 #include <QList> 0019 #include <private/qtx11extras_p.h> 0020 0021 #include "../c_ptr.h" 0022 0023 /** XEMBED messages */ 0024 #define XEMBED_EMBEDDED_NOTIFY 0 0025 #define XEMBED_WINDOW_ACTIVATE 1 0026 #define XEMBED_WINDOW_DEACTIVATE 2 0027 #define XEMBED_REQUEST_FOCUS 3 0028 #define XEMBED_FOCUS_IN 4 0029 #define XEMBED_FOCUS_OUT 5 0030 #define XEMBED_FOCUS_NEXT 6 0031 #define XEMBED_FOCUS_PREV 7 0032 0033 namespace Xcb 0034 { 0035 typedef xcb_window_t WindowId; 0036 0037 class Atom 0038 { 0039 public: 0040 explicit Atom(const QByteArray &name, bool onlyIfExists = false, xcb_connection_t *c = QX11Info::connection()) 0041 : m_connection(c) 0042 , m_retrieved(false) 0043 , m_cookie(xcb_intern_atom_unchecked(m_connection, onlyIfExists, name.length(), name.constData())) 0044 , m_atom(XCB_ATOM_NONE) 0045 , m_name(name) 0046 { 0047 } 0048 Atom() = delete; 0049 Atom(const Atom &) = delete; 0050 0051 ~Atom() 0052 { 0053 if (!m_retrieved && m_cookie.sequence) { 0054 xcb_discard_reply(m_connection, m_cookie.sequence); 0055 } 0056 } 0057 0058 operator xcb_atom_t() const 0059 { 0060 (const_cast<Atom *>(this))->getReply(); 0061 return m_atom; 0062 } 0063 bool isValid() 0064 { 0065 getReply(); 0066 return m_atom != XCB_ATOM_NONE; 0067 } 0068 bool isValid() const 0069 { 0070 (const_cast<Atom *>(this))->getReply(); 0071 return m_atom != XCB_ATOM_NONE; 0072 } 0073 0074 inline const QByteArray &name() const 0075 { 0076 return m_name; 0077 } 0078 0079 private: 0080 void getReply() 0081 { 0082 if (m_retrieved || !m_cookie.sequence) { 0083 return; 0084 } 0085 UniqueCPointer<xcb_intern_atom_reply_t> reply(xcb_intern_atom_reply(m_connection, m_cookie, nullptr)); 0086 if (reply) { 0087 m_atom = reply->atom; 0088 } 0089 m_retrieved = true; 0090 } 0091 xcb_connection_t *m_connection; 0092 bool m_retrieved; 0093 xcb_intern_atom_cookie_t m_cookie; 0094 xcb_atom_t m_atom; 0095 QByteArray m_name; 0096 }; 0097 0098 class Atoms 0099 { 0100 public: 0101 Atoms() 0102 : xembedAtom("_XEMBED") 0103 , selectionAtom(xcb_atom_name_by_screen("_NET_SYSTEM_TRAY", QX11Info::appScreen())) 0104 , opcodeAtom("_NET_SYSTEM_TRAY_OPCODE") 0105 , messageData("_NET_SYSTEM_TRAY_MESSAGE_DATA") 0106 , visualAtom("_NET_SYSTEM_TRAY_VISUAL") 0107 { 0108 } 0109 0110 Atom xembedAtom; 0111 Atom selectionAtom; 0112 Atom opcodeAtom; 0113 Atom messageData; 0114 Atom visualAtom; 0115 }; 0116 0117 extern Atoms *atoms; 0118 0119 } // namespace Xcb