Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

Commit

Permalink
surface: make wlr_subsurface_create private
Browse files Browse the repository at this point in the history
Same as [1], but for wlr_subsurface.

[1]: #2814
  • Loading branch information
emersion committed Jun 29, 2021
1 parent ddc98bf commit 39e253e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 26 deletions.
6 changes: 6 additions & 0 deletions include/types/wlr_surface.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,10 @@ struct wlr_renderer;
struct wlr_surface *surface_create(struct wl_client *client,
uint32_t version, uint32_t id, struct wlr_renderer *renderer);

/**
* Create a new subsurface resource with the provided new ID.
*/
struct wlr_subsurface *subsurface_create(struct wlr_surface *surface,
struct wlr_surface *parent, uint32_t version, uint32_t id);

#endif
8 changes: 0 additions & 8 deletions include/wlr/types/wlr_surface.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,6 @@ bool wlr_surface_has_buffer(struct wlr_surface *surface);
*/
struct wlr_texture *wlr_surface_get_texture(struct wlr_surface *surface);

/**
* Create a new subsurface resource with the provided new ID. If `resource_list`
* is non-NULL, adds the subsurface's resource to the list.
*/
struct wlr_subsurface *wlr_subsurface_create(struct wlr_surface *surface,
struct wlr_surface *parent, uint32_t version, uint32_t id,
struct wl_list *resource_list);

/**
* Get the root of the subsurface tree for this surface. Can return NULL if
* a surface in the tree has been destroyed.
Expand Down
3 changes: 1 addition & 2 deletions types/wlr_compositor.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ static void subcompositor_handle_get_subsurface(struct wl_client *client,
return;
}

wlr_subsurface_create(surface, parent, wl_resource_get_version(resource),
id, NULL);
subsurface_create(surface, parent, wl_resource_get_version(resource), id);
}

static const struct wl_subcompositor_interface subcompositor_impl = {
Expand Down
19 changes: 3 additions & 16 deletions types/wlr_surface.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include "util/time.h"

#define CALLBACK_VERSION 1
#define SUBSURFACE_VERSION 1

static int min(int fst, int snd) {
if (fst < snd) {
Expand Down Expand Up @@ -860,7 +859,6 @@ static struct wlr_subsurface *subsurface_from_resource(

static void subsurface_resource_destroy(struct wl_resource *resource) {
struct wlr_subsurface *subsurface = subsurface_from_resource(resource);
wl_list_remove(wl_resource_get_link(resource));
subsurface_destroy(subsurface);
}

Expand Down Expand Up @@ -1133,11 +1131,8 @@ static void subsurface_handle_surface_destroy(struct wl_listener *listener,
subsurface_destroy(subsurface);
}

struct wlr_subsurface *wlr_subsurface_create(struct wlr_surface *surface,
struct wlr_surface *parent, uint32_t version, uint32_t id,
struct wl_list *resource_list) {
assert(version <= SUBSURFACE_VERSION);

struct wlr_subsurface *subsurface_create(struct wlr_surface *surface,
struct wlr_surface *parent, uint32_t version, uint32_t id) {
struct wl_client *client = wl_resource_get_client(surface->resource);

struct wlr_subsurface *subsurface =
Expand All @@ -1156,8 +1151,7 @@ struct wlr_subsurface *wlr_subsurface_create(struct wlr_surface *surface,
return NULL;
}
wl_resource_set_implementation(subsurface->resource,
&subsurface_implementation, subsurface,
subsurface_resource_destroy);
&subsurface_implementation, subsurface, subsurface_resource_destroy);

wl_signal_init(&subsurface->events.destroy);
wl_signal_init(&subsurface->events.map);
Expand All @@ -1176,13 +1170,6 @@ struct wlr_subsurface *wlr_subsurface_create(struct wlr_surface *surface,

surface->role_data = subsurface;

struct wl_list *resource_link = wl_resource_get_link(subsurface->resource);
if (resource_list != NULL) {
wl_list_insert(resource_list, resource_link);
} else {
wl_list_init(resource_link);
}

wlr_signal_emit_safe(&parent->events.new_subsurface, subsurface);

return subsurface;
Expand Down

0 comments on commit 39e253e

Please sign in to comment.