aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2025-03-23 13:21:19 +0100
committerMattias Andrée <m@maandree.se>2025-03-23 14:16:10 +0100
commit86433cea917715559d496ad0561d6b10bc89d7e5 (patch)
tree0216fd2d2d37c094d2c97584301f3434d5a4677b
parentUpdate todo list (diff)
downloadredshift-ng-86433cea917715559d496ad0561d6b10bc89d7e5.tar.gz
redshift-ng-86433cea917715559d496ad0561d6b10bc89d7e5.tar.bz2
redshift-ng-86433cea917715559d496ad0561d6b10bc89d7e5.tar.xz
Rewrite gamma-randr.c and gamma-vidmode.c to use libgamma
Signed-off-by: Mattias Andrée <m@maandree.se>
-rw-r--r--TODO4
-rw-r--r--po/be.po22
-rw-r--r--po/ca.po21
-rw-r--r--po/cs.po22
-rw-r--r--po/da.po21
-rw-r--r--po/de.po21
-rw-r--r--po/el.po17
-rw-r--r--po/en_GB.po21
-rw-r--r--po/eo.po17
-rw-r--r--po/es.po21
-rw-r--r--po/eu.po21
-rw-r--r--po/fi.po17
-rw-r--r--po/fr.po17
-rw-r--r--po/gl.po17
-rw-r--r--po/he.po17
-rw-r--r--po/hi.po17
-rw-r--r--po/hr.po17
-rw-r--r--po/hu.po22
-rw-r--r--po/it.po17
-rw-r--r--po/ja.po21
-rw-r--r--po/lt.po17
-rw-r--r--po/nb.po17
-rw-r--r--po/nl.po21
-rw-r--r--po/oc.po17
-rw-r--r--po/pl.po17
-rw-r--r--po/pt.po17
-rw-r--r--po/pt_BR.po17
-rw-r--r--po/redshift.pot17
-rw-r--r--po/ro.po17
-rw-r--r--po/ru.po17
-rw-r--r--po/sr.po17
-rw-r--r--po/sv.po17
-rw-r--r--po/tr.po17
-rw-r--r--po/uk.po21
-rw-r--r--po/zh_CN.po22
-rw-r--r--po/zh_TW.po21
-rw-r--r--src/Makefile1
-rw-r--r--src/backend-direct.c608
-rw-r--r--src/colour.c2
-rw-r--r--src/common.h88
-rw-r--r--src/config.mk4
-rw-r--r--src/gamma-coopgamma.c6
-rw-r--r--src/gamma-randr.c381
-rw-r--r--src/gamma-vidmode.c157
44 files changed, 944 insertions, 962 deletions
diff --git a/TODO b/TODO
index cd6d514..237f850 100644
--- a/TODO
+++ b/TODO
@@ -143,3 +143,7 @@ When disabled, redshift should be periodically set the gamma ramps
Add signals for setting location
Add signals for responding with sigqueue the state of redshift
Document option delimiter for -l and -m
+
+Add support for selecting multiple screens
+Add support for prefixing CRTC with screen/card number (e.g. "1.2" for CRTC 2 on screen 1)
+Properly document how provider/method options are separated
diff --git a/po/be.po b/po/be.po
index a1dd30f..adcfc4b 100644
--- a/po/be.po
+++ b/po/be.po
@@ -592,15 +592,14 @@ msgstr "Немагчыма аднавіць CRTC %i."
msgid "Adjust gamma ramps with the X RANDR extension.\n"
msgstr "Наладзіць гаму з пашырэннем X RANDR.\n"
-#. TRANSLATORS: RANDR help output
-#. left column must not be translated
+#. TRANSLATORS: RANDR help output left column must not be translated
#: ../src/gamma-randr.c:306
-msgid ""
-" screen=N\t\tX screen to apply adjustments to\n"
-" crtc=N\tList of comma separated CRTCs to apply adjustments to\n"
+msgid " screen=N X screen to apply adjustments to\n"
+msgstr " screen=N X экран для ўжывання змен для\n"
+
+#: ../src/gamma-randr.c:306
+msgid " crtc=N List of comma-separated CRTCs to apply adjustments to\n"
msgstr ""
-" screen=N\t\tX экран для ўжывання змен для\n"
-" preserve={0,1}\tЦі мусіць быць захавана існуючая гама\n"
#: ../src/gamma-randr.c:328
#, c-format
@@ -624,15 +623,6 @@ msgstr "Памылка падчас запыту да X : %s"
msgid "Adjust gamma ramps with the X VidMode extension.\n"
msgstr "Наладзіць гаму з пашырэннем X VidMode.\n"
-#. TRANSLATORS: VidMode help output
-#. left column must not be translated
-#: ../src/gamma-vidmode.c:145
-msgid " screen=N\t\tX screen to apply adjustments to\n"
-msgstr ""
-" screen=N\t\tX экран для ўжывання змен для\n"
-" crtc=N\t\tCRTC для ўжывання змен\n"
-" preserve={0,1}\tЦі мусіць быць захавана існуючая гама\n"
-
#: ../src/gamma-quartz.c:140 ../src/gamma-w32gdi.c:91
msgid "Unable to save current gamma ramp."
msgstr "Немагчыма захаваць дзейную гаму."
diff --git a/po/ca.po b/po/ca.po
index 3fffd16..b92cd16 100644
--- a/po/ca.po
+++ b/po/ca.po
@@ -598,15 +598,14 @@ msgstr "No es pot restablir el CRTC %i."
msgid "Adjust gamma ramps with the X RANDR extension.\n"
msgstr "Ajustar los valores gamma con la extensión X RANDR\n"
-#. TRANSLATORS: RANDR help output
-#. left column must not be translated
+#. TRANSLATORS: RANDR help output left column must not be translated
#: ../src/gamma-randr.c:306
-msgid ""
-" screen=N\t\tX screen to apply adjustments to\n"
-" crtc=N\tList of comma separated CRTCs to apply adjustments to\n"
-msgstr ""
-" screen=N\t\tPantalla X per aplicar els ajustos\n"
-" crtc=N\\Llista dels CRTC, separats per comes, per aplicar els ajustos\n"
+msgid " screen=N X screen to apply adjustments to\n"
+msgstr " screen=N Pantalla X per aplicar els ajustos\n"
+
+#: ../src/gamma-randr.c:306
+msgid " crtc=N List of comma-separated CRTCs to apply adjustments to\n"
+msgstr " crtc=N Llista dels CRTC, separats per comes, per aplicar els ajustos\n"
#: ../src/gamma-randr.c:328
#, c-format
@@ -630,12 +629,6 @@ msgstr "La sol·licitud X ha fallat: %s"
msgid "Adjust gamma ramps with the X VidMode extension.\n"
msgstr "Ajusta els valors gamma amb l'extensió X VidMode\n"
-#. TRANSLATORS: VidMode help output
-#. left column must not be translated
-#: ../src/gamma-vidmode.c:145
-msgid " screen=N\t\tX screen to apply adjustments to\n"
-msgstr " screen=N\t\tPantalla X per aplicar els ajustos\n"
-
#: ../src/gamma-quartz.c:140 ../src/gamma-w32gdi.c:91
msgid "Unable to save current gamma ramp."
msgstr "No es pot desar el valor gamma actual."
diff --git a/po/cs.po b/po/cs.po
index bafd450..48d76a8 100644
--- a/po/cs.po
+++ b/po/cs.po
@@ -600,16 +600,14 @@ msgid "Adjust gamma ramps with the X RANDR extension.\n"
msgstr ""
"Přizpůsobit hodnoty gama korekce pomocí rozšíření RANDR graf. serveru X.\n"
-#. TRANSLATORS: RANDR help output
-#. left column must not be translated
+#. TRANSLATORS: RANDR help output left column must not be translated
#: ../src/gamma-randr.c:306
-msgid ""
-" screen=N\t\tX screen to apply adjustments to\n"
-" crtc=N\tList of comma separated CRTCs to apply adjustments to\n"
-msgstr ""
-" screen=N\t\tobrazovka graf. serveru X na kterou úpravu použít\n"
-" crtc=N\tSeznam čárkou oddělených obrazových výstupů na který úpravu "
-"použít\n"
+msgid " screen=N X screen to apply adjustments to\n"
+msgstr " screen=N obrazovka graf. serveru X na kterou úpravu použít\n"
+
+#: ../src/gamma-randr.c:306
+msgid " crtc=N List of comma-separated CRTCs to apply adjustments to\n"
+msgstr " crtc=N Seznam čárkou oddělených obrazových výstupů na který úpravu použít\n"
#: ../src/gamma-randr.c:328
#, c-format
@@ -633,12 +631,6 @@ msgstr "Požadavek na graf. server X nebyl v pořádku vyřízen: %s"
msgid "Adjust gamma ramps with the X VidMode extension.\n"
msgstr "Přizpůsobit gama korekci pomocí rozšíření VidMode graf. serveru X.\n"
-#. TRANSLATORS: VidMode help output
-#. left column must not be translated
-#: ../src/gamma-vidmode.c:145
-msgid " screen=N\t\tX screen to apply adjustments to\n"
-msgstr " screen=N\t\tobrazovka graf. serveru X na který úpravu použít\n"
-
#: ../src/gamma-quartz.c:140 ../src/gamma-w32gdi.c:91
msgid "Unable to save current gamma ramp."
msgstr "Stávající gama křivku nebylo možné uložit."
diff --git a/po/da.po b/po/da.po
index 3e7a000..df6e132 100644
--- a/po/da.po
+++ b/po/da.po
@@ -591,15 +591,14 @@ msgstr "Kan ikke genskabe CRTC %i."
msgid "Adjust gamma ramps with the X RANDR extension.\n"
msgstr "Juster gammatabellerne med X RANDR udvidelsen.\n"
-#. TRANSLATORS: RANDR help output
-#. left column must not be translated
+#. TRANSLATORS: RANDR help output left column must not be translated
#: ../src/gamma-randr.c:306
-msgid ""
-" screen=N\t\tX screen to apply adjustments to\n"
-" crtc=N\tList of comma separated CRTCs to apply adjustments to\n"
-msgstr ""
-" screen=N\t\tX-skærm som skal justeres\n"
-" crtc=N\tListe over kommasepareret CRTC'er som skal justeres\n"
+msgid " screen=N X screen to apply adjustments to\n"
+msgstr " screen=N X-skærm som skal justeres\n"
+
+#: ../src/gamma-randr.c:306
+msgid " crtc=N List of comma-separated CRTCs to apply adjustments to\n"
+msgstr " crtc=N Liste over kommasepareret CRTC'er som skal justeres\n"
#: ../src/gamma-randr.c:328
#, c-format
@@ -623,12 +622,6 @@ msgstr "X-anmodning mislykkede: %s"
msgid "Adjust gamma ramps with the X VidMode extension.\n"
msgstr "Juster gammatabellerne med X VidMode udvidelsen.\n"
-#. TRANSLATORS: VidMode help output
-#. left column must not be translated
-#: ../src/gamma-vidmode.c:145
-msgid " screen=N\t\tX screen to apply adjustments to\n"
-msgstr " screen=N\t\tX-skærm som skal justeres\n"
-
#: ../src/gamma-quartz.c:140 ../src/gamma-w32gdi.c:91
msgid "Unable to save current gamma ramp."
msgstr "Kan ikke gemme nuværende gammatabeller."
diff --git a/po/de.po b/po/de.po
index b3fa2dd..c8aed9a 100644
--- a/po/de.po
+++ b/po/de.po
@@ -594,15 +594,14 @@ msgstr "CRTC %i konnte nicht wiederhergestellt werden."
msgid "Adjust gamma ramps with the X RANDR extension.\n"
msgstr "Gamma-Anstieg mit der X-RANDR-Erweiterung ändern.\n"
-#. TRANSLATORS: RANDR help output
-#. left column must not be translated
+#. TRANSLATORS: RANDR help output left column must not be translated
#: ../src/gamma-randr.c:306
-msgid ""
-" screen=N\t\tX screen to apply adjustments to\n"
-" crtc=N\tList of comma separated CRTCs to apply adjustments to\n"
-msgstr ""
-" screen=N\t\tX-Schirm zum Anpassen\n"
-" crtc=N\tListe von durch Komma getrennter CRTCs zum Anpassen\n"
+msgid " screen=N X screen to apply adjustments to\n"
+msgstr " screen=N X-Schirm zum Anpassen\n"
+
+#: ../src/gamma-randr.c:306
+msgid " crtc=N List of comma-separated CRTCs to apply adjustments to\n"
+msgstr " crtc=N Liste von durch Komma getrennter CRTCs zum Anpassen\n"
#: ../src/gamma-randr.c:328
#, c-format
@@ -626,12 +625,6 @@ msgstr "X-Anfrage ist fehlgeschlagen: %s"
msgid "Adjust gamma ramps with the X VidMode extension.\n"
msgstr "Gamma-Änstiegswerte mit der X-VidMode-Erweiterung ändern.\n"
-#. TRANSLATORS: VidMode help output
-#. left column must not be translated
-#: ../src/gamma-vidmode.c:145
-msgid " screen=N\t\tX screen to apply adjustments to\n"
-msgstr " screen=N\t\tX-Schirm zum Anpassen\n"
-
#: ../src/gamma-quartz.c:140 ../src/gamma-w32gdi.c:91
msgid "Unable to save current gamma ramp."
msgstr "Aktueller Gamma-Anstieg konnte nicht gespeichert werden."
diff --git a/po/el.po b/po/el.po
index bed1baa..53431f7 100644
--- a/po/el.po
+++ b/po/el.po
@@ -549,12 +549,13 @@ msgstr ""
msgid "Adjust gamma ramps with the X RANDR extension.\n"
msgstr ""
-#. TRANSLATORS: RANDR help output
-#. left column must not be translated
+#. TRANSLATORS: RANDR help output left column must not be translated
#: ../src/gamma-randr.c:306
-msgid ""
-" screen=N\t\tX screen to apply adjustments to\n"
-" crtc=N\tList of comma separated CRTCs to apply adjustments to\n"
+msgid " screen=N X screen to apply adjustments to\n"
+msgstr ""
+
+#: ../src/gamma-randr.c:306
+msgid " crtc=N List of comma-separated CRTCs to apply adjustments to\n"
msgstr ""
#: ../src/gamma-randr.c:328
@@ -579,12 +580,6 @@ msgstr ""
msgid "Adjust gamma ramps with the X VidMode extension.\n"
msgstr ""
-#. TRANSLATORS: VidMode help output
-#. left column must not be translated
-#: ../src/gamma-vidmode.c:145
-msgid " screen=N\t\tX screen to apply adjustments to\n"
-msgstr ""
-
#: ../src/gamma-quartz.c:140 ../src/gamma-w32gdi.c:91
msgid "Unable to save current gamma ramp."
msgstr ""
diff --git a/po/en_GB.po b/po/en_GB.po
index e0eb00e..55a5175 100644
--- a/po/en_GB.po
+++ b/po/en_GB.po
@@ -592,15 +592,14 @@ msgstr "Unable to restore CRTC %i."
msgid "Adjust gamma ramps with the X RANDR extension.\n"
msgstr "Adjust gamma ramps with the X RANDR extension.\n"
-#. TRANSLATORS: RANDR help output
-#. left column must not be translated
+#. TRANSLATORS: RANDR help output left column must not be translated
#: ../src/gamma-randr.c:306
-msgid ""
-" screen=N\t\tX screen to apply adjustments to\n"
-" crtc=N\tList of comma separated CRTCs to apply adjustments to\n"
-msgstr ""
-" screen=N\t\tX screen to apply adjustments to\n"
-" crtc=N\tList of comma separated CRTCs to apply adjustments to\n"
+msgid " screen=N X screen to apply adjustments to\n"
+msgstr " screen=N X screen to apply adjustments to\n"
+
+#: ../src/gamma-randr.c:306
+msgid " crtc=N List of comma-separated CRTCs to apply adjustments to\n"
+msgstr " crtc=N List of comma-separated CRTCs to apply adjustments to\n"
#: ../src/gamma-randr.c:328
#, c-format
@@ -624,12 +623,6 @@ msgstr "X request failed: %s"
msgid "Adjust gamma ramps with the X VidMode extension.\n"
msgstr "Adjust gamma ramps with the X VidMode extension.\n"
-#. TRANSLATORS: VidMode help output
-#. left column must not be translated
-#: ../src/gamma-vidmode.c:145
-msgid " screen=N\t\tX screen to apply adjustments to\n"
-msgstr " screen=N\t\tX screen to apply adjustments to\n"
-
#: ../src/gamma-quartz.c:140 ../src/gamma-w32gdi.c:91
msgid "Unable to save current gamma ramp."
msgstr "Unable to save current gamma ramp."
diff --git a/po/eo.po b/po/eo.po
index 7bc332e..32c0906 100644
--- a/po/eo.po
+++ b/po/eo.po
@@ -556,12 +556,13 @@ msgstr ""
msgid "Adjust gamma ramps with the X RANDR extension.\n"
msgstr ""
-#. TRANSLATORS: RANDR help output
-#. left column must not be translated
+#. TRANSLATORS: RANDR help output left column must not be translated
#: ../src/gamma-randr.c:306
-msgid ""
-" screen=N\t\tX screen to apply adjustments to\n"
-" crtc=N\tList of comma separated CRTCs to apply adjustments to\n"
+msgid " screen=N X screen to apply adjustments to\n"
+msgstr ""
+
+#: ../src/gamma-randr.c:306
+msgid " crtc=N List of comma-separated CRTCs to apply adjustments to\n"
msgstr ""
#: ../src/gamma-randr.c:328
@@ -586,12 +587,6 @@ msgstr ""
msgid "Adjust gamma ramps with the X VidMode extension.\n"
msgstr ""
-#. TRANSLATORS: VidMode help output
-#. left column must not be translated
-#: ../src/gamma-vidmode.c:145
-msgid " screen=N\t\tX screen to apply adjustments to\n"
-msgstr ""
-
#: ../src/gamma-quartz.c:140 ../src/gamma-w32gdi.c:91
msgid "Unable to save current gamma ramp."
msgstr ""
diff --git a/po/es.po b/po/es.po
index a3fc134..99d0740 100644
--- a/po/es.po
+++ b/po/es.po
@@ -602,15 +602,14 @@ msgstr "No se puede restablecer el CRTC %i."
msgid "Adjust gamma ramps with the X RANDR extension.\n"
msgstr "Ajustar los valores gamma con la extensión X RANDR\n"
-#. TRANSLATORS: RANDR help output
-#. left column must not be translated
+#. TRANSLATORS: RANDR help output left column must not be translated
#: ../src/gamma-randr.c:306
-msgid ""
-" screen=N\t\tX screen to apply adjustments to\n"
-" crtc=N\tList of comma separated CRTCs to apply adjustments to\n"
-msgstr ""
-" screen=N\t\tPantalla X para aplicar los ajustes\n"
-" crtc=N\tLista de los CRTC, separados por comas, para aplicar los ajustes\n"
+msgid " screen=N X screen to apply adjustments to\n"
+msgstr " screen=N Pantalla X para aplicar los ajustes\n"
+
+#: ../src/gamma-randr.c:306
+msgid " crtc=N List of comma-separated CRTCs to apply adjustments to\n"
+msgstr " crtc=N Lista de los CRTC, separados por comas, para aplicar los ajustes\n"
#: ../src/gamma-randr.c:328
#, c-format
@@ -634,12 +633,6 @@ msgstr "La solicitud X ha fallado: %s"
msgid "Adjust gamma ramps with the X VidMode extension.\n"
msgstr "Ajustar los valores gamma con la extensión X VidMode.\n"
-#. TRANSLATORS: VidMode help output
-#. left column must not be translated
-#: ../src/gamma-vidmode.c:145
-msgid " screen=N\t\tX screen to apply adjustments to\n"
-msgstr " screen=N\t\tPantalla X para aplicar los ajustes\n"
-
#: ../src/gamma-quartz.c:140 ../src/gamma-w32gdi.c:91
msgid "Unable to save current gamma ramp."
msgstr "No se puede guardar el valor gamma actual."
diff --git a/po/eu.po b/po/eu.po
index 97f4aae..a807f8e 100644
--- a/po/eu.po
+++ b/po/eu.po
@@ -590,15 +590,14 @@ msgstr "Ezin izan da CRTCa berrezarri %i."
msgid "Adjust gamma ramps with the X RANDR extension.\n"
msgstr "Doitu gammaren ramp-ak X RANDR hedapenarekin.\n"
-#. TRANSLATORS: RANDR help output
-#. left column must not be translated
+#. TRANSLATORS: RANDR help output left column must not be translated
#: ../src/gamma-randr.c:306
-msgid ""
-" screen=N\t\tX screen to apply adjustments to\n"
-" crtc=N\tList of comma separated CRTCs to apply adjustments to\n"
-msgstr ""
-" screen=N\t\tdoitzeak aplikatzeko X pantaila\n"
-" crtc=N\tdoitzeak aplikatzeko koma bidez bereizitako CRTCen zerrenda\n"
+msgid " screen=N X screen to apply adjustments to\n"
+msgstr " screen=N doitzeak aplikatzeko X pantaila\n"
+
+#: ../src/gamma-randr.c:306
+msgid " crtc=N List of comma-separated CRTCs to apply adjustments to\n"
+msgstr " crtc=N doitzeak aplikatzeko koma bidez bereizitako CRTCen zerrenda\n"
#: ../src/gamma-randr.c:328
#, c-format
@@ -622,12 +621,6 @@ msgstr "X eskaerak huts egin du: %s"
msgid "Adjust gamma ramps with the X VidMode extension.\n"
msgstr "Doitu gammaren ramp-ak X VidMode hedapenarekin.\n"
-#. TRANSLATORS: VidMode help output
-#. left column must not be translated
-#: ../src/gamma-vidmode.c:145
-msgid " screen=N\t\tX screen to apply adjustments to\n"
-msgstr " screen=N\t\tdoikuntzak aplikatzeko X pantaila "
-
#: ../src/gamma-quartz.c:140 ../src/gamma-w32gdi.c:91
msgid "Unable to save current gamma ramp."
msgstr "Ezin izan da uneko gammaren ramp-a gorde."
diff --git a/po/fi.po b/po/fi.po
index 0cf46a4..f777e3d 100644
--- a/po/fi.po
+++ b/po/fi.po
@@ -561,12 +561,13 @@ msgstr "Ei kyetä palauttamaan CRTC %i."
msgid "Adjust gamma ramps with the X RANDR extension.\n"
msgstr "Säädä gamman askellusta X RANDR laajennusta käyttäen.\n"
-#. TRANSLATORS: RANDR help output
-#. left column must not be translated
+#. TRANSLATORS: RANDR help output left column must not be translated
#: ../src/gamma-randr.c:306
-msgid ""
-" screen=N\t\tX screen to apply adjustments to\n"
-" crtc=N\tList of comma separated CRTCs to apply adjustments to\n"
+msgid " screen=N X screen to apply adjustments to\n"
+msgstr ""
+
+#: ../src/gamma-randr.c:306
+msgid " crtc=N List of comma-separated CRTCs to apply adjustments to\n"
msgstr ""
#: ../src/gamma-randr.c:328
@@ -591,12 +592,6 @@ msgstr "X-kutsu epäonnistui: %s"
msgid "Adjust gamma ramps with the X VidMode extension.\n"
msgstr "Säädä gamman askellusta X VidMode laajennuksella.\n"
-#. TRANSLATORS: VidMode help output
-#. left column must not be translated
-#: ../src/gamma-vidmode.c:145
-msgid " screen=N\t\tX screen to apply adjustments to\n"
-msgstr ""
-
#: ../src/gamma-quartz.c:140 ../src/gamma-w32gdi.c:91
msgid "Unable to save current gamma ramp."
msgstr ""
diff --git a/po/fr.po b/po/fr.po
index d529b3b..38ee96e 100644
--- a/po/fr.po
+++ b/po/fr.po
@@ -606,12 +606,13 @@ msgstr "Impossible de rétablir CRTC %i."
msgid "Adjust gamma ramps with the X RANDR extension.\n"
msgstr "Ajuster les rampes gamma avec l'extension X RANDR.\n"
-#. TRANSLATORS: RANDR help output
-#. left column must not be translated
+#. TRANSLATORS: RANDR help output left column must not be translated
#: ../src/gamma-randr.c:306
-msgid ""
-" screen=N\t\tX screen to apply adjustments to\n"
-" crtc=N\tList of comma separated CRTCs to apply adjustments to\n"
+msgid " screen=N X screen to apply adjustments to\n"
+msgstr ""
+
+#: ../src/gamma-randr.c:306
+msgid " crtc=N List of comma-separated CRTCs to apply adjustments to\n"
msgstr ""
#: ../src/gamma-randr.c:328
@@ -636,12 +637,6 @@ msgstr "La requête X a échoué : %s"
msgid "Adjust gamma ramps with the X VidMode extension.\n"
msgstr "Ajuster les rampes gamma avec l'extension X VidMode.\n"
-#. TRANSLATORS: VidMode help output
-#. left column must not be translated
-#: ../src/gamma-vidmode.c:145
-msgid " screen=N\t\tX screen to apply adjustments to\n"
-msgstr ""
-
#: ../src/gamma-quartz.c:140 ../src/gamma-w32gdi.c:91
msgid "Unable to save current gamma ramp."
msgstr "Impossible d'enregistrer la rampe gamma actuelle."
diff --git a/po/gl.po b/po/gl.po
index e5ebce5..155cf68 100644
--- a/po/gl.po
+++ b/po/gl.po
@@ -554,12 +554,13 @@ msgstr "Non foi posíbel restituir CRTC %i."
msgid "Adjust gamma ramps with the X RANDR extension.\n"
msgstr ""
-#. TRANSLATORS: RANDR help output
-#. left column must not be translated
+#. TRANSLATORS: RANDR help output left column must not be translated
#: ../src/gamma-randr.c:306
-msgid ""
-" screen=N\t\tX screen to apply adjustments to\n"
-" crtc=N\tList of comma separated CRTCs to apply adjustments to\n"
+msgid " screen=N X screen to apply adjustments to\n"
+msgstr ""
+
+#: ../src/gamma-randr.c:306
+msgid " crtc=N List of comma-separated CRTCs to apply adjustments to\n"
msgstr ""
#: ../src/gamma-randr.c:328
@@ -584,12 +585,6 @@ msgstr ""
msgid "Adjust gamma ramps with the X VidMode extension.\n"
msgstr ""
-#. TRANSLATORS: VidMode help output
-#. left column must not be translated
-#: ../src/gamma-vidmode.c:145
-msgid " screen=N\t\tX screen to apply adjustments to\n"
-msgstr ""
-
#: ../src/gamma-quartz.c:140 ../src/gamma-w32gdi.c:91
msgid "Unable to save current gamma ramp."
msgstr ""
diff --git a/po/he.po b/po/he.po
index 09c121f..7de0f18 100644
--- a/po/he.po
+++ b/po/he.po
@@ -551,12 +551,13 @@ msgstr ""
msgid "Adjust gamma ramps with the X RANDR extension.\n"
msgstr ""
-#. TRANSLATORS: RANDR help output
-#. left column must not be translated
+#. TRANSLATORS: RANDR help output left column must not be translated
#: ../src/gamma-randr.c:306
-msgid ""
-" screen=N\t\tX screen to apply adjustments to\n"
-" crtc=N\tList of comma separated CRTCs to apply adjustments to\n"
+msgid " screen=N X screen to apply adjustments to\n"
+msgstr ""
+
+#: ../src/gamma-randr.c:306
+msgid " crtc=N List of comma-separated CRTCs to apply adjustments to\n"
msgstr ""
#: ../src/gamma-randr.c:328
@@ -581,12 +582,6 @@ msgstr ""
msgid "Adjust gamma ramps with the X VidMode extension.\n"
msgstr ""
-#. TRANSLATORS: VidMode help output
-#. left column must not be translated
-#: ../src/gamma-vidmode.c:145
-msgid " screen=N\t\tX screen to apply adjustments to\n"
-msgstr ""
-
#: ../src/gamma-quartz.c:140 ../src/gamma-w32gdi.c:91
msgid "Unable to save current gamma ramp."
msgstr ""
diff --git a/po/hi.po b/po/hi.po
index bbae145..5b3f994 100644
--- a/po/hi.po
+++ b/po/hi.po
@@ -552,12 +552,13 @@ msgstr ""
msgid "Adjust gamma ramps with the X RANDR extension.\n"
msgstr ""
-#. TRANSLATORS: RANDR help output
-#. left column must not be translated
+#. TRANSLATORS: RANDR help output left column must not be translated
#: ../src/gamma-randr.c:306
-msgid ""
-" screen=N\t\tX screen to apply adjustments to\n"
-" crtc=N\tList of comma separated CRTCs to apply adjustments to\n"
+msgid " screen=N X screen to apply adjustments to\n"
+msgstr ""
+
+#: ../src/gamma-randr.c:306
+msgid " crtc=N List of comma-separated CRTCs to apply adjustments to\n"
msgstr ""
#: ../src/gamma-randr.c:328
@@ -582,12 +583,6 @@ msgstr ""
msgid "Adjust gamma ramps with the X VidMode extension.\n"
msgstr ""
-#. TRANSLATORS: VidMode help output
-#. left column must not be translated
-#: ../src/gamma-vidmode.c:145
-msgid " screen=N\t\tX screen to apply adjustments to\n"
-msgstr ""
-
#: ../src/gamma-quartz.c:140 ../src/gamma-w32gdi.c:91
msgid "Unable to save current gamma ramp."
msgstr ""
diff --git a/po/hr.po b/po/hr.po
index 2744522..2aa2271 100644
--- a/po/hr.po
+++ b/po/hr.po
@@ -559,12 +559,13 @@ msgstr "Nije moguće povratiti CRTC %i."
msgid "Adjust gamma ramps with the X RANDR extension.\n"
msgstr "Prilagodi gama krivulju sa X RANDR proširenjem.\n"
-#. TRANSLATORS: RANDR help output
-#. left column must not be translated
+#. TRANSLATORS: RANDR help output left column must not be translated
#: ../src/gamma-randr.c:306
-msgid ""
-" screen=N\t\tX screen to apply adjustments to\n"
-" crtc=N\tList of comma separated CRTCs to apply adjustments to\n"
+msgid " screen=N X screen to apply adjustments to\n"
+msgstr ""
+
+#: ../src/gamma-randr.c:306
+msgid " crtc=N List of comma-separated CRTCs to apply adjustments to\n"
msgstr ""
#: ../src/gamma-randr.c:328
@@ -589,12 +590,6 @@ msgstr "X zahtjev nije uspio: %s"
msgid "Adjust gamma ramps with the X VidMode extension.\n"
msgstr "Prilagodi gama krivulju sa X VidMode proširenjem.\n"
-#. TRANSLATORS: VidMode help output
-#. left column must not be translated
-#: ../src/gamma-vidmode.c:145
-msgid " screen=N\t\tX screen to apply adjustments to\n"
-msgstr ""
-
#: ../src/gamma-quartz.c:140 ../src/gamma-w32gdi.c:91
msgid "Unable to save current gamma ramp."
msgstr "Nije moguće spremiti trenutnu gama krivulju."
diff --git a/po/hu.po b/po/hu.po
index 588c646..6f0385f 100644
--- a/po/hu.po
+++ b/po/hu.po
@@ -576,16 +576,14 @@ msgstr "Nem tudja visszaállítani a CRTC %i."
msgid "Adjust gamma ramps with the X RANDR extension.\n"
msgstr "Gamma emelkedés beállítása a X RANDR kiterjesztéssel.\n"
-#. TRANSLATORS: RANDR help output
-#. left column must not be translated
+#. TRANSLATORS: RANDR help output left column must not be translated
#: ../src/gamma-randr.c:306
-msgid ""
-" screen=N\t\tX screen to apply adjustments to\n"
-" crtc=N\tList of comma separated CRTCs to apply adjustments to\n"
-msgstr ""
-" screen=N\t\tX képernyö, amire a beállítások érvényesek lesznek\n"
-" crtc=N\tVesszőkkel elválasztott CRTC-lista, amire a beállítások érvényesek "
-"lesznek\n"
+msgid " screen=N X screen to apply adjustments to\n"
+msgstr " screen=N X képernyö, amire a beállítások érvényesek lesznek\n"
+
+#: ../src/gamma-randr.c:306
+msgid " crtc=N List of comma-separated CRTCs to apply adjustments to\n"
+msgstr " crtc=N Vesszőkkel elválasztott CRTC-lista, amire a beállítások érvényesek lesznek\n"
#: ../src/gamma-randr.c:328
#, c-format
@@ -609,12 +607,6 @@ msgstr "X igénylés hibás: %s"
msgid "Adjust gamma ramps with the X VidMode extension.\n"
msgstr "Gamma emelkedés beállításai az X VidMode kiterjesztéssel.\n"
-#. TRANSLATORS: VidMode help output
-#. left column must not be translated
-#: ../src/gamma-vidmode.c:145
-msgid " screen=N\t\tX screen to apply adjustments to\n"
-msgstr ""
-
#: ../src/gamma-quartz.c:140 ../src/gamma-w32gdi.c:91
msgid "Unable to save current gamma ramp."
msgstr "Nem tudja menteni a jelenlegi gamma emelkedést."
diff --git a/po/it.po b/po/it.po
index 4c2217a..b7e22aa 100644
--- a/po/it.po
+++ b/po/it.po
@@ -572,12 +572,13 @@ msgstr "Impossibile ripristinare CRTC %i."
msgid "Adjust gamma ramps with the X RANDR extension.\n"
msgstr "Regolare la scala di gamma con l'estensione di X RANDR.\n"
-#. TRANSLATORS: RANDR help output
-#. left column must not be translated
+#. TRANSLATORS: RANDR help output left column must not be translated
#: ../src/gamma-randr.c:306
-msgid ""
-" screen=N\t\tX screen to apply adjustments to\n"
-" crtc=N\tList of comma separated CRTCs to apply adjustments to\n"
+msgid " screen=N X screen to apply adjustments to\n"
+msgstr ""
+
+#: ../src/gamma-randr.c:306
+msgid " crtc=N List of comma-separated CRTCs to apply adjustments to\n"
msgstr ""
#: ../src/gamma-randr.c:328
@@ -602,12 +603,6 @@ msgstr "Richiesta X non riuscita: %s"
msgid "Adjust gamma ramps with the X VidMode extension.\n"
msgstr "Regolare la scala di gamma con l'estensione di X VidMode.\n"
-#. TRANSLATORS: VidMode help output
-#. left column must not be translated
-#: ../src/gamma-vidmode.c:145
-msgid " screen=N\t\tX screen to apply adjustments to\n"
-msgstr ""
-
#: ../src/gamma-quartz.c:140 ../src/gamma-w32gdi.c:91
msgid "Unable to save current gamma ramp."
msgstr "Impossibile salvare la scala di gamma attuale."
diff --git a/po/ja.po b/po/ja.po
index 3fb430e..37524a5 100644
--- a/po/ja.po
+++ b/po/ja.po
@@ -580,15 +580,14 @@ msgstr "CRTC %i を復元できません."
msgid "Adjust gamma ramps with the X RANDR extension.\n"
msgstr "X RANDR 拡張を用いてガンマ ランプを調整します。\n"
-#. TRANSLATORS: RANDR help output
-#. left column must not be translated
+#. TRANSLATORS: RANDR help output left column must not be translated
#: ../src/gamma-randr.c:306
-msgid ""
-" screen=N\t\tX screen to apply adjustments to\n"
-" crtc=N\tList of comma separated CRTCs to apply adjustments to\n"
-msgstr ""
-" screen=N\t\t調整を適用する X のスクリーン\n"
-" crtc=N\t\t調整を適用する CRTC のコンマ区切りの一覧\n"
+msgid " screen=N X screen to apply adjustments to\n"
+msgstr " screen=N 調整を適用する X のスクリーン\n"
+
+#: ../src/gamma-randr.c:306
+msgid " crtc=N List of comma-separated CRTCs to apply adjustments to\n"
+msgstr " crtc=N 調整を適用する CRTC のコンマ区切りの一覧\n"
#: ../src/gamma-randr.c:328
#, c-format
@@ -612,12 +611,6 @@ msgstr "X のリクエストに失敗しました: %s"
msgid "Adjust gamma ramps with the X VidMode extension.\n"
msgstr "X VidMode 拡張を用いてガンマ ランプを調整します。\n"
-#. TRANSLATORS: VidMode help output
-#. left column must not be translated
-#: ../src/gamma-vidmode.c:145
-msgid " screen=N\t\tX screen to apply adjustments to\n"
-msgstr " screen=N\t\t調整を適用する X のスクリーン\n"
-
#: ../src/gamma-quartz.c:140 ../src/gamma-w32gdi.c:91
msgid "Unable to save current gamma ramp."
msgstr "現在のガンマ ランプを保存できません。"
diff --git a/po/lt.po b/po/lt.po
index 1ee97a7..fb8605d 100644
--- a/po/lt.po
+++ b/po/lt.po
@@ -567,12 +567,13 @@ msgstr "Nepavyko atkurti CRTC %i."
msgid "Adjust gamma ramps with the X RANDR extension.\n"
msgstr "Gamos lentelių sureguliavimas naudojant X RANDR plėtinį.\n"
-#. TRANSLATORS: RANDR help output
-#. left column must not be translated
+#. TRANSLATORS: RANDR help output left column must not be translated
#: ../src/gamma-randr.c:306
-msgid ""
-" screen=N\t\tX screen to apply adjustments to\n"
-" crtc=N\tList of comma separated CRTCs to apply adjustments to\n"
+msgid " screen=N X screen to apply adjustments to\n"
+msgstr ""
+
+#: ../src/gamma-randr.c:306
+msgid " crtc=N List of comma-separated CRTCs to apply adjustments to\n"
msgstr ""
#: ../src/gamma-randr.c:328
@@ -597,12 +598,6 @@ msgstr "X užklausa nepavyko: %s"
msgid "Adjust gamma ramps with the X VidMode extension.\n"
msgstr "Gamos lentelių sureguliavimas naudojant X VidMode plėtinį.\n"
-#. TRANSLATORS: VidMode help output
-#. left column must not be translated
-#: ../src/gamma-vidmode.c:145
-msgid " screen=N\t\tX screen to apply adjustments to\n"
-msgstr ""
-
#: ../src/gamma-quartz.c:140 ../src/gamma-w32gdi.c:91
msgid "Unable to save current gamma ramp."
msgstr "Nepavyko išsaugoti dabartinės gamos lentelės."
diff --git a/po/nb.po b/po/nb.po
index b98d9a9..cae30c7 100644
--- a/po/nb.po
+++ b/po/nb.po
@@ -566,12 +566,13 @@ msgstr "Klarte ikke å gjenopprette CRTC %i."
msgid "Adjust gamma ramps with the X RANDR extension.\n"
msgstr "Still inn gammarampen med X RANDR-utvidelsen.\n"
-#. TRANSLATORS: RANDR help output
-#. left column must not be translated
+#. TRANSLATORS: RANDR help output left column must not be translated
#: ../src/gamma-randr.c:306
-msgid ""
-" screen=N\t\tX screen to apply adjustments to\n"
-" crtc=N\tList of comma separated CRTCs to apply adjustments to\n"
+msgid " screen=N X screen to apply adjustments to\n"
+msgstr ""
+
+#: ../src/gamma-randr.c:306
+msgid " crtc=N List of comma-separated CRTCs to apply adjustments to\n"
msgstr ""
#: ../src/gamma-randr.c:328
@@ -596,12 +597,6 @@ msgstr "X-forespørsel mislyktes. %s"
msgid "Adjust gamma ramps with the X VidMode extension.\n"
msgstr "Angi gammaramper med X VidMode-utvidelsen.\n"
-#. TRANSLATORS: VidMode help output
-#. left column must not be translated
-#: ../src/gamma-vidmode.c:145
-msgid " screen=N\t\tX screen to apply adjustments to\n"
-msgstr ""
-
#: ../src/gamma-quartz.c:140 ../src/gamma-w32gdi.c:91
msgid "Unable to save current gamma ramp."
msgstr "Klarte ikke å lagre gjeldende gammarampe."
diff --git a/po/nl.po b/po/nl.po
index 43a5212..db52a0f 100644
--- a/po/nl.po
+++ b/po/nl.po
@@ -581,15 +581,14 @@ msgstr "Kan CRTC %i niet herstellen."
msgid "Adjust gamma ramps with the X RANDR extension.\n"
msgstr "Pas gamma ramps aan met de X RANDR extensie.\n"
-#. TRANSLATORS: RANDR help output
-#. left column must not be translated
+#. TRANSLATORS: RANDR help output left column must not be translated
#: ../src/gamma-randr.c:306
-msgid ""
-" screen=N\t\tX screen to apply adjustments to\n"
-" crtc=N\tList of comma separated CRTCs to apply adjustments to\n"
-msgstr ""
-" screen=N\t\tX-scherm om bijstellingen op toe te passen\n"
-" crtc=N\tLijst of kommagescheiden CRTC's om bijstellingen op toe te passen\n"
+msgid " screen=N X screen to apply adjustments to\n"
+msgstr " screen=N X-scherm om bijstellingen op toe te passen\n"
+
+#: ../src/gamma-randr.c:306
+msgid " crtc=N List of comma-separated CRTCs to apply adjustments to\n"
+msgstr " crtc=N Lijst of kommagescheiden CRTC's om bijstellingen op toe te passen\n"
#: ../src/gamma-randr.c:328
#, c-format
@@ -616,12 +615,6 @@ msgstr "X-verzoek is mislukt: %s"
msgid "Adjust gamma ramps with the X VidMode extension.\n"
msgstr "Pas gamma ramps aan met de X VidMode extensie.\n"
-#. TRANSLATORS: VidMode help output
-#. left column must not be translated
-#: ../src/gamma-vidmode.c:145
-msgid " screen=N\t\tX screen to apply adjustments to\n"
-msgstr " screen=N\t\tX-scherm om bijstellingen op toe te passen\n"
-
#: ../src/gamma-quartz.c:140 ../src/gamma-w32gdi.c:91
msgid "Unable to save current gamma ramp."
msgstr "Kan de huidige gamma ramps niet opslaan."
diff --git a/po/oc.po b/po/oc.po
index d1b4dd0..a307d07 100644
--- a/po/oc.po
+++ b/po/oc.po
@@ -550,12 +550,13 @@ msgstr ""
msgid "Adjust gamma ramps with the X RANDR extension.\n"
msgstr ""
-#. TRANSLATORS: RANDR help output
-#. left column must not be translated
+#. TRANSLATORS: RANDR help output left column must not be translated
#: ../src/gamma-randr.c:306
-msgid ""
-" screen=N\t\tX screen to apply adjustments to\n"
-" crtc=N\tList of comma separated CRTCs to apply adjustments to\n"
+msgid " screen=N X screen to apply adjustments to\n"
+msgstr ""
+
+#: ../src/gamma-randr.c:306
+msgid " crtc=N List of comma-separated CRTCs to apply adjustments to\n"
msgstr ""
#: ../src/gamma-randr.c:328
@@ -581,12 +582,6 @@ msgstr ""
msgid "Adjust gamma ramps with the X VidMode extension.\n"
msgstr ""
-#. TRANSLATORS: VidMode help output
-#. left column must not be translated
-#: ../src/gamma-vidmode.c:145
-msgid " screen=N\t\tX screen to apply adjustments to\n"
-msgstr ""
-
#: ../src/gamma-quartz.c:140 ../src/gamma-w32gdi.c:91
msgid "Unable to save current gamma ramp."
msgstr ""
diff --git a/po/pl.po b/po/pl.po
index f09e8fa..e3d7895 100644
--- a/po/pl.po
+++ b/po/pl.po
@@ -569,12 +569,13 @@ msgstr "Nie udało się przywrócić CRTC %i."
msgid "Adjust gamma ramps with the X RANDR extension.\n"
msgstr "Dopasuj gamma ramp przy pomocy rozszerzenia X RANDR\n"
-#. TRANSLATORS: RANDR help output
-#. left column must not be translated
+#. TRANSLATORS: RANDR help output left column must not be translated
#: ../src/gamma-randr.c:306
-msgid ""
-" screen=N\t\tX screen to apply adjustments to\n"
-" crtc=N\tList of comma separated CRTCs to apply adjustments to\n"
+msgid " screen=N X screen to apply adjustments to\n"
+msgstr ""
+
+#: ../src/gamma-randr.c:306
+msgid " crtc=N List of comma-separated CRTCs to apply adjustments to\n"
msgstr ""
#: ../src/gamma-randr.c:328
@@ -599,12 +600,6 @@ msgstr "Żądanie X-ów zawiodło: %s"
msgid "Adjust gamma ramps with the X VidMode extension.\n"
msgstr "Dopasuj gamma ramp przy pomocy rozszerzenia X VidMode\n"
-#. TRANSLATORS: VidMode help output
-#. left column must not be translated
-#: ../src/gamma-vidmode.c:145
-msgid " screen=N\t\tX screen to apply adjustments to\n"
-msgstr ""
-
#: ../src/gamma-quartz.c:140 ../src/gamma-w32gdi.c:91
msgid "Unable to save current gamma ramp."
msgstr "Nie udało się zapisać aktualnego gamma ramp."
diff --git a/po/pt.po b/po/pt.po
index 990c803..bc23ce6 100644
--- a/po/pt.po
+++ b/po/pt.po
@@ -562,12 +562,13 @@ msgstr "Incapaz de restaurar CRTC %i."
msgid "Adjust gamma ramps with the X RANDR extension.\n"
msgstr "Ajustar o declive gama com a extensão X RANDR.\n"
-#. TRANSLATORS: RANDR help output
-#. left column must not be translated
+#. TRANSLATORS: RANDR help output left column must not be translated
#: ../src/gamma-randr.c:306
-msgid ""
-" screen=N\t\tX screen to apply adjustments to\n"
-" crtc=N\tList of comma separated CRTCs to apply adjustments to\n"
+msgid " screen=N X screen to apply adjustments to\n"
+msgstr ""
+
+#: ../src/gamma-randr.c:306
+msgid " crtc=N List of comma-separated CRTCs to apply adjustments to\n"
msgstr ""
#: ../src/gamma-randr.c:328
@@ -592,12 +593,6 @@ msgstr "Pedido do X falhou: %s"
msgid "Adjust gamma ramps with the X VidMode extension.\n"
msgstr "Ajustar o declive gama com a extensão X VidMode.\n"
-#. TRANSLATORS: VidMode help output
-#. left column must not be translated
-#: ../src/gamma-vidmode.c:145
-msgid " screen=N\t\tX screen to apply adjustments to\n"
-msgstr ""
-
#: ../src/gamma-quartz.c:140 ../src/gamma-w32gdi.c:91
msgid "Unable to save current gamma ramp."
msgstr "Incapaz de guardar o declive gama atual."
diff --git a/po/pt_BR.po b/po/pt_BR.po
index c8bd90e..104271f 100644
--- a/po/pt_BR.po
+++ b/po/pt_BR.po
@@ -574,12 +574,13 @@ msgstr "Não foi possível restaurar o CRTC %i."
msgid "Adjust gamma ramps with the X RANDR extension.\n"
msgstr "Ajuste as escalas gamma com a extensão X RANDR.\n"
-#. TRANSLATORS: RANDR help output
-#. left column must not be translated
+#. TRANSLATORS: RANDR help output left column must not be translated
#: ../src/gamma-randr.c:306
-msgid ""
-" screen=N\t\tX screen to apply adjustments to\n"
-" crtc=N\tList of comma separated CRTCs to apply adjustments to\n"
+msgid " screen=N X screen to apply adjustments to\n"
+msgstr ""
+
+#: ../src/gamma-randr.c:306
+msgid " crtc=N List of comma-separated CRTCs to apply adjustments to\n"
msgstr ""
#: ../src/gamma-randr.c:328
@@ -604,12 +605,6 @@ msgstr "Requisição X falhou: %s"
msgid "Adjust gamma ramps with the X VidMode extension.\n"
msgstr "Ajuste as escalas gamma com a extensão X VidMode.\n"
-#. TRANSLATORS: VidMode help output
-#. left column must not be translated
-#: ../src/gamma-vidmode.c:145
-msgid " screen=N\t\tX screen to apply adjustments to\n"
-msgstr ""
-
#: ../src/gamma-quartz.c:140 ../src/gamma-w32gdi.c:91
msgid "Unable to save current gamma ramp."
msgstr "Não foi possível salvar a escala gamma atual."
diff --git a/po/redshift.pot b/po/redshift.pot
index a630904..2b00cca 100644
--- a/po/redshift.pot
+++ b/po/redshift.pot
@@ -544,12 +544,13 @@ msgstr ""
msgid "Adjust gamma ramps with the X RANDR extension.\n"
msgstr ""
-#. TRANSLATORS: RANDR help output
-#. left column must not be translated
+#. TRANSLATORS: RANDR help output left column must not be translated
#: ../src/gamma-randr.c:306
-msgid ""
-" screen=N\t\tX screen to apply adjustments to\n"
-" crtc=N\tList of comma separated CRTCs to apply adjustments to\n"
+msgid " screen=N X screen to apply adjustments to\n"
+msgstr ""
+
+#: ../src/gamma-randr.c:306
+msgid " crtc=N List of comma-separated CRTCs to apply adjustments to\n"
msgstr ""
#: ../src/gamma-randr.c:328
@@ -574,12 +575,6 @@ msgstr ""
msgid "Adjust gamma ramps with the X VidMode extension.\n"
msgstr ""
-#. TRANSLATORS: VidMode help output
-#. left column must not be translated
-#: ../src/gamma-vidmode.c:145
-msgid " screen=N\t\tX screen to apply adjustments to\n"
-msgstr ""
-
#: ../src/gamma-quartz.c:140 ../src/gamma-w32gdi.c:91
msgid "Unable to save current gamma ramp."
msgstr ""
diff --git a/po/ro.po b/po/ro.po
index 142b6b3..dcaf068 100644
--- a/po/ro.po
+++ b/po/ro.po
@@ -548,12 +548,13 @@ msgstr ""
msgid "Adjust gamma ramps with the X RANDR extension.\n"
msgstr ""
-#. TRANSLATORS: RANDR help output
-#. left column must not be translated
+#. TRANSLATORS: RANDR help output left column must not be translated
#: ../src/gamma-randr.c:306
-msgid ""
-" screen=N\t\tX screen to apply adjustments to\n"
-" crtc=N\tList of comma separated CRTCs to apply adjustments to\n"
+msgid " screen=N X screen to apply adjustments to\n"
+msgstr ""
+
+#: ../src/gamma-randr.c:306
+msgid " crtc=N List of comma-separated CRTCs to apply adjustments to\n"
msgstr ""
#: ../src/gamma-randr.c:328
@@ -578,12 +579,6 @@ msgstr ""
msgid "Adjust gamma ramps with the X VidMode extension.\n"
msgstr ""
-#. TRANSLATORS: VidMode help output
-#. left column must not be translated
-#: ../src/gamma-vidmode.c:145
-msgid " screen=N\t\tX screen to apply adjustments to\n"
-msgstr ""
-
#: ../src/gamma-quartz.c:140 ../src/gamma-w32gdi.c:91
msgid "Unable to save current gamma ramp."
msgstr ""
diff --git a/po/ru.po b/po/ru.po
index 53001fb..2079ef7 100644
--- a/po/ru.po
+++ b/po/ru.po
@@ -564,12 +564,13 @@ msgstr "Не удается восстановить параметры CRT ко
msgid "Adjust gamma ramps with the X RANDR extension.\n"
msgstr "Корректирование цвета с помощью расширения X RANDR.\n"
-#. TRANSLATORS: RANDR help output
-#. left column must not be translated
+#. TRANSLATORS: RANDR help output left column must not be translated
#: ../src/gamma-randr.c:306
-msgid ""
-" screen=N\t\tX screen to apply adjustments to\n"
-" crtc=N\tList of comma separated CRTCs to apply adjustments to\n"
+msgid " screen=N X screen to apply adjustments to\n"
+msgstr ""
+
+#: ../src/gamma-randr.c:306
+msgid " crtc=N List of comma-separated CRTCs to apply adjustments to\n"
msgstr ""
#: ../src/gamma-randr.c:328
@@ -594,12 +595,6 @@ msgstr "Ошибка X запроса: %s"
msgid "Adjust gamma ramps with the X VidMode extension.\n"
msgstr "Корректирование цвета с помощью расширения X VidMode.\n"
-#. TRANSLATORS: VidMode help output
-#. left column must not be translated
-#: ../src/gamma-vidmode.c:145
-msgid " screen=N\t\tX screen to apply adjustments to\n"
-msgstr ""
-
#: ../src/gamma-quartz.c:140 ../src/gamma-w32gdi.c:91
msgid "Unable to save current gamma ramp."
msgstr "Не удается сохранить текущие значения корректировки цвета."
diff --git a/po/sr.po b/po/sr.po
index fedc4c6..de00da0 100644
--- a/po/sr.po
+++ b/po/sr.po
@@ -565,12 +565,13 @@ msgstr ""
msgid "Adjust gamma ramps with the X RANDR extension.\n"
msgstr ""
-#. TRANSLATORS: RANDR help output
-#. left column must not be translated
+#. TRANSLATORS: RANDR help output left column must not be translated
#: ../src/gamma-randr.c:306
-msgid ""
-" screen=N\t\tX screen to apply adjustments to\n"
-" crtc=N\tList of comma separated CRTCs to apply adjustments to\n"
+msgid " screen=N X screen to apply adjustments to\n"
+msgstr ""
+
+#: ../src/gamma-randr.c:306
+msgid " crtc=N List of comma-separated CRTCs to apply adjustments to\n"
msgstr ""
#: ../src/gamma-randr.c:328
@@ -595,12 +596,6 @@ msgstr ""
msgid "Adjust gamma ramps with the X VidMode extension.\n"
msgstr ""
-#. TRANSLATORS: VidMode help output
-#. left column must not be translated
-#: ../src/gamma-vidmode.c:145
-msgid " screen=N\t\tX screen to apply adjustments to\n"
-msgstr ""
-
#: ../src/gamma-quartz.c:140 ../src/gamma-w32gdi.c:91
msgid "Unable to save current gamma ramp."
msgstr ""
diff --git a/po/sv.po b/po/sv.po
index e2e1772..66bc5bc 100644
--- a/po/sv.po
+++ b/po/sv.po
@@ -571,12 +571,13 @@ msgstr "Det går inte att återställa CRTC %i."
msgid "Adjust gamma ramps with the X RANDR extension.\n"
msgstr "Justera gammaförfiningar med X RANDR utökningen.\n"
-#. TRANSLATORS: RANDR help output
-#. left column must not be translated
+#. TRANSLATORS: RANDR help output left column must not be translated
#: ../src/gamma-randr.c:306
-msgid ""
-" screen=N\t\tX screen to apply adjustments to\n"
-" crtc=N\tList of comma separated CRTCs to apply adjustments to\n"
+msgid " screen=N X screen to apply adjustments to\n"
+msgstr ""
+
+#: ../src/gamma-randr.c:306
+msgid " crtc=N List of comma-separated CRTCs to apply adjustments to\n"
msgstr ""
#: ../src/gamma-randr.c:328
@@ -602,12 +603,6 @@ msgstr "X-anrop misslyckades: %s"
msgid "Adjust gamma ramps with the X VidMode extension.\n"
msgstr "Justera gammaförfiningar med X VidMode utökning.\n"
-#. TRANSLATORS: VidMode help output
-#. left column must not be translated
-#: ../src/gamma-vidmode.c:145
-msgid " screen=N\t\tX screen to apply adjustments to\n"
-msgstr ""
-
#: ../src/gamma-quartz.c:140 ../src/gamma-w32gdi.c:91
msgid "Unable to save current gamma ramp."
msgstr "Det går inte att spara nuvarande gammaförfining."
diff --git a/po/tr.po b/po/tr.po
index 57a8726..43979ca 100644
--- a/po/tr.po
+++ b/po/tr.po
@@ -549,12 +549,13 @@ msgstr ""
msgid "Adjust gamma ramps with the X RANDR extension.\n"
msgstr ""
-#. TRANSLATORS: RANDR help output
-#. left column must not be translated
+#. TRANSLATORS: RANDR help output left column must not be translated
#: ../src/gamma-randr.c:306
-msgid ""
-" screen=N\t\tX screen to apply adjustments to\n"
-" crtc=N\tList of comma separated CRTCs to apply adjustments to\n"
+msgid " screen=N X screen to apply adjustments to\n"
+msgstr ""
+
+#: ../src/gamma-randr.c:306
+msgid " crtc=N List of comma-separated CRTCs to apply adjustments to\n"
msgstr ""
#: ../src/gamma-randr.c:328
@@ -579,12 +580,6 @@ msgstr ""
msgid "Adjust gamma ramps with the X VidMode extension.\n"
msgstr ""
-#. TRANSLATORS: VidMode help output
-#. left column must not be translated
-#: ../src/gamma-vidmode.c:145
-msgid " screen=N\t\tX screen to apply adjustments to\n"
-msgstr ""
-
#: ../src/gamma-quartz.c:140 ../src/gamma-w32gdi.c:91
msgid "Unable to save current gamma ramp."
msgstr ""
diff --git a/po/uk.po b/po/uk.po
index 73a59bd..4da122b 100644
--- a/po/uk.po
+++ b/po/uk.po
@@ -595,15 +595,14 @@ msgstr "Неможливо відновити CRTC %i."
msgid "Adjust gamma ramps with the X RANDR extension.\n"
msgstr "Налаштувати гамма-рампу за допомогою додатку X RANDR.\n"
-#. TRANSLATORS: RANDR help output
-#. left column must not be translated
+#. TRANSLATORS: RANDR help output left column must not be translated
#: ../src/gamma-randr.c:306
-msgid ""
-" screen=N\t\tX screen to apply adjustments to\n"
-" crtc=N\tList of comma separated CRTCs to apply adjustments to\n"
-msgstr ""
-" screen=N\t\tЩоб застосувати коригування до X монітору\n"
-" crtc=N\tЩоб застосувати налаштування до списку CRTCs, розділеного комою\n"
+msgid " screen=N X screen to apply adjustments to\n"
+msgstr " screen=N Щоб застосувати коригування до X монітору\n"
+
+#: ../src/gamma-randr.c:306
+msgid " crtc=N List of comma-separated CRTCs to apply adjustments to\n"
+msgstr " crtc=N Щоб застосувати налаштування до списку CRTCs, розділеного комою\n"
#: ../src/gamma-randr.c:328
#, c-format
@@ -627,12 +626,6 @@ msgstr "X запит не виконаний: %s"
msgid "Adjust gamma ramps with the X VidMode extension.\n"
msgstr "Налаштування гамма-рампи за допомогою додатку X VidMode.\n"
-#. TRANSLATORS: VidMode help output
-#. left column must not be translated
-#: ../src/gamma-vidmode.c:145
-msgid " screen=N\t\tX screen to apply adjustments to\n"
-msgstr " screen=N\t\tX екран для застосування налаштувань\n"
-
#: ../src/gamma-quartz.c:140 ../src/gamma-w32gdi.c:91
msgid "Unable to save current gamma ramp."
msgstr "Неможливо зберегти дану гамма-рампу."
diff --git a/po/zh_CN.po b/po/zh_CN.po
index e308f35..31fb089 100644
--- a/po/zh_CN.po
+++ b/po/zh_CN.po
@@ -578,15 +578,15 @@ msgstr "无法保存 CRTC %i."
msgid "Adjust gamma ramps with the X RANDR extension.\n"
msgstr "使用 X RANDR 扩展调整伽马斜面。\n"
-#. TRANSLATORS: RANDR help output
-#. left column must not be translated
+#. TRANSLATORS: RANDR help output left column must not be translated
#: ../src/gamma-randr.c:306
-msgid ""
-" screen=N\t\tX screen to apply adjustments to\n"
-" crtc=N\tList of comma separated CRTCs to apply adjustments to\n"
-msgstr ""
-" screen=N\t\tX 应用设置屏幕\n"
-" crtc=N\t将调整应用于的逗号分隔 CRTC 列表\n"
+msgid " screen=N X screen to apply adjustments to\n"
+msgstr " screen=N X 应用设置屏幕\n"
+
+#: ../src/gamma-randr.c:306
+msgid " crtc=N List of comma-separated CRTCs to apply adjustments to\n"
+msgstr " crtc=N 将调整应用于的逗号分隔 CRTC 列表\n"
+
#: ../src/gamma-randr.c:328
#, c-format
msgid "Unable to read screen number: `%s'."
@@ -610,12 +610,6 @@ msgstr "X 请求失败:%s"
msgid "Adjust gamma ramps with the X VidMode extension.\n"
msgstr "使用 X VidMode 扩展调整伽马斜面。\n"
-#. TRANSLATORS: VidMode help output
-#. left column must not be translated
-#: ../src/gamma-vidmode.c:145
-msgid " screen=N\t\tX screen to apply adjustments to\n"
-msgstr " screen=N\t\tX 应用调整的屏幕\n"
-
#: ../src/gamma-quartz.c:140 ../src/gamma-w32gdi.c:91
msgid "Unable to save current gamma ramp."
msgstr "无法保存当前的伽马斜面。"
diff --git a/po/zh_TW.po b/po/zh_TW.po
index 3e29313..2685923 100644
--- a/po/zh_TW.po
+++ b/po/zh_TW.po
@@ -583,15 +583,14 @@ msgstr "無法存入 CRTC %i."
msgid "Adjust gamma ramps with the X RANDR extension.\n"
msgstr "使用 X RANDR 擴充來調整咖瑪斜面。\n"
-#. TRANSLATORS: RANDR help output
-#. left column must not be translated
+#. TRANSLATORS: RANDR help output left column must not be translated
#: ../src/gamma-randr.c:306
-msgid ""
-" screen=N\t\tX screen to apply adjustments to\n"
-" crtc=N\tList of comma separated CRTCs to apply adjustments to\n"
-msgstr ""
-" 螢幕=N\t\tX 螢幕去套用調整至\n"
-" crtc=N\t串串逗號幅來各別 CRTCs 去套用調整至\n"
+msgid " screen=N X screen to apply adjustments to\n"
+msgstr " screen=N X 螢幕去套用調整至\n"
+
+#: ../src/gamma-randr.c:306
+msgid " crtc=N List of comma-separated CRTCs to apply adjustments to\n"
+msgstr " crtc=N 串串逗號幅來各別 CRTCs 去套用調整至\n"
# TODO English pluralization of "CRTC" retained
#: ../src/gamma-randr.c:328
@@ -617,12 +616,6 @@ msgstr "X 請求失敗: %s"
msgid "Adjust gamma ramps with the X VidMode extension.\n"
msgstr "使用 X VidMode extension 去調整咖瑪斜面。\n"
-#. TRANSLATORS: VidMode help output
-#. left column must not be translated
-#: ../src/gamma-vidmode.c:145
-msgid " screen=N\t\tX screen to apply adjustments to\n"
-msgstr " 螢幕=N\t\tX 螢幕去套用調整至\n"
-
#: ../src/gamma-quartz.c:140 ../src/gamma-w32gdi.c:91
msgid "Unable to save current gamma ramp."
msgstr "無法儲存目前的咖瑪斜面。"
diff --git a/src/Makefile b/src/Makefile
index fabc63e..a674b2e 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -8,6 +8,7 @@ VERSION_STRING = redshift-ng 1.13
OBJ =\
+ backend-direct.o\
colour.o\
config.o\
config-ini.o\
diff --git a/src/backend-direct.c b/src/backend-direct.c
new file mode 100644
index 0000000..d0a53eb
--- /dev/null
+++ b/src/backend-direct.c
@@ -0,0 +1,608 @@
+/*-
+ * redshift-ng - Automatically adjust display colour temperature according the Sun
+ *
+ * Copyright (c) 2009-2018 Jon Lund Steffensen <jonlst@gmail.com>
+ * Copyright (c) 2014-2016, 2025 Mattias Andrée <m@maandree.se>
+ *
+ * redshift-ng is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * redshift-ng is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with redshift-ng. If not, see <http://www.gnu.org/licenses/>.
+ */
+#include "common.h"
+
+
+/**
+ * Union of libgamma gamma ramp structures
+ */
+union gamma_ramps {
+ /**
+ * Gamma ramp sizes
+ */
+ struct {
+ size_t red; /**< Size of the gamma ramp for the red channel */
+ size_t green; /**< Size of the gamma ramp for the green channel */
+ size_t blue; /**< Size of the gamma ramp for the blue channel */
+ } size;
+
+ /* Ramp structures */
+#define X(SUFFIX, RAMPS, TYPE, MAX, DEPTH)\
+ struct libgamma_gamma_##RAMPS RAMPS
+ LIST_RAMPS_STOP_VALUE_TYPES(X, ;);
+#undef X
+};
+
+
+/**
+ * State for partition (e.g. X screen or graphics card)
+ */
+struct partition_state {
+ /**
+ * libgamma state
+ */
+ struct libgamma_partition_state state;
+
+ /**
+ * Index of CRTC when indexing spans multiple X screens
+ */
+ size_t crtc_num_offset;
+};
+
+
+/**
+ * CRTC state
+ */
+struct crtc_state {
+ /**
+ * libgamma state
+ */
+ struct libgamma_crtc_state state;
+
+ /**
+ * Gamma ramp depth, 0 if uninitialised,
+ * -1 if single-precision float,
+ * -2 if double-precision float,
+ * otherwise the number of bits (of unsigned integer)
+ */
+ signed gamma_depth;
+
+ /**
+ * Gamma ramps used by the gamma adjustment function
+ */
+ union gamma_ramps gamma_ramps;
+
+ /**
+ * Original state of gamma ramps
+ */
+ union gamma_ramps saved_gamma_ramps;
+};
+
+
+struct gamma_state {
+ /**
+ * libgamma state for the site (e.g. X display)
+ */
+ struct libgamma_site_state site;
+
+ /**
+ * Whether the adjustment method supports multiple
+ * sites rather than just the default site
+ */
+ unsigned multiple_sites : 1;
+
+ /**
+ * Whether the adjustment method supports multiple partitions
+ * per site
+ */
+ unsigned multiple_partitions : 1;
+
+ /**
+ * Whether the adjustment method supports multiple CRTC:s
+ * per partition per site
+ */
+ unsigned multiple_crtcs : 1;
+
+ /**
+ * Whether partitions are graphics cards
+ */
+ unsigned partitions_are_graphics_cards : 1;
+
+ /**
+ * Whether a parition has been selected
+ */
+ unsigned partition_selected : 1;
+
+ /**
+ * Whether CRTCs have been selected
+ */
+ unsigned crtcs_selected : 1;
+
+ /**
+ * Selected parition (if `partition_selected`)
+ */
+ size_t selected_partition;
+
+ /**
+ * Number of selected CRTCs
+ */
+ size_t ncrtcs;
+
+ /**
+ * Number of selected parition
+ */
+ size_t npartitions;
+
+ /**
+ * Indices of selected CRTCs
+ */
+ size_t *selected_crtcs;
+
+ /**
+ * State for selected paritions
+ */
+ struct partition_state *partitions;
+
+ /**
+ * State for selected CRTCs
+ */
+ struct crtc_state *crtcs;
+};
+
+
+int
+direct_create(struct gamma_state **state_out, int method, const char *method_name)
+{
+ struct libgamma_method_capabilities caps;
+ struct gamma_state *state;
+ int err;
+
+ *state_out = NULL;
+
+ if (!libgamma_is_method_available(method)) {
+ weprintf(_("Adjustment method `%s' is not available"), method_name);
+ return -1;
+ }
+
+ err = libgamma_method_capabilities(&caps, sizeof(caps), method);
+ if (err) {
+ weprintf("libgamma_method_capabilities %s: %s", libgamma_const_of_method(method), libgamma_strerror(err));
+ return -1;
+ }
+
+ state = *state_out = ecalloc(1, sizeof(**state_out));
+ state->selected_crtcs = NULL;
+ state->partitions = NULL;
+ state->multiple_sites = caps.multiple_sites;
+ state->multiple_partitions = caps.multiple_partitions;
+ state->multiple_crtcs = caps.multiple_crtcs;
+ state->partitions_are_graphics_cards = caps.partitions_are_graphics_cards;
+
+ err = libgamma_site_initialise(&state->site, method, NULL);
+ if (err) {
+ weprintf("libgamma_site_initialise %s NULL: %s", libgamma_const_of_method(method), libgamma_strerror(err));
+ free(state);
+ *state_out = NULL;
+ return -1;
+ }
+
+ return 0;
+}
+
+
+int
+direct_set_partitions(struct gamma_state *state, const char *key, const char *value)
+{
+ const char *end;
+ uintmax_t num;
+
+ /* Check previously unspecified */
+ if (state->partition_selected)
+ weprintf(_("`%s' option specified multiple times, using last selection."), key);
+ state->partition_selected = 1;
+
+ /* Parse number */
+ errno = 0;
+ num = strtoumax(value, (void *)&end, 10);
+ state->selected_partition = (size_t)num;
+ if (num > (uintmax_t)SIZE_MAX || *end || !isdigit(*value) || errno)
+ eprintf(_("Invalid value of `%s' option: `%s'."), key, value);
+
+ return 0;
+}
+
+
+int
+direct_set_crtcs(struct gamma_state *state, const char *key, const char *value)
+{
+ const char *end, *p;
+ uintmax_t num;
+ size_t count;
+
+ /* Check previously unspecified */
+ if (state->crtcs_selected)
+ weprintf(_("`%s' option specified multiple times, using last selection."), key);
+ state->crtcs_selected = 1;
+
+ /* Check if all are selected */
+ state->ncrtcs = 0;
+ free(state->selected_crtcs);
+ state->selected_crtcs = NULL;
+ if (!*value || !strcasecmp(value, "all"))
+ return 0;
+
+ /* Get number count */
+ for (p = value, count = 1; *p; p++)
+ if (*p == ',')
+ count++;
+ state->selected_crtcs = ecalloc(count, sizeof(*state->selected_crtcs));
+
+ /* Parse numbers */
+ errno = 0;
+ for (p = value; *p; p = end) {
+ num = strtoumax(p, (void *)&end, 10);
+ state->selected_crtcs[state->ncrtcs++] = (size_t)num;
+ if (num > (uintmax_t)SIZE_MAX || (*end && *end != ',') || !isdigit(*p) || errno)
+ eprintf(_("Invalid value of `%s' option: `%s'."), key, value);
+ end = &end[*end == ','];
+ }
+
+ return 0;
+}
+
+
+int
+direct_start(struct gamma_state *state)
+{
+
+ struct libgamma_crtc_information crtc_info;
+ size_t crtc_num_offset = 0;
+ size_t crtcs_removed = 0;
+ size_t i, j, k, num, part;
+ int err;
+
+ /* Allocate partition states */
+ if (state->partition_selected) {
+ state->partitions = ecalloc(1, sizeof(*state->partitions));
+ state->partitions[0].state.partition = state->selected_partition;
+ state->partitions[0].state.data = NULL;
+ state->npartitions = 1;
+ } else if (!state->site.partitions_available) {
+ if (state->partitions_are_graphics_cards)
+ weprintf(_("No graphics card found."));
+ else
+ weprintf(_("No X screen found."));
+ return -1;
+ } else {
+ state->npartitions = state->site.partitions_available;
+ state->partitions = ecalloc(state->npartitions, sizeof(*state->partitions));
+ for (i = 0; i < state->npartitions; i++) {
+ state->partitions[i].state.partition = i;
+ state->partitions[i].state.data = NULL;
+ }
+ }
+
+ /* Initialise partitions */
+ for (i = 0; i < state->npartitions; i++) {
+ num = state->partitions[i].state.partition;
+ err = libgamma_partition_initialise(&state->partitions[i].state, &state->site, num);
+ if (err) {
+ weprintf("libgamma_partition_initialise %zu: %s", num, libgamma_strerror(err));
+ return -1;
+ }
+ state->partitions[i].crtc_num_offset = crtc_num_offset;
+ crtc_num_offset += state->partitions[i].state.crtcs_available;
+ }
+
+ /* Allocate CRTCs states and map to partition–CRTC pairs */
+ if (state->ncrtcs) {
+ state->crtcs = ecalloc(state->ncrtcs, sizeof(*state->crtcs));
+ for (i = 0; i < state->ncrtcs; i++) {
+ state->crtcs[i].state.data = NULL;
+ state->crtcs[i].state.crtc = state->selected_crtcs[i];
+ }
+ for (i = 0; i < state->ncrtcs; i++) {
+ for (j = 1; j < state->npartitions; j++)
+ if (state->crtcs[i].state.crtc < state->partitions[j].crtc_num_offset)
+ break;
+ state->crtcs[i].state.partition = &state->partitions[j - 1U].state;
+ }
+ } else if (!crtc_num_offset) {
+ weprintf(_("No CRTCs found."));
+ return -1;
+ } else {
+ state->ncrtcs = crtc_num_offset;
+ state->crtcs = ecalloc(state->ncrtcs, sizeof(*state->crtcs));
+ for (j = 0, i = 0; j < state->npartitions; j++) {
+ for (k = 0; k < state->partitions[j].state.crtcs_available; k++, i++) {
+ state->crtcs[i].state.data = NULL;
+ state->crtcs[i].state.partition = &state->partitions[j].state;
+ state->crtcs[i].state.crtc = k;
+ }
+ }
+ }
+
+ /* Initialise CRTCs and fetch original gamma adjustments */
+ for (i = 0; i < state->ncrtcs; i++) {
+ /* Get CRTC */
+ part = state->crtcs[i].state.partition->partition;
+ num = state->crtcs[i].state.crtc;
+ err = libgamma_crtc_initialise(&state->crtcs[i].state, state->crtcs[i].state.partition, num);
+ if (err) {
+ weprintf("libgamma_crtc_initialise %zu %zu: %s", part, num, libgamma_strerror(err));
+ return -1;
+ }
+
+ /* Get gamma ramp inforamtion for CRTC */
+ libgamma_get_crtc_information(&crtc_info, sizeof(crtc_info), &state->crtcs[i].state,
+ LIBGAMMA_CRTC_INFO_GAMMA_SIZE |
+ LIBGAMMA_CRTC_INFO_GAMMA_DEPTH |
+ LIBGAMMA_CRTC_INFO_GAMMA_SUPPORT);
+ if (crtc_info.gamma_size_error || crtc_info.gamma_depth_error) {
+ libgamma_crtc_destroy(&state->crtcs[i].state);
+ state->crtcs[i].state.data = NULL;
+ crtcs_removed++;
+ goto no_gamma_support;
+ }
+ if (!crtc_info.gamma_support_error && crtc_info.gamma_support == LIBGAMMA_NO) {
+ no_gamma_support:
+ if (state->multiple_crtcs) {
+ if (!state->multiple_partitions)
+ weprintf(_("Adjustments are not supported on CRTC %zu."), num);
+ else if (state->partitions_are_graphics_cards)
+ weprintf(_("Adjustments are not supported on CRTC %zu on graphics card %zu."), num, part);
+ else
+ weprintf(_("Adjustments are not supported on CRTC %zu on X screen %zu."), num, part);
+ } else {
+ if (!state->multiple_partitions)
+ weprintf(_("Adjustments are not supported."));
+ else if (state->partitions_are_graphics_cards)
+ weprintf(_("Adjustments are not supported on graphics card %zu."), part);
+ else
+ weprintf(_("Adjustments are not supported on X screen %zu."), part);
+ }
+ if (!state->crtcs[i].state.data)
+ goto next;
+ }
+
+ /* Initialise and fetch gamma adjustments */
+ state->crtcs[i].gamma_ramps.size.red = crtc_info.red_gamma_size;
+ state->crtcs[i].gamma_ramps.size.green = crtc_info.green_gamma_size;
+ state->crtcs[i].gamma_ramps.size.blue = crtc_info.blue_gamma_size;
+ state->crtcs[i].saved_gamma_ramps.size.red = crtc_info.red_gamma_size;
+ state->crtcs[i].saved_gamma_ramps.size.green = crtc_info.green_gamma_size;
+ state->crtcs[i].saved_gamma_ramps.size.blue = crtc_info.blue_gamma_size;
+ switch (crtc_info.gamma_depth) {
+#define X(SUFFIX, RAMPS, TYPE, MAX, DEPTH)\
+ case DEPTH:\
+ if (libgamma_gamma_##RAMPS##_initialise(&state->crtcs[i].gamma_ramps.RAMPS) ||\
+ libgamma_gamma_##RAMPS##_initialise(&state->crtcs[i].saved_gamma_ramps.RAMPS))\
+ eprintf("libgamma_gamma_"#RAMPS"_initialise:");\
+ j = 0;\
+ do {\
+ err = libgamma_crtc_get_gamma_##RAMPS(&state->crtcs[i].state,\
+ &state->crtcs[i].saved_gamma_ramps.RAMPS);\
+ } while (err && j++ < 10);\
+ if (!err) {\
+ state->crtcs[i].gamma_depth = DEPTH;\
+ break;\
+ }\
+ if (state->multiple_crtcs) {\
+ if (!state->multiple_partitions)\
+ weprintf(_("Could not get current adjustments for CRTC %zu."), num);\
+ else if (state->partitions_are_graphics_cards)\
+ weprintf(_("Could not get current adjustments for CRTC %zu on graphics card %zu."), num, part);\
+ else\
+ weprintf(_("Could not get current adjustments for CRTC %zu on X screen %zu."), num, part);\
+ } else {\
+ if (!state->multiple_partitions)\
+ weprintf(_("Could not get current adjustments."));\
+ else if (state->partitions_are_graphics_cards)\
+ weprintf(_("Could not get current adjustments for graphics card %zu."), part);\
+ else\
+ weprintf(_("Could not get current adjustments for X screen %zu."), part);\
+ }\
+ libgamma_gamma_##RAMPS##_destroy(&state->crtcs[i].gamma_ramps.RAMPS);\
+ libgamma_gamma_##RAMPS##_destroy(&state->crtcs[i].saved_gamma_ramps.RAMPS);\
+ libgamma_crtc_destroy(&state->crtcs[i].state);\
+ state->crtcs[i].state.data = NULL;\
+ crtcs_removed++;\
+ goto next
+
+ LIST_RAMPS_STOP_VALUE_TYPES(X, ;);
+#undef X
+
+ default:
+ if (state->multiple_crtcs) {
+ if (!state->multiple_partitions)
+ weprintf(_("Unsupported gamma ramp type on CRTC %zu."), num);
+ else if (state->partitions_are_graphics_cards)
+ weprintf(_("Unsupported gamma ramp type on CRTC %zu on graphics card %zu."), num, part);
+ else
+ weprintf(_("Unsupported gamma ramp type on CRTC %zu on X screen %zu."), num, part);
+ } else {
+ if (!state->multiple_partitions)
+ weprintf(_("Unsupported gamma ramp type."));
+ else if (state->partitions_are_graphics_cards)
+ weprintf(_("Unsupported gamma ramp type on graphics card %zu."), part);
+ else
+ weprintf(_("Unsupported gamma ramp type on X screen %zu."), part);
+ }
+ return -1;
+ }
+
+ next:
+ libgamma_crtc_information_destroy(&crtc_info);
+ }
+
+ /* Unlist removed CRTCs */
+ if (crtcs_removed) {
+ num = state->ncrtcs - crtcs_removed;
+ for (i = j = 0; crtcs_removed; i++, j++)
+ if (!state->crtcs[i].state.data)
+ break;
+ for (; crtcs_removed; i++) {
+ if (state->crtcs[i].state.data)
+ crtcs_removed--;
+ else
+ memmove(&state->crtcs[j++], &state->crtcs[i], sizeof(*state->crtcs));
+ }
+ memmove(&state->crtcs[j], &state->crtcs[i], (state->ncrtcs - i) * sizeof(*state->crtcs));
+ state->ncrtcs = num;
+ }
+ if (!state->ncrtcs) {
+ weprintf(_("No usable CRTCs available."));
+ return -1;
+ }
+
+ return 0;
+}
+
+
+int
+direct_apply(struct gamma_state *state, const struct colour_setting *setting, int preserve /* TODO */)
+{
+ size_t i, err_count = 0, crtc, part;
+ const char *errstr;
+ int err;
+
+ for (i = 0; i < state->ncrtcs; i++) {
+ switch (state->crtcs[i].gamma_depth) {
+#define X(SUFFIX, RAMPS, TYPE, MAX, DEPTH)\
+ case DEPTH:\
+ fill_ramps_##SUFFIX(state->crtcs[i].gamma_ramps.RAMPS.red,\
+ state->crtcs[i].gamma_ramps.RAMPS.green,\
+ state->crtcs[i].gamma_ramps.RAMPS.blue,\
+ state->crtcs[i].gamma_ramps.size.red,\
+ state->crtcs[i].gamma_ramps.size.green,\
+ state->crtcs[i].gamma_ramps.size.blue,\
+ setting);\
+ err = libgamma_crtc_set_gamma_##RAMPS(&state->crtcs[i].state, &state->crtcs[i].gamma_ramps.RAMPS);\
+ break
+
+ LIST_RAMPS_STOP_VALUE_TYPES(X, ;);
+#undef X
+
+ default:
+ err_count++;
+ err = 0;
+ break;
+ }
+
+ if (err) {
+ err_count++;
+ crtc = state->crtcs[i].state.crtc;
+ part = state->crtcs[i].state.partition->partition;
+ errstr = libgamma_strerror(err);
+ if (state->multiple_crtcs) {
+ if (!state->multiple_partitions)
+ weprintf(_("Unable to set adjustments for CRTC %zu: %s."), crtc, errstr);
+ else if (state->partitions_are_graphics_cards)
+ weprintf(_("Unable to set adjustments for CRTC %zu on graphics card %zu: %s."),
+ crtc, part, errstr);
+ else
+ weprintf(_("Unable to set adjustments for CRTC %zu on X screen %zu: %s."),
+ crtc, part, errstr);
+ } else {
+ if (!state->multiple_partitions)
+ weprintf(_("Unable to set adjustments: %s."), errstr);
+ else if (state->partitions_are_graphics_cards)
+ weprintf(_("Unable to set adjustments for graphics card %zu: %s."), part, errstr);
+ else
+ weprintf(_("Unable to set adjustments for X screen %zu: %s."), part, errstr);
+ }
+ }
+ }
+
+ return err_count == state->ncrtcs ? -1 : 0;
+}
+
+
+void
+direct_restore(struct gamma_state *state)
+{
+ size_t i, crtc, part;
+ const char *errstr;
+ int err;
+
+ for (i = 0; i < state->ncrtcs; i++) {
+ switch (state->crtcs[i].gamma_depth) {
+#define X(SUFFIX, RAMPS, TYPE, MAX, DEPTH)\
+ case DEPTH:\
+ err = libgamma_crtc_set_gamma_##RAMPS(&state->crtcs[i].state, &state->crtcs[i].saved_gamma_ramps.RAMPS);\
+ break
+
+ LIST_RAMPS_STOP_VALUE_TYPES(X, ;);
+#undef X
+
+ default:
+ err = 0;
+ break;
+ }
+
+ if (err) {
+ crtc = state->crtcs[i].state.crtc;
+ part = state->crtcs[i].state.partition->partition;
+ errstr = libgamma_strerror(err);
+ if (state->multiple_crtcs) {
+ if (!state->multiple_partitions)
+ weprintf(_("Unable to restore adjustments for CRTC %zu: %s."), crtc, errstr);
+ else if (state->partitions_are_graphics_cards)
+ weprintf(_("Unable to restore adjustments for CRTC %zu on graphics card %zu: %s."),
+ crtc, part, errstr);
+ else
+ weprintf(_("Unable to restore adjustments for CRTC %zu on X screen %zu: %s."),
+ crtc, part, errstr);
+ } else {
+ if (!state->multiple_partitions)
+ weprintf(_("Unable to restore adjustments: %s."), errstr);
+ else if (state->partitions_are_graphics_cards)
+ weprintf(_("Unable to restore adjustments for graphics card %zu: %s."), part, errstr);
+ else
+ weprintf(_("Unable to restore adjustments for X screen %zu: %s."), part, errstr);
+ }
+ }
+ }
+}
+
+
+void
+direct_free(struct gamma_state *state)
+{
+ size_t i;
+ if (state->crtcs) {
+ for (i = 0; i < state->ncrtcs; i++) {
+ switch (state->crtcs[i].gamma_depth) {
+#define X(SUFFIX, RAMPS, TYPE, MAX, DEPTH)\
+ case DEPTH:\
+ libgamma_gamma_##RAMPS##_destroy(&state->crtcs[i].gamma_ramps.RAMPS);\
+ libgamma_gamma_##RAMPS##_destroy(&state->crtcs[i].saved_gamma_ramps.RAMPS);\
+ break
+ LIST_RAMPS_STOP_VALUE_TYPES(X, ;);
+#undef X
+ default:
+ case 0: /* not initialised */
+ break;
+ }
+ if (state->crtcs[i].state.data)
+ libgamma_crtc_destroy(&state->crtcs[i].state);
+ }
+ free(state->crtcs);
+ }
+ if (state->partitions) {
+ for (i = 0; i < state->npartitions; i++)
+ if (state->partitions[i].state.data)
+ libgamma_partition_destroy(&state->partitions[i].state);
+ free(state->partitions);
+ }
+ free(state->selected_crtcs);
+ libgamma_site_destroy(&state->site);
+ free(state);
+}
diff --git a/src/colour.c b/src/colour.c
index 88acf64..ad65b5f 100644
--- a/src/colour.c
+++ b/src/colour.c
@@ -44,7 +44,7 @@ colour_setting_diff_is_major(const struct colour_setting *a, const struct colour
}
-#define X(SUFFIX, TYPE, MAX, DEPTH)\
+#define X(SUFFIX, RAMPS, TYPE, MAX, DEPTH)\
/**
* Fill a gamma ramp
*
diff --git a/src/common.h b/src/common.h
index b7cf872..e79c6f4 100644
--- a/src/common.h
+++ b/src/common.h
@@ -62,6 +62,7 @@
# include <time.h>
#endif
+#include <libgamma.h>
#include <libred.h>
@@ -1178,6 +1179,77 @@ extern int use_fade;
extern int verbose;
+/* backend-direct.c */
+
+/**
+ * Create an initialised state object for direct gamma adjustments
+ *
+ * @param state_out Output parameter for the state object
+ * @return 0 on success, -1 on failure
+ *
+ * `*state_out` is set (potentially to `NULL`) on failure
+ */
+int direct_create(GAMMA_STATE **state_out, int method, const char *method_name);
+
+/**
+ * Select partitions to apply adjustments to using direct gamma adjustments
+ *
+ * @param state State object for the adjustment method
+ * @param key Option to configure
+ * @param value Option value to set
+ * @return 0 on success, -1 on failure
+ */
+int direct_set_partitions(GAMMA_STATE *state, const char *key, const char *value);
+
+/**
+ * Select CRTCs to apply adjustments to using direct gamma adjustments
+ *
+ * @param state State object for the adjustment method
+ * @param key Option to configure
+ * @param value Option value to set
+ * @return 0 on success, -1 on failure
+ */
+int direct_set_crtcs(GAMMA_STATE *state, const char *key, const char *value);
+
+/**
+ * Finalise option-dependent initialisation and connections
+ * for direct gamma adjustments
+ *
+ * @param state State object for the adjustment method
+ * @return 0 on success, -1 on failure
+ */
+int direct_start(GAMMA_STATE *state);
+
+/**
+ * Apply colour settings using direct gamma adjustments
+ *
+ * @param state State object for the adjustment method
+ * @param settings The colour settings to apply
+ * @param preserve Whether currently applied adjustments (assumed
+ * to be colour calibration) shall remain applied
+ * @return 0 on success, -1 on failure
+ */
+int direct_apply(GAMMA_STATE *state, const struct colour_setting *setting, int preserve);
+
+/**
+ * Restore the adjustments to the `.state` before start was called
+ * using direct gamma adjustments
+ *
+ * @param state State object for the adjustment method
+ */
+void direct_restore(GAMMA_STATE *state);
+
+/**
+ * Close connections and deallocate all state resources
+ * for direct gamma adjustments
+ *
+ * @param state The state to terminate
+ *
+ * The pointer `state` will become invalid
+ */
+void direct_free(GAMMA_STATE *state);
+
+
/* colour.c */
/**
@@ -1203,14 +1275,14 @@ GCC_ONLY(__attribute__((__pure__)))
int colour_setting_diff_is_major(const struct colour_setting *a, const struct colour_setting *b);
#define LIST_RAMPS_STOP_VALUE_TYPES(X, D)\
- X(u8, uint8_t, UINT8_MAX, 8) D\
- X(u16, uint16_t, UINT16_MAX, 16) D\
- X(u32, uint32_t, UINT32_MAX, 32) D\
- X(u64, uint64_t, UINT64_MAX, 64) D\
- X(float, float, 1, -1) D\
- X(double, double, 1, -2)
-
-#define X(SUFFIX, TYPE, MAX, DEPTH)\
+ X(u8, ramps8, uint8_t, UINT8_MAX, 8) D \
+ X(u16, ramps16, uint16_t, UINT16_MAX, 16) D\
+ X(u32, ramps32, uint32_t, UINT32_MAX, 32) D\
+ X(u64, ramps64, uint64_t, UINT64_MAX, 64) D\
+ X(float, rampsf, float, 1, -1) D\
+ X(double, rampsd, double, 1, -2)
+
+#define X(SUFFIX, RAMPS, TYPE, MAX, DEPTH)\
/**
* Fill the gamma ramps
*
diff --git a/src/config.mk b/src/config.mk
index 9c0e131..d0418bb 100644
--- a/src/config.mk
+++ b/src/config.mk
@@ -12,10 +12,8 @@ PKGCONFIG_LDFLAGS = $(PKGCONFIG) --libs
DRM_LIBS = libdrm
GEOCLUE_LIBS = glib-2.0 gio-2.0
-RANDR_LIBS = xcb xcb-randr
-VIDMODE_LIBS = x11 xxf86vm
-LIBS_PKGCONFIG = $(DRM_LIBS) $(GEOCLUE_LIBS) $(RANDR_LIBS) $(VIDMODE_LIBS)
+LIBS_PKGCONFIG = $(DRM_LIBS) $(GEOCLUE_LIBS) libgamma
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -D_GNU_SOURCE\
-DENABLE_DRM -DENABLE_GEOCLUE2 -DENABLE_RANDR -DENABLE_VIDMODE\
diff --git a/src/gamma-coopgamma.c b/src/gamma-coopgamma.c
index 5343e08..7a33746 100644
--- a/src/gamma-coopgamma.c
+++ b/src/gamma-coopgamma.c
@@ -278,7 +278,7 @@ coopgamma_start(struct gamma_state *state)
/* Get total size of the ramps */
switch (info.depth) {
-#define X(SUFFIX, TYPE, MAX, DEPTH)\
+#define X(SUFFIX, RAMPS, TYPE, MAX, DEPTH)\
case DEPTH:\
crtc->rampsize = sizeof(TYPE);\
break
@@ -310,7 +310,7 @@ coopgamma_start(struct gamma_state *state)
#define float f
#define double d
switch (info.depth) {
-#define X(SUFFIX, TYPE, MAX, DEPTH)\
+#define X(SUFFIX, RAMPS, TYPE, MAX, DEPTH)\
case DEPTH:\
r = libcoopgamma_ramps_initialise(&crtc->filter.ramps.SUFFIX);\
if (r < 0) {\
@@ -505,7 +505,7 @@ coopgamma_apply(struct gamma_state *state, const struct colour_setting *setting,
/* Otherwise, create calculate the ramps */
memcpy(filter->ramps.u8.red, state->crtcs[i].plain_ramps.u8.red, state->crtcs[i].rampsize);
switch (filter->depth) {
-#define X(SUFFIX, TYPE, MAX, DEPTH)\
+#define X(SUFFIX, RAMPS, TYPE, MAX, DEPTH)\
case DEPTH:\
fill_ramps_##SUFFIX((void *)(filter->ramps.u8.red),\
(void *)(filter->ramps.u8.green),\
diff --git a/src/gamma-randr.c b/src/gamma-randr.c
index 9438d17..1132960 100644
--- a/src/gamma-randr.c
+++ b/src/gamma-randr.c
@@ -19,244 +19,11 @@
*/
#include "common.h"
-#include <xcb/xcb.h>
-#include <xcb/randr.h>
-#if defined(__GNUC__)
-# pragma GCC diagnostic ignored "-Waggregate-return"
-#endif
-
-
-#define RANDR_VERSION_MAJOR 1
-#define RANDR_VERSION_MINOR 3
-
-
-struct randr_crtc_state {
- xcb_randr_crtc_t crtc;
- unsigned int ramp_size;
- uint16_t *saved_ramps;
-};
-
-
-struct gamma_state {
- xcb_connection_t *conn;
- xcb_screen_t *screen;
- int preferred_screen;
- int screen_num;
- int crtc_num_count;
- int *crtc_num;
- unsigned int crtc_count;
- struct randr_crtc_state *crtcs;
-};
-
static int
randr_create(struct gamma_state **state_out)
{
- xcb_randr_query_version_cookie_t ver_cookie;
- xcb_randr_query_version_reply_t *ver_reply;
- xcb_generic_error_t *error;
- struct gamma_state *state;
- int ec;
-
- /* Initialize state */
- state = *state_out = emalloc(sizeof(**state_out));
- state->screen_num = -1;
- state->crtc_num = NULL;
- state->crtc_num_count = 0;
- state->crtc_count = 0;
- state->crtcs = NULL;
-
- /* Open X server connection */
- state->conn = xcb_connect(NULL, &state->preferred_screen);
-
- /* Query RandR version */
- ver_cookie = xcb_randr_query_version(state->conn, RANDR_VERSION_MAJOR, RANDR_VERSION_MINOR);
- ver_reply = xcb_randr_query_version_reply(state->conn, ver_cookie, &error);
-
- /* TODO What does it mean when both error and ver_reply is NULL?
- Apparently, we have to check both to avoid seg faults. */
- if (error || ver_reply == NULL) {
- ec = (error != 0) ? error->error_code : -1;
- weprintf(_("`%s' returned error %i."), "RANDR Query Version", ec);
- goto fail;
- }
-
- if (ver_reply->major_version != RANDR_VERSION_MAJOR ||
- ver_reply->minor_version < RANDR_VERSION_MINOR) {
- weprintf(_("Unsupported RANDR version (%u.%u)."), ver_reply->major_version, ver_reply->minor_version);
- free(ver_reply);
- goto fail;
- }
-
- free(ver_reply);
-
- return 0;
-
-fail:
- xcb_disconnect(state->conn);
- free(state);
- *state_out = NULL;
- return -1;
-}
-
-
-static int
-randr_start(struct gamma_state *state)
-{
- xcb_generic_error_t *error;
- const xcb_setup_t *setup;
- xcb_screen_iterator_t iter;
- int i, screen_num;
- xcb_randr_get_screen_resources_current_cookie_t res_cookie;
- xcb_randr_get_screen_resources_current_reply_t *res_reply;
- xcb_randr_crtc_t *crtcs;
-
- screen_num = state->screen_num;
- if (screen_num < 0)
- screen_num = state->preferred_screen;
-
- /* Get screen */
- setup = xcb_get_setup(state->conn);
- iter = xcb_setup_roots_iterator(setup);
- state->screen = NULL;
-
- for (i = 0; iter.rem > 0; i++) {
- if (i == screen_num) {
- state->screen = iter.data;
- break;
- }
- xcb_screen_next(&iter);
- }
-
- if (!state->screen) {
- weprintf(_("Screen %i could not be found."), screen_num);
- return -1;
- }
-
- /* Get list of CRTCs for the screen */
- res_cookie = xcb_randr_get_screen_resources_current(state->conn, state->screen->root);
- res_reply = xcb_randr_get_screen_resources_current_reply(state->conn, res_cookie, &error);
-
- if (error) {
- weprintf(_("`%s' returned error %i."), "RANDR Get Screen Resources Current", error->error_code);
- return -1;
- }
-
- state->crtc_count = res_reply->num_crtcs;
- state->crtcs = ecalloc(state->crtc_count, sizeof(struct randr_crtc_state));
-
- crtcs = xcb_randr_get_screen_resources_current_crtcs(res_reply);
-
- /* Save CRTC identifier in state */
- for (i = 0; i < state->crtc_count; i++)
- state->crtcs[i].crtc = crtcs[i];
-
- free(res_reply);
-
- /* Save size and gamma ramps of all CRTCs.
- Current gamma ramps are saved so we can restore them
- at program exit. */
- for (i = 0; i < state->crtc_count; i++) {
- xcb_randr_crtc_t crtc = state->crtcs[i].crtc;
- xcb_randr_get_crtc_gamma_size_cookie_t gamma_size_cookie;
- xcb_randr_get_crtc_gamma_size_reply_t *gamma_size_reply;
- xcb_randr_get_crtc_gamma_cookie_t gamma_get_cookie;
- xcb_randr_get_crtc_gamma_reply_t *gamma_get_reply;
- uint16_t *gamma_r, *gamma_g, *gamma_b;
- unsigned int ramp_size;
-
- /* Request size of gamma ramps */
- gamma_size_cookie = xcb_randr_get_crtc_gamma_size(state->conn, crtc);
- gamma_size_reply = xcb_randr_get_crtc_gamma_size_reply(state->conn, gamma_size_cookie, &error);
-
- if (error) {
- weprintf(_("`%s' returned error %i."), "RANDR Get CRTC Gamma Size", error->error_code);
- return -1;
- }
-
- ramp_size = gamma_size_reply->size;
- state->crtcs[i].ramp_size = ramp_size;
-
- free(gamma_size_reply);
-
- if (ramp_size == 0) {
- weprintf(_("Gamma ramp size too small: %zu"), (size_t)ramp_size);
- return -1;
- }
-
- /* Request current gamma ramps */
- gamma_get_cookie = xcb_randr_get_crtc_gamma(state->conn, crtc);
- gamma_get_reply = xcb_randr_get_crtc_gamma_reply(state->conn, gamma_get_cookie, &error);
-
- if (error) {
- weprintf(_("`%s' returned error %i."), "RANDR Get CRTC Gamma", error->error_code);
- return -1;
- }
-
- gamma_r = xcb_randr_get_crtc_gamma_red(gamma_get_reply);
- gamma_g = xcb_randr_get_crtc_gamma_green(gamma_get_reply);
- gamma_b = xcb_randr_get_crtc_gamma_blue(gamma_get_reply);
-
- /* Allocate space for saved gamma ramps */
- state->crtcs[i].saved_ramps = emalloc(3 * ramp_size * sizeof(uint16_t));
-
- /* Copy gamma ramps into CRTC state */
- memcpy(&state->crtcs[i].saved_ramps[0 * ramp_size], gamma_r, ramp_size * sizeof(uint16_t));
- memcpy(&state->crtcs[i].saved_ramps[1 * ramp_size], gamma_g, ramp_size * sizeof(uint16_t));
- memcpy(&state->crtcs[i].saved_ramps[2 * ramp_size], gamma_b, ramp_size * sizeof(uint16_t));
-
- free(gamma_get_reply);
- }
-
- return 0;
-}
-
-
-static void
-randr_restore(struct gamma_state *state)
-{
- xcb_generic_error_t *error;
- int i;
-
- /* Restore CRTC gamma ramps */
- for (i = 0; i < state->crtc_count; i++) {
- xcb_randr_crtc_t crtc = state->crtcs[i].crtc;
-
- unsigned int ramp_size = state->crtcs[i].ramp_size;
- uint16_t *gamma_r = &state->crtcs[i].saved_ramps[0*ramp_size];
- uint16_t *gamma_g = &state->crtcs[i].saved_ramps[1*ramp_size];
- uint16_t *gamma_b = &state->crtcs[i].saved_ramps[2*ramp_size];
-
- /* Set gamma ramps */
- xcb_void_cookie_t gamma_set_cookie =
- xcb_randr_set_crtc_gamma_checked(state->conn, crtc,
- ramp_size, gamma_r,
- gamma_g, gamma_b);
- error = xcb_request_check(state->conn, gamma_set_cookie);
-
- if (error) {
- weprintf(_("`%s' returned error %i."), "RANDR Set CRTC Gamma", error->error_code);
- weprintf(_("Unable to restore CRTC %i."), i);
- }
- }
-}
-
-
-static void
-randr_free(struct gamma_state *state)
-{
- int i;
-
- /* Free CRTC state */
- for (i = 0; i < state->crtc_count; i++)
- free(state->crtcs[i].saved_ramps);
- free(state->crtcs);
- free(state->crtc_num);
-
- /* Close connection */
- xcb_disconnect(state->conn);
-
- free(state);
+ return direct_create(state_out, LIBGAMMA_METHOD_X_RANDR, "randr");
}
@@ -266,12 +33,9 @@ randr_print_help(FILE *f)
fputs(_("Adjust gamma ramps with the X RANDR extension.\n"), f);
fputs("\n", f);
- /* TRANSLATORS: RANDR help output
- left column must not be translated */
- fputs(_(" screen=N\t\tX screen to apply adjustments to\n"
- " crtc=N\tList of comma separated CRTCs to apply"
- " adjustments to\n"),
- f);
+ /* TRANSLATORS: RANDR help output left column must not be translated */
+ fputs(_(" screen=N X screen to apply adjustments to\n"), f);
+ fputs(_(" crtc=N List of comma-separated CRTCs to apply adjustments to\n"), f);
fputs("\n", f);
}
@@ -280,140 +44,21 @@ static int
randr_set_option(struct gamma_state *state, const char *key, const char *value)
{
if (!strcasecmp(key, "screen")) {
- state->screen_num = atoi(value);
+ return direct_set_partitions(state, key, value);
} else if (!strcasecmp(key, "crtc")) {
- char *tail;
- int i, parsed;
-
- /* Check how many crtcs are configured */
- const char *local_value = value;
- if (!*local_value || !strcasecmp(local_value, "all")) {
- state->crtc_num_count = 0;
- free(state->crtc_num);
- state->crtc_num = NULL;
- return 0;
- }
- for (;;) {
- errno = 0;
- parsed = strtol(local_value, &tail, 0);
- if (!parsed && (errno || tail == local_value)) {
- weprintf(_("Unable to read screen number: `%s'."), value);
- return -1;
- }
- state->crtc_num_count += 1;
- local_value = tail;
-
- if (*local_value == ',')
- local_value += 1;
- else if (!*local_value)
- break;
- }
-
- /* Configure all given crtcs */
- state->crtc_num = calloc(state->crtc_num_count, sizeof(int));
- local_value = value;
- for (i = 0; i < state->crtc_num_count; i++) {
- errno = 0;
- parsed = strtol(local_value, &tail, 0);
- if (parsed == 0 && (errno != 0 || tail == local_value))
- return -1;
- state->crtc_num[i] = parsed;
- local_value = tail;
-
- if (*local_value == ',')
- local_value += 1;
- else if (!*local_value)
- break;
- }
- } else if (strcasecmp(key, "preserve") == 0) {
- weprintf(_("Parameter `%s' is now always on; use the `%s' command-line option to disable."), key, "-P");
+ return direct_set_crtcs(state, key, value);
+ } else if (!strcasecmp(key, "preserve")) {
+ weprintf(_("Deprecated method parameter ignored: `%s'."), key);
+ return 0;
} else {
weprintf(_("Unknown method parameter: `%s'."), key);
return -1;
}
-
- return 0;
-}
-
-
-static int
-randr_apply_for_crtc(struct gamma_state *state, int crtc_num, const struct colour_setting *setting, int preserve)
-{
- xcb_randr_crtc_t crtc;
- xcb_void_cookie_t gamma_set_cookie;
- xcb_generic_error_t *error;
- unsigned int i, ramp_size;
- uint16_t *gamma_ramps, *gamma_r, *gamma_g, *gamma_b, value;
-
- if (crtc_num >= state->crtc_count || crtc_num < 0) {
- if (state->crtc_count > 1)
- weprintf(_("CRTC %i does not exist, valid CRTCs are [0, %i]."), crtc_num, (int)state->crtc_count - 1);
- else
- weprintf(_("CRTC %i does not exist, only CRTC 0 exists."), crtc_num);
-
- return -1;
- }
-
- crtc = state->crtcs[crtc_num].crtc;
- ramp_size = state->crtcs[crtc_num].ramp_size;
-
- /* Create new gamma ramps */
- gamma_ramps = emalloc(3 * ramp_size * sizeof(uint16_t));
-
- gamma_r = &gamma_ramps[0 * ramp_size];
- gamma_g = &gamma_ramps[1 * ramp_size];
- gamma_b = &gamma_ramps[2 * ramp_size];
-
- if (preserve) {
- /* Initialize gamma ramps from saved state */
- memcpy(gamma_ramps, state->crtcs[crtc_num].saved_ramps,
- 3 * ramp_size * sizeof(uint16_t));
- } else {
- /* Initialize gamma ramps to pure state */
- for (i = 0; i < ramp_size; i++) {
- value = (double)i / (ramp_size - 1) * UINT16_MAX;
- gamma_r[i] = value;
- gamma_g[i] = value;
- gamma_b[i] = value;
- }
- }
-
- fill_ramps_u16(gamma_r, gamma_g, gamma_b, ramp_size, ramp_size, ramp_size, setting);
-
- /* Set new gamma ramps */
- gamma_set_cookie = xcb_randr_set_crtc_gamma_checked(state->conn, crtc, ramp_size, gamma_r, gamma_g, gamma_b);
- error = xcb_request_check(state->conn, gamma_set_cookie);
-
- if (error) {
- weprintf(_("`%s' returned error %i."), "RANDR Set CRTC Gamma", error->error_code);
- free(gamma_ramps);
- return -1;
- }
-
- free(gamma_ramps);
-
- return 0;
-}
-
-
-static int
-randr_apply(struct gamma_state *state, const struct colour_setting *setting, int preserve)
-{
- int i;
-
- /* If no CRTC numbers have been specified, set temperature on all CRTCs. */
- if (!state->crtc_num_count) {
- for (i = 0; i < state->crtc_count; i++)
- if (randr_apply_for_crtc(state, i, setting, preserve) < 0)
- return -1;
- } else {
- for (i = 0; i < state->crtc_num_count; ++i)
- if (randr_apply_for_crtc(state, state->crtc_num[i], setting, preserve) < 0)
- return -1;
- }
-
- return 0;
}
+#define randr_start direct_start
+#define randr_apply direct_apply
+#define randr_restore direct_restore
+#define randr_free direct_free
const struct gamma_method randr_gamma_method = GAMMA_METHOD_INIT("randr", 1, 0, randr);
diff --git a/src/gamma-vidmode.c b/src/gamma-vidmode.c
index 7c5321a..e38de97 100644
--- a/src/gamma-vidmode.c
+++ b/src/gamma-vidmode.c
@@ -19,93 +19,11 @@
*/
#include "common.h"
-#include <X11/Xlib.h>
-#include <X11/extensions/xf86vmode.h>
-
-
-struct gamma_state {
- Display *display;
- int screen_num;
- int ramp_size;
- uint16_t *saved_ramps;
-};
-
static int
vidmode_create(struct gamma_state **state_out)
{
- struct gamma_state *state;
-
- state = *state_out = emalloc(sizeof(**state_out));
- state->screen_num = -1;
- state->saved_ramps = NULL;
-
- state->display = XOpenDisplay(NULL);
- if (!state->display) {
- weprintf(_("X request failed: %s"), "XOpenDisplay");
- return -1;
- }
-
- return 0;
-}
-
-
-static int
-vidmode_start(struct gamma_state *state)
-{
- int r;
- int screen_num = state->screen_num;
- int major, minor;
- uint16_t *gamma_r, *gamma_g, *gamma_b;
-
- if (screen_num < 0)
- screen_num = DefaultScreen(state->display);
- state->screen_num = screen_num;
-
- /* Query extension version */
- r = XF86VidModeQueryVersion(state->display, &major, &minor);
- if (!r) {
- weprintf(_("X request failed: %s"), "XF86VidModeQueryVersion");
- return -1;
- }
-
- /* Request size of gamma ramps */
- r = XF86VidModeGetGammaRampSize(state->display, state->screen_num, &state->ramp_size);
- if (!r) {
- weprintf(_("X request failed: %s"), "XF86VidModeGetGammaRampSize");
- return -1;
- }
-
- if (!state->ramp_size) {
- weprintf(_("Gamma ramp size too small: %zu"), (size_t)state->ramp_size);
- return -1;
- }
-
- /* Allocate space for saved gamma ramps */
- state->saved_ramps = emalloc(3 * state->ramp_size * sizeof(uint16_t));
-
- gamma_r = &state->saved_ramps[0 * state->ramp_size];
- gamma_g = &state->saved_ramps[1 * state->ramp_size];
- gamma_b = &state->saved_ramps[2 * state->ramp_size];
-
- /* Save current gamma ramps so we can restore them at program exit. */
- r = XF86VidModeGetGammaRamp(state->display, state->screen_num,
- state->ramp_size, gamma_r, gamma_g, gamma_b);
- if (!r) {
- weprintf(_("X request failed: %s"), "XF86VidModeGetGammaRamp");
- return -1;
- }
-
- return 0;
-}
-
-
-static void
-vidmode_free(struct gamma_state *state)
-{
- free(state->saved_ramps);
- XCloseDisplay(state->display);
- free(state);
+ return direct_create(state_out, LIBGAMMA_METHOD_X_VIDMODE, "vidmode");
}
@@ -115,8 +33,7 @@ vidmode_print_help(FILE *f)
fputs(_("Adjust gamma ramps with the X VidMode extension.\n"), f);
fputs("\n", f);
- /* TRANSLATORS: VidMode help output left column must not be translated */
- fputs(_(" screen=N\t\tX screen to apply adjustments to\n"), f);
+ fputs(_(" screen=N X screen to apply adjustments to\n"), f);
fputs("\n", f);
}
@@ -125,75 +42,19 @@ static int
vidmode_set_option(struct gamma_state *state, const char *key, const char *value)
{
if (!strcasecmp(key, "screen")) {
- state->screen_num = atoi(value);
+ return direct_set_partitions(state, key, value);
} else if (!strcasecmp(key, "preserve")) {
- weprintf(_("Parameter `%s' is now always on; use the `%s' command-line option to disable."), key, "-P");
+ weprintf(_("Deprecated method parameter ignored: `%s'."), key);
+ return 0;
} else {
weprintf(_("Unknown method parameter: `%s'."), key);
return -1;
}
-
- return 0;
-}
-
-
-static void
-vidmode_restore(struct gamma_state *state)
-{
- uint16_t *gamma_r = &state->saved_ramps[0 * state->ramp_size];
- uint16_t *gamma_g = &state->saved_ramps[1 * state->ramp_size];
- uint16_t *gamma_b = &state->saved_ramps[2 * state->ramp_size];
- int r;
-
- /* Restore gamma ramps */
- r = XF86VidModeSetGammaRamp(state->display, state->screen_num,
- state->ramp_size, gamma_r, gamma_g, gamma_b);
- if (!r)
- weprintf(_("X request failed: %s"), "XF86VidModeSetGammaRamp");
-}
-
-
-static int
-vidmode_apply(struct gamma_state *state, const struct colour_setting *setting, int preserve)
-{
- uint16_t value, *gamma_ramps, *gamma_r, *gamma_g, *gamma_b;
- int r, i;
-
- /* Create new gamma ramps */
- gamma_ramps = emalloc(3 * state->ramp_size * sizeof(uint16_t));
-
- gamma_r = &gamma_ramps[0 * state->ramp_size];
- gamma_g = &gamma_ramps[1 * state->ramp_size];
- gamma_b = &gamma_ramps[2 * state->ramp_size];
-
- if (preserve) {
- /* Initialize gamma ramps from saved state */
- memcpy(gamma_ramps, state->saved_ramps, 3 * state->ramp_size * sizeof(uint16_t));
- } else {
- /* Initialize gamma ramps to pure state */
- for (i = 0; i < state->ramp_size; i++) {
- value = (double)i / (state->ramp_size - 1) * UINT16_MAX;
- gamma_r[i] = value;
- gamma_g[i] = value;
- gamma_b[i] = value;
- }
- }
-
- fill_ramps_u16(gamma_r, gamma_g, gamma_b, state->ramp_size, state->ramp_size, state->ramp_size, setting);
-
- /* Set new gamma ramps */
- r = XF86VidModeSetGammaRamp(state->display, state->screen_num,
- state->ramp_size, gamma_r, gamma_g, gamma_b);
- if (!r) {
- weprintf(_("X request failed: %s"), "XF86VidModeSetGammaRamp");
- free(gamma_ramps);
- return -1;
- }
-
- free(gamma_ramps);
-
- return 0;
}
+#define vidmode_start direct_start
+#define vidmode_apply direct_apply
+#define vidmode_restore direct_restore
+#define vidmode_free direct_free
const struct gamma_method vidmode_gamma_method = GAMMA_METHOD_INIT("vidmode", 1, 0, vidmode);