weston/kiosk-shell/kiosk-shell.h

106 lines
3.0 KiB
C
Raw Normal View History

/*
* Copyright 2020 Collabora, Ltd.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#ifndef WESTON_KIOSK_SHELL_H
#define WESTON_KIOSK_SHELL_H
#include <libweston/desktop.h>
#include <libweston/libweston.h>
#include <libweston/config-parser.h>
struct kiosk_shell {
struct weston_compositor *compositor;
struct weston_desktop *desktop;
struct wl_listener destroy_listener;
struct wl_listener output_created_listener;
struct wl_listener output_resized_listener;
struct wl_listener output_moved_listener;
struct wl_listener seat_created_listener;
struct wl_listener transform_listener;
struct weston_layer background_layer;
struct weston_layer normal_layer;
struct weston_layer inactive_layer;
struct wl_list output_list;
kiosk-shell: Keep track of seats created and destroy them at end kiosk_shell_destroy() will free up weston_desktop, but still keeping listeners set-up (keyboard/seat/caps), which will fire when the the compositor is stopped/shutdown by clients still connected. This patch maintains a list of seats and uses it to remove any listeners when calling kiosk_shell_destroy(). desktop-shell and ivi-shell do not appear to be using weston_desktop_destroy() in their respective destroy parts. This avoids an illegal access happening when calling one of the listeners, after weston_desktop has been free'ed, like the following: ==2002== at 0x10F3F8FD: weston_desktop_get_display (libweston-desktop.c:125) ==2002== by 0x10F450A7: weston_desktop_xdg_surface_schedule_configure (xdg-shell.c:1022) ==2002== by 0x10F44793: weston_desktop_xdg_toplevel_set_activated (xdg-shell.c:643) ==2002== by 0x10F41AA5: weston_desktop_surface_set_activated (surface.c:468) ==2002== by 0x10F32E7E: kiosk_shell_seat_handle_keyboard_focus (kiosk-shell.c:329) ==2002== by 0x4A726A7: wl_signal_emit (wayland-server-core.h:478) ==2002== by 0x4A75BD1: weston_keyboard_set_focus (input.c:1586) ==2002== by 0x4A776FE: notify_keyboard_focus_out (input.c:2314) ==2002== by 0x5902BC1: udev_seat_destroy (libinput-seat.c:469) ==2002== by 0x59028C5: udev_input_destroy (libinput-seat.c:375) ==2002== by 0x58F0449: drm_destroy (drm.c:2571) ==2002== by 0x4A6EE39: weston_compositor_destroy (compositor.c:7814) ==2002== Address 0x10bd1780 is 0 bytes inside a block of size 152 free'd ==2002== at 0x48399AB: free (vg_replace_malloc.c:538) ==2002== by 0x10F3F8DA: weston_desktop_destroy (libweston-desktop.c:112) ==2002== by 0x10F34357: kiosk_shell_destroy (kiosk-shell.c:1009) ==2002== by 0x4A5F618: wl_signal_emit (wayland-server-core.h:478) ==2002== by 0x4A6EE06: weston_compositor_destroy (compositor.c:7809) ==2002== by 0x4855548: wet_main (main.c:3420) ==2002== by 0x109154: main (executable.c:33) ==2002== Block was alloc'd at ==2002== at 0x483AB65: calloc (vg_replace_malloc.c:760) ==2002== by 0x10F3F681: zalloc (zalloc.h:38) ==2002== by 0x10F3F724: weston_desktop_create (libweston-desktop.c:65) ==2002== by 0x10F34458: wet_shell_init (kiosk-shell.c:1045) ==2002== by 0x484F83D: wet_load_shell (main.c:924) ==2002== by 0x48552D3: wet_main (main.c:3361) ==2002== by 0x109154: main (executable.c:33) Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2020-10-24 16:26:59 +03:00
struct wl_list seat_list;
const struct weston_xwayland_surface_api *xwayland_surface_api;
struct weston_config *config;
};
struct kiosk_shell_surface {
struct weston_desktop_surface *desktop_surface;
struct weston_view *view;
struct kiosk_shell *shell;
struct weston_output *output;
struct wl_listener output_destroy_listener;
struct wl_signal destroy_signal;
struct wl_signal parent_destroy_signal;
struct wl_listener parent_destroy_listener;
struct kiosk_shell_surface *parent;
kiosk-shell: Introduce surface tree lists to the kiosk shell The following patchset implements proper z-order for xdg surfaces in the kiosk shell. For this it introduces to the kiosk shell the concept of a "surface tree": a list of kiosk shell surface structures having a common ancestor (in the xdg protocol sense). The design is based on the following assumptions that the kiosk shell currently makes: - A kiosk surface with no parent must be fullscreen. - If a parent is set on a kiosk surface, that surface is assigned the output of the root kiosk surface. This means that all kiosk surfaces in a surface tree will always have the same output. - There is no possibility to minimize a kiosk surface. With these in mind, the following design decisions were deemed convenient: - For every output, at most one surface tree list will be active. This means that, for a given output, only views belonging to surfaces of the same surface tree will be in the normal layer. Moreover, all such views will be in the normal layer if the surface tree list is active. - The z-order of surface trees (the weston views' relative placement in the normal layer) is determined by the placement of their corresponding kiosk surface in the surface tree list. Each kiosk shell surface begins its life as root of its own surface tree list. Whenever a parent is set on a surface, that surface is linked to the surface tree list of the root surface of the parent. If a parent kiosk shell surface is destroyed, its children will keep the link to the root surface's surface tree list. If the destroyed parent is also the root surface of the surface tree, each child is unlinked from this root and they become the root of a new surface tree. This commit introduces to the kiosk_shell_surface structure the fields 'surface_tree_list', representing the surface tree list to which the surface is linked at creation as its root, and 'surface_tree_link', the link to the surface tree list. Signed-off-by: Sergio Gómez <sergio.g.delreal@gmail.com>
2023-05-26 02:54:03 +03:00
struct wl_list surface_tree_list;
struct wl_list surface_tree_link;
int focus_count;
int32_t last_width, last_height;
bool grabbed;
struct {
bool is_set;
struct weston_coord_global pos;
} xwayland;
bool appid_output_assigned;
};
struct kiosk_shell_seat {
struct weston_seat *seat;
struct wl_listener seat_destroy_listener;
struct weston_surface *focused_surface;
kiosk-shell: Keep track of seats created and destroy them at end kiosk_shell_destroy() will free up weston_desktop, but still keeping listeners set-up (keyboard/seat/caps), which will fire when the the compositor is stopped/shutdown by clients still connected. This patch maintains a list of seats and uses it to remove any listeners when calling kiosk_shell_destroy(). desktop-shell and ivi-shell do not appear to be using weston_desktop_destroy() in their respective destroy parts. This avoids an illegal access happening when calling one of the listeners, after weston_desktop has been free'ed, like the following: ==2002== at 0x10F3F8FD: weston_desktop_get_display (libweston-desktop.c:125) ==2002== by 0x10F450A7: weston_desktop_xdg_surface_schedule_configure (xdg-shell.c:1022) ==2002== by 0x10F44793: weston_desktop_xdg_toplevel_set_activated (xdg-shell.c:643) ==2002== by 0x10F41AA5: weston_desktop_surface_set_activated (surface.c:468) ==2002== by 0x10F32E7E: kiosk_shell_seat_handle_keyboard_focus (kiosk-shell.c:329) ==2002== by 0x4A726A7: wl_signal_emit (wayland-server-core.h:478) ==2002== by 0x4A75BD1: weston_keyboard_set_focus (input.c:1586) ==2002== by 0x4A776FE: notify_keyboard_focus_out (input.c:2314) ==2002== by 0x5902BC1: udev_seat_destroy (libinput-seat.c:469) ==2002== by 0x59028C5: udev_input_destroy (libinput-seat.c:375) ==2002== by 0x58F0449: drm_destroy (drm.c:2571) ==2002== by 0x4A6EE39: weston_compositor_destroy (compositor.c:7814) ==2002== Address 0x10bd1780 is 0 bytes inside a block of size 152 free'd ==2002== at 0x48399AB: free (vg_replace_malloc.c:538) ==2002== by 0x10F3F8DA: weston_desktop_destroy (libweston-desktop.c:112) ==2002== by 0x10F34357: kiosk_shell_destroy (kiosk-shell.c:1009) ==2002== by 0x4A5F618: wl_signal_emit (wayland-server-core.h:478) ==2002== by 0x4A6EE06: weston_compositor_destroy (compositor.c:7809) ==2002== by 0x4855548: wet_main (main.c:3420) ==2002== by 0x109154: main (executable.c:33) ==2002== Block was alloc'd at ==2002== at 0x483AB65: calloc (vg_replace_malloc.c:760) ==2002== by 0x10F3F681: zalloc (zalloc.h:38) ==2002== by 0x10F3F724: weston_desktop_create (libweston-desktop.c:65) ==2002== by 0x10F34458: wet_shell_init (kiosk-shell.c:1045) ==2002== by 0x484F83D: wet_load_shell (main.c:924) ==2002== by 0x48552D3: wet_main (main.c:3361) ==2002== by 0x109154: main (executable.c:33) Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2020-10-24 16:26:59 +03:00
struct wl_list link; /** kiosk_shell::seat_list */
};
struct kiosk_shell_output {
struct weston_output *output;
struct wl_listener output_destroy_listener;
struct weston_curtain *curtain;
struct kiosk_shell *shell;
struct wl_list link;
char *app_ids;
struct wl_list *active_surface_tree;
};
#endif /* WESTON_KIOSK_SHELL_H */