From 5d412b2879deaf661a7bda593228e56c8f7aeb02 Mon Sep 17 00:00:00 2001
From: Consolatis <35009135+Consolatis@users.noreply.github.com>
Date: Wed, 31 Aug 2022 19:02:17 +0200
Subject: [PATCH] [wip] Preliminary support for overwriting subpixel rendering
Reported-by: @acoolstraw
---
docs/rc.xml.all | 1 +
include/config/rcxml.h | 2 ++
src/config/rcxml.c | 3 +++
src/output.c | 11 +++++++++++
4 files changed, 17 insertions(+)
diff --git a/docs/rc.xml.all b/docs/rc.xml.all
index 390599f8..94c17658 100644
--- a/docs/rc.xml.all
+++ b/docs/rc.xml.all
@@ -11,6 +11,7 @@
server
0
no
+ 0
no
yes
diff --git a/include/config/rcxml.h b/include/config/rcxml.h
index 3f6b248d..ed467c56 100644
--- a/include/config/rcxml.h
+++ b/include/config/rcxml.h
@@ -5,6 +5,7 @@
#include
#include
#include
+#include
#include "common/buf.h"
#include "config/libinput.h"
@@ -17,6 +18,7 @@ struct rcxml {
bool xdg_shell_server_side_deco;
int gap;
bool adaptive_sync;
+ enum wl_output_subpixel subpixel;
/* focus */
bool focus_follow_mouse;
diff --git a/src/config/rcxml.c b/src/config/rcxml.c
index c0a92991..a17c9780 100644
--- a/src/config/rcxml.c
+++ b/src/config/rcxml.c
@@ -360,6 +360,8 @@ entry(xmlNode *node, char *nodename, char *content)
rc.gap = atoi(content);
} else if (!strcasecmp(nodename, "adaptiveSync.core")) {
rc.adaptive_sync = get_bool(content);
+ } else if (!strcasecmp(nodename, "subpixel.core")) {
+ rc.subpixel = atoi(content);
} else if (!strcmp(nodename, "name.theme")) {
rc.theme_name = strdup(content);
} else if (!strcmp(nodename, "cornerradius.theme")) {
@@ -490,6 +492,7 @@ rcxml_init()
wl_list_init(&rc.mousebinds);
wl_list_init(&rc.libinput_categories);
rc.xdg_shell_server_side_deco = true;
+ rc.subpixel = WL_OUTPUT_SUBPIXEL_UNKNOWN;
rc.corner_radius = 8;
rc.font_size_activewindow = 10;
rc.font_size_menuitem = 10;
diff --git a/src/output.c b/src/output.c
index d441e734..a948bc21 100644
--- a/src/output.c
+++ b/src/output.c
@@ -9,6 +9,7 @@
#define _POSIX_C_SOURCE 200809L
#include "config.h"
#include
+#include
#include
#include
#include
@@ -16,6 +17,7 @@
#include
#include
#include
+
#include "buffer.h"
#include "labwc.h"
#include "layers.h"
@@ -106,6 +108,15 @@ new_output_notify(struct wl_listener *listener, void *data)
wlr_output_preferred_mode(wlr_output);
wlr_output_set_mode(wlr_output, preferred_mode);
+ /* Allow to overwrite subpixel rendering */
+ if (rc.subpixel != WL_OUTPUT_SUBPIXEL_UNKNOWN
+ && rc.subpixel != wlr_output->subpixel) {
+ wlr_log(WLR_ERROR,
+ "changing configured output subpixel rendering from %u to %u",
+ wlr_output->subpixel, rc.subpixel);
+ wlr_output_set_subpixel(wlr_output, rc.subpixel);
+ }
+
/*
* Sometimes the preferred mode is not available due to hardware
* constraints (e.g. GPU or cable bandwidth limitations). In these