aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/drm/drm.c11
-rw-r--r--backend/libinput/backend.c6
-rw-r--r--backend/libinput/events.c4
-rw-r--r--examples/pointer.c6
-rw-r--r--examples/screenshot.c4
-rw-r--r--examples/shared.c4
-rw-r--r--examples/touch.c6
-rw-r--r--include/wlr/interfaces/wlr_output.h9
-rw-r--r--include/wlr/types/wlr_gamma_control.h16
-rw-r--r--include/wlr/types/wlr_list.h24
-rw-r--r--include/wlr/types/wlr_output.h4
-rw-r--r--include/wlr/types/wlr_surface.h8
-rw-r--r--rootston/cursor.c4
-rw-r--r--rootston/desktop.c4
-rw-r--r--rootston/wl_shell.c4
-rw-r--r--rootston/xdg_shell_v6.c2
-rw-r--r--rootston/xwayland.c2
-rw-r--r--types/wlr_compositor.c7
-rw-r--r--types/wlr_data_device_manager.c7
-rw-r--r--types/wlr_data_source.c8
-rw-r--r--types/wlr_gamma_control.c123
-rw-r--r--types/wlr_list.c30
-rw-r--r--types/wlr_output.c41
-rw-r--r--types/wlr_screenshooter.c7
-rw-r--r--types/wlr_seat.c7
-rw-r--r--types/wlr_surface.c7
-rw-r--r--types/wlr_wl_shell.c12
-rw-r--r--types/wlr_xdg_shell_v6.c17
-rw-r--r--xwayland/xwm.c8
29 files changed, 225 insertions, 167 deletions
diff --git a/backend/drm/drm.c b/backend/drm/drm.c
index 94923d04..441ba24e 100644
--- a/backend/drm/drm.c
+++ b/backend/drm/drm.c
@@ -211,13 +211,13 @@ static void wlr_drm_connector_swap_buffers(struct wlr_output *output) {
}
static void wlr_drm_connector_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) {
struct wlr_drm_connector *conn = (struct wlr_drm_connector *)output;
struct wlr_drm_backend *drm = (struct wlr_drm_backend *)output->backend;
drmModeCrtcSetGamma(drm->fd, conn->crtc->id, size, r, g, b);
}
-static uint16_t wlr_drm_connector_get_gamma_size(struct wlr_output *output) {
+static uint32_t wlr_drm_connector_get_gamma_size(struct wlr_output *output) {
struct wlr_drm_connector *conn = (struct wlr_drm_connector *)output;
drmModeCrtc *crtc = conn->old_crtc;
return crtc ? crtc->gamma_size : 0;
@@ -770,7 +770,6 @@ void wlr_drm_scan_connectors(struct wlr_drm_backend *drm) {
free(edid);
wl_list_insert(&drm->outputs, &wlr_conn->link);
- wlr_output_create_global(&wlr_conn->output, drm->display);
wlr_log(L_INFO, "Found display '%s'", wlr_conn->output.name);
} else {
seen[index] = true;
@@ -789,7 +788,6 @@ void wlr_drm_scan_connectors(struct wlr_drm_backend *drm) {
if (wlr_conn->state == WLR_DRM_CONN_DISCONNECTED &&
drm_conn->connection == DRM_MODE_CONNECTED) {
-
wlr_log(L_INFO, "'%s' connected", wlr_conn->output.name);
wlr_log(L_INFO, "Detected modes:");
@@ -811,14 +809,17 @@ void wlr_drm_scan_connectors(struct wlr_drm_backend *drm) {
wl_list_insert(&wlr_conn->output.modes, &mode->wlr_mode.link);
}
+ wlr_output_create_global(&wlr_conn->output, drm->display);
+
wlr_conn->state = WLR_DRM_CONN_NEEDS_MODESET;
wlr_log(L_INFO, "Sending modesetting signal for '%s'",
wlr_conn->output.name);
wl_signal_emit(&drm->backend.events.output_add, &wlr_conn->output);
} else if (wlr_conn->state == WLR_DRM_CONN_CONNECTED &&
drm_conn->connection != DRM_MODE_CONNECTED) {
-
wlr_log(L_INFO, "'%s' disconnected", wlr_conn->output.name);
+
+ wlr_output_destroy_global(&wlr_conn->output);
wlr_drm_connector_cleanup(wlr_conn);
}
diff --git a/backend/libinput/backend.c b/backend/libinput/backend.c
index b278b8f7..781314a3 100644
--- a/backend/libinput/backend.c
+++ b/backend/libinput/backend.c
@@ -105,9 +105,9 @@ static void wlr_libinput_backend_destroy(struct wlr_backend *_backend) {
wl_signal_emit(&backend->backend.events.input_remove, wlr_dev);
wlr_input_device_destroy(wlr_dev);
}
- list_free(wlr_devices);
+ wlr_list_free(wlr_devices);
}
- list_free(backend->wlr_device_lists);
+ wlr_list_free(backend->wlr_device_lists);
wl_event_source_remove(backend->input_event);
libinput_unref(backend->libinput_context);
free(backend);
@@ -148,7 +148,7 @@ struct wlr_backend *wlr_libinput_backend_create(struct wl_display *display,
}
wlr_backend_init(&backend->backend, &backend_impl);
- if (!(backend->wlr_device_lists = list_create())) {
+ if (!(backend->wlr_device_lists = wlr_list_create())) {
wlr_log(L_ERROR, "Allocation failed: %s", strerror(errno));
goto error_backend;
}
diff --git a/backend/libinput/events.c b/backend/libinput/events.c
index f6634814..053cab02 100644
--- a/backend/libinput/events.c
+++ b/backend/libinput/events.c
@@ -145,7 +145,7 @@ static void handle_device_added(struct wlr_libinput_backend *backend,
if (wl_list_length(wlr_devices) > 0) {
libinput_device_set_user_data(libinput_dev, wlr_devices);
- list_add(backend->wlr_device_lists, wlr_devices);
+ wlr_list_add(backend->wlr_device_lists, wlr_devices);
} else {
free(wlr_devices);
}
@@ -177,7 +177,7 @@ static void handle_device_removed(struct wlr_libinput_backend *backend,
}
for (size_t i = 0; i < backend->wlr_device_lists->length; i++) {
if (backend->wlr_device_lists->items[i] == wlr_devices) {
- list_del(backend->wlr_device_lists, i);
+ wlr_list_del(backend->wlr_device_lists, i);
break;
}
}
diff --git a/examples/pointer.c b/examples/pointer.c
index 8c3c8b85..66598ad4 100644
--- a/examples/pointer.c
+++ b/examples/pointer.c
@@ -213,7 +213,7 @@ static void handle_touch_up(struct wl_listener *listener, void *data) {
for (size_t i = 0; i < sample->touch_points->length; ++i) {
struct touch_point *point = sample->touch_points->items[i];
if (point->slot == event->slot) {
- list_del(sample->touch_points, i);
+ wlr_list_del(sample->touch_points, i);
break;
}
}
@@ -228,7 +228,7 @@ static void handle_touch_down(struct wl_listener *listener, void *data) {
point->slot = event->slot;
point->x = event->x_mm / event->width_mm;
point->y = event->y_mm / event->height_mm;
- if (list_add(sample->touch_points, point) == -1) {
+ if (wlr_list_add(sample->touch_points, point) == -1) {
free(point);
}
@@ -270,7 +270,7 @@ int main(int argc, char *argv[]) {
struct sample_state state = {
.default_color = { 0.25f, 0.25f, 0.25f, 1 },
.clear_color = { 0.25f, 0.25f, 0.25f, 1 },
- .touch_points = list_create(),
+ .touch_points = wlr_list_create(),
};
state.config = parse_args(argc, argv);
diff --git a/examples/screenshot.c b/examples/screenshot.c
index 95af49ca..2a3b74aa 100644
--- a/examples/screenshot.c
+++ b/examples/screenshot.c
@@ -267,10 +267,6 @@ int main(int argc, char *argv[]) {
struct screenshooter_output *output;
wl_list_for_each(output, &output_list, link) {
- if (output->width == 0 || output->height == 0) {
- continue;
- }
-
output->buffer = create_shm_buffer(output->width, output->height, &output->data);
if (output->buffer == NULL) {
return -1;
diff --git a/examples/shared.c b/examples/shared.c
index 4cde15d1..1a1f4be4 100644
--- a/examples/shared.c
+++ b/examples/shared.c
@@ -414,8 +414,8 @@ static void output_add_notify(struct wl_listener *listener, void *data) {
wlr_log(L_DEBUG, "%s %s %"PRId32"mm x %"PRId32"mm", output->make, output->model,
output->phys_width, output->phys_height);
if (wl_list_length(&output->modes) > 0) {
- struct wlr_output_mode *mode = NULL;
- wl_container_of((&output->modes)->prev, mode, link);
+ struct wlr_output_mode *mode;
+ mode = wl_container_of((&output->modes)->prev, mode, link);
wlr_output_set_mode(output, mode);
}
struct output_state *ostate = calloc(1, sizeof(struct output_state));
diff --git a/examples/touch.c b/examples/touch.c
index 60fb0ae4..3f0c4867 100644
--- a/examples/touch.c
+++ b/examples/touch.c
@@ -65,7 +65,7 @@ static void handle_touch_down(struct touch_state *tstate, int32_t slot,
point->slot = slot;
point->x = x / width;
point->y = y / height;
- if (list_add(sample->touch_points, point) == -1) {
+ if (wlr_list_add(sample->touch_points, point) == -1) {
free(point);
}
}
@@ -75,7 +75,7 @@ static void handle_touch_up(struct touch_state *tstate, int32_t slot) {
for (size_t i = 0; i < sample->touch_points->length; ++i) {
struct touch_point *point = sample->touch_points->items[i];
if (point->slot == slot) {
- list_del(sample->touch_points, i);
+ wlr_list_del(sample->touch_points, i);
break;
}
}
@@ -96,7 +96,7 @@ static void handle_touch_motion(struct touch_state *tstate, int32_t slot,
int main(int argc, char *argv[]) {
struct sample_state state = {
- .touch_points = list_create()
+ .touch_points = wlr_list_create()
};
struct compositor_state compositor = { 0,
.data = &state,
diff --git a/include/wlr/interfaces/wlr_output.h b/include/wlr/interfaces/wlr_output.h
index 17dd5538..636cc06c 100644
--- a/include/wlr/interfaces/wlr_output.h
+++ b/include/wlr/interfaces/wlr_output.h
@@ -18,15 +18,16 @@ struct wlr_output_impl {
void (*make_current)(struct wlr_output *output);
void (*swap_buffers)(struct wlr_output *output);
void (*set_gamma)(struct wlr_output *output,
- uint16_t size, uint16_t *r, uint16_t *g, uint16_t *b);
- uint16_t (*get_gamma_size)(struct wlr_output *output);
+ uint32_t size, uint16_t *r, uint16_t *g, uint16_t *b);
+ uint32_t (*get_gamma_size)(struct wlr_output *output);
};
void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend,
const struct wlr_output_impl *impl);
void wlr_output_free(struct wlr_output *output);
void wlr_output_update_matrix(struct wlr_output *output);
-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);
+void wlr_output_destroy_global(struct wlr_output *wlr_output);
#endif
diff --git a/include/wlr/types/wlr_gamma_control.h b/include/wlr/types/wlr_gamma_control.h
index 96c9f545..59f18494 100644
--- a/include/wlr/types/wlr_gamma_control.h
+++ b/include/wlr/types/wlr_gamma_control.h
@@ -5,18 +5,28 @@
struct wlr_gamma_control_manager {
struct wl_global *wl_global;
+ struct wl_list controls; // list of wlr_gamma_control
void *data;
};
struct wlr_gamma_control {
struct wl_resource *resource;
- struct wl_resource *output;
+ struct wlr_output *output;
+ struct wl_list link;
+
+ struct wl_listener output_destroy_listener;
+
+ struct {
+ struct wl_signal destroy;
+ } events;
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);
+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
diff --git a/include/wlr/types/wlr_list.h b/include/wlr/types/wlr_list.h
index 6a4fe863..8ddd30b6 100644
--- a/include/wlr/types/wlr_list.h
+++ b/include/wlr/types/wlr_list.h
@@ -12,48 +12,48 @@ struct wlr_list {
/**
* Creates a new list, may return `NULL` on failure
*/
-struct wlr_list *list_create(void);
-void list_free(struct wlr_list *list);
-void list_foreach(struct wlr_list *list, void (*callback)(void *item));
+struct wlr_list *wlr_list_create(void);
+void wlr_list_free(struct wlr_list *list);
+void wlr_list_foreach(struct wlr_list *list, void (*callback)(void *item));
/**
* Add `item` to the end of a list.
* Returns: new list length or `-1` on failure
*/
-int list_add(struct wlr_list *list, void *item);
+int wlr_list_add(struct wlr_list *list, void *item);
/**
* Add `item` to the end of a list.
* Returns: new list length or `-1` on failure
*/
-int list_push(struct wlr_list *list, void *item);
+int wlr_list_push(struct wlr_list *list, void *item);
/**
* Place `item` into index `index` in the list
* Returns: new list length or `-1` on failure
*/
-int list_insert(struct wlr_list *list, size_t index, void *item);
+int wlr_list_insert(struct wlr_list *list, size_t index, void *item);
/**
* Remove an item from the list
*/
-void list_del(struct wlr_list *list, size_t index);
+void wlr_list_del(struct wlr_list *list, size_t index);
/**
* Remove and return an item from the end of the list
*/
-void *list_pop(struct wlr_list *list);
+void *wlr_list_pop(struct wlr_list *list);
/**
* Get a reference to the last item of a list without removal
*/
-void *list_peek(struct wlr_list *list);
+void *wlr_list_peek(struct wlr_list *list);
/**
* Append each item in `source` to `list`
* Does not modify `source`
* Returns: new list length or `-1` on failure
*/
-int list_cat(struct wlr_list *list, struct wlr_list *source);
+int wlr_list_cat(struct wlr_list *list, struct wlr_list *source);
// See qsort. Remember to use *_qsort functions as compare functions,
// because they dereference the left and right arguments first!
-void list_qsort(struct wlr_list *list, int compare(const void *left, const void *right));
+void wlr_list_qsort(struct wlr_list *list, int compare(const void *left, const void *right));
// Return index for first item in list that returns 0 for given compare
// function or -1 if none matches.
-int list_seq_find(struct wlr_list *list,
+int wlr_list_seq_find(struct wlr_list *list,
int compare(const void *item, const void *cmp_to),
const void *cmp_to);
diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h
index d8649bbb..74eb15ed 100644
--- a/include/wlr/types/wlr_output.h
+++ b/include/wlr/types/wlr_output.h
@@ -84,7 +84,7 @@ void wlr_output_effective_resolution(struct wlr_output *output,
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);
+ uint32_t size, uint16_t *r, uint16_t *g, uint16_t *b);
+uint32_t wlr_output_get_gamma_size(struct wlr_output *output);
#endif
diff --git a/include/wlr/types/wlr_surface.h b/include/wlr/types/wlr_surface.h
index 461e593f..ea4184aa 100644
--- a/include/wlr/types/wlr_surface.h
+++ b/include/wlr/types/wlr_surface.h
@@ -110,6 +110,14 @@ int wlr_surface_set_role(struct wlr_surface *surface, const char *role,
struct wl_resource *error_resource, uint32_t error_code);
/**
+ * Whether or not this surface currently has an attached buffer. A surface has
+ * an attached buffer when it commits with a non-null buffer in its pending
+ * state. A surface will not have a buffer if it has never committed one, has
+ * committed a null buffer, or something went wrong with uploading the buffer.
+ */
+bool wlr_surface_has_buffer(struct wlr_surface *surface);
+
+/**
* Create the subsurface implementation for this surface.
*/
void wlr_surface_make_subsurface(struct wlr_surface *surface,
diff --git a/rootston/cursor.c b/rootston/cursor.c
index 3be4c2a6..2a3a7c25 100644
--- a/rootston/cursor.c
+++ b/rootston/cursor.c
@@ -183,8 +183,8 @@ void set_view_focus(struct roots_input *input, struct roots_desktop *desktop,
}
view_activate(view, true);
// TODO: list_swap
- list_del(desktop->views, index);
- list_add(desktop->views, view);
+ wlr_list_del(desktop->views, index);
+ wlr_list_add(desktop->views, view);
}
static void handle_cursor_motion(struct wl_listener *listener, void *data) {
diff --git a/rootston/desktop.c b/rootston/desktop.c
index 70767f92..40d088b8 100644
--- a/rootston/desktop.c
+++ b/rootston/desktop.c
@@ -29,7 +29,7 @@ void view_destroy(struct roots_view *view) {
for (size_t i = 0; i < desktop->views->length; ++i) {
struct roots_view *_view = desktop->views->items[i];
if (view == _view) {
- list_del(desktop->views, i);
+ wlr_list_del(desktop->views, i);
break;
}
}
@@ -209,7 +209,7 @@ struct roots_desktop *desktop_create(struct roots_server *server,
return NULL;
}
- desktop->views = list_create();
+ desktop->views = wlr_list_create();
if (desktop->views == NULL) {
free(desktop);
return NULL;
diff --git a/rootston/wl_shell.c b/rootston/wl_shell.c
index 248514f0..88397af8 100644
--- a/rootston/wl_shell.c
+++ b/rootston/wl_shell.c
@@ -110,12 +110,12 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
view->close = close;
view->desktop = desktop;
roots_surface->view = view;
- list_add(desktop->views, view);
+ wlr_list_add(desktop->views, view);
view_initialize(view);
if (surface->state == WLR_WL_SHELL_SURFACE_STATE_TRANSIENT) {
// we need to map it relative to the parent
- int i = list_seq_find(desktop->views, shell_surface_compare_equals,
+ int i = wlr_list_seq_find(desktop->views, shell_surface_compare_equals,
surface->parent);
if (i != -1) {
struct roots_view *parent = desktop->views->items[i];
diff --git a/rootston/xdg_shell_v6.c b/rootston/xdg_shell_v6.c
index 028545df..95b20a8b 100644
--- a/rootston/xdg_shell_v6.c
+++ b/rootston/xdg_shell_v6.c
@@ -124,7 +124,7 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
view->close = close;
view->desktop = desktop;
roots_surface->view = view;
- list_add(desktop->views, view);
+ wlr_list_add(desktop->views, view);
view_initialize(view);
}
diff --git a/rootston/xwayland.c b/rootston/xwayland.c
index 6ef33403..1149b966 100644
--- a/rootston/xwayland.c
+++ b/rootston/xwayland.c
@@ -98,7 +98,7 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
view->set_position = set_position;
view->close = close;
roots_surface->view = view;
- list_add(desktop->views, view);
+ wlr_list_add(desktop->views, view);
if (!surface->override_redirect) {
view_initialize(view);
diff --git a/types/wlr_compositor.c b/types/wlr_compositor.c
index 12903cda..cbb7f138 100644
--- a/types/wlr_compositor.c
+++ b/types/wlr_compositor.c
@@ -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,
diff --git a/types/wlr_data_device_manager.c b/types/wlr_data_device_manager.c
index a813754c..a390e5a2 100644
--- a/types/wlr_data_device_manager.c
+++ b/types/wlr_data_device_manager.c
@@ -133,12 +133,7 @@ static void data_device_manager_bind(struct wl_client *client, void *data,
uint32_t version, uint32_t id) {
struct wlr_data_device_manager *manager = data;
assert(client && manager);
- if (version > 3) {
- wlr_log(L_ERROR, "Client requested unsupported data_device_manager "
- "version, disconnecting");
- wl_client_destroy(client);
- return;
- }
+
struct wl_resource *resource = wl_resource_create(
client, &wl_data_device_manager_interface, version, id);
if (!resource) {
diff --git a/types/wlr_data_source.c b/types/wlr_data_source.c
index 2c227778..98de4f97 100644
--- a/types/wlr_data_source.c
+++ b/types/wlr_data_source.c
@@ -14,16 +14,16 @@ bool wlr_data_source_init(struct wlr_data_source *source,
struct wlr_data_source_impl *impl) {
source->impl = impl;
wl_signal_init(&source->events.destroy);
- return (source->types = list_create());
+ return (source->types = wlr_list_create());
}
void wlr_data_source_finish(struct wlr_data_source *source) {
if (source) {
wl_signal_emit(&source->events.destroy, source);
if (source->types) {
- list_foreach(source->types, free);
+ wlr_list_foreach(source->types, free);
}
- list_free(source->types);
+ wlr_list_free(source->types);
}
}
@@ -81,7 +81,7 @@ static void data_source_offer(struct wl_client *client,
return;
}
- list_add(src->base.types, dtype);
+ wlr_list_add(src->base.types, dtype);
}
static void data_source_destroy(struct wl_client *client,
diff --git a/types/wlr_gamma_control.c b/types/wlr_gamma_control.c
index c654cc21..9d74e749 100644
--- a/types/wlr_gamma_control.c
+++ b/types/wlr_gamma_control.c
@@ -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);
diff --git a/types/wlr_list.c b/types/wlr_list.c
index 365ad236..33e3ea8a 100644
--- a/types/wlr_list.c
+++ b/types/wlr_list.c
@@ -5,7 +5,7 @@
#include <stddef.h>
#include <wlr/types/wlr_list.h>
-struct wlr_list *list_create(void) {
+struct wlr_list *wlr_list_create(void) {
struct wlr_list *list = malloc(sizeof(struct wlr_list));
if (!list) {
return NULL;
@@ -32,7 +32,7 @@ static bool list_resize(struct wlr_list *list) {
return true;
}
-void list_free(struct wlr_list *list) {
+void wlr_list_free(struct wlr_list *list) {
if (list == NULL) {
return;
}
@@ -40,7 +40,7 @@ void list_free(struct wlr_list *list) {
free(list);
}
-void list_foreach(struct wlr_list *list, void (*callback)(void *item)) {
+void wlr_list_foreach(struct wlr_list *list, void (*callback)(void *item)) {
if (list == NULL || callback == NULL) {
return;
}
@@ -49,7 +49,7 @@ void list_foreach(struct wlr_list *list, void (*callback)(void *item)) {
}
}
-int list_add(struct wlr_list *list, void *item) {
+int wlr_list_add(struct wlr_list *list, void *item) {
if (!list_resize(list)) {
return -1;
}
@@ -57,11 +57,11 @@ int list_add(struct wlr_list *list, void *item) {
return list->length;
}
-int list_push(struct wlr_list *list, void *item) {
- return list_add(list, item);
+int wlr_list_push(struct wlr_list *list, void *item) {
+ return wlr_list_add(list, item);
}
-int list_insert(struct wlr_list *list, size_t index, void *item) {
+int wlr_list_insert(struct wlr_list *list, size_t index, void *item) {
if (!list_resize(list)) {
return -1;
}
@@ -71,26 +71,26 @@ int list_insert(struct wlr_list *list, size_t index, void *item) {
return list->length;
}
-void list_del(struct wlr_list *list, size_t index) {
+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 *list_pop(struct wlr_list *list) {
+void *wlr_list_pop(struct wlr_list *list) {
void *_ = list->items[list->length - 1];
- list_del(list, list->length - 1);
+ wlr_list_del(list, list->length - 1);
return _;
}
-void *list_peek(struct wlr_list *list) {
+void *wlr_list_peek(struct wlr_list *list) {
return list->items[list->length - 1];
}
-int list_cat(struct wlr_list *list, struct wlr_list *source) {
+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 (list_add(list, source->items[i]) == -1) {
+ if (wlr_list_add(list, source->items[i]) == -1) {
list->length = old_len;
return -1;
}
@@ -98,11 +98,11 @@ int list_cat(struct wlr_list *list, struct wlr_list *source) {
return list->length;
}
-void list_qsort(struct wlr_list *list, int compare(const void *left, const void *right)) {
+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 list_seq_find(struct wlr_list *list,
+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++) {
diff --git a/types/wlr_output.c b/types/wlr_output.c
index 33324d5c..a02798b2 100644
--- a/types/wlr_output.c
+++ b/types/wlr_output.c
@@ -75,21 +75,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,6 +97,19 @@ struct wl_global *wlr_output_create_global(
return wl_global;
}
+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;
+}
+
void wlr_output_update_matrix(struct wlr_output *output) {
wlr_matrix_texture(output->transform_matrix, output->width, output->height, output->transform);
}
@@ -391,13 +404,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;
}
diff --git a/types/wlr_screenshooter.c b/types/wlr_screenshooter.c
index 38204aa1..c6def691 100644
--- a/types/wlr_screenshooter.c
+++ b/types/wlr_screenshooter.c
@@ -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,
diff --git a/types/wlr_seat.c b/types/wlr_seat.c
index 362c696a..e0fb3e8d 100644
--- a/types/wlr_seat.c
+++ b/types/wlr_seat.c
@@ -175,12 +175,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);
diff --git a/types/wlr_surface.c b/types/wlr_surface.c
index 68c21468..f8689d8e 100644
--- a/types/wlr_surface.c
+++ b/types/wlr_surface.c
@@ -406,7 +406,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 ||
@@ -655,6 +656,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);
diff --git a/types/wlr_wl_shell.c b/types/wlr_wl_shell.c
index 022f865a..73985414 100644
--- a/types/wlr_wl_shell.c
+++ b/types/wlr_wl_shell.c
@@ -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,
diff --git a/types/wlr_xdg_shell_v6.c b/types/wlr_xdg_shell_v6.c
index efa6bb3a..40fe252c4 100644
--- a/types/wlr_xdg_shell_v6.c
+++ b/types/wlr_xdg_shell_v6.c
@@ -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) {
diff --git a/xwayland/xwm.c b/xwayland/xwm.c
index bc1bb4de..f58acb73 100644
--- a/xwayland/xwm.c
+++ b/xwayland/xwm.c
@@ -71,7 +71,7 @@ static struct wlr_xwayland_surface *wlr_xwayland_surface_create(
surface->height = height;
surface->override_redirect = override_redirect;
wl_list_insert(&xwm->new_surfaces, &surface->link);
- surface->state = list_create();
+ surface->state = wlr_list_create();
wl_signal_init(&surface->events.destroy);
wl_signal_init(&surface->events.request_configure);
wl_signal_init(&surface->events.set_class);
@@ -92,7 +92,7 @@ static void wlr_xwayland_surface_destroy(struct wlr_xwayland_surface *surface) {
free(surface->title);
free(surface->class);
free(surface->instance);
- list_free(surface->state);
+ wlr_list_free(surface->state);
free(surface->window_type);
free(surface->protocols);
free(surface->hints);
@@ -199,7 +199,7 @@ static void handle_surface_state(struct wlr_xwm *xwm,
if (action == NET_WM_STATE_REMOVE ||
action == NET_WM_STATE_TOGGLE) {
free(surface->state->items[j]);
- list_del(surface->state, j);
+ wlr_list_del(surface->state, j);
}
break;
}
@@ -209,7 +209,7 @@ static void handle_surface_state(struct wlr_xwm *xwm,
action == NET_WM_STATE_TOGGLE)) {
xcb_atom_t *atom_ptr = malloc(sizeof(xcb_atom_t));
*atom_ptr = atom;
- list_add(surface->state, atom_ptr);
+ wlr_list_add(surface->state, atom_ptr);
}
}