Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support wlroots gamma control protocol #704

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ m4/lt~obsolete.m4
/data/systemd/redshift.service
/data/systemd/redshift-gtk.service
/m4
/src/gamma-control-client-protocol.h
/src/gamma-control-protocol.c
/src/orbital-authorizer-client-protocol.h
/src/orbital-authorizer-protocol.c
/src/redshift
/src/redshift-gtk/defs.py
/src/redshift-gtk/redshift-gtk
Expand Down
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ matrix:
include:
- os: linux
compiler: gcc
dist: trusty
dist: xenial
sudo: false
- os: osx
compiler: clang
Expand All @@ -23,6 +23,8 @@ addons:
# VidMode
- libx11-dev
- libxxf86vm-dev
# Wayland
- libwayland-dev
# GeoClue2
- libglib2.0-dev
# GUI
Expand All @@ -49,7 +51,7 @@ install:
- mkdir "$TRAVIS_BUILD_DIR/root"
- |
if [ "$TRAVIS_OS_NAME" == "linux" ]; then
./configure --prefix="$TRAVIS_BUILD_DIR/root" --enable-drm --enable-vidmode --enable-randr --enable-geoclue2 --enable-gui --enable-apparmor
./configure --prefix="$TRAVIS_BUILD_DIR/root" --enable-drm --enable-vidmode --enable-randr --enable-geoclue2 --enable-gui --enable-apparmor --with-systemduserunitdir=no
elif [ "$TRAVIS_OS_NAME" == "osx" ]; then
./configure --prefix="$TRAVIS_BUILD_DIR/root" --enable-corelocation --enable-quartz --enable-gui
fi
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ build_script:
$env:MSYSTEM = "MINGW32"
}

$env:CONFIGURE_FLAGS = "--disable-drm --disable-randr --disable-vidmode --enable-wingdi --disable-quartz --disable-geoclue2 --disable-corelocation --disable-gui --disable-ubuntu --disable-nls --host=$env:arch-w64-mingw32"
$env:CONFIGURE_FLAGS = "--disable-drm --disable-wayland --disable-randr --disable-vidmode --enable-wingdi --disable-quartz --disable-geoclue2 --disable-corelocation --disable-gui --disable-ubuntu --disable-nls --host=$env:arch-w64-mingw32"

- ps: md (Join-Path $env:APPVEYOR_BUILD_FOLDER root)
- C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && ./bootstrap"
Expand Down
29 changes: 29 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ PKG_CHECK_MODULES([XCB], [xcb], [have_xcb=yes], [have_xcb=no])
PKG_CHECK_MODULES([XCB_RANDR], [xcb-randr],
[have_xcb_randr=yes], [have_xcb_randr=no])

PKG_CHECK_MODULES([WAYLAND], [wayland-client wayland-scanner >= 1.15.0],
[have_wayland=yes], [have_wayland=no])
PKG_CHECK_VAR(WAYLAND_SCANNER, wayland-scanner, wayland_scanner)

PKG_CHECK_MODULES([GLIB], [glib-2.0 gobject-2.0], [have_glib=yes], [have_glib=no])
PKG_CHECK_MODULES([GEOCLUE2], [glib-2.0 gio-2.0 >= 2.26], [have_geoclue2=yes], [have_geoclue2=no])

Expand Down Expand Up @@ -124,6 +128,30 @@ AS_IF([test "x$enable_drm" != xno], [
])
AM_CONDITIONAL([ENABLE_DRM], [test "x$enable_drm" = xyes])

# Check Wayland method
AC_MSG_CHECKING([whether to enable Wayland method])
AC_ARG_ENABLE([wayland], [AC_HELP_STRING([--enable-wayland],
[enable Wayland method])],
[enable_wayland=$enableval],[enable_wayland=maybe])
AS_IF([test "x$enable_wayland" != xno], [
AS_IF([test $have_wayland = yes], [
AC_DEFINE([ENABLE_WAYLAND], 1,
[Define to 1 to enable Wayland method])
AC_MSG_RESULT([yes])
enable_wayland=yes
], [
AC_MSG_RESULT([missing dependencies])
AS_IF([test "x$enable_wayland" = xyes], [
AC_MSG_ERROR([missing dependencies for Wayland method])
])
enable_wayland=no
])
], [
AC_MSG_RESULT([no])
enable_wayland=no
])
AM_CONDITIONAL([ENABLE_WAYLAND], [test "x$enable_wayland" = xyes])

