From 8707444cf572a489e66f8f8b07ec540e130eae16 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Fri, 3 Feb 2023 18:41:28 +0000 Subject: [PATCH] fix shell tab behavior in headers --- hyprland-share-picker/main.cpp | 49 ++++++++++++++------------------- src/screencast/wlr_screencast.c | 6 ++-- 2 files changed, 24 insertions(+), 31 deletions(-) diff --git a/hyprland-share-picker/main.cpp b/hyprland-share-picker/main.cpp index c27f506..1076ad3 100644 --- a/hyprland-share-picker/main.cpp +++ b/hyprland-share-picker/main.cpp @@ -1,23 +1,22 @@ -#include "mainpicker.h" - #include -#include -#include -#include -#include -#include -#include -#include #include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include #include #include #include -#include #include +#include "mainpicker.h" + std::string execAndGet(const char* cmd) { std::array buffer; std::string result; @@ -50,15 +49,15 @@ std::vector getWindows(const char* env) { while (!rolling.empty()) { // ID - const auto IDSEPPOS = rolling.find("[HC\011]"); + const auto IDSEPPOS = rolling.find("[HC>]"); const auto IDSTR = rolling.substr(0, IDSEPPOS); // class - const auto CLASSSEPPOS = rolling.find("[HT\011]"); + const auto CLASSSEPPOS = rolling.find("[HT>]"); const auto CLASSSTR = rolling.substr(IDSEPPOS + 5, CLASSSEPPOS - IDSEPPOS - 5); // title - const auto TITLESEPPOS = rolling.find("[HE\011]"); + const auto TITLESEPPOS = rolling.find("[HE>]"); const auto TITLESTR = rolling.substr(CLASSSEPPOS + 5, TITLESEPPOS - 5 - CLASSSEPPOS); try { @@ -73,7 +72,7 @@ std::vector getWindows(const char* env) { return result; } -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) { qputenv("QT_LOGGING_RULES", "qml=false"); const char* WINDOWLISTSTR = getenv("XDPH_WINDOW_SHARING_LIST"); @@ -95,20 +94,18 @@ int main(int argc, char *argv[]) { // add all screens const auto SCREENS = picker.screens(); - constexpr int BUTTON_WIDTH = 441; + constexpr int BUTTON_WIDTH = 441; constexpr int BUTTON_HEIGHT = 41; - constexpr int BUTTON_PAD = 4; + constexpr int BUTTON_PAD = 4; for (int i = 0; i < SCREENS.size(); ++i) { const auto GEOMETRY = SCREENS[i]->geometry(); - QString text = QString::fromStdString(std::string("Screen " + std::to_string(i) + " at " + std::to_string(GEOMETRY.x()) + ", " - + std::to_string(GEOMETRY.y()) + " (" + std::to_string(GEOMETRY.width()) + "x" - + std::to_string(GEOMETRY.height()) + ") (") + SCREENS[i]->name().toStdString() + ")"); + QString text = QString::fromStdString(std::string("Screen " + std::to_string(i) + " at " + std::to_string(GEOMETRY.x()) + ", " + std::to_string(GEOMETRY.y()) + " (" + std::to_string(GEOMETRY.width()) + "x" + std::to_string(GEOMETRY.height()) + ") (") + SCREENS[i]->name().toStdString() + ")"); QPushButton* button = new QPushButton(text, (QWidget*)SCREENS_SCROLL_AREA_CONTENTS); button->move(9, 5 + (BUTTON_HEIGHT + BUTTON_PAD) * i); button->resize(BUTTON_WIDTH, BUTTON_HEIGHT); - QObject::connect(button, &QPushButton::clicked, [=] () { + QObject::connect(button, &QPushButton::clicked, [=]() { std::string ID = button->text().toStdString(); ID = ID.substr(ID.find_last_of('(') + 1); ID = ID.substr(0, ID.find_last_of(')')); @@ -124,13 +121,9 @@ int main(int argc, char *argv[]) { // windows const auto WINDOWS_SCROLL_AREA_CONTENTS = (QWidget*)TAB1->findChild("windows")->findChild("scrollArea_2")->findChild("scrollAreaWidgetContents_2"); - // get all windows from hyprctl - std::string windowsList = execAndGet("hyprctl clients"); - // loop over them int windowIterator = 0; for (auto& window : WINDOWLIST) { - QString text = QString::fromStdString(window.clazz + ": " + window.name); QPushButton* button = new QPushButton(text, (QWidget*)WINDOWS_SCROLL_AREA_CONTENTS); @@ -139,7 +132,7 @@ int main(int argc, char *argv[]) { mainPickerPtr->windowIDs[button] = window.id; - QObject::connect(button, &QPushButton::clicked, [=] () { + QObject::connect(button, &QPushButton::clicked, [=]() { std::cout << "window:" << mainPickerPtr->windowIDs[button] << "\n"; pickerPtr->quit(); return 0; @@ -158,7 +151,7 @@ int main(int argc, char *argv[]) { QPushButton* button = new QPushButton(text, (QWidget*)REGION_OBJECT); button->move(79, 80); button->resize(321, 41); - QObject::connect(button, &QPushButton::clicked, [=] () { + QObject::connect(button, &QPushButton::clicked, [=]() { auto REGION = execAndGet("slurp -f \"%o %x %y %w %h\""); REGION = REGION.substr(0, REGION.length() - 1); diff --git a/src/screencast/wlr_screencast.c b/src/screencast/wlr_screencast.c index daffc53..f1c5b26 100644 --- a/src/screencast/wlr_screencast.c +++ b/src/screencast/wlr_screencast.c @@ -41,7 +41,7 @@ void handleTitle(void *data, struct zwlr_foreign_toplevel_handle_v1 *handle, con if (current->handle == handle) { strncpy(current->name, title, 255); for (int i = 0; i < 255; ++i) - if (current->name[i] == '\"' || current->name[i] == '\011' || current->name[i] == '\'') + if (current->name[i] == '\"' || current->name[i] == '>' || current->name[i] == '\'') current->name[i] = ' '; current->name[255] = '\0'; break; @@ -57,7 +57,7 @@ void handleAppID(void *data, struct zwlr_foreign_toplevel_handle_v1 *handle, con if (current->handle == handle) { strncpy(current->clazz, app_id, 255); for (int i = 0; i < 255; ++i) - if (current->clazz[i] == '\"' || current->clazz[i] == '\011' || current->clazz[i] == '\'') + if (current->clazz[i] == '\"' || current->clazz[i] == '>' || current->clazz[i] == '\'') current->clazz[i] = ' '; current->name[255] = '\0'; break; @@ -689,7 +689,7 @@ char *buildWindowList(struct xdpw_screencast_context *ctx) { wl_list_for_each(current, &ctx->toplevel_resource_list, link) { char *oldRolling = rolling; - rolling = getFormat("%s%u[HC\011]%s[HT\011]%s[HE\011]", rolling, (uint32_t)(((uint64_t)current->handle) & 0xFFFFFFFF), current->clazz, current->name); + rolling = getFormat("%s%u[HC>]%s[HT>]%s[HE>]", rolling, (uint32_t)(((uint64_t)current->handle) & 0xFFFFFFFF), current->clazz, current->name); free(oldRolling); }