parent
586ae674ae
commit
1b588e7c1f
@ -0,0 +1,21 @@
|
|||||||
|
#ifndef _WLR_GAMMA_CONTROL_H
|
||||||
|
#define _WLR_GAMMA_CONTROL_H
|
||||||
|
#include <wayland-server.h>
|
||||||
|
|
||||||
|
struct wlr_gamma_control_manager {
|
||||||
|
struct wl_global *wl_global;
|
||||||
|
|
||||||
|
void *data;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct wlr_gamma_control {
|
||||||
|
struct wl_resource *resource;
|
||||||
|
struct wl_resource *output;
|
||||||
|
|
||||||
|
void* data;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct wlr_gamma_control_manager *wlr_gamma_control_manager_create(struct wl_display *display);
|
||||||
|
void wlr_gamma_control_manager_destroy(struct wlr_gamma_control_manager *gamma_control_manager);
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,57 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<protocol name="gamma_control">
|
||||||
|
|
||||||
|
<copyright>
|
||||||
|
Copyright © 2015 Giulio camuffo
|
||||||
|
|
||||||
|
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>
|
||||||
|
|
||||||
|
<interface name="gamma_control_manager" version="1">
|
||||||
|
<request name="destroy" type="destructor"/>
|
||||||
|
|
||||||
|
<request name="get_gamma_control">
|
||||||
|
<arg name="id" type="new_id" interface="gamma_control"/>
|
||||||
|
<arg name="output" type="object" interface="wl_output"/>
|
||||||
|
</request>
|
||||||
|
</interface>
|
||||||
|
|
||||||
|
<interface name="gamma_control" version="1">
|
||||||
|
<enum name="error">
|
||||||
|
<entry name="invalid_gamma" value="0"/>
|
||||||
|
</enum>
|
||||||
|
|
||||||
|
<request name="destroy" type="destructor"/>
|
||||||
|
|
||||||
|
<request name="set_gamma">
|
||||||
|
<arg name="red" type="array"/>
|
||||||
|
<arg name="green" type="array"/>
|
||||||
|
<arg name="blue" type="array"/>
|
||||||
|
</request>
|
||||||
|
|
||||||
|
<request name="reset_gamma"/>
|
||||||
|
|
||||||
|
<event name="gamma_size">
|
||||||
|
<arg name="size" type="uint"/>
|
||||||
|
</event>
|
||||||
|
</interface>
|
||||||
|
</protocol>
|
@ -0,0 +1,94 @@
|
|||||||
|
#include <assert.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <wayland-server.h>
|
||||||
|
#include <wlr/types/wlr_gamma_control.h>
|
||||||
|
#include <wlr/util/log.h>
|
||||||
|
#include "gamma-control-protocol.h"
|
||||||
|
|
||||||
|
static void resource_destroy(struct wl_client *client, struct wl_resource *resource) {
|
||||||
|
// TODO: we probably need to do more than this
|
||||||
|
wl_resource_destroy(resource);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gamma_control_destroy(struct wl_resource *resource) {
|
||||||
|
struct wlr_gamma_control *gamma_control = wl_resource_get_user_data(resource);
|
||||||
|
free(gamma_control);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gamma_control_set_gamma(struct wl_client *client,
|
||||||
|
struct wl_resource *_gamma_control, struct wl_array *red,
|
||||||
|
struct wl_array *green, struct wl_array *blue) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gamma_control_reset_gamma(struct wl_client *client,
|
||||||
|
struct wl_resource *_gamma_control) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct gamma_control_interface gamma_control_implementation = {
|
||||||
|
.destroy = resource_destroy,
|
||||||
|
.set_gamma = gamma_control_set_gamma,
|
||||||
|
.reset_gamma = gamma_control_reset_gamma,
|
||||||
|
};
|
||||||
|
|
||||||
|
static void gamma_control_manager_get_gamma_control(struct wl_client *client,
|
||||||
|
struct wl_resource *_gamma_control_manager, uint32_t id,
|
||||||
|
struct wl_resource *_output) {
|
||||||
|
//struct wlr_gamma_control_manager *gamma_control_manager =
|
||||||
|
// wl_resource_get_user_data(_gamma_control_manager);
|
||||||
|
struct wlr_gamma_control *gamma_control;
|
||||||
|
if (!(gamma_control = calloc(1, sizeof(struct wlr_gamma_control)))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
gamma_control->output = _output;
|
||||||
|
gamma_control->resource = wl_resource_create(client,
|
||||||
|
&gamma_control_interface, wl_resource_get_version(_gamma_control_manager), id);
|
||||||
|
wlr_log(L_DEBUG, "new gamma_control %p (res %p)", gamma_control, gamma_control->resource);
|
||||||
|
wl_resource_set_implementation(gamma_control->resource,
|
||||||
|
&gamma_control_implementation, gamma_control, gamma_control_destroy);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct gamma_control_manager_interface gamma_control_manager_impl = {
|
||||||
|
.get_gamma_control = gamma_control_manager_get_gamma_control,
|
||||||
|
};
|
||||||
|
|
||||||
|
static void gamma_control_manager_bind(struct wl_client *wl_client,
|
||||||
|
void *_gamma_control_manager, uint32_t version, uint32_t id) {
|
||||||
|
struct wlr_gamma_control_manager *gamma_control_manager = _gamma_control_manager;
|
||||||
|
assert(wl_client && gamma_control_manager);
|
||||||
|
if (version > 1) {
|
||||||
|
wlr_log(L_ERROR, "Client requested unsupported gamma_control version, disconnecting");
|
||||||
|
wl_client_destroy(wl_client);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
struct wl_resource *wl_resource = wl_resource_create(
|
||||||
|
wl_client, &gamma_control_manager_interface, version, id);
|
||||||
|
wl_resource_set_implementation(wl_resource, &gamma_control_manager_impl,
|
||||||
|
gamma_control_manager, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct wlr_gamma_control_manager *wlr_gamma_control_manager_create(struct wl_display *display) {
|
||||||
|
struct wlr_gamma_control_manager *gamma_control_manager =
|
||||||
|
calloc(1, sizeof(struct wlr_gamma_control_manager));
|
||||||
|
if (!gamma_control_manager) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
struct wl_global *wl_global = wl_global_create(display,
|
||||||
|
&gamma_control_manager_interface, 1, gamma_control_manager, gamma_control_manager_bind);
|
||||||
|
if (!wl_global) {
|
||||||
|
free(gamma_control_manager);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
gamma_control_manager->wl_global = wl_global;
|
||||||
|
return gamma_control_manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wlr_gamma_control_manager_destroy(struct wlr_gamma_control_manager *gamma_control_manager) {
|
||||||
|
if (!gamma_control_manager) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// TODO: this segfault (wl_display->registry_resource_list is not init)
|
||||||
|
// wl_global_destroy(gamma_control_manager->wl_global);
|
||||||
|
free(gamma_control_manager);
|
||||||
|
}
|
Loading…
Reference in new issue