mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-12-26 11:39:47 +01:00
Add wlr_output_{set_gamma,get_gamma_size}
This commit is contained in:
parent
1b588e7c1f
commit
cd125377fc
3 changed files with 27 additions and 2 deletions
|
@ -64,5 +64,8 @@ void wlr_output_effective_resolution(struct wlr_output *output,
|
|||
int *width, int *height);
|
||||
void wlr_output_make_current(struct wlr_output *output);
|
||||
void wlr_output_swap_buffers(struct wlr_output *output);
|
||||
void wlr_output_set_gamma(struct wlr_output *output,
|
||||
uint16_t size, uint16_t *r, uint16_t *g, uint16_t *b);
|
||||
uint16_t wlr_output_get_gamma_size(struct wlr_output *output);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
#include <stdlib.h>
|
||||
#include <wayland-server.h>
|
||||
#include <wlr/types/wlr_gamma_control.h>
|
||||
#include <wlr/types/wlr_output.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);
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,17 @@ static void gamma_control_destroy(struct wl_resource *resource) {
|
|||
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
|
||||
if (red->size != green->size || red->size != blue->size) {
|
||||
wl_resource_post_error(_gamma_control, GAMMA_CONTROL_ERROR_INVALID_GAMMA,
|
||||
"The gamma ramps don't have the same size");
|
||||
return;
|
||||
}
|
||||
uint16_t *r = (uint16_t *)red->data;
|
||||
uint16_t *g = (uint16_t *)green->data;
|
||||
uint16_t *b = (uint16_t *)blue->data;
|
||||
struct wlr_gamma_control *gamma_control = wl_resource_get_user_data(_gamma_control);
|
||||
struct wlr_output *output = wl_resource_get_user_data(gamma_control->output);
|
||||
wlr_output_set_gamma(output, red->size / sizeof(uint16_t), r, g, b);
|
||||
}
|
||||
|
||||
static void gamma_control_reset_gamma(struct wl_client *client,
|
||||
|
@ -37,6 +47,7 @@ static void gamma_control_manager_get_gamma_control(struct wl_client *client,
|
|||
struct wl_resource *_output) {
|
||||
//struct wlr_gamma_control_manager *gamma_control_manager =
|
||||
// wl_resource_get_user_data(_gamma_control_manager);
|
||||
struct wlr_output *output = wl_resource_get_user_data(_output);
|
||||
struct wlr_gamma_control *gamma_control;
|
||||
if (!(gamma_control = calloc(1, sizeof(struct wlr_gamma_control)))) {
|
||||
return;
|
||||
|
@ -47,6 +58,7 @@ static void gamma_control_manager_get_gamma_control(struct wl_client *client,
|
|||
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);
|
||||
gamma_control_send_gamma_size(_gamma_control_manager, wlr_output_get_gamma_size(output));
|
||||
}
|
||||
|
||||
static struct gamma_control_manager_interface gamma_control_manager_impl = {
|
||||
|
|
|
@ -223,3 +223,13 @@ void wlr_output_swap_buffers(struct wlr_output *output) {
|
|||
|
||||
output->impl->swap_buffers(output);
|
||||
}
|
||||
|
||||
void wlr_output_set_gamma(struct wlr_output *output,
|
||||
uint16_t size, uint16_t *r, uint16_t *g, uint16_t *b) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
uint16_t wlr_output_get_gamma_size(struct wlr_output *output) {
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue