Mercurial > minori
diff dep/animone/src/win/x11.cc @ 266:1a6a5d3a94cd
dep/animone: make bsd.cc and x11.cc actually work
apparently I broke these, and even now the x11 code *still* doesn't want
to work correctly (at least on FreeBSD). half of the PID response codes
are just 0 or the PID for the X server itself... wtf?
maybe dwm just doesn't support the XRes extension, or I'm just stupid.
i don't know.
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Thu, 11 Apr 2024 22:05:41 -0400 |
parents | 862d0d8619f6 |
children | a796e97cc86d |
line wrap: on
line diff
--- a/dep/animone/src/win/x11.cc Thu Apr 11 10:22:05 2024 -0400 +++ b/dep/animone/src/win/x11.cc Thu Apr 11 22:05:41 2024 -0400 @@ -53,8 +53,8 @@ std::unique_ptr<xcb_get_property_reply_t> reply(::xcb_get_property_reply(connection, cookie, NULL)); if (reply) { - xcb_window_t* value = reinterpret_cast<xcb_window_t*>(::xcb_get_property_value(reply)); - int len = ::xcb_get_property_value_length(reply); + xcb_window_t* value = reinterpret_cast<xcb_window_t*>(::xcb_get_property_value(reply.get())); + int len = ::xcb_get_property_value_length(reply.get()); for (size_t i = 0; i < len; i++) result.insert(value[i]); @@ -74,7 +74,7 @@ static bool WalkWindows(xcb_connection_t* connection, int depth, xcb_atom_t Atom_WM_STATE, const xcb_window_t* windows, int windows_len, std::set<xcb_window_t>& result) { /* The depth we should start returning at. */ - static constexpr int CUTOFF = 2; + static constexpr int CUTOFF = 1; bool success = false; @@ -87,8 +87,8 @@ for (const auto& cookie : cookies) { std::unique_ptr<xcb_query_tree_reply_t> query_tree_reply(::xcb_query_tree_reply(connection, cookie, NULL)); - xcb_window_t* tree_children = ::xcb_query_tree_children(query_tree_reply); - int tree_children_len = ::xcb_query_tree_children_length(query_tree_reply); + xcb_window_t* tree_children = ::xcb_query_tree_children(query_tree_reply.get()); + int tree_children_len = ::xcb_query_tree_children_length(query_tree_reply.get()); std::vector<xcb_get_property_cookie_t> state_property_cookies; state_property_cookies.reserve(tree_children_len); @@ -163,7 +163,7 @@ { std::vector<xcb_window_t> roots; { - xcb_screen_iterator_t iter = ::xcb_setup_roots_iterator(xcb_get_setup(connection)); + xcb_screen_iterator_t iter = ::xcb_setup_roots_iterator(::xcb_get_setup(connection)); for (; iter.rem; ::xcb_screen_next(&iter)) roots.push_back(iter.data->root); } @@ -202,7 +202,7 @@ ::xcb_get_property_reply(connection, window_cookie.class_property_cookie, NULL)); if (reply && reply->format == 8) { - const char* data = reinterpret_cast<char*>(::xcb_get_property_value(reply.get())); + const char* data = reinterpret_cast<const char*>(::xcb_get_property_value(reply.get())); const int data_len = ::xcb_get_property_value_length(reply.get()); int instance_len = str_nlen(data, data_len); @@ -217,7 +217,7 @@ ::xcb_get_property_reply(connection, window_cookie.name_property_cookie, NULL)); if (reply) { - const char* data = reinterpret_cast<char*>(::xcb_get_property_value(reply.get())); + const char* data = reinterpret_cast<const char*>(::xcb_get_property_value(reply.get())); int len = ::xcb_get_property_value_length(reply.get()); win.text = std::string(data, len); @@ -230,17 +230,23 @@ ::xcb_res_query_client_ids_reply(connection, window_cookie.pid_property_cookie, NULL)); if (reply) { - xcb_res_client_id_value_iterator_t it = ::xcb_res_query_client_ids_ids_iterator(reply); + xcb_res_client_id_value_iterator_t it = ::xcb_res_query_client_ids_ids_iterator(reply.get()); for (; it.rem; ::xcb_res_client_id_value_next(&it)) { if (it.data->spec.mask & XCB_RES_CLIENT_ID_MASK_LOCAL_CLIENT_PID) { - proc.pid = *reinterpret_cast<uint32_t*>(::xcb_res_client_id_value_value(it.data)); - fd::GetProcessName(proc.pid, proc.name); /* fill this in if we can */ + proc.pid = *::xcb_res_client_id_value_value(it.data); + GetProcessName(proc.pid, proc.name); /* fill this in if we can */ break; } } } } + std::cout << "got window: " << win.id << "\n" + << "class name: " << win.class_name << "\n" + << "title: " << win.text << "\n" + << "PID: " << proc.pid << "\n" + << "executable: " << proc.name << "\n" << std::endl; + if (!window_proc(proc, win)) { ::xcb_disconnect(connection); return false;