mirror of
https://github.com/hyprwm/xdg-desktop-portal-hyprland.git
synced 2024-11-25 07:35:57 +01:00
screencopy/picker: add an option to allow restore token by default
fixes #258 screencopy:allow_token_by_default -> bool
This commit is contained in:
parent
5e40936fa0
commit
bab430b3cc
3 changed files with 36 additions and 24 deletions
|
@ -77,8 +77,13 @@ std::vector<SWindowEntry> getWindows(const char* env) {
|
||||||
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");
|
bool allowTokenByDefault = false;
|
||||||
|
for (int i = 1; i < argc; ++i) {
|
||||||
|
if (argv[i] == std::string{"--allow-token"})
|
||||||
|
allowTokenByDefault = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* WINDOWLISTSTR = getenv("XDPH_WINDOW_SHARING_LIST");
|
||||||
const auto WINDOWLIST = getWindows(WINDOWLISTSTR);
|
const auto WINDOWLIST = getWindows(WINDOWLISTSTR);
|
||||||
|
|
||||||
QApplication picker(argc, argv);
|
QApplication picker(argc, argv);
|
||||||
|
@ -93,6 +98,9 @@ int main(int argc, char* argv[]) {
|
||||||
const auto TABWIDGET = w.findChild<QTabWidget*>("tabWidget");
|
const auto TABWIDGET = w.findChild<QTabWidget*>("tabWidget");
|
||||||
const auto ALLOWTOKENBUTTON = w.findChild<QCheckBox*>("checkBox");
|
const auto ALLOWTOKENBUTTON = w.findChild<QCheckBox*>("checkBox");
|
||||||
|
|
||||||
|
if (allowTokenByDefault)
|
||||||
|
ALLOWTOKENBUTTON->setCheckState(Qt::CheckState::Checked);
|
||||||
|
|
||||||
const auto TAB1 = (QWidget*)TABWIDGET->children()[0];
|
const auto TAB1 = (QWidget*)TABWIDGET->children()[0];
|
||||||
|
|
||||||
const auto SCREENS_SCROLL_AREA_CONTENTS =
|
const auto SCREENS_SCROLL_AREA_CONTENTS =
|
||||||
|
@ -183,7 +191,6 @@ int main(int argc, char* argv[]) {
|
||||||
button->setMaximumSize(400, BUTTON_HEIGHT);
|
button->setMaximumSize(400, BUTTON_HEIGHT);
|
||||||
REGION_LAYOUT->addWidget(button);
|
REGION_LAYOUT->addWidget(button);
|
||||||
|
|
||||||
|
|
||||||
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());
|
REGION = REGION.substr(0, REGION.length());
|
||||||
|
|
|
@ -42,6 +42,7 @@ CPortalManager::CPortalManager() {
|
||||||
|
|
||||||
m_sConfig.config->addConfigValue("general:toplevel_dynamic_bind", Hyprlang::INT{0L});
|
m_sConfig.config->addConfigValue("general:toplevel_dynamic_bind", Hyprlang::INT{0L});
|
||||||
m_sConfig.config->addConfigValue("screencopy:max_fps", Hyprlang::INT{120L});
|
m_sConfig.config->addConfigValue("screencopy:max_fps", Hyprlang::INT{120L});
|
||||||
|
m_sConfig.config->addConfigValue("screencopy:allow_token_by_default", Hyprlang::INT{0L});
|
||||||
|
|
||||||
m_sConfig.config->commence();
|
m_sConfig.config->commence();
|
||||||
m_sConfig.config->parse();
|
m_sConfig.config->parse();
|
||||||
|
|
|
@ -42,11 +42,15 @@ SSelectionData promptForScreencopySelection() {
|
||||||
const char* XCURSOR_SIZE = getenv("XCURSOR_SIZE");
|
const char* XCURSOR_SIZE = getenv("XCURSOR_SIZE");
|
||||||
const char* HYPRLAND_INSTANCE_SIGNATURE = getenv("HYPRLAND_INSTANCE_SIGNATURE");
|
const char* HYPRLAND_INSTANCE_SIGNATURE = getenv("HYPRLAND_INSTANCE_SIGNATURE");
|
||||||
|
|
||||||
|
static auto* const* PALLOWTOKENBYDEFAULT =
|
||||||
|
(Hyprlang::INT* const*)g_pPortalManager->m_sConfig.config->getConfigValuePtr("screencopy:allow_token_by_default")->getDataStaticPtr();
|
||||||
|
|
||||||
// DANGEROUS: we are sending a list of app IDs and titles via env. Make sure it's in 'singlequotes' to avoid something like $(rm -rf /)
|
// DANGEROUS: we are sending a list of app IDs and titles via env. Make sure it's in 'singlequotes' to avoid something like $(rm -rf /)
|
||||||
// TODO: this is dumb, use a pipe or something.
|
// TODO: this is dumb, use a pipe or something.
|
||||||
std::string cmd =
|
std::string cmd =
|
||||||
std::format("WAYLAND_DISPLAY='{}' QT_QPA_PLATFORM='wayland' XCURSOR_SIZE='{}' HYPRLAND_INSTANCE_SIGNATURE='{}' XDPH_WINDOW_SHARING_LIST='{}' hyprland-share-picker 2>&1",
|
std::format("WAYLAND_DISPLAY='{}' QT_QPA_PLATFORM='wayland' XCURSOR_SIZE='{}' HYPRLAND_INSTANCE_SIGNATURE='{}' XDPH_WINDOW_SHARING_LIST='{}' hyprland-share-picker{} 2>&1",
|
||||||
WAYLAND_DISPLAY ? WAYLAND_DISPLAY : "", XCURSOR_SIZE ? XCURSOR_SIZE : "24", HYPRLAND_INSTANCE_SIGNATURE ? HYPRLAND_INSTANCE_SIGNATURE : "0", buildWindowList());
|
WAYLAND_DISPLAY ? WAYLAND_DISPLAY : "", XCURSOR_SIZE ? XCURSOR_SIZE : "24", HYPRLAND_INSTANCE_SIGNATURE ? HYPRLAND_INSTANCE_SIGNATURE : "0", buildWindowList(),
|
||||||
|
(**PALLOWTOKENBYDEFAULT ? " --allow-token" : ""));
|
||||||
|
|
||||||
const auto RETVAL = execAndGet(cmd.c_str());
|
const auto RETVAL = execAndGet(cmd.c_str());
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue