Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package xdg-desktop-portal-wlr for
openSUSE:Factory checked in at 2021-06-02 22:12:06
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/xdg-desktop-portal-wlr (Old)
and /work/SRC/openSUSE:Factory/.xdg-desktop-portal-wlr.new.1898 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "xdg-desktop-portal-wlr"
Wed Jun 2 22:12:06 2021 rev:4 rq:896762 version:0.4.0
Changes:
--------
---
/work/SRC/openSUSE:Factory/xdg-desktop-portal-wlr/xdg-desktop-portal-wlr.changes
2021-04-18 21:45:49.644794594 +0200
+++
/work/SRC/openSUSE:Factory/.xdg-desktop-portal-wlr.new.1898/xdg-desktop-portal-wlr.changes
2021-06-02 22:12:34.288103953 +0200
@@ -1,0 +2,10 @@
+Tue Jun 1 17:19:27 UTC 2021 - Arnav Singh <[email protected]>
+
+- Update to 0.4.0:
+ * some CLI options have been replaced with config options.
+ * quotes in the config file are no longer allowed.
+ * Add wlroots to portal manifest UseIn list
+ * screenshot: implement `interactive` option
+ * screenshot: implement PickColor method
+
+-------------------------------------------------------------------
Old:
----
xdg-desktop-portal-wlr-0.3.0.tar.gz
xdg-desktop-portal-wlr-0.3.0.tar.gz.sig
New:
----
xdg-desktop-portal-wlr-0.4.0.tar.gz
xdg-desktop-portal-wlr-0.4.0.tar.gz.sig
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ xdg-desktop-portal-wlr.spec ++++++
--- /var/tmp/diff_new_pack.kLxP8H/_old 2021-06-02 22:12:34.760102786 +0200
+++ /var/tmp/diff_new_pack.kLxP8H/_new 2021-06-02 22:12:34.760102786 +0200
@@ -17,7 +17,7 @@
Name: xdg-desktop-portal-wlr
-Version: 0.3.0
+Version: 0.4.0
Release: 0
Summary: An xdg-desktop-portal backend for wlroots
License: MIT
@@ -25,10 +25,10 @@
URL: https://github.com/emersion/xdg-desktop-portal-wlr
Source0: %{url}/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1:
%{url}/releases/download/v%{version}/xdg-desktop-portal-wlr-%{version}.tar.gz.sig
-BuildRequires: libiniparser-devel
BuildRequires: meson
BuildRequires: pkgconfig
BuildRequires: scdoc >= 1.9.7
+BuildRequires: pkgconfig(inih)
BuildRequires: pkgconfig(libpipewire-0.3) >= 0.3.2
BuildRequires: pkgconfig(libsystemd)
BuildRequires: pkgconfig(systemd)
@@ -36,7 +36,6 @@
BuildRequires: pkgconfig(wayland-protocols) >= 1.14
# Screencasting won't work without pipewire, but it's not a hard dependency.
Recommends: pipewire >= 0.3.2
-Requires: libiniparser1
Requires: xdg-desktop-portal
%description
++++++ xdg-desktop-portal-wlr-0.3.0.tar.gz ->
xdg-desktop-portal-wlr-0.4.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xdg-desktop-portal-wlr-0.3.0/.builds/alpine.yml
new/xdg-desktop-portal-wlr-0.4.0/.builds/alpine.yml
--- old/xdg-desktop-portal-wlr-0.3.0/.builds/alpine.yml 2021-04-18
17:17:13.000000000 +0200
+++ new/xdg-desktop-portal-wlr-0.4.0/.builds/alpine.yml 2021-05-26
08:35:38.000000000 +0200
@@ -6,7 +6,7 @@
- pipewire-dev
- wayland-dev
- wayland-protocols
- - iniparser-dev
+ - inih-dev
- scdoc
sources:
- https://github.com/emersion/xdg-desktop-portal-wlr
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xdg-desktop-portal-wlr-0.3.0/.builds/archlinux.yml
new/xdg-desktop-portal-wlr-0.4.0/.builds/archlinux.yml
--- old/xdg-desktop-portal-wlr-0.3.0/.builds/archlinux.yml 2021-04-18
17:17:13.000000000 +0200
+++ new/xdg-desktop-portal-wlr-0.4.0/.builds/archlinux.yml 2021-05-26
08:35:38.000000000 +0200
@@ -6,7 +6,7 @@
- wayland
- wayland-protocols
- pipewire
- - iniparser
+ - libinih
- scdoc
sources:
- https://github.com/emersion/xdg-desktop-portal-wlr
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xdg-desktop-portal-wlr-0.3.0/.builds/freebsd.yml
new/xdg-desktop-portal-wlr-0.4.0/.builds/freebsd.yml
--- old/xdg-desktop-portal-wlr-0.3.0/.builds/freebsd.yml 2021-04-18
17:17:13.000000000 +0200
+++ new/xdg-desktop-portal-wlr-0.4.0/.builds/freebsd.yml 2021-05-26
08:35:38.000000000 +0200
@@ -7,7 +7,7 @@
- pkgconf
- wayland
- wayland-protocols
- - iniparser
+ - inih
- scdoc
sources:
- https://github.com/emersion/xdg-desktop-portal-wlr
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xdg-desktop-portal-wlr-0.3.0/README.md
new/xdg-desktop-portal-wlr-0.4.0/README.md
--- old/xdg-desktop-portal-wlr-0.3.0/README.md 2021-04-18 17:17:13.000000000
+0200
+++ new/xdg-desktop-portal-wlr-0.4.0/README.md 2021-05-26 08:35:38.000000000
+0200
@@ -26,7 +26,11 @@
## Running
-Make sure `XDG_CURRENT_DESKTOP=sway` is set.
+Make sure `XDG_CURRENT_DESKTOP` is set. Make sure `WAYLAND_DISPLAY` and
+`XDG_CURRENT_DESKTOP` are imported into D-Bus. If you're running Sway, this
+can be added to your config file:
+
+ exec dbus-update-activation-environment --systemd WAYLAND_DISPLAY
XDG_CURRENT_DESKTOP=sway
When correctly installed, xdg-desktop-portal should automatically invoke
xdg-desktop-portal-wlr when needed.
@@ -37,13 +41,15 @@
### Manual startup
-At the moment, some command line flags are available for testing,
compatibility,
-or output selection. If you need to use one of these flags, you can provide an
-instance of xdpw using the following command:
-
-```/usr/lib/xdg-desktop-portal -r & xdg-desktop-portal-wlr [OPTION...]```
+At the moment, some command line flags are available for development and
+testing. If you need to use one of these flags, you can start an instance of
+xdpw using the following command:
+
+```sh
+xdg-desktop-portal-wlr -r [OPTION...]
+```
-To understand the available options, you can run `xdg-desktop-portal-wlr
--help`
+To list the available options, you can run `xdg-desktop-portal-wlr --help`.
## FAQ
@@ -53,7 +59,7 @@
compatible applications and how to get them working.
If you have a question or problem that is not mentioned in those documents,
-please open an issue or come chat with us in [#sway] on freenode IRC.
+please open an issue or come chat with us in #sway on Libera Chat.
## Contributing
@@ -67,5 +73,4 @@
[xdg-desktop-portal]: https://github.com/flatpak/xdg-desktop-portal
[FAQ]: https://github.com/emersion/xdg-desktop-portal-wlr/wiki/FAQ
[screencast compatibility]:
https://github.com/emersion/xdg-desktop-portal-wlr/wiki/Screencast-Compatibility
-[#sway]: https://webchat.freenode.net/#sway
[CONTRIBUTING.md]: CONTRIBUTING.md
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xdg-desktop-portal-wlr-0.3.0/contrib/config.sample
new/xdg-desktop-portal-wlr-0.4.0/contrib/config.sample
--- old/xdg-desktop-portal-wlr-0.3.0/contrib/config.sample 2021-04-18
17:17:13.000000000 +0200
+++ new/xdg-desktop-portal-wlr-0.4.0/contrib/config.sample 2021-05-26
08:35:38.000000000 +0200
@@ -1,5 +1,5 @@
[screencast]
output_name=
max_fps=30
-chooser_cmd="slurp -f %o -o"
+chooser_cmd=slurp -f %o -or
chooser_type=simple
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/xdg-desktop-portal-wlr-0.3.0/contrib/systemd/xdg-desktop-portal-wlr.service.in
new/xdg-desktop-portal-wlr-0.4.0/contrib/systemd/xdg-desktop-portal-wlr.service.in
---
old/xdg-desktop-portal-wlr-0.3.0/contrib/systemd/xdg-desktop-portal-wlr.service.in
2021-04-18 17:17:13.000000000 +0200
+++
new/xdg-desktop-portal-wlr-0.4.0/contrib/systemd/xdg-desktop-portal-wlr.service.in
2021-05-26 08:35:38.000000000 +0200
@@ -2,6 +2,7 @@
Description=Portal service (wlroots implementation)
PartOf=graphical-session.target
After=graphical-session.target
+ConditionEnvironment=WAYLAND_DISPLAY
[Service]
Type=dbus
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/xdg-desktop-portal-wlr-0.3.0/include/pipewire_screencast.h
new/xdg-desktop-portal-wlr-0.4.0/include/pipewire_screencast.h
--- old/xdg-desktop-portal-wlr-0.3.0/include/pipewire_screencast.h
2021-04-18 17:17:13.000000000 +0200
+++ new/xdg-desktop-portal-wlr-0.4.0/include/pipewire_screencast.h
2021-05-26 08:35:38.000000000 +0200
@@ -6,8 +6,9 @@
#define XDPW_PWR_BUFFERS 1
#define XDPW_PWR_ALIGN 16
-void xdpw_pwr_stream_init(struct xdpw_screencast_instance *cast);
-int xdpw_pwr_core_connect(struct xdpw_state *state);
+void xdpw_pwr_stream_create(struct xdpw_screencast_instance *cast);
void xdpw_pwr_stream_destroy(struct xdpw_screencast_instance *cast);
+int xdpw_pwr_context_create(struct xdpw_state *state);
+void xdpw_pwr_context_destroy(struct xdpw_state *state);
#endif
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xdg-desktop-portal-wlr-0.3.0/include/screenshot.h
new/xdg-desktop-portal-wlr-0.4.0/include/screenshot.h
--- old/xdg-desktop-portal-wlr-0.3.0/include/screenshot.h 1970-01-01
01:00:00.000000000 +0100
+++ new/xdg-desktop-portal-wlr-0.4.0/include/screenshot.h 2021-05-26
08:35:38.000000000 +0200
@@ -0,0 +1,10 @@
+#ifndef SCREENSHOT_H
+#define SCREENSHOT_H
+
+
+struct xdpw_ppm_pixel {
+ int max_color_value;
+ unsigned char red, green, blue;
+};
+
+#endif
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xdg-desktop-portal-wlr-0.3.0/meson.build
new/xdg-desktop-portal-wlr-0.4.0/meson.build
--- old/xdg-desktop-portal-wlr-0.3.0/meson.build 2021-04-18
17:17:13.000000000 +0200
+++ new/xdg-desktop-portal-wlr-0.4.0/meson.build 2021-05-26
08:35:38.000000000 +0200
@@ -26,7 +26,7 @@
pipewire = dependency('libpipewire-0.3', version: '>= 0.3.2')
wayland_client = dependency('wayland-client')
wayland_protos = dependency('wayland-protocols', version: '>=1.14')
-iniparser = cc.find_library('iniparser', has_headers: ['iniparser.h',
'dictionary.h'])
+iniparser = dependency('inih')
epoll = dependency('', required: false)
if (not cc.has_function('timerfd_create', prefix: '#include <sys/timerfd.h>')
or
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xdg-desktop-portal-wlr-0.3.0/src/core/config.c
new/xdg-desktop-portal-wlr-0.4.0/src/core/config.c
--- old/xdg-desktop-portal-wlr-0.3.0/src/core/config.c 2021-04-18
17:17:13.000000000 +0200
+++ new/xdg-desktop-portal-wlr-0.4.0/src/core/config.c 2021-05-26
08:35:38.000000000 +0200
@@ -3,17 +3,19 @@
#include "logger.h"
#include "screencast_common.h"
-#include <dictionary.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <iniparser.h>
+#include <ini.h>
void print_config(enum LOGLEVEL loglevel, struct xdpw_config *config) {
- logprint(loglevel, "config: outputname %s",
config->screencast_conf.output_name);
- logprint(loglevel, "config: chooser_cmd: %s\n",
config->screencast_conf.chooser_cmd);
- logprint(loglevel, "config: chooser_type: %s\n",
chooser_type_str(config->screencast_conf.chooser_type));
+ logprint(loglevel, "config: outputname: %s",
config->screencast_conf.output_name);
+ logprint(loglevel, "config: max_fps: %f",
config->screencast_conf.max_fps);
+ logprint(loglevel, "config: exec_before: %s",
config->screencast_conf.exec_before);
+ logprint(loglevel, "config: exec_after: %s",
config->screencast_conf.exec_after);
+ logprint(loglevel, "config: chooser_cmd: %s",
config->screencast_conf.chooser_cmd);
+ logprint(loglevel, "config: chooser_type: %s",
chooser_type_str(config->screencast_conf.chooser_type));
}
// NOTE: calling finish_config won't prepare the config to be read again from
config file
@@ -28,63 +30,65 @@
free(config->screencast_conf.chooser_cmd);
}
-static void getstring_from_conffile(dictionary *d,
- const char *key, char **dest, const char *fallback) {
- if (*dest != NULL) {
+static void parse_string(char **dest, const char* value) {
+ if (value == NULL || *value == '\0') {
+ logprint(TRACE, "config: skipping empty value in config file");
return;
}
- const char *c = iniparser_getstring(d, key, fallback);
- if (c == NULL) {
- return;
- }
- // Allow keys without value as default
- if (strcmp(c, "") != 0) {
- *dest = strdup(c);
- } else {
- *dest = fallback ? strdup(fallback) : NULL;
- }
+ free(*dest);
+ *dest = strdup(value);
}
-static void getdouble_from_conffile(dictionary *d,
- const char *key, double *dest, double fallback) {
- if (*dest != 0) {
+static void parse_double(double *dest, const char* value) {
+ if (value == NULL || *value == '\0') {
+ logprint(TRACE, "config: skipping empty value in config file");
return;
}
- *dest = iniparser_getdouble(d, key, fallback);
-}
-
-static bool file_exists(const char *path) {
- return path && access(path, R_OK) != -1;
+ *dest = strtod(value, (char**)NULL);
}
-static void config_parse_file(const char *configfile, struct xdpw_config
*config) {
- dictionary *d = NULL;
- if (configfile) {
- logprint(INFO, "config: using config file %s", configfile);
- d = iniparser_load(configfile);
+static int handle_ini_screencast(struct config_screencast *screencast_conf,
const char *key, const char *value) {
+ if (strcmp(key, "output_name") == 0) {
+ parse_string(&screencast_conf->output_name, value);
+ } else if (strcmp(key, "max_fps") == 0) {
+ parse_double(&screencast_conf->max_fps, value);
+ } else if (strcmp(key, "exec_before") == 0) {
+ parse_string(&screencast_conf->exec_before, value);
+ } else if (strcmp(key, "exec_after") == 0) {
+ parse_string(&screencast_conf->exec_after, value);
+ } else if (strcmp(key, "chooser_cmd") == 0) {
+ parse_string(&screencast_conf->chooser_cmd, value);
+ } else if (strcmp(key, "chooser_type") == 0) {
+ char *chooser_type = NULL;
+ parse_string(&chooser_type, value);
+ screencast_conf->chooser_type = get_chooser_type(chooser_type);
+ free(chooser_type);
} else {
- logprint(INFO, "config: no config file found");
- }
- if (configfile && !d) {
- logprint(ERROR, "config: unable to load config file %s",
configfile);
+ logprint(TRACE, "config: skipping invalid key in config file");
+ return 0;
}
+ return 1;
+}
- // screencast
- getstring_from_conffile(d, "screencast:output_name",
&config->screencast_conf.output_name, NULL);
- getdouble_from_conffile(d, "screencast:max_fps",
&config->screencast_conf.max_fps, 0);
- getstring_from_conffile(d, "screencast:exec_before",
&config->screencast_conf.exec_before, NULL);
- getstring_from_conffile(d, "screencast:exec_after",
&config->screencast_conf.exec_after, NULL);
- getstring_from_conffile(d, "screencast:chooser_cmd",
&config->screencast_conf.chooser_cmd, NULL);
- if (!config->screencast_conf.chooser_type) {
- char *chooser_type = NULL;
- getstring_from_conffile(d, "screencast:chooser_type",
&chooser_type, "default");
- config->screencast_conf.chooser_type =
get_chooser_type(chooser_type);
- free(chooser_type);
+static int handle_ini_config(void *data, const char* section, const char *key,
const char *value) {
+ struct xdpw_config *config = (struct xdpw_config*)data;
+ logprint(TRACE, "config: parsing setction %s, key %s, value %s",
section, key, value);
+
+ if (strcmp(section, "screencast") == 0) {
+ return handle_ini_screencast(&config->screencast_conf, key,
value);
}
- iniparser_freedict(d);
- logprint(DEBUG, "config: config file parsed");
- print_config(DEBUG, config);
+ logprint(TRACE, "config: skipping invalid key in config file");
+ return 0;
+}
+
+static void default_config(struct xdpw_config *config) {
+ config->screencast_conf.max_fps = 0;
+ config->screencast_conf.chooser_type = XDPW_CHOOSER_DEFAULT;
+}
+
+static bool file_exists(const char *path) {
+ return path && access(path, R_OK) != -1;
}
static char *config_path(const char *prefix, const char *filename) {
@@ -115,24 +119,44 @@
prefix[0] = config_home;
prefix[1] = SYSCONFDIR "/xdg";
- const char *config[2];
- config[0] = getenv("XDG_CURRENT_DESKTOP");
- config[1] = "config";
+ const char *xdg_current_desktop = getenv("XDG_CURRENT_DESKTOP");
+ const char *config_fallback = "config";
+ char *config_list = NULL;
for (size_t i = 0; i < 2; i++) {
- for (size_t j = 0; j < 2; j++) {
- char *path = config_path(prefix[i], config[j]);
- if (!path) {
- continue;
+ if (xdg_current_desktop) {
+ config_list = strdup(xdg_current_desktop);
+ char *config = strtok(config_list, ":");
+ while (config) {
+ char *path = config_path(prefix[i], config);
+ if (!path) {
+ config = strtok(NULL, ":");
+ continue;
+ }
+ logprint(TRACE, "config: trying config file
%s", path);
+ if (file_exists(path)) {
+ free(config_list);
+ free(config_home_fallback);
+ return path;
+ }
+ free(path);
+ config = strtok(NULL, ":");
}
- logprint(TRACE, "config: trying config file %s", path);
- if (file_exists(path)) {
- return path;
- }
- free(path);
+ free(config_list);
+ }
+ char *path = config_path(prefix[i], config_fallback);
+ if (!path) {
+ continue;
}
+ logprint(TRACE, "config: trying config file %s", path);
+ if (file_exists(path)) {
+ free(config_home_fallback);
+ return path;
+ }
+ free(path);
}
+ free(config_home_fallback);
return NULL;
}
@@ -141,5 +165,12 @@
*configfile = get_config_path();
}
- config_parse_file(*configfile, config);
+ default_config(config);
+ if (*configfile == NULL) {
+ logprint(ERROR, "config: no config file found");
+ return;
+ }
+ if (ini_parse(*configfile, handle_ini_config, config) < 0) {
+ logprint(ERROR, "config: unable to load config file %s",
*configfile);
+ }
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xdg-desktop-portal-wlr-0.3.0/src/core/main.c
new/xdg-desktop-portal-wlr-0.4.0/src/core/main.c
--- old/xdg-desktop-portal-wlr-0.3.0/src/core/main.c 2021-04-18
17:17:13.000000000 +0200
+++ new/xdg-desktop-portal-wlr-0.4.0/src/core/main.c 2021-05-26
08:35:38.000000000 +0200
@@ -26,12 +26,9 @@
"\n"
" -l, --loglevel=<loglevel> Select log level (default
is ERROR).\n"
" QUIET, ERROR, WARN, INFO,
DEBUG, TRACE\n"
- " -o, --output=<name> Select output to
capture.\n"
- " metadata (performs no
conversion).\n"
" -c, --config=<config file> Select config file.\n"
" (default is
$XDG_CONFIG_HOME/xdg-desktop-portal-wlr/config)\n"
" -r, --replace Replace a running
instance.\n"
- " -f, --max-fps=<fps> Set the FPS limit
(default 0, no limit).\n"
" -h, --help Get help (this text).\n"
"\n";
@@ -54,9 +51,7 @@
static const char *shortopts = "l:o:c:f:rh";
static const struct option longopts[] = {
{ "loglevel", required_argument, NULL, 'l' },
- { "output", required_argument, NULL, 'o' },
{ "config", required_argument, NULL, 'c' },
- { "max-fps", required_argument, NULL, 'f' },
{ "replace", no_argument, NULL, 'r' },
{ "help", no_argument, NULL, 'h' },
{ NULL, 0, NULL, 0 }
@@ -72,19 +67,12 @@
case 'l':
loglevel = get_loglevel(optarg);
break;
- case 'o':
- config.screencast_conf.output_name = strdup(optarg);
- config.screencast_conf.chooser_type = XDPW_CHOOSER_NONE;
- break;
case 'c':
configfile = strdup(optarg);
break;
case 'r':
replace = true;
break;
- case 'f':
- config.screencast_conf.max_fps = atof(optarg);
- break;
case 'h':
return xdpw_usage(stdout, EXIT_SUCCESS);
default:
@@ -94,6 +82,7 @@
init_logger(stderr, loglevel);
init_config(&configfile, &config);
+ print_config(DEBUG, &config);
int ret = 0;
@@ -238,7 +227,7 @@
if (pollfds[EVENT_LOOP_TIMER].revents & POLLIN) {
logprint(TRACE, "event-loop: got a timer event");
-
+
int timer_fd = pollfds[EVENT_LOOP_TIMER].fd;
uint64_t expirations;
ssize_t n = read(timer_fd, &expirations,
sizeof(expirations));
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/xdg-desktop-portal-wlr-0.3.0/src/screencast/pipewire_screencast.c
new/xdg-desktop-portal-wlr-0.4.0/src/screencast/pipewire_screencast.c
--- old/xdg-desktop-portal-wlr-0.3.0/src/screencast/pipewire_screencast.c
2021-04-18 17:17:13.000000000 +0200
+++ new/xdg-desktop-portal-wlr-0.4.0/src/screencast/pipewire_screencast.c
2021-05-26 08:35:38.000000000 +0200
@@ -136,7 +136,7 @@
.param_changed = pwr_handle_stream_param_changed,
};
-void xdpw_pwr_stream_init(struct xdpw_screencast_instance *cast) {
+void xdpw_pwr_stream_create(struct xdpw_screencast_instance *cast) {
struct xdpw_screencast_context *ctx = cast->ctx;
struct xdpw_state *state = ctx->state;
@@ -206,7 +206,19 @@
¶m, 1);
}
-int xdpw_pwr_core_connect(struct xdpw_state *state) {
+void xdpw_pwr_stream_destroy(struct xdpw_screencast_instance *cast) {
+ if (!cast->stream) {
+ return;
+ }
+
+ logprint(DEBUG, "pipewire: destroying stream");
+ pw_stream_flush(cast->stream, false);
+ pw_stream_disconnect(cast->stream);
+ pw_stream_destroy(cast->stream);
+ cast->stream = NULL;
+}
+
+int xdpw_pwr_context_create(struct xdpw_state *state) {
struct xdpw_screencast_context *ctx = &state->screencast;
logprint(DEBUG, "pipewire: establishing connection to core");
@@ -229,10 +241,18 @@
return 0;
}
-void xdpw_pwr_stream_destroy(struct xdpw_screencast_instance *cast) {
- logprint(DEBUG, "pipewire: destroying stream");
- pw_stream_flush(cast->stream, false);
- pw_stream_disconnect(cast->stream);
- pw_stream_destroy(cast->stream);
- cast->stream = NULL;
+void xdpw_pwr_context_destroy(struct xdpw_state *state) {
+ struct xdpw_screencast_context *ctx = &state->screencast;
+
+ logprint(DEBUG, "pipewire: disconnecting fom core");
+
+ if (ctx->core) {
+ pw_core_disconnect(ctx->core);
+ ctx->core = NULL;
+ }
+
+ if (ctx->pwr_context) {
+ pw_context_destroy(ctx->pwr_context);
+ ctx->pwr_context = NULL;
+ }
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/xdg-desktop-portal-wlr-0.3.0/src/screencast/screencast.c
new/xdg-desktop-portal-wlr-0.4.0/src/screencast/screencast.c
--- old/xdg-desktop-portal-wlr-0.3.0/src/screencast/screencast.c
2021-04-18 17:17:13.000000000 +0200
+++ new/xdg-desktop-portal-wlr-0.4.0/src/screencast/screencast.c
2021-05-26 08:35:38.000000000 +0200
@@ -134,7 +134,7 @@
wl_display_dispatch(cast->ctx->state->wl_display);
wl_display_roundtrip(cast->ctx->state->wl_display);
- xdpw_pwr_stream_init(cast);
+ xdpw_pwr_stream_create(cast);
cast->initialized = true;
return 0;
@@ -472,21 +472,24 @@
state->screencast.state = state;
int err;
- err = xdpw_pwr_core_connect(state);
+ err = xdpw_pwr_context_create(state);
if (err) {
- goto end;
+ goto fail_pipewire;
}
err = xdpw_wlr_screencopy_init(state);
if (err) {
- goto end;
+ goto fail_screencopy;
}
return sd_bus_add_object_vtable(state->bus, &slot, object_path,
interface_name,
screencast_vtable, state);
-end:
- // TODO: clean up pipewire
+fail_screencopy:
xdpw_wlr_screencopy_finish(&state->screencast);
+
+fail_pipewire:
+ xdpw_pwr_context_destroy(state);
+
return err;
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/xdg-desktop-portal-wlr-0.3.0/src/screencast/wlr_screencast.c
new/xdg-desktop-portal-wlr-0.4.0/src/screencast/wlr_screencast.c
--- old/xdg-desktop-portal-wlr-0.3.0/src/screencast/wlr_screencast.c
2021-04-18 17:17:13.000000000 +0200
+++ new/xdg-desktop-portal-wlr-0.4.0/src/screencast/wlr_screencast.c
2021-05-26 08:35:38.000000000 +0200
@@ -406,7 +406,7 @@
if (!wait_chooser(pid)) {
close(chooser_out[0]);
- goto end;
+ return false;
}
FILE *f = fdopen(chooser_out[0], "r");
@@ -432,8 +432,7 @@
logprint(TRACE, "wlroots: output chooser %s selects output %s",
chooser->cmd, name);
wl_list_for_each(out, output_list, link) {
- // TODO: Replugging of outputs can result in a corrupted
output_list
- if (out->name && strcmp(out->name, name) == 0) {
+ if (strcmp(out->name, name) == 0) {
*output = out;
break;
}
@@ -457,9 +456,9 @@
static struct xdpw_wlr_output *wlr_output_chooser_default(struct wl_list
*output_list) {
logprint(DEBUG, "wlroots: output chooser called");
struct xdpw_output_chooser default_chooser[] = {
- {XDPW_CHOOSER_SIMPLE, "slurp -f %o -o"},
- {XDPW_CHOOSER_DMENU, "wofi -d -n"},
- {XDPW_CHOOSER_DMENU, "bemenu"},
+ {XDPW_CHOOSER_SIMPLE, "slurp -f %o -or"},
+ {XDPW_CHOOSER_DMENU, "wofi -d -n --prompt='Select the monitor
to share:'"},
+ {XDPW_CHOOSER_DMENU, "bemenu --prompt='Select the monitor to
share:'"},
};
size_t N = sizeof(default_chooser)/sizeof(default_chooser[0]);
@@ -634,6 +633,13 @@
logprint(DEBUG, "wayland: registry listeners run");
+ // make sure our wlroots supports xdg_output_manager
+ if (!ctx->xdg_output_manager) {
+ logprint(ERROR, "Compositor doesn't support %s!",
+ zxdg_output_manager_v1_interface.name);
+ return -1;
+ }
+
wlr_init_xdg_outputs(ctx);
wl_display_roundtrip(state->wl_display);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/xdg-desktop-portal-wlr-0.3.0/src/screenshot/screenshot.c
new/xdg-desktop-portal-wlr-0.4.0/src/screenshot/screenshot.c
--- old/xdg-desktop-portal-wlr-0.3.0/src/screenshot/screenshot.c
2021-04-18 17:17:13.000000000 +0200
+++ new/xdg-desktop-portal-wlr-0.4.0/src/screenshot/screenshot.c
2021-05-26 08:35:38.000000000 +0200
@@ -5,6 +5,7 @@
#include <sys/wait.h>
#include <unistd.h>
#include "xdpw.h"
+#include "screenshot.h"
static const char object_path[] = "/org/freedesktop/portal/desktop";
static const char interface_name[] = "org.freedesktop.impl.portal.Screenshot";
@@ -35,17 +36,78 @@
return stat == 0;
}
+static bool exec_screenshooter_interactive(const char *path) {
+ pid_t pid = fork();
+ if (pid < 0) {
+ perror("fork");
+ return false;
+ } else if (pid == 0) {
+ char cmd[strlen(path) + 25];
+ snprintf(cmd, sizeof(cmd), "grim -g \"$(slurp)\" -- %s", path);
+ execl("/bin/sh", "/bin/sh", "-c", cmd, NULL);
+ perror("execl");
+ exit(127);
+ }
+
+ int stat;
+ if (waitpid(pid, &stat, 0) < 0) {
+ perror("waitpid");
+ return false;
+ }
+
+ return stat == 0;
+}
static int method_screenshot(sd_bus_message *msg, void *data,
sd_bus_error *ret_error) {
int ret = 0;
+ bool interactive = false;
+
char *handle, *app_id, *parent_window;
ret = sd_bus_message_read(msg, "oss", &handle, &app_id, &parent_window);
if (ret < 0) {
return ret;
}
- // TODO: read options
+
+ ret = sd_bus_message_enter_container(msg, 'a', "{sv}");
+ if (ret < 0) {
+ return ret;
+ }
+ char *key;
+ int inner_ret = 0;
+ while ((ret = sd_bus_message_enter_container(msg, 'e', "sv")) > 0) {
+ inner_ret = sd_bus_message_read(msg, "s", &key);
+ if (inner_ret < 0) {
+ return inner_ret;
+ }
+
+ if (strcmp(key, "interactive") == 0) {
+ bool mode;
+ sd_bus_message_read(msg, "v", "b", &mode);
+ logprint(DEBUG, "dbus: option interactive: %x", mode);
+ interactive = mode;
+ } else if (strcmp(key, "modal") == 0) {
+ bool modal;
+ sd_bus_message_read(msg, "v", "b", &modal);
+ logprint(DEBUG, "dbus: option modal: %x", modal);
+ } else {
+ logprint(WARN, "dbus: unknown option %s", key);
+ sd_bus_message_skip(msg, "v");
+ }
+
+ inner_ret = sd_bus_message_exit_container(msg);
+ if (inner_ret < 0) {
+ return inner_ret;
+ }
+ }
+ if (ret < 0) {
+ return ret;
+ }
+ ret = sd_bus_message_exit_container(msg);
+ if (ret < 0) {
+ return ret;
+ }
// TODO: cleanup this
struct xdpw_request *req =
@@ -56,7 +118,10 @@
// TODO: choose a better path
const char path[] = "/tmp/out.png";
- if (!exec_screenshooter(path)) {
+ if (interactive && !exec_screenshooter_interactive(path)) {
+ return -1;
+ }
+ if (!interactive && !exec_screenshooter(path)) {
return -1;
}
@@ -84,9 +149,143 @@
return 0;
}
+static bool spawn_chooser(int chooser_out[2]) {
+ pid_t pid = fork();
+ if (pid < 0) {
+ perror("fork");
+ return false;
+ } else if (pid == 0) {
+ close(chooser_out[0]);
+
+ dup2(chooser_out[1], STDOUT_FILENO);
+ close(chooser_out[1]);
+
+ execl("/bin/sh", "/bin/sh", "-c", "grim -g \"$(slurp -p)\" -t
ppm -", NULL);
+
+ perror("execl");
+ _exit(127);
+ }
+
+ int stat;
+ if (waitpid(pid, &stat, 0) < 0) {
+ perror("waitpid");
+ return false;
+ }
+
+ close(chooser_out[1]);
+ return stat == 0;
+}
+
+static bool exec_color_picker(struct xdpw_ppm_pixel *pixel) {
+ int chooser_out[2];
+ if (pipe(chooser_out) == -1) {
+ perror("pipe chooser_out");
+ return false;
+ }
+
+ if (!spawn_chooser(chooser_out)) {
+ logprint(ERROR, "Selection failed");
+ close(chooser_out[0]);
+ return false;
+ }
+
+ FILE *f = fdopen(chooser_out[0], "r");
+ if (f == NULL) {
+ perror("fopen pipe chooser_out");
+ close(chooser_out[0]);
+ return false;
+ }
+
+ char *format = NULL;
+ size_t len = 1;
+ if (getline(&format, &len, f) < 0) {
+ goto error_img;
+ }
+ if (strcmp(format, "P6\n") != 0) {
+ goto error_img;
+ }
+ if (getline(&format, &len, f) < 0) {
+ goto error_img;
+ }
+ if (strcmp(format, "1 1\n") != 0) {
+ goto error_img;
+ }
+
+ if (fscanf(f, "%d\n", &pixel->max_color_value) != 1) {
+ goto error_img;
+ }
+
+ unsigned char pixels[3];
+ if (fread(pixels, 3, 1, f) != 1) {
+ goto error_img;
+ }
+
+ pixel->red = pixels[0];
+ pixel->green = pixels[1];
+ pixel->blue = pixels[2];
+
+ free(format);
+ fclose(f);
+
+ return true;
+
+error_img:
+ logprint(WARN, "Invalid image format or size");
+ free(format);
+ fclose(f);
+ return false;
+}
+
+static int method_pick_color(sd_bus_message *msg, void *data,
+ sd_bus_error *ret_error) {
+
+ int ret = 0;
+
+ char *handle, *app_id, *parent_window;
+ ret = sd_bus_message_read(msg, "oss", &handle, &app_id, &parent_window);
+ if (ret < 0) {
+ return ret;
+ }
+
+ struct xdpw_request *req =
+ xdpw_request_create(sd_bus_message_get_bus(msg), handle);
+ if (req == NULL) {
+ return -ENOMEM;
+ }
+
+ struct xdpw_ppm_pixel pixel = {0};
+ if (!exec_color_picker(&pixel)) {
+ return -1;
+ }
+
+ double red = pixel.red / (pixel.max_color_value * 1.0);
+ double green = pixel.green / (pixel.max_color_value * 1.0);
+ double blue = pixel.blue / (pixel.max_color_value * 1.0);
+
+ sd_bus_message *reply = NULL;
+ ret = sd_bus_message_new_method_return(msg, &reply);
+ if (ret < 0) {
+ return ret;
+ }
+
+ ret = sd_bus_message_append(reply, "ua{sv}", PORTAL_RESPONSE_SUCCESS,
1, "color", "(ddd)", red, green, blue);
+ if (ret < 0) {
+ return ret;
+ }
+
+ ret = sd_bus_send(NULL, reply, NULL);
+ if (ret < 0) {
+ return ret;
+ }
+
+ sd_bus_message_unref(reply);
+ return 0;
+}
+
static const sd_bus_vtable screenshot_vtable[] = {
SD_BUS_VTABLE_START(0),
SD_BUS_METHOD("Screenshot", "ossa{sv}", "ua{sv}", method_screenshot,
SD_BUS_VTABLE_UNPRIVILEGED),
+ SD_BUS_METHOD("PickColor", "ossa{sv}", "ua{sv}", method_pick_color,
SD_BUS_VTABLE_UNPRIVILEGED),
SD_BUS_VTABLE_END
};
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xdg-desktop-portal-wlr-0.3.0/wlr.portal
new/xdg-desktop-portal-wlr-0.4.0/wlr.portal
--- old/xdg-desktop-portal-wlr-0.3.0/wlr.portal 2021-04-18 17:17:13.000000000
+0200
+++ new/xdg-desktop-portal-wlr-0.4.0/wlr.portal 2021-05-26 08:35:38.000000000
+0200
@@ -1,4 +1,4 @@
[portal]
DBusName=org.freedesktop.impl.portal.desktop.wlr
Interfaces=org.freedesktop.impl.portal.Screenshot;org.freedesktop.impl.portal.ScreenCast;
-UseIn=sway;Wayfire;river
+UseIn=wlroots;sway;Wayfire;river
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/xdg-desktop-portal-wlr-0.3.0/xdg-desktop-portal-wlr.5.scd
new/xdg-desktop-portal-wlr-0.4.0/xdg-desktop-portal-wlr.5.scd
--- old/xdg-desktop-portal-wlr-0.3.0/xdg-desktop-portal-wlr.5.scd
2021-04-18 17:17:13.000000000 +0200
+++ new/xdg-desktop-portal-wlr-0.4.0/xdg-desktop-portal-wlr.5.scd
2021-05-26 08:35:38.000000000 +0200
@@ -18,6 +18,7 @@
- /etc/xdg/xdg-desktop-portal-wlr/config
_$XDG_CONFIG_HOME_ defaults to _~/.config_.
+_$XDG_CURRENT_DESKTOP_ can be a colon seperated list. Each element of that
list will be tried.
The configuration files use the INI file format. Example:
@@ -28,7 +29,7 @@
exec_before=disable_notifications.sh
exec_after=enable_notifications.sh
chooser_type=simple
-chooser_cmd="slurp -f %o -o"
+chooser_cmd=slurp -f %o -or
```
# SCREENCAST OPTIONS