fix shell tab behavior in headers

This commit is contained in:
vaxerski 2023-02-03 18:41:28 +00:00
parent a0fa7909cd
commit 8707444cf5
2 changed files with 24 additions and 31 deletions

View file

@ -1,23 +1,22 @@
#include "mainpicker.h"
#include <QApplication>
#include <QScreen>
#include <QWidget>
#include <QTabWidget>
#include <QPushButton>
#include <QtWidgets>
#include <QtDebug>
#include <QObject>
#include <QEvent>
#include <string>
#include <iostream>
#include <QObject>
#include <QPushButton>
#include <QScreen>
#include <QTabWidget>
#include <QWidget>
#include <QtDebug>
#include <QtWidgets>
#include <array>
#include <cstdio>
#include <iostream>
#include <memory>
#include <stdexcept>
#include <string>
#include <array>
#include <vector>
#include "mainpicker.h"
std::string execAndGet(const char* cmd) {
std::array<char, 128> buffer;
std::string result;
@ -50,15 +49,15 @@ std::vector<SWindowEntry> 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 {
@ -102,9 +101,7 @@ int main(int argc, char *argv[]) {
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);
@ -124,13 +121,9 @@ int main(int argc, char *argv[]) {
// windows
const auto WINDOWS_SCROLL_AREA_CONTENTS = (QWidget*)TAB1->findChild<QWidget*>("windows")->findChild<QScrollArea*>("scrollArea_2")->findChild<QWidget*>("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);

View file

@ -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);
}