feat: 实现StartManager功能
实现StartManager功能, 曝露在ApplicationManager服务上 Log: 实现StartManager功能 Task: https://pms.uniontech.com/task-view-130337.html Influence: 无 Change-Id: I8e83a66f8c25b09e0f4be1e4be9defac95b02b80
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
@ -26,46 +26,46 @@
|
||||
|
||||
XCBUtils::XCBUtils()
|
||||
{
|
||||
connect = xcb_connect(nullptr, &screenNum); // nullptr表示默认使用环境变量$DISPLAY获取屏幕
|
||||
if (xcb_connection_has_error(connect)) {
|
||||
m_connect = xcb_connect(nullptr, &m_screenNum); // nullptr表示默认使用环境变量$DISPLAY获取屏幕
|
||||
if (xcb_connection_has_error(m_connect)) {
|
||||
std::cout << "XCBUtils: init xcb_connect error" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!xcb_ewmh_init_atoms_replies(&ewmh,
|
||||
xcb_ewmh_init_atoms(connect, &ewmh), // 初始化Atom
|
||||
if (!xcb_ewmh_init_atoms_replies(&m_ewmh,
|
||||
xcb_ewmh_init_atoms(m_connect, &m_ewmh), // 初始化Atom
|
||||
nullptr))
|
||||
std::cout << "XCBUtils: init ewmh error" << std::endl;
|
||||
}
|
||||
|
||||
XCBUtils::~XCBUtils()
|
||||
{
|
||||
if (connect) {
|
||||
xcb_disconnect(connect); // 关闭连接并释放
|
||||
connect = nullptr;
|
||||
if (m_connect) {
|
||||
xcb_disconnect(m_connect); // 关闭连接并释放
|
||||
m_connect = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
XWindow XCBUtils::allocId()
|
||||
{
|
||||
return xcb_generate_id(connect);
|
||||
return xcb_generate_id(m_connect);
|
||||
}
|
||||
|
||||
void XCBUtils::killClientChecked(XWindow xid)
|
||||
{
|
||||
xcb_kill_client_checked(connect, xid);
|
||||
xcb_kill_client_checked(m_connect, xid);
|
||||
}
|
||||
|
||||
xcb_get_property_reply_t *XCBUtils::getPropertyValueReply(XWindow xid, XCBAtom property, XCBAtom type)
|
||||
{
|
||||
xcb_get_property_cookie_t cookie = xcb_get_property(connect,
|
||||
xcb_get_property_cookie_t cookie = xcb_get_property(m_connect,
|
||||
0,
|
||||
xid,
|
||||
property,
|
||||
type,
|
||||
0,
|
||||
MAXLEN);
|
||||
return xcb_get_property_reply(connect, cookie, nullptr);
|
||||
return xcb_get_property_reply(m_connect, cookie, nullptr);
|
||||
}
|
||||
|
||||
void *XCBUtils::getPropertyValue(XWindow xid, XCBAtom property, XCBAtom type)
|
||||
@ -84,7 +84,7 @@ void *XCBUtils::getPropertyValue(XWindow xid, XCBAtom property, XCBAtom type)
|
||||
std::string XCBUtils::getUTF8PropertyStr(XWindow xid, XCBAtom property)
|
||||
{
|
||||
std::string ret;
|
||||
xcb_get_property_reply_t *reply = getPropertyValueReply(xid, property, ewmh.UTF8_STRING);
|
||||
xcb_get_property_reply_t *reply = getPropertyValueReply(xid, property, m_ewmh.UTF8_STRING);
|
||||
if (reply) {
|
||||
ret = getUTF8StrFromReply(reply);
|
||||
|
||||
@ -95,14 +95,14 @@ std::string XCBUtils::getUTF8PropertyStr(XWindow xid, XCBAtom property)
|
||||
|
||||
XCBAtom XCBUtils::getAtom(const char *name)
|
||||
{
|
||||
XCBAtom ret = atomCache.getVal(name);
|
||||
XCBAtom ret = m_atomCache.getVal(name);
|
||||
if (ret == ATOMNONE) {
|
||||
xcb_intern_atom_cookie_t cookie = xcb_intern_atom(connect, false, strlen(name), name);
|
||||
xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply (connect,
|
||||
xcb_intern_atom_cookie_t cookie = xcb_intern_atom(m_connect, false, strlen(name), name);
|
||||
xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply (m_connect,
|
||||
cookie,
|
||||
nullptr);
|
||||
if (reply) {
|
||||
atomCache.store(name, reply->atom);
|
||||
m_atomCache.store(name, reply->atom);
|
||||
ret = reply->atom;
|
||||
|
||||
free(reply);
|
||||
@ -114,16 +114,16 @@ XCBAtom XCBUtils::getAtom(const char *name)
|
||||
|
||||
std::string XCBUtils::getAtomName(XCBAtom atom)
|
||||
{
|
||||
std::string ret = atomCache.getName(atom);
|
||||
std::string ret = m_atomCache.getName(atom);
|
||||
if (ret.empty()) {
|
||||
xcb_get_atom_name_cookie_t cookie = xcb_get_atom_name(connect, atom);
|
||||
xcb_get_atom_name_reply_t *reply = xcb_get_atom_name_reply(connect,
|
||||
xcb_get_atom_name_cookie_t cookie = xcb_get_atom_name(m_connect, atom);
|
||||
xcb_get_atom_name_reply_t *reply = xcb_get_atom_name_reply(m_connect,
|
||||
cookie,
|
||||
nullptr);
|
||||
if (reply) {
|
||||
char *name = xcb_get_atom_name_name(reply);
|
||||
if (name) {
|
||||
atomCache.store(name, atom);
|
||||
m_atomCache.store(name, atom);
|
||||
ret = name;
|
||||
}
|
||||
|
||||
@ -137,8 +137,8 @@ std::string XCBUtils::getAtomName(XCBAtom atom)
|
||||
Geometry XCBUtils::getWindowGeometry(XWindow xid)
|
||||
{
|
||||
Geometry ret;
|
||||
xcb_get_geometry_cookie_t cookie = xcb_get_geometry(connect, xid);
|
||||
xcb_get_geometry_reply_t *reply = xcb_get_geometry_reply(connect, cookie, nullptr);
|
||||
xcb_get_geometry_cookie_t cookie = xcb_get_geometry(m_connect, xid);
|
||||
xcb_get_geometry_reply_t *reply = xcb_get_geometry_reply(m_connect, cookie, nullptr);
|
||||
if (reply) {
|
||||
ret.x = reply->x;
|
||||
ret.y = reply->y;
|
||||
@ -156,8 +156,8 @@ Geometry XCBUtils::getWindowGeometry(XWindow xid)
|
||||
XWindow XCBUtils::getActiveWindow()
|
||||
{
|
||||
XWindow ret;
|
||||
xcb_get_property_cookie_t cookie = xcb_ewmh_get_active_window(&ewmh, screenNum);
|
||||
if (!xcb_ewmh_get_active_window_reply(&ewmh, cookie, &ret, nullptr))
|
||||
xcb_get_property_cookie_t cookie = xcb_ewmh_get_active_window(&m_ewmh, m_screenNum);
|
||||
if (!xcb_ewmh_get_active_window_reply(&m_ewmh, cookie, &ret, nullptr))
|
||||
std::cout << "getActiveWindow error" << std::endl;
|
||||
|
||||
return ret;
|
||||
@ -165,15 +165,15 @@ XWindow XCBUtils::getActiveWindow()
|
||||
|
||||
void XCBUtils::setActiveWindow(XWindow xid)
|
||||
{
|
||||
xcb_ewmh_set_active_window(&ewmh, screenNum, xid);
|
||||
xcb_ewmh_set_active_window(&m_ewmh, m_screenNum, xid);
|
||||
}
|
||||
|
||||
std::list<XWindow> XCBUtils::getClientList()
|
||||
{
|
||||
std::list<XWindow> ret;
|
||||
xcb_get_property_cookie_t cookie = xcb_ewmh_get_client_list(&ewmh, screenNum);
|
||||
xcb_get_property_cookie_t cookie = xcb_ewmh_get_client_list(&m_ewmh, m_screenNum);
|
||||
xcb_ewmh_get_windows_reply_t reply;
|
||||
if (!xcb_ewmh_get_client_list_reply(&ewmh, cookie, &reply, nullptr))
|
||||
if (!xcb_ewmh_get_client_list_reply(&m_ewmh, cookie, &reply, nullptr))
|
||||
std::cout << "getClientList error" << std::endl;
|
||||
|
||||
for (uint32_t i = 0; i < reply.windows_len; i++)
|
||||
@ -185,9 +185,9 @@ std::list<XWindow> XCBUtils::getClientList()
|
||||
std::list<XWindow> XCBUtils::getClientListStacking()
|
||||
{
|
||||
std::list<XWindow> ret;
|
||||
xcb_get_property_cookie_t cookie = xcb_ewmh_get_client_list_stacking(&ewmh, screenNum);
|
||||
xcb_get_property_cookie_t cookie = xcb_ewmh_get_client_list_stacking(&m_ewmh, m_screenNum);
|
||||
xcb_ewmh_get_windows_reply_t reply;
|
||||
if (!xcb_ewmh_get_client_list_stacking_reply(&ewmh, cookie, &reply, nullptr))
|
||||
if (!xcb_ewmh_get_client_list_stacking_reply(&m_ewmh, cookie, &reply, nullptr))
|
||||
std::cout << "getClientListStacking error" << std::endl;
|
||||
|
||||
for (uint32_t i = 0; i < reply.windows_len; i++)
|
||||
@ -199,9 +199,9 @@ std::list<XWindow> XCBUtils::getClientListStacking()
|
||||
std::vector<XCBAtom> XCBUtils::getWMState(XWindow xid)
|
||||
{
|
||||
std::vector<XCBAtom> ret;
|
||||
xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_state(&ewmh, xid);
|
||||
xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_state(&m_ewmh, xid);
|
||||
xcb_ewmh_get_atoms_reply_t reply; // a list of Atom
|
||||
if (xcb_ewmh_get_wm_state_reply(&ewmh, cookie, &reply, nullptr)) {
|
||||
if (xcb_ewmh_get_wm_state_reply(&m_ewmh, cookie, &reply, nullptr)) {
|
||||
for (uint32_t i = 0; i < reply.atoms_len; i++) {
|
||||
ret.push_back(reply.atoms[i]);
|
||||
}
|
||||
@ -215,9 +215,9 @@ std::vector<XCBAtom> XCBUtils::getWMState(XWindow xid)
|
||||
std::vector<XCBAtom> XCBUtils::getWMWindoType(XWindow xid)
|
||||
{
|
||||
std::vector<XCBAtom> ret;
|
||||
xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_window_type(&ewmh, xid);
|
||||
xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_window_type(&m_ewmh, xid);
|
||||
xcb_ewmh_get_atoms_reply_t reply; // a list of Atom
|
||||
if (!xcb_ewmh_get_wm_window_type_reply(&ewmh, cookie, &reply, nullptr))
|
||||
if (!xcb_ewmh_get_wm_window_type_reply(&m_ewmh, cookie, &reply, nullptr))
|
||||
std::cout << xid << " getWMWindoType error" << std::endl;
|
||||
|
||||
return ret;
|
||||
@ -226,9 +226,9 @@ std::vector<XCBAtom> XCBUtils::getWMWindoType(XWindow xid)
|
||||
std::vector<XCBAtom> XCBUtils::getWMAllowedActions(XWindow xid)
|
||||
{
|
||||
std::vector<XCBAtom> ret;
|
||||
xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_allowed_actions(&ewmh, xid);
|
||||
xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_allowed_actions(&m_ewmh, xid);
|
||||
xcb_ewmh_get_atoms_reply_t reply; // a list of Atoms
|
||||
if (!xcb_ewmh_get_wm_allowed_actions_reply(&ewmh, cookie, &reply, nullptr))
|
||||
if (!xcb_ewmh_get_wm_allowed_actions_reply(&m_ewmh, cookie, &reply, nullptr))
|
||||
std::cout << xid << " getWMAllowedActions error" << std::endl;
|
||||
|
||||
for (uint32_t i = 0; i < reply.atoms_len; i++) {
|
||||
@ -244,15 +244,15 @@ void XCBUtils::setWMAllowedActions(XWindow xid, std::vector<XCBAtom> actions)
|
||||
for (size_t i = 0; i < actions.size(); i++)
|
||||
list[i] = actions[i];
|
||||
|
||||
xcb_ewmh_set_wm_allowed_actions(&ewmh, xid, actions.size(), list);
|
||||
xcb_ewmh_set_wm_allowed_actions(&m_ewmh, xid, actions.size(), list);
|
||||
}
|
||||
|
||||
std::string XCBUtils::getWMName(XWindow xid)
|
||||
{
|
||||
std::string ret;
|
||||
xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_name(&ewmh, xid);
|
||||
xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_name(&m_ewmh, xid);
|
||||
xcb_ewmh_get_utf8_strings_reply_t reply1;
|
||||
if (!xcb_ewmh_get_wm_name_reply(&ewmh, cookie, &reply1, nullptr))
|
||||
if (!xcb_ewmh_get_wm_name_reply(&m_ewmh, cookie, &reply1, nullptr))
|
||||
std::cout << xid << " getWMName error" << std::endl;
|
||||
|
||||
ret.assign(reply1.strings);
|
||||
@ -263,8 +263,8 @@ std::string XCBUtils::getWMName(XWindow xid)
|
||||
uint32_t XCBUtils::getWMPid(XWindow xid)
|
||||
{
|
||||
uint32_t ret = 0;
|
||||
xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_pid(&ewmh, xid);
|
||||
if (!xcb_ewmh_get_wm_pid_reply(&ewmh, cookie, &ret, nullptr))
|
||||
xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_pid(&m_ewmh, xid);
|
||||
if (!xcb_ewmh_get_wm_pid_reply(&m_ewmh, cookie, &ret, nullptr))
|
||||
std::cout << xid << " getWMPid error" << std::endl;
|
||||
|
||||
return ret;
|
||||
@ -273,9 +273,9 @@ uint32_t XCBUtils::getWMPid(XWindow xid)
|
||||
std::string XCBUtils::getWMIconName(XWindow xid)
|
||||
{
|
||||
std::string ret;
|
||||
xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_icon_name(&ewmh, xid);
|
||||
xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_icon_name(&m_ewmh, xid);
|
||||
xcb_ewmh_get_utf8_strings_reply_t reply;
|
||||
if (!xcb_ewmh_get_wm_icon_name_reply(&ewmh, cookie, &reply, nullptr))
|
||||
if (!xcb_ewmh_get_wm_icon_name_reply(&m_ewmh, cookie, &reply, nullptr))
|
||||
std::cout << xid << " getWMIconName error" << std::endl;
|
||||
|
||||
ret.assign(reply.strings);
|
||||
@ -326,14 +326,14 @@ XWindow XCBUtils::getWMClientLeader(XWindow xid)
|
||||
|
||||
void XCBUtils::requestCloseWindow(XWindow xid, uint32_t timestamp)
|
||||
{
|
||||
xcb_ewmh_request_close_window(&ewmh, screenNum, xid, timestamp, XCB_EWMH_CLIENT_SOURCE_TYPE_OTHER);
|
||||
xcb_ewmh_request_close_window(&m_ewmh, m_screenNum, xid, timestamp, XCB_EWMH_CLIENT_SOURCE_TYPE_OTHER);
|
||||
}
|
||||
|
||||
uint32_t XCBUtils::getWMDesktop(XWindow xid)
|
||||
{
|
||||
uint32_t ret;
|
||||
xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_desktop(&ewmh, xid);
|
||||
if (!xcb_ewmh_get_wm_desktop_reply(&ewmh, cookie, &ret, nullptr))
|
||||
xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_desktop(&m_ewmh, xid);
|
||||
if (!xcb_ewmh_get_wm_desktop_reply(&m_ewmh, cookie, &ret, nullptr))
|
||||
std::cout << xid << " getWMDesktop error" << std::endl;
|
||||
|
||||
return ret;
|
||||
@ -341,19 +341,19 @@ uint32_t XCBUtils::getWMDesktop(XWindow xid)
|
||||
|
||||
void XCBUtils::setWMDesktop(XWindow xid, uint32_t desktop)
|
||||
{
|
||||
xcb_ewmh_set_wm_desktop(&ewmh, xid, desktop);
|
||||
xcb_ewmh_set_wm_desktop(&m_ewmh, xid, desktop);
|
||||
}
|
||||
|
||||
void XCBUtils::setCurrentWMDesktop(uint32_t desktop)
|
||||
{
|
||||
xcb_ewmh_set_current_desktop(&ewmh, screenNum, desktop);
|
||||
xcb_ewmh_set_current_desktop(&m_ewmh, m_screenNum, desktop);
|
||||
}
|
||||
|
||||
uint32_t XCBUtils::getCurrentWMDesktop()
|
||||
{
|
||||
uint32_t ret;
|
||||
xcb_get_property_cookie_t cookie = xcb_ewmh_get_current_desktop(&ewmh, screenNum);
|
||||
if (!xcb_ewmh_get_current_desktop_reply(&ewmh, cookie, &ret, nullptr))
|
||||
xcb_get_property_cookie_t cookie = xcb_ewmh_get_current_desktop(&m_ewmh, m_screenNum);
|
||||
if (!xcb_ewmh_get_current_desktop_reply(&m_ewmh, cookie, &ret, nullptr))
|
||||
std::cout << "getCurrentWMDesktop error" << std::endl;
|
||||
|
||||
return ret;
|
||||
@ -362,9 +362,9 @@ uint32_t XCBUtils::getCurrentWMDesktop()
|
||||
bool XCBUtils::isGoodWindow(XWindow xid)
|
||||
{
|
||||
bool ret = false;
|
||||
xcb_get_geometry_cookie_t cookie = xcb_get_geometry(connect, xid);
|
||||
xcb_get_geometry_cookie_t cookie = xcb_get_geometry(m_connect, xid);
|
||||
xcb_generic_error_t **errStore = nullptr;
|
||||
xcb_get_geometry_reply_t *reply = xcb_get_geometry_reply(connect, cookie, errStore);
|
||||
xcb_get_geometry_reply_t *reply = xcb_get_geometry_reply(m_connect, cookie, errStore);
|
||||
if (reply) {
|
||||
if (!errStore) // 正常获取窗口geometry则判定为good
|
||||
ret = true;
|
||||
@ -392,8 +392,8 @@ bool XCBUtils::hasXEmbedInfo(XWindow xid)
|
||||
XWindow XCBUtils::getWMTransientFor(XWindow xid)
|
||||
{
|
||||
XWindow ret;
|
||||
xcb_get_property_cookie_t cookie = xcb_icccm_get_wm_transient_for(connect, xid);
|
||||
if (!xcb_icccm_get_wm_transient_for_reply(connect, cookie, &ret, nullptr))
|
||||
xcb_get_property_cookie_t cookie = xcb_icccm_get_wm_transient_for(m_connect, xid);
|
||||
if (!xcb_icccm_get_wm_transient_for_reply(m_connect, cookie, &ret, nullptr))
|
||||
std::cout << xid << " getWMTransientFor error" << std::endl;
|
||||
|
||||
return ret;
|
||||
@ -402,8 +402,8 @@ XWindow XCBUtils::getWMTransientFor(XWindow xid)
|
||||
uint32_t XCBUtils::getWMUserTime(XWindow xid)
|
||||
{
|
||||
uint32_t ret;
|
||||
xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_user_time(&ewmh, xid);
|
||||
if (!xcb_ewmh_get_wm_user_time_reply(&ewmh, cookie, &ret, nullptr))
|
||||
xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_user_time(&m_ewmh, xid);
|
||||
if (!xcb_ewmh_get_wm_user_time_reply(&m_ewmh, cookie, &ret, nullptr))
|
||||
std::cout << xid << " getWMUserTime error" << std::endl;
|
||||
|
||||
return ret;
|
||||
@ -412,8 +412,8 @@ uint32_t XCBUtils::getWMUserTime(XWindow xid)
|
||||
int XCBUtils::getWMUserTimeWindow(XWindow xid)
|
||||
{
|
||||
XCBAtom ret;
|
||||
xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_user_time_window(&ewmh, xid);
|
||||
if (!xcb_ewmh_get_wm_user_time_window_reply(&ewmh, cookie, &ret, NULL))
|
||||
xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_user_time_window(&m_ewmh, xid);
|
||||
if (!xcb_ewmh_get_wm_user_time_window_reply(&m_ewmh, cookie, &ret, NULL))
|
||||
std::cout << xid << " getWMUserTimeWindow error" << std::endl;
|
||||
|
||||
return ret;
|
||||
@ -422,9 +422,9 @@ int XCBUtils::getWMUserTimeWindow(XWindow xid)
|
||||
WMClass XCBUtils::getWMClass(XWindow xid)
|
||||
{
|
||||
WMClass ret;
|
||||
xcb_get_property_cookie_t cookie = xcb_icccm_get_wm_class(connect, xid);
|
||||
xcb_get_property_cookie_t cookie = xcb_icccm_get_wm_class(m_connect, xid);
|
||||
xcb_icccm_get_wm_class_reply_t reply;
|
||||
if (!xcb_icccm_get_wm_class_reply(connect, cookie, &reply, nullptr)) {
|
||||
if (!xcb_icccm_get_wm_class_reply(m_connect, cookie, &reply, nullptr)) {
|
||||
if (reply.class_name)
|
||||
ret.className.assign(reply.class_name);
|
||||
|
||||
@ -442,18 +442,18 @@ WMClass XCBUtils::getWMClass(XWindow xid)
|
||||
// TODO
|
||||
void XCBUtils::minimizeWindow(XWindow xid)
|
||||
{
|
||||
xcb_get_property_cookie_t cookie = xcb_icccm_get_wm_hints(connect, xid);
|
||||
xcb_get_property_cookie_t cookie = xcb_icccm_get_wm_hints(m_connect, xid);
|
||||
xcb_icccm_wm_hints_t *hints = new xcb_icccm_wm_hints_t; // 分配堆空间
|
||||
xcb_icccm_get_wm_hints_reply(connect, cookie, hints, nullptr);
|
||||
xcb_icccm_get_wm_hints_reply(m_connect, cookie, hints, nullptr);
|
||||
xcb_icccm_wm_hints_set_iconic(hints);
|
||||
xcb_icccm_set_wm_hints(connect, xid, hints);
|
||||
xcb_icccm_set_wm_hints(m_connect, xid, hints);
|
||||
free(hints);
|
||||
}
|
||||
|
||||
void XCBUtils::maxmizeWindow(XWindow xid)
|
||||
{
|
||||
xcb_ewmh_request_change_wm_state(&ewmh
|
||||
, screenNum
|
||||
xcb_ewmh_request_change_wm_state(&m_ewmh
|
||||
, m_screenNum
|
||||
, xid
|
||||
, XCB_EWMH_WM_STATE_ADD
|
||||
, getAtom("_NET_WM_STATE_MAXIMIZED_VERT")
|
||||
@ -465,7 +465,7 @@ void XCBUtils::maxmizeWindow(XWindow xid)
|
||||
std::vector<std::string> XCBUtils::getWMCommand(XWindow xid)
|
||||
{
|
||||
std::vector<std::string> ret;
|
||||
xcb_get_property_reply_t *reply = getPropertyValueReply(xid, XCB_ATOM_WM_COMMAND, ewmh.UTF8_STRING);
|
||||
xcb_get_property_reply_t *reply = getPropertyValueReply(xid, XCB_ATOM_WM_COMMAND, m_ewmh.UTF8_STRING);
|
||||
if (reply) {
|
||||
ret = getUTF8StrsFromReply(reply);
|
||||
free(reply);
|
||||
@ -519,7 +519,7 @@ XWindow XCBUtils::getRootWindow()
|
||||
{
|
||||
XWindow rootWindow = 0;
|
||||
/* Get the first screen */
|
||||
xcb_screen_t *screen = xcb_setup_roots_iterator(xcb_get_setup(connect)).data;
|
||||
xcb_screen_t *screen = xcb_setup_roots_iterator(xcb_get_setup(m_connect)).data;
|
||||
if (screen)
|
||||
rootWindow = screen->root;
|
||||
|
||||
@ -530,13 +530,13 @@ XWindow XCBUtils::getRootWindow()
|
||||
void XCBUtils::registerEvents(XWindow xid, uint32_t eventMask)
|
||||
{
|
||||
uint32_t value[1] = {eventMask};
|
||||
xcb_void_cookie_t cookie = xcb_change_window_attributes_checked(connect,
|
||||
xcb_void_cookie_t cookie = xcb_change_window_attributes_checked(m_connect,
|
||||
xid,
|
||||
XCB_CW_EVENT_MASK,
|
||||
&value);
|
||||
xcb_flush(connect);
|
||||
xcb_flush(m_connect);
|
||||
|
||||
xcb_generic_error_t *error = xcb_request_check(connect, cookie);
|
||||
xcb_generic_error_t *error = xcb_request_check(m_connect, cookie);
|
||||
if (error != nullptr) {
|
||||
std::cout << "window " << xid << "registerEvents error" << std::endl;
|
||||
}
|
||||
@ -550,8 +550,8 @@ AtomCache::AtomCache()
|
||||
XCBAtom AtomCache::getVal(std::string name)
|
||||
{
|
||||
XCBAtom atom = ATOMNONE;
|
||||
auto search = atoms.find(name);
|
||||
if (search != atoms.end())
|
||||
auto search = m_atoms.find(name);
|
||||
if (search != m_atoms.end())
|
||||
atom = search->second;
|
||||
|
||||
return atom;
|
||||
@ -560,8 +560,8 @@ XCBAtom AtomCache::getVal(std::string name)
|
||||
std::string AtomCache::getName(XCBAtom atom)
|
||||
{
|
||||
std::string ret;
|
||||
auto search = atomNames.find(atom);
|
||||
if (search != atomNames.end())
|
||||
auto search = m_atomNames.find(atom);
|
||||
if (search != m_atomNames.end())
|
||||
ret = search->second;
|
||||
|
||||
return ret;
|
||||
@ -569,6 +569,6 @@ std::string AtomCache::getName(XCBAtom atom)
|
||||
|
||||
void AtomCache::store(std::string name, XCBAtom value)
|
||||
{
|
||||
atoms[name] = value;
|
||||
atomNames[value] = name;
|
||||
m_atoms[name] = value;
|
||||
m_atomNames[value] = name;
|
||||
}
|
||||
|
Reference in New Issue
Block a user