mirror of
https://github.com/labwc/labwc.git
synced 2025-11-02 09:01:47 -05:00
view: Move xdg_surface + xwayland_surface to derived structs
Add xdg_surface_from_view() + xwayland_surface_from_view() accessors that assert() the view is of the expected type before returning. Fix a real bug in xdg.c parent_of() that dereferenced `view->xdg_surface->toplevel` without first checking `view->type`. The goal of the new accessors is to catch similar bugs in future.
This commit is contained in:
parent
df7276345f
commit
4da37c6532
7 changed files with 147 additions and 106 deletions
|
|
@ -40,13 +40,6 @@ struct view {
|
|||
struct wl_list link;
|
||||
struct output *output;
|
||||
struct workspace *workspace;
|
||||
|
||||
union {
|
||||
struct wlr_xdg_surface *xdg_surface;
|
||||
#if HAVE_XWAYLAND
|
||||
struct wlr_xwayland_surface *xwayland_surface;
|
||||
#endif
|
||||
};
|
||||
struct wlr_surface *surface;
|
||||
struct wlr_scene_tree *scene_tree;
|
||||
struct wlr_scene_node *scene_node;
|
||||
|
|
@ -97,6 +90,7 @@ struct view {
|
|||
|
||||
struct xdg_toplevel_view {
|
||||
struct view base;
|
||||
struct wlr_xdg_surface *xdg_surface;
|
||||
|
||||
/* Events unique to xdg-toplevel views */
|
||||
struct wl_listener set_app_id;
|
||||
|
|
@ -106,6 +100,7 @@ struct xdg_toplevel_view {
|
|||
#if HAVE_XWAYLAND
|
||||
struct xwayland_view {
|
||||
struct view base;
|
||||
struct wlr_xwayland_surface *xwayland_surface;
|
||||
|
||||
/* Events unique to XWayland views */
|
||||
struct wl_listener request_configure;
|
||||
|
|
@ -166,4 +161,12 @@ void view_adjust_size(struct view *view, int *w, int *h);
|
|||
void view_on_output_destroy(struct view *view);
|
||||
void view_destroy(struct view *view);
|
||||
|
||||
/* xdg.c */
|
||||
struct wlr_xdg_surface *xdg_surface_from_view(struct view *view);
|
||||
|
||||
/* xwayland.c */
|
||||
#if HAVE_XWAYLAND
|
||||
struct wlr_xwayland_surface *xwayland_surface_from_view(struct view *view);
|
||||
#endif
|
||||
|
||||
#endif /* __LABWC_VIEW_H */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue