Keeping up-to-date, and preparing for some basic CLI stuff with
a simple CXXOpts handler that had an API I thought was somewhat readable.
This commit is contained in:
parent
a8009bdedb
commit
e0e59f8d9d
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule "vendor/cxxopts"]
|
||||||
|
path = vendor/cxxopts
|
||||||
|
url = https://github.com/jarro2783/cxxopts
|
3
notes.md
3
notes.md
|
@ -6,3 +6,6 @@
|
||||||
'get_screen_resources'.
|
'get_screen_resources'.
|
||||||
- The screen_resources object is contains 'screen_resources_crtcs',
|
- The screen_resources object is contains 'screen_resources_crtcs',
|
||||||
which you again get via an iterator. These are cookies.
|
which you again get via an iterator. These are cookies.
|
||||||
|
|
||||||
|
CXX Opts looks like a really useful version of GetOpts that will do what you want:
|
||||||
|
https://github.com/jarro2783/cxxopts
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <xcb>
|
||||||
|
|
||||||
xcb_randr_get_screen_resources_reply_t* get_screen_resources(xcb_connection_t* connection,
|
xcb_randr_get_screen_resources_reply_t* get_screen_resources(xcb_connection_t* connection,
|
||||||
xcb_window_t rootWindow) {
|
xcb_window_t rootWindow) {
|
||||||
|
@ -42,24 +43,6 @@ void display_one_crtc(xcb_randr_get_crtc_info_reply_t* crtc) {
|
||||||
<< " rotation: " << rotation_map(crtc->rotation) << std::endl;
|
<< " rotation: " << rotation_map(crtc->rotation) << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void display_crtc_info(xcb_connection_t* connection, std::vector<xcb_randr_crtc_t>& crtc_cs) {
|
|
||||||
std::vector<xcb_randr_get_crtc_info_cookie_t> cookies;
|
|
||||||
xcb_generic_error_t* error = nullptr;
|
|
||||||
for (const auto& crtc : crtc_cs) {
|
|
||||||
cookies.push_back(xcb_randr_get_crtc_info(connection, crtc, XCB_CURRENT_TIME));
|
|
||||||
}
|
|
||||||
for (const auto& cookie : cookies) {
|
|
||||||
xcb_randr_get_crtc_info_reply_t* reply =
|
|
||||||
xcb_randr_get_crtc_info_reply(connection, cookie, &error);
|
|
||||||
if (error) {
|
|
||||||
free(error);
|
|
||||||
} else {
|
|
||||||
display_one_crtc(reply);
|
|
||||||
free(reply);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void display_one_output(xcb_connection_t* connection, xcb_randr_get_output_info_reply_t* output,
|
void display_one_output(xcb_connection_t* connection, xcb_randr_get_output_info_reply_t* output,
|
||||||
xcb_timestamp_t timestamp) {
|
xcb_timestamp_t timestamp) {
|
||||||
xcb_randr_get_crtc_info_reply_t* crtc = xcb_randr_get_crtc_info_reply(
|
xcb_randr_get_crtc_info_reply_t* crtc = xcb_randr_get_crtc_info_reply(
|
||||||
|
@ -107,7 +90,12 @@ void display_outputs(xcb_connection_t* connection,
|
||||||
// xcb_randr_get_crtc_info_reply_t* reply =
|
// xcb_randr_get_crtc_info_reply_t* reply =
|
||||||
// xcb_randr_get_crtc_info_reply(connection, cookie, &error);
|
// xcb_randr_get_crtc_info_reply(connection, cookie, &error);
|
||||||
// xcb_randr_rotation_t rotation =
|
// xcb_randr_rotation_t rotation =
|
||||||
// (xcb_randr_rotation_t)reply->rotation; free(reply); return rotation;
|
// bool MyClass::operator!=(const MyClass &other) const {
|
||||||
|
return !(*this == other);
|
||||||
|
}
|
||||||
|
(xcb_randr_rotation_t) reply->rotation;
|
||||||
|
free(reply);
|
||||||
|
return rotation;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 8185e6bb3a5d64717a5456903c71efc005ceb711
|
Loading…
Reference in New Issue