summaryrefslogtreecommitdiff
path: root/sway/config
diff options
context:
space:
mode:
authorWilliam McKinnon <[email protected]>2022-04-26 21:44:51 -0400
committerGitHub <[email protected]>2022-04-26 21:44:51 -0400
commit4660771f6a25b93062df0698634059f893ae1999 (patch)
treeb7135d20119a42d8381fb65004f476750d6212fd /sway/config
parentccda4dae0f9b77b9760d6fdf178e0f0e2571cde0 (diff)
parent5543acff06981639086bc9a0fc9b608796a23e84 (diff)
Merge pull request #1 from swaywm/v1.7
V1.7
Diffstat (limited to 'sway/config')
-rw-r--r--sway/config/bar.c2
-rw-r--r--sway/config/output.c46
2 files changed, 45 insertions, 3 deletions
diff --git a/sway/config/bar.c b/sway/config/bar.c
index e09add44..d1b342e6 100644
--- a/sway/config/bar.c
+++ b/sway/config/bar.c
@@ -219,6 +219,8 @@ static void invoke_swaybar(struct bar_config *bar) {
sigprocmask(SIG_SETMASK, &set, NULL);
signal(SIGPIPE, SIG_DFL);
+ restore_nofile_limit();
+
pid = fork();
if (pid < 0) {
sway_log_errno(SWAY_ERROR, "fork failed");
diff --git a/sway/config/output.c b/sway/config/output.c
index 8e937b28..fa509252 100644
--- a/sway/config/output.c
+++ b/sway/config/output.c
@@ -1,5 +1,6 @@
#define _POSIX_C_SOURCE 200809L
#include <assert.h>
+#include <drm_fourcc.h>
#include <stdbool.h>
#include <string.h>
#include <sys/socket.h>
@@ -67,6 +68,7 @@ struct output_config *new_output_config(const char *name) {
oc->subpixel = WL_OUTPUT_SUBPIXEL_UNKNOWN;
oc->max_render_time = -1;
oc->adaptive_sync = -1;
+ oc->render_bit_depth = RENDER_BIT_DEPTH_DEFAULT;
return oc;
}
@@ -113,6 +115,9 @@ void merge_output_config(struct output_config *dst, struct output_config *src) {
if (src->adaptive_sync != -1) {
dst->adaptive_sync = src->adaptive_sync;
}
+ if (src->render_bit_depth != RENDER_BIT_DEPTH_DEFAULT) {
+ dst->render_bit_depth = src->render_bit_depth;
+ }
if (src->background) {
free(dst->background);
dst->background = strdup(src->background);
@@ -351,9 +356,26 @@ static int compute_default_scale(struct wlr_output *output) {
return 2;
}
+/* Lists of formats to try, in order, when a specific render bit depth has
+ * been asked for. The second to last format in each list should always
+ * be XRGB8888, as a reliable backup in case the others are not available;
+ * the last should be DRM_FORMAT_INVALID, to indicate the end of the list. */
+static const uint32_t *bit_depth_preferences[] = {
+ [RENDER_BIT_DEPTH_8] = (const uint32_t []){
+ DRM_FORMAT_XRGB8888,
+ DRM_FORMAT_INVALID,
+ },
+ [RENDER_BIT_DEPTH_10] = (const uint32_t []){
+ DRM_FORMAT_XRGB2101010,
+ DRM_FORMAT_XBGR2101010,
+ DRM_FORMAT_XRGB8888,
+ DRM_FORMAT_INVALID,
+ },
+};
+
static void queue_output_config(struct output_config *oc,
struct sway_output *output) {
- if (output == root->noop_output) {
+ if (output == root->fallback_output) {
return;
}
@@ -437,10 +459,26 @@ static void queue_output_config(struct output_config *oc,
oc->adaptive_sync);
wlr_output_enable_adaptive_sync(wlr_output, oc->adaptive_sync == 1);
}
+
+ if (oc && oc->render_bit_depth != RENDER_BIT_DEPTH_DEFAULT) {
+ const uint32_t *fmts = bit_depth_preferences[oc->render_bit_depth];
+ assert(fmts);
+
+ for (size_t i = 0; fmts[i] != DRM_FORMAT_INVALID; i++) {
+ wlr_output_set_render_format(wlr_output, fmts[i]);
+ if (wlr_output_test(wlr_output)) {
+ break;
+ }
+
+ sway_log(SWAY_DEBUG, "Preferred output format 0x%08x "
+ "failed to work, falling back to next in "
+ "list, 0x%08x", fmts[i], fmts[i + 1]);
+ }
+ }
}
bool apply_output_config(struct output_config *oc, struct sway_output *output) {
- if (output == root->noop_output) {
+ if (output == root->fallback_output) {
return false;
}
@@ -535,7 +573,7 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) {
}
bool test_output_config(struct output_config *oc, struct sway_output *output) {
- if (output == root->noop_output) {
+ if (output == root->fallback_output) {
return false;
}
@@ -750,6 +788,8 @@ static bool _spawn_swaybg(char **command) {
sway_log_errno(SWAY_ERROR, "fork failed");
return false;
} else if (pid == 0) {
+ restore_nofile_limit();
+
pid = fork();
if (pid < 0) {
sway_log_errno(SWAY_ERROR, "fork failed");