2013-12-04 08:20:01 +00:00
|
|
|
/*
|
|
|
|
* Copyright © 2010-2012 Intel Corporation
|
|
|
|
* Copyright © 2011-2012 Collabora, Ltd.
|
|
|
|
* Copyright © 2013 Raspberry Pi Foundation
|
|
|
|
*
|
2015-06-11 19:55:55 +00:00
|
|
|
* 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:
|
2013-12-04 08:20:01 +00:00
|
|
|
*
|
2015-06-11 19:55:55 +00:00
|
|
|
* 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.
|
2013-12-04 08:20:01 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
2016-07-19 11:16:27 +00:00
|
|
|
#include <stdint.h>
|
2014-08-28 08:41:26 +00:00
|
|
|
#include <time.h>
|
2013-12-04 08:20:01 +00:00
|
|
|
|
2019-03-28 14:28:47 +00:00
|
|
|
#include <libweston/libweston.h>
|
2019-04-04 12:52:47 +00:00
|
|
|
#include <libweston/xwayland-api.h>
|
2013-12-04 08:20:01 +00:00
|
|
|
|
2015-11-17 08:00:33 +00:00
|
|
|
#include "weston-desktop-shell-server-protocol.h"
|
2014-08-20 13:53:19 +00:00
|
|
|
|
2013-12-04 08:20:01 +00:00
|
|
|
enum animation_type {
|
|
|
|
ANIMATION_NONE,
|
|
|
|
|
|
|
|
ANIMATION_ZOOM,
|
|
|
|
ANIMATION_FADE,
|
|
|
|
ANIMATION_DIM_LAYER,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum fade_type {
|
|
|
|
FADE_IN,
|
|
|
|
FADE_OUT
|
|
|
|
};
|
|
|
|
|
|
|
|
enum exposay_target_state {
|
|
|
|
EXPOSAY_TARGET_OVERVIEW, /* show all windows */
|
|
|
|
EXPOSAY_TARGET_CANCEL, /* return to normal, same focus */
|
|
|
|
EXPOSAY_TARGET_SWITCH, /* return to normal, switch focus */
|
|
|
|
};
|
|
|
|
|
|
|
|
enum exposay_layout_state {
|
|
|
|
EXPOSAY_LAYOUT_INACTIVE = 0, /* normal desktop */
|
|
|
|
EXPOSAY_LAYOUT_ANIMATE_TO_INACTIVE, /* in transition to normal */
|
|
|
|
EXPOSAY_LAYOUT_OVERVIEW, /* show all windows */
|
|
|
|
EXPOSAY_LAYOUT_ANIMATE_TO_OVERVIEW, /* in transition to all windows */
|
|
|
|
};
|
|
|
|
|
2014-02-10 12:22:32 +00:00
|
|
|
struct exposay_output {
|
|
|
|
int num_surfaces;
|
|
|
|
int grid_size;
|
|
|
|
int surface_size;
|
|
|
|
int padding_inner;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct exposay {
|
|
|
|
/* XXX: Make these exposay_surfaces. */
|
|
|
|
struct weston_view *focus_prev;
|
|
|
|
struct weston_view *focus_current;
|
|
|
|
struct weston_view *clicked;
|
|
|
|
struct workspace *workspace;
|
|
|
|
struct weston_seat *seat;
|
|
|
|
|
|
|
|
struct wl_list surface_list;
|
|
|
|
|
|
|
|
struct weston_keyboard_grab grab_kbd;
|
|
|
|
struct weston_pointer_grab grab_ptr;
|
|
|
|
|
|
|
|
enum exposay_target_state state_target;
|
|
|
|
enum exposay_layout_state state_cur;
|
|
|
|
int in_flight; /* number of animations still running */
|
|
|
|
|
|
|
|
int row_current;
|
|
|
|
int column_current;
|
|
|
|
struct exposay_output *cur_output;
|
|
|
|
|
|
|
|
bool mod_pressed;
|
|
|
|
bool mod_invalid;
|
|
|
|
};
|
|
|
|
|
2013-12-04 08:20:01 +00:00
|
|
|
struct focus_surface {
|
|
|
|
struct weston_surface *surface;
|
|
|
|
struct weston_view *view;
|
|
|
|
struct weston_transform workspace_transform;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct workspace {
|
|
|
|
struct weston_layer layer;
|
|
|
|
|
|
|
|
struct wl_list focus_list;
|
|
|
|
struct wl_listener seat_destroyed_listener;
|
|
|
|
|
|
|
|
struct focus_surface *fsurf_front;
|
|
|
|
struct focus_surface *fsurf_back;
|
|
|
|
struct weston_view_animation *focus_animation;
|
|
|
|
};
|
|
|
|
|
2014-02-10 12:22:32 +00:00
|
|
|
struct shell_output {
|
|
|
|
struct desktop_shell *shell;
|
|
|
|
struct weston_output *output;
|
|
|
|
struct exposay_output eoutput;
|
|
|
|
struct wl_listener destroy_listener;
|
|
|
|
struct wl_list link;
|
2016-06-09 15:55:52 +00:00
|
|
|
|
|
|
|
struct weston_surface *panel_surface;
|
|
|
|
struct wl_listener panel_surface_listener;
|
|
|
|
|
|
|
|
struct weston_surface *background_surface;
|
|
|
|
struct wl_listener background_surface_listener;
|
2016-09-09 20:16:02 +00:00
|
|
|
|
|
|
|
struct {
|
|
|
|
struct weston_view *view;
|
|
|
|
struct weston_view_animation *animation;
|
|
|
|
enum fade_type type;
|
|
|
|
struct wl_event_source *startup_timer;
|
|
|
|
} fade;
|
2014-02-10 12:22:32 +00:00
|
|
|
};
|
|
|
|
|
2016-08-12 08:41:36 +00:00
|
|
|
struct weston_desktop;
|
2013-12-04 08:20:01 +00:00
|
|
|
struct desktop_shell {
|
|
|
|
struct weston_compositor *compositor;
|
2016-08-12 08:41:36 +00:00
|
|
|
struct weston_desktop *desktop;
|
|
|
|
const struct weston_xwayland_surface_api *xwayland_surface_api;
|
2013-12-04 08:20:01 +00:00
|
|
|
|
|
|
|
struct wl_listener idle_listener;
|
|
|
|
struct wl_listener wake_listener;
|
2015-12-11 18:57:05 +00:00
|
|
|
struct wl_listener transform_listener;
|
2016-06-09 15:55:52 +00:00
|
|
|
struct wl_listener resized_listener;
|
2013-12-04 08:20:01 +00:00
|
|
|
struct wl_listener destroy_listener;
|
|
|
|
struct wl_listener show_input_panel_listener;
|
|
|
|
struct wl_listener hide_input_panel_listener;
|
|
|
|
struct wl_listener update_input_panel_listener;
|
|
|
|
|
|
|
|
struct weston_layer fullscreen_layer;
|
|
|
|
struct weston_layer panel_layer;
|
|
|
|
struct weston_layer background_layer;
|
|
|
|
struct weston_layer lock_layer;
|
|
|
|
struct weston_layer input_panel_layer;
|
|
|
|
|
|
|
|
struct wl_listener pointer_focus_listener;
|
|
|
|
struct weston_surface *grab_surface;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
struct wl_client *client;
|
|
|
|
struct wl_resource *desktop_shell;
|
2013-12-20 19:07:01 +00:00
|
|
|
struct wl_listener client_destroy_listener;
|
2013-12-04 08:20:01 +00:00
|
|
|
|
|
|
|
unsigned deathcount;
|
2017-11-16 16:21:01 +00:00
|
|
|
struct timespec deathstamp;
|
2013-12-04 08:20:01 +00:00
|
|
|
} child;
|
|
|
|
|
|
|
|
bool locked;
|
|
|
|
bool showing_input_panels;
|
|
|
|
bool prepare_event_sent;
|
|
|
|
|
text_backend: make destructor call explicit
We used to rely on the order in which the
weston_compositor::destroy_signal callbacks happened, to not access
freed memory. Don't know when, but this broke at least with ivi-shell,
which caused crashes in random places on compositor shutdown.
Valgrind found the following:
Invalid write of size 8
at 0xC2EDC69: unbind_input_panel (input-panel-ivi.c:340)
by 0x4E3B6BB: destroy_resource (wayland-server.c:537)
by 0x4E3E085: for_each_helper.isra.0 (wayland-util.c:359)
by 0x4E3E60D: wl_map_for_each (wayland-util.c:365)
by 0x4E3BEC7: wl_client_destroy (wayland-server.c:675)
by 0x4182F2: text_backend_notifier_destroy (text-backend.c:1047)
by 0x4084FB: wl_signal_emit (wayland-server-core.h:264)
by 0x4084FB: main (compositor.c:5465)
Address 0x67ea360 is 208 bytes inside a block of size 232 free'd
at 0x4C2A6BC: free (vg_replace_malloc.c:473)
by 0x4084FB: wl_signal_emit (wayland-server-core.h:264)
by 0x4084FB: main (compositor.c:5465)
Invalid write of size 8
at 0x4E3E0D7: wl_list_remove (wayland-util.c:57)
by 0xC2EDEE9: destroy_input_panel_surface (input-panel-ivi.c:191)
by 0x4E3B6BB: destroy_resource (wayland-server.c:537)
by 0x4E3BC7B: wl_resource_destroy (wayland-server.c:550)
by 0x40DB8B: wl_signal_emit (wayland-server-core.h:264)
by 0x40DB8B: weston_surface_destroy (compositor.c:1883)
by 0x40DB8B: weston_surface_destroy (compositor.c:1873)
by 0x4E3B6BB: destroy_resource (wayland-server.c:537)
by 0x4E3E085: for_each_helper.isra.0 (wayland-util.c:359)
by 0x4E3E60D: wl_map_for_each (wayland-util.c:365)
by 0x4E3BEC7: wl_client_destroy (wayland-server.c:675)
by 0x4182F2: text_backend_notifier_destroy (text-backend.c:1047)
by 0x4084FB: wl_signal_emit (wayland-server-core.h:264)
by 0x4084FB: main (compositor.c:5465)
Address 0x67ea370 is 224 bytes inside a block of size 232 free'd
at 0x4C2A6BC: free (vg_replace_malloc.c:473)
by 0x4084FB: wl_signal_emit (wayland-server-core.h:264)
by 0x4084FB: main (compositor.c:5465)
Invalid write of size 8
at 0x4E3E0E7: wl_list_remove (wayland-util.c:58)
by 0xC2EDEE9: destroy_input_panel_surface (input-panel-ivi.c:191)
by 0x4E3B6BB: destroy_resource (wayland-server.c:537)
by 0x4E3BC7B: wl_resource_destroy (wayland-server.c:550)
by 0x40DB8B: wl_signal_emit (wayland-server-core.h:264)
by 0x40DB8B: weston_surface_destroy (compositor.c:1883)
by 0x40DB8B: weston_surface_destroy (compositor.c:1873)
by 0x4E3B6BB: destroy_resource (wayland-server.c:537)
by 0x4E3E085: for_each_helper.isra.0 (wayland-util.c:359)
by 0x4E3E60D: wl_map_for_each (wayland-util.c:365)
by 0x4E3BEC7: wl_client_destroy (wayland-server.c:675)
by 0x4182F2: text_backend_notifier_destroy (text-backend.c:1047)
by 0x4084FB: wl_signal_emit (wayland-server-core.h:264)
by 0x4084FB: main (compositor.c:5465)
Address 0x67ea368 is 216 bytes inside a block of size 232 free'd
at 0x4C2A6BC: free (vg_replace_malloc.c:473)
by 0x4084FB: wl_signal_emit (wayland-server-core.h:264)
by 0x4084FB: main (compositor.c:5465)
Looking at the first of these, unbind_input_panel() gets called when the
text-backend destroys its helper client which has bound to input_panel
interface. This happens after the shell's destroy_signal callback has
been called, so the shell has already been freed.
The other two errors come from
wl_list_remove(&input_panel_surface->link);
which has gone stale when the shell was destroyed
(shell->input_panel.surfaces list).
Rather than creating even more destroy listeners and hooking them up in
spaghetti, modify text-backend to not hook up to the compositor destroy
signal. Instead, make it the text_backend_init() callers' responsibility
to also call text_backend_destroy() appropriately, before the shell goes
away.
This fixed all the above Valgrind errors, and avoid a crash with
ivi-shell when exiting Weston.
Also using desktop-shell exhibited similar Valgrind errors which are
fixed by this patch, but those didn't happen to cause any crashes AFAIK.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-By: Derek Foreman <derekf@osg.samsung.com>
2015-06-24 13:09:17 +00:00
|
|
|
struct text_backend *text_backend;
|
|
|
|
|
2013-12-04 08:20:01 +00:00
|
|
|
struct {
|
|
|
|
struct weston_surface *surface;
|
|
|
|
pixman_box32_t cursor_rectangle;
|
|
|
|
} text_input;
|
|
|
|
|
|
|
|
struct weston_surface *lock_surface;
|
|
|
|
struct wl_listener lock_surface_listener;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
struct wl_array array;
|
|
|
|
unsigned int current;
|
|
|
|
unsigned int num;
|
|
|
|
|
|
|
|
struct wl_list client_list;
|
|
|
|
|
|
|
|
struct weston_animation animation;
|
|
|
|
struct wl_list anim_sticky_list;
|
|
|
|
int anim_dir;
|
2017-11-16 16:20:52 +00:00
|
|
|
struct timespec anim_timestamp;
|
2013-12-04 08:20:01 +00:00
|
|
|
double anim_current;
|
|
|
|
struct workspace *anim_from;
|
|
|
|
struct workspace *anim_to;
|
|
|
|
} workspaces;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
struct wl_resource *binding;
|
|
|
|
struct wl_list surfaces;
|
|
|
|
} input_panel;
|
|
|
|
|
2014-02-10 12:22:32 +00:00
|
|
|
struct exposay exposay;
|
2013-12-04 08:20:01 +00:00
|
|
|
|
2016-01-12 10:21:48 +00:00
|
|
|
bool allow_zap;
|
2013-12-04 08:20:01 +00:00
|
|
|
uint32_t binding_modifier;
|
2014-01-17 00:51:52 +00:00
|
|
|
uint32_t exposay_modifier;
|
2013-12-04 08:20:01 +00:00
|
|
|
enum animation_type win_animation_type;
|
2014-08-12 13:13:30 +00:00
|
|
|
enum animation_type win_close_animation_type;
|
2013-12-04 08:20:01 +00:00
|
|
|
enum animation_type startup_animation_type;
|
|
|
|
enum animation_type focus_animation_type;
|
|
|
|
|
2014-02-26 14:52:13 +00:00
|
|
|
struct weston_layer minimized_layer;
|
|
|
|
|
2014-04-22 00:42:58 +00:00
|
|
|
struct wl_listener seat_create_listener;
|
2013-12-04 08:20:01 +00:00
|
|
|
struct wl_listener output_create_listener;
|
2014-01-29 16:47:52 +00:00
|
|
|
struct wl_listener output_move_listener;
|
2013-12-04 08:20:01 +00:00
|
|
|
struct wl_list output_list;
|
2021-08-26 13:37:24 +00:00
|
|
|
struct wl_list seat_list;
|
2013-12-04 08:20:01 +00:00
|
|
|
|
2015-11-17 08:00:33 +00:00
|
|
|
enum weston_desktop_shell_panel_position panel_position;
|
2014-08-20 13:53:19 +00:00
|
|
|
|
2013-12-04 08:20:01 +00:00
|
|
|
char *client;
|
2014-08-28 08:41:26 +00:00
|
|
|
|
|
|
|
struct timespec startup_time;
|
2013-12-04 08:20:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct weston_output *
|
|
|
|
get_default_output(struct weston_compositor *compositor);
|
|
|
|
|
|
|
|
struct weston_view *
|
|
|
|
get_default_view(struct weston_surface *surface);
|
|
|
|
|
|
|
|
struct shell_surface *
|
|
|
|
get_shell_surface(struct weston_surface *surface);
|
|
|
|
|
|
|
|
struct workspace *
|
|
|
|
get_current_workspace(struct desktop_shell *shell);
|
|
|
|
|
2020-01-24 20:53:44 +00:00
|
|
|
void
|
|
|
|
get_output_work_area(struct desktop_shell *shell,
|
|
|
|
struct weston_output *output,
|
|
|
|
pixman_rectangle32_t *area);
|
|
|
|
|
2013-12-04 08:20:01 +00:00
|
|
|
void
|
2015-06-21 19:25:08 +00:00
|
|
|
lower_fullscreen_layer(struct desktop_shell *shell,
|
|
|
|
struct weston_output *lowering_output);
|
2013-12-04 08:20:01 +00:00
|
|
|
|
|
|
|
void
|
2014-10-18 11:24:53 +00:00
|
|
|
activate(struct desktop_shell *shell, struct weston_view *view,
|
2014-10-18 16:20:16 +00:00
|
|
|
struct weston_seat *seat, uint32_t flags);
|
2013-12-04 08:20:01 +00:00
|
|
|
|
|
|
|
void
|
2015-07-15 18:00:36 +00:00
|
|
|
exposay_binding(struct weston_keyboard *keyboard,
|
2013-12-04 08:20:01 +00:00
|
|
|
enum weston_keyboard_modifier modifier,
|
|
|
|
void *data);
|
2013-12-04 19:00:19 +00:00
|
|
|
int
|
|
|
|
input_panel_setup(struct desktop_shell *shell);
|
|
|
|
void
|
|
|
|
input_panel_destroy(struct desktop_shell *shell);
|
2014-04-11 10:57:15 +00:00
|
|
|
|
|
|
|
typedef void (*shell_for_each_layer_func_t)(struct desktop_shell *,
|
|
|
|
struct weston_layer *, void *);
|
|
|
|
|
|
|
|
void
|
|
|
|
shell_for_each_layer(struct desktop_shell *shell,
|
|
|
|
shell_for_each_layer_func_t func,
|
|
|
|
void *data);
|