mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-12 13:29:45 -05:00
Merge branch 'master' into feature/data-device-selection
This commit is contained in:
commit
1dbe314937
55 changed files with 521 additions and 426 deletions
|
|
@ -2,13 +2,18 @@ lib_wlr_types = static_library(
|
|||
'wlr_types',
|
||||
files(
|
||||
'wlr_data_device.c',
|
||||
'wlr_box.c',
|
||||
'wlr_compositor.c',
|
||||
'wlr_cursor.c',
|
||||
'wlr_gamma_control.c',
|
||||
'wlr_input_device.c',
|
||||
'wlr_keyboard.c',
|
||||
'wlr_list.c',
|
||||
'wlr_output.c',
|
||||
'wlr_output_layout.c',
|
||||
'wlr_pointer.c',
|
||||
'wlr_cursor.c',
|
||||
'wlr_region.c',
|
||||
'wlr_screenshooter.c',
|
||||
'wlr_seat.c',
|
||||
'wlr_surface.c',
|
||||
'wlr_tablet_pad.c',
|
||||
|
|
@ -16,10 +21,6 @@ lib_wlr_types = static_library(
|
|||
'wlr_touch.c',
|
||||
'wlr_xdg_shell_v6.c',
|
||||
'wlr_wl_shell.c',
|
||||
'wlr_compositor.c',
|
||||
'wlr_box.c',
|
||||
'wlr_gamma_control.c',
|
||||
'wlr_screenshooter.c',
|
||||
),
|
||||
include_directories: wlr_inc,
|
||||
dependencies: [wayland_server, pixman, wlr_protos],
|
||||
|
|
|
|||
|
|
@ -53,12 +53,7 @@ static void wl_compositor_bind(struct wl_client *wl_client, void *_compositor,
|
|||
uint32_t version, uint32_t id) {
|
||||
struct wlr_compositor *compositor = _compositor;
|
||||
assert(wl_client && compositor);
|
||||
if (version > 4) {
|
||||
wlr_log(L_ERROR, "Client requested unsupported wl_compositor version, "
|
||||
"disconnecting");
|
||||
wl_client_destroy(wl_client);
|
||||
return;
|
||||
}
|
||||
|
||||
struct wl_resource *wl_resource =
|
||||
wl_resource_create(wl_client, &wl_compositor_interface, version, id);
|
||||
wl_resource_set_implementation(wl_resource, &wl_compositor_impl,
|
||||
|
|
|
|||
|
|
@ -6,100 +6,155 @@
|
|||
#include <wlr/util/log.h>
|
||||
#include "gamma-control-protocol.h"
|
||||
|
||||
static void resource_destroy(struct wl_client *client, struct wl_resource *resource) {
|
||||
static void resource_destroy(struct wl_client *client,
|
||||
struct wl_resource *resource) {
|
||||
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);
|
||||
static void gamma_control_destroy(struct wlr_gamma_control *gamma_control) {
|
||||
wl_signal_emit(&gamma_control->events.destroy, gamma_control);
|
||||
wl_list_remove(&gamma_control->output_destroy_listener.link);
|
||||
wl_resource_set_user_data(gamma_control->resource, NULL);
|
||||
free(gamma_control);
|
||||
}
|
||||
|
||||
static void gamma_control_destroy_resource(struct wl_resource *resource) {
|
||||
struct wlr_gamma_control *gamma_control =
|
||||
wl_resource_get_user_data(resource);
|
||||
gamma_control_destroy(gamma_control);
|
||||
}
|
||||
|
||||
static void gamma_control_handle_output_destroy(struct wl_listener *listener,
|
||||
void *data) {
|
||||
struct wlr_gamma_control *gamma_control =
|
||||
wl_container_of(listener, gamma_control, output_destroy_listener);
|
||||
gamma_control_destroy(gamma_control);
|
||||
}
|
||||
|
||||
static void gamma_control_set_gamma(struct wl_client *client,
|
||||
struct wl_resource *_gamma_control, struct wl_array *red,
|
||||
struct wl_resource *gamma_control_resource, struct wl_array *red,
|
||||
struct wl_array *green, struct wl_array *blue) {
|
||||
struct wlr_gamma_control *gamma_control =
|
||||
wl_resource_get_user_data(gamma_control_resource);
|
||||
|
||||
if (red->size != green->size || red->size != blue->size) {
|
||||
wl_resource_post_error(_gamma_control, GAMMA_CONTROL_ERROR_INVALID_GAMMA,
|
||||
wl_resource_post_error(gamma_control_resource,
|
||||
GAMMA_CONTROL_ERROR_INVALID_GAMMA,
|
||||
"The gamma ramps don't have the same size");
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t size = red->size / sizeof(uint16_t);
|
||||
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);
|
||||
|
||||
wlr_output_set_gamma(gamma_control->output, size, r, g, b);
|
||||
}
|
||||
|
||||
static void gamma_control_reset_gamma(struct wl_client *client,
|
||||
struct wl_resource *_gamma_control) {
|
||||
struct wl_resource *gamma_control_resource) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
static const struct gamma_control_interface gamma_control_implementation = {
|
||||
static const struct gamma_control_interface gamma_control_impl = {
|
||||
.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_output *output = wl_resource_get_user_data(_output);
|
||||
struct wlr_gamma_control *gamma_control;
|
||||
if (!(gamma_control = calloc(1, sizeof(struct wlr_gamma_control)))) {
|
||||
struct wl_resource *gamma_control_manager_resource, uint32_t id,
|
||||
struct wl_resource *output_resource) {
|
||||
struct wlr_gamma_control_manager *gamma_control_manager =
|
||||
wl_resource_get_user_data(gamma_control_manager_resource);
|
||||
struct wlr_output *output = wl_resource_get_user_data(output_resource);
|
||||
|
||||
struct wlr_gamma_control *gamma_control =
|
||||
calloc(1, sizeof(struct wlr_gamma_control));
|
||||
if (gamma_control == NULL) {
|
||||
wl_client_post_no_memory(client);
|
||||
return;
|
||||
}
|
||||
gamma_control->output = _output;
|
||||
gamma_control->output = output;
|
||||
|
||||
int version = wl_resource_get_version(gamma_control_manager_resource);
|
||||
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);
|
||||
&gamma_control_interface, version, id);
|
||||
if (gamma_control->resource == NULL) {
|
||||
wl_client_post_no_memory(client);
|
||||
free(gamma_control);
|
||||
return;
|
||||
}
|
||||
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->resource, wlr_output_get_gamma_size(output));
|
||||
&gamma_control_impl, gamma_control, gamma_control_destroy_resource);
|
||||
|
||||
wl_signal_init(&gamma_control->events.destroy);
|
||||
|
||||
wl_signal_add(&output->events.destroy,
|
||||
&gamma_control->output_destroy_listener);
|
||||
gamma_control->output_destroy_listener.notify =
|
||||
gamma_control_handle_output_destroy;
|
||||
|
||||
wl_list_insert(&gamma_control_manager->controls, &gamma_control->link);
|
||||
|
||||
gamma_control_send_gamma_size(gamma_control->resource,
|
||||
wlr_output_get_gamma_size(output));
|
||||
}
|
||||
|
||||
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,
|
||||
static void gamma_control_manager_bind(struct wl_client *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);
|
||||
struct wlr_gamma_control_manager *gamma_control_manager =
|
||||
_gamma_control_manager;
|
||||
assert(client && gamma_control_manager);
|
||||
|
||||
struct wl_resource *resource = wl_resource_create(client,
|
||||
&gamma_control_manager_interface, version, id);
|
||||
if (resource == NULL) {
|
||||
wl_client_post_no_memory(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,
|
||||
wl_resource_set_implementation(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 *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);
|
||||
&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;
|
||||
|
||||
wl_list_init(&gamma_control_manager->controls);
|
||||
|
||||
return gamma_control_manager;
|
||||
}
|
||||
|
||||
void wlr_gamma_control_manager_destroy(struct wlr_gamma_control_manager *gamma_control_manager) {
|
||||
void wlr_gamma_control_manager_destroy(
|
||||
struct wlr_gamma_control_manager *gamma_control_manager) {
|
||||
if (!gamma_control_manager) {
|
||||
return;
|
||||
}
|
||||
struct wlr_gamma_control *gamma_control, *tmp;
|
||||
wl_list_for_each_safe(gamma_control, tmp, &gamma_control_manager->controls,
|
||||
link) {
|
||||
gamma_control_destroy(gamma_control);
|
||||
}
|
||||
// TODO: this segfault (wl_display->registry_resource_list is not init)
|
||||
// wl_global_destroy(gamma_control_manager->wl_global);
|
||||
free(gamma_control_manager);
|
||||
|
|
|
|||
115
types/wlr_list.c
Normal file
115
types/wlr_list.c
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
#include <wlr/types/wlr_list.h>
|
||||
|
||||
struct wlr_list *wlr_list_create(void) {
|
||||
struct wlr_list *list = malloc(sizeof(struct wlr_list));
|
||||
if (!list) {
|
||||
return NULL;
|
||||
}
|
||||
list->capacity = 10;
|
||||
list->length = 0;
|
||||
list->items = malloc(sizeof(void*) * list->capacity);
|
||||
if (!list->items) {
|
||||
free(list);
|
||||
return NULL;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
static bool list_resize(struct wlr_list *list) {
|
||||
if (list->length == list->capacity) {
|
||||
void *new_items = realloc(list->items, sizeof(void*) * (list->capacity + 10));
|
||||
if (!new_items) {
|
||||
return false;
|
||||
}
|
||||
list->capacity += 10;
|
||||
list->items = new_items;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void wlr_list_free(struct wlr_list *list) {
|
||||
if (list == NULL) {
|
||||
return;
|
||||
}
|
||||
free(list->items);
|
||||
free(list);
|
||||
}
|
||||
|
||||
void wlr_list_foreach(struct wlr_list *list, void (*callback)(void *item)) {
|
||||
if (list == NULL || callback == NULL) {
|
||||
return;
|
||||
}
|
||||
for (size_t i = 0; i < list->length; i++) {
|
||||
callback(list->items[i]);
|
||||
}
|
||||
}
|
||||
|
||||
int wlr_list_add(struct wlr_list *list, void *item) {
|
||||
if (!list_resize(list)) {
|
||||
return -1;
|
||||
}
|
||||
list->items[list->length++] = item;
|
||||
return list->length;
|
||||
}
|
||||
|
||||
int wlr_list_push(struct wlr_list *list, void *item) {
|
||||
return wlr_list_add(list, item);
|
||||
}
|
||||
|
||||
int wlr_list_insert(struct wlr_list *list, size_t index, void *item) {
|
||||
if (!list_resize(list)) {
|
||||
return -1;
|
||||
}
|
||||
memmove(&list->items[index + 1], &list->items[index], sizeof(void*) * (list->length - index));
|
||||
list->length++;
|
||||
list->items[index] = item;
|
||||
return list->length;
|
||||
}
|
||||
|
||||
void wlr_list_del(struct wlr_list *list, size_t index) {
|
||||
list->length--;
|
||||
memmove(&list->items[index], &list->items[index + 1], sizeof(void*) * (list->length - index));
|
||||
}
|
||||
|
||||
void *wlr_list_pop(struct wlr_list *list) {
|
||||
void *_ = list->items[list->length - 1];
|
||||
wlr_list_del(list, list->length - 1);
|
||||
return _;
|
||||
}
|
||||
|
||||
void *wlr_list_peek(struct wlr_list *list) {
|
||||
return list->items[list->length - 1];
|
||||
}
|
||||
|
||||
int wlr_list_cat(struct wlr_list *list, struct wlr_list *source) {
|
||||
size_t old_len = list->length;
|
||||
size_t i;
|
||||
for (i = 0; i < source->length; ++i) {
|
||||
if (wlr_list_add(list, source->items[i]) == -1) {
|
||||
list->length = old_len;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return list->length;
|
||||
}
|
||||
|
||||
void wlr_list_qsort(struct wlr_list *list, int compare(const void *left, const void *right)) {
|
||||
qsort(list->items, list->length, sizeof(void *), compare);
|
||||
}
|
||||
|
||||
int wlr_list_seq_find(struct wlr_list *list,
|
||||
int compare(const void *item, const void *data),
|
||||
const void *data) {
|
||||
for (size_t i = 0; i < list->length; i++) {
|
||||
void *item = list->items[i];
|
||||
if (compare(item, data) == 0) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
#include <wlr/types/wlr_output.h>
|
||||
#include <wlr/types/wlr_surface.h>
|
||||
#include <wlr/interfaces/wlr_output.h>
|
||||
#include <wlr/util/list.h>
|
||||
#include <wlr/types/wlr_list.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include <GLES2/gl2.h>
|
||||
#include <wlr/render/matrix.h>
|
||||
|
|
@ -26,18 +26,18 @@ static void wl_output_send_to_resource(struct wl_resource *resource) {
|
|||
output->make, output->model, output->transform);
|
||||
}
|
||||
if (version >= WL_OUTPUT_MODE_SINCE_VERSION) {
|
||||
for (size_t i = 0; i < output->modes->length; ++i) {
|
||||
struct wlr_output_mode *mode = output->modes->items[i];
|
||||
struct wlr_output_mode *mode;
|
||||
wl_list_for_each(mode, &output->modes, link) {
|
||||
// TODO: mode->flags should just be preferred
|
||||
uint32_t flags = mode->flags;
|
||||
if (output->current_mode == mode) {
|
||||
flags |= WL_OUTPUT_MODE_CURRENT;
|
||||
}
|
||||
wl_output_send_mode(resource, flags,
|
||||
mode->width, mode->height, mode->refresh);
|
||||
wl_output_send_mode(resource, flags, mode->width, mode->height,
|
||||
mode->refresh);
|
||||
}
|
||||
|
||||
if (output->modes->length == 0) {
|
||||
if (wl_list_length(&output->modes) == 0) {
|
||||
// Output has no mode, send the current width/height
|
||||
wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT,
|
||||
output->width, output->height, 0);
|
||||
|
|
@ -51,6 +51,25 @@ static void wl_output_send_to_resource(struct wl_resource *resource) {
|
|||
}
|
||||
}
|
||||
|
||||
static void wlr_output_send_current_mode_to_resource(
|
||||
struct wl_resource *resource) {
|
||||
struct wlr_output *output = wl_resource_get_user_data(resource);
|
||||
assert(output);
|
||||
const uint32_t version = wl_resource_get_version(resource);
|
||||
if (version < WL_OUTPUT_MODE_SINCE_VERSION) {
|
||||
return;
|
||||
}
|
||||
if (output->current_mode != NULL) {
|
||||
struct wlr_output_mode *mode = output->current_mode;
|
||||
wl_output_send_mode(resource, mode->flags | WL_OUTPUT_MODE_CURRENT,
|
||||
mode->width, mode->height, mode->refresh);
|
||||
} else {
|
||||
// Output has no mode, send the current width/height
|
||||
wl_output_send_mode(resource, WL_OUTPUT_MODE_CURRENT, output->width,
|
||||
output->height, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void wl_output_destroy(struct wl_resource *resource) {
|
||||
struct wlr_output *output = wl_resource_get_user_data(resource);
|
||||
struct wl_resource *_resource = NULL;
|
||||
|
|
@ -75,21 +94,21 @@ static void wl_output_bind(struct wl_client *wl_client, void *_wlr_output,
|
|||
uint32_t version, uint32_t id) {
|
||||
struct wlr_output *wlr_output = _wlr_output;
|
||||
assert(wl_client && wlr_output);
|
||||
if (version > 3) {
|
||||
wlr_log(L_ERROR, "Client requested unsupported wl_output version, disconnecting");
|
||||
wl_client_destroy(wl_client);
|
||||
return;
|
||||
}
|
||||
struct wl_resource *wl_resource = wl_resource_create(
|
||||
wl_client, &wl_output_interface, version, id);
|
||||
wl_resource_set_implementation(wl_resource, &wl_output_impl,
|
||||
wlr_output, wl_output_destroy);
|
||||
wl_list_insert(&wlr_output->wl_resources, wl_resource_get_link(wl_resource));
|
||||
|
||||
struct wl_resource *wl_resource = wl_resource_create(wl_client,
|
||||
&wl_output_interface, version, id);
|
||||
wl_resource_set_implementation(wl_resource, &wl_output_impl, wlr_output,
|
||||
wl_output_destroy);
|
||||
wl_list_insert(&wlr_output->wl_resources,
|
||||
wl_resource_get_link(wl_resource));
|
||||
wl_output_send_to_resource(wl_resource);
|
||||
}
|
||||
|
||||
struct wl_global *wlr_output_create_global(
|
||||
struct wlr_output *wlr_output, struct wl_display *display) {
|
||||
struct wl_global *wlr_output_create_global(struct wlr_output *wlr_output,
|
||||
struct wl_display *display) {
|
||||
if (wlr_output->wl_global != NULL) {
|
||||
return wlr_output->wl_global;
|
||||
}
|
||||
struct wl_global *wl_global = wl_global_create(display,
|
||||
&wl_output_interface, 3, wlr_output, wl_output_bind);
|
||||
wlr_output->wl_global = wl_global;
|
||||
|
|
@ -97,32 +116,65 @@ struct wl_global *wlr_output_create_global(
|
|||
return wl_global;
|
||||
}
|
||||
|
||||
void wlr_output_update_matrix(struct wlr_output *output) {
|
||||
wlr_matrix_texture(output->transform_matrix, output->width, output->height, output->transform);
|
||||
void wlr_output_destroy_global(struct wlr_output *wlr_output) {
|
||||
if (wlr_output->wl_global == NULL) {
|
||||
return;
|
||||
}
|
||||
struct wl_resource *resource, *tmp;
|
||||
wl_resource_for_each_safe(resource, tmp, &wlr_output->wl_resources) {
|
||||
struct wl_list *link = wl_resource_get_link(resource);
|
||||
wl_list_remove(link);
|
||||
}
|
||||
wl_global_destroy(wlr_output->wl_global);
|
||||
wlr_output->wl_global = NULL;
|
||||
}
|
||||
|
||||
static void wlr_output_update_matrix(struct wlr_output *output) {
|
||||
wlr_matrix_texture(output->transform_matrix, output->width, output->height,
|
||||
output->transform);
|
||||
}
|
||||
|
||||
void wlr_output_enable(struct wlr_output *output, bool enable) {
|
||||
output->impl->enable(output, enable);
|
||||
}
|
||||
|
||||
bool wlr_output_set_mode(struct wlr_output *output, struct wlr_output_mode *mode) {
|
||||
bool wlr_output_set_mode(struct wlr_output *output,
|
||||
struct wlr_output_mode *mode) {
|
||||
if (!output->impl || !output->impl->set_mode) {
|
||||
return false;
|
||||
}
|
||||
bool result = output->impl->set_mode(output, mode);
|
||||
if (result) {
|
||||
wlr_output_update_matrix(output);
|
||||
struct wl_resource *resource;
|
||||
wl_resource_for_each(resource, &output->wl_resources) {
|
||||
wlr_output_send_current_mode_to_resource(resource);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void wlr_output_update_size(struct wlr_output *output, int32_t width,
|
||||
int32_t height) {
|
||||
output->width = width;
|
||||
output->height = height;
|
||||
wlr_output_update_matrix(output);
|
||||
if (output->wl_global != NULL) {
|
||||
struct wl_resource *resource;
|
||||
wl_resource_for_each(resource, &output->wl_resources) {
|
||||
wlr_output_send_current_mode_to_resource(resource);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void wlr_output_transform(struct wlr_output *output,
|
||||
enum wl_output_transform transform) {
|
||||
output->impl->transform(output, transform);
|
||||
wlr_output_update_matrix(output);
|
||||
}
|
||||
|
||||
void wlr_output_set_position(struct wlr_output *output, int32_t lx, int32_t ly) {
|
||||
void wlr_output_set_position(struct wlr_output *output, int32_t lx,
|
||||
int32_t ly) {
|
||||
if (lx == output->lx && ly == output->ly) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -153,8 +205,7 @@ static bool set_cursor(struct wlr_output *output, const uint8_t *buf,
|
|||
output->cursor.height = height;
|
||||
|
||||
if (!output->cursor.renderer) {
|
||||
/* NULL egl is okay given that we are only using pixel buffers */
|
||||
output->cursor.renderer = wlr_gles2_renderer_create(NULL);
|
||||
output->cursor.renderer = wlr_gles2_renderer_create(output->backend);
|
||||
if (!output->cursor.renderer) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -307,10 +358,11 @@ bool wlr_output_move_cursor(struct wlr_output *output, int x, int y) {
|
|||
return output->impl->move_cursor(output, x, y);
|
||||
}
|
||||
|
||||
void wlr_output_init(struct wlr_output *output,
|
||||
void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend,
|
||||
const struct wlr_output_impl *impl) {
|
||||
output->backend = backend;
|
||||
output->impl = impl;
|
||||
output->modes = list_create();
|
||||
wl_list_init(&output->modes);
|
||||
output->transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
||||
output->scale = 1;
|
||||
wl_signal_init(&output->events.frame);
|
||||
|
|
@ -334,11 +386,11 @@ void wlr_output_destroy(struct wlr_output *output) {
|
|||
wlr_texture_destroy(output->cursor.texture);
|
||||
wlr_renderer_destroy(output->cursor.renderer);
|
||||
|
||||
for (size_t i = 0; output->modes && i < output->modes->length; ++i) {
|
||||
struct wlr_output_mode *mode = output->modes->items[i];
|
||||
struct wlr_output_mode *mode, *tmp_mode;
|
||||
wl_list_for_each_safe(mode, tmp_mode, &output->modes, link) {
|
||||
free(mode);
|
||||
}
|
||||
list_free(output->modes);
|
||||
wl_list_remove(&output->modes);
|
||||
if (output->impl && output->impl->destroy) {
|
||||
output->impl->destroy(output);
|
||||
} else {
|
||||
|
|
@ -391,13 +443,13 @@ 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) {
|
||||
uint32_t size, uint16_t *r, uint16_t *g, uint16_t *b) {
|
||||
if (output->impl->set_gamma) {
|
||||
output->impl->set_gamma(output, size, r, g, b);
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t wlr_output_get_gamma_size(struct wlr_output *output) {
|
||||
uint32_t wlr_output_get_gamma_size(struct wlr_output *output) {
|
||||
if (!output->impl->get_gamma_size) {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -121,12 +121,7 @@ static void screenshooter_bind(struct wl_client *wl_client,
|
|||
void *_screenshooter, uint32_t version, uint32_t id) {
|
||||
struct wlr_screenshooter *screenshooter = _screenshooter;
|
||||
assert(wl_client && screenshooter);
|
||||
if (version > 1) {
|
||||
wlr_log(L_ERROR, "Client requested unsupported screenshooter version,"
|
||||
"disconnecting");
|
||||
wl_client_destroy(wl_client);
|
||||
return;
|
||||
}
|
||||
|
||||
struct wl_resource *wl_resource = wl_resource_create(wl_client,
|
||||
&orbital_screenshooter_interface, version, id);
|
||||
wl_resource_set_implementation(wl_resource, &screenshooter_impl,
|
||||
|
|
|
|||
|
|
@ -177,12 +177,7 @@ static void wl_seat_bind(struct wl_client *wl_client, void *_wlr_seat,
|
|||
uint32_t version, uint32_t id) {
|
||||
struct wlr_seat *wlr_seat = _wlr_seat;
|
||||
assert(wl_client && wlr_seat);
|
||||
if (version > 6) {
|
||||
wlr_log(L_ERROR,
|
||||
"Client requested unsupported wl_seat version, disconnecting");
|
||||
wl_client_destroy(wl_client);
|
||||
return;
|
||||
}
|
||||
|
||||
struct wlr_seat_handle *handle = calloc(1, sizeof(struct wlr_seat_handle));
|
||||
handle->wl_resource = wl_resource_create(
|
||||
wl_client, &wl_seat_interface, version, id);
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@
|
|||
#include <stdlib.h>
|
||||
#include <wayland-server.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include <wlr/egl.h>
|
||||
#include <wlr/render/interface.h>
|
||||
#include <wlr/types/wlr_surface.h>
|
||||
#include <wlr/render/egl.h>
|
||||
#include <wlr/render/matrix.h>
|
||||
|
||||
static void wlr_surface_state_reset_buffer(struct wlr_surface_state *state) {
|
||||
|
|
@ -408,7 +408,8 @@ static void wlr_surface_commit_pending(struct wlr_surface *surface) {
|
|||
wlr_surface_move_state(surface, surface->pending, surface->current);
|
||||
|
||||
if (null_buffer_commit) {
|
||||
surface->texture->valid = false;
|
||||
wlr_texture_destroy(surface->texture);
|
||||
surface->texture = NULL;
|
||||
}
|
||||
|
||||
bool reupload_buffer = oldw != surface->current->buffer_width ||
|
||||
|
|
@ -657,6 +658,10 @@ void wlr_surface_get_matrix(struct wlr_surface *surface,
|
|||
wlr_matrix_mul(projection, matrix, matrix);
|
||||
}
|
||||
|
||||
bool wlr_surface_has_buffer(struct wlr_surface *surface) {
|
||||
return surface->texture && surface->texture->valid;
|
||||
}
|
||||
|
||||
int wlr_surface_set_role(struct wlr_surface *surface, const char *role,
|
||||
struct wl_resource *error_resource, uint32_t error_code) {
|
||||
assert(role);
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
#include <wlr/types/wlr_wl_shell.h>
|
||||
#include <stdlib.h>
|
||||
#include <wayland-server-protocol.h>
|
||||
#include <wlr/render/interface.h>
|
||||
|
||||
static const char *wlr_wl_shell_surface_role = "wl-shell-surface";
|
||||
|
||||
|
|
@ -482,7 +481,7 @@ static void handle_wlr_surface_committed(struct wl_listener *listener,
|
|||
struct wlr_wl_shell_surface *surface =
|
||||
wl_container_of(listener, surface, surface_commit_listener);
|
||||
if (!surface->configured &&
|
||||
surface->surface->texture->valid &&
|
||||
wlr_surface_has_buffer(surface->surface) &&
|
||||
surface->state != WLR_WL_SHELL_SURFACE_STATE_NONE) {
|
||||
surface->configured = true;
|
||||
wl_signal_emit(&surface->shell->events.new_surface, surface);
|
||||
|
|
@ -490,7 +489,7 @@ static void handle_wlr_surface_committed(struct wl_listener *listener,
|
|||
|
||||
if (surface->popup_mapped &&
|
||||
surface->state == WLR_WL_SHELL_SURFACE_STATE_POPUP &&
|
||||
!surface->surface->texture->valid) {
|
||||
!wlr_surface_has_buffer(surface->surface)) {
|
||||
surface->popup_mapped = false;
|
||||
struct wlr_wl_shell_popup_grab *grab =
|
||||
shell_popup_grab_from_seat(surface->shell,
|
||||
|
|
@ -580,12 +579,7 @@ static void shell_bind(struct wl_client *wl_client, void *_wl_shell,
|
|||
uint32_t version, uint32_t id) {
|
||||
struct wlr_wl_shell *wl_shell = _wl_shell;
|
||||
assert(wl_client && wl_shell);
|
||||
if (version > 1) {
|
||||
wlr_log(L_ERROR,
|
||||
"Client requested unsupported wl_shell version, disconnecting");
|
||||
wl_client_destroy(wl_client);
|
||||
return;
|
||||
}
|
||||
|
||||
struct wl_resource *wl_resource = wl_resource_create(wl_client,
|
||||
&wl_shell_interface, version, id);
|
||||
wl_resource_set_implementation(wl_resource, &shell_impl, wl_shell,
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
#include <wlr/types/wlr_surface.h>
|
||||
#include <wlr/types/wlr_seat.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include <wlr/render/interface.h>
|
||||
#include "xdg-shell-unstable-v6-protocol.h"
|
||||
|
||||
static const char *wlr_desktop_xdg_toplevel_role = "xdg_toplevel";
|
||||
|
|
@ -1018,7 +1017,8 @@ static void wlr_xdg_surface_v6_toplevel_committed(
|
|||
struct wlr_xdg_surface_v6 *surface) {
|
||||
assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL);
|
||||
|
||||
if (!surface->surface->texture->valid && !surface->toplevel_state->added) {
|
||||
if (!wlr_surface_has_buffer(surface->surface)
|
||||
&& !surface->toplevel_state->added) {
|
||||
// on the first commit, send a configure request to tell the client it
|
||||
// is added
|
||||
wlr_xdg_surface_v6_schedule_configure(surface);
|
||||
|
|
@ -1026,7 +1026,7 @@ static void wlr_xdg_surface_v6_toplevel_committed(
|
|||
return;
|
||||
}
|
||||
|
||||
if (!surface->surface->texture->valid) {
|
||||
if (!wlr_surface_has_buffer(surface->surface)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1048,7 +1048,7 @@ static void handle_wlr_surface_committed(struct wl_listener *listener,
|
|||
struct wlr_xdg_surface_v6 *surface =
|
||||
wl_container_of(listener, surface, surface_commit_listener);
|
||||
|
||||
if (surface->surface->texture->valid && !surface->configured) {
|
||||
if (wlr_surface_has_buffer(surface->surface) && !surface->configured) {
|
||||
wl_resource_post_error(surface->resource,
|
||||
ZXDG_SURFACE_V6_ERROR_UNCONFIGURED_BUFFER,
|
||||
"xdg_surface has never been configured");
|
||||
|
|
@ -1117,7 +1117,7 @@ static void xdg_shell_get_xdg_surface(struct wl_client *wl_client,
|
|||
&zxdg_surface_v6_interface, wl_resource_get_version(client_resource),
|
||||
id);
|
||||
|
||||
if (surface->surface->texture->valid) {
|
||||
if (wlr_surface_has_buffer(surface->surface)) {
|
||||
wl_resource_post_error(surface->resource,
|
||||
ZXDG_SURFACE_V6_ERROR_UNCONFIGURED_BUFFER,
|
||||
"xdg_surface must not have a buffer at creation");
|
||||
|
|
@ -1201,12 +1201,7 @@ static void xdg_shell_bind(struct wl_client *wl_client, void *_xdg_shell,
|
|||
uint32_t version, uint32_t id) {
|
||||
struct wlr_xdg_shell_v6 *xdg_shell = _xdg_shell;
|
||||
assert(wl_client && xdg_shell);
|
||||
if (version > 1) {
|
||||
wlr_log(L_ERROR,
|
||||
"Client requested unsupported xdg_shell_v6 version, disconnecting");
|
||||
wl_client_destroy(wl_client);
|
||||
return;
|
||||
}
|
||||
|
||||
struct wlr_xdg_client_v6 *client =
|
||||
calloc(1, sizeof(struct wlr_xdg_client_v6));
|
||||
if (client == NULL) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue