mirror of
https://git.outfoxxed.me/quickshell/quickshell.git
synced 2025-11-06 19:14:57 +11:00
x11: add XPanelWindow
This commit is contained in:
parent
908ba3eef5
commit
73cfeba61b
15 changed files with 804 additions and 5 deletions
55
src/x11/util.cpp
Normal file
55
src/x11/util.cpp
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
#include "util.hpp"
|
||||
|
||||
#include <qbytearray.h>
|
||||
#include <qguiapplication.h>
|
||||
#include <qguiapplication_platform.h>
|
||||
#include <xcb/xcb.h>
|
||||
#include <xcb/xproto.h>
|
||||
|
||||
xcb_connection_t* x11Connection() {
|
||||
static xcb_connection_t* conn = nullptr; // NOLINT
|
||||
|
||||
if (conn == nullptr) {
|
||||
if (auto* x11Application = dynamic_cast<QGuiApplication*>(QGuiApplication::instance())
|
||||
->nativeInterface<QNativeInterface::QX11Application>())
|
||||
{
|
||||
conn = x11Application->connection();
|
||||
}
|
||||
}
|
||||
|
||||
return conn;
|
||||
}
|
||||
|
||||
// NOLINTBEGIN
|
||||
XAtom XAtom::_NET_WM_STRUT {};
|
||||
XAtom XAtom::_NET_WM_STRUT_PARTIAL {};
|
||||
// NOLINTEND
|
||||
|
||||
void XAtom::initAtoms() {
|
||||
_NET_WM_STRUT.init("_NET_WM_STRUT");
|
||||
_NET_WM_STRUT_PARTIAL.init("_NET_WM_STRUT_PARTIAL");
|
||||
}
|
||||
|
||||
void XAtom::init(const QByteArray& name) {
|
||||
this->cookie = xcb_intern_atom(x11Connection(), 0, name.length(), name.data());
|
||||
}
|
||||
|
||||
bool XAtom::isValid() {
|
||||
this->resolve();
|
||||
return this->mAtom != XCB_ATOM_NONE;
|
||||
}
|
||||
|
||||
const xcb_atom_t& XAtom::atom() {
|
||||
this->resolve();
|
||||
return this->mAtom;
|
||||
}
|
||||
|
||||
void XAtom::resolve() {
|
||||
if (!this->resolved) {
|
||||
this->resolved = true;
|
||||
|
||||
auto* reply = xcb_intern_atom_reply(x11Connection(), this->cookie, nullptr);
|
||||
if (reply != nullptr) this->mAtom = reply->atom;
|
||||
free(reply); // NOLINT
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue