mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2024-11-22 07:02:28 +00:00
layer-shell-v1: convert to try_from
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/884
This commit is contained in:
parent
49cb85ad72
commit
f9bd416d41
@ -139,18 +139,13 @@ uint32_t wlr_layer_surface_v1_configure(struct wlr_layer_surface_v1 *surface,
|
|||||||
*/
|
*/
|
||||||
void wlr_layer_surface_v1_destroy(struct wlr_layer_surface_v1 *surface);
|
void wlr_layer_surface_v1_destroy(struct wlr_layer_surface_v1 *surface);
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if the surface has the layer surface role.
|
|
||||||
*/
|
|
||||||
bool wlr_surface_is_layer_surface(struct wlr_surface *surface);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a struct wlr_layer_surface from a struct wlr_surface.
|
* Get a struct wlr_layer_surface from a struct wlr_surface.
|
||||||
* Asserts that the surface has the layer surface role.
|
*
|
||||||
* May return NULL even if the surface has the layer surface role if the
|
* Returns NULL if the surface doesn't have the layer surface role or if
|
||||||
* corresponding layer surface has been destroyed.
|
* the layer surface has been destroyed.
|
||||||
*/
|
*/
|
||||||
struct wlr_layer_surface_v1 *wlr_layer_surface_v1_from_wlr_surface(
|
struct wlr_layer_surface_v1 *wlr_layer_surface_v1_try_from_wlr_surface(
|
||||||
struct wlr_surface *surface);
|
struct wlr_surface *surface);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,13 +38,11 @@ struct wlr_layer_surface_v1 *wlr_layer_surface_v1_from_resource(
|
|||||||
|
|
||||||
static const struct wlr_surface_role layer_surface_role;
|
static const struct wlr_surface_role layer_surface_role;
|
||||||
|
|
||||||
bool wlr_surface_is_layer_surface(struct wlr_surface *surface) {
|
struct wlr_layer_surface_v1 *wlr_layer_surface_v1_try_from_wlr_surface(
|
||||||
return surface->role == &layer_surface_role;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct wlr_layer_surface_v1 *wlr_layer_surface_v1_from_wlr_surface(
|
|
||||||
struct wlr_surface *surface) {
|
struct wlr_surface *surface) {
|
||||||
assert(wlr_surface_is_layer_surface(surface));
|
if (surface->role != &layer_surface_role) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
return (struct wlr_layer_surface_v1 *)surface->role_data;
|
return (struct wlr_layer_surface_v1 *)surface->role_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,7 +312,8 @@ void wlr_layer_surface_v1_destroy(struct wlr_layer_surface_v1 *surface) {
|
|||||||
|
|
||||||
static void layer_surface_role_commit(struct wlr_surface *wlr_surface) {
|
static void layer_surface_role_commit(struct wlr_surface *wlr_surface) {
|
||||||
struct wlr_layer_surface_v1 *surface =
|
struct wlr_layer_surface_v1 *surface =
|
||||||
wlr_layer_surface_v1_from_wlr_surface(wlr_surface);
|
wlr_layer_surface_v1_try_from_wlr_surface(wlr_surface);
|
||||||
|
assert(surface != NULL);
|
||||||
|
|
||||||
const uint32_t horiz = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT |
|
const uint32_t horiz = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT |
|
||||||
ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT;
|
ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT;
|
||||||
@ -366,7 +365,8 @@ static void layer_surface_role_commit(struct wlr_surface *wlr_surface) {
|
|||||||
static void layer_surface_role_precommit(struct wlr_surface *wlr_surface,
|
static void layer_surface_role_precommit(struct wlr_surface *wlr_surface,
|
||||||
const struct wlr_surface_state *state) {
|
const struct wlr_surface_state *state) {
|
||||||
struct wlr_layer_surface_v1 *surface =
|
struct wlr_layer_surface_v1 *surface =
|
||||||
wlr_layer_surface_v1_from_wlr_surface(wlr_surface);
|
wlr_layer_surface_v1_try_from_wlr_surface(wlr_surface);
|
||||||
|
assert(surface != NULL);
|
||||||
|
|
||||||
if (state->committed & WLR_SURFACE_STATE_BUFFER && state->buffer == NULL) {
|
if (state->committed & WLR_SURFACE_STATE_BUFFER && state->buffer == NULL) {
|
||||||
// This is a NULL commit
|
// This is a NULL commit
|
||||||
@ -378,7 +378,8 @@ static void layer_surface_role_precommit(struct wlr_surface *wlr_surface,
|
|||||||
|
|
||||||
static void layer_surface_role_destroy(struct wlr_surface *wlr_surface) {
|
static void layer_surface_role_destroy(struct wlr_surface *wlr_surface) {
|
||||||
struct wlr_layer_surface_v1 *surface =
|
struct wlr_layer_surface_v1 *surface =
|
||||||
wlr_layer_surface_v1_from_wlr_surface(wlr_surface);
|
wlr_layer_surface_v1_try_from_wlr_surface(wlr_surface);
|
||||||
|
assert(surface != NULL);
|
||||||
|
|
||||||
if (surface->configured && surface->mapped) {
|
if (surface->configured && surface->mapped) {
|
||||||
layer_surface_unmap(surface);
|
layer_surface_unmap(surface);
|
||||||
|
Loading…
Reference in New Issue
Block a user