# Check RANDR method
AC_MSG_CHECKING([whether to enable RANDR method])
AC_ARG_ENABLE([randr], [AC_HELP_STRING([--enable-randr],
Expand Down Expand Up @@ -376,6 +404,7 @@ echo "

Adjustment methods:
DRM: ${enable_drm}
Wayland: ${enable_wayland}
RANDR: ${enable_randr}
VidMode: ${enable_vidmode}
Quartz (macOS): ${enable_quartz}
Expand Down
1 change: 1 addition & 0 deletions po/POTFILES.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ src/options.c
src/config-ini.c

src/gamma-drm.c
src/gamma-wl.c
src/gamma-randr.c
src/gamma-vidmode.c
src/gamma-quartz.c
Expand Down
30 changes: 30 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ redshift_SOURCES = \

EXTRA_redshift_SOURCES = \
gamma-drm.c gamma-drm.h \
gamma-wl.c gamma-wl.h \
gamma-randr.c gamma-randr.h \
gamma-vidmode.c gamma-vidmode.h \
gamma-quartz.c gamma-quartz.h \
Expand All @@ -43,6 +44,27 @@ redshift_LDADD += \
$(DRM_LIBS) $(DRM_CFLAGS)
endif

if ENABLE_WAYLAND
redshift_SOURCES += gamma-wl.c gamma-wl.h os-compatibility.c os-compatibility.h

AM_CFLAGS += $(WAYLAND_CFLAGS)

redshift_LDADD += \
$(WAYLAND_LIBS) $(WAYLAND_CFLAGS)

nodist_redshift_SOURCES = \
gamma-control-client-protocol.h \
gamma-control-protocol.c \
orbital-authorizer-protocol.c \
orbital-authorizer-client-protocol.h

BUILT_SOURCES = \
gamma-control-protocol.c \
gamma-control-client-protocol.h \
orbital-authorizer-protocol.c \
orbital-authorizer-client-protocol.h
endif

if ENABLE_RANDR
redshift_SOURCES += gamma-randr.c gamma-randr.h
AM_CFLAGS += $(XCB_CFLAGS) $(XCB_RANDR_CFLAGS)
Expand Down Expand Up @@ -103,3 +125,11 @@ endif

.rc.o:
$(AM_V_GEN)$(WINDRES) -I$(top_builddir) -i $< -o $@

%-protocol.c : $(srcdir)/%.xml
$(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(WAYLAND_SCANNER) private-code < $< > $@

%-client-protocol.h : $(srcdir)/%.xml
$(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(WAYLAND_SCANNER) client-header < $< > $@

CLEANFILES = *-protocol.c *-client-protocol.h
126 changes: 126 additions & 0 deletions src/gamma-control.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="wlr_gamma_control_unstable_v1">
<copyright>
Copyright © 2015 Giulio camuffo
Copyright © 2018 Simon Ser

Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
without fee, provided that the above copyright notice appear in
all copies and that both that copyright notice and this permission
notice appear in supporting documentation, and that the name of
the copyright holders not be used in advertising or publicity
pertaining to distribution of the software without specific,
written prior permission. The copyright holders make no
representations about the suitability of this software for any
purpose. It is provided "as is" without express or implied
warranty.

THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
</copyright>

<description summary="manage gamma tables of outputs">
This protocol allows a privileged client to set the gamma tables for
outputs.

Warning! The protocol described in this file is experimental and
backward incompatible changes may be made. Backward compatible changes
may be added together with the corresponding interface version bump.
Backward incompatible changes are done by bumping the version number in
the protocol and interface names and resetting the interface version.
Once the protocol is to be declared stable, the 'z' prefix and the
version number in the protocol and interface names are removed and the
interface version number is reset.
</description>

<interface name="zwlr_gamma_control_manager_v1" version="1">
<description summary="manager to create per-output gamma controls">
This interface is a manager that allows creating per-output gamma
controls.
</description>

<request name="get_gamma_control">
<description summary="get a gamma control for an output">
Create a gamma control that can be used to adjust gamma tables for the
provided output.
</description>
<arg name="id" type="new_id" interface="zwlr_gamma_control_v1"/>
<arg name="output" type="object" interface="wl_output"/>
</request>

<request name="destroy" type="destructor">
<description summary="destroy the manager">
All objects created by the manager will still remain valid, until their
appropriate destroy request has been called.
</description>
</request>
</interface>

<interface name="zwlr_gamma_control_v1" version="1">
<description summary="adjust gamma tables for an output">
This interface allows a client to adjust gamma tables for a particular
output.

The client will receive the gamma size, and will then be able to set gamma
tables. At any time the compositor can send a failed event indicating that
this object is no longer valid.

There must always be at most one gamma control object per output, which
has exclusive access to this particular output. When the gamma control
object is destroyed, the gamma table is restored to its original value.
</description>

<event name="gamma_size">
<description summary="size of gamma ramps">
Advertise the size of each gamma ramp.

This event is sent immediately when the gamma control object is created.
</description>
<arg name="size" type="uint"/>
</event>

<enum name="error">
<entry name="invalid_gamma" value="1" summary="invalid gamma tables"/>
</enum>

<request name="set_gamma">
<description summary="set the gamma table">
Set the gamma table. The file descriptor can be memory-mapped to provide
the raw gamma table, which contains successive gamma ramps for the red,
green and blue channels. Each gamma ramp is an array of 16-byte unsigned
integers which has the same length as the gamma size.

The file descriptor data must have the same length as three times the
gamma size.
</description>
<arg name="fd" type="fd" summary="gamma table file descriptor"/>
</request>

<event name="failed">
<description summary="object no longer valid">
This event indicates that the gamma control is no longer valid. This
can happen for a number of reasons, including:
- The output doesn't support gamma tables
- Setting the gamma tables failed
- Another client already has exclusive gamma control for this output
- The compositor has transfered gamma control to another client

Upon receiving this event, the client should destroy this object.
</description>
</event>

<request name="destroy" type="destructor">
<description summary="destroy this control">
Destroys the gamma control object. If the object is still valid, this
restores the original gamma tables.
</description>
</request>
</interface>
</protocol>
Loading