mirror of
https://github.com/cage-kiosk/cage.git
synced 2025-10-29 05:40:19 -04:00
view: implement view_from_wlr_surface in terms of wlr_surface->data pointer
This commit is contained in:
parent
1ccbacf198
commit
ba9c245393
3 changed files with 12 additions and 12 deletions
2
seat.c
2
seat.c
|
|
@ -817,7 +817,7 @@ struct cg_view *
|
|||
seat_get_focus(struct cg_seat *seat)
|
||||
{
|
||||
struct wlr_surface *prev_surface = seat->seat->keyboard_state.focused_surface;
|
||||
return view_from_wlr_surface(seat->server, prev_surface);
|
||||
return view_from_wlr_surface(prev_surface);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
20
view.c
20
view.c
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Cage: A Wayland kiosk.
|
||||
*
|
||||
* Copyright (C) 2018-2020 Jente Hidskes
|
||||
* Copyright (C) 2018-2021 Jente Hidskes
|
||||
*
|
||||
* See the LICENSE file accompanying this file.
|
||||
*/
|
||||
|
|
@ -103,14 +103,13 @@ view_unmap(struct cg_view *view)
|
|||
|
||||
wlr_scene_node_destroy(view->scene_node);
|
||||
|
||||
view->wlr_surface->data = NULL;
|
||||
view->wlr_surface = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
view_map(struct cg_view *view, struct wlr_surface *surface)
|
||||
{
|
||||
view->wlr_surface = surface;
|
||||
|
||||
view->scene_node = wlr_scene_subsurface_tree_create(&view->server->scene->node, surface);
|
||||
if (!view->scene_node) {
|
||||
wl_resource_post_no_memory(surface->resource);
|
||||
|
|
@ -118,6 +117,9 @@ view_map(struct cg_view *view, struct wlr_surface *surface)
|
|||
}
|
||||
view->scene_node->data = view;
|
||||
|
||||
view->wlr_surface = surface;
|
||||
surface->data = view;
|
||||
|
||||
#if CAGE_HAS_XWAYLAND
|
||||
/* We shouldn't position override-redirect windows. They set
|
||||
their own (x,y) coordinates in handle_wayland_surface_map. */
|
||||
|
|
@ -159,13 +161,11 @@ view_init(struct cg_view *view, struct cg_server *server, enum cg_view_type type
|
|||
}
|
||||
|
||||
struct cg_view *
|
||||
view_from_wlr_surface(struct cg_server *server, struct wlr_surface *surface)
|
||||
view_from_wlr_surface(struct wlr_surface *surface)
|
||||
{
|
||||
struct cg_view *view;
|
||||
wl_list_for_each (view, &server->views, link) {
|
||||
if (view->wlr_surface == surface) {
|
||||
return view;
|
||||
}
|
||||
if (!surface) {
|
||||
return NULL;
|
||||
}
|
||||
return NULL;
|
||||
|
||||
return surface->data;
|
||||
}
|
||||
|
|
|
|||
2
view.h
2
view.h
|
|
@ -54,6 +54,6 @@ void view_map(struct cg_view *view, struct wlr_surface *surface);
|
|||
void view_destroy(struct cg_view *view);
|
||||
void view_init(struct cg_view *view, struct cg_server *server, enum cg_view_type type, const struct cg_view_impl *impl);
|
||||
|
||||
struct cg_view *view_from_wlr_surface(struct cg_server *server, struct wlr_surface *surface);
|
||||
struct cg_view *view_from_wlr_surface(struct wlr_surface *surface);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue