fix(ewmh): Check success of reply

This commit is contained in:
Michael Carlberg 2016-11-26 09:51:06 +01:00
parent 3413c4a463
commit 0d4a24ef8e
2 changed files with 16 additions and 9 deletions

View File

@ -44,7 +44,7 @@ namespace modules {
if (!ewmh_util::supports(m_ewmh.get(), m_ewmh->_NET_DESKTOP_VIEWPORT) && m_pinworkspaces) { if (!ewmh_util::supports(m_ewmh.get(), m_ewmh->_NET_DESKTOP_VIEWPORT) && m_pinworkspaces) {
throw module_error("The WM does not support _NET_DESKTOP_VIEWPORT (required when `pin-workspaces = true`)"); throw module_error("The WM does not support _NET_DESKTOP_VIEWPORT (required when `pin-workspaces = true`)");
} else if (!m_pinworkspaces) { } else if (!m_pinworkspaces) {
m_monitorsupport = true; m_monitorsupport = false;
} }
// Get list of monitors // Get list of monitors

View File

@ -83,10 +83,12 @@ namespace ewmh_util {
} }
vector<position> get_desktop_viewports(xcb_ewmh_connection_t* conn, int screen) { vector<position> get_desktop_viewports(xcb_ewmh_connection_t* conn, int screen) {
xcb_ewmh_get_desktop_viewport_reply_t reply;
xcb_ewmh_get_desktop_viewport_reply(conn, xcb_ewmh_get_desktop_viewport(conn, screen), &reply, nullptr);
vector<position> viewports; vector<position> viewports;
xcb_ewmh_get_desktop_viewport_reply_t reply;
if (!xcb_ewmh_get_desktop_viewport_reply(conn, xcb_ewmh_get_desktop_viewport(conn, screen), &reply, nullptr)) {
return viewports;
}
for (size_t n = 0; n < reply.desktop_viewport_len; n++) { for (size_t n = 0; n < reply.desktop_viewport_len; n++) {
viewports.emplace_back(position{static_cast<int16_t>(reply.desktop_viewport[n].x), static_cast<int16_t>(reply.desktop_viewport[n].y)}); viewports.emplace_back(position{static_cast<int16_t>(reply.desktop_viewport[n].x), static_cast<int16_t>(reply.desktop_viewport[n].y)});
@ -96,10 +98,13 @@ namespace ewmh_util {
} }
vector<string> get_desktop_names(xcb_ewmh_connection_t* conn, int screen) { vector<string> get_desktop_names(xcb_ewmh_connection_t* conn, int screen) {
xcb_ewmh_get_utf8_strings_reply_t reply;
xcb_ewmh_get_desktop_names_reply(conn, xcb_ewmh_get_desktop_names(conn, screen), &reply, nullptr);
vector<string> names; vector<string> names;
xcb_ewmh_get_utf8_strings_reply_t reply;
if (!xcb_ewmh_get_desktop_names_reply(conn, xcb_ewmh_get_desktop_names(conn, screen), &reply, nullptr)) {
return names;
}
char buffer[BUFSIZ]; char buffer[BUFSIZ];
size_t len{0}; size_t len{0};
@ -120,8 +125,10 @@ namespace ewmh_util {
} }
xcb_window_t get_active_window(xcb_ewmh_connection_t* conn, int screen) { xcb_window_t get_active_window(xcb_ewmh_connection_t* conn, int screen) {
xcb_window_t win{XCB_NONE}; xcb_window_t win{0};
xcb_ewmh_get_active_window_reply(conn, xcb_ewmh_get_active_window(conn, screen), &win, nullptr); if (!xcb_ewmh_get_active_window_reply(conn, xcb_ewmh_get_active_window(conn, screen), &win, nullptr)) {
return XCB_NONE;
}
return win; return win;
} }
} }