From e0e59f8d9d1a338560e760e836daf9161f3de107 Mon Sep 17 00:00:00 2001 From: "Elf M. Sternberg" Date: Thu, 31 Mar 2022 15:38:18 -0700 Subject: [PATCH] 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. --- .gitmodules | 3 +++ notes.md | 3 +++ src/xrandr.cpp | 26 +++++++------------------- vendor/cxxopts | 1 + 4 files changed, 14 insertions(+), 19 deletions(-) create mode 100644 .gitmodules create mode 160000 vendor/cxxopts diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..02e84e4 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "vendor/cxxopts"] + path = vendor/cxxopts + url = https://github.com/jarro2783/cxxopts diff --git a/notes.md b/notes.md index 9ae2e6f..4b7490e 100644 --- a/notes.md +++ b/notes.md @@ -6,3 +6,6 @@ 'get_screen_resources'. - The screen_resources object is contains 'screen_resources_crtcs', 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 diff --git a/src/xrandr.cpp b/src/xrandr.cpp index 5945370..0bde342 100644 --- a/src/xrandr.cpp +++ b/src/xrandr.cpp @@ -4,6 +4,7 @@ #include #include #include +#include xcb_randr_get_screen_resources_reply_t* get_screen_resources(xcb_connection_t* connection, 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; } -void display_crtc_info(xcb_connection_t* connection, std::vector& crtc_cs) { - std::vector 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, xcb_timestamp_t timestamp) { 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(connection, cookie, &error); // 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; // } // diff --git a/vendor/cxxopts b/vendor/cxxopts new file mode 160000 index 0000000..8185e6b --- /dev/null +++ b/vendor/cxxopts @@ -0,0 +1 @@ +Subproject commit 8185e6bb3a5d64717a5456903c71efc005ceb711