mirror of
https://github.com/hyprwm/xdg-desktop-portal-hyprland.git
synced 2024-11-25 15:35:58 +01:00
fix shell tab behavior in headers
This commit is contained in:
parent
a0fa7909cd
commit
8707444cf5
2 changed files with 24 additions and 31 deletions
|
@ -1,23 +1,22 @@
|
||||||
#include "mainpicker.h"
|
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QScreen>
|
|
||||||
#include <QWidget>
|
|
||||||
#include <QTabWidget>
|
|
||||||
#include <QPushButton>
|
|
||||||
#include <QtWidgets>
|
|
||||||
#include <QtDebug>
|
|
||||||
#include <QObject>
|
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
#include <string>
|
#include <QObject>
|
||||||
#include <iostream>
|
#include <QPushButton>
|
||||||
|
#include <QScreen>
|
||||||
|
#include <QTabWidget>
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QtDebug>
|
||||||
|
#include <QtWidgets>
|
||||||
|
#include <array>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <iostream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <array>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "mainpicker.h"
|
||||||
|
|
||||||
std::string execAndGet(const char* cmd) {
|
std::string execAndGet(const char* cmd) {
|
||||||
std::array<char, 128> buffer;
|
std::array<char, 128> buffer;
|
||||||
std::string result;
|
std::string result;
|
||||||
|
@ -50,15 +49,15 @@ std::vector<SWindowEntry> getWindows(const char* env) {
|
||||||
|
|
||||||
while (!rolling.empty()) {
|
while (!rolling.empty()) {
|
||||||
// ID
|
// ID
|
||||||
const auto IDSEPPOS = rolling.find("[HC\011]");
|
const auto IDSEPPOS = rolling.find("[HC>]");
|
||||||
const auto IDSTR = rolling.substr(0, IDSEPPOS);
|
const auto IDSTR = rolling.substr(0, IDSEPPOS);
|
||||||
|
|
||||||
// class
|
// class
|
||||||
const auto CLASSSEPPOS = rolling.find("[HT\011]");
|
const auto CLASSSEPPOS = rolling.find("[HT>]");
|
||||||
const auto CLASSSTR = rolling.substr(IDSEPPOS + 5, CLASSSEPPOS - IDSEPPOS - 5);
|
const auto CLASSSTR = rolling.substr(IDSEPPOS + 5, CLASSSEPPOS - IDSEPPOS - 5);
|
||||||
|
|
||||||
// title
|
// title
|
||||||
const auto TITLESEPPOS = rolling.find("[HE\011]");
|
const auto TITLESEPPOS = rolling.find("[HE>]");
|
||||||
const auto TITLESTR = rolling.substr(CLASSSEPPOS + 5, TITLESEPPOS - 5 - CLASSSEPPOS);
|
const auto TITLESTR = rolling.substr(CLASSSEPPOS + 5, TITLESEPPOS - 5 - CLASSSEPPOS);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -73,7 +72,7 @@ std::vector<SWindowEntry> getWindows(const char* env) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
qputenv("QT_LOGGING_RULES", "qml=false");
|
qputenv("QT_LOGGING_RULES", "qml=false");
|
||||||
|
|
||||||
const char* WINDOWLISTSTR = getenv("XDPH_WINDOW_SHARING_LIST");
|
const char* WINDOWLISTSTR = getenv("XDPH_WINDOW_SHARING_LIST");
|
||||||
|
@ -102,13 +101,11 @@ int main(int argc, char *argv[]) {
|
||||||
for (int i = 0; i < SCREENS.size(); ++i) {
|
for (int i = 0; i < SCREENS.size(); ++i) {
|
||||||
const auto GEOMETRY = SCREENS[i]->geometry();
|
const auto GEOMETRY = SCREENS[i]->geometry();
|
||||||
|
|
||||||
QString text = QString::fromStdString(std::string("Screen " + std::to_string(i) + " at " + std::to_string(GEOMETRY.x()) + ", "
|
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() + ")");
|
||||||
+ 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);
|
QPushButton* button = new QPushButton(text, (QWidget*)SCREENS_SCROLL_AREA_CONTENTS);
|
||||||
button->move(9, 5 + (BUTTON_HEIGHT + BUTTON_PAD) * i);
|
button->move(9, 5 + (BUTTON_HEIGHT + BUTTON_PAD) * i);
|
||||||
button->resize(BUTTON_WIDTH, BUTTON_HEIGHT);
|
button->resize(BUTTON_WIDTH, BUTTON_HEIGHT);
|
||||||
QObject::connect(button, &QPushButton::clicked, [=] () {
|
QObject::connect(button, &QPushButton::clicked, [=]() {
|
||||||
std::string ID = button->text().toStdString();
|
std::string ID = button->text().toStdString();
|
||||||
ID = ID.substr(ID.find_last_of('(') + 1);
|
ID = ID.substr(ID.find_last_of('(') + 1);
|
||||||
ID = ID.substr(0, ID.find_last_of(')'));
|
ID = ID.substr(0, ID.find_last_of(')'));
|
||||||
|
@ -124,13 +121,9 @@ int main(int argc, char *argv[]) {
|
||||||
// windows
|
// windows
|
||||||
const auto WINDOWS_SCROLL_AREA_CONTENTS = (QWidget*)TAB1->findChild<QWidget*>("windows")->findChild<QScrollArea*>("scrollArea_2")->findChild<QWidget*>("scrollAreaWidgetContents_2");
|
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
|
// loop over them
|
||||||
int windowIterator = 0;
|
int windowIterator = 0;
|
||||||
for (auto& window : WINDOWLIST) {
|
for (auto& window : WINDOWLIST) {
|
||||||
|
|
||||||
QString text = QString::fromStdString(window.clazz + ": " + window.name);
|
QString text = QString::fromStdString(window.clazz + ": " + window.name);
|
||||||
|
|
||||||
QPushButton* button = new QPushButton(text, (QWidget*)WINDOWS_SCROLL_AREA_CONTENTS);
|
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;
|
mainPickerPtr->windowIDs[button] = window.id;
|
||||||
|
|
||||||
QObject::connect(button, &QPushButton::clicked, [=] () {
|
QObject::connect(button, &QPushButton::clicked, [=]() {
|
||||||
std::cout << "window:" << mainPickerPtr->windowIDs[button] << "\n";
|
std::cout << "window:" << mainPickerPtr->windowIDs[button] << "\n";
|
||||||
pickerPtr->quit();
|
pickerPtr->quit();
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -158,7 +151,7 @@ int main(int argc, char *argv[]) {
|
||||||
QPushButton* button = new QPushButton(text, (QWidget*)REGION_OBJECT);
|
QPushButton* button = new QPushButton(text, (QWidget*)REGION_OBJECT);
|
||||||
button->move(79, 80);
|
button->move(79, 80);
|
||||||
button->resize(321, 41);
|
button->resize(321, 41);
|
||||||
QObject::connect(button, &QPushButton::clicked, [=] () {
|
QObject::connect(button, &QPushButton::clicked, [=]() {
|
||||||
auto REGION = execAndGet("slurp -f \"%o %x %y %w %h\"");
|
auto REGION = execAndGet("slurp -f \"%o %x %y %w %h\"");
|
||||||
REGION = REGION.substr(0, REGION.length() - 1);
|
REGION = REGION.substr(0, REGION.length() - 1);
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ void handleTitle(void *data, struct zwlr_foreign_toplevel_handle_v1 *handle, con
|
||||||
if (current->handle == handle) {
|
if (current->handle == handle) {
|
||||||
strncpy(current->name, title, 255);
|
strncpy(current->name, title, 255);
|
||||||
for (int i = 0; i < 255; ++i)
|
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[i] = ' ';
|
||||||
current->name[255] = '\0';
|
current->name[255] = '\0';
|
||||||
break;
|
break;
|
||||||
|
@ -57,7 +57,7 @@ void handleAppID(void *data, struct zwlr_foreign_toplevel_handle_v1 *handle, con
|
||||||
if (current->handle == handle) {
|
if (current->handle == handle) {
|
||||||
strncpy(current->clazz, app_id, 255);
|
strncpy(current->clazz, app_id, 255);
|
||||||
for (int i = 0; i < 255; ++i)
|
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->clazz[i] = ' ';
|
||||||
current->name[255] = '\0';
|
current->name[255] = '\0';
|
||||||
break;
|
break;
|
||||||
|
@ -689,7 +689,7 @@ char *buildWindowList(struct xdpw_screencast_context *ctx) {
|
||||||
wl_list_for_each(current, &ctx->toplevel_resource_list, link) {
|
wl_list_for_each(current, &ctx->toplevel_resource_list, link) {
|
||||||
char *oldRolling = rolling;
|
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);
|
free(oldRolling);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue