2011-01-18 15:53:49 +03:00
|
|
|
|
/*
|
2012-02-20 03:52:44 +04:00
|
|
|
|
* Copyright © 2010-2012 Intel Corporation
|
2012-01-27 18:25:16 +04:00
|
|
|
|
* Copyright © 2011-2012 Collabora, Ltd.
|
2013-11-19 14:37:14 +04:00
|
|
|
|
* Copyright © 2013 Raspberry Pi Foundation
|
2011-01-18 15:53:49 +03:00
|
|
|
|
*
|
2015-06-11 22:55:55 +03: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:
|
2011-01-18 15:53:49 +03:00
|
|
|
|
*
|
2015-06-11 22:55:55 +03: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.
|
2011-01-18 15:53:49 +03:00
|
|
|
|
*/
|
|
|
|
|
|
2013-05-22 19:03:19 +04:00
|
|
|
|
#include "config.h"
|
|
|
|
|
|
2011-01-18 15:53:49 +03:00
|
|
|
|
#include <stdlib.h>
|
2016-07-19 14:16:27 +03:00
|
|
|
|
#include <stdint.h>
|
2011-09-06 21:48:16 +04:00
|
|
|
|
#include <stdio.h>
|
2011-01-18 15:53:49 +03:00
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <unistd.h>
|
2011-04-13 01:25:42 +04:00
|
|
|
|
#include <linux/input.h>
|
2011-11-15 15:34:54 +04:00
|
|
|
|
#include <assert.h>
|
2011-12-02 18:31:49 +04:00
|
|
|
|
#include <signal.h>
|
2012-01-20 18:48:25 +04:00
|
|
|
|
#include <math.h>
|
2012-05-26 21:41:06 +04:00
|
|
|
|
#include <sys/types.h>
|
2011-01-18 15:53:49 +03:00
|
|
|
|
|
2013-12-04 12:20:01 +04:00
|
|
|
|
#include "shell.h"
|
2016-06-03 16:45:21 +03:00
|
|
|
|
#include "compositor/weston.h"
|
2015-11-17 11:00:33 +03:00
|
|
|
|
#include "weston-desktop-shell-server-protocol.h"
|
2019-04-04 14:27:31 +03:00
|
|
|
|
#include <libweston/config-parser.h>
|
2015-06-16 01:37:09 +03:00
|
|
|
|
#include "shared/helpers.h"
|
2017-11-16 19:20:52 +03:00
|
|
|
|
#include "shared/timespec-util.h"
|
2022-11-22 14:28:57 +03:00
|
|
|
|
#include <libweston/shell-utils.h>
|
2022-06-30 12:59:45 +03:00
|
|
|
|
#include <libweston/desktop.h>
|
2011-01-18 15:53:49 +03:00
|
|
|
|
|
2012-06-13 02:01:22 +04:00
|
|
|
|
#define DEFAULT_NUM_WORKSPACES 1
|
2012-06-13 02:01:23 +04:00
|
|
|
|
#define DEFAULT_WORKSPACE_CHANGE_ANIMATION_LENGTH 200
|
2012-06-13 02:01:22 +04:00
|
|
|
|
|
2012-06-13 02:01:24 +04:00
|
|
|
|
struct focus_state {
|
2016-08-15 11:56:52 +03:00
|
|
|
|
struct desktop_shell *shell;
|
2012-06-13 02:01:24 +04:00
|
|
|
|
struct weston_seat *seat;
|
2012-08-01 00:36:34 +04:00
|
|
|
|
struct workspace *ws;
|
2012-06-13 02:01:24 +04:00
|
|
|
|
struct weston_surface *keyboard_focus;
|
|
|
|
|
struct wl_list link;
|
|
|
|
|
struct wl_listener seat_destroy_listener;
|
|
|
|
|
struct wl_listener surface_destroy_listener;
|
|
|
|
|
};
|
|
|
|
|
|
2013-11-25 22:01:44 +04:00
|
|
|
|
/*
|
|
|
|
|
* Surface stacking and ordering.
|
|
|
|
|
*
|
|
|
|
|
* This is handled using several linked lists of surfaces, organised into
|
|
|
|
|
* ‘layers’. The layers are ordered, and each of the surfaces in one layer are
|
|
|
|
|
* above all of the surfaces in the layer below. The set of layers is static and
|
|
|
|
|
* in the following order (top-most first):
|
|
|
|
|
* • Lock layer (only ever displayed on its own)
|
|
|
|
|
* • Cursor layer
|
2014-03-05 15:21:34 +04:00
|
|
|
|
* • Input panel layer
|
2013-11-25 22:01:44 +04:00
|
|
|
|
* • Fullscreen layer
|
|
|
|
|
* • Panel layer
|
|
|
|
|
* • Workspace layers
|
|
|
|
|
* • Background layer
|
|
|
|
|
*
|
|
|
|
|
* The list of layers may be manipulated to remove whole layers of surfaces from
|
|
|
|
|
* display. For example, when locking the screen, all layers except the lock
|
|
|
|
|
* layer are removed.
|
|
|
|
|
*
|
|
|
|
|
* A surface’s layer is modified on configuring the surface, in
|
|
|
|
|
* set_surface_type() (which is only called when the surface’s type change is
|
|
|
|
|
* _committed_). If a surface’s type changes (e.g. when making a window
|
|
|
|
|
* fullscreen) its layer changes too.
|
|
|
|
|
*
|
|
|
|
|
* In order to allow popup and transient surfaces to be correctly stacked above
|
|
|
|
|
* their parent surfaces, each surface tracks both its parent surface, and a
|
|
|
|
|
* linked list of its children. When a surface’s layer is updated, so are the
|
|
|
|
|
* layers of its children. Note that child surfaces are *not* the same as
|
|
|
|
|
* subsurfaces — child/parent surfaces are purely for maintaining stacking
|
|
|
|
|
* order.
|
|
|
|
|
*
|
|
|
|
|
* The children_link list of siblings of a surface (i.e. those surfaces which
|
|
|
|
|
* have the same parent) only contains weston_surfaces which have a
|
|
|
|
|
* shell_surface. Stacking is not implemented for non-shell_surface
|
|
|
|
|
* weston_surfaces. This means that the following implication does *not* hold:
|
|
|
|
|
* (shsurf->parent != NULL) ⇒ !wl_list_is_empty(shsurf->children_link)
|
|
|
|
|
*/
|
|
|
|
|
|
2011-11-23 18:14:12 +04:00
|
|
|
|
struct shell_surface {
|
2013-06-14 19:07:54 +04:00
|
|
|
|
struct wl_signal destroy_signal;
|
2011-11-25 14:09:16 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
struct weston_desktop_surface *desktop_surface;
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
struct weston_view *view;
|
libweston, desktop-shell: Add a wrapper for weston_surface reference
Similar to how we do it with drm_fb ref counts, increase a reference
count and return the same object.
Plug-in in desktop-shell when we map up the view in order to survive a
weston_surface destruction.
Astute readers will notice that this patch removes weston_view_destroy()
while keeping the balance between removing and adding a
weston_surface_unref() call in desktop_shell_destroy_surface().
The reason is to let weston_surface_unref() handle destruction on its
own. If multiple references are taken, then weston_surface_unref()
doesn't destroy the view, it just decreases the reference, with
a latter call to weston_surface_unref() to determine if the view
should be destroyed as well. This situation happens if we have
close animation enabled, were we have more than one reference taken: one
when mapping the view/surface and when when the surface itself was created,
(what we call, a weak reference).
If only a single reference is taken (for instance if we don't have close
animations enabled) then this weston_surface_unref()
call is inert as that reference is not set-up, leaving libweston to
handle the view destruction.
Following that with a weston_view_destroy() explicit call would cause a
UAF as the view was previous destroyed by a weston_surface_unref() call.
A side-effect of not keeping the weston_view_destroy() call would
happen when tearing down the compositor. If close animations are enabled,
weston_surface_unref() would not destroy the view, and because
weston_view_destroy() no longer exists, we would still have the
view in the other layers by the time we check-up if layers
have views present.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-02-14 23:42:22 +03:00
|
|
|
|
struct weston_surface *wsurface_anim_fade;
|
2022-02-14 23:57:08 +03:00
|
|
|
|
struct weston_view *wview_anim_fade;
|
2013-12-03 07:01:53 +04:00
|
|
|
|
int32_t last_width, last_height;
|
2014-03-11 21:19:10 +04:00
|
|
|
|
|
2012-04-16 18:31:41 +04:00
|
|
|
|
struct desktop_shell *shell;
|
2011-11-23 18:42:16 +04:00
|
|
|
|
|
2019-06-23 15:53:59 +03:00
|
|
|
|
struct wl_list children_list;
|
|
|
|
|
struct wl_list children_link;
|
|
|
|
|
|
2022-02-04 19:50:07 +03:00
|
|
|
|
struct weston_coord_global saved_pos;
|
2012-03-01 08:57:46 +04:00
|
|
|
|
bool saved_position_valid;
|
2012-04-27 05:07:24 +04:00
|
|
|
|
bool saved_rotation_valid;
|
2013-10-25 03:52:00 +04:00
|
|
|
|
int unresponsive, grabbed;
|
2014-02-06 09:36:04 +04:00
|
|
|
|
uint32_t resize_edges;
|
2022-07-29 17:04:32 +03:00
|
|
|
|
uint32_t orientation;
|
2011-11-22 15:43:52 +04:00
|
|
|
|
|
2012-01-20 18:48:25 +04:00
|
|
|
|
struct {
|
|
|
|
|
struct weston_transform transform;
|
2012-01-27 22:36:13 +04:00
|
|
|
|
struct weston_matrix rotation;
|
2012-01-20 18:48:25 +04:00
|
|
|
|
} rotation;
|
|
|
|
|
|
2012-01-05 07:19:14 +04:00
|
|
|
|
struct {
|
2012-03-01 08:57:46 +04:00
|
|
|
|
struct weston_transform transform; /* matrix from x, y */
|
2022-01-17 17:24:03 +03:00
|
|
|
|
struct weston_curtain *black_view;
|
2012-03-01 08:57:46 +04:00
|
|
|
|
} fullscreen;
|
|
|
|
|
|
2012-02-18 08:49:07 +04:00
|
|
|
|
struct weston_output *fullscreen_output;
|
Rename wayland-compositor to weston
This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.
1) Initially, we had one big repository with protocol code, sample
compositor and sample clients. We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code. At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message. The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.
2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor. Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example. Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.
We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
2012-01-03 19:29:47 +04:00
|
|
|
|
struct weston_output *output;
|
2018-05-02 12:10:32 +03:00
|
|
|
|
struct wl_listener output_destroy_listener;
|
2013-12-03 21:35:42 +04:00
|
|
|
|
|
shell: Centralize management of sending configure requests
Currently, there's a giant bug in how xdg-shell state management
is done. If a client calls set_fullscreen and then set_maximized,
it will get two configure events:
=> set_fullscreen
<= configure(800, 600, [STATE_FULLSCREEN])
=> set_maximized
<= configure(800, 560, [STATE_FULLSCREEN, STATE_MAXIMIZED])
Since fullscreen takes precedence over maximized, the client will
render full-screen at 800x600 first, and then 800x560 next. As
a result, the surface gets the wrong size.
This is because the code that sends out configure requests is
"immediate" -- when an app calls set_maximized, we immediately
send out the configure event that would have happened if we
transitioned immediately into maximized mode.
In wl_shell, this is correct behavior. However, in xdg-shell,
this is wrong. State needs to be more carefully managed in
xdg-shell, as states aren't exclusive.
Pull all the code that sends out configure events out and send
them centrally, based on Weston's on surface state management.
This should work with both wl_shell and xdg_shell's strategies.
2014-04-12 03:00:31 +04:00
|
|
|
|
struct surface_state {
|
2016-08-16 15:26:03 +03:00
|
|
|
|
bool fullscreen;
|
|
|
|
|
bool maximized;
|
2014-01-30 17:01:10 +04:00
|
|
|
|
bool lowered;
|
2016-08-12 11:41:36 +03:00
|
|
|
|
} state;
|
2014-04-30 03:03:54 +04:00
|
|
|
|
|
2016-11-16 16:17:14 +03:00
|
|
|
|
struct {
|
|
|
|
|
bool is_set;
|
|
|
|
|
int32_t x;
|
|
|
|
|
int32_t y;
|
|
|
|
|
} xwayland;
|
|
|
|
|
|
2013-12-10 02:36:28 +04:00
|
|
|
|
int focus_count;
|
2015-04-15 01:09:06 +03:00
|
|
|
|
|
|
|
|
|
bool destroying;
|
2011-11-23 18:14:12 +04:00
|
|
|
|
};
|
|
|
|
|
|
2012-04-04 18:48:05 +04:00
|
|
|
|
struct shell_grab {
|
2013-05-07 06:15:05 +04:00
|
|
|
|
struct weston_pointer_grab grab;
|
2012-04-04 18:48:05 +04:00
|
|
|
|
struct shell_surface *shsurf;
|
|
|
|
|
struct wl_listener shsurf_destroy_listener;
|
|
|
|
|
};
|
|
|
|
|
|
2013-08-15 20:10:08 +04:00
|
|
|
|
struct shell_touch_grab {
|
|
|
|
|
struct weston_touch_grab grab;
|
|
|
|
|
struct shell_surface *shsurf;
|
|
|
|
|
struct wl_listener shsurf_destroy_listener;
|
|
|
|
|
struct weston_touch *touch;
|
|
|
|
|
};
|
|
|
|
|
|
2017-12-19 11:33:33 +03:00
|
|
|
|
struct shell_tablet_tool_grab {
|
|
|
|
|
struct weston_tablet_tool_grab grab;
|
|
|
|
|
struct shell_surface *shsurf;
|
|
|
|
|
struct wl_listener shsurf_destroy_listener;
|
|
|
|
|
struct weston_tablet_tool *tool;
|
|
|
|
|
};
|
|
|
|
|
|
2012-04-04 18:48:05 +04:00
|
|
|
|
struct weston_move_grab {
|
|
|
|
|
struct shell_grab base;
|
2012-05-08 20:17:55 +04:00
|
|
|
|
wl_fixed_t dx, dy;
|
2015-06-03 23:53:22 +03:00
|
|
|
|
bool client_initiated;
|
2011-01-18 15:53:49 +03:00
|
|
|
|
};
|
|
|
|
|
|
2013-08-15 20:10:08 +04:00
|
|
|
|
struct weston_touch_move_grab {
|
|
|
|
|
struct shell_touch_grab base;
|
2014-01-18 03:18:10 +04:00
|
|
|
|
int active;
|
2013-08-15 20:10:08 +04:00
|
|
|
|
wl_fixed_t dx, dy;
|
|
|
|
|
};
|
|
|
|
|
|
2017-12-19 11:33:33 +03:00
|
|
|
|
struct weston_tablet_tool_move_grab {
|
|
|
|
|
struct shell_tablet_tool_grab base;
|
|
|
|
|
wl_fixed_t dx, dy;
|
|
|
|
|
};
|
|
|
|
|
|
2012-01-20 18:48:25 +04:00
|
|
|
|
struct rotate_grab {
|
2012-04-04 18:48:05 +04:00
|
|
|
|
struct shell_grab base;
|
2012-01-27 22:36:13 +04:00
|
|
|
|
struct weston_matrix rotation;
|
2012-01-20 18:48:25 +04:00
|
|
|
|
struct {
|
2012-09-30 04:57:21 +04:00
|
|
|
|
float x;
|
|
|
|
|
float y;
|
2012-01-20 18:48:25 +04:00
|
|
|
|
} center;
|
|
|
|
|
};
|
|
|
|
|
|
2013-03-26 00:42:45 +04:00
|
|
|
|
struct shell_seat {
|
|
|
|
|
struct weston_seat *seat;
|
|
|
|
|
struct wl_listener seat_destroy_listener;
|
2013-12-10 02:36:28 +04:00
|
|
|
|
struct weston_surface *focused_surface;
|
2013-03-26 00:42:45 +04:00
|
|
|
|
|
2014-04-22 04:42:58 +04:00
|
|
|
|
struct wl_listener caps_changed_listener;
|
|
|
|
|
struct wl_listener pointer_focus_listener;
|
|
|
|
|
struct wl_listener keyboard_focus_listener;
|
2017-12-19 11:33:33 +03:00
|
|
|
|
struct wl_listener tablet_tool_added_listener;
|
2021-08-26 16:37:24 +03:00
|
|
|
|
|
|
|
|
|
struct wl_list link; /** shell::seat_list */
|
2013-03-26 00:42:45 +04:00
|
|
|
|
};
|
|
|
|
|
|
2017-12-19 11:33:33 +03:00
|
|
|
|
struct tablet_tool_listener {
|
|
|
|
|
struct wl_listener base;
|
|
|
|
|
struct wl_listener removed_listener;
|
|
|
|
|
};
|
2014-02-12 00:22:51 +04:00
|
|
|
|
|
2022-02-14 23:57:08 +03:00
|
|
|
|
static struct weston_view *
|
|
|
|
|
shell_fade_create_fade_out_view(struct shell_surface *shsurf,
|
|
|
|
|
struct weston_surface *surface);
|
|
|
|
|
|
2012-04-17 13:20:49 +04:00
|
|
|
|
static struct desktop_shell *
|
|
|
|
|
shell_surface_get_shell(struct shell_surface *shsurf);
|
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
static void
|
|
|
|
|
set_busy_cursor(struct shell_surface *shsurf, struct weston_pointer *pointer);
|
|
|
|
|
|
2013-02-15 06:31:44 +04:00
|
|
|
|
static void
|
2015-07-15 21:00:39 +03:00
|
|
|
|
surface_rotate(struct shell_surface *surface, struct weston_pointer *pointer);
|
2013-02-15 06:31:44 +04:00
|
|
|
|
|
shell: wait for desktop-shell init before fade in
On Raspberry Pi, weston-desktop-shell is so slow to start, that the
compositor has time to run the fade-in before the wallpaper is up. The
user launching Weston sees the screen flipping to black, the fbcon
fading in, and then the desktop popping up.
To fix this, wait for the weston-desktop-shell to draw
everything before starting the initial fade-in. A new request is
added to the private desktop-shell protocol to signal it. If a
desktop-shell client does not support the new request, the fade-in
happens already at bind time.
If weston-desktop-shell crashes, or does not send the 'desktop_ready'
request in 15 seconds, the compositor will fade in anyway. This should
avoid a blocked screen in case weston-desktop-shell malfunction.
shell_fade_startup() does not directly start the fade-in but schedules
an idle callback, so that the compositor can process all pending events
before starting the fade clock. Otherwise (on RPi) we risk skipping part
of the animation. Yes, it is a hack, that should have been done in
window.c and weston-desktop-shell instead.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2013-05-22 19:03:09 +04:00
|
|
|
|
static void
|
|
|
|
|
shell_fade_startup(struct desktop_shell *shell);
|
|
|
|
|
|
2016-09-09 23:16:02 +03:00
|
|
|
|
static void
|
|
|
|
|
shell_fade(struct desktop_shell *shell, enum fade_type type);
|
|
|
|
|
|
2013-11-25 22:01:30 +04:00
|
|
|
|
static struct shell_seat *
|
|
|
|
|
get_shell_seat(struct weston_seat *seat);
|
|
|
|
|
|
2014-08-20 17:53:20 +04:00
|
|
|
|
static void
|
|
|
|
|
get_output_panel_size(struct desktop_shell *shell,
|
|
|
|
|
struct weston_output *output,
|
|
|
|
|
int *width, int *height);
|
2014-04-30 03:03:54 +04:00
|
|
|
|
|
2013-11-25 22:01:44 +04:00
|
|
|
|
static void
|
|
|
|
|
shell_surface_update_child_surface_layers(struct shell_surface *shsurf);
|
|
|
|
|
|
2012-04-04 18:48:05 +04:00
|
|
|
|
static void
|
2012-04-12 07:18:23 +04:00
|
|
|
|
destroy_shell_grab_shsurf(struct wl_listener *listener, void *data)
|
2012-04-04 18:48:05 +04:00
|
|
|
|
{
|
|
|
|
|
struct shell_grab *grab;
|
|
|
|
|
|
|
|
|
|
grab = container_of(listener, struct shell_grab,
|
|
|
|
|
shsurf_destroy_listener);
|
|
|
|
|
|
|
|
|
|
grab->shsurf = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-04 12:20:01 +04:00
|
|
|
|
struct weston_view *
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
get_default_view(struct weston_surface *surface)
|
|
|
|
|
{
|
|
|
|
|
struct shell_surface *shsurf;
|
|
|
|
|
struct weston_view *view;
|
|
|
|
|
|
|
|
|
|
if (!surface || wl_list_empty(&surface->views))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
shsurf = get_shell_surface(surface);
|
|
|
|
|
if (shsurf)
|
|
|
|
|
return shsurf->view;
|
|
|
|
|
|
|
|
|
|
wl_list_for_each(view, &surface->views, surface_link)
|
|
|
|
|
if (weston_view_is_mapped(view))
|
|
|
|
|
return view;
|
|
|
|
|
|
|
|
|
|
return container_of(surface->views.next, struct weston_view, surface_link);
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-10 18:50:50 +03:00
|
|
|
|
static void
|
|
|
|
|
desktop_shell_destroy_surface(struct shell_surface *shsurf)
|
|
|
|
|
{
|
|
|
|
|
struct shell_surface *shsurf_child, *tmp;
|
|
|
|
|
|
2022-05-17 17:49:35 +03:00
|
|
|
|
if (shsurf->fullscreen.black_view)
|
2022-11-22 14:28:57 +03:00
|
|
|
|
weston_shell_utils_curtain_destroy(shsurf->fullscreen.black_view);
|
2022-05-17 17:49:35 +03:00
|
|
|
|
|
2021-11-10 18:50:50 +03:00
|
|
|
|
wl_list_for_each_safe(shsurf_child, tmp, &shsurf->children_list, children_link) {
|
|
|
|
|
wl_list_remove(&shsurf_child->children_link);
|
|
|
|
|
wl_list_init(&shsurf_child->children_link);
|
|
|
|
|
}
|
|
|
|
|
wl_list_remove(&shsurf->children_link);
|
2022-05-05 15:32:27 +03:00
|
|
|
|
weston_desktop_surface_unlink_view(shsurf->view);
|
2022-05-13 20:11:46 +03:00
|
|
|
|
weston_view_destroy(shsurf->view);
|
2021-11-10 18:50:50 +03:00
|
|
|
|
|
|
|
|
|
wl_signal_emit(&shsurf->destroy_signal, shsurf);
|
libweston, desktop-shell: Add a wrapper for weston_surface reference
Similar to how we do it with drm_fb ref counts, increase a reference
count and return the same object.
Plug-in in desktop-shell when we map up the view in order to survive a
weston_surface destruction.
Astute readers will notice that this patch removes weston_view_destroy()
while keeping the balance between removing and adding a
weston_surface_unref() call in desktop_shell_destroy_surface().
The reason is to let weston_surface_unref() handle destruction on its
own. If multiple references are taken, then weston_surface_unref()
doesn't destroy the view, it just decreases the reference, with
a latter call to weston_surface_unref() to determine if the view
should be destroyed as well. This situation happens if we have
close animation enabled, were we have more than one reference taken: one
when mapping the view/surface and when when the surface itself was created,
(what we call, a weak reference).
If only a single reference is taken (for instance if we don't have close
animations enabled) then this weston_surface_unref()
call is inert as that reference is not set-up, leaving libweston to
handle the view destruction.
Following that with a weston_view_destroy() explicit call would cause a
UAF as the view was previous destroyed by a weston_surface_unref() call.
A side-effect of not keeping the weston_view_destroy() call would
happen when tearing down the compositor. If close animations are enabled,
weston_surface_unref() would not destroy the view, and because
weston_view_destroy() no longer exists, we would still have the
view in the other layers by the time we check-up if layers
have views present.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-02-14 23:42:22 +03:00
|
|
|
|
weston_surface_unref(shsurf->wsurface_anim_fade);
|
2021-11-10 18:50:50 +03:00
|
|
|
|
|
|
|
|
|
if (shsurf->output_destroy_listener.notify) {
|
|
|
|
|
wl_list_remove(&shsurf->output_destroy_listener.link);
|
|
|
|
|
shsurf->output_destroy_listener.notify = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
free(shsurf);
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-04 18:48:05 +04:00
|
|
|
|
static void
|
2012-06-28 19:08:05 +04:00
|
|
|
|
shell_grab_start(struct shell_grab *grab,
|
2013-05-07 06:15:05 +04:00
|
|
|
|
const struct weston_pointer_grab_interface *interface,
|
2012-06-28 19:08:05 +04:00
|
|
|
|
struct shell_surface *shsurf,
|
2013-05-07 06:15:05 +04:00
|
|
|
|
struct weston_pointer *pointer,
|
2015-11-17 11:00:33 +03:00
|
|
|
|
enum weston_desktop_shell_cursor cursor)
|
2012-04-04 18:48:05 +04:00
|
|
|
|
{
|
2012-06-28 19:08:05 +04:00
|
|
|
|
struct desktop_shell *shell = shsurf->shell;
|
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
weston_seat_break_desktop_grabs(pointer->seat);
|
2012-10-30 22:07:27 +04:00
|
|
|
|
|
2012-04-04 18:48:05 +04:00
|
|
|
|
grab->grab.interface = interface;
|
|
|
|
|
grab->shsurf = shsurf;
|
2012-04-12 07:18:23 +04:00
|
|
|
|
grab->shsurf_destroy_listener.notify = destroy_shell_grab_shsurf;
|
2013-06-14 19:07:54 +04:00
|
|
|
|
wl_signal_add(&shsurf->destroy_signal,
|
2012-04-12 07:18:23 +04:00
|
|
|
|
&grab->shsurf_destroy_listener);
|
2012-04-04 18:48:05 +04:00
|
|
|
|
|
2013-10-25 03:52:00 +04:00
|
|
|
|
shsurf->grabbed = 1;
|
2013-05-07 06:15:05 +04:00
|
|
|
|
weston_pointer_start_grab(pointer, &grab->grab);
|
2013-07-04 03:24:57 +04:00
|
|
|
|
if (shell->child.desktop_shell) {
|
2015-11-17 11:00:33 +03:00
|
|
|
|
weston_desktop_shell_send_grab_cursor(shell->child.desktop_shell,
|
2013-07-04 03:24:57 +04:00
|
|
|
|
cursor);
|
2022-10-28 22:06:24 +03:00
|
|
|
|
weston_pointer_set_focus(pointer,
|
|
|
|
|
get_default_view(shell->grab_surface));
|
2013-07-04 03:24:57 +04:00
|
|
|
|
}
|
2012-04-04 18:48:05 +04:00
|
|
|
|
}
|
|
|
|
|
|
2016-06-23 19:55:19 +03:00
|
|
|
|
static void
|
|
|
|
|
get_panel_size(struct desktop_shell *shell,
|
|
|
|
|
struct weston_view *view,
|
|
|
|
|
int *width,
|
|
|
|
|
int *height)
|
|
|
|
|
{
|
2022-02-09 02:31:55 +03:00
|
|
|
|
struct weston_coord_global a, b;
|
|
|
|
|
struct weston_coord_surface tmp_s;
|
|
|
|
|
|
|
|
|
|
tmp_s = weston_coord_surface(0, 0, view->surface);
|
|
|
|
|
a = weston_coord_surface_to_global(view, tmp_s);
|
|
|
|
|
|
|
|
|
|
tmp_s = weston_coord_surface(view->surface->width,
|
|
|
|
|
view->surface->height,
|
|
|
|
|
view->surface);
|
|
|
|
|
b = weston_coord_surface_to_global(view, tmp_s);
|
|
|
|
|
|
|
|
|
|
a.c = weston_coord_sub(b.c, a.c);
|
|
|
|
|
*width = a.c.x;
|
|
|
|
|
*height = a.c.y;
|
2016-06-23 19:55:19 +03:00
|
|
|
|
}
|
|
|
|
|
|
2014-08-20 17:53:20 +04:00
|
|
|
|
static void
|
|
|
|
|
get_output_panel_size(struct desktop_shell *shell,
|
|
|
|
|
struct weston_output *output,
|
|
|
|
|
int *width,
|
|
|
|
|
int *height)
|
shell: Centralize management of sending configure requests
Currently, there's a giant bug in how xdg-shell state management
is done. If a client calls set_fullscreen and then set_maximized,
it will get two configure events:
=> set_fullscreen
<= configure(800, 600, [STATE_FULLSCREEN])
=> set_maximized
<= configure(800, 560, [STATE_FULLSCREEN, STATE_MAXIMIZED])
Since fullscreen takes precedence over maximized, the client will
render full-screen at 800x600 first, and then 800x560 next. As
a result, the surface gets the wrong size.
This is because the code that sends out configure requests is
"immediate" -- when an app calls set_maximized, we immediately
send out the configure event that would have happened if we
transitioned immediately into maximized mode.
In wl_shell, this is correct behavior. However, in xdg-shell,
this is wrong. State needs to be more carefully managed in
xdg-shell, as states aren't exclusive.
Pull all the code that sends out configure events out and send
them centrally, based on Weston's on surface state management.
This should work with both wl_shell and xdg_shell's strategies.
2014-04-12 03:00:31 +04:00
|
|
|
|
{
|
|
|
|
|
struct weston_view *view;
|
2014-08-20 17:53:20 +04:00
|
|
|
|
|
|
|
|
|
*width = 0;
|
|
|
|
|
*height = 0;
|
shell: Centralize management of sending configure requests
Currently, there's a giant bug in how xdg-shell state management
is done. If a client calls set_fullscreen and then set_maximized,
it will get two configure events:
=> set_fullscreen
<= configure(800, 600, [STATE_FULLSCREEN])
=> set_maximized
<= configure(800, 560, [STATE_FULLSCREEN, STATE_MAXIMIZED])
Since fullscreen takes precedence over maximized, the client will
render full-screen at 800x600 first, and then 800x560 next. As
a result, the surface gets the wrong size.
This is because the code that sends out configure requests is
"immediate" -- when an app calls set_maximized, we immediately
send out the configure event that would have happened if we
transitioned immediately into maximized mode.
In wl_shell, this is correct behavior. However, in xdg-shell,
this is wrong. State needs to be more carefully managed in
xdg-shell, as states aren't exclusive.
Pull all the code that sends out configure events out and send
them centrally, based on Weston's on surface state management.
This should work with both wl_shell and xdg_shell's strategies.
2014-04-12 03:00:31 +04:00
|
|
|
|
|
|
|
|
|
if (!output)
|
2014-08-20 17:53:20 +04:00
|
|
|
|
return;
|
shell: Centralize management of sending configure requests
Currently, there's a giant bug in how xdg-shell state management
is done. If a client calls set_fullscreen and then set_maximized,
it will get two configure events:
=> set_fullscreen
<= configure(800, 600, [STATE_FULLSCREEN])
=> set_maximized
<= configure(800, 560, [STATE_FULLSCREEN, STATE_MAXIMIZED])
Since fullscreen takes precedence over maximized, the client will
render full-screen at 800x600 first, and then 800x560 next. As
a result, the surface gets the wrong size.
This is because the code that sends out configure requests is
"immediate" -- when an app calls set_maximized, we immediately
send out the configure event that would have happened if we
transitioned immediately into maximized mode.
In wl_shell, this is correct behavior. However, in xdg-shell,
this is wrong. State needs to be more carefully managed in
xdg-shell, as states aren't exclusive.
Pull all the code that sends out configure events out and send
them centrally, based on Weston's on surface state management.
This should work with both wl_shell and xdg_shell's strategies.
2014-04-12 03:00:31 +04:00
|
|
|
|
|
2014-07-09 23:12:56 +04:00
|
|
|
|
wl_list_for_each(view, &shell->panel_layer.view_list.link, layer_link.link) {
|
2016-06-23 19:55:19 +03:00
|
|
|
|
if (view->surface->output == output) {
|
|
|
|
|
get_panel_size(shell, view, width, height);
|
2014-08-20 17:53:20 +04:00
|
|
|
|
return;
|
shell: Centralize management of sending configure requests
Currently, there's a giant bug in how xdg-shell state management
is done. If a client calls set_fullscreen and then set_maximized,
it will get two configure events:
=> set_fullscreen
<= configure(800, 600, [STATE_FULLSCREEN])
=> set_maximized
<= configure(800, 560, [STATE_FULLSCREEN, STATE_MAXIMIZED])
Since fullscreen takes precedence over maximized, the client will
render full-screen at 800x600 first, and then 800x560 next. As
a result, the surface gets the wrong size.
This is because the code that sends out configure requests is
"immediate" -- when an app calls set_maximized, we immediately
send out the configure event that would have happened if we
transitioned immediately into maximized mode.
In wl_shell, this is correct behavior. However, in xdg-shell,
this is wrong. State needs to be more carefully managed in
xdg-shell, as states aren't exclusive.
Pull all the code that sends out configure events out and send
them centrally, based on Weston's on surface state management.
This should work with both wl_shell and xdg_shell's strategies.
2014-04-12 03:00:31 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-20 17:53:20 +04:00
|
|
|
|
/* the correct view wasn't found */
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-24 23:53:44 +03:00
|
|
|
|
void
|
2016-08-15 11:56:52 +03:00
|
|
|
|
get_output_work_area(struct desktop_shell *shell,
|
2014-08-20 17:53:20 +04:00
|
|
|
|
struct weston_output *output,
|
|
|
|
|
pixman_rectangle32_t *area)
|
|
|
|
|
{
|
|
|
|
|
int32_t panel_width = 0, panel_height = 0;
|
|
|
|
|
|
desktop-shell: handle NULL output in get_output_work_area()
This is a tentative crash fix for a case where there are no
enabled weston_outputs at all.
Let get_output_work_area() return a zero area if the given output is
NULL. If there is no output, there is no area. Unfortunately we cannot
return "no position" but have to use 0,0 instead.
In send_configure_for_surface(), this causes a maximized surface to
receive width=0 and height=0 in the configure event, which means the
client is free to choose the size. There is no correct size to send for
maximizing for no output.
In constrain_position(), this has no effect. The interactive move of a
surface is restricted to not go below the panel, so even if a user
managed to move a surface without an output, it just prevents the
surface moving beyond y=0.
In weston_view_set_initial_position(), get_output_work_area() will not
be called with NULL output anyway.
In set_maximized_position(), this makes it behave as if the output was
at 0,0 which is the default position of the first output.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Fabien Lahoudere <fabien.lahoudere@collabora.com>
Reviewed-by: Ian Ray <ian.ray@ge.com>
2018-05-02 11:21:55 +03:00
|
|
|
|
if (!output) {
|
|
|
|
|
area->x = 0;
|
|
|
|
|
area->y = 0;
|
|
|
|
|
area->width = 0;
|
|
|
|
|
area->height = 0;
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-15 20:23:54 +03:00
|
|
|
|
area->x = output->x;
|
|
|
|
|
area->y = output->y;
|
2014-08-20 17:53:20 +04:00
|
|
|
|
|
|
|
|
|
get_output_panel_size(shell, output, &panel_width, &panel_height);
|
|
|
|
|
switch (shell->panel_position) {
|
2015-11-17 11:00:33 +03:00
|
|
|
|
case WESTON_DESKTOP_SHELL_PANEL_POSITION_TOP:
|
2014-08-20 17:53:20 +04:00
|
|
|
|
default:
|
2015-04-15 20:23:54 +03:00
|
|
|
|
area->y += panel_height;
|
2017-03-13 19:31:36 +03:00
|
|
|
|
/* fallthrough */
|
2015-11-17 11:00:33 +03:00
|
|
|
|
case WESTON_DESKTOP_SHELL_PANEL_POSITION_BOTTOM:
|
2014-08-20 17:53:20 +04:00
|
|
|
|
area->width = output->width;
|
|
|
|
|
area->height = output->height - panel_height;
|
|
|
|
|
break;
|
2015-11-17 11:00:33 +03:00
|
|
|
|
case WESTON_DESKTOP_SHELL_PANEL_POSITION_LEFT:
|
2015-04-15 20:23:54 +03:00
|
|
|
|
area->x += panel_width;
|
2017-03-13 19:31:36 +03:00
|
|
|
|
/* fallthrough */
|
2015-11-17 11:00:33 +03:00
|
|
|
|
case WESTON_DESKTOP_SHELL_PANEL_POSITION_RIGHT:
|
2014-08-20 17:53:20 +04:00
|
|
|
|
area->width = output->width - panel_width;
|
|
|
|
|
area->height = output->height;
|
|
|
|
|
break;
|
|
|
|
|
}
|
shell: Centralize management of sending configure requests
Currently, there's a giant bug in how xdg-shell state management
is done. If a client calls set_fullscreen and then set_maximized,
it will get two configure events:
=> set_fullscreen
<= configure(800, 600, [STATE_FULLSCREEN])
=> set_maximized
<= configure(800, 560, [STATE_FULLSCREEN, STATE_MAXIMIZED])
Since fullscreen takes precedence over maximized, the client will
render full-screen at 800x600 first, and then 800x560 next. As
a result, the surface gets the wrong size.
This is because the code that sends out configure requests is
"immediate" -- when an app calls set_maximized, we immediately
send out the configure event that would have happened if we
transitioned immediately into maximized mode.
In wl_shell, this is correct behavior. However, in xdg-shell,
this is wrong. State needs to be more carefully managed in
xdg-shell, as states aren't exclusive.
Pull all the code that sends out configure events out and send
them centrally, based on Weston's on surface state management.
This should work with both wl_shell and xdg_shell's strategies.
2014-04-12 03:00:31 +04:00
|
|
|
|
}
|
|
|
|
|
|
2012-04-04 18:48:05 +04:00
|
|
|
|
static void
|
2012-06-28 19:08:05 +04:00
|
|
|
|
shell_grab_end(struct shell_grab *grab)
|
2012-04-04 18:48:05 +04:00
|
|
|
|
{
|
2013-10-25 03:52:00 +04:00
|
|
|
|
if (grab->shsurf) {
|
2012-06-08 02:08:04 +04:00
|
|
|
|
wl_list_remove(&grab->shsurf_destroy_listener.link);
|
2013-10-25 03:52:00 +04:00
|
|
|
|
grab->shsurf->grabbed = 0;
|
2014-05-06 16:50:47 +04:00
|
|
|
|
|
|
|
|
|
if (grab->shsurf->resize_edges) {
|
|
|
|
|
grab->shsurf->resize_edges = 0;
|
|
|
|
|
}
|
2013-10-25 03:52:00 +04:00
|
|
|
|
}
|
2012-06-28 19:08:05 +04:00
|
|
|
|
|
2013-07-23 03:31:53 +04:00
|
|
|
|
weston_pointer_end_grab(grab->grab.pointer);
|
2012-04-04 18:48:05 +04:00
|
|
|
|
}
|
|
|
|
|
|
2013-08-15 20:10:08 +04:00
|
|
|
|
static void
|
|
|
|
|
shell_touch_grab_start(struct shell_touch_grab *grab,
|
|
|
|
|
const struct weston_touch_grab_interface *interface,
|
|
|
|
|
struct shell_surface *shsurf,
|
|
|
|
|
struct weston_touch *touch)
|
|
|
|
|
{
|
|
|
|
|
struct desktop_shell *shell = shsurf->shell;
|
2014-01-17 22:08:25 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
weston_seat_break_desktop_grabs(touch->seat);
|
2014-04-30 02:01:16 +04:00
|
|
|
|
|
2013-08-15 20:10:08 +04:00
|
|
|
|
grab->grab.interface = interface;
|
|
|
|
|
grab->shsurf = shsurf;
|
|
|
|
|
grab->shsurf_destroy_listener.notify = destroy_shell_grab_shsurf;
|
|
|
|
|
wl_signal_add(&shsurf->destroy_signal,
|
|
|
|
|
&grab->shsurf_destroy_listener);
|
|
|
|
|
|
|
|
|
|
grab->touch = touch;
|
2013-10-25 03:52:00 +04:00
|
|
|
|
shsurf->grabbed = 1;
|
2013-08-15 20:10:08 +04:00
|
|
|
|
|
|
|
|
|
weston_touch_start_grab(touch, &grab->grab);
|
|
|
|
|
if (shell->child.desktop_shell)
|
2015-05-01 00:45:41 +03:00
|
|
|
|
weston_touch_set_focus(touch,
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
get_default_view(shell->grab_surface));
|
2013-08-15 20:10:08 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
shell_touch_grab_end(struct shell_touch_grab *grab)
|
|
|
|
|
{
|
2013-10-25 03:52:00 +04:00
|
|
|
|
if (grab->shsurf) {
|
2013-08-15 20:10:08 +04:00
|
|
|
|
wl_list_remove(&grab->shsurf_destroy_listener.link);
|
2013-10-25 03:52:00 +04:00
|
|
|
|
grab->shsurf->grabbed = 0;
|
|
|
|
|
}
|
2013-08-15 20:10:08 +04:00
|
|
|
|
|
|
|
|
|
weston_touch_end_grab(grab->touch);
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-19 11:33:33 +03:00
|
|
|
|
static void
|
|
|
|
|
shell_tablet_tool_grab_start(struct shell_tablet_tool_grab *grab,
|
|
|
|
|
const struct weston_tablet_tool_grab_interface *interface,
|
|
|
|
|
struct shell_surface *shsurf,
|
|
|
|
|
struct weston_tablet_tool *tool)
|
|
|
|
|
{
|
|
|
|
|
struct desktop_shell *shell = shsurf->shell;
|
|
|
|
|
|
|
|
|
|
weston_seat_break_desktop_grabs(tool->seat);
|
|
|
|
|
|
|
|
|
|
grab->grab.interface = interface;
|
|
|
|
|
grab->shsurf = shsurf;
|
|
|
|
|
grab->shsurf_destroy_listener.notify = destroy_shell_grab_shsurf;
|
|
|
|
|
wl_signal_add(&shsurf->destroy_signal, &grab->shsurf_destroy_listener);
|
|
|
|
|
|
|
|
|
|
grab->tool = tool;
|
|
|
|
|
shsurf->grabbed = 1;
|
|
|
|
|
|
|
|
|
|
weston_tablet_tool_start_grab(tool, &grab->grab);
|
|
|
|
|
if (shell->child.desktop_shell)
|
|
|
|
|
weston_tablet_tool_set_focus(tool,
|
|
|
|
|
get_default_view(shell->grab_surface),
|
|
|
|
|
0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
shell_tablet_tool_grab_end(struct shell_tablet_tool_grab *grab)
|
|
|
|
|
{
|
|
|
|
|
if (grab->shsurf) {
|
|
|
|
|
wl_list_remove(&grab->shsurf_destroy_listener.link);
|
|
|
|
|
grab->shsurf->grabbed = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
weston_tablet_tool_end_grab(grab->tool);
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-25 15:09:52 +04:00
|
|
|
|
static enum animation_type
|
|
|
|
|
get_animation_type(char *animation)
|
|
|
|
|
{
|
2014-01-16 02:26:31 +04:00
|
|
|
|
if (!animation)
|
|
|
|
|
return ANIMATION_NONE;
|
|
|
|
|
|
2012-04-25 15:09:52 +04:00
|
|
|
|
if (!strcmp("zoom", animation))
|
|
|
|
|
return ANIMATION_ZOOM;
|
|
|
|
|
else if (!strcmp("fade", animation))
|
|
|
|
|
return ANIMATION_FADE;
|
animation, shell: add kbd focus change animation
When enabled, this will make all but the keyboard-focused window dim.
Also the background gets dimmed, if there are any windows open. The
panel is not dimmed.
When the keyboard focus changes, the change in dimming is animated.
The dimming is implemented with transparent solid-color surfaces, two at
most. The net effect of two overlapping dim surfaces is kept constant
during animations (stable fade animation).
There is a new weston.ini option "focus-animation", that defaults to
none, and can be set to "dim-layer" to enable the focus change
animation.
[pq: Sliced, squashed, and rebased the patch series. Fixed surface alpha
interaction with the switcher. Wrote the commit message.]
[pochu: rebased, ported to weston_view]
2013-11-19 14:37:11 +04:00
|
|
|
|
else if (!strcmp("dim-layer", animation))
|
|
|
|
|
return ANIMATION_DIM_LAYER;
|
2012-04-25 15:09:52 +04:00
|
|
|
|
else
|
|
|
|
|
return ANIMATION_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-26 01:57:11 +04:00
|
|
|
|
static void
|
2013-05-27 05:48:14 +04:00
|
|
|
|
shell_configuration(struct desktop_shell *shell)
|
2011-12-07 13:49:52 +04:00
|
|
|
|
{
|
2013-05-24 05:40:56 +04:00
|
|
|
|
struct weston_config_section *section;
|
2022-08-01 17:03:03 +03:00
|
|
|
|
struct weston_config *config;
|
2014-08-21 20:32:38 +04:00
|
|
|
|
char *s, *client;
|
2019-11-26 03:14:24 +03:00
|
|
|
|
bool allow_zap;
|
2013-05-24 05:40:56 +04:00
|
|
|
|
|
2022-08-01 17:03:03 +03:00
|
|
|
|
config = wet_get_config(shell->compositor);
|
|
|
|
|
section = weston_config_get_section(config, "shell", NULL, NULL);
|
2018-12-15 16:51:57 +03:00
|
|
|
|
client = wet_get_libexec_path(WESTON_SHELL_CLIENT);
|
2016-11-24 23:45:45 +03:00
|
|
|
|
weston_config_section_get_string(section, "client", &s, client);
|
2014-08-21 20:32:38 +04:00
|
|
|
|
free(client);
|
2013-11-20 16:22:29 +04:00
|
|
|
|
shell->client = s;
|
2016-01-12 13:21:48 +03:00
|
|
|
|
|
|
|
|
|
weston_config_section_get_bool(section,
|
|
|
|
|
"allow-zap", &allow_zap, true);
|
|
|
|
|
shell->allow_zap = allow_zap;
|
|
|
|
|
|
2022-11-22 14:48:13 +03:00
|
|
|
|
shell->binding_modifier = weston_config_get_binding_modifier(config, MODIFIER_SUPER);
|
2014-01-17 04:51:52 +04:00
|
|
|
|
|
2013-05-24 05:40:56 +04:00
|
|
|
|
weston_config_section_get_string(section, "animation", &s, "none");
|
|
|
|
|
shell->win_animation_type = get_animation_type(s);
|
2013-06-18 11:11:03 +04:00
|
|
|
|
free(s);
|
2014-08-12 17:13:30 +04:00
|
|
|
|
weston_config_section_get_string(section, "close-animation", &s, "fade");
|
|
|
|
|
shell->win_close_animation_type = get_animation_type(s);
|
|
|
|
|
free(s);
|
2013-10-16 22:38:24 +04:00
|
|
|
|
weston_config_section_get_string(section,
|
|
|
|
|
"startup-animation", &s, "fade");
|
|
|
|
|
shell->startup_animation_type = get_animation_type(s);
|
|
|
|
|
free(s);
|
2013-10-30 19:59:55 +04:00
|
|
|
|
if (shell->startup_animation_type == ANIMATION_ZOOM)
|
|
|
|
|
shell->startup_animation_type = ANIMATION_NONE;
|
animation, shell: add kbd focus change animation
When enabled, this will make all but the keyboard-focused window dim.
Also the background gets dimmed, if there are any windows open. The
panel is not dimmed.
When the keyboard focus changes, the change in dimming is animated.
The dimming is implemented with transparent solid-color surfaces, two at
most. The net effect of two overlapping dim surfaces is kept constant
during animations (stable fade animation).
There is a new weston.ini option "focus-animation", that defaults to
none, and can be set to "dim-layer" to enable the focus change
animation.
[pq: Sliced, squashed, and rebased the patch series. Fixed surface alpha
interaction with the switcher. Wrote the commit message.]
[pochu: rebased, ported to weston_view]
2013-11-19 14:37:11 +04:00
|
|
|
|
weston_config_section_get_string(section, "focus-animation", &s, "none");
|
|
|
|
|
shell->focus_animation_type = get_animation_type(s);
|
|
|
|
|
free(s);
|
2012-06-13 02:01:22 +04:00
|
|
|
|
}
|
|
|
|
|
|
compositor: add weston_surface_set_label_func()
When printing out logs from Weston's actions, mainly for debugging, it
can be very difficult to identify the different surfaces. Inspecting
the configure function pointer is not useful, as the configure functions
may live in modules.
Add vfunc get_label to weston_surface, which will produce a short,
human-readable description of the surface, which allows identifying it
better, rather than just looking at the surface size, for instance.
Set the label function from most parts of Weston, to identify cursors and
drag icons, and panels, backgrounds, screensavers and lock surfaces, and
the desktop shell's application surfaces.
v2: renamed 'description' to 'label', so we get
weston_surface_set_label_func().
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-08-06 20:36:51 +04:00
|
|
|
|
static int
|
|
|
|
|
focus_surface_get_label(struct weston_surface *surface, char *buf, size_t len)
|
|
|
|
|
{
|
|
|
|
|
return snprintf(buf, len, "focus highlight effect for output %s",
|
2019-09-25 21:23:13 +03:00
|
|
|
|
(surface->output ? surface->output->name : "NULL"));
|
compositor: add weston_surface_set_label_func()
When printing out logs from Weston's actions, mainly for debugging, it
can be very difficult to identify the different surfaces. Inspecting
the configure function pointer is not useful, as the configure functions
may live in modules.
Add vfunc get_label to weston_surface, which will produce a short,
human-readable description of the surface, which allows identifying it
better, rather than just looking at the surface size, for instance.
Set the label function from most parts of Weston, to identify cursors and
drag icons, and panels, backgrounds, screensavers and lock surfaces, and
the desktop shell's application surfaces.
v2: renamed 'description' to 'label', so we get
weston_surface_set_label_func().
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-08-06 20:36:51 +04:00
|
|
|
|
}
|
animation, shell: add kbd focus change animation
When enabled, this will make all but the keyboard-focused window dim.
Also the background gets dimmed, if there are any windows open. The
panel is not dimmed.
When the keyboard focus changes, the change in dimming is animated.
The dimming is implemented with transparent solid-color surfaces, two at
most. The net effect of two overlapping dim surfaces is kept constant
during animations (stable fade animation).
There is a new weston.ini option "focus-animation", that defaults to
none, and can be set to "dim-layer" to enable the focus change
animation.
[pq: Sliced, squashed, and rebased the patch series. Fixed surface alpha
interaction with the switcher. Wrote the commit message.]
[pochu: rebased, ported to weston_view]
2013-11-19 14:37:11 +04:00
|
|
|
|
|
|
|
|
|
/* no-op func for checking focus surface */
|
|
|
|
|
static void
|
2022-02-04 17:02:26 +03:00
|
|
|
|
focus_surface_committed(struct weston_surface *es,
|
|
|
|
|
struct weston_coord_surface new_origin)
|
animation, shell: add kbd focus change animation
When enabled, this will make all but the keyboard-focused window dim.
Also the background gets dimmed, if there are any windows open. The
panel is not dimmed.
When the keyboard focus changes, the change in dimming is animated.
The dimming is implemented with transparent solid-color surfaces, two at
most. The net effect of two overlapping dim surfaces is kept constant
during animations (stable fade animation).
There is a new weston.ini option "focus-animation", that defaults to
none, and can be set to "dim-layer" to enable the focus change
animation.
[pq: Sliced, squashed, and rebased the patch series. Fixed surface alpha
interaction with the switcher. Wrote the commit message.]
[pochu: rebased, ported to weston_view]
2013-11-19 14:37:11 +04:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool
|
|
|
|
|
is_focus_view (struct weston_view *view)
|
|
|
|
|
{
|
2022-01-18 22:00:33 +03:00
|
|
|
|
return (view->surface->committed == focus_surface_committed);
|
animation, shell: add kbd focus change animation
When enabled, this will make all but the keyboard-focused window dim.
Also the background gets dimmed, if there are any windows open. The
panel is not dimmed.
When the keyboard focus changes, the change in dimming is animated.
The dimming is implemented with transparent solid-color surfaces, two at
most. The net effect of two overlapping dim surfaces is kept constant
during animations (stable fade animation).
There is a new weston.ini option "focus-animation", that defaults to
none, and can be set to "dim-layer" to enable the focus change
animation.
[pq: Sliced, squashed, and rebased the patch series. Fixed surface alpha
interaction with the switcher. Wrote the commit message.]
[pochu: rebased, ported to weston_view]
2013-11-19 14:37:11 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static struct focus_surface *
|
|
|
|
|
create_focus_surface(struct weston_compositor *ec,
|
|
|
|
|
struct weston_output *output)
|
|
|
|
|
{
|
|
|
|
|
struct focus_surface *fsurf = NULL;
|
2022-01-18 22:00:33 +03:00
|
|
|
|
struct weston_curtain_params curtain_params = {
|
|
|
|
|
.r = 0.0, .g = 0.0, .b = 0.0, .a = 1.0,
|
|
|
|
|
.x = output->x, .y = output->y,
|
|
|
|
|
.width = output->width, .height = output->height,
|
|
|
|
|
.surface_committed = focus_surface_committed,
|
|
|
|
|
.get_label = focus_surface_get_label,
|
|
|
|
|
.surface_private = NULL,
|
|
|
|
|
.capture_input = false,
|
|
|
|
|
};
|
animation, shell: add kbd focus change animation
When enabled, this will make all but the keyboard-focused window dim.
Also the background gets dimmed, if there are any windows open. The
panel is not dimmed.
When the keyboard focus changes, the change in dimming is animated.
The dimming is implemented with transparent solid-color surfaces, two at
most. The net effect of two overlapping dim surfaces is kept constant
during animations (stable fade animation).
There is a new weston.ini option "focus-animation", that defaults to
none, and can be set to "dim-layer" to enable the focus change
animation.
[pq: Sliced, squashed, and rebased the patch series. Fixed surface alpha
interaction with the switcher. Wrote the commit message.]
[pochu: rebased, ported to weston_view]
2013-11-19 14:37:11 +04:00
|
|
|
|
|
|
|
|
|
fsurf = malloc(sizeof *fsurf);
|
|
|
|
|
if (!fsurf)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2022-01-18 22:00:33 +03:00
|
|
|
|
curtain_params.surface_private = fsurf;
|
animation, shell: add kbd focus change animation
When enabled, this will make all but the keyboard-focused window dim.
Also the background gets dimmed, if there are any windows open. The
panel is not dimmed.
When the keyboard focus changes, the change in dimming is animated.
The dimming is implemented with transparent solid-color surfaces, two at
most. The net effect of two overlapping dim surfaces is kept constant
during animations (stable fade animation).
There is a new weston.ini option "focus-animation", that defaults to
none, and can be set to "dim-layer" to enable the focus change
animation.
[pq: Sliced, squashed, and rebased the patch series. Fixed surface alpha
interaction with the switcher. Wrote the commit message.]
[pochu: rebased, ported to weston_view]
2013-11-19 14:37:11 +04:00
|
|
|
|
|
2022-11-22 14:28:57 +03:00
|
|
|
|
fsurf->curtain = weston_shell_utils_curtain_create(ec, &curtain_params);
|
2022-01-17 17:24:03 +03:00
|
|
|
|
weston_view_set_output(fsurf->curtain->view, output);
|
|
|
|
|
fsurf->curtain->view->is_mapped = true;
|
animation, shell: add kbd focus change animation
When enabled, this will make all but the keyboard-focused window dim.
Also the background gets dimmed, if there are any windows open. The
panel is not dimmed.
When the keyboard focus changes, the change in dimming is animated.
The dimming is implemented with transparent solid-color surfaces, two at
most. The net effect of two overlapping dim surfaces is kept constant
during animations (stable fade animation).
There is a new weston.ini option "focus-animation", that defaults to
none, and can be set to "dim-layer" to enable the focus change
animation.
[pq: Sliced, squashed, and rebased the patch series. Fixed surface alpha
interaction with the switcher. Wrote the commit message.]
[pochu: rebased, ported to weston_view]
2013-11-19 14:37:11 +04:00
|
|
|
|
|
|
|
|
|
return fsurf;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
focus_surface_destroy(struct focus_surface *fsurf)
|
|
|
|
|
{
|
2022-11-22 14:28:57 +03:00
|
|
|
|
weston_shell_utils_curtain_destroy(fsurf->curtain);
|
animation, shell: add kbd focus change animation
When enabled, this will make all but the keyboard-focused window dim.
Also the background gets dimmed, if there are any windows open. The
panel is not dimmed.
When the keyboard focus changes, the change in dimming is animated.
The dimming is implemented with transparent solid-color surfaces, two at
most. The net effect of two overlapping dim surfaces is kept constant
during animations (stable fade animation).
There is a new weston.ini option "focus-animation", that defaults to
none, and can be set to "dim-layer" to enable the focus change
animation.
[pq: Sliced, squashed, and rebased the patch series. Fixed surface alpha
interaction with the switcher. Wrote the commit message.]
[pochu: rebased, ported to weston_view]
2013-11-19 14:37:11 +04:00
|
|
|
|
free(fsurf);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
focus_animation_done(struct weston_view_animation *animation, void *data)
|
|
|
|
|
{
|
|
|
|
|
struct workspace *ws = data;
|
|
|
|
|
|
|
|
|
|
ws->focus_animation = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-13 02:01:24 +04:00
|
|
|
|
static void
|
|
|
|
|
focus_state_destroy(struct focus_state *state)
|
|
|
|
|
{
|
|
|
|
|
wl_list_remove(&state->seat_destroy_listener.link);
|
|
|
|
|
wl_list_remove(&state->surface_destroy_listener.link);
|
|
|
|
|
free(state);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
focus_state_seat_destroy(struct wl_listener *listener, void *data)
|
|
|
|
|
{
|
|
|
|
|
struct focus_state *state = container_of(listener,
|
|
|
|
|
struct focus_state,
|
|
|
|
|
seat_destroy_listener);
|
|
|
|
|
|
|
|
|
|
wl_list_remove(&state->link);
|
|
|
|
|
focus_state_destroy(state);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
focus_state_surface_destroy(struct wl_listener *listener, void *data)
|
|
|
|
|
{
|
|
|
|
|
struct focus_state *state = container_of(listener,
|
|
|
|
|
struct focus_state,
|
2012-07-31 18:30:26 +04:00
|
|
|
|
surface_destroy_listener);
|
2014-10-18 15:24:53 +04:00
|
|
|
|
struct weston_surface *main_surface;
|
|
|
|
|
struct weston_view *next;
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
struct weston_view *view;
|
2012-08-01 01:29:30 +04:00
|
|
|
|
|
shell: keyboard focus and restacking fixes for sub-surfaces
The shell needs to redirect some actions to the parent surface, when
they originally target a sub-surface. This patch implements the
following:
- Move, resize, and rotate bindings always target the parent surface.
- Opacity (full-surface alpha) binding targets the parent surface. This
is broken, because it should change the opacity of the whole compound
window, which is difficult to implement in the renderer.
- click_to_activate_binding() needs to check the shell surface type from
the main surface, because sub-surface would produce SHELL_SURFACE_NONE
and prevent activation.
- Also activate() needs to check the type from the main surface, and
restack the main surface. Keyboard focus is assigned to the original
(sub-)surface.
- focus_state_surface_destroy() needs to handle sub-surfaces: only the
main surface will be in a layer list. If the destroyed surface is
indeed a sub-surface, activate the main surface next. This way a
client that destroys a focused sub-surface still retains focus in the
same window.
- The workspace_manager.move_surface request can accept also
sub-surfaces, and it will move the corresponding main surface.
Changes in v2:
- do not special-case keyboard focus for sub-surfaces
- fix surface type checks for sub-surfaces in shell, fix restacking of
sub-surfaces in shell, fix focus_state_surface_destroy()
Changes in v3:
- Renamed weston_surface_get_parent() to
weston_surface_get_main_surface() to be more explicit that this is
about sub-surfaces
- Fixed move_surface_to_workspace() to handle keyboard focus on a
sub-surface.
- Used a temporary variable in several places to clarify code, instead
of reassigning a variable.
- Fixed workspace_manager_move_surface() to deal with sub-surfaces.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:44 +04:00
|
|
|
|
main_surface = weston_surface_get_main_surface(state->keyboard_focus);
|
|
|
|
|
|
2012-08-01 01:29:30 +04:00
|
|
|
|
next = NULL;
|
2014-07-09 23:12:56 +04:00
|
|
|
|
wl_list_for_each(view,
|
|
|
|
|
&state->ws->layer.view_list.link, layer_link.link) {
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
if (view->surface == main_surface)
|
2012-08-01 01:29:30 +04:00
|
|
|
|
continue;
|
animation, shell: add kbd focus change animation
When enabled, this will make all but the keyboard-focused window dim.
Also the background gets dimmed, if there are any windows open. The
panel is not dimmed.
When the keyboard focus changes, the change in dimming is animated.
The dimming is implemented with transparent solid-color surfaces, two at
most. The net effect of two overlapping dim surfaces is kept constant
during animations (stable fade animation).
There is a new weston.ini option "focus-animation", that defaults to
none, and can be set to "dim-layer" to enable the focus change
animation.
[pq: Sliced, squashed, and rebased the patch series. Fixed surface alpha
interaction with the switcher. Wrote the commit message.]
[pochu: rebased, ported to weston_view]
2013-11-19 14:37:11 +04:00
|
|
|
|
if (is_focus_view(view))
|
|
|
|
|
continue;
|
2016-08-12 11:41:36 +03:00
|
|
|
|
if (!get_shell_surface(view->surface))
|
|
|
|
|
continue;
|
2012-08-01 01:29:30 +04:00
|
|
|
|
|
2014-10-18 15:24:53 +04:00
|
|
|
|
next = view;
|
2012-08-01 01:29:30 +04:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
shell: keyboard focus and restacking fixes for sub-surfaces
The shell needs to redirect some actions to the parent surface, when
they originally target a sub-surface. This patch implements the
following:
- Move, resize, and rotate bindings always target the parent surface.
- Opacity (full-surface alpha) binding targets the parent surface. This
is broken, because it should change the opacity of the whole compound
window, which is difficult to implement in the renderer.
- click_to_activate_binding() needs to check the shell surface type from
the main surface, because sub-surface would produce SHELL_SURFACE_NONE
and prevent activation.
- Also activate() needs to check the type from the main surface, and
restack the main surface. Keyboard focus is assigned to the original
(sub-)surface.
- focus_state_surface_destroy() needs to handle sub-surfaces: only the
main surface will be in a layer list. If the destroyed surface is
indeed a sub-surface, activate the main surface next. This way a
client that destroys a focused sub-surface still retains focus in the
same window.
- The workspace_manager.move_surface request can accept also
sub-surfaces, and it will move the corresponding main surface.
Changes in v2:
- do not special-case keyboard focus for sub-surfaces
- fix surface type checks for sub-surfaces in shell, fix restacking of
sub-surfaces in shell, fix focus_state_surface_destroy()
Changes in v3:
- Renamed weston_surface_get_parent() to
weston_surface_get_main_surface() to be more explicit that this is
about sub-surfaces
- Fixed move_surface_to_workspace() to handle keyboard focus on a
sub-surface.
- Used a temporary variable in several places to clarify code, instead
of reassigning a variable.
- Fixed workspace_manager_move_surface() to deal with sub-surfaces.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:44 +04:00
|
|
|
|
/* if the focus was a sub-surface, activate its main surface */
|
|
|
|
|
if (main_surface != state->keyboard_focus)
|
2014-10-18 15:24:53 +04:00
|
|
|
|
next = get_default_view(main_surface);
|
shell: keyboard focus and restacking fixes for sub-surfaces
The shell needs to redirect some actions to the parent surface, when
they originally target a sub-surface. This patch implements the
following:
- Move, resize, and rotate bindings always target the parent surface.
- Opacity (full-surface alpha) binding targets the parent surface. This
is broken, because it should change the opacity of the whole compound
window, which is difficult to implement in the renderer.
- click_to_activate_binding() needs to check the shell surface type from
the main surface, because sub-surface would produce SHELL_SURFACE_NONE
and prevent activation.
- Also activate() needs to check the type from the main surface, and
restack the main surface. Keyboard focus is assigned to the original
(sub-)surface.
- focus_state_surface_destroy() needs to handle sub-surfaces: only the
main surface will be in a layer list. If the destroyed surface is
indeed a sub-surface, activate the main surface next. This way a
client that destroys a focused sub-surface still retains focus in the
same window.
- The workspace_manager.move_surface request can accept also
sub-surfaces, and it will move the corresponding main surface.
Changes in v2:
- do not special-case keyboard focus for sub-surfaces
- fix surface type checks for sub-surfaces in shell, fix restacking of
sub-surfaces in shell, fix focus_state_surface_destroy()
Changes in v3:
- Renamed weston_surface_get_parent() to
weston_surface_get_main_surface() to be more explicit that this is
about sub-surfaces
- Fixed move_surface_to_workspace() to handle keyboard focus on a
sub-surface.
- Used a temporary variable in several places to clarify code, instead
of reassigning a variable.
- Fixed workspace_manager_move_surface() to deal with sub-surfaces.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:44 +04:00
|
|
|
|
|
2012-08-01 01:29:30 +04:00
|
|
|
|
if (next) {
|
2018-12-07 01:33:34 +03:00
|
|
|
|
if (state->keyboard_focus) {
|
|
|
|
|
wl_list_remove(&state->surface_destroy_listener.link);
|
|
|
|
|
wl_list_init(&state->surface_destroy_listener.link);
|
|
|
|
|
}
|
animation, shell: add kbd focus change animation
When enabled, this will make all but the keyboard-focused window dim.
Also the background gets dimmed, if there are any windows open. The
panel is not dimmed.
When the keyboard focus changes, the change in dimming is animated.
The dimming is implemented with transparent solid-color surfaces, two at
most. The net effect of two overlapping dim surfaces is kept constant
during animations (stable fade animation).
There is a new weston.ini option "focus-animation", that defaults to
none, and can be set to "dim-layer" to enable the focus change
animation.
[pq: Sliced, squashed, and rebased the patch series. Fixed surface alpha
interaction with the switcher. Wrote the commit message.]
[pochu: rebased, ported to weston_view]
2013-11-19 14:37:11 +04:00
|
|
|
|
state->keyboard_focus = NULL;
|
2016-08-15 11:56:52 +03:00
|
|
|
|
activate(state->shell, next, state->seat,
|
2014-10-18 20:20:16 +04:00
|
|
|
|
WESTON_ACTIVATE_FLAG_CONFIGURE);
|
2012-08-01 01:29:30 +04:00
|
|
|
|
} else {
|
2016-08-15 11:56:52 +03:00
|
|
|
|
if (state->shell->focus_animation_type == ANIMATION_DIM_LAYER) {
|
animation, shell: add kbd focus change animation
When enabled, this will make all but the keyboard-focused window dim.
Also the background gets dimmed, if there are any windows open. The
panel is not dimmed.
When the keyboard focus changes, the change in dimming is animated.
The dimming is implemented with transparent solid-color surfaces, two at
most. The net effect of two overlapping dim surfaces is kept constant
during animations (stable fade animation).
There is a new weston.ini option "focus-animation", that defaults to
none, and can be set to "dim-layer" to enable the focus change
animation.
[pq: Sliced, squashed, and rebased the patch series. Fixed surface alpha
interaction with the switcher. Wrote the commit message.]
[pochu: rebased, ported to weston_view]
2013-11-19 14:37:11 +04:00
|
|
|
|
if (state->ws->focus_animation)
|
|
|
|
|
weston_view_animation_destroy(state->ws->focus_animation);
|
|
|
|
|
|
|
|
|
|
state->ws->focus_animation = weston_fade_run(
|
2022-01-17 17:24:03 +03:00
|
|
|
|
state->ws->fsurf_front->curtain->view,
|
|
|
|
|
state->ws->fsurf_front->curtain->view->alpha, 0.0, 300,
|
animation, shell: add kbd focus change animation
When enabled, this will make all but the keyboard-focused window dim.
Also the background gets dimmed, if there are any windows open. The
panel is not dimmed.
When the keyboard focus changes, the change in dimming is animated.
The dimming is implemented with transparent solid-color surfaces, two at
most. The net effect of two overlapping dim surfaces is kept constant
during animations (stable fade animation).
There is a new weston.ini option "focus-animation", that defaults to
none, and can be set to "dim-layer" to enable the focus change
animation.
[pq: Sliced, squashed, and rebased the patch series. Fixed surface alpha
interaction with the switcher. Wrote the commit message.]
[pochu: rebased, ported to weston_view]
2013-11-19 14:37:11 +04:00
|
|
|
|
focus_animation_done, state->ws);
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-01 01:29:30 +04:00
|
|
|
|
wl_list_remove(&state->link);
|
|
|
|
|
focus_state_destroy(state);
|
|
|
|
|
}
|
2012-06-13 02:01:24 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static struct focus_state *
|
2016-08-15 11:56:52 +03:00
|
|
|
|
focus_state_create(struct desktop_shell *shell, struct weston_seat *seat,
|
|
|
|
|
struct workspace *ws)
|
2012-06-13 02:01:24 +04:00
|
|
|
|
{
|
|
|
|
|
struct focus_state *state;
|
|
|
|
|
|
|
|
|
|
state = malloc(sizeof *state);
|
|
|
|
|
if (state == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2016-08-15 11:56:52 +03:00
|
|
|
|
state->shell = shell;
|
animation, shell: add kbd focus change animation
When enabled, this will make all but the keyboard-focused window dim.
Also the background gets dimmed, if there are any windows open. The
panel is not dimmed.
When the keyboard focus changes, the change in dimming is animated.
The dimming is implemented with transparent solid-color surfaces, two at
most. The net effect of two overlapping dim surfaces is kept constant
during animations (stable fade animation).
There is a new weston.ini option "focus-animation", that defaults to
none, and can be set to "dim-layer" to enable the focus change
animation.
[pq: Sliced, squashed, and rebased the patch series. Fixed surface alpha
interaction with the switcher. Wrote the commit message.]
[pochu: rebased, ported to weston_view]
2013-11-19 14:37:11 +04:00
|
|
|
|
state->keyboard_focus = NULL;
|
2012-08-01 00:36:34 +04:00
|
|
|
|
state->ws = ws;
|
2012-06-13 02:01:24 +04:00
|
|
|
|
state->seat = seat;
|
2012-08-01 00:36:34 +04:00
|
|
|
|
wl_list_insert(&ws->focus_list, &state->link);
|
2012-06-13 02:01:24 +04:00
|
|
|
|
|
|
|
|
|
state->seat_destroy_listener.notify = focus_state_seat_destroy;
|
|
|
|
|
state->surface_destroy_listener.notify = focus_state_surface_destroy;
|
2013-05-07 06:27:40 +04:00
|
|
|
|
wl_signal_add(&seat->destroy_signal,
|
2012-06-13 02:01:24 +04:00
|
|
|
|
&state->seat_destroy_listener);
|
2012-08-01 00:36:34 +04:00
|
|
|
|
wl_list_init(&state->surface_destroy_listener.link);
|
2012-06-13 02:01:24 +04:00
|
|
|
|
|
|
|
|
|
return state;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-30 00:13:03 +04:00
|
|
|
|
static struct focus_state *
|
|
|
|
|
ensure_focus_state(struct desktop_shell *shell, struct weston_seat *seat)
|
|
|
|
|
{
|
|
|
|
|
struct workspace *ws = get_current_workspace(shell);
|
|
|
|
|
struct focus_state *state;
|
|
|
|
|
|
|
|
|
|
wl_list_for_each(state, &ws->focus_list, link)
|
|
|
|
|
if (state->seat == seat)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
if (&state->link == &ws->focus_list)
|
2016-08-15 11:56:52 +03:00
|
|
|
|
state = focus_state_create(shell, seat, ws);
|
2012-08-30 00:13:03 +04:00
|
|
|
|
|
|
|
|
|
return state;
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-23 00:25:20 +04:00
|
|
|
|
static void
|
|
|
|
|
focus_state_set_focus(struct focus_state *state,
|
|
|
|
|
struct weston_surface *surface)
|
|
|
|
|
{
|
|
|
|
|
if (state->keyboard_focus) {
|
|
|
|
|
wl_list_remove(&state->surface_destroy_listener.link);
|
|
|
|
|
wl_list_init(&state->surface_destroy_listener.link);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
state->keyboard_focus = surface;
|
|
|
|
|
if (surface)
|
|
|
|
|
wl_signal_add(&surface->destroy_signal,
|
|
|
|
|
&state->surface_destroy_listener);
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-13 02:01:24 +04:00
|
|
|
|
static void
|
2012-08-01 00:36:34 +04:00
|
|
|
|
restore_focus_state(struct desktop_shell *shell, struct workspace *ws)
|
2012-06-13 02:01:24 +04:00
|
|
|
|
{
|
|
|
|
|
struct focus_state *state, *next;
|
2013-05-08 17:54:37 +04:00
|
|
|
|
struct weston_surface *surface;
|
2014-04-09 19:33:31 +04:00
|
|
|
|
struct wl_list pending_seat_list;
|
|
|
|
|
struct weston_seat *seat, *next_seat;
|
|
|
|
|
|
|
|
|
|
/* Temporarily steal the list of seats so that we can keep
|
|
|
|
|
* track of the seats we've already processed */
|
|
|
|
|
wl_list_init(&pending_seat_list);
|
|
|
|
|
wl_list_insert_list(&pending_seat_list, &shell->compositor->seat_list);
|
|
|
|
|
wl_list_init(&shell->compositor->seat_list);
|
2012-06-13 02:01:24 +04:00
|
|
|
|
|
|
|
|
|
wl_list_for_each_safe(state, next, &ws->focus_list, link) {
|
2015-08-01 00:55:32 +03:00
|
|
|
|
struct weston_keyboard *keyboard =
|
|
|
|
|
weston_seat_get_keyboard(state->seat);
|
|
|
|
|
|
2014-04-09 19:33:31 +04:00
|
|
|
|
wl_list_remove(&state->seat->link);
|
|
|
|
|
wl_list_insert(&shell->compositor->seat_list,
|
|
|
|
|
&state->seat->link);
|
|
|
|
|
|
2015-08-01 00:55:32 +03:00
|
|
|
|
if (!keyboard)
|
2014-01-18 00:18:53 +04:00
|
|
|
|
continue;
|
|
|
|
|
|
2013-05-08 17:54:37 +04:00
|
|
|
|
surface = state->keyboard_focus;
|
2012-08-30 00:12:59 +04:00
|
|
|
|
|
2015-08-01 00:55:32 +03:00
|
|
|
|
weston_keyboard_set_focus(keyboard, surface);
|
2012-06-13 02:01:24 +04:00
|
|
|
|
}
|
2014-04-09 19:33:31 +04:00
|
|
|
|
|
|
|
|
|
/* For any remaining seats that we don't have a focus state
|
|
|
|
|
* for we'll reset the keyboard focus to NULL */
|
|
|
|
|
wl_list_for_each_safe(seat, next_seat, &pending_seat_list, link) {
|
2015-08-01 00:55:32 +03:00
|
|
|
|
struct weston_keyboard *keyboard =
|
|
|
|
|
weston_seat_get_keyboard(seat);
|
|
|
|
|
|
2014-04-09 19:33:31 +04:00
|
|
|
|
wl_list_insert(&shell->compositor->seat_list, &seat->link);
|
|
|
|
|
|
2015-08-01 00:55:32 +03:00
|
|
|
|
if (!keyboard)
|
2014-04-09 19:33:31 +04:00
|
|
|
|
continue;
|
|
|
|
|
|
2015-08-01 00:55:32 +03:00
|
|
|
|
weston_keyboard_set_focus(keyboard, NULL);
|
2014-04-09 19:33:31 +04:00
|
|
|
|
}
|
2012-06-13 02:01:24 +04:00
|
|
|
|
}
|
|
|
|
|
|
2012-08-30 00:13:00 +04:00
|
|
|
|
static void
|
|
|
|
|
drop_focus_state(struct desktop_shell *shell, struct workspace *ws,
|
|
|
|
|
struct weston_surface *surface)
|
|
|
|
|
{
|
|
|
|
|
struct focus_state *state;
|
|
|
|
|
|
|
|
|
|
wl_list_for_each(state, &ws->focus_list, link)
|
|
|
|
|
if (state->keyboard_focus == surface)
|
2014-01-23 00:25:20 +04:00
|
|
|
|
focus_state_set_focus(state, NULL);
|
2012-08-30 00:13:00 +04:00
|
|
|
|
}
|
|
|
|
|
|
animation, shell: add kbd focus change animation
When enabled, this will make all but the keyboard-focused window dim.
Also the background gets dimmed, if there are any windows open. The
panel is not dimmed.
When the keyboard focus changes, the change in dimming is animated.
The dimming is implemented with transparent solid-color surfaces, two at
most. The net effect of two overlapping dim surfaces is kept constant
during animations (stable fade animation).
There is a new weston.ini option "focus-animation", that defaults to
none, and can be set to "dim-layer" to enable the focus change
animation.
[pq: Sliced, squashed, and rebased the patch series. Fixed surface alpha
interaction with the switcher. Wrote the commit message.]
[pochu: rebased, ported to weston_view]
2013-11-19 14:37:11 +04:00
|
|
|
|
static void
|
|
|
|
|
animate_focus_change(struct desktop_shell *shell, struct workspace *ws,
|
|
|
|
|
struct weston_view *from, struct weston_view *to)
|
|
|
|
|
{
|
|
|
|
|
struct weston_output *output;
|
|
|
|
|
bool focus_surface_created = false;
|
|
|
|
|
|
|
|
|
|
/* FIXME: Only support dim animation using two layers */
|
|
|
|
|
if (from == to || shell->focus_animation_type != ANIMATION_DIM_LAYER)
|
|
|
|
|
return;
|
|
|
|
|
|
2022-11-22 14:28:57 +03:00
|
|
|
|
output = weston_shell_utils_get_default_output(shell->compositor);
|
animation, shell: add kbd focus change animation
When enabled, this will make all but the keyboard-focused window dim.
Also the background gets dimmed, if there are any windows open. The
panel is not dimmed.
When the keyboard focus changes, the change in dimming is animated.
The dimming is implemented with transparent solid-color surfaces, two at
most. The net effect of two overlapping dim surfaces is kept constant
during animations (stable fade animation).
There is a new weston.ini option "focus-animation", that defaults to
none, and can be set to "dim-layer" to enable the focus change
animation.
[pq: Sliced, squashed, and rebased the patch series. Fixed surface alpha
interaction with the switcher. Wrote the commit message.]
[pochu: rebased, ported to weston_view]
2013-11-19 14:37:11 +04:00
|
|
|
|
if (ws->fsurf_front == NULL && (from || to)) {
|
|
|
|
|
ws->fsurf_front = create_focus_surface(shell->compositor, output);
|
2014-01-16 02:45:59 +04:00
|
|
|
|
if (ws->fsurf_front == NULL)
|
|
|
|
|
return;
|
2022-01-17 17:24:03 +03:00
|
|
|
|
ws->fsurf_front->curtain->view->alpha = 0.0;
|
2014-01-16 02:45:59 +04:00
|
|
|
|
|
|
|
|
|
ws->fsurf_back = create_focus_surface(shell->compositor, output);
|
|
|
|
|
if (ws->fsurf_back == NULL) {
|
|
|
|
|
focus_surface_destroy(ws->fsurf_front);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-01-17 17:24:03 +03:00
|
|
|
|
ws->fsurf_back->curtain->view->alpha = 0.0;
|
2014-01-16 02:45:59 +04:00
|
|
|
|
|
animation, shell: add kbd focus change animation
When enabled, this will make all but the keyboard-focused window dim.
Also the background gets dimmed, if there are any windows open. The
panel is not dimmed.
When the keyboard focus changes, the change in dimming is animated.
The dimming is implemented with transparent solid-color surfaces, two at
most. The net effect of two overlapping dim surfaces is kept constant
during animations (stable fade animation).
There is a new weston.ini option "focus-animation", that defaults to
none, and can be set to "dim-layer" to enable the focus change
animation.
[pq: Sliced, squashed, and rebased the patch series. Fixed surface alpha
interaction with the switcher. Wrote the commit message.]
[pochu: rebased, ported to weston_view]
2013-11-19 14:37:11 +04:00
|
|
|
|
focus_surface_created = true;
|
|
|
|
|
} else {
|
2022-01-17 17:24:03 +03:00
|
|
|
|
weston_layer_entry_remove(&ws->fsurf_front->curtain->view->layer_link);
|
|
|
|
|
weston_layer_entry_remove(&ws->fsurf_back->curtain->view->layer_link);
|
animation, shell: add kbd focus change animation
When enabled, this will make all but the keyboard-focused window dim.
Also the background gets dimmed, if there are any windows open. The
panel is not dimmed.
When the keyboard focus changes, the change in dimming is animated.
The dimming is implemented with transparent solid-color surfaces, two at
most. The net effect of two overlapping dim surfaces is kept constant
during animations (stable fade animation).
There is a new weston.ini option "focus-animation", that defaults to
none, and can be set to "dim-layer" to enable the focus change
animation.
[pq: Sliced, squashed, and rebased the patch series. Fixed surface alpha
interaction with the switcher. Wrote the commit message.]
[pochu: rebased, ported to weston_view]
2013-11-19 14:37:11 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ws->focus_animation) {
|
|
|
|
|
weston_view_animation_destroy(ws->focus_animation);
|
|
|
|
|
ws->focus_animation = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (to)
|
2014-07-09 23:12:56 +04:00
|
|
|
|
weston_layer_entry_insert(&to->layer_link,
|
2022-01-17 17:24:03 +03:00
|
|
|
|
&ws->fsurf_front->curtain->view->layer_link);
|
animation, shell: add kbd focus change animation
When enabled, this will make all but the keyboard-focused window dim.
Also the background gets dimmed, if there are any windows open. The
panel is not dimmed.
When the keyboard focus changes, the change in dimming is animated.
The dimming is implemented with transparent solid-color surfaces, two at
most. The net effect of two overlapping dim surfaces is kept constant
during animations (stable fade animation).
There is a new weston.ini option "focus-animation", that defaults to
none, and can be set to "dim-layer" to enable the focus change
animation.
[pq: Sliced, squashed, and rebased the patch series. Fixed surface alpha
interaction with the switcher. Wrote the commit message.]
[pochu: rebased, ported to weston_view]
2013-11-19 14:37:11 +04:00
|
|
|
|
else if (from)
|
2014-07-09 23:12:56 +04:00
|
|
|
|
weston_layer_entry_insert(&ws->layer.view_list,
|
2022-01-17 17:24:03 +03:00
|
|
|
|
&ws->fsurf_front->curtain->view->layer_link);
|
animation, shell: add kbd focus change animation
When enabled, this will make all but the keyboard-focused window dim.
Also the background gets dimmed, if there are any windows open. The
panel is not dimmed.
When the keyboard focus changes, the change in dimming is animated.
The dimming is implemented with transparent solid-color surfaces, two at
most. The net effect of two overlapping dim surfaces is kept constant
during animations (stable fade animation).
There is a new weston.ini option "focus-animation", that defaults to
none, and can be set to "dim-layer" to enable the focus change
animation.
[pq: Sliced, squashed, and rebased the patch series. Fixed surface alpha
interaction with the switcher. Wrote the commit message.]
[pochu: rebased, ported to weston_view]
2013-11-19 14:37:11 +04:00
|
|
|
|
|
|
|
|
|
if (focus_surface_created) {
|
|
|
|
|
ws->focus_animation = weston_fade_run(
|
2022-01-17 17:24:03 +03:00
|
|
|
|
ws->fsurf_front->curtain->view,
|
|
|
|
|
ws->fsurf_front->curtain->view->alpha, 0.4, 300,
|
animation, shell: add kbd focus change animation
When enabled, this will make all but the keyboard-focused window dim.
Also the background gets dimmed, if there are any windows open. The
panel is not dimmed.
When the keyboard focus changes, the change in dimming is animated.
The dimming is implemented with transparent solid-color surfaces, two at
most. The net effect of two overlapping dim surfaces is kept constant
during animations (stable fade animation).
There is a new weston.ini option "focus-animation", that defaults to
none, and can be set to "dim-layer" to enable the focus change
animation.
[pq: Sliced, squashed, and rebased the patch series. Fixed surface alpha
interaction with the switcher. Wrote the commit message.]
[pochu: rebased, ported to weston_view]
2013-11-19 14:37:11 +04:00
|
|
|
|
focus_animation_done, ws);
|
|
|
|
|
} else if (from) {
|
2014-07-09 23:12:56 +04:00
|
|
|
|
weston_layer_entry_insert(&from->layer_link,
|
2022-01-17 17:24:03 +03:00
|
|
|
|
&ws->fsurf_back->curtain->view->layer_link);
|
animation, shell: add kbd focus change animation
When enabled, this will make all but the keyboard-focused window dim.
Also the background gets dimmed, if there are any windows open. The
panel is not dimmed.
When the keyboard focus changes, the change in dimming is animated.
The dimming is implemented with transparent solid-color surfaces, two at
most. The net effect of two overlapping dim surfaces is kept constant
during animations (stable fade animation).
There is a new weston.ini option "focus-animation", that defaults to
none, and can be set to "dim-layer" to enable the focus change
animation.
[pq: Sliced, squashed, and rebased the patch series. Fixed surface alpha
interaction with the switcher. Wrote the commit message.]
[pochu: rebased, ported to weston_view]
2013-11-19 14:37:11 +04:00
|
|
|
|
ws->focus_animation = weston_stable_fade_run(
|
2022-01-17 17:24:03 +03:00
|
|
|
|
ws->fsurf_front->curtain->view, 0.0,
|
|
|
|
|
ws->fsurf_back->curtain->view, 0.4,
|
animation, shell: add kbd focus change animation
When enabled, this will make all but the keyboard-focused window dim.
Also the background gets dimmed, if there are any windows open. The
panel is not dimmed.
When the keyboard focus changes, the change in dimming is animated.
The dimming is implemented with transparent solid-color surfaces, two at
most. The net effect of two overlapping dim surfaces is kept constant
during animations (stable fade animation).
There is a new weston.ini option "focus-animation", that defaults to
none, and can be set to "dim-layer" to enable the focus change
animation.
[pq: Sliced, squashed, and rebased the patch series. Fixed surface alpha
interaction with the switcher. Wrote the commit message.]
[pochu: rebased, ported to weston_view]
2013-11-19 14:37:11 +04:00
|
|
|
|
focus_animation_done, ws);
|
|
|
|
|
} else if (to) {
|
2014-07-09 23:12:56 +04:00
|
|
|
|
weston_layer_entry_insert(&ws->layer.view_list,
|
2022-01-17 17:24:03 +03:00
|
|
|
|
&ws->fsurf_back->curtain->view->layer_link);
|
animation, shell: add kbd focus change animation
When enabled, this will make all but the keyboard-focused window dim.
Also the background gets dimmed, if there are any windows open. The
panel is not dimmed.
When the keyboard focus changes, the change in dimming is animated.
The dimming is implemented with transparent solid-color surfaces, two at
most. The net effect of two overlapping dim surfaces is kept constant
during animations (stable fade animation).
There is a new weston.ini option "focus-animation", that defaults to
none, and can be set to "dim-layer" to enable the focus change
animation.
[pq: Sliced, squashed, and rebased the patch series. Fixed surface alpha
interaction with the switcher. Wrote the commit message.]
[pochu: rebased, ported to weston_view]
2013-11-19 14:37:11 +04:00
|
|
|
|
ws->focus_animation = weston_stable_fade_run(
|
2022-01-17 17:24:03 +03:00
|
|
|
|
ws->fsurf_front->curtain->view, 0.0,
|
|
|
|
|
ws->fsurf_back->curtain->view, 0.4,
|
animation, shell: add kbd focus change animation
When enabled, this will make all but the keyboard-focused window dim.
Also the background gets dimmed, if there are any windows open. The
panel is not dimmed.
When the keyboard focus changes, the change in dimming is animated.
The dimming is implemented with transparent solid-color surfaces, two at
most. The net effect of two overlapping dim surfaces is kept constant
during animations (stable fade animation).
There is a new weston.ini option "focus-animation", that defaults to
none, and can be set to "dim-layer" to enable the focus change
animation.
[pq: Sliced, squashed, and rebased the patch series. Fixed surface alpha
interaction with the switcher. Wrote the commit message.]
[pochu: rebased, ported to weston_view]
2013-11-19 14:37:11 +04:00
|
|
|
|
focus_animation_done, ws);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-10 18:50:50 +03:00
|
|
|
|
static void
|
2022-05-05 15:38:14 +03:00
|
|
|
|
desktop_shell_destroy_layer(struct weston_layer *layer);
|
2021-11-10 18:50:50 +03:00
|
|
|
|
|
2012-06-13 02:01:22 +04:00
|
|
|
|
static void
|
|
|
|
|
workspace_destroy(struct workspace *ws)
|
|
|
|
|
{
|
2012-06-13 02:01:24 +04:00
|
|
|
|
struct focus_state *state, *next;
|
|
|
|
|
|
|
|
|
|
wl_list_for_each_safe(state, next, &ws->focus_list, link)
|
|
|
|
|
focus_state_destroy(state);
|
|
|
|
|
|
animation, shell: add kbd focus change animation
When enabled, this will make all but the keyboard-focused window dim.
Also the background gets dimmed, if there are any windows open. The
panel is not dimmed.
When the keyboard focus changes, the change in dimming is animated.
The dimming is implemented with transparent solid-color surfaces, two at
most. The net effect of two overlapping dim surfaces is kept constant
during animations (stable fade animation).
There is a new weston.ini option "focus-animation", that defaults to
none, and can be set to "dim-layer" to enable the focus change
animation.
[pq: Sliced, squashed, and rebased the patch series. Fixed surface alpha
interaction with the switcher. Wrote the commit message.]
[pochu: rebased, ported to weston_view]
2013-11-19 14:37:11 +04:00
|
|
|
|
if (ws->fsurf_front)
|
|
|
|
|
focus_surface_destroy(ws->fsurf_front);
|
|
|
|
|
if (ws->fsurf_back)
|
|
|
|
|
focus_surface_destroy(ws->fsurf_back);
|
|
|
|
|
|
2022-05-05 15:38:14 +03:00
|
|
|
|
desktop_shell_destroy_layer(&ws->layer);
|
2012-06-13 02:01:22 +04:00
|
|
|
|
}
|
|
|
|
|
|
2012-06-13 02:01:24 +04:00
|
|
|
|
static void
|
|
|
|
|
seat_destroyed(struct wl_listener *listener, void *data)
|
|
|
|
|
{
|
|
|
|
|
struct weston_seat *seat = data;
|
|
|
|
|
struct focus_state *state, *next;
|
|
|
|
|
struct workspace *ws = container_of(listener,
|
|
|
|
|
struct workspace,
|
|
|
|
|
seat_destroyed_listener);
|
|
|
|
|
|
|
|
|
|
wl_list_for_each_safe(state, next, &ws->focus_list, link)
|
|
|
|
|
if (state->seat == seat)
|
|
|
|
|
wl_list_remove(&state->link);
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-22 18:16:02 +03:00
|
|
|
|
static void
|
2016-12-17 15:40:51 +03:00
|
|
|
|
workspace_create(struct desktop_shell *shell)
|
2012-06-13 02:01:22 +04:00
|
|
|
|
{
|
2022-06-22 18:16:02 +03:00
|
|
|
|
struct workspace *ws = &shell->workspace;
|
2012-06-13 02:01:22 +04:00
|
|
|
|
|
2016-12-17 15:40:51 +03:00
|
|
|
|
weston_layer_init(&ws->layer, shell->compositor);
|
2022-06-22 18:16:02 +03:00
|
|
|
|
weston_layer_set_position(&ws->layer, WESTON_LAYER_POSITION_NORMAL);
|
2012-06-13 02:01:22 +04:00
|
|
|
|
|
2012-06-13 02:01:24 +04:00
|
|
|
|
wl_list_init(&ws->focus_list);
|
|
|
|
|
wl_list_init(&ws->seat_destroyed_listener.link);
|
|
|
|
|
ws->seat_destroyed_listener.notify = seat_destroyed;
|
animation, shell: add kbd focus change animation
When enabled, this will make all but the keyboard-focused window dim.
Also the background gets dimmed, if there are any windows open. The
panel is not dimmed.
When the keyboard focus changes, the change in dimming is animated.
The dimming is implemented with transparent solid-color surfaces, two at
most. The net effect of two overlapping dim surfaces is kept constant
during animations (stable fade animation).
There is a new weston.ini option "focus-animation", that defaults to
none, and can be set to "dim-layer" to enable the focus change
animation.
[pq: Sliced, squashed, and rebased the patch series. Fixed surface alpha
interaction with the switcher. Wrote the commit message.]
[pochu: rebased, ported to weston_view]
2013-11-19 14:37:11 +04:00
|
|
|
|
ws->fsurf_front = NULL;
|
|
|
|
|
ws->fsurf_back = NULL;
|
|
|
|
|
ws->focus_animation = NULL;
|
2012-06-13 02:01:22 +04:00
|
|
|
|
}
|
|
|
|
|
|
2013-12-04 12:20:01 +04:00
|
|
|
|
struct workspace *
|
2012-06-13 02:01:22 +04:00
|
|
|
|
get_current_workspace(struct desktop_shell *shell)
|
|
|
|
|
{
|
2022-06-22 18:16:02 +03:00
|
|
|
|
return &shell->workspace;
|
2012-08-30 00:13:00 +04:00
|
|
|
|
}
|
|
|
|
|
|
2014-10-16 00:02:06 +04:00
|
|
|
|
static void
|
|
|
|
|
surface_keyboard_focus_lost(struct weston_surface *surface)
|
|
|
|
|
{
|
|
|
|
|
struct weston_compositor *compositor = surface->compositor;
|
|
|
|
|
struct weston_seat *seat;
|
|
|
|
|
struct weston_surface *focus;
|
|
|
|
|
|
|
|
|
|
wl_list_for_each(seat, &compositor->seat_list, link) {
|
|
|
|
|
struct weston_keyboard *keyboard =
|
|
|
|
|
weston_seat_get_keyboard(seat);
|
|
|
|
|
|
|
|
|
|
if (!keyboard)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
focus = weston_surface_get_main_surface(keyboard->focus);
|
|
|
|
|
if (focus == surface)
|
|
|
|
|
weston_keyboard_set_focus(keyboard, NULL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-15 20:10:08 +04:00
|
|
|
|
static void
|
2017-11-16 19:20:58 +03:00
|
|
|
|
touch_move_grab_down(struct weston_touch_grab *grab,
|
|
|
|
|
const struct timespec *time,
|
2015-07-08 11:55:28 +03:00
|
|
|
|
int touch_id, wl_fixed_t x, wl_fixed_t y)
|
2013-08-15 20:10:08 +04:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2017-11-16 19:20:59 +03:00
|
|
|
|
touch_move_grab_up(struct weston_touch_grab *grab, const struct timespec *time,
|
|
|
|
|
int touch_id)
|
2013-08-15 20:10:08 +04:00
|
|
|
|
{
|
2013-10-26 01:18:04 +04:00
|
|
|
|
struct weston_touch_move_grab *move =
|
|
|
|
|
(struct weston_touch_move_grab *) container_of(
|
|
|
|
|
grab, struct shell_touch_grab, grab);
|
2013-10-03 19:43:07 +04:00
|
|
|
|
|
2014-01-18 03:18:10 +04:00
|
|
|
|
if (touch_id == 0)
|
|
|
|
|
move->active = 0;
|
|
|
|
|
|
2013-12-03 01:05:03 +04:00
|
|
|
|
if (grab->touch->num_tp == 0) {
|
2013-10-26 01:18:04 +04:00
|
|
|
|
shell_touch_grab_end(&move->base);
|
|
|
|
|
free(move);
|
|
|
|
|
}
|
2013-08-15 20:10:08 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2017-11-16 19:21:00 +03:00
|
|
|
|
touch_move_grab_motion(struct weston_touch_grab *grab,
|
|
|
|
|
const struct timespec *time, int touch_id,
|
|
|
|
|
wl_fixed_t x, wl_fixed_t y)
|
2013-08-15 20:10:08 +04:00
|
|
|
|
{
|
|
|
|
|
struct weston_touch_move_grab *move = (struct weston_touch_move_grab *) grab;
|
|
|
|
|
struct shell_surface *shsurf = move->base.shsurf;
|
|
|
|
|
struct weston_surface *es;
|
|
|
|
|
int dx = wl_fixed_to_int(grab->touch->grab_x + move->dx);
|
|
|
|
|
int dy = wl_fixed_to_int(grab->touch->grab_y + move->dy);
|
|
|
|
|
|
2022-03-18 23:49:29 +03:00
|
|
|
|
if (!shsurf || !shsurf->desktop_surface || !move->active)
|
2013-08-15 20:10:08 +04:00
|
|
|
|
return;
|
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
es = weston_desktop_surface_get_surface(shsurf->desktop_surface);
|
2013-08-15 20:10:08 +04:00
|
|
|
|
|
2013-12-03 07:01:53 +04:00
|
|
|
|
weston_view_set_position(shsurf->view, dx, dy);
|
2013-08-15 20:10:08 +04:00
|
|
|
|
|
|
|
|
|
weston_compositor_schedule_repaint(es->compositor);
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-12 11:39:51 +04:00
|
|
|
|
static void
|
|
|
|
|
touch_move_grab_frame(struct weston_touch_grab *grab)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-26 01:18:05 +04:00
|
|
|
|
static void
|
|
|
|
|
touch_move_grab_cancel(struct weston_touch_grab *grab)
|
|
|
|
|
{
|
|
|
|
|
struct weston_touch_move_grab *move =
|
|
|
|
|
(struct weston_touch_move_grab *) container_of(
|
|
|
|
|
grab, struct shell_touch_grab, grab);
|
|
|
|
|
|
|
|
|
|
shell_touch_grab_end(&move->base);
|
|
|
|
|
free(move);
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-15 20:10:08 +04:00
|
|
|
|
static const struct weston_touch_grab_interface touch_move_grab_interface = {
|
|
|
|
|
touch_move_grab_down,
|
|
|
|
|
touch_move_grab_up,
|
|
|
|
|
touch_move_grab_motion,
|
2014-04-12 11:39:51 +04:00
|
|
|
|
touch_move_grab_frame,
|
2013-10-26 01:18:05 +04:00
|
|
|
|
touch_move_grab_cancel,
|
2013-08-15 20:10:08 +04:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static int
|
2015-07-15 21:00:37 +03:00
|
|
|
|
surface_touch_move(struct shell_surface *shsurf, struct weston_touch *touch)
|
2013-08-15 20:10:08 +04:00
|
|
|
|
{
|
|
|
|
|
struct weston_touch_move_grab *move;
|
|
|
|
|
|
|
|
|
|
if (!shsurf)
|
|
|
|
|
return -1;
|
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
if (weston_desktop_surface_get_fullscreen(shsurf->desktop_surface) ||
|
|
|
|
|
weston_desktop_surface_get_maximized(shsurf->desktop_surface))
|
2013-08-15 20:10:08 +04:00
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
move = malloc(sizeof *move);
|
|
|
|
|
if (!move)
|
|
|
|
|
return -1;
|
|
|
|
|
|
2014-01-18 03:18:10 +04:00
|
|
|
|
move->active = 1;
|
2022-02-04 02:47:41 +03:00
|
|
|
|
move->dx = wl_fixed_from_double(shsurf->view->geometry.pos_offset.x) -
|
2016-08-12 11:41:36 +03:00
|
|
|
|
touch->grab_x;
|
2022-02-04 02:47:41 +03:00
|
|
|
|
move->dy = wl_fixed_from_double(shsurf->view->geometry.pos_offset.y) -
|
2016-08-12 11:41:36 +03:00
|
|
|
|
touch->grab_y;
|
2013-08-15 20:10:08 +04:00
|
|
|
|
|
|
|
|
|
shell_touch_grab_start(&move->base, &touch_move_grab_interface, shsurf,
|
2015-07-15 21:00:37 +03:00
|
|
|
|
touch);
|
2013-08-15 20:10:08 +04:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-05 06:30:29 +04:00
|
|
|
|
static void
|
2013-05-09 06:02:59 +04:00
|
|
|
|
noop_grab_focus(struct weston_pointer_grab *grab)
|
2012-01-05 06:30:29 +04:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-04 18:28:29 +04:00
|
|
|
|
static void
|
|
|
|
|
noop_grab_axis(struct weston_pointer_grab *grab,
|
2017-11-16 19:20:56 +03:00
|
|
|
|
const struct timespec *time,
|
|
|
|
|
struct weston_pointer_axis_event *event)
|
2014-10-04 18:28:29 +04:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-18 09:38:22 +03:00
|
|
|
|
static void
|
|
|
|
|
noop_grab_axis_source(struct weston_pointer_grab *grab,
|
|
|
|
|
uint32_t source)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
noop_grab_frame(struct weston_pointer_grab *grab)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-30 03:03:54 +04:00
|
|
|
|
static void
|
|
|
|
|
constrain_position(struct weston_move_grab *move, int *cx, int *cy)
|
|
|
|
|
{
|
|
|
|
|
struct shell_surface *shsurf = move->base.shsurf;
|
2016-08-12 11:41:36 +03:00
|
|
|
|
struct weston_surface *surface =
|
|
|
|
|
weston_desktop_surface_get_surface(shsurf->desktop_surface);
|
2014-04-30 03:03:54 +04:00
|
|
|
|
struct weston_pointer *pointer = move->base.grab.pointer;
|
2015-04-15 20:23:56 +03:00
|
|
|
|
int x, y, bottom;
|
2014-04-30 03:03:54 +04:00
|
|
|
|
const int safety = 50;
|
2015-04-15 20:23:56 +03:00
|
|
|
|
pixman_rectangle32_t area;
|
2016-08-12 11:41:36 +03:00
|
|
|
|
struct weston_geometry geometry;
|
2014-04-30 03:03:54 +04:00
|
|
|
|
|
2022-02-04 01:40:10 +03:00
|
|
|
|
x = pointer->pos.c.x + wl_fixed_to_double(move->dx);
|
|
|
|
|
y = pointer->pos.c.y + wl_fixed_to_double(move->dy);
|
2014-04-30 03:03:54 +04:00
|
|
|
|
|
2015-11-17 11:00:33 +03:00
|
|
|
|
if (shsurf->shell->panel_position ==
|
|
|
|
|
WESTON_DESKTOP_SHELL_PANEL_POSITION_TOP) {
|
2016-08-12 11:41:36 +03:00
|
|
|
|
get_output_work_area(shsurf->shell, surface->output, &area);
|
|
|
|
|
geometry =
|
|
|
|
|
weston_desktop_surface_get_geometry(shsurf->desktop_surface);
|
2014-04-30 03:03:54 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
bottom = y + geometry.height + geometry.y;
|
2015-04-15 20:23:56 +03:00
|
|
|
|
if (bottom - safety < area.y)
|
2016-08-12 11:41:36 +03:00
|
|
|
|
y = area.y + safety - geometry.height
|
|
|
|
|
- geometry.y;
|
2014-08-20 17:53:20 +04:00
|
|
|
|
|
|
|
|
|
if (move->client_initiated &&
|
2016-08-12 11:41:36 +03:00
|
|
|
|
y + geometry.y < area.y)
|
|
|
|
|
y = area.y - geometry.y;
|
2014-08-20 17:53:20 +04:00
|
|
|
|
}
|
2014-04-30 03:03:54 +04:00
|
|
|
|
|
|
|
|
|
*cx = x;
|
|
|
|
|
*cy = y;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-18 15:53:49 +03:00
|
|
|
|
static void
|
2017-11-24 19:01:46 +03:00
|
|
|
|
move_grab_motion(struct weston_pointer_grab *grab,
|
|
|
|
|
const struct timespec *time,
|
2014-10-05 23:39:14 +04:00
|
|
|
|
struct weston_pointer_motion_event *event)
|
2011-01-18 15:53:49 +03:00
|
|
|
|
{
|
Rename wayland-compositor to weston
This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.
1) Initially, we had one big repository with protocol code, sample
compositor and sample clients. We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code. At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message. The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.
2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor. Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example. Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.
We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
2012-01-03 19:29:47 +04:00
|
|
|
|
struct weston_move_grab *move = (struct weston_move_grab *) grab;
|
2013-05-07 06:15:05 +04:00
|
|
|
|
struct weston_pointer *pointer = grab->pointer;
|
2012-04-04 18:48:05 +04:00
|
|
|
|
struct shell_surface *shsurf = move->base.shsurf;
|
2016-08-12 11:41:36 +03:00
|
|
|
|
struct weston_surface *surface;
|
2014-04-30 03:03:54 +04:00
|
|
|
|
int cx, cy;
|
2013-11-15 02:42:52 +04:00
|
|
|
|
|
2014-10-05 23:39:14 +04:00
|
|
|
|
weston_pointer_move(pointer, event);
|
2022-03-18 23:49:29 +03:00
|
|
|
|
if (!shsurf || !shsurf->desktop_surface)
|
2012-04-04 18:48:05 +04:00
|
|
|
|
return;
|
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
surface = weston_desktop_surface_get_surface(shsurf->desktop_surface);
|
|
|
|
|
|
2014-04-30 03:03:54 +04:00
|
|
|
|
constrain_position(move, &cx, &cy);
|
|
|
|
|
|
|
|
|
|
weston_view_set_position(shsurf->view, cx, cy);
|
2012-06-21 20:06:22 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
weston_compositor_schedule_repaint(surface->compositor);
|
2011-01-18 15:53:49 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2013-05-07 06:15:05 +04:00
|
|
|
|
move_grab_button(struct weston_pointer_grab *grab,
|
2017-11-16 19:20:55 +03:00
|
|
|
|
const struct timespec *time, uint32_t button, uint32_t state_w)
|
2011-01-18 15:53:49 +03:00
|
|
|
|
{
|
2012-04-04 18:48:05 +04:00
|
|
|
|
struct shell_grab *shell_grab = container_of(grab, struct shell_grab,
|
|
|
|
|
grab);
|
2013-05-07 06:15:05 +04:00
|
|
|
|
struct weston_pointer *pointer = grab->pointer;
|
2012-05-30 19:31:51 +04:00
|
|
|
|
enum wl_pointer_button_state state = state_w;
|
2011-01-18 15:53:49 +03:00
|
|
|
|
|
2012-05-30 19:31:51 +04:00
|
|
|
|
if (pointer->button_count == 0 &&
|
|
|
|
|
state == WL_POINTER_BUTTON_STATE_RELEASED) {
|
2012-06-28 19:08:05 +04:00
|
|
|
|
shell_grab_end(shell_grab);
|
2012-01-05 06:30:29 +04:00
|
|
|
|
free(grab);
|
|
|
|
|
}
|
2011-01-18 15:53:49 +03:00
|
|
|
|
}
|
|
|
|
|
|
2013-10-26 01:18:05 +04:00
|
|
|
|
static void
|
|
|
|
|
move_grab_cancel(struct weston_pointer_grab *grab)
|
|
|
|
|
{
|
|
|
|
|
struct shell_grab *shell_grab =
|
|
|
|
|
container_of(grab, struct shell_grab, grab);
|
|
|
|
|
|
|
|
|
|
shell_grab_end(shell_grab);
|
|
|
|
|
free(grab);
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-07 06:15:05 +04:00
|
|
|
|
static const struct weston_pointer_grab_interface move_grab_interface = {
|
2012-01-05 06:30:29 +04:00
|
|
|
|
noop_grab_focus,
|
2011-01-18 15:53:49 +03:00
|
|
|
|
move_grab_motion,
|
|
|
|
|
move_grab_button,
|
2014-10-04 18:28:29 +04:00
|
|
|
|
noop_grab_axis,
|
2016-01-18 09:38:22 +03:00
|
|
|
|
noop_grab_axis_source,
|
|
|
|
|
noop_grab_frame,
|
2013-10-26 01:18:05 +04:00
|
|
|
|
move_grab_cancel,
|
2011-01-18 15:53:49 +03:00
|
|
|
|
};
|
|
|
|
|
|
2012-08-01 08:08:07 +04:00
|
|
|
|
static int
|
2015-07-15 21:00:38 +03:00
|
|
|
|
surface_move(struct shell_surface *shsurf, struct weston_pointer *pointer,
|
2015-06-03 23:53:22 +03:00
|
|
|
|
bool client_initiated)
|
2012-08-01 08:08:07 +04:00
|
|
|
|
{
|
|
|
|
|
struct weston_move_grab *move;
|
2022-02-04 02:47:41 +03:00
|
|
|
|
struct weston_coord offset;
|
2012-08-01 08:08:07 +04:00
|
|
|
|
|
|
|
|
|
if (!shsurf)
|
|
|
|
|
return -1;
|
|
|
|
|
|
2014-05-01 03:05:49 +04:00
|
|
|
|
if (shsurf->grabbed ||
|
2016-08-12 11:41:36 +03:00
|
|
|
|
weston_desktop_surface_get_fullscreen(shsurf->desktop_surface) ||
|
|
|
|
|
weston_desktop_surface_get_maximized(shsurf->desktop_surface))
|
2012-08-01 08:08:07 +04:00
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
move = malloc(sizeof *move);
|
|
|
|
|
if (!move)
|
|
|
|
|
return -1;
|
|
|
|
|
|
2022-02-04 02:47:41 +03:00
|
|
|
|
offset = weston_coord_sub(shsurf->view->geometry.pos_offset,
|
|
|
|
|
pointer->grab_pos.c);
|
|
|
|
|
move->dx = wl_fixed_from_double(offset.x);
|
|
|
|
|
move->dy = wl_fixed_from_double(offset.y);
|
2014-04-30 03:03:54 +04:00
|
|
|
|
move->client_initiated = client_initiated;
|
2012-08-01 08:08:07 +04:00
|
|
|
|
|
2022-07-29 17:04:32 +03:00
|
|
|
|
weston_desktop_surface_set_orientation(shsurf->desktop_surface,
|
|
|
|
|
WESTON_TOP_LEVEL_TILED_ORIENTATION_NONE);
|
|
|
|
|
shsurf->orientation = WESTON_TOP_LEVEL_TILED_ORIENTATION_NONE;
|
2012-08-01 08:08:07 +04:00
|
|
|
|
shell_grab_start(&move->base, &move_grab_interface, shsurf,
|
2015-11-17 11:00:33 +03:00
|
|
|
|
pointer, WESTON_DESKTOP_SHELL_CURSOR_MOVE);
|
2012-08-01 08:08:07 +04:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct weston_resize_grab {
|
|
|
|
|
struct shell_grab base;
|
|
|
|
|
uint32_t edges;
|
|
|
|
|
int32_t width, height;
|
|
|
|
|
};
|
|
|
|
|
|
2017-12-19 11:33:33 +03:00
|
|
|
|
static void
|
|
|
|
|
tablet_tool_noop_grab_proximity_in(struct weston_tablet_tool_grab *grab,
|
|
|
|
|
const struct timespec *time,
|
|
|
|
|
struct weston_tablet *tablet)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
tablet_tool_move_grab_proximity_out(struct weston_tablet_tool_grab *grab,
|
|
|
|
|
const struct timespec *time)
|
|
|
|
|
{
|
|
|
|
|
struct weston_tablet_tool_move_grab *move =
|
|
|
|
|
(struct weston_tablet_tool_move_grab *)grab;
|
|
|
|
|
|
|
|
|
|
shell_tablet_tool_grab_end(&move->base);
|
|
|
|
|
free(grab);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
tablet_tool_move_grab_up(struct weston_tablet_tool_grab *grab,
|
|
|
|
|
const struct timespec *time)
|
|
|
|
|
{
|
|
|
|
|
struct weston_tablet_tool_move_grab *move =
|
|
|
|
|
(struct weston_tablet_tool_move_grab *)grab;
|
|
|
|
|
|
|
|
|
|
shell_tablet_tool_grab_end(&move->base);
|
|
|
|
|
free(grab);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
tablet_tool_noop_grab_down(struct weston_tablet_tool_grab *grab,
|
|
|
|
|
const struct timespec *time)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
tablet_tool_move_grab_motion(struct weston_tablet_tool_grab *grab,
|
|
|
|
|
const struct timespec *time,
|
|
|
|
|
struct weston_coord_global pos)
|
|
|
|
|
{
|
|
|
|
|
struct weston_tablet_tool_move_grab *move =
|
|
|
|
|
(struct weston_tablet_tool_move_grab *)grab;
|
|
|
|
|
struct shell_surface *shsurf = move->base.shsurf;
|
|
|
|
|
struct weston_surface *es;
|
|
|
|
|
|
|
|
|
|
weston_tablet_tool_cursor_move(grab->tool, pos);
|
|
|
|
|
|
|
|
|
|
if (!shsurf)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
es = weston_desktop_surface_get_surface(shsurf->desktop_surface);
|
|
|
|
|
weston_view_set_position(shsurf->view,
|
|
|
|
|
pos.c.x + wl_fixed_to_double(move->dx),
|
|
|
|
|
pos.c.y + wl_fixed_to_double(move->dy));
|
|
|
|
|
weston_compositor_schedule_repaint(es->compositor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
tablet_tool_noop_grab_pressure(struct weston_tablet_tool_grab *grab,
|
|
|
|
|
const struct timespec *time,
|
|
|
|
|
uint32_t pressure)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
tablet_tool_noop_grab_distance(struct weston_tablet_tool_grab *grab,
|
|
|
|
|
const struct timespec *time,
|
|
|
|
|
uint32_t distance)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
tablet_tool_noop_grab_tilt(struct weston_tablet_tool_grab *grab,
|
|
|
|
|
const struct timespec *time,
|
|
|
|
|
int32_t tilt_x, int32_t tilt_y)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void tablet_tool_noop_grab_button(struct weston_tablet_tool_grab *grab,
|
|
|
|
|
const struct timespec *time, uint32_t button,
|
|
|
|
|
uint32_t state)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
tablet_tool_noop_grab_frame(struct weston_tablet_tool_grab *grab,
|
|
|
|
|
const struct timespec *time)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
tablet_tool_move_grab_cancel(struct weston_tablet_tool_grab *grab)
|
|
|
|
|
{
|
|
|
|
|
struct weston_tablet_tool_move_grab *move =
|
|
|
|
|
(struct weston_tablet_tool_move_grab *)grab;
|
|
|
|
|
|
|
|
|
|
shell_tablet_tool_grab_end(&move->base);
|
|
|
|
|
free(grab);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static struct weston_tablet_tool_grab_interface tablet_tool_move_grab_interface = {
|
|
|
|
|
tablet_tool_noop_grab_proximity_in,
|
|
|
|
|
tablet_tool_move_grab_proximity_out,
|
|
|
|
|
tablet_tool_move_grab_motion,
|
|
|
|
|
tablet_tool_noop_grab_down,
|
|
|
|
|
tablet_tool_move_grab_up,
|
|
|
|
|
tablet_tool_noop_grab_pressure,
|
|
|
|
|
tablet_tool_noop_grab_distance,
|
|
|
|
|
tablet_tool_noop_grab_tilt,
|
|
|
|
|
tablet_tool_noop_grab_button,
|
|
|
|
|
tablet_tool_noop_grab_frame,
|
|
|
|
|
tablet_tool_move_grab_cancel,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
surface_tablet_tool_move(struct shell_surface *shsurf, struct weston_tablet_tool *tool)
|
|
|
|
|
{
|
|
|
|
|
struct weston_tablet_tool_move_grab *move;
|
|
|
|
|
struct weston_coord offset;
|
|
|
|
|
|
|
|
|
|
if (!shsurf)
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
if (shsurf->state.fullscreen || shsurf->state.maximized)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
move = malloc(sizeof(*move));
|
|
|
|
|
if (!move)
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
offset = weston_coord_sub(shsurf->view->geometry.pos_offset,
|
|
|
|
|
tool->grab_pos.c);
|
|
|
|
|
move->dx = wl_fixed_from_double(offset.x);
|
|
|
|
|
move->dy = wl_fixed_from_double(offset.y);
|
|
|
|
|
|
|
|
|
|
shell_tablet_tool_grab_start(&move->base, &tablet_tool_move_grab_interface,
|
|
|
|
|
shsurf, tool);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2012-08-01 08:08:07 +04:00
|
|
|
|
static void
|
2017-11-24 19:01:46 +03:00
|
|
|
|
resize_grab_motion(struct weston_pointer_grab *grab,
|
|
|
|
|
const struct timespec *time,
|
2014-10-05 23:39:14 +04:00
|
|
|
|
struct weston_pointer_motion_event *event)
|
2012-08-01 08:08:07 +04:00
|
|
|
|
{
|
|
|
|
|
struct weston_resize_grab *resize = (struct weston_resize_grab *) grab;
|
2013-05-07 06:15:05 +04:00
|
|
|
|
struct weston_pointer *pointer = grab->pointer;
|
2012-08-01 08:08:07 +04:00
|
|
|
|
struct shell_surface *shsurf = resize->base.shsurf;
|
|
|
|
|
int32_t width, height;
|
2016-08-12 11:41:36 +03:00
|
|
|
|
struct weston_size min_size, max_size;
|
2022-02-09 02:31:55 +03:00
|
|
|
|
struct weston_coord_surface tmp_s;
|
2012-08-01 08:08:07 +04:00
|
|
|
|
wl_fixed_t from_x, from_y;
|
|
|
|
|
wl_fixed_t to_x, to_y;
|
|
|
|
|
|
2014-10-05 23:39:14 +04:00
|
|
|
|
weston_pointer_move(pointer, event);
|
2013-11-15 02:42:52 +04:00
|
|
|
|
|
2023-02-16 19:54:22 +03:00
|
|
|
|
if (!shsurf || !shsurf->desktop_surface)
|
2012-08-01 08:08:07 +04:00
|
|
|
|
return;
|
|
|
|
|
|
2022-11-25 00:59:26 +03:00
|
|
|
|
weston_view_update_transform(shsurf->view);
|
|
|
|
|
|
2022-02-04 01:40:10 +03:00
|
|
|
|
tmp_s = weston_coord_global_to_surface(shsurf->view, pointer->grab_pos);
|
2022-02-09 02:31:55 +03:00
|
|
|
|
from_x = wl_fixed_from_double(tmp_s.c.x);
|
|
|
|
|
from_y = wl_fixed_from_double(tmp_s.c.y);
|
2022-02-04 01:40:10 +03:00
|
|
|
|
tmp_s = weston_coord_global_to_surface(shsurf->view, pointer->pos);
|
2022-02-09 02:31:55 +03:00
|
|
|
|
to_x = wl_fixed_from_double(tmp_s.c.x);
|
|
|
|
|
to_y = wl_fixed_from_double(tmp_s.c.y);
|
2012-08-01 08:08:07 +04:00
|
|
|
|
|
|
|
|
|
width = resize->width;
|
2022-02-23 18:06:23 +03:00
|
|
|
|
if (resize->edges & WESTON_DESKTOP_SURFACE_EDGE_LEFT) {
|
2012-08-01 08:08:07 +04:00
|
|
|
|
width += wl_fixed_to_int(from_x - to_x);
|
2022-02-23 18:06:23 +03:00
|
|
|
|
} else if (resize->edges & WESTON_DESKTOP_SURFACE_EDGE_RIGHT) {
|
2012-08-01 08:08:07 +04:00
|
|
|
|
width += wl_fixed_to_int(to_x - from_x);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
height = resize->height;
|
2022-02-23 18:06:23 +03:00
|
|
|
|
if (resize->edges & WESTON_DESKTOP_SURFACE_EDGE_TOP) {
|
2012-08-01 08:08:07 +04:00
|
|
|
|
height += wl_fixed_to_int(from_y - to_y);
|
2022-02-23 18:06:23 +03:00
|
|
|
|
} else if (resize->edges & WESTON_DESKTOP_SURFACE_EDGE_BOTTOM) {
|
2012-08-01 08:08:07 +04:00
|
|
|
|
height += wl_fixed_to_int(to_y - from_y);
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
max_size = weston_desktop_surface_get_max_size(shsurf->desktop_surface);
|
|
|
|
|
min_size = weston_desktop_surface_get_min_size(shsurf->desktop_surface);
|
2012-08-01 08:08:07 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
min_size.width = MAX(1, min_size.width);
|
|
|
|
|
min_size.height = MAX(1, min_size.height);
|
2014-01-17 22:08:25 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
if (width < min_size.width)
|
|
|
|
|
width = min_size.width;
|
|
|
|
|
else if (max_size.width > 0 && width > max_size.width)
|
|
|
|
|
width = max_size.width;
|
|
|
|
|
if (height < min_size.height)
|
|
|
|
|
height = min_size.height;
|
2022-05-13 15:28:33 +03:00
|
|
|
|
else if (max_size.height > 0 && height > max_size.height)
|
|
|
|
|
height = max_size.height;
|
2016-08-12 11:41:36 +03:00
|
|
|
|
weston_desktop_surface_set_size(shsurf->desktop_surface, width, height);
|
2012-08-01 08:08:07 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2013-05-07 06:15:05 +04:00
|
|
|
|
resize_grab_button(struct weston_pointer_grab *grab,
|
2017-11-16 19:20:55 +03:00
|
|
|
|
const struct timespec *time,
|
|
|
|
|
uint32_t button, uint32_t state_w)
|
2012-08-01 08:08:07 +04:00
|
|
|
|
{
|
|
|
|
|
struct weston_resize_grab *resize = (struct weston_resize_grab *) grab;
|
2013-05-07 06:15:05 +04:00
|
|
|
|
struct weston_pointer *pointer = grab->pointer;
|
2012-08-01 08:08:07 +04:00
|
|
|
|
enum wl_pointer_button_state state = state_w;
|
|
|
|
|
|
|
|
|
|
if (pointer->button_count == 0 &&
|
|
|
|
|
state == WL_POINTER_BUTTON_STATE_RELEASED) {
|
2023-02-16 19:54:22 +03:00
|
|
|
|
if (resize->base.shsurf && resize->base.shsurf->desktop_surface) {
|
2018-11-08 00:24:56 +03:00
|
|
|
|
struct weston_desktop_surface *desktop_surface =
|
|
|
|
|
resize->base.shsurf->desktop_surface;
|
|
|
|
|
weston_desktop_surface_set_resizing(desktop_surface,
|
|
|
|
|
false);
|
2023-02-06 21:55:18 +03:00
|
|
|
|
weston_desktop_surface_set_size(desktop_surface, 0, 0);
|
2018-11-08 00:24:56 +03:00
|
|
|
|
}
|
|
|
|
|
|
2012-08-01 08:08:07 +04:00
|
|
|
|
shell_grab_end(&resize->base);
|
|
|
|
|
free(grab);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-26 01:18:05 +04:00
|
|
|
|
static void
|
|
|
|
|
resize_grab_cancel(struct weston_pointer_grab *grab)
|
|
|
|
|
{
|
|
|
|
|
struct weston_resize_grab *resize = (struct weston_resize_grab *) grab;
|
|
|
|
|
|
2023-02-16 19:54:22 +03:00
|
|
|
|
if (resize->base.shsurf && resize->base.shsurf->desktop_surface) {
|
2018-11-08 00:24:56 +03:00
|
|
|
|
struct weston_desktop_surface *desktop_surface =
|
|
|
|
|
resize->base.shsurf->desktop_surface;
|
|
|
|
|
weston_desktop_surface_set_resizing(desktop_surface, false);
|
2023-02-06 21:55:18 +03:00
|
|
|
|
weston_desktop_surface_set_size(desktop_surface, 0, 0);
|
2018-11-08 00:24:56 +03:00
|
|
|
|
}
|
|
|
|
|
|
2013-10-26 01:18:05 +04:00
|
|
|
|
shell_grab_end(&resize->base);
|
|
|
|
|
free(grab);
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-07 06:15:05 +04:00
|
|
|
|
static const struct weston_pointer_grab_interface resize_grab_interface = {
|
2012-08-01 08:08:07 +04:00
|
|
|
|
noop_grab_focus,
|
|
|
|
|
resize_grab_motion,
|
|
|
|
|
resize_grab_button,
|
2014-10-04 18:28:29 +04:00
|
|
|
|
noop_grab_axis,
|
2016-01-18 09:38:22 +03:00
|
|
|
|
noop_grab_axis_source,
|
|
|
|
|
noop_grab_frame,
|
2013-10-26 01:18:05 +04:00
|
|
|
|
resize_grab_cancel,
|
2012-08-01 08:08:07 +04:00
|
|
|
|
};
|
|
|
|
|
|
2013-04-25 14:57:46 +04:00
|
|
|
|
|
2012-08-01 08:08:07 +04:00
|
|
|
|
static int
|
|
|
|
|
surface_resize(struct shell_surface *shsurf,
|
2015-07-15 21:00:40 +03:00
|
|
|
|
struct weston_pointer *pointer, uint32_t edges)
|
2012-08-01 08:08:07 +04:00
|
|
|
|
{
|
|
|
|
|
struct weston_resize_grab *resize;
|
2014-08-21 17:47:22 +04:00
|
|
|
|
const unsigned resize_topbottom =
|
2022-02-23 18:06:23 +03:00
|
|
|
|
WESTON_DESKTOP_SURFACE_EDGE_TOP | WESTON_DESKTOP_SURFACE_EDGE_BOTTOM;
|
2014-08-21 17:47:22 +04:00
|
|
|
|
const unsigned resize_leftright =
|
2022-02-23 18:06:23 +03:00
|
|
|
|
WESTON_DESKTOP_SURFACE_EDGE_LEFT | WESTON_DESKTOP_SURFACE_EDGE_RIGHT;
|
2014-08-21 17:47:22 +04:00
|
|
|
|
const unsigned resize_any = resize_topbottom | resize_leftright;
|
2016-08-12 11:41:36 +03:00
|
|
|
|
struct weston_geometry geometry;
|
2012-08-01 08:08:07 +04:00
|
|
|
|
|
2014-05-01 03:05:49 +04:00
|
|
|
|
if (shsurf->grabbed ||
|
2016-08-12 11:41:36 +03:00
|
|
|
|
weston_desktop_surface_get_fullscreen(shsurf->desktop_surface) ||
|
|
|
|
|
weston_desktop_surface_get_maximized(shsurf->desktop_surface))
|
2012-08-01 08:08:07 +04:00
|
|
|
|
return 0;
|
|
|
|
|
|
2014-08-21 17:47:22 +04:00
|
|
|
|
/* Check for invalid edge combinations. */
|
2022-02-23 18:06:23 +03:00
|
|
|
|
if (edges == WESTON_DESKTOP_SURFACE_EDGE_NONE || edges > resize_any ||
|
2014-08-21 17:47:22 +04:00
|
|
|
|
(edges & resize_topbottom) == resize_topbottom ||
|
|
|
|
|
(edges & resize_leftright) == resize_leftright)
|
2012-08-01 08:08:07 +04:00
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
resize = malloc(sizeof *resize);
|
|
|
|
|
if (!resize)
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
resize->edges = edges;
|
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
geometry = weston_desktop_surface_get_geometry(shsurf->desktop_surface);
|
|
|
|
|
resize->width = geometry.width;
|
|
|
|
|
resize->height = geometry.height;
|
2014-07-15 00:28:48 +04:00
|
|
|
|
|
2014-02-06 09:36:04 +04:00
|
|
|
|
shsurf->resize_edges = edges;
|
2017-07-28 15:11:58 +03:00
|
|
|
|
weston_desktop_surface_set_resizing(shsurf->desktop_surface, true);
|
2022-07-29 17:04:32 +03:00
|
|
|
|
weston_desktop_surface_set_orientation(shsurf->desktop_surface,
|
|
|
|
|
WESTON_TOP_LEVEL_TILED_ORIENTATION_NONE);
|
|
|
|
|
shsurf->orientation = WESTON_TOP_LEVEL_TILED_ORIENTATION_NONE;
|
2012-08-01 08:08:07 +04:00
|
|
|
|
shell_grab_start(&resize->base, &resize_grab_interface, shsurf,
|
2015-07-15 21:00:40 +03:00
|
|
|
|
pointer, edges);
|
2012-08-01 08:08:07 +04:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-18 05:06:20 +04:00
|
|
|
|
static void
|
2013-05-09 06:02:59 +04:00
|
|
|
|
busy_cursor_grab_focus(struct weston_pointer_grab *base)
|
2012-04-18 05:06:20 +04:00
|
|
|
|
{
|
2012-06-05 17:58:51 +04:00
|
|
|
|
struct shell_grab *grab = (struct shell_grab *) base;
|
2013-05-09 06:02:59 +04:00
|
|
|
|
struct weston_pointer *pointer = base->pointer;
|
2016-08-12 11:41:36 +03:00
|
|
|
|
struct weston_desktop_surface *desktop_surface;
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
struct weston_view *view;
|
2013-05-09 06:02:59 +04:00
|
|
|
|
|
2022-02-04 01:40:10 +03:00
|
|
|
|
view = weston_compositor_pick_view(pointer->seat->compositor,
|
|
|
|
|
pointer->pos);
|
2016-08-12 11:41:36 +03:00
|
|
|
|
desktop_surface = weston_surface_get_desktop_surface(view->surface);
|
2012-04-18 05:06:20 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
if (!grab->shsurf || grab->shsurf->desktop_surface != desktop_surface) {
|
2014-02-12 00:22:51 +04:00
|
|
|
|
shell_grab_end(grab);
|
|
|
|
|
free(grab);
|
|
|
|
|
}
|
2012-04-18 05:06:20 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2017-11-24 19:01:46 +03:00
|
|
|
|
busy_cursor_grab_motion(struct weston_pointer_grab *grab,
|
|
|
|
|
const struct timespec *time,
|
2014-10-05 23:39:14 +04:00
|
|
|
|
struct weston_pointer_motion_event *event)
|
2012-04-18 05:06:20 +04:00
|
|
|
|
{
|
2014-10-05 23:39:14 +04:00
|
|
|
|
weston_pointer_move(grab->pointer, event);
|
2012-06-05 17:58:51 +04:00
|
|
|
|
}
|
2012-04-18 05:06:20 +04:00
|
|
|
|
|
2012-06-05 17:58:51 +04:00
|
|
|
|
static void
|
2013-05-07 06:15:05 +04:00
|
|
|
|
busy_cursor_grab_button(struct weston_pointer_grab *base,
|
2017-11-16 19:20:55 +03:00
|
|
|
|
const struct timespec *time,
|
|
|
|
|
uint32_t button, uint32_t state)
|
2012-06-05 17:58:51 +04:00
|
|
|
|
{
|
2012-08-01 08:20:21 +04:00
|
|
|
|
struct shell_grab *grab = (struct shell_grab *) base;
|
2013-05-09 00:47:00 +04:00
|
|
|
|
struct shell_surface *shsurf = grab->shsurf;
|
2015-07-15 21:00:38 +03:00
|
|
|
|
struct weston_pointer *pointer = grab->grab.pointer;
|
|
|
|
|
struct weston_seat *seat = pointer->seat;
|
2012-08-01 08:20:21 +04:00
|
|
|
|
|
|
|
|
|
if (shsurf && button == BTN_LEFT && state) {
|
2014-10-18 20:20:16 +04:00
|
|
|
|
activate(shsurf->shell, shsurf->view, seat,
|
|
|
|
|
WESTON_ACTIVATE_FLAG_CONFIGURE);
|
2015-07-15 21:00:38 +03:00
|
|
|
|
surface_move(shsurf, pointer, false);
|
2013-02-15 06:31:44 +04:00
|
|
|
|
} else if (shsurf && button == BTN_RIGHT && state) {
|
2014-10-18 20:20:16 +04:00
|
|
|
|
activate(shsurf->shell, shsurf->view, seat,
|
|
|
|
|
WESTON_ACTIVATE_FLAG_CONFIGURE);
|
2015-07-15 21:00:39 +03:00
|
|
|
|
surface_rotate(shsurf, pointer);
|
2012-08-01 08:20:21 +04:00
|
|
|
|
}
|
2012-06-05 17:58:51 +04:00
|
|
|
|
}
|
|
|
|
|
|
2013-10-26 01:18:05 +04:00
|
|
|
|
static void
|
|
|
|
|
busy_cursor_grab_cancel(struct weston_pointer_grab *base)
|
|
|
|
|
{
|
|
|
|
|
struct shell_grab *grab = (struct shell_grab *) base;
|
|
|
|
|
|
|
|
|
|
shell_grab_end(grab);
|
|
|
|
|
free(grab);
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-07 06:15:05 +04:00
|
|
|
|
static const struct weston_pointer_grab_interface busy_cursor_grab_interface = {
|
2012-06-05 17:58:51 +04:00
|
|
|
|
busy_cursor_grab_focus,
|
|
|
|
|
busy_cursor_grab_motion,
|
|
|
|
|
busy_cursor_grab_button,
|
2014-10-04 18:28:29 +04:00
|
|
|
|
noop_grab_axis,
|
2016-01-18 09:38:22 +03:00
|
|
|
|
noop_grab_axis_source,
|
|
|
|
|
noop_grab_frame,
|
2013-10-26 01:18:05 +04:00
|
|
|
|
busy_cursor_grab_cancel,
|
2012-06-05 17:58:51 +04:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void
|
2016-08-12 11:41:36 +03:00
|
|
|
|
handle_pointer_focus(struct wl_listener *listener, void *data)
|
2014-02-12 00:22:51 +04:00
|
|
|
|
{
|
2016-08-12 11:41:36 +03:00
|
|
|
|
struct weston_pointer *pointer = data;
|
|
|
|
|
struct weston_view *view = pointer->focus;
|
2014-02-12 00:22:51 +04:00
|
|
|
|
struct shell_surface *shsurf;
|
2016-08-12 11:41:36 +03:00
|
|
|
|
struct weston_desktop_client *client;
|
2014-02-12 00:22:51 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
if (!view)
|
2014-02-12 00:22:51 +04:00
|
|
|
|
return;
|
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
shsurf = get_shell_surface(view->surface);
|
2012-04-18 05:06:18 +04:00
|
|
|
|
if (!shsurf)
|
|
|
|
|
return;
|
2012-06-05 17:58:51 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
client = weston_desktop_surface_get_client(shsurf->desktop_surface);
|
2012-06-05 17:58:51 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
if (shsurf->unresponsive)
|
|
|
|
|
set_busy_cursor(shsurf, pointer);
|
|
|
|
|
else
|
|
|
|
|
weston_desktop_client_ping(client);
|
2012-06-05 17:58:51 +04:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-19 19:45:26 +03:00
|
|
|
|
static void
|
|
|
|
|
has_keyboard_focused_child_callback(struct weston_desktop_surface *surface,
|
|
|
|
|
void *user_data);
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
has_keyboard_focused_child_callback(struct weston_desktop_surface *surface,
|
|
|
|
|
void *user_data)
|
|
|
|
|
{
|
|
|
|
|
struct weston_surface *es = weston_desktop_surface_get_surface(surface);
|
|
|
|
|
struct shell_surface *shsurf = get_shell_surface(es);
|
|
|
|
|
bool *has_keyboard_focus = user_data;
|
|
|
|
|
|
|
|
|
|
if (shsurf->focus_count > 0) {
|
|
|
|
|
*has_keyboard_focus = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
weston_desktop_surface_foreach_child(shsurf->desktop_surface,
|
|
|
|
|
has_keyboard_focused_child_callback,
|
|
|
|
|
&has_keyboard_focus);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool
|
|
|
|
|
has_keyboard_focused_child(struct shell_surface *shsurf)
|
|
|
|
|
{
|
|
|
|
|
bool has_keyboard_focus = false;
|
|
|
|
|
|
|
|
|
|
if (shsurf->focus_count > 0)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
weston_desktop_surface_foreach_child(shsurf->desktop_surface,
|
|
|
|
|
has_keyboard_focused_child_callback,
|
|
|
|
|
&has_keyboard_focus);
|
|
|
|
|
|
|
|
|
|
return has_keyboard_focus;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
sync_surface_activated_state(struct shell_surface *shsurf)
|
|
|
|
|
{
|
|
|
|
|
struct weston_desktop_surface *surface = shsurf->desktop_surface;
|
|
|
|
|
struct weston_desktop_surface *parent;
|
|
|
|
|
struct weston_surface *parent_surface;
|
|
|
|
|
|
|
|
|
|
parent = weston_desktop_surface_get_parent(surface);
|
|
|
|
|
if (parent) {
|
|
|
|
|
parent_surface = weston_desktop_surface_get_surface(parent);
|
|
|
|
|
sync_surface_activated_state(get_shell_surface(parent_surface));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (has_keyboard_focused_child(shsurf))
|
|
|
|
|
weston_desktop_surface_set_activated(surface, true);
|
|
|
|
|
else
|
|
|
|
|
weston_desktop_surface_set_activated(surface, false);
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-19 11:33:33 +03:00
|
|
|
|
static void
|
|
|
|
|
handle_tablet_tool_focus(struct wl_listener *listener, void *data)
|
|
|
|
|
{
|
|
|
|
|
struct weston_tablet_tool *tool = data;
|
|
|
|
|
struct weston_view *view = tool->focus;
|
|
|
|
|
struct shell_surface *shsurf;
|
|
|
|
|
struct weston_desktop_client *client;
|
|
|
|
|
|
|
|
|
|
if (!view)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
shsurf = get_shell_surface(view->surface);
|
|
|
|
|
if (!shsurf)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
client = weston_desktop_surface_get_client(shsurf->desktop_surface);
|
|
|
|
|
|
|
|
|
|
weston_desktop_client_ping(client);
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-10 02:36:28 +04:00
|
|
|
|
static void
|
2021-03-05 22:40:22 +03:00
|
|
|
|
shell_surface_deactivate(struct shell_surface *shsurf)
|
2013-12-10 02:36:28 +04:00
|
|
|
|
{
|
|
|
|
|
if (--shsurf->focus_count == 0)
|
2019-02-19 19:45:26 +03:00
|
|
|
|
sync_surface_activated_state(shsurf);
|
2013-12-10 02:36:28 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2021-03-05 22:40:22 +03:00
|
|
|
|
shell_surface_activate(struct shell_surface *shsurf)
|
2013-12-10 02:36:28 +04:00
|
|
|
|
{
|
|
|
|
|
if (shsurf->focus_count++ == 0)
|
2019-02-19 19:45:26 +03:00
|
|
|
|
sync_surface_activated_state(shsurf);
|
2013-12-10 02:36:28 +04:00
|
|
|
|
}
|
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
/* The surface will be inserted into the list immediately after the link
|
|
|
|
|
* returned by this function (i.e. will be stacked immediately above the
|
|
|
|
|
* returned link). */
|
|
|
|
|
static struct weston_layer_entry *
|
|
|
|
|
shell_surface_calculate_layer_link (struct shell_surface *shsurf)
|
2014-02-12 21:56:19 +04:00
|
|
|
|
{
|
2016-08-12 11:41:36 +03:00
|
|
|
|
struct workspace *ws;
|
2014-02-12 21:56:19 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
if (weston_desktop_surface_get_fullscreen(shsurf->desktop_surface) &&
|
|
|
|
|
!shsurf->state.lowered) {
|
|
|
|
|
return &shsurf->shell->fullscreen_layer.view_list;
|
2012-04-18 05:06:18 +04:00
|
|
|
|
}
|
2014-02-12 21:56:19 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
/* Move the surface to a normal workspace layer so that surfaces
|
|
|
|
|
* which were previously fullscreen or transient are no longer
|
|
|
|
|
* rendered on top. */
|
|
|
|
|
ws = get_current_workspace(shsurf->shell);
|
|
|
|
|
return &ws->layer.view_list;
|
2012-04-18 05:06:18 +04:00
|
|
|
|
}
|
|
|
|
|
|
2013-12-03 21:35:45 +04:00
|
|
|
|
static void
|
2016-08-12 11:41:36 +03:00
|
|
|
|
shell_surface_update_child_surface_layers (struct shell_surface *shsurf)
|
2013-09-11 20:20:47 +04:00
|
|
|
|
{
|
2016-08-12 11:41:36 +03:00
|
|
|
|
weston_desktop_surface_propagate_layer(shsurf->desktop_surface);
|
compositor: Implement JSON-timeline logging
Logging is activated and deactivated with the debug key binding 't'.
When activated, it creates a new log file, where it records the events.
The log file contains events and detailed object information entries in
JSON format, and is meant to be parsed in sequence from beginning to the
end.
The emitted events are mostly related to the output repaint cycle, like
when repaint begins, is submitted to GPU, and when it completes on a
vblank. This is recorded per-output. Also some per-surface events are
recorded, including when surface damage is flushed.
To reduce the log size, events refer to objects like outputs and
surfaces by id numbers. Detailed object information is emitted only as
needed: on the first object occurrence, and afterwards only if
weston_timeline_object::force_refresh asks for it.
The detailed information for surfaces includes the string returned by
weston_surface::get_label. Therefore it is important to set
weston_timeline_object::force_refresh = 1 whenever the string would
change, so that the new details get recorded.
A rudimentary parser and SVG generator can be found at:
https://github.com/ppaalanen/wesgr
The timeline logs can answer questions including:
- How does the compositor repaint cycle work timing-wise?
- When was the vblank deadline missed?
- What is the latency from surface commit to showing the new content on
screen?
- How long does it take to process the scenegraph?
v2: weston_surface::get_description renamed to get_label.
v3: reafctor a bit into fprint_quoted_string().
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-11-12 16:09:24 +03:00
|
|
|
|
}
|
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
/* Update the surface’s layer. Mark both the old and new views as having dirty
|
|
|
|
|
* geometry to ensure the changes are redrawn.
|
|
|
|
|
*
|
|
|
|
|
* If any child surfaces exist and are mapped, ensure they’re in the same layer
|
|
|
|
|
* as this surface. */
|
2015-01-27 20:10:37 +03:00
|
|
|
|
static void
|
2016-08-12 11:41:36 +03:00
|
|
|
|
shell_surface_update_layer(struct shell_surface *shsurf)
|
2015-01-27 20:10:37 +03:00
|
|
|
|
{
|
2016-08-12 11:41:36 +03:00
|
|
|
|
struct weston_surface *surface =
|
|
|
|
|
weston_desktop_surface_get_surface(shsurf->desktop_surface);
|
|
|
|
|
struct weston_layer_entry *new_layer_link;
|
2015-01-27 20:10:37 +03:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
new_layer_link = shell_surface_calculate_layer_link(shsurf);
|
2013-11-25 22:01:41 +04:00
|
|
|
|
|
2014-04-30 15:15:14 +04:00
|
|
|
|
if (new_layer_link == NULL)
|
|
|
|
|
return;
|
2013-11-25 22:01:41 +04:00
|
|
|
|
if (new_layer_link == &shsurf->view->layer_link)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
weston_view_geometry_dirty(shsurf->view);
|
2014-07-09 23:12:56 +04:00
|
|
|
|
weston_layer_entry_remove(&shsurf->view->layer_link);
|
|
|
|
|
weston_layer_entry_insert(new_layer_link, &shsurf->view->layer_link);
|
2013-11-25 22:01:41 +04:00
|
|
|
|
weston_view_geometry_dirty(shsurf->view);
|
2016-08-12 11:41:36 +03:00
|
|
|
|
weston_surface_damage(surface);
|
2013-11-25 22:01:44 +04:00
|
|
|
|
|
|
|
|
|
shell_surface_update_child_surface_layers(shsurf);
|
2013-11-25 22:01:41 +04:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-02 12:10:32 +03:00
|
|
|
|
static void
|
|
|
|
|
notify_output_destroy(struct wl_listener *listener, void *data)
|
|
|
|
|
{
|
|
|
|
|
struct shell_surface *shsurf =
|
|
|
|
|
container_of(listener,
|
|
|
|
|
struct shell_surface, output_destroy_listener);
|
|
|
|
|
|
|
|
|
|
shsurf->output = NULL;
|
|
|
|
|
shsurf->output_destroy_listener.notify = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-25 22:01:35 +04:00
|
|
|
|
static void
|
|
|
|
|
shell_surface_set_output(struct shell_surface *shsurf,
|
|
|
|
|
struct weston_output *output)
|
|
|
|
|
{
|
2016-08-12 11:41:36 +03:00
|
|
|
|
struct weston_surface *es =
|
|
|
|
|
weston_desktop_surface_get_surface(shsurf->desktop_surface);
|
2013-11-25 22:01:35 +04:00
|
|
|
|
|
|
|
|
|
/* get the default output, if the client set it as NULL
|
2017-01-01 17:46:33 +03:00
|
|
|
|
check whether the output is available */
|
2013-11-25 22:01:35 +04:00
|
|
|
|
if (output)
|
|
|
|
|
shsurf->output = output;
|
|
|
|
|
else if (es->output)
|
|
|
|
|
shsurf->output = es->output;
|
|
|
|
|
else
|
2022-11-22 14:28:57 +03:00
|
|
|
|
shsurf->output = weston_shell_utils_get_default_output(es->compositor);
|
2018-05-02 12:10:32 +03:00
|
|
|
|
|
|
|
|
|
if (shsurf->output_destroy_listener.notify) {
|
|
|
|
|
wl_list_remove(&shsurf->output_destroy_listener.link);
|
|
|
|
|
shsurf->output_destroy_listener.notify = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!shsurf->output)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
shsurf->output_destroy_listener.notify = notify_output_destroy;
|
|
|
|
|
wl_signal_add(&shsurf->output->destroy_signal,
|
|
|
|
|
&shsurf->output_destroy_listener);
|
2013-11-25 22:01:35 +04:00
|
|
|
|
}
|
|
|
|
|
|
2013-12-14 00:10:57 +04:00
|
|
|
|
static void
|
|
|
|
|
weston_view_set_initial_position(struct weston_view *view,
|
|
|
|
|
struct desktop_shell *shell);
|
|
|
|
|
|
2013-11-25 22:01:30 +04:00
|
|
|
|
static void
|
|
|
|
|
unset_fullscreen(struct shell_surface *shsurf)
|
2012-03-01 08:57:46 +04:00
|
|
|
|
{
|
2013-11-25 22:01:37 +04:00
|
|
|
|
/* Unset the fullscreen output, driver configuration and transforms. */
|
2012-03-01 08:57:46 +04:00
|
|
|
|
wl_list_remove(&shsurf->fullscreen.transform.link);
|
|
|
|
|
wl_list_init(&shsurf->fullscreen.transform.link);
|
2013-11-25 22:01:37 +04:00
|
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
if (shsurf->fullscreen.black_view)
|
2022-11-22 14:28:57 +03:00
|
|
|
|
weston_shell_utils_curtain_destroy(shsurf->fullscreen.black_view);
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
shsurf->fullscreen.black_view = NULL;
|
2013-11-25 22:01:37 +04:00
|
|
|
|
|
2013-12-14 00:10:57 +04:00
|
|
|
|
if (shsurf->saved_position_valid)
|
|
|
|
|
weston_view_set_position(shsurf->view,
|
2022-02-04 19:50:07 +03:00
|
|
|
|
shsurf->saved_pos.c.x,
|
|
|
|
|
shsurf->saved_pos.c.y);
|
2013-12-14 00:10:57 +04:00
|
|
|
|
else
|
|
|
|
|
weston_view_set_initial_position(shsurf->view, shsurf->shell);
|
2016-08-16 15:26:20 +03:00
|
|
|
|
shsurf->saved_position_valid = false;
|
2013-12-14 00:10:57 +04:00
|
|
|
|
|
2022-07-29 17:04:32 +03:00
|
|
|
|
weston_desktop_surface_set_orientation(shsurf->desktop_surface,
|
|
|
|
|
shsurf->orientation);
|
|
|
|
|
|
2012-04-27 05:07:24 +04:00
|
|
|
|
if (shsurf->saved_rotation_valid) {
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
wl_list_insert(&shsurf->view->geometry.transformation_list,
|
2013-11-25 22:01:30 +04:00
|
|
|
|
&shsurf->rotation.transform.link);
|
2012-04-27 05:07:24 +04:00
|
|
|
|
shsurf->saved_rotation_valid = false;
|
|
|
|
|
}
|
2012-03-01 08:57:46 +04:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-25 22:01:30 +04:00
|
|
|
|
static void
|
|
|
|
|
unset_maximized(struct shell_surface *shsurf)
|
2013-03-11 22:26:54 +04:00
|
|
|
|
{
|
2016-08-12 11:41:36 +03:00
|
|
|
|
struct weston_surface *surface =
|
|
|
|
|
weston_desktop_surface_get_surface(shsurf->desktop_surface);
|
|
|
|
|
|
2013-03-11 22:26:54 +04:00
|
|
|
|
/* undo all maximized things here */
|
2022-11-22 14:28:57 +03:00
|
|
|
|
shell_surface_set_output(shsurf,
|
|
|
|
|
weston_shell_utils_get_default_output(surface->compositor));
|
2013-12-14 00:10:57 +04:00
|
|
|
|
|
|
|
|
|
if (shsurf->saved_position_valid)
|
|
|
|
|
weston_view_set_position(shsurf->view,
|
2022-02-04 19:50:07 +03:00
|
|
|
|
shsurf->saved_pos.c.x,
|
|
|
|
|
shsurf->saved_pos.c.y);
|
2013-12-14 00:10:57 +04:00
|
|
|
|
else
|
|
|
|
|
weston_view_set_initial_position(shsurf->view, shsurf->shell);
|
2016-08-16 15:26:20 +03:00
|
|
|
|
shsurf->saved_position_valid = false;
|
2013-03-11 22:26:54 +04:00
|
|
|
|
|
2022-07-29 17:04:32 +03:00
|
|
|
|
weston_desktop_surface_set_orientation(shsurf->desktop_surface,
|
|
|
|
|
shsurf->orientation);
|
|
|
|
|
|
2013-03-11 22:26:54 +04:00
|
|
|
|
if (shsurf->saved_rotation_valid) {
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
wl_list_insert(&shsurf->view->geometry.transformation_list,
|
|
|
|
|
&shsurf->rotation.transform.link);
|
2013-03-11 22:26:54 +04:00
|
|
|
|
shsurf->saved_rotation_valid = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-26 18:52:13 +04:00
|
|
|
|
static void
|
2015-02-16 13:52:13 +03:00
|
|
|
|
set_minimized(struct weston_surface *surface)
|
2014-02-26 18:52:13 +04:00
|
|
|
|
{
|
|
|
|
|
struct shell_surface *shsurf;
|
|
|
|
|
struct workspace *current_ws;
|
|
|
|
|
struct weston_view *view;
|
2021-10-01 12:12:21 +03:00
|
|
|
|
struct weston_subsurface *subsurface;
|
2014-02-26 18:52:13 +04:00
|
|
|
|
|
|
|
|
|
view = get_default_view(surface);
|
|
|
|
|
if (!view)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
assert(weston_surface_get_main_surface(view->surface) == view->surface);
|
|
|
|
|
|
|
|
|
|
shsurf = get_shell_surface(surface);
|
|
|
|
|
current_ws = get_current_workspace(shsurf->shell);
|
|
|
|
|
|
2014-07-09 23:12:56 +04:00
|
|
|
|
weston_layer_entry_remove(&view->layer_link);
|
2015-02-16 13:52:13 +03:00
|
|
|
|
weston_layer_entry_insert(&shsurf->shell->minimized_layer.view_list, &view->layer_link);
|
2014-02-26 18:52:13 +04:00
|
|
|
|
|
2015-02-16 13:52:13 +03:00
|
|
|
|
drop_focus_state(shsurf->shell, current_ws, view->surface);
|
2014-10-16 00:02:06 +04:00
|
|
|
|
surface_keyboard_focus_lost(surface);
|
2014-02-26 18:52:13 +04:00
|
|
|
|
|
|
|
|
|
shell_surface_update_child_surface_layers(shsurf);
|
2021-10-01 12:12:21 +03:00
|
|
|
|
|
|
|
|
|
weston_view_damage_below(shsurf->view);
|
|
|
|
|
wl_list_for_each(subsurface, &surface->subsurface_list, parent_link) {
|
|
|
|
|
wl_list_for_each(view, &subsurface->surface->views, surface_link)
|
|
|
|
|
weston_view_damage_below(view);
|
|
|
|
|
}
|
2014-02-26 18:52:13 +04:00
|
|
|
|
}
|
|
|
|
|
|
2012-04-28 01:20:01 +04:00
|
|
|
|
|
2012-04-16 18:31:41 +04:00
|
|
|
|
static struct desktop_shell *
|
2012-02-07 04:45:41 +04:00
|
|
|
|
shell_surface_get_shell(struct shell_surface *shsurf)
|
2011-12-02 12:59:17 +04:00
|
|
|
|
{
|
2012-04-12 17:55:26 +04:00
|
|
|
|
return shsurf->shell;
|
2012-02-07 04:45:41 +04:00
|
|
|
|
}
|
|
|
|
|
|
compositor: add weston_surface_set_label_func()
When printing out logs from Weston's actions, mainly for debugging, it
can be very difficult to identify the different surfaces. Inspecting
the configure function pointer is not useful, as the configure functions
may live in modules.
Add vfunc get_label to weston_surface, which will produce a short,
human-readable description of the surface, which allows identifying it
better, rather than just looking at the surface size, for instance.
Set the label function from most parts of Weston, to identify cursors and
drag icons, and panels, backgrounds, screensavers and lock surfaces, and
the desktop shell's application surfaces.
v2: renamed 'description' to 'label', so we get
weston_surface_set_label_func().
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-08-06 20:36:51 +04:00
|
|
|
|
static int
|
|
|
|
|
black_surface_get_label(struct weston_surface *surface, char *buf, size_t len)
|
|
|
|
|
{
|
2016-08-12 11:41:33 +03:00
|
|
|
|
struct weston_view *fs_view = surface->committed_private;
|
2014-10-18 14:23:20 +04:00
|
|
|
|
struct weston_surface *fs_surface = fs_view->surface;
|
compositor: add weston_surface_set_label_func()
When printing out logs from Weston's actions, mainly for debugging, it
can be very difficult to identify the different surfaces. Inspecting
the configure function pointer is not useful, as the configure functions
may live in modules.
Add vfunc get_label to weston_surface, which will produce a short,
human-readable description of the surface, which allows identifying it
better, rather than just looking at the surface size, for instance.
Set the label function from most parts of Weston, to identify cursors and
drag icons, and panels, backgrounds, screensavers and lock surfaces, and
the desktop shell's application surfaces.
v2: renamed 'description' to 'label', so we get
weston_surface_set_label_func().
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-08-06 20:36:51 +04:00
|
|
|
|
int n;
|
|
|
|
|
int rem;
|
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
|
|
n = snprintf(buf, len, "black background surface for ");
|
|
|
|
|
if (n < 0)
|
|
|
|
|
return n;
|
|
|
|
|
|
|
|
|
|
rem = (int)len - n;
|
|
|
|
|
if (rem < 0)
|
|
|
|
|
rem = 0;
|
|
|
|
|
|
|
|
|
|
if (fs_surface->get_label)
|
|
|
|
|
ret = fs_surface->get_label(fs_surface, buf + n, rem);
|
|
|
|
|
else
|
|
|
|
|
ret = snprintf(buf + n, rem, "<unknown>");
|
|
|
|
|
|
|
|
|
|
if (ret < 0)
|
|
|
|
|
return n;
|
|
|
|
|
|
|
|
|
|
return n + ret;
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-01 16:13:08 +04:00
|
|
|
|
static void
|
2022-02-04 17:02:26 +03:00
|
|
|
|
black_surface_committed(struct weston_surface *es,
|
|
|
|
|
struct weston_coord_surface new_origin)
|
2022-01-18 21:28:42 +03:00
|
|
|
|
{
|
|
|
|
|
}
|
2012-04-01 16:13:08 +04:00
|
|
|
|
|
2022-01-18 21:28:42 +03:00
|
|
|
|
static bool
|
|
|
|
|
is_black_surface_view(struct weston_view *view, struct weston_view **fs_view)
|
2012-03-01 08:57:46 +04:00
|
|
|
|
{
|
2022-01-18 21:28:42 +03:00
|
|
|
|
struct weston_surface *surface = view->surface;
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
|
2022-01-18 21:28:42 +03:00
|
|
|
|
if (surface->committed == black_surface_committed) {
|
|
|
|
|
if (fs_view)
|
|
|
|
|
*fs_view = surface->committed_private;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
2012-03-01 08:57:46 +04:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-25 22:01:43 +04:00
|
|
|
|
static void
|
|
|
|
|
shell_ensure_fullscreen_black_view(struct shell_surface *shsurf)
|
|
|
|
|
{
|
2016-08-12 11:41:36 +03:00
|
|
|
|
struct weston_surface *surface =
|
|
|
|
|
weston_desktop_surface_get_surface(shsurf->desktop_surface);
|
2022-01-18 21:28:42 +03:00
|
|
|
|
struct weston_compositor *ec = surface->compositor;
|
2013-11-25 22:01:43 +04:00
|
|
|
|
struct weston_output *output = shsurf->fullscreen_output;
|
2022-01-18 21:28:42 +03:00
|
|
|
|
struct weston_curtain_params curtain_params = {
|
|
|
|
|
.r = 0.0, .g = 0.0, .b = 0.0, .a = 1.0,
|
|
|
|
|
.x = output->x, .y = output->y,
|
|
|
|
|
.width = output->width, .height = output->height,
|
|
|
|
|
.surface_committed = black_surface_committed,
|
|
|
|
|
.get_label = black_surface_get_label,
|
|
|
|
|
.surface_private = shsurf->view,
|
2022-01-18 21:59:33 +03:00
|
|
|
|
.capture_input = true,
|
2022-01-18 21:28:42 +03:00
|
|
|
|
};
|
2022-01-17 17:24:03 +03:00
|
|
|
|
struct weston_view *view;
|
2013-11-25 22:01:43 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
assert(weston_desktop_surface_get_fullscreen(shsurf->desktop_surface));
|
2013-11-25 22:01:43 +04:00
|
|
|
|
|
2022-01-18 21:28:42 +03:00
|
|
|
|
if (!shsurf->fullscreen.black_view) {
|
2013-11-25 22:01:43 +04:00
|
|
|
|
shsurf->fullscreen.black_view =
|
2022-11-22 14:28:57 +03:00
|
|
|
|
weston_shell_utils_curtain_create(ec, &curtain_params);
|
2022-01-18 21:28:42 +03:00
|
|
|
|
}
|
2022-01-17 17:24:03 +03:00
|
|
|
|
view = shsurf->fullscreen.black_view->view;
|
2022-01-18 21:28:42 +03:00
|
|
|
|
|
2022-01-17 17:24:03 +03:00
|
|
|
|
weston_view_set_output(view, output);
|
|
|
|
|
view->is_mapped = true;
|
2013-11-25 22:01:43 +04:00
|
|
|
|
|
2022-01-17 17:24:03 +03:00
|
|
|
|
weston_layer_entry_remove(&view->layer_link);
|
|
|
|
|
weston_layer_entry_insert(&shsurf->view->layer_link, &view->layer_link);
|
|
|
|
|
weston_view_geometry_dirty(view);
|
2016-08-12 11:41:36 +03:00
|
|
|
|
weston_surface_damage(surface);
|
2014-01-30 17:01:10 +04:00
|
|
|
|
|
|
|
|
|
shsurf->state.lowered = false;
|
2013-11-25 22:01:43 +04:00
|
|
|
|
}
|
|
|
|
|
|
2012-03-01 08:57:46 +04:00
|
|
|
|
/* Create black surface and append it to the associated fullscreen surface.
|
|
|
|
|
* Handle size dismatch and positioning according to the method. */
|
|
|
|
|
static void
|
|
|
|
|
shell_configure_fullscreen(struct shell_surface *shsurf)
|
|
|
|
|
{
|
2016-08-12 11:41:36 +03:00
|
|
|
|
struct weston_surface *surface =
|
|
|
|
|
weston_desktop_surface_get_surface(shsurf->desktop_surface);
|
2013-04-25 14:57:46 +04:00
|
|
|
|
int32_t surf_x, surf_y, surf_width, surf_height;
|
2012-03-01 08:57:46 +04:00
|
|
|
|
|
2014-01-30 17:01:10 +04:00
|
|
|
|
/* Reverse the effect of lower_fullscreen_layer() */
|
2014-07-09 23:12:56 +04:00
|
|
|
|
weston_layer_entry_remove(&shsurf->view->layer_link);
|
2016-08-12 11:41:36 +03:00
|
|
|
|
weston_layer_entry_insert(&shsurf->shell->fullscreen_layer.view_list,
|
|
|
|
|
&shsurf->view->layer_link);
|
2014-01-30 17:01:10 +04:00
|
|
|
|
|
2018-05-02 11:21:58 +03:00
|
|
|
|
if (!shsurf->fullscreen_output) {
|
|
|
|
|
/* If there is no output, there's not much we can do.
|
|
|
|
|
* Position the window somewhere, whatever. */
|
|
|
|
|
weston_view_set_position(shsurf->view, 0, 0);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-25 22:01:43 +04:00
|
|
|
|
shell_ensure_fullscreen_black_view(shsurf);
|
2012-03-01 08:57:46 +04:00
|
|
|
|
|
2022-11-22 14:28:57 +03:00
|
|
|
|
weston_shell_utils_subsurfaces_boundingbox(surface, &surf_x, &surf_y,
|
|
|
|
|
&surf_width, &surf_height);
|
2013-04-25 14:57:46 +04:00
|
|
|
|
|
2022-06-15 17:56:24 +03:00
|
|
|
|
if (weston_surface_has_content(surface))
|
2022-11-22 14:28:57 +03:00
|
|
|
|
weston_shell_utils_center_on_output(shsurf->view, shsurf->fullscreen_output);
|
2012-03-01 08:57:46 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
shell_map_fullscreen(struct shell_surface *shsurf)
|
|
|
|
|
{
|
2012-04-17 13:20:49 +04:00
|
|
|
|
shell_configure_fullscreen(shsurf);
|
2012-03-01 08:57:46 +04:00
|
|
|
|
}
|
|
|
|
|
|
2021-08-26 16:37:24 +03:00
|
|
|
|
static void
|
|
|
|
|
desktop_shell_destroy_seat(struct shell_seat *shseat)
|
|
|
|
|
{
|
2021-10-26 19:40:44 +03:00
|
|
|
|
|
2021-08-26 16:38:43 +03:00
|
|
|
|
wl_list_remove(&shseat->keyboard_focus_listener.link);
|
|
|
|
|
wl_list_remove(&shseat->caps_changed_listener.link);
|
|
|
|
|
wl_list_remove(&shseat->pointer_focus_listener.link);
|
2021-08-26 16:37:24 +03:00
|
|
|
|
wl_list_remove(&shseat->seat_destroy_listener.link);
|
2017-12-19 11:33:33 +03:00
|
|
|
|
wl_list_remove(&shseat->tablet_tool_added_listener.link);
|
2021-08-26 16:37:24 +03:00
|
|
|
|
|
|
|
|
|
wl_list_remove(&shseat->link);
|
|
|
|
|
free(shseat);
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-19 11:33:33 +03:00
|
|
|
|
static void
|
|
|
|
|
destroy_tablet_tool_listener(struct wl_listener *listener, void *data)
|
|
|
|
|
{
|
|
|
|
|
struct tablet_tool_listener *tool_listener =
|
|
|
|
|
container_of(listener, struct tablet_tool_listener, removed_listener);
|
|
|
|
|
|
|
|
|
|
wl_list_remove(&tool_listener->removed_listener.link);
|
|
|
|
|
wl_list_remove(&tool_listener->base.link);
|
|
|
|
|
free(tool_listener);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
handle_tablet_tool_added(struct wl_listener *listener, void *data)
|
|
|
|
|
{
|
|
|
|
|
struct weston_tablet_tool *tool = data;
|
|
|
|
|
struct tablet_tool_listener *tool_listener;
|
|
|
|
|
|
|
|
|
|
tool_listener = malloc(sizeof *tool_listener);
|
|
|
|
|
if (!tool_listener) {
|
|
|
|
|
weston_log("no memory to allocate to shell seat tablet listener\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tool_listener->removed_listener.notify = destroy_tablet_tool_listener;
|
|
|
|
|
wl_signal_add(&tool->removed_signal,
|
|
|
|
|
&tool_listener->removed_listener);
|
|
|
|
|
|
|
|
|
|
tool_listener->base.notify = handle_tablet_tool_focus;
|
|
|
|
|
wl_signal_add(&tool->focus_signal, &tool_listener->base);
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-26 00:42:45 +04:00
|
|
|
|
static void
|
|
|
|
|
destroy_shell_seat(struct wl_listener *listener, void *data)
|
|
|
|
|
{
|
|
|
|
|
struct shell_seat *shseat =
|
|
|
|
|
container_of(listener,
|
|
|
|
|
struct shell_seat, seat_destroy_listener);
|
|
|
|
|
|
2021-08-26 16:37:24 +03:00
|
|
|
|
desktop_shell_destroy_seat(shseat);
|
2013-03-26 00:42:45 +04:00
|
|
|
|
}
|
|
|
|
|
|
2014-04-22 04:42:58 +04:00
|
|
|
|
static void
|
|
|
|
|
shell_seat_caps_changed(struct wl_listener *listener, void *data)
|
|
|
|
|
{
|
2015-08-01 00:55:32 +03:00
|
|
|
|
struct weston_pointer *pointer;
|
2014-04-22 04:42:58 +04:00
|
|
|
|
struct shell_seat *seat;
|
|
|
|
|
|
|
|
|
|
seat = container_of(listener, struct shell_seat, caps_changed_listener);
|
2015-08-01 00:55:32 +03:00
|
|
|
|
pointer = weston_seat_get_pointer(seat->seat);
|
2014-04-22 04:42:58 +04:00
|
|
|
|
|
2015-08-01 00:55:32 +03:00
|
|
|
|
if (pointer &&
|
2014-04-22 04:42:58 +04:00
|
|
|
|
wl_list_empty(&seat->pointer_focus_listener.link)) {
|
2015-08-01 00:55:32 +03:00
|
|
|
|
wl_signal_add(&pointer->focus_signal,
|
2014-04-22 04:42:58 +04:00
|
|
|
|
&seat->pointer_focus_listener);
|
2015-08-01 00:55:32 +03:00
|
|
|
|
} else if (!pointer) {
|
2015-07-15 21:00:45 +03:00
|
|
|
|
wl_list_remove(&seat->pointer_focus_listener.link);
|
2014-04-22 04:42:58 +04:00
|
|
|
|
wl_list_init(&seat->pointer_focus_listener.link);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-26 00:42:45 +04:00
|
|
|
|
static struct shell_seat *
|
2021-08-26 16:37:24 +03:00
|
|
|
|
create_shell_seat(struct desktop_shell *shell, struct weston_seat *seat)
|
2013-03-26 00:42:45 +04:00
|
|
|
|
{
|
|
|
|
|
struct shell_seat *shseat;
|
2017-12-19 11:33:33 +03:00
|
|
|
|
struct weston_tablet_tool *tool;
|
2013-03-26 00:42:45 +04:00
|
|
|
|
|
|
|
|
|
shseat = calloc(1, sizeof *shseat);
|
|
|
|
|
if (!shseat) {
|
|
|
|
|
weston_log("no memory to allocate shell seat\n");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
shseat->seat = seat;
|
|
|
|
|
|
|
|
|
|
shseat->seat_destroy_listener.notify = destroy_shell_seat;
|
|
|
|
|
wl_signal_add(&seat->destroy_signal,
|
|
|
|
|
&shseat->seat_destroy_listener);
|
|
|
|
|
|
2014-04-22 04:42:58 +04:00
|
|
|
|
wl_list_init(&shseat->keyboard_focus_listener.link);
|
|
|
|
|
|
|
|
|
|
shseat->pointer_focus_listener.notify = handle_pointer_focus;
|
|
|
|
|
wl_list_init(&shseat->pointer_focus_listener.link);
|
|
|
|
|
|
2017-12-19 11:33:33 +03:00
|
|
|
|
shseat->tablet_tool_added_listener.notify = handle_tablet_tool_added;
|
|
|
|
|
wl_list_init(&shseat->tablet_tool_added_listener.link);
|
|
|
|
|
|
|
|
|
|
wl_list_for_each(tool, &seat->tablet_tool_list, link) {
|
|
|
|
|
struct tablet_tool_listener *listener = malloc(sizeof *listener);
|
|
|
|
|
|
|
|
|
|
if (!listener) {
|
|
|
|
|
weston_log("no memory to allocate to shell seat tablet listener\n");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
listener->removed_listener.notify = destroy_tablet_tool_listener;
|
|
|
|
|
wl_signal_add(&tool->removed_signal,
|
|
|
|
|
&listener->removed_listener);
|
|
|
|
|
|
|
|
|
|
listener->base.notify = handle_tablet_tool_focus;
|
|
|
|
|
wl_signal_add(&tool->focus_signal, &listener->base);
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-22 04:42:58 +04:00
|
|
|
|
shseat->caps_changed_listener.notify = shell_seat_caps_changed;
|
|
|
|
|
wl_signal_add(&seat->updated_caps_signal,
|
|
|
|
|
&shseat->caps_changed_listener);
|
|
|
|
|
shell_seat_caps_changed(&shseat->caps_changed_listener, NULL);
|
|
|
|
|
|
2021-08-26 16:37:24 +03:00
|
|
|
|
wl_list_insert(&shell->seat_list, &shseat->link);
|
|
|
|
|
|
2013-03-26 00:42:45 +04:00
|
|
|
|
return shseat;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static struct shell_seat *
|
|
|
|
|
get_shell_seat(struct weston_seat *seat)
|
|
|
|
|
{
|
|
|
|
|
struct wl_listener *listener;
|
|
|
|
|
|
2021-11-20 20:14:45 +03:00
|
|
|
|
if (!seat)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2013-03-26 00:42:45 +04:00
|
|
|
|
listener = wl_signal_get(&seat->destroy_signal, destroy_shell_seat);
|
2021-11-20 20:14:45 +03:00
|
|
|
|
if (!listener)
|
|
|
|
|
return NULL;
|
2013-03-26 00:42:45 +04:00
|
|
|
|
|
|
|
|
|
return container_of(listener,
|
|
|
|
|
struct shell_seat, seat_destroy_listener);
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-05 07:19:14 +04:00
|
|
|
|
static void
|
2016-08-12 11:41:36 +03:00
|
|
|
|
fade_out_done_idle_cb(void *data)
|
2012-01-05 07:19:14 +04:00
|
|
|
|
{
|
2016-08-12 11:41:36 +03:00
|
|
|
|
struct shell_surface *shsurf = data;
|
2021-11-10 18:50:50 +03:00
|
|
|
|
desktop_shell_destroy_surface(shsurf);
|
2012-01-05 07:19:14 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2016-08-12 11:41:36 +03:00
|
|
|
|
fade_out_done(struct weston_view_animation *animation, void *data)
|
2012-01-05 07:19:14 +04:00
|
|
|
|
{
|
2016-08-12 11:41:36 +03:00
|
|
|
|
struct shell_surface *shsurf = data;
|
|
|
|
|
struct wl_event_loop *loop;
|
2012-01-05 07:19:14 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
loop = wl_display_get_event_loop(shsurf->shell->compositor->wl_display);
|
2014-08-12 00:44:02 +04:00
|
|
|
|
|
2022-02-14 23:57:08 +03:00
|
|
|
|
if (weston_view_is_mapped(shsurf->wview_anim_fade)) {
|
|
|
|
|
weston_view_unmap(shsurf->wview_anim_fade);
|
2016-08-12 11:41:36 +03:00
|
|
|
|
wl_event_loop_add_idle(loop, fade_out_done_idle_cb, shsurf);
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-11-15 02:42:52 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
struct shell_surface *
|
|
|
|
|
get_shell_surface(struct weston_surface *surface)
|
2014-08-20 13:27:10 +04:00
|
|
|
|
{
|
2016-08-12 11:41:36 +03:00
|
|
|
|
if (weston_surface_is_desktop_surface(surface)) {
|
|
|
|
|
struct weston_desktop_surface *desktop_surface =
|
|
|
|
|
weston_surface_get_desktop_surface(surface);
|
|
|
|
|
return weston_desktop_surface_get_user_data(desktop_surface);
|
2014-08-20 13:27:10 +04:00
|
|
|
|
}
|
2016-08-12 11:41:36 +03:00
|
|
|
|
return NULL;
|
2014-08-20 13:27:10 +04:00
|
|
|
|
}
|
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
/*
|
|
|
|
|
* libweston-desktop
|
|
|
|
|
*/
|
2013-03-26 00:42:45 +04:00
|
|
|
|
|
|
|
|
|
static void
|
2016-08-12 11:41:36 +03:00
|
|
|
|
desktop_surface_added(struct weston_desktop_surface *desktop_surface,
|
|
|
|
|
void *shell)
|
2015-02-27 13:35:45 +03:00
|
|
|
|
{
|
2016-08-12 11:41:36 +03:00
|
|
|
|
struct weston_desktop_client *client =
|
|
|
|
|
weston_desktop_surface_get_client(desktop_surface);
|
|
|
|
|
struct wl_client *wl_client =
|
|
|
|
|
weston_desktop_client_get_client(client);
|
|
|
|
|
struct weston_view *view;
|
2015-02-27 13:35:45 +03:00
|
|
|
|
struct shell_surface *shsurf;
|
2016-08-12 11:41:36 +03:00
|
|
|
|
struct weston_surface *surface =
|
|
|
|
|
weston_desktop_surface_get_surface(desktop_surface);
|
2015-02-27 13:35:45 +03:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
view = weston_desktop_surface_create_view(desktop_surface);
|
|
|
|
|
if (!view)
|
2014-04-29 18:54:02 +04:00
|
|
|
|
return;
|
|
|
|
|
|
2011-11-25 14:09:16 +04:00
|
|
|
|
shsurf = calloc(1, sizeof *shsurf);
|
|
|
|
|
if (!shsurf) {
|
2016-08-12 11:41:36 +03:00
|
|
|
|
if (wl_client)
|
|
|
|
|
wl_client_post_no_memory(wl_client);
|
|
|
|
|
else
|
|
|
|
|
weston_log("no memory to allocate shell surface\n");
|
|
|
|
|
return;
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-22 14:28:57 +03:00
|
|
|
|
weston_surface_set_label_func(surface, weston_shell_utils_surface_get_label);
|
2012-03-27 18:36:41 +04:00
|
|
|
|
|
2012-04-19 17:18:18 +04:00
|
|
|
|
shsurf->shell = (struct desktop_shell *) shell;
|
2012-04-18 05:06:18 +04:00
|
|
|
|
shsurf->unresponsive = 0;
|
2012-03-01 08:57:46 +04:00
|
|
|
|
shsurf->saved_position_valid = false;
|
2012-04-27 05:07:24 +04:00
|
|
|
|
shsurf->saved_rotation_valid = false;
|
2016-08-12 11:41:36 +03:00
|
|
|
|
shsurf->desktop_surface = desktop_surface;
|
|
|
|
|
shsurf->view = view;
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
shsurf->fullscreen.black_view = NULL;
|
2012-03-01 08:57:46 +04:00
|
|
|
|
wl_list_init(&shsurf->fullscreen.transform.link);
|
|
|
|
|
|
2018-05-02 12:10:32 +03:00
|
|
|
|
shell_surface_set_output(
|
2022-11-22 14:28:57 +03:00
|
|
|
|
shsurf, weston_shell_utils_get_default_output(shsurf->shell->compositor));
|
2014-04-12 03:18:54 +04:00
|
|
|
|
|
2013-06-14 19:07:54 +04:00
|
|
|
|
wl_signal_init(&shsurf->destroy_signal);
|
2011-11-25 14:09:16 +04:00
|
|
|
|
|
2012-01-20 18:48:25 +04:00
|
|
|
|
/* empty when not in use */
|
|
|
|
|
wl_list_init(&shsurf->rotation.transform.link);
|
2012-01-27 22:36:13 +04:00
|
|
|
|
weston_matrix_init(&shsurf->rotation.rotation);
|
2012-01-20 18:48:25 +04:00
|
|
|
|
|
2019-06-23 15:53:59 +03:00
|
|
|
|
/*
|
|
|
|
|
* initialize list as well as link. The latter allows to use
|
|
|
|
|
* wl_list_remove() even when this surface is not in another list.
|
|
|
|
|
*/
|
|
|
|
|
wl_list_init(&shsurf->children_list);
|
|
|
|
|
wl_list_init(&shsurf->children_link);
|
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
weston_desktop_surface_set_user_data(desktop_surface, shsurf);
|
2013-12-03 21:35:45 +04:00
|
|
|
|
}
|
|
|
|
|
|
2012-04-19 17:18:18 +04:00
|
|
|
|
static void
|
2016-08-12 11:41:36 +03:00
|
|
|
|
desktop_surface_removed(struct weston_desktop_surface *desktop_surface,
|
|
|
|
|
void *shell)
|
2012-04-19 17:18:18 +04:00
|
|
|
|
{
|
2016-08-12 11:41:36 +03:00
|
|
|
|
struct shell_surface *shsurf =
|
|
|
|
|
weston_desktop_surface_get_user_data(desktop_surface);
|
2013-06-14 19:07:53 +04:00
|
|
|
|
struct weston_surface *surface =
|
2016-08-12 11:41:36 +03:00
|
|
|
|
weston_desktop_surface_get_surface(desktop_surface);
|
2021-03-05 22:44:26 +03:00
|
|
|
|
struct weston_seat *seat;
|
2012-04-19 17:18:18 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
if (!shsurf)
|
2012-04-19 17:18:18 +04:00
|
|
|
|
return;
|
|
|
|
|
|
2021-03-05 22:44:26 +03:00
|
|
|
|
wl_list_for_each(seat, &shsurf->shell->compositor->seat_list, link) {
|
|
|
|
|
struct shell_seat *shseat = get_shell_seat(seat);
|
|
|
|
|
/* activate() controls the focused surface activation and
|
|
|
|
|
* removal of a surface requires invalidating the
|
|
|
|
|
* focused_surface to avoid activate() use a stale (and just
|
|
|
|
|
* removed) surface when attempting to de-activate it. It will
|
|
|
|
|
* also update the focused_surface once it has a chance to run.
|
|
|
|
|
*/
|
2021-11-20 20:14:45 +03:00
|
|
|
|
if (shseat && surface == shseat->focused_surface)
|
2021-03-05 22:44:26 +03:00
|
|
|
|
shseat->focused_surface = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-17 17:49:35 +03:00
|
|
|
|
if (shsurf->fullscreen.black_view) {
|
2022-11-22 14:28:57 +03:00
|
|
|
|
weston_shell_utils_curtain_destroy(shsurf->fullscreen.black_view);
|
2022-05-17 17:49:35 +03:00
|
|
|
|
shsurf->fullscreen.black_view = NULL;
|
|
|
|
|
}
|
2011-11-25 14:09:16 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
weston_surface_set_label_func(surface, NULL);
|
|
|
|
|
weston_desktop_surface_set_user_data(shsurf->desktop_surface, NULL);
|
|
|
|
|
shsurf->desktop_surface = NULL;
|
2014-02-04 03:50:38 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
if (weston_surface_is_mapped(surface) &&
|
|
|
|
|
shsurf->shell->win_close_animation_type == ANIMATION_FADE) {
|
desktop-shell: don't run fade animation if compositor is inactive
When a window is closed, Weston will, by default, run a fade out animation and
defer destroying the underlying surface until it completes. However, if the
compositor is sleeping, and therefore not rendering any frames, this animation
will *never* complete. Therefore, if windows are repeatedly created and
destroyed while in sleep mode, these surfaces will keep accumulating, and since
the buffers attached to them may be backed by an fd, eventually the ulimit will
be reached resulting in a potential crash or other errors.
This can be demonstrated repeatedly launching and killing an X11 application
with Xwayland running.
while true; do xterm & pid=$!; sleep 0.5; kill $pid; done
As soon as the compositor goes to sleep, one can observe a steadily growing
list of dmabufs in the output of lsof.
As a fix, desktop_surface_removed should check whether the compositor is active
before kicking off the fade animation. If it is not, it should instead drop the
extra reference taken in desktop_surface_committed and then destroy the surface
immediately.
Signed-off-by: Erik Kurzinger <ekurzinger@nvidia.com>
2021-05-18 18:49:37 +03:00
|
|
|
|
|
2023-02-17 06:08:13 +03:00
|
|
|
|
if (shsurf->shell->compositor->state == WESTON_COMPOSITOR_ACTIVE &&
|
|
|
|
|
shsurf->view->output->power_state == WESTON_OUTPUT_POWER_NORMAL) {
|
2021-07-31 18:25:41 +03:00
|
|
|
|
pixman_region32_fini(&surface->pending.input);
|
|
|
|
|
pixman_region32_init(&surface->pending.input);
|
|
|
|
|
pixman_region32_fini(&surface->input);
|
|
|
|
|
pixman_region32_init(&surface->input);
|
2022-02-14 23:57:08 +03:00
|
|
|
|
|
|
|
|
|
/* its location might have changed, but also might've
|
|
|
|
|
* migrated to a different output, so re-compute this
|
|
|
|
|
* as the animation requires having the same output as
|
|
|
|
|
* the view */
|
|
|
|
|
weston_view_set_output(shsurf->wview_anim_fade,
|
|
|
|
|
shsurf->view->output);
|
|
|
|
|
weston_view_set_position(shsurf->wview_anim_fade,
|
2022-02-04 02:47:41 +03:00
|
|
|
|
shsurf->view->geometry.pos_offset.x,
|
|
|
|
|
shsurf->view->geometry.pos_offset.y);
|
2022-02-14 23:57:08 +03:00
|
|
|
|
|
|
|
|
|
weston_layer_entry_insert(&shsurf->view->layer_link,
|
|
|
|
|
&shsurf->wview_anim_fade->layer_link);
|
|
|
|
|
|
|
|
|
|
/* unmap the "original" view */
|
|
|
|
|
weston_view_unmap(shsurf->view);
|
|
|
|
|
weston_fade_run(shsurf->wview_anim_fade, 1.0, 0.0, 300.0,
|
2021-07-31 18:25:41 +03:00
|
|
|
|
fade_out_done, shsurf);
|
2022-02-14 23:57:08 +03:00
|
|
|
|
|
2021-07-31 18:25:41 +03:00
|
|
|
|
return;
|
|
|
|
|
}
|
desktop-shell: don't run fade animation if compositor is inactive
When a window is closed, Weston will, by default, run a fade out animation and
defer destroying the underlying surface until it completes. However, if the
compositor is sleeping, and therefore not rendering any frames, this animation
will *never* complete. Therefore, if windows are repeatedly created and
destroyed while in sleep mode, these surfaces will keep accumulating, and since
the buffers attached to them may be backed by an fd, eventually the ulimit will
be reached resulting in a potential crash or other errors.
This can be demonstrated repeatedly launching and killing an X11 application
with Xwayland running.
while true; do xterm & pid=$!; sleep 0.5; kill $pid; done
As soon as the compositor goes to sleep, one can observe a steadily growing
list of dmabufs in the output of lsof.
As a fix, desktop_surface_removed should check whether the compositor is active
before kicking off the fade animation. If it is not, it should instead drop the
extra reference taken in desktop_surface_committed and then destroy the surface
immediately.
Signed-off-by: Erik Kurzinger <ekurzinger@nvidia.com>
2021-05-18 18:49:37 +03:00
|
|
|
|
}
|
2018-05-22 12:48:35 +03:00
|
|
|
|
|
2021-11-10 18:50:50 +03:00
|
|
|
|
desktop_shell_destroy_surface(shsurf);
|
2013-12-03 21:35:45 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2016-08-12 11:41:36 +03:00
|
|
|
|
set_maximized_position(struct desktop_shell *shell,
|
|
|
|
|
struct shell_surface *shsurf)
|
2013-12-03 21:35:45 +04:00
|
|
|
|
{
|
2016-08-12 11:41:36 +03:00
|
|
|
|
pixman_rectangle32_t area;
|
|
|
|
|
struct weston_geometry geometry;
|
2013-12-03 21:35:45 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
get_output_work_area(shell, shsurf->output, &area);
|
|
|
|
|
geometry = weston_desktop_surface_get_geometry(shsurf->desktop_surface);
|
2014-02-02 03:35:15 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
weston_view_set_position(shsurf->view,
|
|
|
|
|
area.x - geometry.x,
|
|
|
|
|
area.y - geometry.y);
|
2014-02-02 03:35:15 +04:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-16 16:17:14 +03:00
|
|
|
|
static void
|
|
|
|
|
set_position_from_xwayland(struct shell_surface *shsurf)
|
|
|
|
|
{
|
|
|
|
|
struct weston_geometry geometry;
|
|
|
|
|
float x;
|
|
|
|
|
float y;
|
|
|
|
|
|
|
|
|
|
assert(shsurf->xwayland.is_set);
|
|
|
|
|
|
|
|
|
|
geometry = weston_desktop_surface_get_geometry(shsurf->desktop_surface);
|
|
|
|
|
x = shsurf->xwayland.x - geometry.x;
|
|
|
|
|
y = shsurf->xwayland.y - geometry.y;
|
|
|
|
|
|
|
|
|
|
weston_view_set_position(shsurf->view, x, y);
|
|
|
|
|
|
|
|
|
|
#ifdef WM_DEBUG
|
|
|
|
|
weston_log("%s: XWM %d, %d; geometry %d, %d; view %f, %f\n",
|
|
|
|
|
__func__, shsurf->xwayland.x, shsurf->xwayland.y,
|
|
|
|
|
geometry.x, geometry.y, x, y);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-03 21:35:45 +04:00
|
|
|
|
static void
|
2022-02-08 20:37:47 +03:00
|
|
|
|
map(struct desktop_shell *shell, struct shell_surface *shsurf)
|
2013-12-03 21:35:45 +04:00
|
|
|
|
{
|
2016-08-12 11:41:36 +03:00
|
|
|
|
struct weston_surface *surface =
|
|
|
|
|
weston_desktop_surface_get_surface(shsurf->desktop_surface);
|
|
|
|
|
struct weston_compositor *compositor = shell->compositor;
|
|
|
|
|
struct weston_seat *seat;
|
2013-12-03 21:35:45 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
/* initial positioning, see also configure() */
|
2016-08-16 15:26:03 +03:00
|
|
|
|
if (shsurf->state.fullscreen) {
|
2022-11-22 14:28:57 +03:00
|
|
|
|
weston_shell_utils_center_on_output(shsurf->view,
|
|
|
|
|
shsurf->fullscreen_output);
|
2016-08-12 11:41:36 +03:00
|
|
|
|
shell_map_fullscreen(shsurf);
|
2016-08-16 15:26:03 +03:00
|
|
|
|
} else if (shsurf->state.maximized) {
|
2016-08-12 11:41:36 +03:00
|
|
|
|
set_maximized_position(shell, shsurf);
|
2016-11-16 16:17:14 +03:00
|
|
|
|
} else if (shsurf->xwayland.is_set) {
|
|
|
|
|
set_position_from_xwayland(shsurf);
|
2016-08-12 11:41:36 +03:00
|
|
|
|
} else {
|
|
|
|
|
weston_view_set_initial_position(shsurf->view, shell);
|
|
|
|
|
}
|
2013-12-03 21:35:45 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
/* Surface stacking order, see also activate(). */
|
|
|
|
|
shell_surface_update_layer(shsurf);
|
2014-03-13 19:04:53 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
weston_view_update_transform(shsurf->view);
|
|
|
|
|
shsurf->view->is_mapped = true;
|
2016-08-16 15:26:03 +03:00
|
|
|
|
if (shsurf->state.maximized) {
|
2016-08-12 11:41:36 +03:00
|
|
|
|
surface->output = shsurf->output;
|
2018-04-26 12:08:10 +03:00
|
|
|
|
weston_view_set_output(shsurf->view, shsurf->output);
|
2016-08-12 11:41:36 +03:00
|
|
|
|
}
|
2013-12-03 21:35:45 +04:00
|
|
|
|
|
2022-06-01 19:47:29 +03:00
|
|
|
|
weston_surface_map(surface);
|
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
if (!shell->locked) {
|
|
|
|
|
wl_list_for_each(seat, &compositor->seat_list, link)
|
|
|
|
|
activate(shell, shsurf->view, seat,
|
|
|
|
|
WESTON_ACTIVATE_FLAG_CONFIGURE);
|
|
|
|
|
}
|
2013-12-03 21:35:45 +04:00
|
|
|
|
|
2016-08-16 15:26:03 +03:00
|
|
|
|
if (!shsurf->state.fullscreen && !shsurf->state.maximized) {
|
2016-08-12 11:41:36 +03:00
|
|
|
|
switch (shell->win_animation_type) {
|
|
|
|
|
case ANIMATION_FADE:
|
|
|
|
|
weston_fade_run(shsurf->view, 0.0, 1.0, 300.0, NULL, NULL);
|
|
|
|
|
break;
|
|
|
|
|
case ANIMATION_ZOOM:
|
|
|
|
|
weston_zoom_run(shsurf->view, 0.5, 1.0, NULL, NULL);
|
|
|
|
|
break;
|
|
|
|
|
case ANIMATION_NONE:
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-12-03 21:35:45 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2016-08-12 11:41:36 +03:00
|
|
|
|
desktop_surface_committed(struct weston_desktop_surface *desktop_surface,
|
|
|
|
|
int32_t sx, int32_t sy, void *data)
|
2013-12-03 21:35:45 +04:00
|
|
|
|
{
|
2016-08-12 11:41:36 +03:00
|
|
|
|
struct shell_surface *shsurf =
|
|
|
|
|
weston_desktop_surface_get_user_data(desktop_surface);
|
|
|
|
|
struct weston_surface *surface =
|
|
|
|
|
weston_desktop_surface_get_surface(desktop_surface);
|
|
|
|
|
struct weston_view *view = shsurf->view;
|
|
|
|
|
struct desktop_shell *shell = data;
|
2023-02-07 18:05:47 +03:00
|
|
|
|
bool was_fullscreen;
|
|
|
|
|
bool was_maximized;
|
2013-12-03 21:35:45 +04:00
|
|
|
|
|
2023-02-01 13:25:28 +03:00
|
|
|
|
if (!weston_surface_has_content(surface) &&
|
|
|
|
|
weston_surface_is_unmapping(surface) &&
|
|
|
|
|
shsurf->state.fullscreen) {
|
|
|
|
|
unset_fullscreen(shsurf);
|
2016-08-12 11:41:36 +03:00
|
|
|
|
return;
|
2023-02-01 13:25:28 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (surface->width == 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2013-12-03 21:35:45 +04:00
|
|
|
|
|
2016-08-16 15:26:03 +03:00
|
|
|
|
was_fullscreen = shsurf->state.fullscreen;
|
|
|
|
|
was_maximized = shsurf->state.maximized;
|
|
|
|
|
|
|
|
|
|
shsurf->state.fullscreen =
|
|
|
|
|
weston_desktop_surface_get_fullscreen(desktop_surface);
|
|
|
|
|
shsurf->state.maximized =
|
|
|
|
|
weston_desktop_surface_get_maximized(desktop_surface);
|
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
if (!weston_surface_is_mapped(surface)) {
|
2022-02-08 20:37:47 +03:00
|
|
|
|
map(shell, shsurf);
|
libweston, desktop-shell: Add a wrapper for weston_surface reference
Similar to how we do it with drm_fb ref counts, increase a reference
count and return the same object.
Plug-in in desktop-shell when we map up the view in order to survive a
weston_surface destruction.
Astute readers will notice that this patch removes weston_view_destroy()
while keeping the balance between removing and adding a
weston_surface_unref() call in desktop_shell_destroy_surface().
The reason is to let weston_surface_unref() handle destruction on its
own. If multiple references are taken, then weston_surface_unref()
doesn't destroy the view, it just decreases the reference, with
a latter call to weston_surface_unref() to determine if the view
should be destroyed as well. This situation happens if we have
close animation enabled, were we have more than one reference taken: one
when mapping the view/surface and when when the surface itself was created,
(what we call, a weak reference).
If only a single reference is taken (for instance if we don't have close
animations enabled) then this weston_surface_unref()
call is inert as that reference is not set-up, leaving libweston to
handle the view destruction.
Following that with a weston_view_destroy() explicit call would cause a
UAF as the view was previous destroyed by a weston_surface_unref() call.
A side-effect of not keeping the weston_view_destroy() call would
happen when tearing down the compositor. If close animations are enabled,
weston_surface_unref() would not destroy the view, and because
weston_view_destroy() no longer exists, we would still have the
view in the other layers by the time we check-up if layers
have views present.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-02-14 23:42:22 +03:00
|
|
|
|
/* as we need to survive the weston_surface destruction we'll
|
|
|
|
|
* need to take another reference */
|
2022-02-14 23:57:08 +03:00
|
|
|
|
if (shsurf->shell->win_close_animation_type == ANIMATION_FADE) {
|
libweston, desktop-shell: Add a wrapper for weston_surface reference
Similar to how we do it with drm_fb ref counts, increase a reference
count and return the same object.
Plug-in in desktop-shell when we map up the view in order to survive a
weston_surface destruction.
Astute readers will notice that this patch removes weston_view_destroy()
while keeping the balance between removing and adding a
weston_surface_unref() call in desktop_shell_destroy_surface().
The reason is to let weston_surface_unref() handle destruction on its
own. If multiple references are taken, then weston_surface_unref()
doesn't destroy the view, it just decreases the reference, with
a latter call to weston_surface_unref() to determine if the view
should be destroyed as well. This situation happens if we have
close animation enabled, were we have more than one reference taken: one
when mapping the view/surface and when when the surface itself was created,
(what we call, a weak reference).
If only a single reference is taken (for instance if we don't have close
animations enabled) then this weston_surface_unref()
call is inert as that reference is not set-up, leaving libweston to
handle the view destruction.
Following that with a weston_view_destroy() explicit call would cause a
UAF as the view was previous destroyed by a weston_surface_unref() call.
A side-effect of not keeping the weston_view_destroy() call would
happen when tearing down the compositor. If close animations are enabled,
weston_surface_unref() would not destroy the view, and because
weston_view_destroy() no longer exists, we would still have the
view in the other layers by the time we check-up if layers
have views present.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-02-14 23:42:22 +03:00
|
|
|
|
shsurf->wsurface_anim_fade =
|
|
|
|
|
weston_surface_ref(surface);
|
2022-02-14 23:57:08 +03:00
|
|
|
|
shsurf->wview_anim_fade =
|
|
|
|
|
shell_fade_create_fade_out_view(shsurf, surface);
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
return;
|
2014-04-10 21:41:46 +04:00
|
|
|
|
}
|
2013-12-03 21:35:45 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
if (sx == 0 && sy == 0 &&
|
|
|
|
|
shsurf->last_width == surface->width &&
|
2016-08-16 15:26:03 +03:00
|
|
|
|
shsurf->last_height == surface->height &&
|
|
|
|
|
was_fullscreen == shsurf->state.fullscreen &&
|
|
|
|
|
was_maximized == shsurf->state.maximized)
|
2016-08-12 11:41:36 +03:00
|
|
|
|
return;
|
shell: Replace set_margin with set_window_geometry
Currently, there is a fun flicker when toggling maximization or
fullscreen on a window in mutter or more sophisicated compositors
and WMs.
What happens is that the client want so go maximized, so we
calculate the size that we want the window to resize to (640x480),
and then add on its margins to find the buffer size (+10 = 660x500),
and then send out a configure event for that size. The client
renders to that size, realizes that it's maximized, and then
says "oh hey, my margins are actually 0 now!", and so the compositor
has to send out another configure event.
In order to fix this, make the the configure request correspond to
the window geometry we'd like the window to be at. At the same time,
replace set_margin with set_window_geometry, where we specify a rect
rather than a border around the window.
2014-05-02 18:21:38 +04:00
|
|
|
|
|
2023-02-07 18:05:47 +03:00
|
|
|
|
if (was_fullscreen)
|
2016-08-16 15:26:03 +03:00
|
|
|
|
unset_fullscreen(shsurf);
|
2023-02-07 18:05:47 +03:00
|
|
|
|
if (was_maximized)
|
2016-08-16 15:26:03 +03:00
|
|
|
|
unset_maximized(shsurf);
|
|
|
|
|
|
2023-02-07 18:05:47 +03:00
|
|
|
|
if ((shsurf->state.fullscreen || shsurf->state.maximized) &&
|
2016-08-16 15:26:20 +03:00
|
|
|
|
!shsurf->saved_position_valid) {
|
2022-02-04 19:50:07 +03:00
|
|
|
|
shsurf->saved_pos.c = shsurf->view->geometry.pos_offset;
|
2016-08-16 15:26:20 +03:00
|
|
|
|
shsurf->saved_position_valid = true;
|
|
|
|
|
|
|
|
|
|
if (!wl_list_empty(&shsurf->rotation.transform.link)) {
|
|
|
|
|
wl_list_remove(&shsurf->rotation.transform.link);
|
|
|
|
|
wl_list_init(&shsurf->rotation.transform.link);
|
|
|
|
|
weston_view_geometry_dirty(shsurf->view);
|
|
|
|
|
shsurf->saved_rotation_valid = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-09 01:09:05 +03:00
|
|
|
|
weston_view_update_transform(shsurf->view);
|
|
|
|
|
|
2023-02-07 18:05:47 +03:00
|
|
|
|
if (shsurf->state.fullscreen) {
|
2023-05-03 01:55:45 +03:00
|
|
|
|
struct weston_seat *seat;
|
|
|
|
|
|
|
|
|
|
wl_list_for_each(seat, &surface->compositor->seat_list,link) {
|
|
|
|
|
activate(shell, shsurf->view, seat,
|
|
|
|
|
WESTON_ACTIVATE_FLAG_CONFIGURE);
|
|
|
|
|
}
|
2023-02-07 18:05:47 +03:00
|
|
|
|
} else if (shsurf->state.maximized) {
|
2016-08-12 11:41:36 +03:00
|
|
|
|
set_maximized_position(shell, shsurf);
|
|
|
|
|
surface->output = shsurf->output;
|
|
|
|
|
} else {
|
2022-02-09 02:31:55 +03:00
|
|
|
|
struct weston_coord_surface from_s, to_s;
|
|
|
|
|
struct weston_coord_global to_g, from_g;
|
2022-02-04 02:47:41 +03:00
|
|
|
|
struct weston_coord_global offset, pos;
|
shell: Replace set_margin with set_window_geometry
Currently, there is a fun flicker when toggling maximization or
fullscreen on a window in mutter or more sophisicated compositors
and WMs.
What happens is that the client want so go maximized, so we
calculate the size that we want the window to resize to (640x480),
and then add on its margins to find the buffer size (+10 = 660x500),
and then send out a configure event for that size. The client
renders to that size, realizes that it's maximized, and then
says "oh hey, my margins are actually 0 now!", and so the compositor
has to send out another configure event.
In order to fix this, make the the configure request correspond to
the window geometry we'd like the window to be at. At the same time,
replace set_margin with set_window_geometry, where we specify a rect
rather than a border around the window.
2014-05-02 18:21:38 +04:00
|
|
|
|
|
2022-02-09 02:31:55 +03:00
|
|
|
|
from_s = weston_coord_surface(0, 0, view->surface);
|
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
if (shsurf->resize_edges) {
|
|
|
|
|
sx = 0;
|
|
|
|
|
sy = 0;
|
|
|
|
|
}
|
2014-04-10 21:41:46 +04:00
|
|
|
|
|
2022-02-23 18:06:23 +03:00
|
|
|
|
if (shsurf->resize_edges & WESTON_DESKTOP_SURFACE_EDGE_LEFT)
|
2016-08-12 11:41:36 +03:00
|
|
|
|
sx = shsurf->last_width - surface->width;
|
2022-02-23 18:06:23 +03:00
|
|
|
|
if (shsurf->resize_edges & WESTON_DESKTOP_SURFACE_EDGE_TOP)
|
2016-08-12 11:41:36 +03:00
|
|
|
|
sy = shsurf->last_height - surface->height;
|
2014-09-08 14:34:20 +04:00
|
|
|
|
|
2022-02-09 02:31:55 +03:00
|
|
|
|
to_s = weston_coord_surface(sx, sy, view->surface);
|
|
|
|
|
|
|
|
|
|
from_g = weston_coord_surface_to_global(view, from_s);
|
|
|
|
|
to_g = weston_coord_surface_to_global(view, to_s);
|
2013-12-03 21:35:45 +04:00
|
|
|
|
|
2022-02-04 02:47:41 +03:00
|
|
|
|
offset.c = weston_coord_sub(to_g.c, from_g.c);
|
|
|
|
|
pos.c = weston_coord_add(view->geometry.pos_offset, offset.c);
|
|
|
|
|
|
|
|
|
|
weston_view_set_position(shsurf->view, pos.c.x, pos.c.y);
|
2016-08-12 11:41:36 +03:00
|
|
|
|
}
|
2013-12-03 21:35:46 +04:00
|
|
|
|
|
2017-04-04 20:49:33 +03:00
|
|
|
|
shsurf->last_width = surface->width;
|
|
|
|
|
shsurf->last_height = surface->height;
|
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
/* XXX: would a fullscreen surface need the same handling? */
|
|
|
|
|
if (surface->output) {
|
|
|
|
|
wl_list_for_each(view, &surface->views, surface_link)
|
|
|
|
|
weston_view_update_transform(view);
|
|
|
|
|
}
|
2013-12-03 21:35:45 +04:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-06 22:37:44 +03:00
|
|
|
|
static void
|
|
|
|
|
get_maximized_size(struct shell_surface *shsurf, int32_t *width, int32_t *height)
|
|
|
|
|
{
|
|
|
|
|
struct desktop_shell *shell;
|
|
|
|
|
pixman_rectangle32_t area;
|
|
|
|
|
|
|
|
|
|
shell = shell_surface_get_shell(shsurf);
|
|
|
|
|
get_output_work_area(shell, shsurf->output, &area);
|
|
|
|
|
|
|
|
|
|
*width = area.width;
|
|
|
|
|
*height = area.height;
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-03 21:35:45 +04:00
|
|
|
|
static void
|
2016-08-12 11:41:36 +03:00
|
|
|
|
set_fullscreen(struct shell_surface *shsurf, bool fullscreen,
|
|
|
|
|
struct weston_output *output)
|
2013-12-03 21:35:45 +04:00
|
|
|
|
{
|
2016-08-12 11:41:36 +03:00
|
|
|
|
struct weston_desktop_surface *desktop_surface = shsurf->desktop_surface;
|
|
|
|
|
struct weston_surface *surface =
|
|
|
|
|
weston_desktop_surface_get_surface(shsurf->desktop_surface);
|
|
|
|
|
int32_t width = 0, height = 0;
|
|
|
|
|
|
|
|
|
|
if (fullscreen) {
|
|
|
|
|
/* handle clients launching in fullscreen */
|
|
|
|
|
if (output == NULL && !weston_surface_is_mapped(surface)) {
|
|
|
|
|
/* Set the output to the one that has focus currently. */
|
2022-11-22 14:28:57 +03:00
|
|
|
|
output = weston_shell_utils_get_focused_output(surface->compositor);
|
2016-08-12 11:41:36 +03:00
|
|
|
|
}
|
2014-02-09 03:29:49 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
shell_surface_set_output(shsurf, output);
|
|
|
|
|
shsurf->fullscreen_output = shsurf->output;
|
2013-12-03 21:35:45 +04:00
|
|
|
|
|
2020-03-28 01:23:14 +03:00
|
|
|
|
if (shsurf->output) {
|
|
|
|
|
width = shsurf->output->width;
|
|
|
|
|
height = shsurf->output->height;
|
|
|
|
|
}
|
2022-07-29 17:04:32 +03:00
|
|
|
|
weston_desktop_surface_set_orientation(shsurf->desktop_surface,
|
|
|
|
|
WESTON_TOP_LEVEL_TILED_ORIENTATION_NONE);
|
2022-08-29 18:31:52 +03:00
|
|
|
|
} else if (weston_desktop_surface_get_maximized(desktop_surface) ||
|
|
|
|
|
weston_desktop_surface_get_pending_maximized(desktop_surface)) {
|
2017-10-06 22:37:45 +03:00
|
|
|
|
get_maximized_size(shsurf, &width, &height);
|
2014-09-02 13:35:12 +04:00
|
|
|
|
}
|
2016-08-12 11:41:36 +03:00
|
|
|
|
weston_desktop_surface_set_fullscreen(desktop_surface, fullscreen);
|
|
|
|
|
weston_desktop_surface_set_size(desktop_surface, width, height);
|
2013-12-03 21:35:45 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2016-08-12 11:41:36 +03:00
|
|
|
|
desktop_surface_move(struct weston_desktop_surface *desktop_surface,
|
|
|
|
|
struct weston_seat *seat, uint32_t serial, void *shell)
|
2013-12-03 21:35:45 +04:00
|
|
|
|
{
|
2016-08-12 11:41:36 +03:00
|
|
|
|
struct weston_pointer *pointer = weston_seat_get_pointer(seat);
|
|
|
|
|
struct weston_touch *touch = weston_seat_get_touch(seat);
|
|
|
|
|
struct shell_surface *shsurf =
|
|
|
|
|
weston_desktop_surface_get_user_data(desktop_surface);
|
|
|
|
|
struct weston_surface *surface =
|
|
|
|
|
weston_desktop_surface_get_surface(shsurf->desktop_surface);
|
|
|
|
|
struct wl_resource *resource = surface->resource;
|
|
|
|
|
struct weston_surface *focus;
|
2013-12-03 21:35:46 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
if (pointer &&
|
|
|
|
|
pointer->focus &&
|
|
|
|
|
pointer->button_count > 0 &&
|
|
|
|
|
pointer->grab_serial == serial) {
|
|
|
|
|
focus = weston_surface_get_main_surface(pointer->focus->surface);
|
|
|
|
|
if ((focus == surface) &&
|
|
|
|
|
(surface_move(shsurf, pointer, true) < 0))
|
|
|
|
|
wl_resource_post_no_memory(resource);
|
|
|
|
|
} else if (touch &&
|
|
|
|
|
touch->focus &&
|
|
|
|
|
touch->grab_serial == serial) {
|
|
|
|
|
focus = weston_surface_get_main_surface(touch->focus->surface);
|
|
|
|
|
if ((focus == surface) &&
|
|
|
|
|
(surface_touch_move(shsurf, touch) < 0))
|
|
|
|
|
wl_resource_post_no_memory(resource);
|
2017-12-19 11:33:33 +03:00
|
|
|
|
} else if (!wl_list_empty(&seat->tablet_tool_list)) {
|
|
|
|
|
struct weston_tablet_tool *tool;
|
|
|
|
|
|
|
|
|
|
wl_list_for_each(tool, &seat->tablet_tool_list, link) {
|
|
|
|
|
if (tool->focus && tool->grab_serial == serial) {
|
|
|
|
|
focus = weston_surface_get_main_surface(
|
|
|
|
|
tool->focus->surface);
|
|
|
|
|
if (focus == surface &&
|
|
|
|
|
surface_tablet_tool_move(shsurf, tool) < 0)
|
|
|
|
|
wl_resource_post_no_memory(resource);
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-08-12 11:41:36 +03:00
|
|
|
|
}
|
2013-12-03 21:35:45 +04:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-26 18:52:13 +04:00
|
|
|
|
static void
|
2016-08-12 11:41:36 +03:00
|
|
|
|
desktop_surface_resize(struct weston_desktop_surface *desktop_surface,
|
|
|
|
|
struct weston_seat *seat, uint32_t serial,
|
|
|
|
|
enum weston_desktop_surface_edge edges, void *shell)
|
2014-02-26 18:52:13 +04:00
|
|
|
|
{
|
2016-08-12 11:41:36 +03:00
|
|
|
|
struct weston_pointer *pointer = weston_seat_get_pointer(seat);
|
|
|
|
|
struct shell_surface *shsurf =
|
|
|
|
|
weston_desktop_surface_get_user_data(desktop_surface);
|
|
|
|
|
struct weston_surface *surface =
|
|
|
|
|
weston_desktop_surface_get_surface(shsurf->desktop_surface);
|
|
|
|
|
struct wl_resource *resource = surface->resource;
|
|
|
|
|
struct weston_surface *focus;
|
2014-02-26 18:52:13 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
if (!pointer ||
|
|
|
|
|
pointer->button_count == 0 ||
|
|
|
|
|
pointer->grab_serial != serial ||
|
|
|
|
|
pointer->focus == NULL)
|
2014-02-26 18:52:13 +04:00
|
|
|
|
return;
|
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
focus = weston_surface_get_main_surface(pointer->focus->surface);
|
|
|
|
|
if (focus != surface)
|
2014-04-10 21:41:46 +04:00
|
|
|
|
return;
|
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
if (surface_resize(shsurf, pointer, edges) < 0)
|
|
|
|
|
wl_resource_post_no_memory(resource);
|
2015-02-13 09:02:00 +03:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-23 15:53:59 +03:00
|
|
|
|
static void
|
|
|
|
|
desktop_surface_set_parent(struct weston_desktop_surface *desktop_surface,
|
|
|
|
|
struct weston_desktop_surface *parent,
|
|
|
|
|
void *shell)
|
|
|
|
|
{
|
2020-01-17 13:32:55 +03:00
|
|
|
|
struct shell_surface *shsurf_parent;
|
2019-06-23 15:53:59 +03:00
|
|
|
|
struct shell_surface *shsurf =
|
|
|
|
|
weston_desktop_surface_get_user_data(desktop_surface);
|
|
|
|
|
|
2020-01-17 13:32:55 +03:00
|
|
|
|
/* unlink any potential child */
|
|
|
|
|
wl_list_remove(&shsurf->children_link);
|
|
|
|
|
|
|
|
|
|
if (parent) {
|
|
|
|
|
shsurf_parent = weston_desktop_surface_get_user_data(parent);
|
|
|
|
|
wl_list_insert(shsurf_parent->children_list.prev,
|
|
|
|
|
&shsurf->children_link);
|
|
|
|
|
} else {
|
|
|
|
|
wl_list_init(&shsurf->children_link);
|
|
|
|
|
}
|
2019-06-23 15:53:59 +03:00
|
|
|
|
}
|
|
|
|
|
|
2013-12-03 21:35:45 +04:00
|
|
|
|
static void
|
2016-08-12 11:41:36 +03:00
|
|
|
|
desktop_surface_fullscreen_requested(struct weston_desktop_surface *desktop_surface,
|
|
|
|
|
bool fullscreen,
|
|
|
|
|
struct weston_output *output, void *shell)
|
2013-12-03 21:35:45 +04:00
|
|
|
|
{
|
2016-08-12 11:41:36 +03:00
|
|
|
|
struct shell_surface *shsurf =
|
|
|
|
|
weston_desktop_surface_get_user_data(desktop_surface);
|
2013-12-03 21:35:45 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
set_fullscreen(shsurf, fullscreen, output);
|
2013-12-03 21:35:45 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2016-08-12 11:41:36 +03:00
|
|
|
|
set_maximized(struct shell_surface *shsurf, bool maximized)
|
2013-12-03 21:35:45 +04:00
|
|
|
|
{
|
2016-08-12 11:41:36 +03:00
|
|
|
|
struct weston_desktop_surface *desktop_surface = shsurf->desktop_surface;
|
2013-12-03 21:35:45 +04:00
|
|
|
|
struct weston_surface *surface =
|
2016-08-12 11:41:36 +03:00
|
|
|
|
weston_desktop_surface_get_surface(shsurf->desktop_surface);
|
|
|
|
|
int32_t width = 0, height = 0;
|
2013-12-03 21:35:45 +04:00
|
|
|
|
|
2020-12-11 23:23:58 +03:00
|
|
|
|
if (weston_desktop_surface_get_fullscreen(desktop_surface))
|
|
|
|
|
return;
|
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
if (maximized) {
|
|
|
|
|
struct weston_output *output;
|
2015-02-06 05:15:28 +03:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
if (!weston_surface_is_mapped(surface))
|
2022-11-22 14:28:57 +03:00
|
|
|
|
output = weston_shell_utils_get_focused_output(surface->compositor);
|
2016-08-12 11:41:36 +03:00
|
|
|
|
else
|
|
|
|
|
output = surface->output;
|
2013-12-03 21:35:45 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
shell_surface_set_output(shsurf, output);
|
2013-12-03 21:35:45 +04:00
|
|
|
|
|
2017-10-06 22:37:44 +03:00
|
|
|
|
get_maximized_size(shsurf, &width, &height);
|
2022-07-29 17:04:32 +03:00
|
|
|
|
|
|
|
|
|
weston_desktop_surface_set_orientation(shsurf->desktop_surface,
|
|
|
|
|
WESTON_TOP_LEVEL_TILED_ORIENTATION_NONE);
|
2016-08-12 11:41:36 +03:00
|
|
|
|
}
|
|
|
|
|
weston_desktop_surface_set_maximized(desktop_surface, maximized);
|
|
|
|
|
weston_desktop_surface_set_size(desktop_surface, width, height);
|
2013-12-03 21:35:45 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2016-08-12 11:41:36 +03:00
|
|
|
|
desktop_surface_maximized_requested(struct weston_desktop_surface *desktop_surface,
|
|
|
|
|
bool maximized, void *shell)
|
2013-12-03 21:35:45 +04:00
|
|
|
|
{
|
2016-08-12 11:41:36 +03:00
|
|
|
|
struct shell_surface *shsurf =
|
|
|
|
|
weston_desktop_surface_get_user_data(desktop_surface);
|
2013-12-03 21:35:45 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
set_maximized(shsurf, maximized);
|
2013-12-03 21:35:45 +04:00
|
|
|
|
}
|
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
static void
|
|
|
|
|
desktop_surface_minimized_requested(struct weston_desktop_surface *desktop_surface,
|
|
|
|
|
void *shell)
|
2013-12-03 21:35:45 +04:00
|
|
|
|
{
|
2016-08-12 11:41:36 +03:00
|
|
|
|
struct weston_surface *surface =
|
|
|
|
|
weston_desktop_surface_get_surface(desktop_surface);
|
2013-12-03 21:35:45 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
/* apply compositor's own minimization logic (hide) */
|
|
|
|
|
set_minimized(surface);
|
2013-12-03 21:35:45 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2016-08-12 11:41:36 +03:00
|
|
|
|
set_busy_cursor(struct shell_surface *shsurf, struct weston_pointer *pointer)
|
2013-12-03 21:35:45 +04:00
|
|
|
|
{
|
2016-08-12 11:41:36 +03:00
|
|
|
|
struct shell_grab *grab;
|
2013-12-03 21:35:45 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
if (pointer->grab->interface == &busy_cursor_grab_interface)
|
2015-02-06 05:15:28 +03:00
|
|
|
|
return;
|
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
grab = malloc(sizeof *grab);
|
|
|
|
|
if (!grab)
|
2013-12-03 21:35:45 +04:00
|
|
|
|
return;
|
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
shell_grab_start(grab, &busy_cursor_grab_interface, shsurf, pointer,
|
|
|
|
|
WESTON_DESKTOP_SHELL_CURSOR_BUSY);
|
|
|
|
|
/* Mark the shsurf as ungrabbed so that button binding is able
|
|
|
|
|
* to move it. */
|
|
|
|
|
shsurf->grabbed = 0;
|
|
|
|
|
}
|
2013-12-03 21:35:45 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
static void
|
|
|
|
|
end_busy_cursor(struct weston_compositor *compositor,
|
|
|
|
|
struct weston_desktop_client *desktop_client)
|
|
|
|
|
{
|
|
|
|
|
struct shell_surface *shsurf;
|
|
|
|
|
struct shell_grab *grab;
|
|
|
|
|
struct weston_seat *seat;
|
2013-12-03 21:35:45 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
wl_list_for_each(seat, &compositor->seat_list, link) {
|
|
|
|
|
struct weston_pointer *pointer = weston_seat_get_pointer(seat);
|
|
|
|
|
struct weston_desktop_client *grab_client;
|
2015-03-18 11:37:47 +03:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
if (!pointer)
|
|
|
|
|
continue;
|
2015-03-18 11:37:47 +03:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
if (pointer->grab->interface != &busy_cursor_grab_interface)
|
|
|
|
|
continue;
|
2013-12-03 21:35:45 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
grab = (struct shell_grab *) pointer->grab;
|
|
|
|
|
shsurf = grab->shsurf;
|
|
|
|
|
if (!shsurf)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
grab_client =
|
|
|
|
|
weston_desktop_surface_get_client(shsurf->desktop_surface);
|
|
|
|
|
if (grab_client == desktop_client) {
|
|
|
|
|
shell_grab_end(grab);
|
|
|
|
|
free(grab);
|
|
|
|
|
}
|
2015-09-24 03:30:43 +03:00
|
|
|
|
}
|
2013-12-03 21:35:45 +04:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-12 00:22:51 +04:00
|
|
|
|
static void
|
2016-08-12 11:41:36 +03:00
|
|
|
|
desktop_surface_set_unresponsive(struct weston_desktop_surface *desktop_surface,
|
|
|
|
|
void *user_data)
|
2014-02-12 00:22:51 +04:00
|
|
|
|
{
|
2016-08-12 11:41:36 +03:00
|
|
|
|
struct shell_surface *shsurf =
|
|
|
|
|
weston_desktop_surface_get_user_data(desktop_surface);
|
|
|
|
|
bool *unresponsive = user_data;
|
2014-02-12 00:22:51 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
shsurf->unresponsive = *unresponsive;
|
2014-02-12 00:22:51 +04:00
|
|
|
|
}
|
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
static void
|
|
|
|
|
desktop_surface_ping_timeout(struct weston_desktop_client *desktop_client,
|
|
|
|
|
void *shell_)
|
2013-12-03 21:35:45 +04:00
|
|
|
|
{
|
2016-08-12 11:41:36 +03:00
|
|
|
|
struct desktop_shell *shell = shell_;
|
|
|
|
|
struct shell_surface *shsurf;
|
|
|
|
|
struct weston_seat *seat;
|
|
|
|
|
bool unresponsive = true;
|
2013-12-03 21:35:45 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
weston_desktop_client_for_each_surface(desktop_client,
|
|
|
|
|
desktop_surface_set_unresponsive,
|
|
|
|
|
&unresponsive);
|
2013-12-03 21:35:45 +04:00
|
|
|
|
|
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
wl_list_for_each(seat, &shell->compositor->seat_list, link) {
|
|
|
|
|
struct weston_pointer *pointer = weston_seat_get_pointer(seat);
|
|
|
|
|
struct weston_desktop_client *grab_client;
|
2013-12-03 21:35:45 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
if (!pointer || !pointer->focus)
|
|
|
|
|
continue;
|
2013-12-03 21:35:45 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
shsurf = get_shell_surface(pointer->focus->surface);
|
|
|
|
|
if (!shsurf)
|
|
|
|
|
continue;
|
2013-12-09 10:27:11 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
grab_client =
|
|
|
|
|
weston_desktop_surface_get_client(shsurf->desktop_surface);
|
|
|
|
|
if (grab_client == desktop_client)
|
|
|
|
|
set_busy_cursor(shsurf, pointer);
|
2013-12-03 21:35:45 +04:00
|
|
|
|
}
|
2016-08-12 11:41:36 +03:00
|
|
|
|
}
|
2013-12-03 21:35:45 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
static void
|
|
|
|
|
desktop_surface_pong(struct weston_desktop_client *desktop_client,
|
|
|
|
|
void *shell_)
|
|
|
|
|
{
|
|
|
|
|
struct desktop_shell *shell = shell_;
|
|
|
|
|
bool unresponsive = false;
|
2013-12-03 21:35:45 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
weston_desktop_client_for_each_surface(desktop_client,
|
|
|
|
|
desktop_surface_set_unresponsive,
|
|
|
|
|
&unresponsive);
|
|
|
|
|
end_busy_cursor(shell->compositor, desktop_client);
|
2013-12-03 21:35:45 +04:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-16 16:17:14 +03:00
|
|
|
|
static void
|
|
|
|
|
desktop_surface_set_xwayland_position(struct weston_desktop_surface *surface,
|
|
|
|
|
int32_t x, int32_t y, void *shell_)
|
|
|
|
|
{
|
|
|
|
|
struct shell_surface *shsurf =
|
|
|
|
|
weston_desktop_surface_get_user_data(surface);
|
|
|
|
|
|
|
|
|
|
shsurf->xwayland.x = x;
|
|
|
|
|
shsurf->xwayland.y = y;
|
|
|
|
|
shsurf->xwayland.is_set = true;
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-22 22:04:18 +03:00
|
|
|
|
static void
|
|
|
|
|
desktop_surface_get_position(struct weston_desktop_surface *surface,
|
|
|
|
|
int32_t *x, int32_t *y,
|
|
|
|
|
void *shell_)
|
|
|
|
|
{
|
|
|
|
|
struct shell_surface *shsurf = weston_desktop_surface_get_user_data(surface);
|
|
|
|
|
|
2022-02-04 02:47:41 +03:00
|
|
|
|
*x = shsurf->view->geometry.pos_offset.x;
|
|
|
|
|
*y = shsurf->view->geometry.pos_offset.y;
|
2022-06-22 22:04:18 +03:00
|
|
|
|
}
|
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
static const struct weston_desktop_api shell_desktop_api = {
|
|
|
|
|
.struct_size = sizeof(struct weston_desktop_api),
|
|
|
|
|
.surface_added = desktop_surface_added,
|
|
|
|
|
.surface_removed = desktop_surface_removed,
|
|
|
|
|
.committed = desktop_surface_committed,
|
|
|
|
|
.move = desktop_surface_move,
|
|
|
|
|
.resize = desktop_surface_resize,
|
2019-06-23 15:53:59 +03:00
|
|
|
|
.set_parent = desktop_surface_set_parent,
|
2016-08-12 11:41:36 +03:00
|
|
|
|
.fullscreen_requested = desktop_surface_fullscreen_requested,
|
|
|
|
|
.maximized_requested = desktop_surface_maximized_requested,
|
|
|
|
|
.minimized_requested = desktop_surface_minimized_requested,
|
|
|
|
|
.ping_timeout = desktop_surface_ping_timeout,
|
|
|
|
|
.pong = desktop_surface_pong,
|
2016-11-16 16:17:14 +03:00
|
|
|
|
.set_xwayland_position = desktop_surface_set_xwayland_position,
|
2022-06-22 22:04:18 +03:00
|
|
|
|
.get_position = desktop_surface_get_position,
|
2016-08-12 11:41:36 +03:00
|
|
|
|
};
|
2013-12-03 21:35:45 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
/* ************************ *
|
|
|
|
|
* end of libweston-desktop *
|
|
|
|
|
* ************************ */
|
2012-06-27 00:29:50 +04:00
|
|
|
|
static void
|
2016-06-23 19:55:20 +03:00
|
|
|
|
configure_static_view(struct weston_view *ev, struct weston_layer *layer, int x, int y)
|
2012-06-27 00:29:50 +04:00
|
|
|
|
{
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
struct weston_view *v, *next;
|
2012-06-27 00:29:50 +04:00
|
|
|
|
|
2018-04-26 12:08:10 +03:00
|
|
|
|
if (!ev->output)
|
|
|
|
|
return;
|
|
|
|
|
|
2014-07-09 23:12:56 +04:00
|
|
|
|
wl_list_for_each_safe(v, next, &layer->view_list.link, layer_link.link) {
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
if (v->output == ev->output && v != ev) {
|
|
|
|
|
weston_view_unmap(v);
|
2016-08-12 11:41:33 +03:00
|
|
|
|
v->surface->committed = NULL;
|
compositor: add weston_surface_set_label_func()
When printing out logs from Weston's actions, mainly for debugging, it
can be very difficult to identify the different surfaces. Inspecting
the configure function pointer is not useful, as the configure functions
may live in modules.
Add vfunc get_label to weston_surface, which will produce a short,
human-readable description of the surface, which allows identifying it
better, rather than just looking at the surface size, for instance.
Set the label function from most parts of Weston, to identify cursors and
drag icons, and panels, backgrounds, screensavers and lock surfaces, and
the desktop shell's application surfaces.
v2: renamed 'description' to 'label', so we get
weston_surface_set_label_func().
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-08-06 20:36:51 +04:00
|
|
|
|
weston_surface_set_label_func(v->surface, NULL);
|
2012-06-27 00:29:50 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-23 19:55:20 +03:00
|
|
|
|
weston_view_set_position(ev, ev->output->x + x, ev->output->y + y);
|
2022-06-12 22:51:45 +03:00
|
|
|
|
weston_surface_map(ev->surface);
|
2016-06-30 07:04:29 +03:00
|
|
|
|
ev->is_mapped = true;
|
2012-06-27 00:29:50 +04:00
|
|
|
|
|
2014-07-09 23:12:56 +04:00
|
|
|
|
if (wl_list_empty(&ev->layer_link.link)) {
|
|
|
|
|
weston_layer_entry_insert(&layer->view_list, &ev->layer_link);
|
2022-11-30 02:00:09 +03:00
|
|
|
|
weston_view_geometry_dirty(ev);
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
weston_compositor_schedule_repaint(ev->surface->compositor);
|
2012-06-27 00:29:50 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-09 18:55:52 +03:00
|
|
|
|
|
|
|
|
|
static struct shell_output *
|
2016-08-12 11:41:36 +03:00
|
|
|
|
find_shell_output_from_weston_output(struct desktop_shell *shell,
|
|
|
|
|
struct weston_output *output)
|
2016-06-09 18:55:52 +03:00
|
|
|
|
{
|
|
|
|
|
struct shell_output *shell_output;
|
|
|
|
|
|
|
|
|
|
wl_list_for_each(shell_output, &shell->output_list, link) {
|
|
|
|
|
if (shell_output->output == output)
|
|
|
|
|
return shell_output;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
compositor: add weston_surface_set_label_func()
When printing out logs from Weston's actions, mainly for debugging, it
can be very difficult to identify the different surfaces. Inspecting
the configure function pointer is not useful, as the configure functions
may live in modules.
Add vfunc get_label to weston_surface, which will produce a short,
human-readable description of the surface, which allows identifying it
better, rather than just looking at the surface size, for instance.
Set the label function from most parts of Weston, to identify cursors and
drag icons, and panels, backgrounds, screensavers and lock surfaces, and
the desktop shell's application surfaces.
v2: renamed 'description' to 'label', so we get
weston_surface_set_label_func().
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-08-06 20:36:51 +04:00
|
|
|
|
static int
|
|
|
|
|
background_get_label(struct weston_surface *surface, char *buf, size_t len)
|
|
|
|
|
{
|
|
|
|
|
return snprintf(buf, len, "background for output %s",
|
2019-09-25 21:23:13 +03:00
|
|
|
|
(surface->output ? surface->output->name : "NULL"));
|
compositor: add weston_surface_set_label_func()
When printing out logs from Weston's actions, mainly for debugging, it
can be very difficult to identify the different surfaces. Inspecting
the configure function pointer is not useful, as the configure functions
may live in modules.
Add vfunc get_label to weston_surface, which will produce a short,
human-readable description of the surface, which allows identifying it
better, rather than just looking at the surface size, for instance.
Set the label function from most parts of Weston, to identify cursors and
drag icons, and panels, backgrounds, screensavers and lock surfaces, and
the desktop shell's application surfaces.
v2: renamed 'description' to 'label', so we get
weston_surface_set_label_func().
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-08-06 20:36:51 +04:00
|
|
|
|
}
|
|
|
|
|
|
2012-06-27 05:19:23 +04:00
|
|
|
|
static void
|
2022-02-04 17:02:26 +03:00
|
|
|
|
background_committed(struct weston_surface *es,
|
|
|
|
|
struct weston_coord_surface new_origin)
|
2012-06-27 05:19:23 +04:00
|
|
|
|
{
|
2016-08-12 11:41:33 +03:00
|
|
|
|
struct desktop_shell *shell = es->committed_private;
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
struct weston_view *view;
|
2012-06-27 05:19:23 +04:00
|
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
view = container_of(es->views.next, struct weston_view, surface_link);
|
|
|
|
|
|
2016-06-23 19:55:20 +03:00
|
|
|
|
configure_static_view(view, &shell->background_layer, 0, 0);
|
2012-06-27 05:19:23 +04:00
|
|
|
|
}
|
|
|
|
|
|
2016-06-09 18:55:52 +03:00
|
|
|
|
static void
|
|
|
|
|
handle_background_surface_destroy(struct wl_listener *listener, void *data)
|
|
|
|
|
{
|
|
|
|
|
struct shell_output *output =
|
|
|
|
|
container_of(listener, struct shell_output, background_surface_listener);
|
|
|
|
|
|
|
|
|
|
weston_log("background surface gone\n");
|
2018-01-31 09:15:45 +03:00
|
|
|
|
wl_list_remove(&output->background_surface_listener.link);
|
2016-06-09 18:55:52 +03:00
|
|
|
|
output->background_surface = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-06 21:48:16 +04:00
|
|
|
|
static void
|
|
|
|
|
desktop_shell_set_background(struct wl_client *client,
|
|
|
|
|
struct wl_resource *resource,
|
2011-11-22 15:43:52 +04:00
|
|
|
|
struct wl_resource *output_resource,
|
2011-09-06 21:48:16 +04:00
|
|
|
|
struct wl_resource *surface_resource)
|
|
|
|
|
{
|
2013-06-14 19:07:54 +04:00
|
|
|
|
struct desktop_shell *shell = wl_resource_get_user_data(resource);
|
2013-06-14 19:07:53 +04:00
|
|
|
|
struct weston_surface *surface =
|
|
|
|
|
wl_resource_get_user_data(surface_resource);
|
2016-06-09 18:55:52 +03:00
|
|
|
|
struct shell_output *sh_output;
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
struct weston_view *view, *next;
|
2011-11-23 23:46:40 +04:00
|
|
|
|
|
2016-08-12 11:41:33 +03:00
|
|
|
|
if (surface->committed) {
|
2012-06-27 00:29:50 +04:00
|
|
|
|
wl_resource_post_error(surface_resource,
|
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
|
|
|
|
"surface role already assigned");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2011-11-22 15:43:52 +04:00
|
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
wl_list_for_each_safe(view, next, &surface->views, surface_link)
|
|
|
|
|
weston_view_destroy(view);
|
|
|
|
|
view = weston_view_create(surface);
|
|
|
|
|
|
2016-08-12 11:41:33 +03:00
|
|
|
|
surface->committed = background_committed;
|
|
|
|
|
surface->committed_private = shell;
|
compositor: add weston_surface_set_label_func()
When printing out logs from Weston's actions, mainly for debugging, it
can be very difficult to identify the different surfaces. Inspecting
the configure function pointer is not useful, as the configure functions
may live in modules.
Add vfunc get_label to weston_surface, which will produce a short,
human-readable description of the surface, which allows identifying it
better, rather than just looking at the surface size, for instance.
Set the label function from most parts of Weston, to identify cursors and
drag icons, and panels, backgrounds, screensavers and lock surfaces, and
the desktop shell's application surfaces.
v2: renamed 'description' to 'label', so we get
weston_surface_set_label_func().
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-08-06 20:36:51 +04:00
|
|
|
|
weston_surface_set_label_func(surface, background_get_label);
|
2017-03-27 16:31:25 +03:00
|
|
|
|
surface->output = weston_head_from_resource(output_resource)->output;
|
2018-04-26 12:08:10 +03:00
|
|
|
|
weston_view_set_output(view, surface->output);
|
2016-06-09 18:55:52 +03:00
|
|
|
|
|
|
|
|
|
sh_output = find_shell_output_from_weston_output(shell, surface->output);
|
2017-12-07 12:44:18 +03:00
|
|
|
|
if (sh_output->background_surface) {
|
|
|
|
|
/* The output already has a background, tell our helper
|
|
|
|
|
* there is no need for another one. */
|
|
|
|
|
weston_desktop_shell_send_configure(resource, 0,
|
|
|
|
|
surface_resource,
|
|
|
|
|
0, 0);
|
|
|
|
|
} else {
|
|
|
|
|
weston_desktop_shell_send_configure(resource, 0,
|
|
|
|
|
surface_resource,
|
|
|
|
|
surface->output->width,
|
|
|
|
|
surface->output->height);
|
|
|
|
|
|
|
|
|
|
sh_output->background_surface = surface;
|
2016-06-09 18:55:52 +03:00
|
|
|
|
|
2017-12-07 12:44:18 +03:00
|
|
|
|
sh_output->background_surface_listener.notify =
|
|
|
|
|
handle_background_surface_destroy;
|
|
|
|
|
wl_signal_add(&surface->destroy_signal,
|
|
|
|
|
&sh_output->background_surface_listener);
|
|
|
|
|
}
|
2011-09-06 21:48:16 +04:00
|
|
|
|
}
|
|
|
|
|
|
compositor: add weston_surface_set_label_func()
When printing out logs from Weston's actions, mainly for debugging, it
can be very difficult to identify the different surfaces. Inspecting
the configure function pointer is not useful, as the configure functions
may live in modules.
Add vfunc get_label to weston_surface, which will produce a short,
human-readable description of the surface, which allows identifying it
better, rather than just looking at the surface size, for instance.
Set the label function from most parts of Weston, to identify cursors and
drag icons, and panels, backgrounds, screensavers and lock surfaces, and
the desktop shell's application surfaces.
v2: renamed 'description' to 'label', so we get
weston_surface_set_label_func().
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-08-06 20:36:51 +04:00
|
|
|
|
static int
|
|
|
|
|
panel_get_label(struct weston_surface *surface, char *buf, size_t len)
|
|
|
|
|
{
|
|
|
|
|
return snprintf(buf, len, "panel for output %s",
|
2019-09-25 21:23:13 +03:00
|
|
|
|
(surface->output ? surface->output->name : "NULL"));
|
compositor: add weston_surface_set_label_func()
When printing out logs from Weston's actions, mainly for debugging, it
can be very difficult to identify the different surfaces. Inspecting
the configure function pointer is not useful, as the configure functions
may live in modules.
Add vfunc get_label to weston_surface, which will produce a short,
human-readable description of the surface, which allows identifying it
better, rather than just looking at the surface size, for instance.
Set the label function from most parts of Weston, to identify cursors and
drag icons, and panels, backgrounds, screensavers and lock surfaces, and
the desktop shell's application surfaces.
v2: renamed 'description' to 'label', so we get
weston_surface_set_label_func().
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-08-06 20:36:51 +04:00
|
|
|
|
}
|
|
|
|
|
|
2012-06-27 05:19:23 +04:00
|
|
|
|
static void
|
2022-02-04 17:02:26 +03:00
|
|
|
|
panel_committed(struct weston_surface *es,
|
|
|
|
|
struct weston_coord_surface new_origin)
|
2012-06-27 05:19:23 +04:00
|
|
|
|
{
|
2016-08-12 11:41:33 +03:00
|
|
|
|
struct desktop_shell *shell = es->committed_private;
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
struct weston_view *view;
|
2016-06-23 19:55:20 +03:00
|
|
|
|
int width, height;
|
|
|
|
|
int x = 0, y = 0;
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
|
|
|
|
|
view = container_of(es->views.next, struct weston_view, surface_link);
|
2012-06-27 05:19:23 +04:00
|
|
|
|
|
2022-11-09 01:09:05 +03:00
|
|
|
|
/* XXX delete me eventually - it would be better if we didn't get here
|
|
|
|
|
* with a dirty transform at all, but for now just make sure the
|
|
|
|
|
* transform is updated here. */
|
|
|
|
|
weston_view_update_transform(view);
|
|
|
|
|
|
2016-06-23 19:55:20 +03:00
|
|
|
|
get_panel_size(shell, view, &width, &height);
|
|
|
|
|
switch (shell->panel_position) {
|
|
|
|
|
case WESTON_DESKTOP_SHELL_PANEL_POSITION_TOP:
|
|
|
|
|
break;
|
|
|
|
|
case WESTON_DESKTOP_SHELL_PANEL_POSITION_BOTTOM:
|
|
|
|
|
y = view->output->height - height;
|
|
|
|
|
break;
|
|
|
|
|
case WESTON_DESKTOP_SHELL_PANEL_POSITION_LEFT:
|
|
|
|
|
break;
|
|
|
|
|
case WESTON_DESKTOP_SHELL_PANEL_POSITION_RIGHT:
|
|
|
|
|
x = view->output->width - width;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
configure_static_view(view, &shell->panel_layer, x, y);
|
2012-06-27 05:19:23 +04:00
|
|
|
|
}
|
|
|
|
|
|
2016-06-09 18:55:52 +03:00
|
|
|
|
static void
|
|
|
|
|
handle_panel_surface_destroy(struct wl_listener *listener, void *data)
|
|
|
|
|
{
|
|
|
|
|
struct shell_output *output =
|
|
|
|
|
container_of(listener, struct shell_output, panel_surface_listener);
|
|
|
|
|
|
|
|
|
|
weston_log("panel surface gone\n");
|
2018-01-31 09:15:45 +03:00
|
|
|
|
wl_list_remove(&output->panel_surface_listener.link);
|
2016-06-09 18:55:52 +03:00
|
|
|
|
output->panel_surface = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-09-06 21:48:16 +04:00
|
|
|
|
static void
|
|
|
|
|
desktop_shell_set_panel(struct wl_client *client,
|
|
|
|
|
struct wl_resource *resource,
|
2011-11-22 15:43:52 +04:00
|
|
|
|
struct wl_resource *output_resource,
|
2011-09-06 21:48:16 +04:00
|
|
|
|
struct wl_resource *surface_resource)
|
|
|
|
|
{
|
2013-06-14 19:07:54 +04:00
|
|
|
|
struct desktop_shell *shell = wl_resource_get_user_data(resource);
|
2013-06-14 19:07:53 +04:00
|
|
|
|
struct weston_surface *surface =
|
|
|
|
|
wl_resource_get_user_data(surface_resource);
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
struct weston_view *view, *next;
|
2016-06-09 18:55:52 +03:00
|
|
|
|
struct shell_output *sh_output;
|
2011-11-23 23:46:40 +04:00
|
|
|
|
|
2016-08-12 11:41:33 +03:00
|
|
|
|
if (surface->committed) {
|
2012-06-27 05:19:23 +04:00
|
|
|
|
wl_resource_post_error(surface_resource,
|
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
|
|
|
|
"surface role already assigned");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2011-09-06 21:48:16 +04:00
|
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
wl_list_for_each_safe(view, next, &surface->views, surface_link)
|
|
|
|
|
weston_view_destroy(view);
|
|
|
|
|
view = weston_view_create(surface);
|
|
|
|
|
|
2016-08-12 11:41:33 +03:00
|
|
|
|
surface->committed = panel_committed;
|
|
|
|
|
surface->committed_private = shell;
|
compositor: add weston_surface_set_label_func()
When printing out logs from Weston's actions, mainly for debugging, it
can be very difficult to identify the different surfaces. Inspecting
the configure function pointer is not useful, as the configure functions
may live in modules.
Add vfunc get_label to weston_surface, which will produce a short,
human-readable description of the surface, which allows identifying it
better, rather than just looking at the surface size, for instance.
Set the label function from most parts of Weston, to identify cursors and
drag icons, and panels, backgrounds, screensavers and lock surfaces, and
the desktop shell's application surfaces.
v2: renamed 'description' to 'label', so we get
weston_surface_set_label_func().
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-08-06 20:36:51 +04:00
|
|
|
|
weston_surface_set_label_func(surface, panel_get_label);
|
2017-03-27 16:31:25 +03:00
|
|
|
|
surface->output = weston_head_from_resource(output_resource)->output;
|
2018-04-26 12:08:10 +03:00
|
|
|
|
weston_view_set_output(view, surface->output);
|
2016-06-09 18:55:52 +03:00
|
|
|
|
|
|
|
|
|
sh_output = find_shell_output_from_weston_output(shell, surface->output);
|
2017-12-07 12:54:11 +03:00
|
|
|
|
if (sh_output->panel_surface) {
|
|
|
|
|
/* The output already has a panel, tell our helper
|
|
|
|
|
* there is no need for another one. */
|
|
|
|
|
weston_desktop_shell_send_configure(resource, 0,
|
|
|
|
|
surface_resource,
|
|
|
|
|
0, 0);
|
|
|
|
|
} else {
|
|
|
|
|
weston_desktop_shell_send_configure(resource, 0,
|
|
|
|
|
surface_resource,
|
|
|
|
|
surface->output->width,
|
|
|
|
|
surface->output->height);
|
2016-06-09 18:55:52 +03:00
|
|
|
|
|
2017-12-07 12:54:11 +03:00
|
|
|
|
sh_output->panel_surface = surface;
|
|
|
|
|
|
|
|
|
|
sh_output->panel_surface_listener.notify = handle_panel_surface_destroy;
|
|
|
|
|
wl_signal_add(&surface->destroy_signal, &sh_output->panel_surface_listener);
|
|
|
|
|
}
|
2011-09-06 21:48:16 +04:00
|
|
|
|
}
|
|
|
|
|
|
compositor: add weston_surface_set_label_func()
When printing out logs from Weston's actions, mainly for debugging, it
can be very difficult to identify the different surfaces. Inspecting
the configure function pointer is not useful, as the configure functions
may live in modules.
Add vfunc get_label to weston_surface, which will produce a short,
human-readable description of the surface, which allows identifying it
better, rather than just looking at the surface size, for instance.
Set the label function from most parts of Weston, to identify cursors and
drag icons, and panels, backgrounds, screensavers and lock surfaces, and
the desktop shell's application surfaces.
v2: renamed 'description' to 'label', so we get
weston_surface_set_label_func().
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-08-06 20:36:51 +04:00
|
|
|
|
static int
|
|
|
|
|
lock_surface_get_label(struct weston_surface *surface, char *buf, size_t len)
|
|
|
|
|
{
|
|
|
|
|
return snprintf(buf, len, "lock window");
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-27 05:44:35 +04:00
|
|
|
|
static void
|
2022-02-04 17:02:26 +03:00
|
|
|
|
lock_surface_committed(struct weston_surface *surface,
|
|
|
|
|
struct weston_coord_surface new_origin)
|
2012-06-27 05:44:35 +04:00
|
|
|
|
{
|
2016-08-12 11:41:33 +03:00
|
|
|
|
struct desktop_shell *shell = surface->committed_private;
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
struct weston_view *view;
|
|
|
|
|
|
|
|
|
|
view = container_of(surface->views.next, struct weston_view, surface_link);
|
2012-06-27 05:44:35 +04:00
|
|
|
|
|
2013-12-03 07:01:53 +04:00
|
|
|
|
if (surface->width == 0)
|
2013-02-21 14:29:21 +04:00
|
|
|
|
return;
|
|
|
|
|
|
2022-11-22 14:28:57 +03:00
|
|
|
|
weston_shell_utils_center_on_output(view,
|
|
|
|
|
weston_shell_utils_get_default_output(shell->compositor));
|
2012-06-27 05:44:35 +04:00
|
|
|
|
|
|
|
|
|
if (!weston_surface_is_mapped(surface)) {
|
2014-07-09 23:12:56 +04:00
|
|
|
|
weston_layer_entry_insert(&shell->lock_layer.view_list,
|
|
|
|
|
&view->layer_link);
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
weston_view_update_transform(view);
|
2022-06-12 22:51:45 +03:00
|
|
|
|
weston_surface_map(surface);
|
2016-06-30 07:04:29 +03:00
|
|
|
|
view->is_mapped = true;
|
2013-02-21 20:35:22 +04:00
|
|
|
|
shell_fade(shell, FADE_IN);
|
2012-06-27 05:44:35 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-16 01:39:55 +04:00
|
|
|
|
static void
|
2012-04-12 07:18:23 +04:00
|
|
|
|
handle_lock_surface_destroy(struct wl_listener *listener, void *data)
|
2011-11-16 01:39:55 +04:00
|
|
|
|
{
|
2012-04-16 18:31:41 +04:00
|
|
|
|
struct desktop_shell *shell =
|
|
|
|
|
container_of(listener, struct desktop_shell, lock_surface_listener);
|
2011-11-16 01:39:55 +04:00
|
|
|
|
|
2012-06-07 20:01:59 +04:00
|
|
|
|
weston_log("lock surface gone\n");
|
2011-11-16 01:39:55 +04:00
|
|
|
|
shell->lock_surface = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
desktop-shell: screen locking protocol
Add protocol and functions for supporting screen locking, triggered by
activity timeout.
After activity timeout, compositor starts the fade to black, and then
enters SLEEPING state. At that point it calls lock() in the shell
plugin.
When input events trigger a wakeup, unlock() in the shell plugin is
called. This sends prepare_lock_surface event to the desktop-shell
client. The screen stays locked while the compositor starts fade-in.
At this point, desktop-shell client usually creates a surface for the
unlocking GUI (e.g. a password prompt), and sends it with the
set_lock_surface request. The compositor supposedly shows and allows
interaction only with the given lock surface (not yet implemented).
When desktop-shell has authenticated the user, or instead of issuing
set_lock_surface, it sends the unlock request. Upon receiving the unlock
request, the shell plugin unlocks the screen.
If desktop-shell client dies, the screen is unlocked automatically.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-15 15:34:48 +04:00
|
|
|
|
static void
|
|
|
|
|
desktop_shell_set_lock_surface(struct wl_client *client,
|
|
|
|
|
struct wl_resource *resource,
|
|
|
|
|
struct wl_resource *surface_resource)
|
|
|
|
|
{
|
2013-06-14 19:07:54 +04:00
|
|
|
|
struct desktop_shell *shell = wl_resource_get_user_data(resource);
|
2013-06-14 19:07:53 +04:00
|
|
|
|
struct weston_surface *surface =
|
|
|
|
|
wl_resource_get_user_data(surface_resource);
|
2011-12-01 12:42:22 +04:00
|
|
|
|
|
2011-11-15 15:34:54 +04:00
|
|
|
|
shell->prepare_event_sent = false;
|
|
|
|
|
|
|
|
|
|
if (!shell->locked)
|
|
|
|
|
return;
|
2011-11-15 15:34:49 +04:00
|
|
|
|
|
2011-12-01 12:42:22 +04:00
|
|
|
|
shell->lock_surface = surface;
|
2011-11-15 15:34:49 +04:00
|
|
|
|
|
2012-04-12 07:18:23 +04:00
|
|
|
|
shell->lock_surface_listener.notify = handle_lock_surface_destroy;
|
2013-06-14 19:07:54 +04:00
|
|
|
|
wl_signal_add(&surface->destroy_signal,
|
2012-04-12 07:18:23 +04:00
|
|
|
|
&shell->lock_surface_listener);
|
2011-11-23 18:42:16 +04:00
|
|
|
|
|
2013-10-31 02:49:45 +04:00
|
|
|
|
weston_view_create(surface);
|
2016-08-12 11:41:33 +03:00
|
|
|
|
surface->committed = lock_surface_committed;
|
|
|
|
|
surface->committed_private = shell;
|
compositor: add weston_surface_set_label_func()
When printing out logs from Weston's actions, mainly for debugging, it
can be very difficult to identify the different surfaces. Inspecting
the configure function pointer is not useful, as the configure functions
may live in modules.
Add vfunc get_label to weston_surface, which will produce a short,
human-readable description of the surface, which allows identifying it
better, rather than just looking at the surface size, for instance.
Set the label function from most parts of Weston, to identify cursors and
drag icons, and panels, backgrounds, screensavers and lock surfaces, and
the desktop shell's application surfaces.
v2: renamed 'description' to 'label', so we get
weston_surface_set_label_func().
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-08-06 20:36:51 +04:00
|
|
|
|
weston_surface_set_label_func(surface, lock_surface_get_label);
|
2011-11-15 15:34:54 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2012-04-16 18:31:41 +04:00
|
|
|
|
resume_desktop(struct desktop_shell *shell)
|
2011-11-15 15:34:54 +04:00
|
|
|
|
{
|
2012-06-25 22:03:13 +04:00
|
|
|
|
struct workspace *ws = get_current_workspace(shell);
|
2011-11-30 18:26:35 +04:00
|
|
|
|
|
2016-12-17 15:40:51 +03:00
|
|
|
|
weston_layer_unset_position(&shell->lock_layer);
|
|
|
|
|
|
|
|
|
|
if (shell->showing_input_panels)
|
|
|
|
|
weston_layer_set_position(&shell->input_panel_layer,
|
|
|
|
|
WESTON_LAYER_POSITION_TOP_UI);
|
|
|
|
|
weston_layer_set_position(&shell->fullscreen_layer,
|
|
|
|
|
WESTON_LAYER_POSITION_FULLSCREEN);
|
|
|
|
|
weston_layer_set_position(&shell->panel_layer,
|
|
|
|
|
WESTON_LAYER_POSITION_UI);
|
|
|
|
|
weston_layer_set_position(&ws->layer, WESTON_LAYER_POSITION_NORMAL);
|
2011-11-15 15:34:54 +04:00
|
|
|
|
|
2012-08-01 00:36:34 +04:00
|
|
|
|
restore_focus_state(shell, get_current_workspace(shell));
|
2012-06-13 02:01:24 +04:00
|
|
|
|
|
2011-11-15 15:34:54 +04:00
|
|
|
|
shell->locked = false;
|
2013-02-21 20:35:22 +04:00
|
|
|
|
shell_fade(shell, FADE_IN);
|
2012-02-10 17:33:10 +04:00
|
|
|
|
weston_compositor_damage_all(shell->compositor);
|
desktop-shell: screen locking protocol
Add protocol and functions for supporting screen locking, triggered by
activity timeout.
After activity timeout, compositor starts the fade to black, and then
enters SLEEPING state. At that point it calls lock() in the shell
plugin.
When input events trigger a wakeup, unlock() in the shell plugin is
called. This sends prepare_lock_surface event to the desktop-shell
client. The screen stays locked while the compositor starts fade-in.
At this point, desktop-shell client usually creates a surface for the
unlocking GUI (e.g. a password prompt), and sends it with the
set_lock_surface request. The compositor supposedly shows and allows
interaction only with the given lock surface (not yet implemented).
When desktop-shell has authenticated the user, or instead of issuing
set_lock_surface, it sends the unlock request. Upon receiving the unlock
request, the shell plugin unlocks the screen.
If desktop-shell client dies, the screen is unlocked automatically.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-15 15:34:48 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
desktop_shell_unlock(struct wl_client *client,
|
|
|
|
|
struct wl_resource *resource)
|
|
|
|
|
{
|
2013-06-14 19:07:54 +04:00
|
|
|
|
struct desktop_shell *shell = wl_resource_get_user_data(resource);
|
desktop-shell: screen locking protocol
Add protocol and functions for supporting screen locking, triggered by
activity timeout.
After activity timeout, compositor starts the fade to black, and then
enters SLEEPING state. At that point it calls lock() in the shell
plugin.
When input events trigger a wakeup, unlock() in the shell plugin is
called. This sends prepare_lock_surface event to the desktop-shell
client. The screen stays locked while the compositor starts fade-in.
At this point, desktop-shell client usually creates a surface for the
unlocking GUI (e.g. a password prompt), and sends it with the
set_lock_surface request. The compositor supposedly shows and allows
interaction only with the given lock surface (not yet implemented).
When desktop-shell has authenticated the user, or instead of issuing
set_lock_surface, it sends the unlock request. Upon receiving the unlock
request, the shell plugin unlocks the screen.
If desktop-shell client dies, the screen is unlocked automatically.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-15 15:34:48 +04:00
|
|
|
|
|
|
|
|
|
shell->prepare_event_sent = false;
|
2011-11-15 15:34:54 +04:00
|
|
|
|
|
|
|
|
|
if (shell->locked)
|
|
|
|
|
resume_desktop(shell);
|
desktop-shell: screen locking protocol
Add protocol and functions for supporting screen locking, triggered by
activity timeout.
After activity timeout, compositor starts the fade to black, and then
enters SLEEPING state. At that point it calls lock() in the shell
plugin.
When input events trigger a wakeup, unlock() in the shell plugin is
called. This sends prepare_lock_surface event to the desktop-shell
client. The screen stays locked while the compositor starts fade-in.
At this point, desktop-shell client usually creates a surface for the
unlocking GUI (e.g. a password prompt), and sends it with the
set_lock_surface request. The compositor supposedly shows and allows
interaction only with the given lock surface (not yet implemented).
When desktop-shell has authenticated the user, or instead of issuing
set_lock_surface, it sends the unlock request. Upon receiving the unlock
request, the shell plugin unlocks the screen.
If desktop-shell client dies, the screen is unlocked automatically.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-15 15:34:48 +04:00
|
|
|
|
}
|
|
|
|
|
|
2012-06-05 17:58:51 +04:00
|
|
|
|
static void
|
2012-06-28 19:08:05 +04:00
|
|
|
|
desktop_shell_set_grab_surface(struct wl_client *client,
|
2012-06-05 17:58:51 +04:00
|
|
|
|
struct wl_resource *resource,
|
|
|
|
|
struct wl_resource *surface_resource)
|
|
|
|
|
{
|
2013-06-14 19:07:54 +04:00
|
|
|
|
struct desktop_shell *shell = wl_resource_get_user_data(resource);
|
2012-06-05 17:58:51 +04:00
|
|
|
|
|
2013-06-14 19:07:53 +04:00
|
|
|
|
shell->grab_surface = wl_resource_get_user_data(surface_resource);
|
2013-10-25 02:51:35 +04:00
|
|
|
|
weston_view_create(shell->grab_surface);
|
2012-06-05 17:58:51 +04:00
|
|
|
|
}
|
|
|
|
|
|
shell: wait for desktop-shell init before fade in
On Raspberry Pi, weston-desktop-shell is so slow to start, that the
compositor has time to run the fade-in before the wallpaper is up. The
user launching Weston sees the screen flipping to black, the fbcon
fading in, and then the desktop popping up.
To fix this, wait for the weston-desktop-shell to draw
everything before starting the initial fade-in. A new request is
added to the private desktop-shell protocol to signal it. If a
desktop-shell client does not support the new request, the fade-in
happens already at bind time.
If weston-desktop-shell crashes, or does not send the 'desktop_ready'
request in 15 seconds, the compositor will fade in anyway. This should
avoid a blocked screen in case weston-desktop-shell malfunction.
shell_fade_startup() does not directly start the fade-in but schedules
an idle callback, so that the compositor can process all pending events
before starting the fade clock. Otherwise (on RPi) we risk skipping part
of the animation. Yes, it is a hack, that should have been done in
window.c and weston-desktop-shell instead.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2013-05-22 19:03:09 +04:00
|
|
|
|
static void
|
|
|
|
|
desktop_shell_desktop_ready(struct wl_client *client,
|
|
|
|
|
struct wl_resource *resource)
|
|
|
|
|
{
|
2013-06-14 19:07:54 +04:00
|
|
|
|
struct desktop_shell *shell = wl_resource_get_user_data(resource);
|
shell: wait for desktop-shell init before fade in
On Raspberry Pi, weston-desktop-shell is so slow to start, that the
compositor has time to run the fade-in before the wallpaper is up. The
user launching Weston sees the screen flipping to black, the fbcon
fading in, and then the desktop popping up.
To fix this, wait for the weston-desktop-shell to draw
everything before starting the initial fade-in. A new request is
added to the private desktop-shell protocol to signal it. If a
desktop-shell client does not support the new request, the fade-in
happens already at bind time.
If weston-desktop-shell crashes, or does not send the 'desktop_ready'
request in 15 seconds, the compositor will fade in anyway. This should
avoid a blocked screen in case weston-desktop-shell malfunction.
shell_fade_startup() does not directly start the fade-in but schedules
an idle callback, so that the compositor can process all pending events
before starting the fade clock. Otherwise (on RPi) we risk skipping part
of the animation. Yes, it is a hack, that should have been done in
window.c and weston-desktop-shell instead.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2013-05-22 19:03:09 +04:00
|
|
|
|
|
|
|
|
|
shell_fade_startup(shell);
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-20 17:53:19 +04:00
|
|
|
|
static void
|
|
|
|
|
desktop_shell_set_panel_position(struct wl_client *client,
|
|
|
|
|
struct wl_resource *resource,
|
|
|
|
|
uint32_t position)
|
|
|
|
|
{
|
|
|
|
|
struct desktop_shell *shell = wl_resource_get_user_data(resource);
|
|
|
|
|
|
2015-11-17 11:00:33 +03:00
|
|
|
|
if (position != WESTON_DESKTOP_SHELL_PANEL_POSITION_TOP &&
|
|
|
|
|
position != WESTON_DESKTOP_SHELL_PANEL_POSITION_BOTTOM &&
|
|
|
|
|
position != WESTON_DESKTOP_SHELL_PANEL_POSITION_LEFT &&
|
|
|
|
|
position != WESTON_DESKTOP_SHELL_PANEL_POSITION_RIGHT) {
|
2014-08-20 17:53:19 +04:00
|
|
|
|
wl_resource_post_error(resource,
|
2015-11-17 11:00:33 +03:00
|
|
|
|
WESTON_DESKTOP_SHELL_ERROR_INVALID_ARGUMENT,
|
2014-08-20 17:53:19 +04:00
|
|
|
|
"bad position argument");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
shell->panel_position = position;
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-17 11:00:33 +03:00
|
|
|
|
static const struct weston_desktop_shell_interface desktop_shell_implementation = {
|
2011-09-06 21:48:16 +04:00
|
|
|
|
desktop_shell_set_background,
|
desktop-shell: screen locking protocol
Add protocol and functions for supporting screen locking, triggered by
activity timeout.
After activity timeout, compositor starts the fade to black, and then
enters SLEEPING state. At that point it calls lock() in the shell
plugin.
When input events trigger a wakeup, unlock() in the shell plugin is
called. This sends prepare_lock_surface event to the desktop-shell
client. The screen stays locked while the compositor starts fade-in.
At this point, desktop-shell client usually creates a surface for the
unlocking GUI (e.g. a password prompt), and sends it with the
set_lock_surface request. The compositor supposedly shows and allows
interaction only with the given lock surface (not yet implemented).
When desktop-shell has authenticated the user, or instead of issuing
set_lock_surface, it sends the unlock request. Upon receiving the unlock
request, the shell plugin unlocks the screen.
If desktop-shell client dies, the screen is unlocked automatically.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-15 15:34:48 +04:00
|
|
|
|
desktop_shell_set_panel,
|
|
|
|
|
desktop_shell_set_lock_surface,
|
2012-06-05 17:58:51 +04:00
|
|
|
|
desktop_shell_unlock,
|
shell: wait for desktop-shell init before fade in
On Raspberry Pi, weston-desktop-shell is so slow to start, that the
compositor has time to run the fade-in before the wallpaper is up. The
user launching Weston sees the screen flipping to black, the fbcon
fading in, and then the desktop popping up.
To fix this, wait for the weston-desktop-shell to draw
everything before starting the initial fade-in. A new request is
added to the private desktop-shell protocol to signal it. If a
desktop-shell client does not support the new request, the fade-in
happens already at bind time.
If weston-desktop-shell crashes, or does not send the 'desktop_ready'
request in 15 seconds, the compositor will fade in anyway. This should
avoid a blocked screen in case weston-desktop-shell malfunction.
shell_fade_startup() does not directly start the fade-in but schedules
an idle callback, so that the compositor can process all pending events
before starting the fade clock. Otherwise (on RPi) we risk skipping part
of the animation. Yes, it is a hack, that should have been done in
window.c and weston-desktop-shell instead.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2013-05-22 19:03:09 +04:00
|
|
|
|
desktop_shell_set_grab_surface,
|
2014-08-20 17:53:19 +04:00
|
|
|
|
desktop_shell_desktop_ready,
|
|
|
|
|
desktop_shell_set_panel_position
|
2011-09-06 21:48:16 +04:00
|
|
|
|
};
|
|
|
|
|
|
2011-04-13 01:25:42 +04:00
|
|
|
|
static void
|
2017-11-16 19:20:55 +03:00
|
|
|
|
move_binding(struct weston_pointer *pointer, const struct timespec *time,
|
2015-07-15 21:00:36 +03:00
|
|
|
|
uint32_t button, void *data)
|
2011-04-13 01:25:42 +04:00
|
|
|
|
{
|
2014-01-05 23:04:59 +04:00
|
|
|
|
struct weston_surface *focus;
|
shell: keyboard focus and restacking fixes for sub-surfaces
The shell needs to redirect some actions to the parent surface, when
they originally target a sub-surface. This patch implements the
following:
- Move, resize, and rotate bindings always target the parent surface.
- Opacity (full-surface alpha) binding targets the parent surface. This
is broken, because it should change the opacity of the whole compound
window, which is difficult to implement in the renderer.
- click_to_activate_binding() needs to check the shell surface type from
the main surface, because sub-surface would produce SHELL_SURFACE_NONE
and prevent activation.
- Also activate() needs to check the type from the main surface, and
restack the main surface. Keyboard focus is assigned to the original
(sub-)surface.
- focus_state_surface_destroy() needs to handle sub-surfaces: only the
main surface will be in a layer list. If the destroyed surface is
indeed a sub-surface, activate the main surface next. This way a
client that destroys a focused sub-surface still retains focus in the
same window.
- The workspace_manager.move_surface request can accept also
sub-surfaces, and it will move the corresponding main surface.
Changes in v2:
- do not special-case keyboard focus for sub-surfaces
- fix surface type checks for sub-surfaces in shell, fix restacking of
sub-surfaces in shell, fix focus_state_surface_destroy()
Changes in v3:
- Renamed weston_surface_get_parent() to
weston_surface_get_main_surface() to be more explicit that this is
about sub-surfaces
- Fixed move_surface_to_workspace() to handle keyboard focus on a
sub-surface.
- Used a temporary variable in several places to clarify code, instead
of reassigning a variable.
- Fixed workspace_manager_move_surface() to deal with sub-surfaces.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:44 +04:00
|
|
|
|
struct weston_surface *surface;
|
2012-05-18 21:46:27 +04:00
|
|
|
|
struct shell_surface *shsurf;
|
2011-11-23 19:52:40 +04:00
|
|
|
|
|
2015-07-15 21:00:36 +03:00
|
|
|
|
if (pointer->focus == NULL)
|
2014-01-05 23:04:59 +04:00
|
|
|
|
return;
|
|
|
|
|
|
2015-07-15 21:00:36 +03:00
|
|
|
|
focus = pointer->focus->surface;
|
2014-01-05 23:04:59 +04:00
|
|
|
|
|
shell: keyboard focus and restacking fixes for sub-surfaces
The shell needs to redirect some actions to the parent surface, when
they originally target a sub-surface. This patch implements the
following:
- Move, resize, and rotate bindings always target the parent surface.
- Opacity (full-surface alpha) binding targets the parent surface. This
is broken, because it should change the opacity of the whole compound
window, which is difficult to implement in the renderer.
- click_to_activate_binding() needs to check the shell surface type from
the main surface, because sub-surface would produce SHELL_SURFACE_NONE
and prevent activation.
- Also activate() needs to check the type from the main surface, and
restack the main surface. Keyboard focus is assigned to the original
(sub-)surface.
- focus_state_surface_destroy() needs to handle sub-surfaces: only the
main surface will be in a layer list. If the destroyed surface is
indeed a sub-surface, activate the main surface next. This way a
client that destroys a focused sub-surface still retains focus in the
same window.
- The workspace_manager.move_surface request can accept also
sub-surfaces, and it will move the corresponding main surface.
Changes in v2:
- do not special-case keyboard focus for sub-surfaces
- fix surface type checks for sub-surfaces in shell, fix restacking of
sub-surfaces in shell, fix focus_state_surface_destroy()
Changes in v3:
- Renamed weston_surface_get_parent() to
weston_surface_get_main_surface() to be more explicit that this is
about sub-surfaces
- Fixed move_surface_to_workspace() to handle keyboard focus on a
sub-surface.
- Used a temporary variable in several places to clarify code, instead
of reassigning a variable.
- Fixed workspace_manager_move_surface() to deal with sub-surfaces.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:44 +04:00
|
|
|
|
surface = weston_surface_get_main_surface(focus);
|
2011-11-22 15:43:52 +04:00
|
|
|
|
if (surface == NULL)
|
2011-09-06 21:48:16 +04:00
|
|
|
|
return;
|
2011-04-13 19:52:54 +04:00
|
|
|
|
|
2012-05-18 21:46:27 +04:00
|
|
|
|
shsurf = get_shell_surface(surface);
|
2016-08-12 11:41:36 +03:00
|
|
|
|
if (shsurf == NULL ||
|
|
|
|
|
weston_desktop_surface_get_fullscreen(shsurf->desktop_surface) ||
|
|
|
|
|
weston_desktop_surface_get_maximized(shsurf->desktop_surface))
|
2012-05-18 21:46:27 +04:00
|
|
|
|
return;
|
|
|
|
|
|
2015-07-15 21:00:38 +03:00
|
|
|
|
surface_move(shsurf, pointer, false);
|
2011-04-13 01:25:42 +04:00
|
|
|
|
}
|
|
|
|
|
|
2013-12-03 21:35:48 +04:00
|
|
|
|
static void
|
2017-11-16 19:20:57 +03:00
|
|
|
|
maximize_binding(struct weston_keyboard *keyboard, const struct timespec *time,
|
2015-07-15 21:00:36 +03:00
|
|
|
|
uint32_t button, void *data)
|
2013-12-03 21:35:48 +04:00
|
|
|
|
{
|
2015-07-15 21:00:36 +03:00
|
|
|
|
struct weston_surface *focus = keyboard->focus;
|
2013-12-03 21:35:48 +04:00
|
|
|
|
struct weston_surface *surface;
|
|
|
|
|
struct shell_surface *shsurf;
|
|
|
|
|
|
|
|
|
|
surface = weston_surface_get_main_surface(focus);
|
|
|
|
|
if (surface == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
shsurf = get_shell_surface(surface);
|
|
|
|
|
if (shsurf == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
set_maximized(shsurf, !weston_desktop_surface_get_maximized(shsurf->desktop_surface));
|
2013-12-03 21:35:48 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2017-11-16 19:20:57 +03:00
|
|
|
|
fullscreen_binding(struct weston_keyboard *keyboard,
|
|
|
|
|
const struct timespec *time, uint32_t button, void *data)
|
2013-12-03 21:35:48 +04:00
|
|
|
|
{
|
2015-07-15 21:00:36 +03:00
|
|
|
|
struct weston_surface *focus = keyboard->focus;
|
2013-12-03 21:35:48 +04:00
|
|
|
|
struct weston_surface *surface;
|
|
|
|
|
struct shell_surface *shsurf;
|
2016-08-12 11:41:36 +03:00
|
|
|
|
bool fullscreen;
|
2013-12-03 21:35:48 +04:00
|
|
|
|
|
|
|
|
|
surface = weston_surface_get_main_surface(focus);
|
|
|
|
|
if (surface == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
shsurf = get_shell_surface(surface);
|
|
|
|
|
if (shsurf == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
fullscreen =
|
|
|
|
|
weston_desktop_surface_get_fullscreen(shsurf->desktop_surface);
|
2013-12-03 21:35:48 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
set_fullscreen(shsurf, !fullscreen, NULL);
|
2013-12-03 21:35:48 +04:00
|
|
|
|
}
|
|
|
|
|
|
2022-07-16 00:22:00 +03:00
|
|
|
|
static void
|
|
|
|
|
set_tiled_orientation(struct weston_surface *focus,
|
|
|
|
|
enum weston_top_level_tiled_orientation orientation)
|
|
|
|
|
{
|
|
|
|
|
struct weston_surface *surface;
|
|
|
|
|
struct shell_surface *shsurf;
|
|
|
|
|
int width, height;
|
|
|
|
|
pixman_rectangle32_t area;
|
|
|
|
|
struct weston_geometry geom;
|
|
|
|
|
int x, y;
|
|
|
|
|
|
|
|
|
|
surface = weston_surface_get_main_surface(focus);
|
|
|
|
|
if (surface == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
shsurf = get_shell_surface(surface);
|
|
|
|
|
if (shsurf == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
2022-07-29 17:04:32 +03:00
|
|
|
|
shsurf->orientation = orientation;
|
2022-07-16 00:22:00 +03:00
|
|
|
|
get_maximized_size(shsurf, &width, &height);
|
|
|
|
|
get_output_work_area(shsurf->shell, shsurf->output, &area);
|
|
|
|
|
geom = weston_desktop_surface_get_geometry(shsurf->desktop_surface);
|
|
|
|
|
|
|
|
|
|
if (orientation & WESTON_TOP_LEVEL_TILED_ORIENTATION_LEFT ||
|
|
|
|
|
orientation & WESTON_TOP_LEVEL_TILED_ORIENTATION_RIGHT)
|
|
|
|
|
width /= 2;
|
|
|
|
|
else if (orientation & WESTON_TOP_LEVEL_TILED_ORIENTATION_TOP ||
|
|
|
|
|
orientation & WESTON_TOP_LEVEL_TILED_ORIENTATION_BOTTOM)
|
|
|
|
|
height /= 2;
|
|
|
|
|
|
|
|
|
|
x = area.x - geom.x;
|
|
|
|
|
y = area.y - geom.y;
|
|
|
|
|
|
|
|
|
|
if (orientation & WESTON_TOP_LEVEL_TILED_ORIENTATION_RIGHT)
|
|
|
|
|
x += width;
|
|
|
|
|
else if (orientation & WESTON_TOP_LEVEL_TILED_ORIENTATION_BOTTOM)
|
|
|
|
|
y += height;
|
|
|
|
|
|
|
|
|
|
weston_view_set_position(shsurf->view, x, y);
|
|
|
|
|
weston_desktop_surface_set_size(shsurf->desktop_surface, width, height);
|
|
|
|
|
weston_desktop_surface_set_orientation(shsurf->desktop_surface, orientation);
|
|
|
|
|
weston_compositor_schedule_repaint(surface->compositor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
set_tiled_orientation_left(struct weston_keyboard *keyboard,
|
|
|
|
|
const struct timespec *time,
|
|
|
|
|
uint32_t button, void *data)
|
|
|
|
|
{
|
|
|
|
|
set_tiled_orientation(keyboard->focus, WESTON_TOP_LEVEL_TILED_ORIENTATION_LEFT);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
set_tiled_orientation_right(struct weston_keyboard *keyboard,
|
|
|
|
|
const struct timespec *time,
|
|
|
|
|
uint32_t button, void *data)
|
|
|
|
|
{
|
|
|
|
|
set_tiled_orientation(keyboard->focus, WESTON_TOP_LEVEL_TILED_ORIENTATION_RIGHT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
set_tiled_orientation_up(struct weston_keyboard *keyboard,
|
|
|
|
|
const struct timespec *time,
|
|
|
|
|
uint32_t button, void *data)
|
|
|
|
|
{
|
|
|
|
|
set_tiled_orientation(keyboard->focus, WESTON_TOP_LEVEL_TILED_ORIENTATION_TOP);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
set_tiled_orientation_down(struct weston_keyboard *keyboard,
|
|
|
|
|
const struct timespec *time,
|
|
|
|
|
uint32_t button, void *data)
|
|
|
|
|
{
|
|
|
|
|
set_tiled_orientation(keyboard->focus, WESTON_TOP_LEVEL_TILED_ORIENTATION_BOTTOM);
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-03 19:43:05 +04:00
|
|
|
|
static void
|
2017-11-16 19:20:58 +03:00
|
|
|
|
touch_move_binding(struct weston_touch *touch, const struct timespec *time, void *data)
|
2013-10-03 19:43:05 +04:00
|
|
|
|
{
|
2014-09-04 19:23:05 +04:00
|
|
|
|
struct weston_surface *focus;
|
2013-10-03 19:43:05 +04:00
|
|
|
|
struct weston_surface *surface;
|
|
|
|
|
struct shell_surface *shsurf;
|
|
|
|
|
|
2015-07-15 21:00:36 +03:00
|
|
|
|
if (touch->focus == NULL)
|
2014-09-04 19:23:05 +04:00
|
|
|
|
return;
|
|
|
|
|
|
2015-07-15 21:00:36 +03:00
|
|
|
|
focus = touch->focus->surface;
|
2013-10-03 19:43:05 +04:00
|
|
|
|
surface = weston_surface_get_main_surface(focus);
|
|
|
|
|
if (surface == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
shsurf = get_shell_surface(surface);
|
2016-08-12 11:41:36 +03:00
|
|
|
|
if (shsurf == NULL ||
|
|
|
|
|
weston_desktop_surface_get_fullscreen(shsurf->desktop_surface) ||
|
|
|
|
|
weston_desktop_surface_get_maximized(shsurf->desktop_surface))
|
2013-10-03 19:43:05 +04:00
|
|
|
|
return;
|
|
|
|
|
|
2015-07-15 21:00:37 +03:00
|
|
|
|
surface_touch_move(shsurf, touch);
|
2013-10-03 19:43:05 +04:00
|
|
|
|
}
|
|
|
|
|
|
2011-04-13 01:25:42 +04:00
|
|
|
|
static void
|
2017-11-16 19:20:55 +03:00
|
|
|
|
resize_binding(struct weston_pointer *pointer, const struct timespec *time,
|
2015-07-15 21:00:36 +03:00
|
|
|
|
uint32_t button, void *data)
|
2011-04-13 01:25:42 +04:00
|
|
|
|
{
|
2014-01-05 23:04:59 +04:00
|
|
|
|
struct weston_surface *focus;
|
shell: keyboard focus and restacking fixes for sub-surfaces
The shell needs to redirect some actions to the parent surface, when
they originally target a sub-surface. This patch implements the
following:
- Move, resize, and rotate bindings always target the parent surface.
- Opacity (full-surface alpha) binding targets the parent surface. This
is broken, because it should change the opacity of the whole compound
window, which is difficult to implement in the renderer.
- click_to_activate_binding() needs to check the shell surface type from
the main surface, because sub-surface would produce SHELL_SURFACE_NONE
and prevent activation.
- Also activate() needs to check the type from the main surface, and
restack the main surface. Keyboard focus is assigned to the original
(sub-)surface.
- focus_state_surface_destroy() needs to handle sub-surfaces: only the
main surface will be in a layer list. If the destroyed surface is
indeed a sub-surface, activate the main surface next. This way a
client that destroys a focused sub-surface still retains focus in the
same window.
- The workspace_manager.move_surface request can accept also
sub-surfaces, and it will move the corresponding main surface.
Changes in v2:
- do not special-case keyboard focus for sub-surfaces
- fix surface type checks for sub-surfaces in shell, fix restacking of
sub-surfaces in shell, fix focus_state_surface_destroy()
Changes in v3:
- Renamed weston_surface_get_parent() to
weston_surface_get_main_surface() to be more explicit that this is
about sub-surfaces
- Fixed move_surface_to_workspace() to handle keyboard focus on a
sub-surface.
- Used a temporary variable in several places to clarify code, instead
of reassigning a variable.
- Fixed workspace_manager_move_surface() to deal with sub-surfaces.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:44 +04:00
|
|
|
|
struct weston_surface *surface;
|
2011-04-13 01:25:42 +04:00
|
|
|
|
uint32_t edges = 0;
|
|
|
|
|
int32_t x, y;
|
2011-11-25 14:09:16 +04:00
|
|
|
|
struct shell_surface *shsurf;
|
2022-02-09 02:31:55 +03:00
|
|
|
|
struct weston_coord_surface surf_pos;
|
2011-11-23 19:52:40 +04:00
|
|
|
|
|
2015-07-15 21:00:36 +03:00
|
|
|
|
if (pointer->focus == NULL)
|
2014-01-05 23:04:59 +04:00
|
|
|
|
return;
|
|
|
|
|
|
2015-07-15 21:00:36 +03:00
|
|
|
|
focus = pointer->focus->surface;
|
2014-01-05 23:04:59 +04:00
|
|
|
|
|
shell: keyboard focus and restacking fixes for sub-surfaces
The shell needs to redirect some actions to the parent surface, when
they originally target a sub-surface. This patch implements the
following:
- Move, resize, and rotate bindings always target the parent surface.
- Opacity (full-surface alpha) binding targets the parent surface. This
is broken, because it should change the opacity of the whole compound
window, which is difficult to implement in the renderer.
- click_to_activate_binding() needs to check the shell surface type from
the main surface, because sub-surface would produce SHELL_SURFACE_NONE
and prevent activation.
- Also activate() needs to check the type from the main surface, and
restack the main surface. Keyboard focus is assigned to the original
(sub-)surface.
- focus_state_surface_destroy() needs to handle sub-surfaces: only the
main surface will be in a layer list. If the destroyed surface is
indeed a sub-surface, activate the main surface next. This way a
client that destroys a focused sub-surface still retains focus in the
same window.
- The workspace_manager.move_surface request can accept also
sub-surfaces, and it will move the corresponding main surface.
Changes in v2:
- do not special-case keyboard focus for sub-surfaces
- fix surface type checks for sub-surfaces in shell, fix restacking of
sub-surfaces in shell, fix focus_state_surface_destroy()
Changes in v3:
- Renamed weston_surface_get_parent() to
weston_surface_get_main_surface() to be more explicit that this is
about sub-surfaces
- Fixed move_surface_to_workspace() to handle keyboard focus on a
sub-surface.
- Used a temporary variable in several places to clarify code, instead
of reassigning a variable.
- Fixed workspace_manager_move_surface() to deal with sub-surfaces.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:44 +04:00
|
|
|
|
surface = weston_surface_get_main_surface(focus);
|
2011-11-22 15:43:52 +04:00
|
|
|
|
if (surface == NULL)
|
2011-09-06 21:48:16 +04:00
|
|
|
|
return;
|
2011-11-28 17:34:13 +04:00
|
|
|
|
|
2011-11-25 14:09:16 +04:00
|
|
|
|
shsurf = get_shell_surface(surface);
|
2016-08-12 11:41:36 +03:00
|
|
|
|
if (shsurf == NULL ||
|
|
|
|
|
weston_desktop_surface_get_fullscreen(shsurf->desktop_surface) ||
|
|
|
|
|
weston_desktop_surface_get_maximized(shsurf->desktop_surface))
|
2011-11-28 17:34:13 +04:00
|
|
|
|
return;
|
|
|
|
|
|
2022-02-04 01:40:10 +03:00
|
|
|
|
surf_pos = weston_coord_global_to_surface(shsurf->view, pointer->grab_pos);
|
2022-02-09 02:31:55 +03:00
|
|
|
|
x = surf_pos.c.x;
|
|
|
|
|
y = surf_pos.c.y;
|
2011-04-13 01:25:42 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
if (x < surface->width / 3)
|
2022-02-23 18:06:23 +03:00
|
|
|
|
edges |= WESTON_DESKTOP_SURFACE_EDGE_LEFT;
|
2016-08-12 11:41:36 +03:00
|
|
|
|
else if (x < 2 * surface->width / 3)
|
2011-04-13 01:25:42 +04:00
|
|
|
|
edges |= 0;
|
|
|
|
|
else
|
2022-02-23 18:06:23 +03:00
|
|
|
|
edges |= WESTON_DESKTOP_SURFACE_EDGE_RIGHT;
|
2011-04-13 01:25:42 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
if (y < surface->height / 3)
|
2022-02-23 18:06:23 +03:00
|
|
|
|
edges |= WESTON_DESKTOP_SURFACE_EDGE_TOP;
|
2016-08-12 11:41:36 +03:00
|
|
|
|
else if (y < 2 * surface->height / 3)
|
2011-04-13 01:25:42 +04:00
|
|
|
|
edges |= 0;
|
|
|
|
|
else
|
2022-02-23 18:06:23 +03:00
|
|
|
|
edges |= WESTON_DESKTOP_SURFACE_EDGE_BOTTOM;
|
2011-08-27 01:21:20 +04:00
|
|
|
|
|
2015-07-15 21:00:40 +03:00
|
|
|
|
surface_resize(shsurf, pointer, edges);
|
2011-04-23 21:04:11 +04:00
|
|
|
|
}
|
|
|
|
|
|
2012-03-22 21:01:03 +04:00
|
|
|
|
static void
|
2017-11-16 19:20:56 +03:00
|
|
|
|
surface_opacity_binding(struct weston_pointer *pointer,
|
|
|
|
|
const struct timespec *time,
|
2016-01-18 08:58:17 +03:00
|
|
|
|
struct weston_pointer_axis_event *event,
|
|
|
|
|
void *data)
|
2012-03-22 21:01:03 +04:00
|
|
|
|
{
|
2012-09-27 20:40:42 +04:00
|
|
|
|
float step = 0.005;
|
2012-03-22 21:01:03 +04:00
|
|
|
|
struct shell_surface *shsurf;
|
2015-07-15 21:00:36 +03:00
|
|
|
|
struct weston_surface *focus = pointer->focus->surface;
|
shell: keyboard focus and restacking fixes for sub-surfaces
The shell needs to redirect some actions to the parent surface, when
they originally target a sub-surface. This patch implements the
following:
- Move, resize, and rotate bindings always target the parent surface.
- Opacity (full-surface alpha) binding targets the parent surface. This
is broken, because it should change the opacity of the whole compound
window, which is difficult to implement in the renderer.
- click_to_activate_binding() needs to check the shell surface type from
the main surface, because sub-surface would produce SHELL_SURFACE_NONE
and prevent activation.
- Also activate() needs to check the type from the main surface, and
restack the main surface. Keyboard focus is assigned to the original
(sub-)surface.
- focus_state_surface_destroy() needs to handle sub-surfaces: only the
main surface will be in a layer list. If the destroyed surface is
indeed a sub-surface, activate the main surface next. This way a
client that destroys a focused sub-surface still retains focus in the
same window.
- The workspace_manager.move_surface request can accept also
sub-surfaces, and it will move the corresponding main surface.
Changes in v2:
- do not special-case keyboard focus for sub-surfaces
- fix surface type checks for sub-surfaces in shell, fix restacking of
sub-surfaces in shell, fix focus_state_surface_destroy()
Changes in v3:
- Renamed weston_surface_get_parent() to
weston_surface_get_main_surface() to be more explicit that this is
about sub-surfaces
- Fixed move_surface_to_workspace() to handle keyboard focus on a
sub-surface.
- Used a temporary variable in several places to clarify code, instead
of reassigning a variable.
- Fixed workspace_manager_move_surface() to deal with sub-surfaces.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:44 +04:00
|
|
|
|
struct weston_surface *surface;
|
2012-03-22 21:01:03 +04:00
|
|
|
|
|
shell: keyboard focus and restacking fixes for sub-surfaces
The shell needs to redirect some actions to the parent surface, when
they originally target a sub-surface. This patch implements the
following:
- Move, resize, and rotate bindings always target the parent surface.
- Opacity (full-surface alpha) binding targets the parent surface. This
is broken, because it should change the opacity of the whole compound
window, which is difficult to implement in the renderer.
- click_to_activate_binding() needs to check the shell surface type from
the main surface, because sub-surface would produce SHELL_SURFACE_NONE
and prevent activation.
- Also activate() needs to check the type from the main surface, and
restack the main surface. Keyboard focus is assigned to the original
(sub-)surface.
- focus_state_surface_destroy() needs to handle sub-surfaces: only the
main surface will be in a layer list. If the destroyed surface is
indeed a sub-surface, activate the main surface next. This way a
client that destroys a focused sub-surface still retains focus in the
same window.
- The workspace_manager.move_surface request can accept also
sub-surfaces, and it will move the corresponding main surface.
Changes in v2:
- do not special-case keyboard focus for sub-surfaces
- fix surface type checks for sub-surfaces in shell, fix restacking of
sub-surfaces in shell, fix focus_state_surface_destroy()
Changes in v3:
- Renamed weston_surface_get_parent() to
weston_surface_get_main_surface() to be more explicit that this is
about sub-surfaces
- Fixed move_surface_to_workspace() to handle keyboard focus on a
sub-surface.
- Used a temporary variable in several places to clarify code, instead
of reassigning a variable.
- Fixed workspace_manager_move_surface() to deal with sub-surfaces.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:44 +04:00
|
|
|
|
/* XXX: broken for windows containing sub-surfaces */
|
|
|
|
|
surface = weston_surface_get_main_surface(focus);
|
2012-03-22 21:01:03 +04:00
|
|
|
|
if (surface == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
shsurf = get_shell_surface(surface);
|
|
|
|
|
if (!shsurf)
|
|
|
|
|
return;
|
|
|
|
|
|
2016-03-22 18:44:54 +03:00
|
|
|
|
shsurf->view->alpha -= event->value * step;
|
2012-03-22 21:01:03 +04:00
|
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
if (shsurf->view->alpha > 1.0)
|
|
|
|
|
shsurf->view->alpha = 1.0;
|
|
|
|
|
if (shsurf->view->alpha < step)
|
|
|
|
|
shsurf->view->alpha = step;
|
2012-03-22 21:01:03 +04:00
|
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
weston_view_geometry_dirty(shsurf->view);
|
2012-03-22 21:01:03 +04:00
|
|
|
|
weston_surface_damage(surface);
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-30 19:31:58 +04:00
|
|
|
|
static void
|
2017-11-16 19:20:57 +03:00
|
|
|
|
terminate_binding(struct weston_keyboard *keyboard, const struct timespec *time,
|
2015-07-15 21:00:36 +03:00
|
|
|
|
uint32_t key, void *data)
|
2011-12-20 00:18:05 +04:00
|
|
|
|
{
|
Rename wayland-compositor to weston
This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.
1) Initially, we had one big repository with protocol code, sample
compositor and sample clients. We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code. At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message. The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.
2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor. Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example. Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.
We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
2012-01-03 19:29:47 +04:00
|
|
|
|
struct weston_compositor *compositor = data;
|
2011-12-20 00:18:05 +04:00
|
|
|
|
|
2019-02-06 11:44:37 +03:00
|
|
|
|
weston_compositor_exit(compositor);
|
2011-12-20 00:18:05 +04:00
|
|
|
|
}
|
|
|
|
|
|
2012-01-20 18:48:25 +04:00
|
|
|
|
static void
|
2017-11-24 19:01:46 +03:00
|
|
|
|
rotate_grab_motion(struct weston_pointer_grab *grab,
|
|
|
|
|
const struct timespec *time,
|
2014-10-05 23:39:14 +04:00
|
|
|
|
struct weston_pointer_motion_event *event)
|
2012-01-20 18:48:25 +04:00
|
|
|
|
{
|
|
|
|
|
struct rotate_grab *rotate =
|
2012-04-04 18:48:05 +04:00
|
|
|
|
container_of(grab, struct rotate_grab, base.grab);
|
2013-05-07 06:15:05 +04:00
|
|
|
|
struct weston_pointer *pointer = grab->pointer;
|
2012-04-04 18:48:05 +04:00
|
|
|
|
struct shell_surface *shsurf = rotate->base.shsurf;
|
2019-02-11 22:55:09 +03:00
|
|
|
|
struct weston_surface *surface;
|
2012-09-30 04:57:21 +04:00
|
|
|
|
float cx, cy, dx, dy, cposx, cposy, dposx, dposy, r;
|
2012-04-04 18:48:05 +04:00
|
|
|
|
|
2014-10-05 23:39:14 +04:00
|
|
|
|
weston_pointer_move(pointer, event);
|
2013-11-15 02:42:52 +04:00
|
|
|
|
|
2012-04-04 18:48:05 +04:00
|
|
|
|
if (!shsurf)
|
|
|
|
|
return;
|
|
|
|
|
|
2019-02-11 22:55:09 +03:00
|
|
|
|
surface = weston_desktop_surface_get_surface(shsurf->desktop_surface);
|
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
cx = 0.5f * surface->width;
|
|
|
|
|
cy = 0.5f * surface->height;
|
2012-01-20 18:48:25 +04:00
|
|
|
|
|
2022-02-04 01:40:10 +03:00
|
|
|
|
dx = pointer->pos.c.x - rotate->center.x;
|
|
|
|
|
dy = pointer->pos.c.y - rotate->center.y;
|
2012-01-20 18:48:25 +04:00
|
|
|
|
r = sqrtf(dx * dx + dy * dy);
|
|
|
|
|
|
2012-04-04 18:48:05 +04:00
|
|
|
|
wl_list_remove(&shsurf->rotation.transform.link);
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
weston_view_geometry_dirty(shsurf->view);
|
2012-01-20 18:48:25 +04:00
|
|
|
|
|
|
|
|
|
if (r > 20.0f) {
|
|
|
|
|
struct weston_matrix *matrix =
|
2012-04-04 18:48:05 +04:00
|
|
|
|
&shsurf->rotation.transform.matrix;
|
2012-01-20 18:48:25 +04:00
|
|
|
|
|
2012-01-27 22:36:13 +04:00
|
|
|
|
weston_matrix_init(&rotate->rotation);
|
2013-01-28 23:40:28 +04:00
|
|
|
|
weston_matrix_rotate_xy(&rotate->rotation, dx / r, dy / r);
|
2012-01-20 18:48:25 +04:00
|
|
|
|
|
|
|
|
|
weston_matrix_init(matrix);
|
2012-01-30 16:16:34 +04:00
|
|
|
|
weston_matrix_translate(matrix, -cx, -cy, 0.0f);
|
2012-04-04 18:48:05 +04:00
|
|
|
|
weston_matrix_multiply(matrix, &shsurf->rotation.rotation);
|
2012-01-27 22:36:13 +04:00
|
|
|
|
weston_matrix_multiply(matrix, &rotate->rotation);
|
2012-01-30 16:16:34 +04:00
|
|
|
|
weston_matrix_translate(matrix, cx, cy, 0.0f);
|
2012-01-20 18:48:25 +04:00
|
|
|
|
|
2012-01-24 11:53:37 +04:00
|
|
|
|
wl_list_insert(
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
&shsurf->view->geometry.transformation_list,
|
2012-04-04 18:48:05 +04:00
|
|
|
|
&shsurf->rotation.transform.link);
|
2012-01-20 18:48:25 +04:00
|
|
|
|
} else {
|
2012-04-04 18:48:05 +04:00
|
|
|
|
wl_list_init(&shsurf->rotation.transform.link);
|
|
|
|
|
weston_matrix_init(&shsurf->rotation.rotation);
|
2012-01-27 22:36:13 +04:00
|
|
|
|
weston_matrix_init(&rotate->rotation);
|
2012-01-20 18:48:25 +04:00
|
|
|
|
}
|
2012-02-09 17:58:44 +04:00
|
|
|
|
|
2012-03-23 01:22:04 +04:00
|
|
|
|
/* We need to adjust the position of the surface
|
|
|
|
|
* in case it was resized in a rotated state before */
|
2022-02-04 02:47:41 +03:00
|
|
|
|
cposx = shsurf->view->geometry.pos_offset.x + cx;
|
|
|
|
|
cposy = shsurf->view->geometry.pos_offset.y + cy;
|
2012-03-23 01:22:04 +04:00
|
|
|
|
dposx = rotate->center.x - cposx;
|
|
|
|
|
dposy = rotate->center.y - cposy;
|
|
|
|
|
if (dposx != 0.0f || dposy != 0.0f) {
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
weston_view_set_position(shsurf->view,
|
2022-02-04 02:47:41 +03:00
|
|
|
|
shsurf->view->geometry.pos_offset.x + dposx,
|
|
|
|
|
shsurf->view->geometry.pos_offset.y + dposy);
|
2012-03-23 01:22:04 +04:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-11 00:37:33 +04:00
|
|
|
|
/* Repaint implies weston_view_update_transform(), which
|
2012-02-09 17:58:44 +04:00
|
|
|
|
* lazily applies the damage due to rotation update.
|
|
|
|
|
*/
|
2016-08-12 11:41:36 +03:00
|
|
|
|
weston_compositor_schedule_repaint(surface->compositor);
|
2012-01-20 18:48:25 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2013-05-07 06:15:05 +04:00
|
|
|
|
rotate_grab_button(struct weston_pointer_grab *grab,
|
2017-11-16 19:20:55 +03:00
|
|
|
|
const struct timespec *time,
|
|
|
|
|
uint32_t button, uint32_t state_w)
|
2012-01-20 18:48:25 +04:00
|
|
|
|
{
|
|
|
|
|
struct rotate_grab *rotate =
|
2012-04-04 18:48:05 +04:00
|
|
|
|
container_of(grab, struct rotate_grab, base.grab);
|
2013-05-07 06:15:05 +04:00
|
|
|
|
struct weston_pointer *pointer = grab->pointer;
|
2012-04-04 18:48:05 +04:00
|
|
|
|
struct shell_surface *shsurf = rotate->base.shsurf;
|
2012-05-30 19:31:51 +04:00
|
|
|
|
enum wl_pointer_button_state state = state_w;
|
2012-01-20 18:48:25 +04:00
|
|
|
|
|
2012-05-30 19:31:51 +04:00
|
|
|
|
if (pointer->button_count == 0 &&
|
|
|
|
|
state == WL_POINTER_BUTTON_STATE_RELEASED) {
|
2012-04-04 18:48:05 +04:00
|
|
|
|
if (shsurf)
|
|
|
|
|
weston_matrix_multiply(&shsurf->rotation.rotation,
|
|
|
|
|
&rotate->rotation);
|
2012-06-28 19:08:05 +04:00
|
|
|
|
shell_grab_end(&rotate->base);
|
2012-01-20 18:48:25 +04:00
|
|
|
|
free(rotate);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-26 01:18:05 +04:00
|
|
|
|
static void
|
|
|
|
|
rotate_grab_cancel(struct weston_pointer_grab *grab)
|
|
|
|
|
{
|
|
|
|
|
struct rotate_grab *rotate =
|
|
|
|
|
container_of(grab, struct rotate_grab, base.grab);
|
|
|
|
|
|
|
|
|
|
shell_grab_end(&rotate->base);
|
|
|
|
|
free(rotate);
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-07 06:15:05 +04:00
|
|
|
|
static const struct weston_pointer_grab_interface rotate_grab_interface = {
|
2012-01-20 18:48:25 +04:00
|
|
|
|
noop_grab_focus,
|
|
|
|
|
rotate_grab_motion,
|
|
|
|
|
rotate_grab_button,
|
2014-10-04 18:28:29 +04:00
|
|
|
|
noop_grab_axis,
|
2016-01-18 09:38:22 +03:00
|
|
|
|
noop_grab_axis_source,
|
|
|
|
|
noop_grab_frame,
|
2013-10-26 01:18:05 +04:00
|
|
|
|
rotate_grab_cancel,
|
2012-01-20 18:48:25 +04:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void
|
2016-08-12 11:41:36 +03:00
|
|
|
|
surface_rotate(struct shell_surface *shsurf, struct weston_pointer *pointer)
|
2012-01-20 18:48:25 +04:00
|
|
|
|
{
|
2016-08-12 11:41:36 +03:00
|
|
|
|
struct weston_surface *surface =
|
|
|
|
|
weston_desktop_surface_get_surface(shsurf->desktop_surface);
|
2012-01-20 18:48:25 +04:00
|
|
|
|
struct rotate_grab *rotate;
|
2022-02-09 02:31:55 +03:00
|
|
|
|
struct weston_coord_surface center;
|
|
|
|
|
struct weston_coord_global center_g;
|
2012-09-30 04:57:21 +04:00
|
|
|
|
float dx, dy;
|
|
|
|
|
float r;
|
2012-01-20 18:48:25 +04:00
|
|
|
|
|
|
|
|
|
rotate = malloc(sizeof *rotate);
|
|
|
|
|
if (!rotate)
|
|
|
|
|
return;
|
|
|
|
|
|
2022-02-09 02:31:55 +03:00
|
|
|
|
center = weston_coord_surface(surface->width * 0.5f,
|
|
|
|
|
surface->height * 0.5f,
|
|
|
|
|
shsurf->view->surface);
|
|
|
|
|
center_g = weston_coord_surface_to_global(shsurf->view, center);
|
|
|
|
|
|
|
|
|
|
rotate->center.x = center_g.c.x;
|
|
|
|
|
rotate->center.y = center_g.c.y;
|
2012-01-20 18:48:25 +04:00
|
|
|
|
|
2022-02-04 01:40:10 +03:00
|
|
|
|
dx = pointer->pos.c.x - rotate->center.x;
|
|
|
|
|
dy = pointer->pos.c.y - rotate->center.y;
|
2012-01-27 22:36:13 +04:00
|
|
|
|
r = sqrtf(dx * dx + dy * dy);
|
|
|
|
|
if (r > 20.0f) {
|
|
|
|
|
struct weston_matrix inverse;
|
|
|
|
|
|
|
|
|
|
weston_matrix_init(&inverse);
|
2013-01-28 23:40:28 +04:00
|
|
|
|
weston_matrix_rotate_xy(&inverse, dx / r, -dy / r);
|
2016-08-12 11:41:36 +03:00
|
|
|
|
weston_matrix_multiply(&shsurf->rotation.rotation, &inverse);
|
2012-03-23 01:22:04 +04:00
|
|
|
|
|
|
|
|
|
weston_matrix_init(&rotate->rotation);
|
2013-01-28 23:40:28 +04:00
|
|
|
|
weston_matrix_rotate_xy(&rotate->rotation, dx / r, dy / r);
|
2012-01-27 22:36:13 +04:00
|
|
|
|
} else {
|
2016-08-12 11:41:36 +03:00
|
|
|
|
weston_matrix_init(&shsurf->rotation.rotation);
|
2012-01-27 22:36:13 +04:00
|
|
|
|
weston_matrix_init(&rotate->rotation);
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
shell_grab_start(&rotate->base, &rotate_grab_interface, shsurf,
|
2015-11-17 11:00:33 +03:00
|
|
|
|
pointer, WESTON_DESKTOP_SHELL_CURSOR_ARROW);
|
2012-01-20 18:48:25 +04:00
|
|
|
|
}
|
|
|
|
|
|
2013-02-15 06:31:44 +04:00
|
|
|
|
static void
|
2017-11-16 19:20:55 +03:00
|
|
|
|
rotate_binding(struct weston_pointer *pointer, const struct timespec *time,
|
|
|
|
|
uint32_t button, void *data)
|
2013-02-15 06:31:44 +04:00
|
|
|
|
{
|
2014-01-05 23:04:59 +04:00
|
|
|
|
struct weston_surface *focus;
|
shell: keyboard focus and restacking fixes for sub-surfaces
The shell needs to redirect some actions to the parent surface, when
they originally target a sub-surface. This patch implements the
following:
- Move, resize, and rotate bindings always target the parent surface.
- Opacity (full-surface alpha) binding targets the parent surface. This
is broken, because it should change the opacity of the whole compound
window, which is difficult to implement in the renderer.
- click_to_activate_binding() needs to check the shell surface type from
the main surface, because sub-surface would produce SHELL_SURFACE_NONE
and prevent activation.
- Also activate() needs to check the type from the main surface, and
restack the main surface. Keyboard focus is assigned to the original
(sub-)surface.
- focus_state_surface_destroy() needs to handle sub-surfaces: only the
main surface will be in a layer list. If the destroyed surface is
indeed a sub-surface, activate the main surface next. This way a
client that destroys a focused sub-surface still retains focus in the
same window.
- The workspace_manager.move_surface request can accept also
sub-surfaces, and it will move the corresponding main surface.
Changes in v2:
- do not special-case keyboard focus for sub-surfaces
- fix surface type checks for sub-surfaces in shell, fix restacking of
sub-surfaces in shell, fix focus_state_surface_destroy()
Changes in v3:
- Renamed weston_surface_get_parent() to
weston_surface_get_main_surface() to be more explicit that this is
about sub-surfaces
- Fixed move_surface_to_workspace() to handle keyboard focus on a
sub-surface.
- Used a temporary variable in several places to clarify code, instead
of reassigning a variable.
- Fixed workspace_manager_move_surface() to deal with sub-surfaces.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:44 +04:00
|
|
|
|
struct weston_surface *base_surface;
|
2013-02-15 06:31:44 +04:00
|
|
|
|
struct shell_surface *surface;
|
|
|
|
|
|
2015-07-15 21:00:36 +03:00
|
|
|
|
if (pointer->focus == NULL)
|
2014-01-05 23:04:59 +04:00
|
|
|
|
return;
|
|
|
|
|
|
2015-07-15 21:00:36 +03:00
|
|
|
|
focus = pointer->focus->surface;
|
2014-01-05 23:04:59 +04:00
|
|
|
|
|
shell: keyboard focus and restacking fixes for sub-surfaces
The shell needs to redirect some actions to the parent surface, when
they originally target a sub-surface. This patch implements the
following:
- Move, resize, and rotate bindings always target the parent surface.
- Opacity (full-surface alpha) binding targets the parent surface. This
is broken, because it should change the opacity of the whole compound
window, which is difficult to implement in the renderer.
- click_to_activate_binding() needs to check the shell surface type from
the main surface, because sub-surface would produce SHELL_SURFACE_NONE
and prevent activation.
- Also activate() needs to check the type from the main surface, and
restack the main surface. Keyboard focus is assigned to the original
(sub-)surface.
- focus_state_surface_destroy() needs to handle sub-surfaces: only the
main surface will be in a layer list. If the destroyed surface is
indeed a sub-surface, activate the main surface next. This way a
client that destroys a focused sub-surface still retains focus in the
same window.
- The workspace_manager.move_surface request can accept also
sub-surfaces, and it will move the corresponding main surface.
Changes in v2:
- do not special-case keyboard focus for sub-surfaces
- fix surface type checks for sub-surfaces in shell, fix restacking of
sub-surfaces in shell, fix focus_state_surface_destroy()
Changes in v3:
- Renamed weston_surface_get_parent() to
weston_surface_get_main_surface() to be more explicit that this is
about sub-surfaces
- Fixed move_surface_to_workspace() to handle keyboard focus on a
sub-surface.
- Used a temporary variable in several places to clarify code, instead
of reassigning a variable.
- Fixed workspace_manager_move_surface() to deal with sub-surfaces.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:44 +04:00
|
|
|
|
base_surface = weston_surface_get_main_surface(focus);
|
2013-02-15 06:31:44 +04:00
|
|
|
|
if (base_surface == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
surface = get_shell_surface(base_surface);
|
2016-08-12 11:41:36 +03:00
|
|
|
|
if (surface == NULL ||
|
|
|
|
|
weston_desktop_surface_get_fullscreen(surface->desktop_surface) ||
|
|
|
|
|
weston_desktop_surface_get_maximized(surface->desktop_surface))
|
2013-02-15 06:31:44 +04:00
|
|
|
|
return;
|
|
|
|
|
|
2015-07-15 21:00:39 +03:00
|
|
|
|
surface_rotate(surface, pointer);
|
2013-02-15 06:31:44 +04:00
|
|
|
|
}
|
|
|
|
|
|
2014-01-30 17:01:10 +04:00
|
|
|
|
/* Move all fullscreen layers down to the current workspace and hide their
|
|
|
|
|
* black views. The surfaces' state is set to both fullscreen and lowered,
|
|
|
|
|
* and this is reversed when such a surface is re-configured, see
|
|
|
|
|
* shell_configure_fullscreen() and shell_ensure_fullscreen_black_view().
|
|
|
|
|
*
|
2015-06-21 22:25:08 +03:00
|
|
|
|
* lowering_output = NULL - Lower on all outputs, else only lower on the
|
|
|
|
|
* specified output.
|
|
|
|
|
*
|
2014-01-30 17:01:10 +04:00
|
|
|
|
* This should be used when implementing shell-wide overlays, such as
|
2013-11-25 22:01:42 +04:00
|
|
|
|
* the alt-tab switcher, which need to de-promote fullscreen layers. */
|
2013-12-04 12:20:01 +04:00
|
|
|
|
void
|
2015-06-21 22:25:08 +03:00
|
|
|
|
lower_fullscreen_layer(struct desktop_shell *shell,
|
2016-08-12 11:41:36 +03:00
|
|
|
|
struct weston_output *lowering_output)
|
2012-06-19 00:34:58 +04:00
|
|
|
|
{
|
|
|
|
|
struct workspace *ws;
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
struct weston_view *view, *prev;
|
2012-06-19 00:34:58 +04:00
|
|
|
|
|
|
|
|
|
ws = get_current_workspace(shell);
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
wl_list_for_each_reverse_safe(view, prev,
|
2014-07-09 23:12:56 +04:00
|
|
|
|
&shell->fullscreen_layer.view_list.link,
|
|
|
|
|
layer_link.link) {
|
2014-01-30 17:01:10 +04:00
|
|
|
|
struct shell_surface *shsurf = get_shell_surface(view->surface);
|
|
|
|
|
|
|
|
|
|
if (!shsurf)
|
|
|
|
|
continue;
|
|
|
|
|
|
2015-06-21 22:25:08 +03:00
|
|
|
|
/* Only lower surfaces which have lowering_output as their fullscreen
|
|
|
|
|
* output, unless a NULL output asks for lowering on all outputs.
|
|
|
|
|
*/
|
|
|
|
|
if (lowering_output && (shsurf->fullscreen_output != lowering_output))
|
|
|
|
|
continue;
|
|
|
|
|
|
2014-01-30 17:01:10 +04:00
|
|
|
|
/* We can have a non-fullscreen popup for a fullscreen surface
|
|
|
|
|
* in the fullscreen layer. */
|
2023-05-02 19:45:25 +03:00
|
|
|
|
if (weston_desktop_surface_get_fullscreen(shsurf->desktop_surface) &&
|
|
|
|
|
shsurf->fullscreen.black_view) {
|
2014-01-30 17:01:10 +04:00
|
|
|
|
/* Hide the black view */
|
2022-01-17 17:24:03 +03:00
|
|
|
|
weston_layer_entry_remove(&shsurf->fullscreen.black_view->view->layer_link);
|
|
|
|
|
wl_list_init(&shsurf->fullscreen.black_view->view->layer_link.link);
|
|
|
|
|
weston_view_damage_below(shsurf->fullscreen.black_view->view);
|
2014-01-30 17:01:10 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Lower the view to the workspace layer */
|
2014-07-09 23:12:56 +04:00
|
|
|
|
weston_layer_entry_remove(&view->layer_link);
|
|
|
|
|
weston_layer_entry_insert(&ws->layer.view_list, &view->layer_link);
|
2013-11-25 22:01:42 +04:00
|
|
|
|
weston_view_damage_below(view);
|
|
|
|
|
weston_surface_damage(view->surface);
|
2014-01-30 17:01:10 +04:00
|
|
|
|
|
|
|
|
|
shsurf->state.lowered = true;
|
2013-11-25 22:01:42 +04:00
|
|
|
|
}
|
2012-06-19 00:34:58 +04:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-23 15:53:59 +03:00
|
|
|
|
static struct shell_surface *get_last_child(struct shell_surface *shsurf)
|
|
|
|
|
{
|
|
|
|
|
struct shell_surface *shsurf_child;
|
|
|
|
|
|
|
|
|
|
wl_list_for_each_reverse(shsurf_child, &shsurf->children_list, children_link) {
|
|
|
|
|
if (weston_view_is_mapped(shsurf_child->view))
|
|
|
|
|
return shsurf_child;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-04 12:20:01 +04:00
|
|
|
|
void
|
2014-10-18 15:24:53 +04:00
|
|
|
|
activate(struct desktop_shell *shell, struct weston_view *view,
|
2014-10-18 20:20:16 +04:00
|
|
|
|
struct weston_seat *seat, uint32_t flags)
|
2011-09-06 21:48:16 +04:00
|
|
|
|
{
|
2014-10-18 15:24:53 +04:00
|
|
|
|
struct weston_surface *es = view->surface;
|
shell: keyboard focus and restacking fixes for sub-surfaces
The shell needs to redirect some actions to the parent surface, when
they originally target a sub-surface. This patch implements the
following:
- Move, resize, and rotate bindings always target the parent surface.
- Opacity (full-surface alpha) binding targets the parent surface. This
is broken, because it should change the opacity of the whole compound
window, which is difficult to implement in the renderer.
- click_to_activate_binding() needs to check the shell surface type from
the main surface, because sub-surface would produce SHELL_SURFACE_NONE
and prevent activation.
- Also activate() needs to check the type from the main surface, and
restack the main surface. Keyboard focus is assigned to the original
(sub-)surface.
- focus_state_surface_destroy() needs to handle sub-surfaces: only the
main surface will be in a layer list. If the destroyed surface is
indeed a sub-surface, activate the main surface next. This way a
client that destroys a focused sub-surface still retains focus in the
same window.
- The workspace_manager.move_surface request can accept also
sub-surfaces, and it will move the corresponding main surface.
Changes in v2:
- do not special-case keyboard focus for sub-surfaces
- fix surface type checks for sub-surfaces in shell, fix restacking of
sub-surfaces in shell, fix focus_state_surface_destroy()
Changes in v3:
- Renamed weston_surface_get_parent() to
weston_surface_get_main_surface() to be more explicit that this is
about sub-surfaces
- Fixed move_surface_to_workspace() to handle keyboard focus on a
sub-surface.
- Used a temporary variable in several places to clarify code, instead
of reassigning a variable.
- Fixed workspace_manager_move_surface() to deal with sub-surfaces.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:44 +04:00
|
|
|
|
struct weston_surface *main_surface;
|
2012-08-01 00:36:34 +04:00
|
|
|
|
struct focus_state *state;
|
2012-08-30 00:13:03 +04:00
|
|
|
|
struct workspace *ws;
|
animation, shell: add kbd focus change animation
When enabled, this will make all but the keyboard-focused window dim.
Also the background gets dimmed, if there are any windows open. The
panel is not dimmed.
When the keyboard focus changes, the change in dimming is animated.
The dimming is implemented with transparent solid-color surfaces, two at
most. The net effect of two overlapping dim surfaces is kept constant
during animations (stable fade animation).
There is a new weston.ini option "focus-animation", that defaults to
none, and can be set to "dim-layer" to enable the focus change
animation.
[pq: Sliced, squashed, and rebased the patch series. Fixed surface alpha
interaction with the switcher. Wrote the commit message.]
[pochu: rebased, ported to weston_view]
2013-11-19 14:37:11 +04:00
|
|
|
|
struct weston_surface *old_es;
|
2019-06-23 15:53:59 +03:00
|
|
|
|
struct shell_surface *shsurf, *shsurf_child;
|
2021-03-05 22:44:26 +03:00
|
|
|
|
struct shell_seat *shseat = get_shell_seat(seat);
|
2011-09-06 21:48:16 +04:00
|
|
|
|
|
shell: keyboard focus and restacking fixes for sub-surfaces
The shell needs to redirect some actions to the parent surface, when
they originally target a sub-surface. This patch implements the
following:
- Move, resize, and rotate bindings always target the parent surface.
- Opacity (full-surface alpha) binding targets the parent surface. This
is broken, because it should change the opacity of the whole compound
window, which is difficult to implement in the renderer.
- click_to_activate_binding() needs to check the shell surface type from
the main surface, because sub-surface would produce SHELL_SURFACE_NONE
and prevent activation.
- Also activate() needs to check the type from the main surface, and
restack the main surface. Keyboard focus is assigned to the original
(sub-)surface.
- focus_state_surface_destroy() needs to handle sub-surfaces: only the
main surface will be in a layer list. If the destroyed surface is
indeed a sub-surface, activate the main surface next. This way a
client that destroys a focused sub-surface still retains focus in the
same window.
- The workspace_manager.move_surface request can accept also
sub-surfaces, and it will move the corresponding main surface.
Changes in v2:
- do not special-case keyboard focus for sub-surfaces
- fix surface type checks for sub-surfaces in shell, fix restacking of
sub-surfaces in shell, fix focus_state_surface_destroy()
Changes in v3:
- Renamed weston_surface_get_parent() to
weston_surface_get_main_surface() to be more explicit that this is
about sub-surfaces
- Fixed move_surface_to_workspace() to handle keyboard focus on a
sub-surface.
- Used a temporary variable in several places to clarify code, instead
of reassigning a variable.
- Fixed workspace_manager_move_surface() to deal with sub-surfaces.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:44 +04:00
|
|
|
|
main_surface = weston_surface_get_main_surface(es);
|
2015-06-21 22:25:08 +03:00
|
|
|
|
shsurf = get_shell_surface(main_surface);
|
|
|
|
|
assert(shsurf);
|
|
|
|
|
|
2019-06-23 15:53:59 +03:00
|
|
|
|
shsurf_child = get_last_child(shsurf);
|
|
|
|
|
if (shsurf_child) {
|
|
|
|
|
/* Activate last xdg child instead of parent. */
|
|
|
|
|
activate(shell, shsurf_child->view, seat, flags);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-21 22:25:08 +03:00
|
|
|
|
/* Only demote fullscreen surfaces on the output of activated shsurf.
|
|
|
|
|
* Leave fullscreen surfaces on unrelated outputs alone. */
|
2018-05-02 11:21:57 +03:00
|
|
|
|
if (shsurf->output)
|
|
|
|
|
lower_fullscreen_layer(shell, shsurf->output);
|
shell: keyboard focus and restacking fixes for sub-surfaces
The shell needs to redirect some actions to the parent surface, when
they originally target a sub-surface. This patch implements the
following:
- Move, resize, and rotate bindings always target the parent surface.
- Opacity (full-surface alpha) binding targets the parent surface. This
is broken, because it should change the opacity of the whole compound
window, which is difficult to implement in the renderer.
- click_to_activate_binding() needs to check the shell surface type from
the main surface, because sub-surface would produce SHELL_SURFACE_NONE
and prevent activation.
- Also activate() needs to check the type from the main surface, and
restack the main surface. Keyboard focus is assigned to the original
(sub-)surface.
- focus_state_surface_destroy() needs to handle sub-surfaces: only the
main surface will be in a layer list. If the destroyed surface is
indeed a sub-surface, activate the main surface next. This way a
client that destroys a focused sub-surface still retains focus in the
same window.
- The workspace_manager.move_surface request can accept also
sub-surfaces, and it will move the corresponding main surface.
Changes in v2:
- do not special-case keyboard focus for sub-surfaces
- fix surface type checks for sub-surfaces in shell, fix restacking of
sub-surfaces in shell, fix focus_state_surface_destroy()
Changes in v3:
- Renamed weston_surface_get_parent() to
weston_surface_get_main_surface() to be more explicit that this is
about sub-surfaces
- Fixed move_surface_to_workspace() to handle keyboard focus on a
sub-surface.
- Used a temporary variable in several places to clarify code, instead
of reassigning a variable.
- Fixed workspace_manager_move_surface() to deal with sub-surfaces.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:44 +04:00
|
|
|
|
|
2021-03-05 23:07:30 +03:00
|
|
|
|
weston_view_activate_input(view, seat, flags);
|
2011-09-06 21:48:16 +04:00
|
|
|
|
|
2022-03-18 12:42:17 +03:00
|
|
|
|
if (shseat && shseat->focused_surface &&
|
|
|
|
|
shseat->focused_surface != main_surface) {
|
2021-03-05 22:44:26 +03:00
|
|
|
|
struct shell_surface *current_focus =
|
|
|
|
|
get_shell_surface(shseat->focused_surface);
|
|
|
|
|
assert(current_focus);
|
|
|
|
|
shell_surface_deactivate(current_focus);
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-18 12:42:17 +03:00
|
|
|
|
if (shseat && shseat->focused_surface != main_surface) {
|
|
|
|
|
shell_surface_activate(shsurf);
|
2021-11-20 20:14:45 +03:00
|
|
|
|
shseat->focused_surface = main_surface;
|
2022-03-18 12:42:17 +03:00
|
|
|
|
}
|
2021-03-05 22:44:26 +03:00
|
|
|
|
|
2012-08-30 00:13:03 +04:00
|
|
|
|
state = ensure_focus_state(shell, seat);
|
|
|
|
|
if (state == NULL)
|
|
|
|
|
return;
|
2012-08-01 00:36:34 +04:00
|
|
|
|
|
animation, shell: add kbd focus change animation
When enabled, this will make all but the keyboard-focused window dim.
Also the background gets dimmed, if there are any windows open. The
panel is not dimmed.
When the keyboard focus changes, the change in dimming is animated.
The dimming is implemented with transparent solid-color surfaces, two at
most. The net effect of two overlapping dim surfaces is kept constant
during animations (stable fade animation).
There is a new weston.ini option "focus-animation", that defaults to
none, and can be set to "dim-layer" to enable the focus change
animation.
[pq: Sliced, squashed, and rebased the patch series. Fixed surface alpha
interaction with the switcher. Wrote the commit message.]
[pochu: rebased, ported to weston_view]
2013-11-19 14:37:11 +04:00
|
|
|
|
old_es = state->keyboard_focus;
|
2014-01-23 00:25:20 +04:00
|
|
|
|
focus_state_set_focus(state, es);
|
2012-08-01 00:36:34 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
if (weston_desktop_surface_get_fullscreen(shsurf->desktop_surface) &&
|
|
|
|
|
flags & WESTON_ACTIVATE_FLAG_CONFIGURE)
|
2013-12-03 21:35:42 +04:00
|
|
|
|
shell_configure_fullscreen(shsurf);
|
animation, shell: add kbd focus change animation
When enabled, this will make all but the keyboard-focused window dim.
Also the background gets dimmed, if there are any windows open. The
panel is not dimmed.
When the keyboard focus changes, the change in dimming is animated.
The dimming is implemented with transparent solid-color surfaces, two at
most. The net effect of two overlapping dim surfaces is kept constant
during animations (stable fade animation).
There is a new weston.ini option "focus-animation", that defaults to
none, and can be set to "dim-layer" to enable the focus change
animation.
[pq: Sliced, squashed, and rebased the patch series. Fixed surface alpha
interaction with the switcher. Wrote the commit message.]
[pochu: rebased, ported to weston_view]
2013-11-19 14:37:11 +04:00
|
|
|
|
|
2014-01-30 16:49:39 +04:00
|
|
|
|
/* Update the surface’s layer. This brings it to the top of the stacking
|
|
|
|
|
* order as appropriate. */
|
|
|
|
|
shell_surface_update_layer(shsurf);
|
|
|
|
|
|
2013-11-25 22:01:42 +04:00
|
|
|
|
if (shell->focus_animation_type != ANIMATION_NONE) {
|
|
|
|
|
ws = get_current_workspace(shell);
|
animation, shell: add kbd focus change animation
When enabled, this will make all but the keyboard-focused window dim.
Also the background gets dimmed, if there are any windows open. The
panel is not dimmed.
When the keyboard focus changes, the change in dimming is animated.
The dimming is implemented with transparent solid-color surfaces, two at
most. The net effect of two overlapping dim surfaces is kept constant
during animations (stable fade animation).
There is a new weston.ini option "focus-animation", that defaults to
none, and can be set to "dim-layer" to enable the focus change
animation.
[pq: Sliced, squashed, and rebased the patch series. Fixed surface alpha
interaction with the switcher. Wrote the commit message.]
[pochu: rebased, ported to weston_view]
2013-11-19 14:37:11 +04:00
|
|
|
|
animate_focus_change(shell, ws, get_default_view(old_es), get_default_view(es));
|
2013-11-25 22:01:42 +04:00
|
|
|
|
}
|
2011-09-06 21:48:16 +04:00
|
|
|
|
}
|
|
|
|
|
|
2011-12-20 00:18:05 +04:00
|
|
|
|
static void
|
2013-10-03 19:43:04 +04:00
|
|
|
|
activate_binding(struct weston_seat *seat,
|
|
|
|
|
struct desktop_shell *shell,
|
2014-10-18 20:20:16 +04:00
|
|
|
|
struct weston_view *focus_view,
|
|
|
|
|
uint32_t flags)
|
2011-12-20 00:18:05 +04:00
|
|
|
|
{
|
2014-10-18 14:23:20 +04:00
|
|
|
|
struct weston_view *main_view;
|
shell: keyboard focus and restacking fixes for sub-surfaces
The shell needs to redirect some actions to the parent surface, when
they originally target a sub-surface. This patch implements the
following:
- Move, resize, and rotate bindings always target the parent surface.
- Opacity (full-surface alpha) binding targets the parent surface. This
is broken, because it should change the opacity of the whole compound
window, which is difficult to implement in the renderer.
- click_to_activate_binding() needs to check the shell surface type from
the main surface, because sub-surface would produce SHELL_SURFACE_NONE
and prevent activation.
- Also activate() needs to check the type from the main surface, and
restack the main surface. Keyboard focus is assigned to the original
(sub-)surface.
- focus_state_surface_destroy() needs to handle sub-surfaces: only the
main surface will be in a layer list. If the destroyed surface is
indeed a sub-surface, activate the main surface next. This way a
client that destroys a focused sub-surface still retains focus in the
same window.
- The workspace_manager.move_surface request can accept also
sub-surfaces, and it will move the corresponding main surface.
Changes in v2:
- do not special-case keyboard focus for sub-surfaces
- fix surface type checks for sub-surfaces in shell, fix restacking of
sub-surfaces in shell, fix focus_state_surface_destroy()
Changes in v3:
- Renamed weston_surface_get_parent() to
weston_surface_get_main_surface() to be more explicit that this is
about sub-surfaces
- Fixed move_surface_to_workspace() to handle keyboard focus on a
sub-surface.
- Used a temporary variable in several places to clarify code, instead
of reassigning a variable.
- Fixed workspace_manager_move_surface() to deal with sub-surfaces.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:44 +04:00
|
|
|
|
struct weston_surface *main_surface;
|
2011-12-20 00:18:05 +04:00
|
|
|
|
|
2014-10-18 14:23:20 +04:00
|
|
|
|
if (!focus_view)
|
|
|
|
|
return;
|
2012-03-05 10:13:13 +04:00
|
|
|
|
|
2014-10-18 14:23:20 +04:00
|
|
|
|
if (is_black_surface_view(focus_view, &main_view))
|
|
|
|
|
focus_view = main_view;
|
2012-03-01 08:57:46 +04:00
|
|
|
|
|
2014-10-18 14:23:20 +04:00
|
|
|
|
main_surface = weston_surface_get_main_surface(focus_view->surface);
|
2016-08-12 11:41:36 +03:00
|
|
|
|
if (!get_shell_surface(main_surface))
|
2012-06-27 18:22:15 +04:00
|
|
|
|
return;
|
2012-06-22 00:49:42 +04:00
|
|
|
|
|
2014-10-18 20:20:16 +04:00
|
|
|
|
activate(shell, focus_view, seat, flags);
|
2013-10-03 19:43:04 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2017-11-16 19:20:55 +03:00
|
|
|
|
click_to_activate_binding(struct weston_pointer *pointer,
|
|
|
|
|
const struct timespec *time,
|
2015-07-15 21:00:36 +03:00
|
|
|
|
uint32_t button, void *data)
|
2013-10-03 19:43:04 +04:00
|
|
|
|
{
|
2015-07-15 21:00:36 +03:00
|
|
|
|
if (pointer->grab != &pointer->default_grab)
|
2013-10-03 19:43:04 +04:00
|
|
|
|
return;
|
2015-07-15 21:00:36 +03:00
|
|
|
|
if (pointer->focus == NULL)
|
2014-01-02 04:28:32 +04:00
|
|
|
|
return;
|
2013-10-03 19:43:04 +04:00
|
|
|
|
|
2014-10-18 20:20:16 +04:00
|
|
|
|
activate_binding(pointer->seat, data, pointer->focus,
|
2014-10-18 20:42:19 +04:00
|
|
|
|
WESTON_ACTIVATE_FLAG_CLICKED |
|
2014-10-18 20:20:16 +04:00
|
|
|
|
WESTON_ACTIVATE_FLAG_CONFIGURE);
|
2013-10-03 19:43:04 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2017-11-16 19:20:58 +03:00
|
|
|
|
touch_to_activate_binding(struct weston_touch *touch,
|
|
|
|
|
const struct timespec *time,
|
2015-07-15 21:00:36 +03:00
|
|
|
|
void *data)
|
2013-10-03 19:43:04 +04:00
|
|
|
|
{
|
2015-07-15 21:00:36 +03:00
|
|
|
|
if (touch->grab != &touch->default_grab)
|
2013-10-03 19:43:04 +04:00
|
|
|
|
return;
|
2015-07-15 21:00:36 +03:00
|
|
|
|
if (touch->focus == NULL)
|
2014-01-03 11:00:11 +04:00
|
|
|
|
return;
|
2013-10-03 19:43:04 +04:00
|
|
|
|
|
2014-10-18 20:20:16 +04:00
|
|
|
|
activate_binding(touch->seat, data, touch->focus,
|
|
|
|
|
WESTON_ACTIVATE_FLAG_CONFIGURE);
|
2011-12-20 00:18:05 +04:00
|
|
|
|
}
|
|
|
|
|
|
2021-01-20 11:34:09 +03:00
|
|
|
|
static void
|
|
|
|
|
tablet_tool_activate_binding(struct weston_tablet_tool *tool,
|
|
|
|
|
uint32_t button, void *data)
|
|
|
|
|
{
|
|
|
|
|
if (tool->grab != &tool->default_grab)
|
|
|
|
|
return;
|
|
|
|
|
if (tool->focus == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
activate_binding(tool->seat, data, tool->focus,
|
|
|
|
|
WESTON_ACTIVATE_FLAG_CLICKED |
|
|
|
|
|
WESTON_ACTIVATE_FLAG_CONFIGURE);
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-09 19:33:32 +04:00
|
|
|
|
static void
|
|
|
|
|
unfocus_all_seats(struct desktop_shell *shell)
|
|
|
|
|
{
|
|
|
|
|
struct weston_seat *seat, *next;
|
|
|
|
|
|
|
|
|
|
wl_list_for_each_safe(seat, next, &shell->compositor->seat_list, link) {
|
2015-08-01 00:55:32 +03:00
|
|
|
|
struct weston_keyboard *keyboard =
|
|
|
|
|
weston_seat_get_keyboard(seat);
|
|
|
|
|
|
|
|
|
|
if (!keyboard)
|
2014-04-09 19:33:32 +04:00
|
|
|
|
continue;
|
|
|
|
|
|
2015-08-01 00:55:32 +03:00
|
|
|
|
weston_keyboard_set_focus(keyboard, NULL);
|
2014-04-09 19:33:32 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-23 21:04:11 +04:00
|
|
|
|
static void
|
compositor: Move fade animation out of core Weston into shell
Previously, it was impossible to override the fade in/out behavior of
Weston using a different shell, since this was implemented in core
Weston. This also led to complicated interaction between the shell and
the core when displaying lock surfaces and screensavers.
This patch starts to solve this issue by moving the fade animation out
of the core. On compositor.c, besides deleting the fade code, the idle
handler had to be changed to emit the lock signal, since it was called
from the fade_frame() function before. This causes a slight change of
behavior, since before the fade would happen with the compositor being
active, while now it is already in the idle state. That leads to the
dpms state being set when cancelling the fade with mouse movement, and
in turn, to a slight freeze with drm compositor. This problem will be
fixed in a follow up patch.
On the shell side, the fade was re-implemented in a slightly different
manner. Instead of using a custom frame function, the fade animation
from animation.c is used. The interface for starting the fade was also
changed to take the value of an enum instead of a float alpha value,
in order to improve readability.
2013-02-21 20:35:20 +04:00
|
|
|
|
lock(struct desktop_shell *shell)
|
2011-04-23 21:04:11 +04:00
|
|
|
|
{
|
2012-06-25 22:03:13 +04:00
|
|
|
|
struct workspace *ws = get_current_workspace(shell);
|
2011-11-15 15:34:54 +04:00
|
|
|
|
|
2012-02-29 21:53:50 +04:00
|
|
|
|
if (shell->locked) {
|
2013-02-21 20:35:22 +04:00
|
|
|
|
weston_compositor_sleep(shell->compositor);
|
2011-11-15 15:34:54 +04:00
|
|
|
|
return;
|
2012-02-29 21:53:50 +04:00
|
|
|
|
}
|
desktop-shell: screen locking protocol
Add protocol and functions for supporting screen locking, triggered by
activity timeout.
After activity timeout, compositor starts the fade to black, and then
enters SLEEPING state. At that point it calls lock() in the shell
plugin.
When input events trigger a wakeup, unlock() in the shell plugin is
called. This sends prepare_lock_surface event to the desktop-shell
client. The screen stays locked while the compositor starts fade-in.
At this point, desktop-shell client usually creates a surface for the
unlocking GUI (e.g. a password prompt), and sends it with the
set_lock_surface request. The compositor supposedly shows and allows
interaction only with the given lock surface (not yet implemented).
When desktop-shell has authenticated the user, or instead of issuing
set_lock_surface, it sends the unlock request. Upon receiving the unlock
request, the shell plugin unlocks the screen.
If desktop-shell client dies, the screen is unlocked automatically.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-15 15:34:48 +04:00
|
|
|
|
|
|
|
|
|
shell->locked = true;
|
2011-11-15 15:34:54 +04:00
|
|
|
|
|
2012-02-29 21:42:35 +04:00
|
|
|
|
/* Hide all surfaces by removing the fullscreen, panel and
|
|
|
|
|
* toplevel layers. This way nothing else can show or receive
|
|
|
|
|
* input events while we are locked. */
|
2011-11-15 15:34:54 +04:00
|
|
|
|
|
2016-12-17 15:40:51 +03:00
|
|
|
|
weston_layer_unset_position(&shell->panel_layer);
|
|
|
|
|
weston_layer_unset_position(&shell->fullscreen_layer);
|
2012-08-09 20:50:43 +04:00
|
|
|
|
if (shell->showing_input_panels)
|
2016-12-17 15:40:51 +03:00
|
|
|
|
weston_layer_unset_position(&shell->input_panel_layer);
|
|
|
|
|
weston_layer_unset_position(&ws->layer);
|
|
|
|
|
|
|
|
|
|
weston_layer_set_position(&shell->lock_layer,
|
|
|
|
|
WESTON_LAYER_POSITION_LOCK);
|
2011-11-15 15:34:54 +04:00
|
|
|
|
|
2015-07-21 00:28:13 +03:00
|
|
|
|
weston_compositor_sleep(shell->compositor);
|
|
|
|
|
|
2014-04-09 19:33:32 +04:00
|
|
|
|
/* Remove the keyboard focus on all seats. This will be
|
|
|
|
|
* restored to the workspace's saved state via
|
|
|
|
|
* restore_focus_state when the compositor is unlocked */
|
|
|
|
|
unfocus_all_seats(shell);
|
|
|
|
|
|
2011-11-15 15:34:54 +04:00
|
|
|
|
/* TODO: disable bindings that should not work while locked. */
|
|
|
|
|
|
|
|
|
|
/* All this must be undone in resume_desktop(). */
|
desktop-shell: screen locking protocol
Add protocol and functions for supporting screen locking, triggered by
activity timeout.
After activity timeout, compositor starts the fade to black, and then
enters SLEEPING state. At that point it calls lock() in the shell
plugin.
When input events trigger a wakeup, unlock() in the shell plugin is
called. This sends prepare_lock_surface event to the desktop-shell
client. The screen stays locked while the compositor starts fade-in.
At this point, desktop-shell client usually creates a surface for the
unlocking GUI (e.g. a password prompt), and sends it with the
set_lock_surface request. The compositor supposedly shows and allows
interaction only with the given lock surface (not yet implemented).
When desktop-shell has authenticated the user, or instead of issuing
set_lock_surface, it sends the unlock request. Upon receiving the unlock
request, the shell plugin unlocks the screen.
If desktop-shell client dies, the screen is unlocked automatically.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-15 15:34:48 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
compositor: Move fade animation out of core Weston into shell
Previously, it was impossible to override the fade in/out behavior of
Weston using a different shell, since this was implemented in core
Weston. This also led to complicated interaction between the shell and
the core when displaying lock surfaces and screensavers.
This patch starts to solve this issue by moving the fade animation out
of the core. On compositor.c, besides deleting the fade code, the idle
handler had to be changed to emit the lock signal, since it was called
from the fade_frame() function before. This causes a slight change of
behavior, since before the fade would happen with the compositor being
active, while now it is already in the idle state. That leads to the
dpms state being set when cancelling the fade with mouse movement, and
in turn, to a slight freeze with drm compositor. This problem will be
fixed in a follow up patch.
On the shell side, the fade was re-implemented in a slightly different
manner. Instead of using a custom frame function, the fade animation
from animation.c is used. The interface for starting the fade was also
changed to take the value of an enum instead of a float alpha value,
in order to improve readability.
2013-02-21 20:35:20 +04:00
|
|
|
|
unlock(struct desktop_shell *shell)
|
desktop-shell: screen locking protocol
Add protocol and functions for supporting screen locking, triggered by
activity timeout.
After activity timeout, compositor starts the fade to black, and then
enters SLEEPING state. At that point it calls lock() in the shell
plugin.
When input events trigger a wakeup, unlock() in the shell plugin is
called. This sends prepare_lock_surface event to the desktop-shell
client. The screen stays locked while the compositor starts fade-in.
At this point, desktop-shell client usually creates a surface for the
unlocking GUI (e.g. a password prompt), and sends it with the
set_lock_surface request. The compositor supposedly shows and allows
interaction only with the given lock surface (not yet implemented).
When desktop-shell has authenticated the user, or instead of issuing
set_lock_surface, it sends the unlock request. Upon receiving the unlock
request, the shell plugin unlocks the screen.
If desktop-shell client dies, the screen is unlocked automatically.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-15 15:34:48 +04:00
|
|
|
|
{
|
2015-11-17 11:00:33 +03:00
|
|
|
|
struct wl_resource *shell_resource;
|
|
|
|
|
|
2011-11-16 15:47:34 +04:00
|
|
|
|
if (!shell->locked || shell->lock_surface) {
|
2013-02-21 20:35:22 +04:00
|
|
|
|
shell_fade(shell, FADE_IN);
|
desktop-shell: screen locking protocol
Add protocol and functions for supporting screen locking, triggered by
activity timeout.
After activity timeout, compositor starts the fade to black, and then
enters SLEEPING state. At that point it calls lock() in the shell
plugin.
When input events trigger a wakeup, unlock() in the shell plugin is
called. This sends prepare_lock_surface event to the desktop-shell
client. The screen stays locked while the compositor starts fade-in.
At this point, desktop-shell client usually creates a surface for the
unlocking GUI (e.g. a password prompt), and sends it with the
set_lock_surface request. The compositor supposedly shows and allows
interaction only with the given lock surface (not yet implemented).
When desktop-shell has authenticated the user, or instead of issuing
set_lock_surface, it sends the unlock request. Upon receiving the unlock
request, the shell plugin unlocks the screen.
If desktop-shell client dies, the screen is unlocked automatically.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-15 15:34:48 +04:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If desktop-shell client has gone away, unlock immediately. */
|
|
|
|
|
if (!shell->child.desktop_shell) {
|
2011-11-15 15:34:54 +04:00
|
|
|
|
resume_desktop(shell);
|
desktop-shell: screen locking protocol
Add protocol and functions for supporting screen locking, triggered by
activity timeout.
After activity timeout, compositor starts the fade to black, and then
enters SLEEPING state. At that point it calls lock() in the shell
plugin.
When input events trigger a wakeup, unlock() in the shell plugin is
called. This sends prepare_lock_surface event to the desktop-shell
client. The screen stays locked while the compositor starts fade-in.
At this point, desktop-shell client usually creates a surface for the
unlocking GUI (e.g. a password prompt), and sends it with the
set_lock_surface request. The compositor supposedly shows and allows
interaction only with the given lock surface (not yet implemented).
When desktop-shell has authenticated the user, or instead of issuing
set_lock_surface, it sends the unlock request. Upon receiving the unlock
request, the shell plugin unlocks the screen.
If desktop-shell client dies, the screen is unlocked automatically.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-15 15:34:48 +04:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (shell->prepare_event_sent)
|
|
|
|
|
return;
|
|
|
|
|
|
2015-11-17 11:00:33 +03:00
|
|
|
|
shell_resource = shell->child.desktop_shell;
|
|
|
|
|
weston_desktop_shell_send_prepare_lock_surface(shell_resource);
|
desktop-shell: screen locking protocol
Add protocol and functions for supporting screen locking, triggered by
activity timeout.
After activity timeout, compositor starts the fade to black, and then
enters SLEEPING state. At that point it calls lock() in the shell
plugin.
When input events trigger a wakeup, unlock() in the shell plugin is
called. This sends prepare_lock_surface event to the desktop-shell
client. The screen stays locked while the compositor starts fade-in.
At this point, desktop-shell client usually creates a surface for the
unlocking GUI (e.g. a password prompt), and sends it with the
set_lock_surface request. The compositor supposedly shows and allows
interaction only with the given lock surface (not yet implemented).
When desktop-shell has authenticated the user, or instead of issuing
set_lock_surface, it sends the unlock request. Upon receiving the unlock
request, the shell plugin unlocks the screen.
If desktop-shell client dies, the screen is unlocked automatically.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-15 15:34:48 +04:00
|
|
|
|
shell->prepare_event_sent = true;
|
2011-04-23 21:04:11 +04:00
|
|
|
|
}
|
|
|
|
|
|
compositor: Move fade animation out of core Weston into shell
Previously, it was impossible to override the fade in/out behavior of
Weston using a different shell, since this was implemented in core
Weston. This also led to complicated interaction between the shell and
the core when displaying lock surfaces and screensavers.
This patch starts to solve this issue by moving the fade animation out
of the core. On compositor.c, besides deleting the fade code, the idle
handler had to be changed to emit the lock signal, since it was called
from the fade_frame() function before. This causes a slight change of
behavior, since before the fade would happen with the compositor being
active, while now it is already in the idle state. That leads to the
dpms state being set when cancelling the fade with mouse movement, and
in turn, to a slight freeze with drm compositor. This problem will be
fixed in a follow up patch.
On the shell side, the fade was re-implemented in a slightly different
manner. Instead of using a custom frame function, the fade animation
from animation.c is used. The interface for starting the fade was also
changed to take the value of an enum instead of a float alpha value,
in order to improve readability.
2013-02-21 20:35:20 +04:00
|
|
|
|
static void
|
2016-09-09 23:16:02 +03:00
|
|
|
|
shell_fade_done_for_output(struct weston_view_animation *animation, void *data)
|
compositor: Move fade animation out of core Weston into shell
Previously, it was impossible to override the fade in/out behavior of
Weston using a different shell, since this was implemented in core
Weston. This also led to complicated interaction between the shell and
the core when displaying lock surfaces and screensavers.
This patch starts to solve this issue by moving the fade animation out
of the core. On compositor.c, besides deleting the fade code, the idle
handler had to be changed to emit the lock signal, since it was called
from the fade_frame() function before. This causes a slight change of
behavior, since before the fade would happen with the compositor being
active, while now it is already in the idle state. That leads to the
dpms state being set when cancelling the fade with mouse movement, and
in turn, to a slight freeze with drm compositor. This problem will be
fixed in a follow up patch.
On the shell side, the fade was re-implemented in a slightly different
manner. Instead of using a custom frame function, the fade animation
from animation.c is used. The interface for starting the fade was also
changed to take the value of an enum instead of a float alpha value,
in order to improve readability.
2013-02-21 20:35:20 +04:00
|
|
|
|
{
|
2016-09-09 23:16:02 +03:00
|
|
|
|
struct shell_output *shell_output = data;
|
|
|
|
|
struct desktop_shell *shell = shell_output->shell;
|
compositor: Move fade animation out of core Weston into shell
Previously, it was impossible to override the fade in/out behavior of
Weston using a different shell, since this was implemented in core
Weston. This also led to complicated interaction between the shell and
the core when displaying lock surfaces and screensavers.
This patch starts to solve this issue by moving the fade animation out
of the core. On compositor.c, besides deleting the fade code, the idle
handler had to be changed to emit the lock signal, since it was called
from the fade_frame() function before. This causes a slight change of
behavior, since before the fade would happen with the compositor being
active, while now it is already in the idle state. That leads to the
dpms state being set when cancelling the fade with mouse movement, and
in turn, to a slight freeze with drm compositor. This problem will be
fixed in a follow up patch.
On the shell side, the fade was re-implemented in a slightly different
manner. Instead of using a custom frame function, the fade animation
from animation.c is used. The interface for starting the fade was also
changed to take the value of an enum instead of a float alpha value,
in order to improve readability.
2013-02-21 20:35:20 +04:00
|
|
|
|
|
2016-09-09 23:16:02 +03:00
|
|
|
|
shell_output->fade.animation = NULL;
|
|
|
|
|
switch (shell_output->fade.type) {
|
compositor: Move fade animation out of core Weston into shell
Previously, it was impossible to override the fade in/out behavior of
Weston using a different shell, since this was implemented in core
Weston. This also led to complicated interaction between the shell and
the core when displaying lock surfaces and screensavers.
This patch starts to solve this issue by moving the fade animation out
of the core. On compositor.c, besides deleting the fade code, the idle
handler had to be changed to emit the lock signal, since it was called
from the fade_frame() function before. This causes a slight change of
behavior, since before the fade would happen with the compositor being
active, while now it is already in the idle state. That leads to the
dpms state being set when cancelling the fade with mouse movement, and
in turn, to a slight freeze with drm compositor. This problem will be
fixed in a follow up patch.
On the shell side, the fade was re-implemented in a slightly different
manner. Instead of using a custom frame function, the fade animation
from animation.c is used. The interface for starting the fade was also
changed to take the value of an enum instead of a float alpha value,
in order to improve readability.
2013-02-21 20:35:20 +04:00
|
|
|
|
case FADE_IN:
|
2022-11-22 14:28:57 +03:00
|
|
|
|
weston_shell_utils_curtain_destroy(shell_output->fade.curtain);
|
desktop-shell: Reuse curtains for fades
Use the common infrastructure we have, rather than open-coding again.
In changing to the common weston_curtain infrastructure which was
introduced in a previous commit, there are two small functional
derivations.
After adding the view to a layer, we explicitly call
weston_view_geometry_dirty(). This is believed to have no functional
impact, as weston_views have their geometry-dirty flag set when they are
created.
weston_surface_damage() is also called to ensure that the surface is
scheduled for a repaint. As there is currently no good common mechanic
in the common code to ensure that output repaint will occur, due to the
damage propagating outwards from the weston_surface, we are forced to
call this to predictably ensure that the output will be repainted after
we have made this change to the scene graph which should result in the
user observing the new content being repainted.
It is possible that these changes are not strictly required in order for
the correct behaviour to occur. However, it is felt that explicitly
adding these calls is perhaps the least fragile way to ensure that the
behaviour continues to be correct and breakage is not observed,
especially with both view mapping and surface damage identified as areas
for future work which could be beneficial to Weston. If it is felt that
these calls can be removed, then this is certainly possible at a later
stage.
Lastly, there are many users within desktop-shell of the common pattern
of creating a weston_curtain and inserting it into the scene graph to be
painted. These users have been an area of both theoretical concern and
real-life observed fragility and breakage recently. By making each user
follow a common and predictable pattern of usage, each user is no longer
its own special case. This should make it easier to make the
desktop-shell codebase more robust, not only simplifying the codebase,
but improving observed behaviour.
In doing this, it is hoped that future structural and interface changes
become easier to make, allowing us to improve some of the more difficult
corners of the libweston API.
Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-01-19 02:01:56 +03:00
|
|
|
|
shell_output->fade.curtain = NULL;
|
compositor: Move fade animation out of core Weston into shell
Previously, it was impossible to override the fade in/out behavior of
Weston using a different shell, since this was implemented in core
Weston. This also led to complicated interaction between the shell and
the core when displaying lock surfaces and screensavers.
This patch starts to solve this issue by moving the fade animation out
of the core. On compositor.c, besides deleting the fade code, the idle
handler had to be changed to emit the lock signal, since it was called
from the fade_frame() function before. This causes a slight change of
behavior, since before the fade would happen with the compositor being
active, while now it is already in the idle state. That leads to the
dpms state being set when cancelling the fade with mouse movement, and
in turn, to a slight freeze with drm compositor. This problem will be
fixed in a follow up patch.
On the shell side, the fade was re-implemented in a slightly different
manner. Instead of using a custom frame function, the fade animation
from animation.c is used. The interface for starting the fade was also
changed to take the value of an enum instead of a float alpha value,
in order to improve readability.
2013-02-21 20:35:20 +04:00
|
|
|
|
break;
|
|
|
|
|
case FADE_OUT:
|
|
|
|
|
lock(shell);
|
|
|
|
|
break;
|
2013-11-25 22:01:32 +04:00
|
|
|
|
default:
|
|
|
|
|
break;
|
compositor: Move fade animation out of core Weston into shell
Previously, it was impossible to override the fade in/out behavior of
Weston using a different shell, since this was implemented in core
Weston. This also led to complicated interaction between the shell and
the core when displaying lock surfaces and screensavers.
This patch starts to solve this issue by moving the fade animation out
of the core. On compositor.c, besides deleting the fade code, the idle
handler had to be changed to emit the lock signal, since it was called
from the fade_frame() function before. This causes a slight change of
behavior, since before the fade would happen with the compositor being
active, while now it is already in the idle state. That leads to the
dpms state being set when cancelling the fade with mouse movement, and
in turn, to a slight freeze with drm compositor. This problem will be
fixed in a follow up patch.
On the shell side, the fade was re-implemented in a slightly different
manner. Instead of using a custom frame function, the fade animation
from animation.c is used. The interface for starting the fade was also
changed to take the value of an enum instead of a float alpha value,
in order to improve readability.
2013-02-21 20:35:20 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-13 00:57:43 +03:00
|
|
|
|
static int
|
|
|
|
|
fade_surface_get_label(struct weston_surface *surface,
|
|
|
|
|
char *buf, size_t len)
|
|
|
|
|
{
|
|
|
|
|
struct shell_output *output = surface->committed_private;
|
|
|
|
|
|
|
|
|
|
return snprintf(buf, len, "desktop shell fade surface for %s",
|
|
|
|
|
output->output->name);
|
|
|
|
|
}
|
|
|
|
|
|
desktop-shell: Reuse curtains for fades
Use the common infrastructure we have, rather than open-coding again.
In changing to the common weston_curtain infrastructure which was
introduced in a previous commit, there are two small functional
derivations.
After adding the view to a layer, we explicitly call
weston_view_geometry_dirty(). This is believed to have no functional
impact, as weston_views have their geometry-dirty flag set when they are
created.
weston_surface_damage() is also called to ensure that the surface is
scheduled for a repaint. As there is currently no good common mechanic
in the common code to ensure that output repaint will occur, due to the
damage propagating outwards from the weston_surface, we are forced to
call this to predictably ensure that the output will be repainted after
we have made this change to the scene graph which should result in the
user observing the new content being repainted.
It is possible that these changes are not strictly required in order for
the correct behaviour to occur. However, it is felt that explicitly
adding these calls is perhaps the least fragile way to ensure that the
behaviour continues to be correct and breakage is not observed,
especially with both view mapping and surface damage identified as areas
for future work which could be beneficial to Weston. If it is felt that
these calls can be removed, then this is certainly possible at a later
stage.
Lastly, there are many users within desktop-shell of the common pattern
of creating a weston_curtain and inserting it into the scene graph to be
painted. These users have been an area of both theoretical concern and
real-life observed fragility and breakage recently. By making each user
follow a common and predictable pattern of usage, each user is no longer
its own special case. This should make it easier to make the
desktop-shell codebase more robust, not only simplifying the codebase,
but improving observed behaviour.
In doing this, it is hoped that future structural and interface changes
become easier to make, allowing us to improve some of the more difficult
corners of the libweston API.
Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-01-19 02:01:56 +03:00
|
|
|
|
static struct weston_curtain *
|
|
|
|
|
shell_fade_create_view_for_output(struct desktop_shell *shell,
|
|
|
|
|
struct shell_output *shell_output)
|
compositor: Move fade animation out of core Weston into shell
Previously, it was impossible to override the fade in/out behavior of
Weston using a different shell, since this was implemented in core
Weston. This also led to complicated interaction between the shell and
the core when displaying lock surfaces and screensavers.
This patch starts to solve this issue by moving the fade animation out
of the core. On compositor.c, besides deleting the fade code, the idle
handler had to be changed to emit the lock signal, since it was called
from the fade_frame() function before. This causes a slight change of
behavior, since before the fade would happen with the compositor being
active, while now it is already in the idle state. That leads to the
dpms state being set when cancelling the fade with mouse movement, and
in turn, to a slight freeze with drm compositor. This problem will be
fixed in a follow up patch.
On the shell side, the fade was re-implemented in a slightly different
manner. Instead of using a custom frame function, the fade animation
from animation.c is used. The interface for starting the fade was also
changed to take the value of an enum instead of a float alpha value,
in order to improve readability.
2013-02-21 20:35:20 +04:00
|
|
|
|
{
|
|
|
|
|
struct weston_compositor *compositor = shell->compositor;
|
desktop-shell: Reuse curtains for fades
Use the common infrastructure we have, rather than open-coding again.
In changing to the common weston_curtain infrastructure which was
introduced in a previous commit, there are two small functional
derivations.
After adding the view to a layer, we explicitly call
weston_view_geometry_dirty(). This is believed to have no functional
impact, as weston_views have their geometry-dirty flag set when they are
created.
weston_surface_damage() is also called to ensure that the surface is
scheduled for a repaint. As there is currently no good common mechanic
in the common code to ensure that output repaint will occur, due to the
damage propagating outwards from the weston_surface, we are forced to
call this to predictably ensure that the output will be repainted after
we have made this change to the scene graph which should result in the
user observing the new content being repainted.
It is possible that these changes are not strictly required in order for
the correct behaviour to occur. However, it is felt that explicitly
adding these calls is perhaps the least fragile way to ensure that the
behaviour continues to be correct and breakage is not observed,
especially with both view mapping and surface damage identified as areas
for future work which could be beneficial to Weston. If it is felt that
these calls can be removed, then this is certainly possible at a later
stage.
Lastly, there are many users within desktop-shell of the common pattern
of creating a weston_curtain and inserting it into the scene graph to be
painted. These users have been an area of both theoretical concern and
real-life observed fragility and breakage recently. By making each user
follow a common and predictable pattern of usage, each user is no longer
its own special case. This should make it easier to make the
desktop-shell codebase more robust, not only simplifying the codebase,
but improving observed behaviour.
In doing this, it is hoped that future structural and interface changes
become easier to make, allowing us to improve some of the more difficult
corners of the libweston API.
Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-01-19 02:01:56 +03:00
|
|
|
|
struct weston_output *output = shell_output->output;
|
|
|
|
|
struct weston_curtain_params curtain_params = {
|
|
|
|
|
.r = 0.0, .g = 0.0, .b = 0.0, .a = 1.0,
|
|
|
|
|
.x = output->x, .y = output->y,
|
|
|
|
|
.width = output->width, .height = output->height,
|
|
|
|
|
.surface_committed = black_surface_committed,
|
2022-04-13 00:57:43 +03:00
|
|
|
|
.get_label = fade_surface_get_label,
|
desktop-shell: Reuse curtains for fades
Use the common infrastructure we have, rather than open-coding again.
In changing to the common weston_curtain infrastructure which was
introduced in a previous commit, there are two small functional
derivations.
After adding the view to a layer, we explicitly call
weston_view_geometry_dirty(). This is believed to have no functional
impact, as weston_views have their geometry-dirty flag set when they are
created.
weston_surface_damage() is also called to ensure that the surface is
scheduled for a repaint. As there is currently no good common mechanic
in the common code to ensure that output repaint will occur, due to the
damage propagating outwards from the weston_surface, we are forced to
call this to predictably ensure that the output will be repainted after
we have made this change to the scene graph which should result in the
user observing the new content being repainted.
It is possible that these changes are not strictly required in order for
the correct behaviour to occur. However, it is felt that explicitly
adding these calls is perhaps the least fragile way to ensure that the
behaviour continues to be correct and breakage is not observed,
especially with both view mapping and surface damage identified as areas
for future work which could be beneficial to Weston. If it is felt that
these calls can be removed, then this is certainly possible at a later
stage.
Lastly, there are many users within desktop-shell of the common pattern
of creating a weston_curtain and inserting it into the scene graph to be
painted. These users have been an area of both theoretical concern and
real-life observed fragility and breakage recently. By making each user
follow a common and predictable pattern of usage, each user is no longer
its own special case. This should make it easier to make the
desktop-shell codebase more robust, not only simplifying the codebase,
but improving observed behaviour.
In doing this, it is hoped that future structural and interface changes
become easier to make, allowing us to improve some of the more difficult
corners of the libweston API.
Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-01-19 02:01:56 +03:00
|
|
|
|
.surface_private = shell_output,
|
|
|
|
|
.capture_input = false,
|
|
|
|
|
};
|
|
|
|
|
struct weston_curtain *curtain;
|
shell: wait for desktop-shell init before fade in
On Raspberry Pi, weston-desktop-shell is so slow to start, that the
compositor has time to run the fade-in before the wallpaper is up. The
user launching Weston sees the screen flipping to black, the fbcon
fading in, and then the desktop popping up.
To fix this, wait for the weston-desktop-shell to draw
everything before starting the initial fade-in. A new request is
added to the private desktop-shell protocol to signal it. If a
desktop-shell client does not support the new request, the fade-in
happens already at bind time.
If weston-desktop-shell crashes, or does not send the 'desktop_ready'
request in 15 seconds, the compositor will fade in anyway. This should
avoid a blocked screen in case weston-desktop-shell malfunction.
shell_fade_startup() does not directly start the fade-in but schedules
an idle callback, so that the compositor can process all pending events
before starting the fade clock. Otherwise (on RPi) we risk skipping part
of the animation. Yes, it is a hack, that should have been done in
window.c and weston-desktop-shell instead.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2013-05-22 19:03:09 +04:00
|
|
|
|
|
2022-11-22 14:28:57 +03:00
|
|
|
|
curtain = weston_shell_utils_curtain_create(compositor, &curtain_params);
|
desktop-shell: Reuse curtains for fades
Use the common infrastructure we have, rather than open-coding again.
In changing to the common weston_curtain infrastructure which was
introduced in a previous commit, there are two small functional
derivations.
After adding the view to a layer, we explicitly call
weston_view_geometry_dirty(). This is believed to have no functional
impact, as weston_views have their geometry-dirty flag set when they are
created.
weston_surface_damage() is also called to ensure that the surface is
scheduled for a repaint. As there is currently no good common mechanic
in the common code to ensure that output repaint will occur, due to the
damage propagating outwards from the weston_surface, we are forced to
call this to predictably ensure that the output will be repainted after
we have made this change to the scene graph which should result in the
user observing the new content being repainted.
It is possible that these changes are not strictly required in order for
the correct behaviour to occur. However, it is felt that explicitly
adding these calls is perhaps the least fragile way to ensure that the
behaviour continues to be correct and breakage is not observed,
especially with both view mapping and surface damage identified as areas
for future work which could be beneficial to Weston. If it is felt that
these calls can be removed, then this is certainly possible at a later
stage.
Lastly, there are many users within desktop-shell of the common pattern
of creating a weston_curtain and inserting it into the scene graph to be
painted. These users have been an area of both theoretical concern and
real-life observed fragility and breakage recently. By making each user
follow a common and predictable pattern of usage, each user is no longer
its own special case. This should make it easier to make the
desktop-shell codebase more robust, not only simplifying the codebase,
but improving observed behaviour.
In doing this, it is hoped that future structural and interface changes
become easier to make, allowing us to improve some of the more difficult
corners of the libweston API.
Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-01-19 02:01:56 +03:00
|
|
|
|
assert(curtain);
|
shell: wait for desktop-shell init before fade in
On Raspberry Pi, weston-desktop-shell is so slow to start, that the
compositor has time to run the fade-in before the wallpaper is up. The
user launching Weston sees the screen flipping to black, the fbcon
fading in, and then the desktop popping up.
To fix this, wait for the weston-desktop-shell to draw
everything before starting the initial fade-in. A new request is
added to the private desktop-shell protocol to signal it. If a
desktop-shell client does not support the new request, the fade-in
happens already at bind time.
If weston-desktop-shell crashes, or does not send the 'desktop_ready'
request in 15 seconds, the compositor will fade in anyway. This should
avoid a blocked screen in case weston-desktop-shell malfunction.
shell_fade_startup() does not directly start the fade-in but schedules
an idle callback, so that the compositor can process all pending events
before starting the fade clock. Otherwise (on RPi) we risk skipping part
of the animation. Yes, it is a hack, that should have been done in
window.c and weston-desktop-shell instead.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2013-05-22 19:03:09 +04:00
|
|
|
|
|
desktop-shell: Reuse curtains for fades
Use the common infrastructure we have, rather than open-coding again.
In changing to the common weston_curtain infrastructure which was
introduced in a previous commit, there are two small functional
derivations.
After adding the view to a layer, we explicitly call
weston_view_geometry_dirty(). This is believed to have no functional
impact, as weston_views have their geometry-dirty flag set when they are
created.
weston_surface_damage() is also called to ensure that the surface is
scheduled for a repaint. As there is currently no good common mechanic
in the common code to ensure that output repaint will occur, due to the
damage propagating outwards from the weston_surface, we are forced to
call this to predictably ensure that the output will be repainted after
we have made this change to the scene graph which should result in the
user observing the new content being repainted.
It is possible that these changes are not strictly required in order for
the correct behaviour to occur. However, it is felt that explicitly
adding these calls is perhaps the least fragile way to ensure that the
behaviour continues to be correct and breakage is not observed,
especially with both view mapping and surface damage identified as areas
for future work which could be beneficial to Weston. If it is felt that
these calls can be removed, then this is certainly possible at a later
stage.
Lastly, there are many users within desktop-shell of the common pattern
of creating a weston_curtain and inserting it into the scene graph to be
painted. These users have been an area of both theoretical concern and
real-life observed fragility and breakage recently. By making each user
follow a common and predictable pattern of usage, each user is no longer
its own special case. This should make it easier to make the
desktop-shell codebase more robust, not only simplifying the codebase,
but improving observed behaviour.
In doing this, it is hoped that future structural and interface changes
become easier to make, allowing us to improve some of the more difficult
corners of the libweston API.
Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-01-19 02:01:56 +03:00
|
|
|
|
weston_view_set_output(curtain->view, output);
|
|
|
|
|
curtain->view->is_mapped = true;
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
|
2014-07-09 23:12:56 +04:00
|
|
|
|
weston_layer_entry_insert(&compositor->fade_layer.view_list,
|
desktop-shell: Reuse curtains for fades
Use the common infrastructure we have, rather than open-coding again.
In changing to the common weston_curtain infrastructure which was
introduced in a previous commit, there are two small functional
derivations.
After adding the view to a layer, we explicitly call
weston_view_geometry_dirty(). This is believed to have no functional
impact, as weston_views have their geometry-dirty flag set when they are
created.
weston_surface_damage() is also called to ensure that the surface is
scheduled for a repaint. As there is currently no good common mechanic
in the common code to ensure that output repaint will occur, due to the
damage propagating outwards from the weston_surface, we are forced to
call this to predictably ensure that the output will be repainted after
we have made this change to the scene graph which should result in the
user observing the new content being repainted.
It is possible that these changes are not strictly required in order for
the correct behaviour to occur. However, it is felt that explicitly
adding these calls is perhaps the least fragile way to ensure that the
behaviour continues to be correct and breakage is not observed,
especially with both view mapping and surface damage identified as areas
for future work which could be beneficial to Weston. If it is felt that
these calls can be removed, then this is certainly possible at a later
stage.
Lastly, there are many users within desktop-shell of the common pattern
of creating a weston_curtain and inserting it into the scene graph to be
painted. These users have been an area of both theoretical concern and
real-life observed fragility and breakage recently. By making each user
follow a common and predictable pattern of usage, each user is no longer
its own special case. This should make it easier to make the
desktop-shell codebase more robust, not only simplifying the codebase,
but improving observed behaviour.
In doing this, it is hoped that future structural and interface changes
become easier to make, allowing us to improve some of the more difficult
corners of the libweston API.
Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-01-19 02:01:56 +03:00
|
|
|
|
&curtain->view->layer_link);
|
|
|
|
|
weston_view_geometry_dirty(curtain->view);
|
|
|
|
|
weston_surface_damage(curtain->view->surface);
|
shell: wait for desktop-shell init before fade in
On Raspberry Pi, weston-desktop-shell is so slow to start, that the
compositor has time to run the fade-in before the wallpaper is up. The
user launching Weston sees the screen flipping to black, the fbcon
fading in, and then the desktop popping up.
To fix this, wait for the weston-desktop-shell to draw
everything before starting the initial fade-in. A new request is
added to the private desktop-shell protocol to signal it. If a
desktop-shell client does not support the new request, the fade-in
happens already at bind time.
If weston-desktop-shell crashes, or does not send the 'desktop_ready'
request in 15 seconds, the compositor will fade in anyway. This should
avoid a blocked screen in case weston-desktop-shell malfunction.
shell_fade_startup() does not directly start the fade-in but schedules
an idle callback, so that the compositor can process all pending events
before starting the fade clock. Otherwise (on RPi) we risk skipping part
of the animation. Yes, it is a hack, that should have been done in
window.c and weston-desktop-shell instead.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2013-05-22 19:03:09 +04:00
|
|
|
|
|
desktop-shell: Reuse curtains for fades
Use the common infrastructure we have, rather than open-coding again.
In changing to the common weston_curtain infrastructure which was
introduced in a previous commit, there are two small functional
derivations.
After adding the view to a layer, we explicitly call
weston_view_geometry_dirty(). This is believed to have no functional
impact, as weston_views have their geometry-dirty flag set when they are
created.
weston_surface_damage() is also called to ensure that the surface is
scheduled for a repaint. As there is currently no good common mechanic
in the common code to ensure that output repaint will occur, due to the
damage propagating outwards from the weston_surface, we are forced to
call this to predictably ensure that the output will be repainted after
we have made this change to the scene graph which should result in the
user observing the new content being repainted.
It is possible that these changes are not strictly required in order for
the correct behaviour to occur. However, it is felt that explicitly
adding these calls is perhaps the least fragile way to ensure that the
behaviour continues to be correct and breakage is not observed,
especially with both view mapping and surface damage identified as areas
for future work which could be beneficial to Weston. If it is felt that
these calls can be removed, then this is certainly possible at a later
stage.
Lastly, there are many users within desktop-shell of the common pattern
of creating a weston_curtain and inserting it into the scene graph to be
painted. These users have been an area of both theoretical concern and
real-life observed fragility and breakage recently. By making each user
follow a common and predictable pattern of usage, each user is no longer
its own special case. This should make it easier to make the
desktop-shell codebase more robust, not only simplifying the codebase,
but improving observed behaviour.
In doing this, it is hoped that future structural and interface changes
become easier to make, allowing us to improve some of the more difficult
corners of the libweston API.
Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-01-19 02:01:56 +03:00
|
|
|
|
return curtain;
|
shell: wait for desktop-shell init before fade in
On Raspberry Pi, weston-desktop-shell is so slow to start, that the
compositor has time to run the fade-in before the wallpaper is up. The
user launching Weston sees the screen flipping to black, the fbcon
fading in, and then the desktop popping up.
To fix this, wait for the weston-desktop-shell to draw
everything before starting the initial fade-in. A new request is
added to the private desktop-shell protocol to signal it. If a
desktop-shell client does not support the new request, the fade-in
happens already at bind time.
If weston-desktop-shell crashes, or does not send the 'desktop_ready'
request in 15 seconds, the compositor will fade in anyway. This should
avoid a blocked screen in case weston-desktop-shell malfunction.
shell_fade_startup() does not directly start the fade-in but schedules
an idle callback, so that the compositor can process all pending events
before starting the fade clock. Otherwise (on RPi) we risk skipping part
of the animation. Yes, it is a hack, that should have been done in
window.c and weston-desktop-shell instead.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2013-05-22 19:03:09 +04:00
|
|
|
|
}
|
|
|
|
|
|
2022-02-14 23:57:08 +03:00
|
|
|
|
static struct weston_view *
|
|
|
|
|
shell_fade_create_fade_out_view(struct shell_surface *shsurf,
|
|
|
|
|
struct weston_surface *surface)
|
|
|
|
|
{
|
|
|
|
|
struct weston_view *view;
|
|
|
|
|
struct weston_output *woutput;
|
|
|
|
|
|
|
|
|
|
view = weston_view_create(surface);
|
|
|
|
|
if (!view)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2022-11-22 14:28:57 +03:00
|
|
|
|
woutput = weston_shell_utils_get_focused_output(surface->compositor);
|
2022-02-14 23:57:08 +03:00
|
|
|
|
/* set the initial position and output just in case we happen to not
|
|
|
|
|
* move it around and just destroy it */
|
|
|
|
|
weston_view_set_output(view, woutput);
|
|
|
|
|
weston_view_set_position(view,
|
2022-02-04 02:47:41 +03:00
|
|
|
|
shsurf->view->geometry.pos_offset.x,
|
|
|
|
|
shsurf->view->geometry.pos_offset.y);
|
2022-02-14 23:57:08 +03:00
|
|
|
|
view->is_mapped = true;
|
|
|
|
|
|
|
|
|
|
return view;
|
|
|
|
|
}
|
|
|
|
|
|
shell: wait for desktop-shell init before fade in
On Raspberry Pi, weston-desktop-shell is so slow to start, that the
compositor has time to run the fade-in before the wallpaper is up. The
user launching Weston sees the screen flipping to black, the fbcon
fading in, and then the desktop popping up.
To fix this, wait for the weston-desktop-shell to draw
everything before starting the initial fade-in. A new request is
added to the private desktop-shell protocol to signal it. If a
desktop-shell client does not support the new request, the fade-in
happens already at bind time.
If weston-desktop-shell crashes, or does not send the 'desktop_ready'
request in 15 seconds, the compositor will fade in anyway. This should
avoid a blocked screen in case weston-desktop-shell malfunction.
shell_fade_startup() does not directly start the fade-in but schedules
an idle callback, so that the compositor can process all pending events
before starting the fade clock. Otherwise (on RPi) we risk skipping part
of the animation. Yes, it is a hack, that should have been done in
window.c and weston-desktop-shell instead.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2013-05-22 19:03:09 +04:00
|
|
|
|
static void
|
|
|
|
|
shell_fade(struct desktop_shell *shell, enum fade_type type)
|
|
|
|
|
{
|
compositor: Move fade animation out of core Weston into shell
Previously, it was impossible to override the fade in/out behavior of
Weston using a different shell, since this was implemented in core
Weston. This also led to complicated interaction between the shell and
the core when displaying lock surfaces and screensavers.
This patch starts to solve this issue by moving the fade animation out
of the core. On compositor.c, besides deleting the fade code, the idle
handler had to be changed to emit the lock signal, since it was called
from the fade_frame() function before. This causes a slight change of
behavior, since before the fade would happen with the compositor being
active, while now it is already in the idle state. That leads to the
dpms state being set when cancelling the fade with mouse movement, and
in turn, to a slight freeze with drm compositor. This problem will be
fixed in a follow up patch.
On the shell side, the fade was re-implemented in a slightly different
manner. Instead of using a custom frame function, the fade animation
from animation.c is used. The interface for starting the fade was also
changed to take the value of an enum instead of a float alpha value,
in order to improve readability.
2013-02-21 20:35:20 +04:00
|
|
|
|
float tint;
|
2016-09-09 23:16:02 +03:00
|
|
|
|
struct shell_output *shell_output;
|
compositor: Move fade animation out of core Weston into shell
Previously, it was impossible to override the fade in/out behavior of
Weston using a different shell, since this was implemented in core
Weston. This also led to complicated interaction between the shell and
the core when displaying lock surfaces and screensavers.
This patch starts to solve this issue by moving the fade animation out
of the core. On compositor.c, besides deleting the fade code, the idle
handler had to be changed to emit the lock signal, since it was called
from the fade_frame() function before. This causes a slight change of
behavior, since before the fade would happen with the compositor being
active, while now it is already in the idle state. That leads to the
dpms state being set when cancelling the fade with mouse movement, and
in turn, to a slight freeze with drm compositor. This problem will be
fixed in a follow up patch.
On the shell side, the fade was re-implemented in a slightly different
manner. Instead of using a custom frame function, the fade animation
from animation.c is used. The interface for starting the fade was also
changed to take the value of an enum instead of a float alpha value,
in order to improve readability.
2013-02-21 20:35:20 +04:00
|
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
|
case FADE_IN:
|
|
|
|
|
tint = 0.0;
|
|
|
|
|
break;
|
|
|
|
|
case FADE_OUT:
|
|
|
|
|
tint = 1.0;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
2016-08-30 22:05:27 +03:00
|
|
|
|
weston_log("shell: invalid fade type\n");
|
compositor: Move fade animation out of core Weston into shell
Previously, it was impossible to override the fade in/out behavior of
Weston using a different shell, since this was implemented in core
Weston. This also led to complicated interaction between the shell and
the core when displaying lock surfaces and screensavers.
This patch starts to solve this issue by moving the fade animation out
of the core. On compositor.c, besides deleting the fade code, the idle
handler had to be changed to emit the lock signal, since it was called
from the fade_frame() function before. This causes a slight change of
behavior, since before the fade would happen with the compositor being
active, while now it is already in the idle state. That leads to the
dpms state being set when cancelling the fade with mouse movement, and
in turn, to a slight freeze with drm compositor. This problem will be
fixed in a follow up patch.
On the shell side, the fade was re-implemented in a slightly different
manner. Instead of using a custom frame function, the fade animation
from animation.c is used. The interface for starting the fade was also
changed to take the value of an enum instead of a float alpha value,
in order to improve readability.
2013-02-21 20:35:20 +04:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-09 23:16:02 +03:00
|
|
|
|
/* Create a separate fade surface for each output */
|
|
|
|
|
wl_list_for_each(shell_output, &shell->output_list, link) {
|
|
|
|
|
shell_output->fade.type = type;
|
compositor: Move fade animation out of core Weston into shell
Previously, it was impossible to override the fade in/out behavior of
Weston using a different shell, since this was implemented in core
Weston. This also led to complicated interaction between the shell and
the core when displaying lock surfaces and screensavers.
This patch starts to solve this issue by moving the fade animation out
of the core. On compositor.c, besides deleting the fade code, the idle
handler had to be changed to emit the lock signal, since it was called
from the fade_frame() function before. This causes a slight change of
behavior, since before the fade would happen with the compositor being
active, while now it is already in the idle state. That leads to the
dpms state being set when cancelling the fade with mouse movement, and
in turn, to a slight freeze with drm compositor. This problem will be
fixed in a follow up patch.
On the shell side, the fade was re-implemented in a slightly different
manner. Instead of using a custom frame function, the fade animation
from animation.c is used. The interface for starting the fade was also
changed to take the value of an enum instead of a float alpha value,
in order to improve readability.
2013-02-21 20:35:20 +04:00
|
|
|
|
|
desktop-shell: Reuse curtains for fades
Use the common infrastructure we have, rather than open-coding again.
In changing to the common weston_curtain infrastructure which was
introduced in a previous commit, there are two small functional
derivations.
After adding the view to a layer, we explicitly call
weston_view_geometry_dirty(). This is believed to have no functional
impact, as weston_views have their geometry-dirty flag set when they are
created.
weston_surface_damage() is also called to ensure that the surface is
scheduled for a repaint. As there is currently no good common mechanic
in the common code to ensure that output repaint will occur, due to the
damage propagating outwards from the weston_surface, we are forced to
call this to predictably ensure that the output will be repainted after
we have made this change to the scene graph which should result in the
user observing the new content being repainted.
It is possible that these changes are not strictly required in order for
the correct behaviour to occur. However, it is felt that explicitly
adding these calls is perhaps the least fragile way to ensure that the
behaviour continues to be correct and breakage is not observed,
especially with both view mapping and surface damage identified as areas
for future work which could be beneficial to Weston. If it is felt that
these calls can be removed, then this is certainly possible at a later
stage.
Lastly, there are many users within desktop-shell of the common pattern
of creating a weston_curtain and inserting it into the scene graph to be
painted. These users have been an area of both theoretical concern and
real-life observed fragility and breakage recently. By making each user
follow a common and predictable pattern of usage, each user is no longer
its own special case. This should make it easier to make the
desktop-shell codebase more robust, not only simplifying the codebase,
but improving observed behaviour.
In doing this, it is hoped that future structural and interface changes
become easier to make, allowing us to improve some of the more difficult
corners of the libweston API.
Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-01-19 02:01:56 +03:00
|
|
|
|
if (shell_output->fade.curtain == NULL) {
|
|
|
|
|
shell_output->fade.curtain =
|
|
|
|
|
shell_fade_create_view_for_output(shell, shell_output);
|
|
|
|
|
if (!shell_output->fade.curtain)
|
2016-09-09 23:16:02 +03:00
|
|
|
|
continue;
|
compositor: Move fade animation out of core Weston into shell
Previously, it was impossible to override the fade in/out behavior of
Weston using a different shell, since this was implemented in core
Weston. This also led to complicated interaction between the shell and
the core when displaying lock surfaces and screensavers.
This patch starts to solve this issue by moving the fade animation out
of the core. On compositor.c, besides deleting the fade code, the idle
handler had to be changed to emit the lock signal, since it was called
from the fade_frame() function before. This causes a slight change of
behavior, since before the fade would happen with the compositor being
active, while now it is already in the idle state. That leads to the
dpms state being set when cancelling the fade with mouse movement, and
in turn, to a slight freeze with drm compositor. This problem will be
fixed in a follow up patch.
On the shell side, the fade was re-implemented in a slightly different
manner. Instead of using a custom frame function, the fade animation
from animation.c is used. The interface for starting the fade was also
changed to take the value of an enum instead of a float alpha value,
in order to improve readability.
2013-02-21 20:35:20 +04:00
|
|
|
|
|
desktop-shell: Reuse curtains for fades
Use the common infrastructure we have, rather than open-coding again.
In changing to the common weston_curtain infrastructure which was
introduced in a previous commit, there are two small functional
derivations.
After adding the view to a layer, we explicitly call
weston_view_geometry_dirty(). This is believed to have no functional
impact, as weston_views have their geometry-dirty flag set when they are
created.
weston_surface_damage() is also called to ensure that the surface is
scheduled for a repaint. As there is currently no good common mechanic
in the common code to ensure that output repaint will occur, due to the
damage propagating outwards from the weston_surface, we are forced to
call this to predictably ensure that the output will be repainted after
we have made this change to the scene graph which should result in the
user observing the new content being repainted.
It is possible that these changes are not strictly required in order for
the correct behaviour to occur. However, it is felt that explicitly
adding these calls is perhaps the least fragile way to ensure that the
behaviour continues to be correct and breakage is not observed,
especially with both view mapping and surface damage identified as areas
for future work which could be beneficial to Weston. If it is felt that
these calls can be removed, then this is certainly possible at a later
stage.
Lastly, there are many users within desktop-shell of the common pattern
of creating a weston_curtain and inserting it into the scene graph to be
painted. These users have been an area of both theoretical concern and
real-life observed fragility and breakage recently. By making each user
follow a common and predictable pattern of usage, each user is no longer
its own special case. This should make it easier to make the
desktop-shell codebase more robust, not only simplifying the codebase,
but improving observed behaviour.
In doing this, it is hoped that future structural and interface changes
become easier to make, allowing us to improve some of the more difficult
corners of the libweston API.
Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-01-19 02:01:56 +03:00
|
|
|
|
shell_output->fade.curtain->view->alpha = 1.0 - tint;
|
|
|
|
|
weston_view_update_transform(shell_output->fade.curtain->view);
|
2016-09-09 23:16:02 +03:00
|
|
|
|
}
|
compositor: Move fade animation out of core Weston into shell
Previously, it was impossible to override the fade in/out behavior of
Weston using a different shell, since this was implemented in core
Weston. This also led to complicated interaction between the shell and
the core when displaying lock surfaces and screensavers.
This patch starts to solve this issue by moving the fade animation out
of the core. On compositor.c, besides deleting the fade code, the idle
handler had to be changed to emit the lock signal, since it was called
from the fade_frame() function before. This causes a slight change of
behavior, since before the fade would happen with the compositor being
active, while now it is already in the idle state. That leads to the
dpms state being set when cancelling the fade with mouse movement, and
in turn, to a slight freeze with drm compositor. This problem will be
fixed in a follow up patch.
On the shell side, the fade was re-implemented in a slightly different
manner. Instead of using a custom frame function, the fade animation
from animation.c is used. The interface for starting the fade was also
changed to take the value of an enum instead of a float alpha value,
in order to improve readability.
2013-02-21 20:35:20 +04:00
|
|
|
|
|
desktop-shell: Reuse curtains for fades
Use the common infrastructure we have, rather than open-coding again.
In changing to the common weston_curtain infrastructure which was
introduced in a previous commit, there are two small functional
derivations.
After adding the view to a layer, we explicitly call
weston_view_geometry_dirty(). This is believed to have no functional
impact, as weston_views have their geometry-dirty flag set when they are
created.
weston_surface_damage() is also called to ensure that the surface is
scheduled for a repaint. As there is currently no good common mechanic
in the common code to ensure that output repaint will occur, due to the
damage propagating outwards from the weston_surface, we are forced to
call this to predictably ensure that the output will be repainted after
we have made this change to the scene graph which should result in the
user observing the new content being repainted.
It is possible that these changes are not strictly required in order for
the correct behaviour to occur. However, it is felt that explicitly
adding these calls is perhaps the least fragile way to ensure that the
behaviour continues to be correct and breakage is not observed,
especially with both view mapping and surface damage identified as areas
for future work which could be beneficial to Weston. If it is felt that
these calls can be removed, then this is certainly possible at a later
stage.
Lastly, there are many users within desktop-shell of the common pattern
of creating a weston_curtain and inserting it into the scene graph to be
painted. These users have been an area of both theoretical concern and
real-life observed fragility and breakage recently. By making each user
follow a common and predictable pattern of usage, each user is no longer
its own special case. This should make it easier to make the
desktop-shell codebase more robust, not only simplifying the codebase,
but improving observed behaviour.
In doing this, it is hoped that future structural and interface changes
become easier to make, allowing us to improve some of the more difficult
corners of the libweston API.
Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-01-19 02:01:56 +03:00
|
|
|
|
if (shell_output->fade.curtain->view->output == NULL) {
|
2016-09-09 23:16:02 +03:00
|
|
|
|
/* If the black view gets a NULL output, we lost the
|
|
|
|
|
* last output and we'll just cancel the fade. This
|
|
|
|
|
* happens when you close the last window under the
|
|
|
|
|
* X11 or Wayland backends. */
|
|
|
|
|
shell->locked = false;
|
2022-11-22 14:28:57 +03:00
|
|
|
|
weston_shell_utils_curtain_destroy(shell_output->fade.curtain);
|
desktop-shell: Reuse curtains for fades
Use the common infrastructure we have, rather than open-coding again.
In changing to the common weston_curtain infrastructure which was
introduced in a previous commit, there are two small functional
derivations.
After adding the view to a layer, we explicitly call
weston_view_geometry_dirty(). This is believed to have no functional
impact, as weston_views have their geometry-dirty flag set when they are
created.
weston_surface_damage() is also called to ensure that the surface is
scheduled for a repaint. As there is currently no good common mechanic
in the common code to ensure that output repaint will occur, due to the
damage propagating outwards from the weston_surface, we are forced to
call this to predictably ensure that the output will be repainted after
we have made this change to the scene graph which should result in the
user observing the new content being repainted.
It is possible that these changes are not strictly required in order for
the correct behaviour to occur. However, it is felt that explicitly
adding these calls is perhaps the least fragile way to ensure that the
behaviour continues to be correct and breakage is not observed,
especially with both view mapping and surface damage identified as areas
for future work which could be beneficial to Weston. If it is felt that
these calls can be removed, then this is certainly possible at a later
stage.
Lastly, there are many users within desktop-shell of the common pattern
of creating a weston_curtain and inserting it into the scene graph to be
painted. These users have been an area of both theoretical concern and
real-life observed fragility and breakage recently. By making each user
follow a common and predictable pattern of usage, each user is no longer
its own special case. This should make it easier to make the
desktop-shell codebase more robust, not only simplifying the codebase,
but improving observed behaviour.
In doing this, it is hoped that future structural and interface changes
become easier to make, allowing us to improve some of the more difficult
corners of the libweston API.
Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-01-19 02:01:56 +03:00
|
|
|
|
shell_output->fade.curtain = NULL;
|
2016-09-09 23:16:02 +03:00
|
|
|
|
} else if (shell_output->fade.animation) {
|
|
|
|
|
weston_fade_update(shell_output->fade.animation, tint);
|
|
|
|
|
} else {
|
|
|
|
|
shell_output->fade.animation =
|
desktop-shell: Reuse curtains for fades
Use the common infrastructure we have, rather than open-coding again.
In changing to the common weston_curtain infrastructure which was
introduced in a previous commit, there are two small functional
derivations.
After adding the view to a layer, we explicitly call
weston_view_geometry_dirty(). This is believed to have no functional
impact, as weston_views have their geometry-dirty flag set when they are
created.
weston_surface_damage() is also called to ensure that the surface is
scheduled for a repaint. As there is currently no good common mechanic
in the common code to ensure that output repaint will occur, due to the
damage propagating outwards from the weston_surface, we are forced to
call this to predictably ensure that the output will be repainted after
we have made this change to the scene graph which should result in the
user observing the new content being repainted.
It is possible that these changes are not strictly required in order for
the correct behaviour to occur. However, it is felt that explicitly
adding these calls is perhaps the least fragile way to ensure that the
behaviour continues to be correct and breakage is not observed,
especially with both view mapping and surface damage identified as areas
for future work which could be beneficial to Weston. If it is felt that
these calls can be removed, then this is certainly possible at a later
stage.
Lastly, there are many users within desktop-shell of the common pattern
of creating a weston_curtain and inserting it into the scene graph to be
painted. These users have been an area of both theoretical concern and
real-life observed fragility and breakage recently. By making each user
follow a common and predictable pattern of usage, each user is no longer
its own special case. This should make it easier to make the
desktop-shell codebase more robust, not only simplifying the codebase,
but improving observed behaviour.
In doing this, it is hoped that future structural and interface changes
become easier to make, allowing us to improve some of the more difficult
corners of the libweston API.
Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-01-19 02:01:56 +03:00
|
|
|
|
weston_fade_run(shell_output->fade.curtain->view,
|
2016-09-09 23:16:02 +03:00
|
|
|
|
1.0 - tint, tint, 300.0,
|
|
|
|
|
shell_fade_done_for_output, shell_output);
|
|
|
|
|
}
|
2014-01-20 09:48:10 +04:00
|
|
|
|
}
|
compositor: Move fade animation out of core Weston into shell
Previously, it was impossible to override the fade in/out behavior of
Weston using a different shell, since this was implemented in core
Weston. This also led to complicated interaction between the shell and
the core when displaying lock surfaces and screensavers.
This patch starts to solve this issue by moving the fade animation out
of the core. On compositor.c, besides deleting the fade code, the idle
handler had to be changed to emit the lock signal, since it was called
from the fade_frame() function before. This causes a slight change of
behavior, since before the fade would happen with the compositor being
active, while now it is already in the idle state. That leads to the
dpms state being set when cancelling the fade with mouse movement, and
in turn, to a slight freeze with drm compositor. This problem will be
fixed in a follow up patch.
On the shell side, the fade was re-implemented in a slightly different
manner. Instead of using a custom frame function, the fade animation
from animation.c is used. The interface for starting the fade was also
changed to take the value of an enum instead of a float alpha value,
in order to improve readability.
2013-02-21 20:35:20 +04:00
|
|
|
|
}
|
|
|
|
|
|
shell: wait for desktop-shell init before fade in
On Raspberry Pi, weston-desktop-shell is so slow to start, that the
compositor has time to run the fade-in before the wallpaper is up. The
user launching Weston sees the screen flipping to black, the fbcon
fading in, and then the desktop popping up.
To fix this, wait for the weston-desktop-shell to draw
everything before starting the initial fade-in. A new request is
added to the private desktop-shell protocol to signal it. If a
desktop-shell client does not support the new request, the fade-in
happens already at bind time.
If weston-desktop-shell crashes, or does not send the 'desktop_ready'
request in 15 seconds, the compositor will fade in anyway. This should
avoid a blocked screen in case weston-desktop-shell malfunction.
shell_fade_startup() does not directly start the fade-in but schedules
an idle callback, so that the compositor can process all pending events
before starting the fade clock. Otherwise (on RPi) we risk skipping part
of the animation. Yes, it is a hack, that should have been done in
window.c and weston-desktop-shell instead.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2013-05-22 19:03:09 +04:00
|
|
|
|
static void
|
|
|
|
|
do_shell_fade_startup(void *data)
|
|
|
|
|
{
|
|
|
|
|
struct desktop_shell *shell = data;
|
2016-09-09 23:16:02 +03:00
|
|
|
|
struct shell_output *shell_output;
|
shell: wait for desktop-shell init before fade in
On Raspberry Pi, weston-desktop-shell is so slow to start, that the
compositor has time to run the fade-in before the wallpaper is up. The
user launching Weston sees the screen flipping to black, the fbcon
fading in, and then the desktop popping up.
To fix this, wait for the weston-desktop-shell to draw
everything before starting the initial fade-in. A new request is
added to the private desktop-shell protocol to signal it. If a
desktop-shell client does not support the new request, the fade-in
happens already at bind time.
If weston-desktop-shell crashes, or does not send the 'desktop_ready'
request in 15 seconds, the compositor will fade in anyway. This should
avoid a blocked screen in case weston-desktop-shell malfunction.
shell_fade_startup() does not directly start the fade-in but schedules
an idle callback, so that the compositor can process all pending events
before starting the fade clock. Otherwise (on RPi) we risk skipping part
of the animation. Yes, it is a hack, that should have been done in
window.c and weston-desktop-shell instead.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2013-05-22 19:03:09 +04:00
|
|
|
|
|
2015-05-26 11:54:52 +03:00
|
|
|
|
if (shell->startup_animation_type == ANIMATION_FADE) {
|
2013-10-16 22:38:24 +04:00
|
|
|
|
shell_fade(shell, FADE_IN);
|
2015-05-26 11:54:52 +03:00
|
|
|
|
} else {
|
|
|
|
|
weston_log("desktop shell: "
|
|
|
|
|
"unexpected fade-in animation type %d\n",
|
|
|
|
|
shell->startup_animation_type);
|
2016-09-09 23:16:02 +03:00
|
|
|
|
wl_list_for_each(shell_output, &shell->output_list, link) {
|
2022-11-22 14:28:57 +03:00
|
|
|
|
weston_shell_utils_curtain_destroy(shell_output->fade.curtain);
|
desktop-shell: Reuse curtains for fades
Use the common infrastructure we have, rather than open-coding again.
In changing to the common weston_curtain infrastructure which was
introduced in a previous commit, there are two small functional
derivations.
After adding the view to a layer, we explicitly call
weston_view_geometry_dirty(). This is believed to have no functional
impact, as weston_views have their geometry-dirty flag set when they are
created.
weston_surface_damage() is also called to ensure that the surface is
scheduled for a repaint. As there is currently no good common mechanic
in the common code to ensure that output repaint will occur, due to the
damage propagating outwards from the weston_surface, we are forced to
call this to predictably ensure that the output will be repainted after
we have made this change to the scene graph which should result in the
user observing the new content being repainted.
It is possible that these changes are not strictly required in order for
the correct behaviour to occur. However, it is felt that explicitly
adding these calls is perhaps the least fragile way to ensure that the
behaviour continues to be correct and breakage is not observed,
especially with both view mapping and surface damage identified as areas
for future work which could be beneficial to Weston. If it is felt that
these calls can be removed, then this is certainly possible at a later
stage.
Lastly, there are many users within desktop-shell of the common pattern
of creating a weston_curtain and inserting it into the scene graph to be
painted. These users have been an area of both theoretical concern and
real-life observed fragility and breakage recently. By making each user
follow a common and predictable pattern of usage, each user is no longer
its own special case. This should make it easier to make the
desktop-shell codebase more robust, not only simplifying the codebase,
but improving observed behaviour.
In doing this, it is hoped that future structural and interface changes
become easier to make, allowing us to improve some of the more difficult
corners of the libweston API.
Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-01-19 02:01:56 +03:00
|
|
|
|
shell_output->fade.curtain = NULL;
|
2016-09-09 23:16:02 +03:00
|
|
|
|
}
|
2013-10-16 22:38:24 +04:00
|
|
|
|
}
|
shell: wait for desktop-shell init before fade in
On Raspberry Pi, weston-desktop-shell is so slow to start, that the
compositor has time to run the fade-in before the wallpaper is up. The
user launching Weston sees the screen flipping to black, the fbcon
fading in, and then the desktop popping up.
To fix this, wait for the weston-desktop-shell to draw
everything before starting the initial fade-in. A new request is
added to the private desktop-shell protocol to signal it. If a
desktop-shell client does not support the new request, the fade-in
happens already at bind time.
If weston-desktop-shell crashes, or does not send the 'desktop_ready'
request in 15 seconds, the compositor will fade in anyway. This should
avoid a blocked screen in case weston-desktop-shell malfunction.
shell_fade_startup() does not directly start the fade-in but schedules
an idle callback, so that the compositor can process all pending events
before starting the fade clock. Otherwise (on RPi) we risk skipping part
of the animation. Yes, it is a hack, that should have been done in
window.c and weston-desktop-shell instead.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2013-05-22 19:03:09 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
shell_fade_startup(struct desktop_shell *shell)
|
|
|
|
|
{
|
|
|
|
|
struct wl_event_loop *loop;
|
2016-09-09 23:16:02 +03:00
|
|
|
|
struct shell_output *shell_output;
|
|
|
|
|
bool has_fade = false;
|
shell: wait for desktop-shell init before fade in
On Raspberry Pi, weston-desktop-shell is so slow to start, that the
compositor has time to run the fade-in before the wallpaper is up. The
user launching Weston sees the screen flipping to black, the fbcon
fading in, and then the desktop popping up.
To fix this, wait for the weston-desktop-shell to draw
everything before starting the initial fade-in. A new request is
added to the private desktop-shell protocol to signal it. If a
desktop-shell client does not support the new request, the fade-in
happens already at bind time.
If weston-desktop-shell crashes, or does not send the 'desktop_ready'
request in 15 seconds, the compositor will fade in anyway. This should
avoid a blocked screen in case weston-desktop-shell malfunction.
shell_fade_startup() does not directly start the fade-in but schedules
an idle callback, so that the compositor can process all pending events
before starting the fade clock. Otherwise (on RPi) we risk skipping part
of the animation. Yes, it is a hack, that should have been done in
window.c and weston-desktop-shell instead.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2013-05-22 19:03:09 +04:00
|
|
|
|
|
2016-09-09 23:16:02 +03:00
|
|
|
|
wl_list_for_each(shell_output, &shell->output_list, link) {
|
|
|
|
|
if (!shell_output->fade.startup_timer)
|
|
|
|
|
continue;
|
shell: wait for desktop-shell init before fade in
On Raspberry Pi, weston-desktop-shell is so slow to start, that the
compositor has time to run the fade-in before the wallpaper is up. The
user launching Weston sees the screen flipping to black, the fbcon
fading in, and then the desktop popping up.
To fix this, wait for the weston-desktop-shell to draw
everything before starting the initial fade-in. A new request is
added to the private desktop-shell protocol to signal it. If a
desktop-shell client does not support the new request, the fade-in
happens already at bind time.
If weston-desktop-shell crashes, or does not send the 'desktop_ready'
request in 15 seconds, the compositor will fade in anyway. This should
avoid a blocked screen in case weston-desktop-shell malfunction.
shell_fade_startup() does not directly start the fade-in but schedules
an idle callback, so that the compositor can process all pending events
before starting the fade clock. Otherwise (on RPi) we risk skipping part
of the animation. Yes, it is a hack, that should have been done in
window.c and weston-desktop-shell instead.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2013-05-22 19:03:09 +04:00
|
|
|
|
|
2016-09-09 23:16:02 +03:00
|
|
|
|
wl_event_source_remove(shell_output->fade.startup_timer);
|
|
|
|
|
shell_output->fade.startup_timer = NULL;
|
|
|
|
|
has_fade = true;
|
|
|
|
|
}
|
shell: wait for desktop-shell init before fade in
On Raspberry Pi, weston-desktop-shell is so slow to start, that the
compositor has time to run the fade-in before the wallpaper is up. The
user launching Weston sees the screen flipping to black, the fbcon
fading in, and then the desktop popping up.
To fix this, wait for the weston-desktop-shell to draw
everything before starting the initial fade-in. A new request is
added to the private desktop-shell protocol to signal it. If a
desktop-shell client does not support the new request, the fade-in
happens already at bind time.
If weston-desktop-shell crashes, or does not send the 'desktop_ready'
request in 15 seconds, the compositor will fade in anyway. This should
avoid a blocked screen in case weston-desktop-shell malfunction.
shell_fade_startup() does not directly start the fade-in but schedules
an idle callback, so that the compositor can process all pending events
before starting the fade clock. Otherwise (on RPi) we risk skipping part
of the animation. Yes, it is a hack, that should have been done in
window.c and weston-desktop-shell instead.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2013-05-22 19:03:09 +04:00
|
|
|
|
|
2016-09-09 23:16:02 +03:00
|
|
|
|
if (has_fade) {
|
|
|
|
|
loop = wl_display_get_event_loop(shell->compositor->wl_display);
|
|
|
|
|
wl_event_loop_add_idle(loop, do_shell_fade_startup, shell);
|
|
|
|
|
}
|
shell: wait for desktop-shell init before fade in
On Raspberry Pi, weston-desktop-shell is so slow to start, that the
compositor has time to run the fade-in before the wallpaper is up. The
user launching Weston sees the screen flipping to black, the fbcon
fading in, and then the desktop popping up.
To fix this, wait for the weston-desktop-shell to draw
everything before starting the initial fade-in. A new request is
added to the private desktop-shell protocol to signal it. If a
desktop-shell client does not support the new request, the fade-in
happens already at bind time.
If weston-desktop-shell crashes, or does not send the 'desktop_ready'
request in 15 seconds, the compositor will fade in anyway. This should
avoid a blocked screen in case weston-desktop-shell malfunction.
shell_fade_startup() does not directly start the fade-in but schedules
an idle callback, so that the compositor can process all pending events
before starting the fade clock. Otherwise (on RPi) we risk skipping part
of the animation. Yes, it is a hack, that should have been done in
window.c and weston-desktop-shell instead.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2013-05-22 19:03:09 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
fade_startup_timeout(void *data)
|
|
|
|
|
{
|
|
|
|
|
struct desktop_shell *shell = data;
|
|
|
|
|
|
|
|
|
|
shell_fade_startup(shell);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
shell_fade_init(struct desktop_shell *shell)
|
|
|
|
|
{
|
|
|
|
|
/* Make compositor output all black, and wait for the desktop-shell
|
|
|
|
|
* client to signal it is ready, then fade in. The timer triggers a
|
|
|
|
|
* fade-in, in case the desktop-shell client takes too long.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
struct wl_event_loop *loop;
|
2016-09-09 23:16:02 +03:00
|
|
|
|
struct shell_output *shell_output;
|
2015-05-26 11:54:52 +03:00
|
|
|
|
|
2016-08-30 22:05:27 +03:00
|
|
|
|
if (shell->startup_animation_type == ANIMATION_NONE)
|
|
|
|
|
return;
|
2016-08-11 03:25:24 +03:00
|
|
|
|
|
2016-09-09 23:16:02 +03:00
|
|
|
|
wl_list_for_each(shell_output, &shell->output_list, link) {
|
desktop-shell: Reuse curtains for fades
Use the common infrastructure we have, rather than open-coding again.
In changing to the common weston_curtain infrastructure which was
introduced in a previous commit, there are two small functional
derivations.
After adding the view to a layer, we explicitly call
weston_view_geometry_dirty(). This is believed to have no functional
impact, as weston_views have their geometry-dirty flag set when they are
created.
weston_surface_damage() is also called to ensure that the surface is
scheduled for a repaint. As there is currently no good common mechanic
in the common code to ensure that output repaint will occur, due to the
damage propagating outwards from the weston_surface, we are forced to
call this to predictably ensure that the output will be repainted after
we have made this change to the scene graph which should result in the
user observing the new content being repainted.
It is possible that these changes are not strictly required in order for
the correct behaviour to occur. However, it is felt that explicitly
adding these calls is perhaps the least fragile way to ensure that the
behaviour continues to be correct and breakage is not observed,
especially with both view mapping and surface damage identified as areas
for future work which could be beneficial to Weston. If it is felt that
these calls can be removed, then this is certainly possible at a later
stage.
Lastly, there are many users within desktop-shell of the common pattern
of creating a weston_curtain and inserting it into the scene graph to be
painted. These users have been an area of both theoretical concern and
real-life observed fragility and breakage recently. By making each user
follow a common and predictable pattern of usage, each user is no longer
its own special case. This should make it easier to make the
desktop-shell codebase more robust, not only simplifying the codebase,
but improving observed behaviour.
In doing this, it is hoped that future structural and interface changes
become easier to make, allowing us to improve some of the more difficult
corners of the libweston API.
Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-01-19 02:01:56 +03:00
|
|
|
|
if (shell_output->fade.curtain != NULL) {
|
2016-09-09 23:16:02 +03:00
|
|
|
|
weston_log("%s: warning: fade surface already exists\n",
|
|
|
|
|
__func__);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
desktop-shell: Reuse curtains for fades
Use the common infrastructure we have, rather than open-coding again.
In changing to the common weston_curtain infrastructure which was
introduced in a previous commit, there are two small functional
derivations.
After adding the view to a layer, we explicitly call
weston_view_geometry_dirty(). This is believed to have no functional
impact, as weston_views have their geometry-dirty flag set when they are
created.
weston_surface_damage() is also called to ensure that the surface is
scheduled for a repaint. As there is currently no good common mechanic
in the common code to ensure that output repaint will occur, due to the
damage propagating outwards from the weston_surface, we are forced to
call this to predictably ensure that the output will be repainted after
we have made this change to the scene graph which should result in the
user observing the new content being repainted.
It is possible that these changes are not strictly required in order for
the correct behaviour to occur. However, it is felt that explicitly
adding these calls is perhaps the least fragile way to ensure that the
behaviour continues to be correct and breakage is not observed,
especially with both view mapping and surface damage identified as areas
for future work which could be beneficial to Weston. If it is felt that
these calls can be removed, then this is certainly possible at a later
stage.
Lastly, there are many users within desktop-shell of the common pattern
of creating a weston_curtain and inserting it into the scene graph to be
painted. These users have been an area of both theoretical concern and
real-life observed fragility and breakage recently. By making each user
follow a common and predictable pattern of usage, each user is no longer
its own special case. This should make it easier to make the
desktop-shell codebase more robust, not only simplifying the codebase,
but improving observed behaviour.
In doing this, it is hoped that future structural and interface changes
become easier to make, allowing us to improve some of the more difficult
corners of the libweston API.
Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-01-19 02:01:56 +03:00
|
|
|
|
shell_output->fade.curtain =
|
|
|
|
|
shell_fade_create_view_for_output(shell, shell_output);
|
|
|
|
|
if (!shell_output->fade.curtain)
|
2016-09-09 23:16:02 +03:00
|
|
|
|
continue;
|
shell: wait for desktop-shell init before fade in
On Raspberry Pi, weston-desktop-shell is so slow to start, that the
compositor has time to run the fade-in before the wallpaper is up. The
user launching Weston sees the screen flipping to black, the fbcon
fading in, and then the desktop popping up.
To fix this, wait for the weston-desktop-shell to draw
everything before starting the initial fade-in. A new request is
added to the private desktop-shell protocol to signal it. If a
desktop-shell client does not support the new request, the fade-in
happens already at bind time.
If weston-desktop-shell crashes, or does not send the 'desktop_ready'
request in 15 seconds, the compositor will fade in anyway. This should
avoid a blocked screen in case weston-desktop-shell malfunction.
shell_fade_startup() does not directly start the fade-in but schedules
an idle callback, so that the compositor can process all pending events
before starting the fade clock. Otherwise (on RPi) we risk skipping part
of the animation. Yes, it is a hack, that should have been done in
window.c and weston-desktop-shell instead.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2013-05-22 19:03:09 +04:00
|
|
|
|
|
desktop-shell: Reuse curtains for fades
Use the common infrastructure we have, rather than open-coding again.
In changing to the common weston_curtain infrastructure which was
introduced in a previous commit, there are two small functional
derivations.
After adding the view to a layer, we explicitly call
weston_view_geometry_dirty(). This is believed to have no functional
impact, as weston_views have their geometry-dirty flag set when they are
created.
weston_surface_damage() is also called to ensure that the surface is
scheduled for a repaint. As there is currently no good common mechanic
in the common code to ensure that output repaint will occur, due to the
damage propagating outwards from the weston_surface, we are forced to
call this to predictably ensure that the output will be repainted after
we have made this change to the scene graph which should result in the
user observing the new content being repainted.
It is possible that these changes are not strictly required in order for
the correct behaviour to occur. However, it is felt that explicitly
adding these calls is perhaps the least fragile way to ensure that the
behaviour continues to be correct and breakage is not observed,
especially with both view mapping and surface damage identified as areas
for future work which could be beneficial to Weston. If it is felt that
these calls can be removed, then this is certainly possible at a later
stage.
Lastly, there are many users within desktop-shell of the common pattern
of creating a weston_curtain and inserting it into the scene graph to be
painted. These users have been an area of both theoretical concern and
real-life observed fragility and breakage recently. By making each user
follow a common and predictable pattern of usage, each user is no longer
its own special case. This should make it easier to make the
desktop-shell codebase more robust, not only simplifying the codebase,
but improving observed behaviour.
In doing this, it is hoped that future structural and interface changes
become easier to make, allowing us to improve some of the more difficult
corners of the libweston API.
Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-01-19 02:01:56 +03:00
|
|
|
|
weston_view_update_transform(shell_output->fade.curtain->view);
|
|
|
|
|
weston_surface_damage(shell_output->fade.curtain->view->surface);
|
shell: wait for desktop-shell init before fade in
On Raspberry Pi, weston-desktop-shell is so slow to start, that the
compositor has time to run the fade-in before the wallpaper is up. The
user launching Weston sees the screen flipping to black, the fbcon
fading in, and then the desktop popping up.
To fix this, wait for the weston-desktop-shell to draw
everything before starting the initial fade-in. A new request is
added to the private desktop-shell protocol to signal it. If a
desktop-shell client does not support the new request, the fade-in
happens already at bind time.
If weston-desktop-shell crashes, or does not send the 'desktop_ready'
request in 15 seconds, the compositor will fade in anyway. This should
avoid a blocked screen in case weston-desktop-shell malfunction.
shell_fade_startup() does not directly start the fade-in but schedules
an idle callback, so that the compositor can process all pending events
before starting the fade clock. Otherwise (on RPi) we risk skipping part
of the animation. Yes, it is a hack, that should have been done in
window.c and weston-desktop-shell instead.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2013-05-22 19:03:09 +04:00
|
|
|
|
|
2016-09-09 23:16:02 +03:00
|
|
|
|
loop = wl_display_get_event_loop(shell->compositor->wl_display);
|
|
|
|
|
shell_output->fade.startup_timer =
|
|
|
|
|
wl_event_loop_add_timer(loop, fade_startup_timeout, shell);
|
|
|
|
|
wl_event_source_timer_update(shell_output->fade.startup_timer, 15000);
|
|
|
|
|
}
|
shell: wait for desktop-shell init before fade in
On Raspberry Pi, weston-desktop-shell is so slow to start, that the
compositor has time to run the fade-in before the wallpaper is up. The
user launching Weston sees the screen flipping to black, the fbcon
fading in, and then the desktop popping up.
To fix this, wait for the weston-desktop-shell to draw
everything before starting the initial fade-in. A new request is
added to the private desktop-shell protocol to signal it. If a
desktop-shell client does not support the new request, the fade-in
happens already at bind time.
If weston-desktop-shell crashes, or does not send the 'desktop_ready'
request in 15 seconds, the compositor will fade in anyway. This should
avoid a blocked screen in case weston-desktop-shell malfunction.
shell_fade_startup() does not directly start the fade-in but schedules
an idle callback, so that the compositor can process all pending events
before starting the fade clock. Otherwise (on RPi) we risk skipping part
of the animation. Yes, it is a hack, that should have been done in
window.c and weston-desktop-shell instead.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2013-05-22 19:03:09 +04:00
|
|
|
|
}
|
|
|
|
|
|
compositor: Move fade animation out of core Weston into shell
Previously, it was impossible to override the fade in/out behavior of
Weston using a different shell, since this was implemented in core
Weston. This also led to complicated interaction between the shell and
the core when displaying lock surfaces and screensavers.
This patch starts to solve this issue by moving the fade animation out
of the core. On compositor.c, besides deleting the fade code, the idle
handler had to be changed to emit the lock signal, since it was called
from the fade_frame() function before. This causes a slight change of
behavior, since before the fade would happen with the compositor being
active, while now it is already in the idle state. That leads to the
dpms state being set when cancelling the fade with mouse movement, and
in turn, to a slight freeze with drm compositor. This problem will be
fixed in a follow up patch.
On the shell side, the fade was re-implemented in a slightly different
manner. Instead of using a custom frame function, the fade animation
from animation.c is used. The interface for starting the fade was also
changed to take the value of an enum instead of a float alpha value,
in order to improve readability.
2013-02-21 20:35:20 +04:00
|
|
|
|
static void
|
2013-02-21 20:35:23 +04:00
|
|
|
|
idle_handler(struct wl_listener *listener, void *data)
|
compositor: Move fade animation out of core Weston into shell
Previously, it was impossible to override the fade in/out behavior of
Weston using a different shell, since this was implemented in core
Weston. This also led to complicated interaction between the shell and
the core when displaying lock surfaces and screensavers.
This patch starts to solve this issue by moving the fade animation out
of the core. On compositor.c, besides deleting the fade code, the idle
handler had to be changed to emit the lock signal, since it was called
from the fade_frame() function before. This causes a slight change of
behavior, since before the fade would happen with the compositor being
active, while now it is already in the idle state. That leads to the
dpms state being set when cancelling the fade with mouse movement, and
in turn, to a slight freeze with drm compositor. This problem will be
fixed in a follow up patch.
On the shell side, the fade was re-implemented in a slightly different
manner. Instead of using a custom frame function, the fade animation
from animation.c is used. The interface for starting the fade was also
changed to take the value of an enum instead of a float alpha value,
in order to improve readability.
2013-02-21 20:35:20 +04:00
|
|
|
|
{
|
|
|
|
|
struct desktop_shell *shell =
|
2013-02-21 20:35:23 +04:00
|
|
|
|
container_of(listener, struct desktop_shell, idle_listener);
|
2014-01-18 04:22:50 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
struct weston_seat *seat;
|
2015-08-01 00:55:32 +03:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
wl_list_for_each(seat, &shell->compositor->seat_list, link)
|
|
|
|
|
weston_seat_break_desktop_grabs(seat);
|
compositor: Move fade animation out of core Weston into shell
Previously, it was impossible to override the fade in/out behavior of
Weston using a different shell, since this was implemented in core
Weston. This also led to complicated interaction between the shell and
the core when displaying lock surfaces and screensavers.
This patch starts to solve this issue by moving the fade animation out
of the core. On compositor.c, besides deleting the fade code, the idle
handler had to be changed to emit the lock signal, since it was called
from the fade_frame() function before. This causes a slight change of
behavior, since before the fade would happen with the compositor being
active, while now it is already in the idle state. That leads to the
dpms state being set when cancelling the fade with mouse movement, and
in turn, to a slight freeze with drm compositor. This problem will be
fixed in a follow up patch.
On the shell side, the fade was re-implemented in a slightly different
manner. Instead of using a custom frame function, the fade animation
from animation.c is used. The interface for starting the fade was also
changed to take the value of an enum instead of a float alpha value,
in order to improve readability.
2013-02-21 20:35:20 +04:00
|
|
|
|
|
|
|
|
|
shell_fade(shell, FADE_OUT);
|
2016-09-09 23:16:02 +03:00
|
|
|
|
/* lock() is called from shell_fade_done_for_output() */
|
compositor: Move fade animation out of core Weston into shell
Previously, it was impossible to override the fade in/out behavior of
Weston using a different shell, since this was implemented in core
Weston. This also led to complicated interaction between the shell and
the core when displaying lock surfaces and screensavers.
This patch starts to solve this issue by moving the fade animation out
of the core. On compositor.c, besides deleting the fade code, the idle
handler had to be changed to emit the lock signal, since it was called
from the fade_frame() function before. This causes a slight change of
behavior, since before the fade would happen with the compositor being
active, while now it is already in the idle state. That leads to the
dpms state being set when cancelling the fade with mouse movement, and
in turn, to a slight freeze with drm compositor. This problem will be
fixed in a follow up patch.
On the shell side, the fade was re-implemented in a slightly different
manner. Instead of using a custom frame function, the fade animation
from animation.c is used. The interface for starting the fade was also
changed to take the value of an enum instead of a float alpha value,
in order to improve readability.
2013-02-21 20:35:20 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2013-02-21 20:35:23 +04:00
|
|
|
|
wake_handler(struct wl_listener *listener, void *data)
|
compositor: Move fade animation out of core Weston into shell
Previously, it was impossible to override the fade in/out behavior of
Weston using a different shell, since this was implemented in core
Weston. This also led to complicated interaction between the shell and
the core when displaying lock surfaces and screensavers.
This patch starts to solve this issue by moving the fade animation out
of the core. On compositor.c, besides deleting the fade code, the idle
handler had to be changed to emit the lock signal, since it was called
from the fade_frame() function before. This causes a slight change of
behavior, since before the fade would happen with the compositor being
active, while now it is already in the idle state. That leads to the
dpms state being set when cancelling the fade with mouse movement, and
in turn, to a slight freeze with drm compositor. This problem will be
fixed in a follow up patch.
On the shell side, the fade was re-implemented in a slightly different
manner. Instead of using a custom frame function, the fade animation
from animation.c is used. The interface for starting the fade was also
changed to take the value of an enum instead of a float alpha value,
in order to improve readability.
2013-02-21 20:35:20 +04:00
|
|
|
|
{
|
|
|
|
|
struct desktop_shell *shell =
|
2013-02-21 20:35:23 +04:00
|
|
|
|
container_of(listener, struct desktop_shell, wake_listener);
|
compositor: Move fade animation out of core Weston into shell
Previously, it was impossible to override the fade in/out behavior of
Weston using a different shell, since this was implemented in core
Weston. This also led to complicated interaction between the shell and
the core when displaying lock surfaces and screensavers.
This patch starts to solve this issue by moving the fade animation out
of the core. On compositor.c, besides deleting the fade code, the idle
handler had to be changed to emit the lock signal, since it was called
from the fade_frame() function before. This causes a slight change of
behavior, since before the fade would happen with the compositor being
active, while now it is already in the idle state. That leads to the
dpms state being set when cancelling the fade with mouse movement, and
in turn, to a slight freeze with drm compositor. This problem will be
fixed in a follow up patch.
On the shell side, the fade was re-implemented in a slightly different
manner. Instead of using a custom frame function, the fade animation
from animation.c is used. The interface for starting the fade was also
changed to take the value of an enum instead of a float alpha value,
in order to improve readability.
2013-02-21 20:35:20 +04:00
|
|
|
|
|
|
|
|
|
unlock(shell);
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-11 21:57:05 +03:00
|
|
|
|
static void
|
|
|
|
|
transform_handler(struct wl_listener *listener, void *data)
|
|
|
|
|
{
|
|
|
|
|
struct weston_surface *surface = data;
|
|
|
|
|
struct shell_surface *shsurf = get_shell_surface(surface);
|
2016-08-12 11:41:36 +03:00
|
|
|
|
const struct weston_xwayland_surface_api *api;
|
2015-12-11 21:57:05 +03:00
|
|
|
|
int x, y;
|
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
if (!shsurf)
|
|
|
|
|
return;
|
|
|
|
|
|
2019-12-09 17:36:47 +03:00
|
|
|
|
shell_surface_set_output(shsurf, shsurf->view->output);
|
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
api = shsurf->shell->xwayland_surface_api;
|
|
|
|
|
if (!api) {
|
|
|
|
|
api = weston_xwayland_surface_get_api(shsurf->shell->compositor);
|
|
|
|
|
shsurf->shell->xwayland_surface_api = api;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!api || !api->is_xwayland_surface(surface))
|
2015-12-11 21:57:05 +03:00
|
|
|
|
return;
|
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
if (!weston_view_is_mapped(shsurf->view))
|
2015-12-11 21:57:05 +03:00
|
|
|
|
return;
|
|
|
|
|
|
2022-02-04 02:47:41 +03:00
|
|
|
|
x = shsurf->view->geometry.pos_offset.x;
|
|
|
|
|
y = shsurf->view->geometry.pos_offset.y;
|
2015-12-11 21:57:05 +03:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
api->send_position(surface, x, y);
|
2015-12-11 21:57:05 +03:00
|
|
|
|
}
|
|
|
|
|
|
2012-08-13 17:07:52 +04:00
|
|
|
|
static void
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
weston_view_set_initial_position(struct weston_view *view,
|
|
|
|
|
struct desktop_shell *shell)
|
2012-08-13 17:07:52 +04:00
|
|
|
|
{
|
|
|
|
|
struct weston_compositor *compositor = shell->compositor;
|
|
|
|
|
int ix = 0, iy = 0;
|
2014-08-20 17:53:20 +04:00
|
|
|
|
int32_t range_x, range_y;
|
2015-04-15 20:23:54 +03:00
|
|
|
|
int32_t x, y;
|
2012-08-13 17:07:52 +04:00
|
|
|
|
struct weston_output *output, *target_output = NULL;
|
|
|
|
|
struct weston_seat *seat;
|
2014-08-20 17:53:20 +04:00
|
|
|
|
pixman_rectangle32_t area;
|
2012-08-13 17:07:52 +04:00
|
|
|
|
|
|
|
|
|
/* As a heuristic place the new window on the same output as the
|
|
|
|
|
* pointer. Falling back to the output containing 0, 0.
|
|
|
|
|
*
|
|
|
|
|
* TODO: Do something clever for touch too?
|
|
|
|
|
*/
|
|
|
|
|
wl_list_for_each(seat, &compositor->seat_list, link) {
|
2015-08-01 00:55:32 +03:00
|
|
|
|
struct weston_pointer *pointer = weston_seat_get_pointer(seat);
|
|
|
|
|
|
|
|
|
|
if (pointer) {
|
2022-02-04 01:40:10 +03:00
|
|
|
|
ix = pointer->pos.c.x;
|
|
|
|
|
iy = pointer->pos.c.y;
|
2012-08-13 17:07:52 +04:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wl_list_for_each(output, &compositor->output_list, link) {
|
2022-08-31 19:48:05 +03:00
|
|
|
|
if (weston_output_contains_point(output, ix, iy)) {
|
2012-08-13 17:07:52 +04:00
|
|
|
|
target_output = output;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!target_output) {
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
weston_view_set_position(view, 10 + random() % 400,
|
|
|
|
|
10 + random() % 400);
|
2012-08-13 17:07:52 +04:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Valid range within output where the surface will still be onscreen.
|
|
|
|
|
* If this is negative it means that the surface is bigger than
|
|
|
|
|
* output.
|
|
|
|
|
*/
|
2014-08-20 17:53:20 +04:00
|
|
|
|
get_output_work_area(shell, target_output, &area);
|
|
|
|
|
|
2015-04-15 20:23:54 +03:00
|
|
|
|
x = area.x;
|
|
|
|
|
y = area.y;
|
2014-08-20 17:53:20 +04:00
|
|
|
|
range_x = area.width - view->surface->width;
|
|
|
|
|
range_y = area.height - view->surface->height;
|
2012-08-13 17:07:52 +04:00
|
|
|
|
|
2012-08-13 18:18:44 +04:00
|
|
|
|
if (range_x > 0)
|
2015-04-15 20:23:54 +03:00
|
|
|
|
x += random() % range_x;
|
2012-08-13 18:18:44 +04:00
|
|
|
|
|
|
|
|
|
if (range_y > 0)
|
2015-04-15 20:23:54 +03:00
|
|
|
|
y += random() % range_y;
|
2012-08-13 17:07:52 +04:00
|
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
weston_view_set_position(view, x, y);
|
2012-08-13 17:07:52 +04:00
|
|
|
|
}
|
|
|
|
|
|
2014-08-28 12:41:26 +04:00
|
|
|
|
static bool
|
|
|
|
|
check_desktop_shell_crash_too_early(struct desktop_shell *shell)
|
|
|
|
|
{
|
|
|
|
|
struct timespec now;
|
|
|
|
|
|
|
|
|
|
if (clock_gettime(CLOCK_MONOTONIC, &now) < 0)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* If the shell helper client dies before the session has been
|
|
|
|
|
* up for roughly 30 seconds, better just make Weston shut down,
|
|
|
|
|
* because the user likely has no way to interact with the desktop
|
|
|
|
|
* anyway.
|
|
|
|
|
*/
|
|
|
|
|
if (now.tv_sec - shell->startup_time.tv_sec < 30) {
|
|
|
|
|
weston_log("Error: %s apparently cannot run at all.\n",
|
|
|
|
|
shell->client);
|
|
|
|
|
weston_log_continue(STAMP_SPACE "Quitting...");
|
2019-02-06 11:44:37 +03:00
|
|
|
|
weston_compositor_exit_with_code(shell->compositor,
|
|
|
|
|
EXIT_FAILURE);
|
2014-08-28 12:41:26 +04:00
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-25 18:57:01 +04:00
|
|
|
|
static void launch_desktop_shell_process(void *data);
|
2012-01-17 16:36:27 +04:00
|
|
|
|
|
2011-11-03 16:11:32 +04:00
|
|
|
|
static void
|
shell: fix race on desktop-shell exit
The desktop shell plugin registers both a wl_client destroy signal
listener, and a sigchld handler, when launching weston-desktop-shell.
However, nothing guarantees in which order do the wl_client destructor
and the sigchld handler run.
Luckily, the sigchld handler cannot interrupt any code, because we
handle the signal via signalfd, which means it is handled like any event
in the compositor's main event loop.
Still, shell.c has a race, that when lost, can cause a crash, as
described in bug #82957.
If the sigchld handler happens to run first, it will try to launch a new
weston-desktop-shell without removing the destroy listener from the old
wl_client first. This leads to list corruption, that may cause a crash
when the old wl_client gets destroyed.
Simply removing the destroy listener in the sigchld handler is not
enough, because respawning sets shell->child.client pointer, and if
the wl_client destructor runs after, it will reset it to NULL.
OTOH, the wl_client destroy handler cannot reset shell->child.process,
because that would cause the sigchld handler in weston core to not find
the process tracker anymore, and report that an unknown process exited.
Turns out, that to make everything work, we would need to wait for both
the wl_client destructor and the sigchld handler to have run, before
respawn. This gets tricky.
Instead, solve the problem by removing shell->child.process. Use the new
weston_client_start() which automatically creates and manages the struct
weston_process. The shell does not need to know about the process exit,
it only needs to know about the client disconnect. Weston-desktop-shell
will never attempt to reconnect, and it would not work even if it did,
so disconnect is equivalent to weston-desktop-shell exiting.
This should permanently solve the race for weston-desktop-shell.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=82957
Cc: Boyan Ding <stu_dby@126.com>
Cc: Derek Foreman <derekf@osg.samsung.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
2014-08-27 13:11:53 +04:00
|
|
|
|
respawn_desktop_shell_process(struct desktop_shell *shell)
|
2011-11-03 16:11:32 +04:00
|
|
|
|
{
|
2017-11-16 19:21:01 +03:00
|
|
|
|
struct timespec time;
|
2012-01-17 16:36:27 +04:00
|
|
|
|
|
|
|
|
|
/* if desktop-shell dies more than 5 times in 30 seconds, give up */
|
2017-11-16 19:21:01 +03:00
|
|
|
|
weston_compositor_get_time(&time);
|
|
|
|
|
if (timespec_sub_to_msec(&time, &shell->child.deathstamp) > 30000) {
|
2012-01-17 16:36:27 +04:00
|
|
|
|
shell->child.deathstamp = time;
|
|
|
|
|
shell->child.deathcount = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
shell->child.deathcount++;
|
|
|
|
|
if (shell->child.deathcount > 5) {
|
shell: fix race on desktop-shell exit
The desktop shell plugin registers both a wl_client destroy signal
listener, and a sigchld handler, when launching weston-desktop-shell.
However, nothing guarantees in which order do the wl_client destructor
and the sigchld handler run.
Luckily, the sigchld handler cannot interrupt any code, because we
handle the signal via signalfd, which means it is handled like any event
in the compositor's main event loop.
Still, shell.c has a race, that when lost, can cause a crash, as
described in bug #82957.
If the sigchld handler happens to run first, it will try to launch a new
weston-desktop-shell without removing the destroy listener from the old
wl_client first. This leads to list corruption, that may cause a crash
when the old wl_client gets destroyed.
Simply removing the destroy listener in the sigchld handler is not
enough, because respawning sets shell->child.client pointer, and if
the wl_client destructor runs after, it will reset it to NULL.
OTOH, the wl_client destroy handler cannot reset shell->child.process,
because that would cause the sigchld handler in weston core to not find
the process tracker anymore, and report that an unknown process exited.
Turns out, that to make everything work, we would need to wait for both
the wl_client destructor and the sigchld handler to have run, before
respawn. This gets tricky.
Instead, solve the problem by removing shell->child.process. Use the new
weston_client_start() which automatically creates and manages the struct
weston_process. The shell does not need to know about the process exit,
it only needs to know about the client disconnect. Weston-desktop-shell
will never attempt to reconnect, and it would not work even if it did,
so disconnect is equivalent to weston-desktop-shell exiting.
This should permanently solve the race for weston-desktop-shell.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=82957
Cc: Boyan Ding <stu_dby@126.com>
Cc: Derek Foreman <derekf@osg.samsung.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
2014-08-27 13:11:53 +04:00
|
|
|
|
weston_log("%s disconnected, giving up.\n", shell->client);
|
2012-01-17 16:36:27 +04:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
shell: fix race on desktop-shell exit
The desktop shell plugin registers both a wl_client destroy signal
listener, and a sigchld handler, when launching weston-desktop-shell.
However, nothing guarantees in which order do the wl_client destructor
and the sigchld handler run.
Luckily, the sigchld handler cannot interrupt any code, because we
handle the signal via signalfd, which means it is handled like any event
in the compositor's main event loop.
Still, shell.c has a race, that when lost, can cause a crash, as
described in bug #82957.
If the sigchld handler happens to run first, it will try to launch a new
weston-desktop-shell without removing the destroy listener from the old
wl_client first. This leads to list corruption, that may cause a crash
when the old wl_client gets destroyed.
Simply removing the destroy listener in the sigchld handler is not
enough, because respawning sets shell->child.client pointer, and if
the wl_client destructor runs after, it will reset it to NULL.
OTOH, the wl_client destroy handler cannot reset shell->child.process,
because that would cause the sigchld handler in weston core to not find
the process tracker anymore, and report that an unknown process exited.
Turns out, that to make everything work, we would need to wait for both
the wl_client destructor and the sigchld handler to have run, before
respawn. This gets tricky.
Instead, solve the problem by removing shell->child.process. Use the new
weston_client_start() which automatically creates and manages the struct
weston_process. The shell does not need to know about the process exit,
it only needs to know about the client disconnect. Weston-desktop-shell
will never attempt to reconnect, and it would not work even if it did,
so disconnect is equivalent to weston-desktop-shell exiting.
This should permanently solve the race for weston-desktop-shell.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=82957
Cc: Boyan Ding <stu_dby@126.com>
Cc: Derek Foreman <derekf@osg.samsung.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
2014-08-27 13:11:53 +04:00
|
|
|
|
weston_log("%s disconnected, respawning...\n", shell->client);
|
2012-01-17 16:36:27 +04:00
|
|
|
|
launch_desktop_shell_process(shell);
|
2011-11-03 16:11:32 +04:00
|
|
|
|
}
|
|
|
|
|
|
2013-12-20 23:07:01 +04:00
|
|
|
|
static void
|
|
|
|
|
desktop_shell_client_destroy(struct wl_listener *listener, void *data)
|
|
|
|
|
{
|
|
|
|
|
struct desktop_shell *shell;
|
|
|
|
|
|
|
|
|
|
shell = container_of(listener, struct desktop_shell,
|
|
|
|
|
child.client_destroy_listener);
|
|
|
|
|
|
shell: fix race on desktop-shell exit
The desktop shell plugin registers both a wl_client destroy signal
listener, and a sigchld handler, when launching weston-desktop-shell.
However, nothing guarantees in which order do the wl_client destructor
and the sigchld handler run.
Luckily, the sigchld handler cannot interrupt any code, because we
handle the signal via signalfd, which means it is handled like any event
in the compositor's main event loop.
Still, shell.c has a race, that when lost, can cause a crash, as
described in bug #82957.
If the sigchld handler happens to run first, it will try to launch a new
weston-desktop-shell without removing the destroy listener from the old
wl_client first. This leads to list corruption, that may cause a crash
when the old wl_client gets destroyed.
Simply removing the destroy listener in the sigchld handler is not
enough, because respawning sets shell->child.client pointer, and if
the wl_client destructor runs after, it will reset it to NULL.
OTOH, the wl_client destroy handler cannot reset shell->child.process,
because that would cause the sigchld handler in weston core to not find
the process tracker anymore, and report that an unknown process exited.
Turns out, that to make everything work, we would need to wait for both
the wl_client destructor and the sigchld handler to have run, before
respawn. This gets tricky.
Instead, solve the problem by removing shell->child.process. Use the new
weston_client_start() which automatically creates and manages the struct
weston_process. The shell does not need to know about the process exit,
it only needs to know about the client disconnect. Weston-desktop-shell
will never attempt to reconnect, and it would not work even if it did,
so disconnect is equivalent to weston-desktop-shell exiting.
This should permanently solve the race for weston-desktop-shell.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=82957
Cc: Boyan Ding <stu_dby@126.com>
Cc: Derek Foreman <derekf@osg.samsung.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
2014-08-27 13:11:53 +04:00
|
|
|
|
wl_list_remove(&shell->child.client_destroy_listener.link);
|
2013-12-20 23:07:01 +04:00
|
|
|
|
shell->child.client = NULL;
|
shell: fix race on desktop-shell exit
The desktop shell plugin registers both a wl_client destroy signal
listener, and a sigchld handler, when launching weston-desktop-shell.
However, nothing guarantees in which order do the wl_client destructor
and the sigchld handler run.
Luckily, the sigchld handler cannot interrupt any code, because we
handle the signal via signalfd, which means it is handled like any event
in the compositor's main event loop.
Still, shell.c has a race, that when lost, can cause a crash, as
described in bug #82957.
If the sigchld handler happens to run first, it will try to launch a new
weston-desktop-shell without removing the destroy listener from the old
wl_client first. This leads to list corruption, that may cause a crash
when the old wl_client gets destroyed.
Simply removing the destroy listener in the sigchld handler is not
enough, because respawning sets shell->child.client pointer, and if
the wl_client destructor runs after, it will reset it to NULL.
OTOH, the wl_client destroy handler cannot reset shell->child.process,
because that would cause the sigchld handler in weston core to not find
the process tracker anymore, and report that an unknown process exited.
Turns out, that to make everything work, we would need to wait for both
the wl_client destructor and the sigchld handler to have run, before
respawn. This gets tricky.
Instead, solve the problem by removing shell->child.process. Use the new
weston_client_start() which automatically creates and manages the struct
weston_process. The shell does not need to know about the process exit,
it only needs to know about the client disconnect. Weston-desktop-shell
will never attempt to reconnect, and it would not work even if it did,
so disconnect is equivalent to weston-desktop-shell exiting.
This should permanently solve the race for weston-desktop-shell.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=82957
Cc: Boyan Ding <stu_dby@126.com>
Cc: Derek Foreman <derekf@osg.samsung.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
2014-08-27 13:11:53 +04:00
|
|
|
|
/*
|
|
|
|
|
* unbind_desktop_shell() will reset shell->child.desktop_shell
|
|
|
|
|
* before the respawned process has a chance to create a new
|
|
|
|
|
* desktop_shell object, because we are being called from the
|
|
|
|
|
* wl_client destructor which destroys all wl_resources before
|
|
|
|
|
* returning.
|
|
|
|
|
*/
|
|
|
|
|
|
2014-08-28 12:41:26 +04:00
|
|
|
|
if (!check_desktop_shell_crash_too_early(shell))
|
|
|
|
|
respawn_desktop_shell_process(shell);
|
|
|
|
|
|
shell: fix race on desktop-shell exit
The desktop shell plugin registers both a wl_client destroy signal
listener, and a sigchld handler, when launching weston-desktop-shell.
However, nothing guarantees in which order do the wl_client destructor
and the sigchld handler run.
Luckily, the sigchld handler cannot interrupt any code, because we
handle the signal via signalfd, which means it is handled like any event
in the compositor's main event loop.
Still, shell.c has a race, that when lost, can cause a crash, as
described in bug #82957.
If the sigchld handler happens to run first, it will try to launch a new
weston-desktop-shell without removing the destroy listener from the old
wl_client first. This leads to list corruption, that may cause a crash
when the old wl_client gets destroyed.
Simply removing the destroy listener in the sigchld handler is not
enough, because respawning sets shell->child.client pointer, and if
the wl_client destructor runs after, it will reset it to NULL.
OTOH, the wl_client destroy handler cannot reset shell->child.process,
because that would cause the sigchld handler in weston core to not find
the process tracker anymore, and report that an unknown process exited.
Turns out, that to make everything work, we would need to wait for both
the wl_client destructor and the sigchld handler to have run, before
respawn. This gets tricky.
Instead, solve the problem by removing shell->child.process. Use the new
weston_client_start() which automatically creates and manages the struct
weston_process. The shell does not need to know about the process exit,
it only needs to know about the client disconnect. Weston-desktop-shell
will never attempt to reconnect, and it would not work even if it did,
so disconnect is equivalent to weston-desktop-shell exiting.
This should permanently solve the race for weston-desktop-shell.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=82957
Cc: Boyan Ding <stu_dby@126.com>
Cc: Derek Foreman <derekf@osg.samsung.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
2014-08-27 13:11:53 +04:00
|
|
|
|
shell_fade_startup(shell);
|
2013-12-20 23:07:01 +04:00
|
|
|
|
}
|
|
|
|
|
|
2012-09-25 18:57:01 +04:00
|
|
|
|
static void
|
|
|
|
|
launch_desktop_shell_process(void *data)
|
2011-11-03 16:11:32 +04:00
|
|
|
|
{
|
2012-09-25 18:57:01 +04:00
|
|
|
|
struct desktop_shell *shell = data;
|
2011-11-03 16:11:32 +04:00
|
|
|
|
|
shell: fix race on desktop-shell exit
The desktop shell plugin registers both a wl_client destroy signal
listener, and a sigchld handler, when launching weston-desktop-shell.
However, nothing guarantees in which order do the wl_client destructor
and the sigchld handler run.
Luckily, the sigchld handler cannot interrupt any code, because we
handle the signal via signalfd, which means it is handled like any event
in the compositor's main event loop.
Still, shell.c has a race, that when lost, can cause a crash, as
described in bug #82957.
If the sigchld handler happens to run first, it will try to launch a new
weston-desktop-shell without removing the destroy listener from the old
wl_client first. This leads to list corruption, that may cause a crash
when the old wl_client gets destroyed.
Simply removing the destroy listener in the sigchld handler is not
enough, because respawning sets shell->child.client pointer, and if
the wl_client destructor runs after, it will reset it to NULL.
OTOH, the wl_client destroy handler cannot reset shell->child.process,
because that would cause the sigchld handler in weston core to not find
the process tracker anymore, and report that an unknown process exited.
Turns out, that to make everything work, we would need to wait for both
the wl_client destructor and the sigchld handler to have run, before
respawn. This gets tricky.
Instead, solve the problem by removing shell->child.process. Use the new
weston_client_start() which automatically creates and manages the struct
weston_process. The shell does not need to know about the process exit,
it only needs to know about the client disconnect. Weston-desktop-shell
will never attempt to reconnect, and it would not work even if it did,
so disconnect is equivalent to weston-desktop-shell exiting.
This should permanently solve the race for weston-desktop-shell.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=82957
Cc: Boyan Ding <stu_dby@126.com>
Cc: Derek Foreman <derekf@osg.samsung.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
2014-08-27 13:11:53 +04:00
|
|
|
|
shell->child.client = weston_client_start(shell->compositor,
|
|
|
|
|
shell->client);
|
2011-11-03 16:11:32 +04:00
|
|
|
|
|
2014-08-25 22:56:46 +04:00
|
|
|
|
if (!shell->child.client) {
|
2013-11-20 16:22:29 +04:00
|
|
|
|
weston_log("not able to start %s\n", shell->client);
|
2014-08-25 22:56:46 +04:00
|
|
|
|
return;
|
|
|
|
|
}
|
2013-12-20 23:07:01 +04:00
|
|
|
|
|
|
|
|
|
shell->child.client_destroy_listener.notify =
|
|
|
|
|
desktop_shell_client_destroy;
|
|
|
|
|
wl_client_add_destroy_listener(shell->child.client,
|
|
|
|
|
&shell->child.client_destroy_listener);
|
2011-11-03 16:11:32 +04:00
|
|
|
|
}
|
|
|
|
|
|
desktop-shell: screen locking protocol
Add protocol and functions for supporting screen locking, triggered by
activity timeout.
After activity timeout, compositor starts the fade to black, and then
enters SLEEPING state. At that point it calls lock() in the shell
plugin.
When input events trigger a wakeup, unlock() in the shell plugin is
called. This sends prepare_lock_surface event to the desktop-shell
client. The screen stays locked while the compositor starts fade-in.
At this point, desktop-shell client usually creates a surface for the
unlocking GUI (e.g. a password prompt), and sends it with the
set_lock_surface request. The compositor supposedly shows and allows
interaction only with the given lock surface (not yet implemented).
When desktop-shell has authenticated the user, or instead of issuing
set_lock_surface, it sends the unlock request. Upon receiving the unlock
request, the shell plugin unlocks the screen.
If desktop-shell client dies, the screen is unlocked automatically.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-15 15:34:48 +04:00
|
|
|
|
static void
|
|
|
|
|
unbind_desktop_shell(struct wl_resource *resource)
|
|
|
|
|
{
|
2013-06-14 19:07:54 +04:00
|
|
|
|
struct desktop_shell *shell = wl_resource_get_user_data(resource);
|
2011-11-16 01:39:55 +04:00
|
|
|
|
|
|
|
|
|
if (shell->locked)
|
|
|
|
|
resume_desktop(shell);
|
|
|
|
|
|
desktop-shell: screen locking protocol
Add protocol and functions for supporting screen locking, triggered by
activity timeout.
After activity timeout, compositor starts the fade to black, and then
enters SLEEPING state. At that point it calls lock() in the shell
plugin.
When input events trigger a wakeup, unlock() in the shell plugin is
called. This sends prepare_lock_surface event to the desktop-shell
client. The screen stays locked while the compositor starts fade-in.
At this point, desktop-shell client usually creates a surface for the
unlocking GUI (e.g. a password prompt), and sends it with the
set_lock_surface request. The compositor supposedly shows and allows
interaction only with the given lock surface (not yet implemented).
When desktop-shell has authenticated the user, or instead of issuing
set_lock_surface, it sends the unlock request. Upon receiving the unlock
request, the shell plugin unlocks the screen.
If desktop-shell client dies, the screen is unlocked automatically.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-15 15:34:48 +04:00
|
|
|
|
shell->child.desktop_shell = NULL;
|
|
|
|
|
shell->prepare_event_sent = false;
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-06 21:48:16 +04:00
|
|
|
|
static void
|
|
|
|
|
bind_desktop_shell(struct wl_client *client,
|
|
|
|
|
void *data, uint32_t version, uint32_t id)
|
|
|
|
|
{
|
2012-04-16 18:31:41 +04:00
|
|
|
|
struct desktop_shell *shell = data;
|
2011-11-03 16:11:33 +04:00
|
|
|
|
struct wl_resource *resource;
|
|
|
|
|
|
2015-11-17 11:00:33 +03:00
|
|
|
|
resource = wl_resource_create(client, &weston_desktop_shell_interface,
|
|
|
|
|
1, id);
|
2011-11-03 16:11:33 +04:00
|
|
|
|
|
desktop-shell: screen locking protocol
Add protocol and functions for supporting screen locking, triggered by
activity timeout.
After activity timeout, compositor starts the fade to black, and then
enters SLEEPING state. At that point it calls lock() in the shell
plugin.
When input events trigger a wakeup, unlock() in the shell plugin is
called. This sends prepare_lock_surface event to the desktop-shell
client. The screen stays locked while the compositor starts fade-in.
At this point, desktop-shell client usually creates a surface for the
unlocking GUI (e.g. a password prompt), and sends it with the
set_lock_surface request. The compositor supposedly shows and allows
interaction only with the given lock surface (not yet implemented).
When desktop-shell has authenticated the user, or instead of issuing
set_lock_surface, it sends the unlock request. Upon receiving the unlock
request, the shell plugin unlocks the screen.
If desktop-shell client dies, the screen is unlocked automatically.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-15 15:34:48 +04:00
|
|
|
|
if (client == shell->child.client) {
|
2013-06-28 05:17:02 +04:00
|
|
|
|
wl_resource_set_implementation(resource,
|
|
|
|
|
&desktop_shell_implementation,
|
|
|
|
|
shell, unbind_desktop_shell);
|
desktop-shell: screen locking protocol
Add protocol and functions for supporting screen locking, triggered by
activity timeout.
After activity timeout, compositor starts the fade to black, and then
enters SLEEPING state. At that point it calls lock() in the shell
plugin.
When input events trigger a wakeup, unlock() in the shell plugin is
called. This sends prepare_lock_surface event to the desktop-shell
client. The screen stays locked while the compositor starts fade-in.
At this point, desktop-shell client usually creates a surface for the
unlocking GUI (e.g. a password prompt), and sends it with the
set_lock_surface request. The compositor supposedly shows and allows
interaction only with the given lock surface (not yet implemented).
When desktop-shell has authenticated the user, or instead of issuing
set_lock_surface, it sends the unlock request. Upon receiving the unlock
request, the shell plugin unlocks the screen.
If desktop-shell client dies, the screen is unlocked automatically.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-15 15:34:48 +04:00
|
|
|
|
shell->child.desktop_shell = resource;
|
2011-11-03 16:11:33 +04:00
|
|
|
|
return;
|
desktop-shell: screen locking protocol
Add protocol and functions for supporting screen locking, triggered by
activity timeout.
After activity timeout, compositor starts the fade to black, and then
enters SLEEPING state. At that point it calls lock() in the shell
plugin.
When input events trigger a wakeup, unlock() in the shell plugin is
called. This sends prepare_lock_surface event to the desktop-shell
client. The screen stays locked while the compositor starts fade-in.
At this point, desktop-shell client usually creates a surface for the
unlocking GUI (e.g. a password prompt), and sends it with the
set_lock_surface request. The compositor supposedly shows and allows
interaction only with the given lock surface (not yet implemented).
When desktop-shell has authenticated the user, or instead of issuing
set_lock_surface, it sends the unlock request. Upon receiving the unlock
request, the shell plugin unlocks the screen.
If desktop-shell client dies, the screen is unlocked automatically.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-15 15:34:48 +04:00
|
|
|
|
}
|
2011-09-06 21:48:16 +04:00
|
|
|
|
|
2011-11-03 16:11:33 +04:00
|
|
|
|
wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
|
|
|
|
|
"permission to bind desktop_shell denied");
|
2011-09-06 21:48:16 +04:00
|
|
|
|
}
|
|
|
|
|
|
2012-02-20 03:52:44 +04:00
|
|
|
|
struct switcher {
|
2012-04-16 18:31:41 +04:00
|
|
|
|
struct desktop_shell *shell;
|
2014-10-18 15:09:56 +04:00
|
|
|
|
struct weston_view *current;
|
2012-02-20 03:52:44 +04:00
|
|
|
|
struct wl_listener listener;
|
2013-04-18 23:25:39 +04:00
|
|
|
|
struct weston_keyboard_grab grab;
|
2014-02-26 18:53:11 +04:00
|
|
|
|
struct wl_array minimized_array;
|
2012-02-20 03:52:44 +04:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
switcher_next(struct switcher *switcher)
|
|
|
|
|
{
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
struct weston_view *view;
|
2014-10-18 15:09:56 +04:00
|
|
|
|
struct weston_view *first = NULL, *prev = NULL, *next = NULL;
|
2012-04-03 06:18:58 +04:00
|
|
|
|
struct shell_surface *shsurf;
|
2012-06-19 00:34:58 +04:00
|
|
|
|
struct workspace *ws = get_current_workspace(switcher->shell);
|
2012-02-20 03:52:44 +04:00
|
|
|
|
|
2014-02-26 18:53:11 +04:00
|
|
|
|
/* temporary re-display minimized surfaces */
|
|
|
|
|
struct weston_view *tmp;
|
|
|
|
|
struct weston_view **minimized;
|
2014-07-09 23:12:56 +04:00
|
|
|
|
wl_list_for_each_safe(view, tmp, &switcher->shell->minimized_layer.view_list.link, layer_link.link) {
|
|
|
|
|
weston_layer_entry_remove(&view->layer_link);
|
|
|
|
|
weston_layer_entry_insert(&ws->layer.view_list, &view->layer_link);
|
2014-02-26 18:53:11 +04:00
|
|
|
|
minimized = wl_array_add(&switcher->minimized_array, sizeof *minimized);
|
|
|
|
|
*minimized = view;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-09 23:12:56 +04:00
|
|
|
|
wl_list_for_each(view, &ws->layer.view_list.link, layer_link.link) {
|
2013-12-03 21:35:43 +04:00
|
|
|
|
shsurf = get_shell_surface(view->surface);
|
2016-08-12 11:41:36 +03:00
|
|
|
|
if (shsurf) {
|
2012-02-20 03:52:44 +04:00
|
|
|
|
if (first == NULL)
|
2014-10-18 15:09:56 +04:00
|
|
|
|
first = view;
|
2012-02-20 03:52:44 +04:00
|
|
|
|
if (prev == switcher->current)
|
2014-10-18 15:09:56 +04:00
|
|
|
|
next = view;
|
|
|
|
|
prev = view;
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
view->alpha = 0.25;
|
|
|
|
|
weston_view_geometry_dirty(view);
|
|
|
|
|
weston_surface_damage(view->surface);
|
2012-02-20 03:52:44 +04:00
|
|
|
|
}
|
2012-04-01 16:13:09 +04:00
|
|
|
|
|
2014-10-18 14:23:20 +04:00
|
|
|
|
if (is_black_surface_view(view, NULL)) {
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
view->alpha = 0.25;
|
|
|
|
|
weston_view_geometry_dirty(view);
|
|
|
|
|
weston_surface_damage(view->surface);
|
2012-04-01 16:13:09 +04:00
|
|
|
|
}
|
2012-02-20 03:52:44 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (next == NULL)
|
|
|
|
|
next = first;
|
|
|
|
|
|
2012-03-12 12:06:01 +04:00
|
|
|
|
if (next == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
2012-02-20 03:52:44 +04:00
|
|
|
|
wl_list_remove(&switcher->listener.link);
|
2013-06-07 07:34:41 +04:00
|
|
|
|
wl_signal_add(&next->destroy_signal, &switcher->listener);
|
2012-02-20 03:52:44 +04:00
|
|
|
|
|
|
|
|
|
switcher->current = next;
|
2014-10-18 15:09:56 +04:00
|
|
|
|
wl_list_for_each(view, &next->surface->views, surface_link)
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
view->alpha = 1.0;
|
2012-04-01 16:13:09 +04:00
|
|
|
|
|
2014-10-18 15:09:56 +04:00
|
|
|
|
shsurf = get_shell_surface(switcher->current->surface);
|
2016-08-12 11:41:36 +03:00
|
|
|
|
if (shsurf && weston_desktop_surface_get_fullscreen(shsurf->desktop_surface))
|
2022-01-17 17:24:03 +03:00
|
|
|
|
shsurf->fullscreen.black_view->view->alpha = 1.0;
|
2012-02-20 03:52:44 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2014-10-18 15:09:56 +04:00
|
|
|
|
switcher_handle_view_destroy(struct wl_listener *listener, void *data)
|
2012-02-20 03:52:44 +04:00
|
|
|
|
{
|
|
|
|
|
struct switcher *switcher =
|
|
|
|
|
container_of(listener, struct switcher, listener);
|
|
|
|
|
|
|
|
|
|
switcher_next(switcher);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2012-05-31 23:27:47 +04:00
|
|
|
|
switcher_destroy(struct switcher *switcher)
|
2012-02-20 03:52:44 +04:00
|
|
|
|
{
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
struct weston_view *view;
|
2013-04-18 23:25:39 +04:00
|
|
|
|
struct weston_keyboard *keyboard = switcher->grab.keyboard;
|
2012-06-19 00:34:58 +04:00
|
|
|
|
struct workspace *ws = get_current_workspace(switcher->shell);
|
2012-02-20 03:52:44 +04:00
|
|
|
|
|
2014-07-09 23:12:56 +04:00
|
|
|
|
wl_list_for_each(view, &ws->layer.view_list.link, layer_link.link) {
|
animation, shell: add kbd focus change animation
When enabled, this will make all but the keyboard-focused window dim.
Also the background gets dimmed, if there are any windows open. The
panel is not dimmed.
When the keyboard focus changes, the change in dimming is animated.
The dimming is implemented with transparent solid-color surfaces, two at
most. The net effect of two overlapping dim surfaces is kept constant
during animations (stable fade animation).
There is a new weston.ini option "focus-animation", that defaults to
none, and can be set to "dim-layer" to enable the focus change
animation.
[pq: Sliced, squashed, and rebased the patch series. Fixed surface alpha
interaction with the switcher. Wrote the commit message.]
[pochu: rebased, ported to weston_view]
2013-11-19 14:37:11 +04:00
|
|
|
|
if (is_focus_view(view))
|
|
|
|
|
continue;
|
|
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
view->alpha = 1.0;
|
|
|
|
|
weston_surface_damage(view->surface);
|
2012-02-20 03:52:44 +04:00
|
|
|
|
}
|
|
|
|
|
|
2021-10-15 20:20:17 +03:00
|
|
|
|
if (switcher->current && get_shell_surface(switcher->current->surface)) {
|
2014-10-18 15:24:53 +04:00
|
|
|
|
activate(switcher->shell, switcher->current,
|
2014-10-18 20:20:16 +04:00
|
|
|
|
keyboard->seat,
|
|
|
|
|
WESTON_ACTIVATE_FLAG_CONFIGURE);
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-20 03:52:44 +04:00
|
|
|
|
wl_list_remove(&switcher->listener.link);
|
2013-04-18 23:25:39 +04:00
|
|
|
|
weston_keyboard_end_grab(keyboard);
|
|
|
|
|
if (keyboard->input_method_resource)
|
|
|
|
|
keyboard->grab = &keyboard->input_method_grab;
|
2014-02-26 18:53:11 +04:00
|
|
|
|
|
|
|
|
|
/* re-hide surfaces that were temporary shown during the switch */
|
|
|
|
|
struct weston_view **minimized;
|
|
|
|
|
wl_array_for_each(minimized, &switcher->minimized_array) {
|
|
|
|
|
/* with the exception of the current selected */
|
2014-10-18 15:09:56 +04:00
|
|
|
|
if ((*minimized)->surface != switcher->current->surface) {
|
2014-07-09 23:12:56 +04:00
|
|
|
|
weston_layer_entry_remove(&(*minimized)->layer_link);
|
|
|
|
|
weston_layer_entry_insert(&switcher->shell->minimized_layer.view_list, &(*minimized)->layer_link);
|
2014-02-26 18:53:11 +04:00
|
|
|
|
weston_view_damage_below(*minimized);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
wl_array_release(&switcher->minimized_array);
|
|
|
|
|
|
2012-02-20 03:52:44 +04:00
|
|
|
|
free(switcher);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2013-04-18 23:25:39 +04:00
|
|
|
|
switcher_key(struct weston_keyboard_grab *grab,
|
2017-11-16 19:20:57 +03:00
|
|
|
|
const struct timespec *time, uint32_t key, uint32_t state_w)
|
2012-02-20 03:52:44 +04:00
|
|
|
|
{
|
|
|
|
|
struct switcher *switcher = container_of(grab, struct switcher, grab);
|
2012-05-30 19:31:52 +04:00
|
|
|
|
enum wl_keyboard_key_state state = state_w;
|
2012-02-20 03:52:44 +04:00
|
|
|
|
|
2012-05-30 19:31:52 +04:00
|
|
|
|
if (key == KEY_TAB && state == WL_KEYBOARD_KEY_STATE_PRESSED)
|
2012-02-20 03:52:44 +04:00
|
|
|
|
switcher_next(switcher);
|
2012-05-31 23:27:47 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2013-04-18 23:25:39 +04:00
|
|
|
|
switcher_modifier(struct weston_keyboard_grab *grab, uint32_t serial,
|
2012-05-31 23:27:47 +04:00
|
|
|
|
uint32_t mods_depressed, uint32_t mods_latched,
|
|
|
|
|
uint32_t mods_locked, uint32_t group)
|
|
|
|
|
{
|
|
|
|
|
struct switcher *switcher = container_of(grab, struct switcher, grab);
|
2015-01-30 22:24:36 +03:00
|
|
|
|
struct weston_seat *seat = grab->keyboard->seat;
|
2012-05-31 23:27:47 +04:00
|
|
|
|
|
|
|
|
|
if ((seat->modifier_state & switcher->shell->binding_modifier) == 0)
|
|
|
|
|
switcher_destroy(switcher);
|
2012-05-10 20:28:35 +04:00
|
|
|
|
}
|
2012-02-20 03:52:44 +04:00
|
|
|
|
|
2013-10-26 01:18:05 +04:00
|
|
|
|
static void
|
|
|
|
|
switcher_cancel(struct weston_keyboard_grab *grab)
|
|
|
|
|
{
|
|
|
|
|
struct switcher *switcher = container_of(grab, struct switcher, grab);
|
|
|
|
|
|
|
|
|
|
switcher_destroy(switcher);
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-18 23:25:39 +04:00
|
|
|
|
static const struct weston_keyboard_grab_interface switcher_grab = {
|
2012-05-31 23:27:47 +04:00
|
|
|
|
switcher_key,
|
|
|
|
|
switcher_modifier,
|
2013-10-26 01:18:05 +04:00
|
|
|
|
switcher_cancel,
|
2012-02-20 03:52:44 +04:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void
|
2017-11-16 19:20:57 +03:00
|
|
|
|
switcher_binding(struct weston_keyboard *keyboard, const struct timespec *time,
|
2015-07-15 21:00:36 +03:00
|
|
|
|
uint32_t key, void *data)
|
2012-02-20 03:52:44 +04:00
|
|
|
|
{
|
2012-04-16 18:31:41 +04:00
|
|
|
|
struct desktop_shell *shell = data;
|
2012-02-20 03:52:44 +04:00
|
|
|
|
struct switcher *switcher;
|
|
|
|
|
|
|
|
|
|
switcher = malloc(sizeof *switcher);
|
2020-07-28 10:28:45 +03:00
|
|
|
|
if (!switcher)
|
|
|
|
|
return;
|
2021-05-14 14:37:46 +03:00
|
|
|
|
|
2012-04-12 17:55:26 +04:00
|
|
|
|
switcher->shell = shell;
|
2012-02-20 03:52:44 +04:00
|
|
|
|
switcher->current = NULL;
|
2014-10-18 15:09:56 +04:00
|
|
|
|
switcher->listener.notify = switcher_handle_view_destroy;
|
2012-02-20 03:52:44 +04:00
|
|
|
|
wl_list_init(&switcher->listener.link);
|
2014-02-26 18:53:11 +04:00
|
|
|
|
wl_array_init(&switcher->minimized_array);
|
2012-02-20 03:52:44 +04:00
|
|
|
|
|
2015-06-21 22:25:08 +03:00
|
|
|
|
lower_fullscreen_layer(switcher->shell, NULL);
|
2012-02-20 03:52:44 +04:00
|
|
|
|
switcher->grab.interface = &switcher_grab;
|
2015-07-15 21:00:36 +03:00
|
|
|
|
weston_keyboard_start_grab(keyboard, &switcher->grab);
|
|
|
|
|
weston_keyboard_set_focus(keyboard, NULL);
|
2012-02-20 03:52:44 +04:00
|
|
|
|
switcher_next(switcher);
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-29 21:53:50 +04:00
|
|
|
|
static void
|
2017-11-16 19:20:57 +03:00
|
|
|
|
backlight_binding(struct weston_keyboard *keyboard, const struct timespec *time,
|
2015-07-15 21:00:36 +03:00
|
|
|
|
uint32_t key, void *data)
|
2012-02-29 21:53:50 +04:00
|
|
|
|
{
|
|
|
|
|
struct weston_compositor *compositor = data;
|
|
|
|
|
struct weston_output *output;
|
2012-03-13 02:40:09 +04:00
|
|
|
|
long backlight_new = 0;
|
2012-02-29 21:53:50 +04:00
|
|
|
|
|
|
|
|
|
/* TODO: we're limiting to simple use cases, where we assume just
|
|
|
|
|
* control on the primary display. We'd have to extend later if we
|
|
|
|
|
* ever get support for setting backlights on random desktop LCD
|
|
|
|
|
* panels though */
|
2022-11-22 14:28:57 +03:00
|
|
|
|
output = weston_shell_utils_get_default_output(compositor);
|
2012-02-29 21:53:50 +04:00
|
|
|
|
if (!output)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (!output->set_backlight)
|
|
|
|
|
return;
|
|
|
|
|
|
2012-03-13 02:40:09 +04:00
|
|
|
|
if (key == KEY_F9 || key == KEY_BRIGHTNESSDOWN)
|
|
|
|
|
backlight_new = output->backlight_current - 25;
|
|
|
|
|
else if (key == KEY_F10 || key == KEY_BRIGHTNESSUP)
|
|
|
|
|
backlight_new = output->backlight_current + 25;
|
2012-02-29 21:53:50 +04:00
|
|
|
|
|
2012-03-13 02:40:09 +04:00
|
|
|
|
if (backlight_new < 5)
|
|
|
|
|
backlight_new = 5;
|
|
|
|
|
if (backlight_new > 255)
|
|
|
|
|
backlight_new = 255;
|
|
|
|
|
|
|
|
|
|
output->backlight_current = backlight_new;
|
2012-02-29 21:53:50 +04:00
|
|
|
|
output->set_backlight(output, output->backlight_current);
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-26 21:41:06 +04:00
|
|
|
|
static void
|
2017-11-16 19:20:57 +03:00
|
|
|
|
force_kill_binding(struct weston_keyboard *keyboard,
|
|
|
|
|
const struct timespec *time, uint32_t key, void *data)
|
2012-05-26 21:41:06 +04:00
|
|
|
|
{
|
2013-05-08 17:54:37 +04:00
|
|
|
|
struct weston_surface *focus_surface;
|
2012-05-26 21:41:06 +04:00
|
|
|
|
struct wl_client *client;
|
2012-09-27 18:48:36 +04:00
|
|
|
|
struct desktop_shell *shell = data;
|
|
|
|
|
struct weston_compositor *compositor = shell->compositor;
|
2012-05-26 21:41:06 +04:00
|
|
|
|
pid_t pid;
|
|
|
|
|
|
2015-07-15 21:00:36 +03:00
|
|
|
|
focus_surface = keyboard->focus;
|
2012-08-13 23:27:27 +04:00
|
|
|
|
if (!focus_surface)
|
|
|
|
|
return;
|
|
|
|
|
|
2012-09-27 18:48:36 +04:00
|
|
|
|
wl_signal_emit(&compositor->kill_signal, focus_surface);
|
|
|
|
|
|
2013-06-07 07:34:41 +04:00
|
|
|
|
client = wl_resource_get_client(focus_surface->resource);
|
2012-09-27 18:48:35 +04:00
|
|
|
|
wl_client_get_credentials(client, &pid, NULL, NULL);
|
|
|
|
|
|
|
|
|
|
/* Skip clients that we launched ourselves (the credentials of
|
|
|
|
|
* the socketpair is ours) */
|
|
|
|
|
if (pid == getpid())
|
|
|
|
|
return;
|
2012-05-26 21:41:06 +04:00
|
|
|
|
|
2012-05-30 19:31:58 +04:00
|
|
|
|
kill(pid, SIGKILL);
|
2012-05-26 21:41:06 +04:00
|
|
|
|
}
|
|
|
|
|
|
2014-01-29 20:47:54 +04:00
|
|
|
|
static void
|
2019-04-20 15:20:18 +03:00
|
|
|
|
shell_reposition_view_on_output_change(struct weston_view *view)
|
2014-01-29 20:47:54 +04:00
|
|
|
|
{
|
|
|
|
|
struct weston_output *output, *first_output;
|
|
|
|
|
struct weston_compositor *ec = view->surface->compositor;
|
|
|
|
|
struct shell_surface *shsurf;
|
|
|
|
|
float x, y;
|
|
|
|
|
int visible;
|
|
|
|
|
|
2019-04-20 15:40:56 +03:00
|
|
|
|
if (wl_list_empty(&ec->output_list))
|
|
|
|
|
return;
|
|
|
|
|
|
2022-02-04 02:47:41 +03:00
|
|
|
|
x = view->geometry.pos_offset.x;
|
|
|
|
|
y = view->geometry.pos_offset.y;
|
2014-01-29 20:47:54 +04:00
|
|
|
|
|
|
|
|
|
/* At this point the destroyed output is not in the list anymore.
|
|
|
|
|
* If the view is still visible somewhere, we leave where it is,
|
|
|
|
|
* otherwise, move it to the first output. */
|
|
|
|
|
visible = 0;
|
|
|
|
|
wl_list_for_each(output, &ec->output_list, link) {
|
2022-08-31 19:48:05 +03:00
|
|
|
|
if (weston_output_contains_point(output, x, y)) {
|
2014-01-29 20:47:54 +04:00
|
|
|
|
visible = 1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-24 17:57:19 +03:00
|
|
|
|
shsurf = get_shell_surface(view->surface);
|
|
|
|
|
if (!shsurf)
|
|
|
|
|
return;
|
|
|
|
|
|
2014-01-29 20:47:54 +04:00
|
|
|
|
if (!visible) {
|
|
|
|
|
first_output = container_of(ec->output_list.next,
|
|
|
|
|
struct weston_output, link);
|
|
|
|
|
|
|
|
|
|
x = first_output->x + first_output->width / 4;
|
|
|
|
|
y = first_output->y + first_output->height / 4;
|
2014-03-07 12:27:19 +04:00
|
|
|
|
|
|
|
|
|
weston_view_set_position(view, x, y);
|
|
|
|
|
} else {
|
|
|
|
|
weston_view_geometry_dirty(view);
|
2014-01-29 20:47:54 +04:00
|
|
|
|
|
2023-03-24 17:57:19 +03:00
|
|
|
|
if (shsurf->state.maximized ||
|
|
|
|
|
shsurf->state.fullscreen)
|
|
|
|
|
return;
|
|
|
|
|
}
|
2014-01-29 20:47:54 +04:00
|
|
|
|
|
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
shsurf->saved_position_valid = false;
|
|
|
|
|
set_maximized(shsurf, false);
|
|
|
|
|
set_fullscreen(shsurf, false, NULL);
|
2014-01-29 20:47:54 +04:00
|
|
|
|
}
|
|
|
|
|
|
2014-04-11 14:57:15 +04:00
|
|
|
|
void
|
|
|
|
|
shell_for_each_layer(struct desktop_shell *shell,
|
|
|
|
|
shell_for_each_layer_func_t func, void *data)
|
|
|
|
|
{
|
|
|
|
|
func(shell, &shell->fullscreen_layer, data);
|
|
|
|
|
func(shell, &shell->panel_layer, data);
|
|
|
|
|
func(shell, &shell->background_layer, data);
|
|
|
|
|
func(shell, &shell->lock_layer, data);
|
|
|
|
|
func(shell, &shell->input_panel_layer, data);
|
2022-06-22 18:16:02 +03:00
|
|
|
|
func(shell, &shell->workspace.layer, data);
|
2014-04-11 14:57:15 +04:00
|
|
|
|
}
|
|
|
|
|
|
2014-01-29 20:47:54 +04:00
|
|
|
|
static void
|
2019-04-20 15:20:18 +03:00
|
|
|
|
shell_output_changed_move_layer(struct desktop_shell *shell,
|
2014-04-11 14:57:15 +04:00
|
|
|
|
struct weston_layer *layer,
|
|
|
|
|
void *data)
|
2014-01-29 20:47:54 +04:00
|
|
|
|
{
|
|
|
|
|
struct weston_view *view;
|
|
|
|
|
|
2018-02-08 19:46:42 +03:00
|
|
|
|
wl_list_for_each(view, &layer->view_list.link, layer_link.link)
|
2019-04-20 15:20:18 +03:00
|
|
|
|
shell_reposition_view_on_output_change(view);
|
|
|
|
|
|
2014-01-29 20:47:54 +04:00
|
|
|
|
}
|
|
|
|
|
|
2013-10-23 09:58:32 +04:00
|
|
|
|
static void
|
2021-05-24 16:53:40 +03:00
|
|
|
|
shell_output_destroy(struct shell_output *shell_output)
|
2013-10-23 09:58:32 +04:00
|
|
|
|
{
|
2021-05-24 16:13:21 +03:00
|
|
|
|
struct desktop_shell *shell = shell_output->shell;
|
2013-10-23 09:58:32 +04:00
|
|
|
|
|
2019-04-20 15:20:18 +03:00
|
|
|
|
shell_for_each_layer(shell, shell_output_changed_move_layer, NULL);
|
2014-01-29 20:47:54 +04:00
|
|
|
|
|
2021-05-24 16:53:40 +03:00
|
|
|
|
if (shell_output->fade.animation) {
|
|
|
|
|
weston_view_animation_destroy(shell_output->fade.animation);
|
|
|
|
|
shell_output->fade.animation = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
desktop-shell: Reuse curtains for fades
Use the common infrastructure we have, rather than open-coding again.
In changing to the common weston_curtain infrastructure which was
introduced in a previous commit, there are two small functional
derivations.
After adding the view to a layer, we explicitly call
weston_view_geometry_dirty(). This is believed to have no functional
impact, as weston_views have their geometry-dirty flag set when they are
created.
weston_surface_damage() is also called to ensure that the surface is
scheduled for a repaint. As there is currently no good common mechanic
in the common code to ensure that output repaint will occur, due to the
damage propagating outwards from the weston_surface, we are forced to
call this to predictably ensure that the output will be repainted after
we have made this change to the scene graph which should result in the
user observing the new content being repainted.
It is possible that these changes are not strictly required in order for
the correct behaviour to occur. However, it is felt that explicitly
adding these calls is perhaps the least fragile way to ensure that the
behaviour continues to be correct and breakage is not observed,
especially with both view mapping and surface damage identified as areas
for future work which could be beneficial to Weston. If it is felt that
these calls can be removed, then this is certainly possible at a later
stage.
Lastly, there are many users within desktop-shell of the common pattern
of creating a weston_curtain and inserting it into the scene graph to be
painted. These users have been an area of both theoretical concern and
real-life observed fragility and breakage recently. By making each user
follow a common and predictable pattern of usage, each user is no longer
its own special case. This should make it easier to make the
desktop-shell codebase more robust, not only simplifying the codebase,
but improving observed behaviour.
In doing this, it is hoped that future structural and interface changes
become easier to make, allowing us to improve some of the more difficult
corners of the libweston API.
Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-01-19 02:01:56 +03:00
|
|
|
|
if (shell_output->fade.curtain)
|
2022-11-22 14:28:57 +03:00
|
|
|
|
weston_shell_utils_curtain_destroy(shell_output->fade.curtain);
|
2021-05-24 16:53:40 +03:00
|
|
|
|
|
|
|
|
|
if (shell_output->fade.startup_timer)
|
|
|
|
|
wl_event_source_remove(shell_output->fade.startup_timer);
|
|
|
|
|
|
2021-05-24 16:13:21 +03:00
|
|
|
|
if (shell_output->panel_surface)
|
|
|
|
|
wl_list_remove(&shell_output->panel_surface_listener.link);
|
|
|
|
|
if (shell_output->background_surface)
|
|
|
|
|
wl_list_remove(&shell_output->background_surface_listener.link);
|
|
|
|
|
wl_list_remove(&shell_output->destroy_listener.link);
|
|
|
|
|
wl_list_remove(&shell_output->link);
|
|
|
|
|
free(shell_output);
|
2013-10-23 09:58:32 +04:00
|
|
|
|
}
|
|
|
|
|
|
2021-05-24 16:53:40 +03:00
|
|
|
|
static void
|
|
|
|
|
handle_output_destroy(struct wl_listener *listener, void *data)
|
|
|
|
|
{
|
|
|
|
|
struct shell_output *shell_output =
|
|
|
|
|
container_of(listener, struct shell_output, destroy_listener);
|
|
|
|
|
|
|
|
|
|
shell_output_destroy(shell_output);
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-09 18:55:52 +03:00
|
|
|
|
static void
|
|
|
|
|
shell_resize_surface_to_output(struct desktop_shell *shell,
|
|
|
|
|
struct weston_surface *surface,
|
|
|
|
|
const struct weston_output *output)
|
|
|
|
|
{
|
|
|
|
|
if (!surface)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
weston_desktop_shell_send_configure(shell->child.desktop_shell, 0,
|
|
|
|
|
surface->resource,
|
|
|
|
|
output->width,
|
|
|
|
|
output->height);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
handle_output_resized(struct wl_listener *listener, void *data)
|
|
|
|
|
{
|
|
|
|
|
struct desktop_shell *shell =
|
|
|
|
|
container_of(listener, struct desktop_shell, resized_listener);
|
|
|
|
|
struct weston_output *output = (struct weston_output *)data;
|
|
|
|
|
struct shell_output *sh_output = find_shell_output_from_weston_output(shell, output);
|
|
|
|
|
|
|
|
|
|
shell_resize_surface_to_output(shell, sh_output->background_surface, output);
|
|
|
|
|
shell_resize_surface_to_output(shell, sh_output->panel_surface, output);
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-23 09:58:32 +04:00
|
|
|
|
static void
|
|
|
|
|
create_shell_output(struct desktop_shell *shell,
|
|
|
|
|
struct weston_output *output)
|
|
|
|
|
{
|
|
|
|
|
struct shell_output *shell_output;
|
|
|
|
|
|
|
|
|
|
shell_output = zalloc(sizeof *shell_output);
|
|
|
|
|
if (shell_output == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
shell_output->output = output;
|
|
|
|
|
shell_output->shell = shell;
|
|
|
|
|
shell_output->destroy_listener.notify = handle_output_destroy;
|
|
|
|
|
wl_signal_add(&output->destroy_signal,
|
|
|
|
|
&shell_output->destroy_listener);
|
2013-10-24 10:36:04 +04:00
|
|
|
|
wl_list_insert(shell->output_list.prev, &shell_output->link);
|
2019-04-20 15:20:18 +03:00
|
|
|
|
|
|
|
|
|
if (wl_list_length(&shell->output_list) == 1)
|
|
|
|
|
shell_for_each_layer(shell,
|
|
|
|
|
shell_output_changed_move_layer, NULL);
|
2013-10-23 09:58:32 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
handle_output_create(struct wl_listener *listener, void *data)
|
|
|
|
|
{
|
|
|
|
|
struct desktop_shell *shell =
|
|
|
|
|
container_of(listener, struct desktop_shell, output_create_listener);
|
|
|
|
|
struct weston_output *output = (struct weston_output *)data;
|
|
|
|
|
|
|
|
|
|
create_shell_output(shell, output);
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-29 20:47:52 +04:00
|
|
|
|
static void
|
2014-04-11 14:57:15 +04:00
|
|
|
|
handle_output_move_layer(struct desktop_shell *shell,
|
|
|
|
|
struct weston_layer *layer, void *data)
|
2014-01-29 20:47:52 +04:00
|
|
|
|
{
|
2014-04-11 14:57:15 +04:00
|
|
|
|
struct weston_output *output = data;
|
2014-01-29 20:47:52 +04:00
|
|
|
|
struct weston_view *view;
|
|
|
|
|
float x, y;
|
|
|
|
|
|
2014-07-09 23:12:56 +04:00
|
|
|
|
wl_list_for_each(view, &layer->view_list.link, layer_link.link) {
|
2014-04-11 14:57:15 +04:00
|
|
|
|
if (view->output != output)
|
|
|
|
|
continue;
|
2014-01-29 20:47:52 +04:00
|
|
|
|
|
2022-02-04 02:47:41 +03:00
|
|
|
|
x = view->geometry.pos_offset.x + output->move_x;
|
|
|
|
|
y = view->geometry.pos_offset.y + output->move_y;
|
2014-04-11 14:57:15 +04:00
|
|
|
|
weston_view_set_position(view, x, y);
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-01-29 20:47:52 +04:00
|
|
|
|
|
2014-04-11 14:57:15 +04:00
|
|
|
|
static void
|
|
|
|
|
handle_output_move(struct wl_listener *listener, void *data)
|
|
|
|
|
{
|
|
|
|
|
struct desktop_shell *shell;
|
2014-01-29 20:47:52 +04:00
|
|
|
|
|
2014-04-11 14:57:15 +04:00
|
|
|
|
shell = container_of(listener, struct desktop_shell,
|
|
|
|
|
output_move_listener);
|
|
|
|
|
|
|
|
|
|
shell_for_each_layer(shell, handle_output_move_layer, data);
|
2014-01-29 20:47:52 +04:00
|
|
|
|
}
|
|
|
|
|
|
2013-10-23 09:58:32 +04:00
|
|
|
|
static void
|
|
|
|
|
setup_output_destroy_handler(struct weston_compositor *ec,
|
|
|
|
|
struct desktop_shell *shell)
|
|
|
|
|
{
|
|
|
|
|
struct weston_output *output;
|
|
|
|
|
|
|
|
|
|
wl_list_init(&shell->output_list);
|
|
|
|
|
wl_list_for_each(output, &ec->output_list, link)
|
|
|
|
|
create_shell_output(shell, output);
|
|
|
|
|
|
|
|
|
|
shell->output_create_listener.notify = handle_output_create;
|
|
|
|
|
wl_signal_add(&ec->output_created_signal,
|
|
|
|
|
&shell->output_create_listener);
|
2014-01-29 20:47:52 +04:00
|
|
|
|
|
|
|
|
|
shell->output_move_listener.notify = handle_output_move;
|
|
|
|
|
wl_signal_add(&ec->output_moved_signal, &shell->output_move_listener);
|
2013-10-23 09:58:32 +04:00
|
|
|
|
}
|
|
|
|
|
|
2021-11-10 18:50:50 +03:00
|
|
|
|
static void
|
2022-05-05 15:38:14 +03:00
|
|
|
|
desktop_shell_destroy_layer(struct weston_layer *layer)
|
2021-11-10 18:50:50 +03:00
|
|
|
|
{
|
2022-05-17 17:49:35 +03:00
|
|
|
|
struct weston_view *view;
|
|
|
|
|
bool removed;
|
2021-11-10 18:50:50 +03:00
|
|
|
|
|
2022-05-17 17:49:35 +03:00
|
|
|
|
do {
|
|
|
|
|
removed = false;
|
2022-01-17 17:20:09 +03:00
|
|
|
|
|
2021-11-10 18:50:50 +03:00
|
|
|
|
/* fullscreen_layer is special as it would have a view with an
|
|
|
|
|
* additional black_view created and added to its layer_link
|
|
|
|
|
* fullscreen view. See shell_ensure_fullscreen_black_view()
|
|
|
|
|
*
|
2022-03-31 23:20:45 +03:00
|
|
|
|
* Note that we do not choose to destroy all other potential
|
|
|
|
|
* views we find in the layer, but instead we explicitly verify
|
|
|
|
|
* if the view in question was explicitly created by
|
|
|
|
|
* desktop-shell, rather than libweston-desktop (in
|
|
|
|
|
* desktop_surface_added()).
|
|
|
|
|
*
|
|
|
|
|
* This is particularly important because libweston-desktop
|
|
|
|
|
* could create additional views, which are managed implicitly,
|
|
|
|
|
* but which are still being added to the layer list.
|
|
|
|
|
*
|
2022-05-17 17:49:35 +03:00
|
|
|
|
* We avoid using wl_list_for_each_safe() as it can't handle
|
|
|
|
|
* removal of the next item in the list, so with this approach
|
|
|
|
|
* we restart the loop as long as we keep removing views from
|
|
|
|
|
* the list.
|
2022-03-31 23:20:45 +03:00
|
|
|
|
*/
|
2022-05-17 17:49:35 +03:00
|
|
|
|
wl_list_for_each(view, &layer->view_list.link, layer_link.link) {
|
|
|
|
|
struct shell_surface *shsurf =
|
|
|
|
|
get_shell_surface(view->surface);
|
|
|
|
|
if (shsurf) {
|
|
|
|
|
desktop_shell_destroy_surface(shsurf);
|
|
|
|
|
removed = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} while (removed);
|
2021-11-10 18:50:50 +03:00
|
|
|
|
|
|
|
|
|
weston_layer_fini(layer);
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-22 15:43:43 +04:00
|
|
|
|
static void
|
2012-04-12 17:55:26 +04:00
|
|
|
|
shell_destroy(struct wl_listener *listener, void *data)
|
2011-12-22 15:43:43 +04:00
|
|
|
|
{
|
2012-04-16 18:31:41 +04:00
|
|
|
|
struct desktop_shell *shell =
|
|
|
|
|
container_of(listener, struct desktop_shell, destroy_listener);
|
2013-10-23 09:58:32 +04:00
|
|
|
|
struct shell_output *shell_output, *tmp;
|
2021-08-26 16:37:24 +03:00
|
|
|
|
struct shell_seat *shseat, *shseat_next;
|
2011-12-22 15:43:43 +04:00
|
|
|
|
|
2014-01-17 04:46:28 +04:00
|
|
|
|
/* Force state to unlocked so we don't try to fade */
|
|
|
|
|
shell->locked = false;
|
shell: fix race on desktop-shell exit
The desktop shell plugin registers both a wl_client destroy signal
listener, and a sigchld handler, when launching weston-desktop-shell.
However, nothing guarantees in which order do the wl_client destructor
and the sigchld handler run.
Luckily, the sigchld handler cannot interrupt any code, because we
handle the signal via signalfd, which means it is handled like any event
in the compositor's main event loop.
Still, shell.c has a race, that when lost, can cause a crash, as
described in bug #82957.
If the sigchld handler happens to run first, it will try to launch a new
weston-desktop-shell without removing the destroy listener from the old
wl_client first. This leads to list corruption, that may cause a crash
when the old wl_client gets destroyed.
Simply removing the destroy listener in the sigchld handler is not
enough, because respawning sets shell->child.client pointer, and if
the wl_client destructor runs after, it will reset it to NULL.
OTOH, the wl_client destroy handler cannot reset shell->child.process,
because that would cause the sigchld handler in weston core to not find
the process tracker anymore, and report that an unknown process exited.
Turns out, that to make everything work, we would need to wait for both
the wl_client destructor and the sigchld handler to have run, before
respawn. This gets tricky.
Instead, solve the problem by removing shell->child.process. Use the new
weston_client_start() which automatically creates and manages the struct
weston_process. The shell does not need to know about the process exit,
it only needs to know about the client disconnect. Weston-desktop-shell
will never attempt to reconnect, and it would not work even if it did,
so disconnect is equivalent to weston-desktop-shell exiting.
This should permanently solve the race for weston-desktop-shell.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=82957
Cc: Boyan Ding <stu_dby@126.com>
Cc: Derek Foreman <derekf@osg.samsung.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
2014-08-27 13:11:53 +04:00
|
|
|
|
|
|
|
|
|
if (shell->child.client) {
|
|
|
|
|
/* disable respawn */
|
|
|
|
|
wl_list_remove(&shell->child.client_destroy_listener.link);
|
2012-01-02 18:00:24 +04:00
|
|
|
|
wl_client_destroy(shell->child.client);
|
shell: fix race on desktop-shell exit
The desktop shell plugin registers both a wl_client destroy signal
listener, and a sigchld handler, when launching weston-desktop-shell.
However, nothing guarantees in which order do the wl_client destructor
and the sigchld handler run.
Luckily, the sigchld handler cannot interrupt any code, because we
handle the signal via signalfd, which means it is handled like any event
in the compositor's main event loop.
Still, shell.c has a race, that when lost, can cause a crash, as
described in bug #82957.
If the sigchld handler happens to run first, it will try to launch a new
weston-desktop-shell without removing the destroy listener from the old
wl_client first. This leads to list corruption, that may cause a crash
when the old wl_client gets destroyed.
Simply removing the destroy listener in the sigchld handler is not
enough, because respawning sets shell->child.client pointer, and if
the wl_client destructor runs after, it will reset it to NULL.
OTOH, the wl_client destroy handler cannot reset shell->child.process,
because that would cause the sigchld handler in weston core to not find
the process tracker anymore, and report that an unknown process exited.
Turns out, that to make everything work, we would need to wait for both
the wl_client destructor and the sigchld handler to have run, before
respawn. This gets tricky.
Instead, solve the problem by removing shell->child.process. Use the new
weston_client_start() which automatically creates and manages the struct
weston_process. The shell does not need to know about the process exit,
it only needs to know about the client disconnect. Weston-desktop-shell
will never attempt to reconnect, and it would not work even if it did,
so disconnect is equivalent to weston-desktop-shell exiting.
This should permanently solve the race for weston-desktop-shell.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=82957
Cc: Boyan Ding <stu_dby@126.com>
Cc: Derek Foreman <derekf@osg.samsung.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
2014-08-27 13:11:53 +04:00
|
|
|
|
}
|
2012-01-02 18:00:24 +04:00
|
|
|
|
|
2018-08-07 16:35:02 +03:00
|
|
|
|
wl_list_remove(&shell->destroy_listener.link);
|
2013-02-21 20:35:23 +04:00
|
|
|
|
wl_list_remove(&shell->idle_listener.link);
|
|
|
|
|
wl_list_remove(&shell->wake_listener.link);
|
2015-12-11 21:57:05 +03:00
|
|
|
|
wl_list_remove(&shell->transform_listener.link);
|
2013-12-04 23:00:19 +04:00
|
|
|
|
|
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 16:09:17 +03:00
|
|
|
|
text_backend_destroy(shell->text_backend);
|
2013-12-04 23:00:19 +04:00
|
|
|
|
input_panel_destroy(shell);
|
2012-05-16 16:04:19 +04:00
|
|
|
|
|
2021-05-24 16:53:40 +03:00
|
|
|
|
wl_list_for_each_safe(shell_output, tmp, &shell->output_list, link)
|
|
|
|
|
shell_output_destroy(shell_output);
|
2013-10-23 09:58:32 +04:00
|
|
|
|
|
|
|
|
|
wl_list_remove(&shell->output_create_listener.link);
|
2014-05-01 07:46:25 +04:00
|
|
|
|
wl_list_remove(&shell->output_move_listener.link);
|
2016-06-09 18:55:52 +03:00
|
|
|
|
wl_list_remove(&shell->resized_listener.link);
|
2013-10-23 09:58:32 +04:00
|
|
|
|
|
2021-08-26 16:37:24 +03:00
|
|
|
|
wl_list_for_each_safe(shseat, shseat_next, &shell->seat_list, link)
|
|
|
|
|
desktop_shell_destroy_seat(shseat);
|
|
|
|
|
|
2021-05-24 14:42:00 +03:00
|
|
|
|
weston_desktop_destroy(shell->desktop);
|
|
|
|
|
|
2022-06-22 18:16:02 +03:00
|
|
|
|
workspace_destroy(&shell->workspace);
|
2012-06-13 02:01:22 +04:00
|
|
|
|
|
2022-05-05 15:38:14 +03:00
|
|
|
|
desktop_shell_destroy_layer(&shell->panel_layer);
|
|
|
|
|
desktop_shell_destroy_layer(&shell->background_layer);
|
|
|
|
|
desktop_shell_destroy_layer(&shell->lock_layer);
|
|
|
|
|
desktop_shell_destroy_layer(&shell->input_panel_layer);
|
|
|
|
|
desktop_shell_destroy_layer(&shell->minimized_layer);
|
|
|
|
|
desktop_shell_destroy_layer(&shell->fullscreen_layer);
|
2021-05-14 14:37:46 +03:00
|
|
|
|
|
2013-11-20 16:22:29 +04:00
|
|
|
|
free(shell->client);
|
2011-12-22 15:43:43 +04:00
|
|
|
|
free(shell);
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-20 19:54:25 +04:00
|
|
|
|
static void
|
|
|
|
|
shell_add_bindings(struct weston_compositor *ec, struct desktop_shell *shell)
|
|
|
|
|
{
|
|
|
|
|
uint32_t mod;
|
|
|
|
|
|
2016-01-12 13:21:48 +03:00
|
|
|
|
if (shell->allow_zap)
|
|
|
|
|
weston_compositor_add_key_binding(ec, KEY_BACKSPACE,
|
|
|
|
|
MODIFIER_CTRL | MODIFIER_ALT,
|
|
|
|
|
terminate_binding, ec);
|
|
|
|
|
|
2012-04-20 19:54:25 +04:00
|
|
|
|
/* fixed bindings */
|
2012-05-30 19:31:58 +04:00
|
|
|
|
weston_compositor_add_button_binding(ec, BTN_LEFT, 0,
|
|
|
|
|
click_to_activate_binding,
|
|
|
|
|
shell);
|
2014-04-07 22:52:17 +04:00
|
|
|
|
weston_compositor_add_button_binding(ec, BTN_RIGHT, 0,
|
|
|
|
|
click_to_activate_binding,
|
|
|
|
|
shell);
|
2013-10-03 19:43:04 +04:00
|
|
|
|
weston_compositor_add_touch_binding(ec, 0,
|
|
|
|
|
touch_to_activate_binding,
|
|
|
|
|
shell);
|
2021-01-20 11:34:09 +03:00
|
|
|
|
weston_compositor_add_tablet_tool_binding(ec, BTN_TOUCH, 0,
|
|
|
|
|
tablet_tool_activate_binding, shell);
|
2016-01-12 13:21:49 +03:00
|
|
|
|
weston_compositor_add_key_binding(ec, KEY_BRIGHTNESSDOWN, 0,
|
|
|
|
|
backlight_binding, ec);
|
|
|
|
|
weston_compositor_add_key_binding(ec, KEY_BRIGHTNESSUP, 0,
|
|
|
|
|
backlight_binding, ec);
|
2012-04-20 19:54:25 +04:00
|
|
|
|
|
|
|
|
|
mod = shell->binding_modifier;
|
2016-01-12 13:21:49 +03:00
|
|
|
|
if (!mod)
|
|
|
|
|
return;
|
|
|
|
|
|
2017-09-18 15:22:01 +03:00
|
|
|
|
/* This binding is not configurable, but is only enabled if there is a
|
|
|
|
|
* valid binding modifier. */
|
|
|
|
|
weston_compositor_add_axis_binding(ec, WL_POINTER_AXIS_VERTICAL_SCROLL,
|
|
|
|
|
MODIFIER_SUPER | MODIFIER_ALT,
|
|
|
|
|
surface_opacity_binding, NULL);
|
|
|
|
|
|
2014-01-12 01:10:21 +04:00
|
|
|
|
weston_compositor_add_key_binding(ec, KEY_M, mod | MODIFIER_SHIFT,
|
|
|
|
|
maximize_binding, NULL);
|
|
|
|
|
weston_compositor_add_key_binding(ec, KEY_F, mod | MODIFIER_SHIFT,
|
|
|
|
|
fullscreen_binding, NULL);
|
2012-05-30 19:31:58 +04:00
|
|
|
|
weston_compositor_add_button_binding(ec, BTN_LEFT, mod, move_binding,
|
|
|
|
|
shell);
|
2013-10-03 19:43:05 +04:00
|
|
|
|
weston_compositor_add_touch_binding(ec, mod, touch_move_binding, shell);
|
2015-06-26 00:03:30 +03:00
|
|
|
|
weston_compositor_add_button_binding(ec, BTN_RIGHT, mod,
|
2012-05-30 19:31:58 +04:00
|
|
|
|
resize_binding, shell);
|
2014-01-20 22:35:26 +04:00
|
|
|
|
weston_compositor_add_button_binding(ec, BTN_LEFT,
|
|
|
|
|
mod | MODIFIER_SHIFT,
|
|
|
|
|
resize_binding, shell);
|
2013-05-22 19:03:04 +04:00
|
|
|
|
|
2022-07-16 00:22:00 +03:00
|
|
|
|
weston_compositor_add_key_binding(ec, KEY_LEFT, mod | MODIFIER_SHIFT,
|
|
|
|
|
set_tiled_orientation_left, NULL);
|
|
|
|
|
weston_compositor_add_key_binding(ec, KEY_RIGHT, mod | MODIFIER_SHIFT,
|
|
|
|
|
set_tiled_orientation_right, NULL);
|
|
|
|
|
weston_compositor_add_key_binding(ec, KEY_UP, mod | MODIFIER_SHIFT,
|
|
|
|
|
set_tiled_orientation_up, NULL);
|
|
|
|
|
weston_compositor_add_key_binding(ec, KEY_DOWN, mod | MODIFIER_SHIFT,
|
|
|
|
|
set_tiled_orientation_down, NULL);
|
|
|
|
|
|
2013-05-22 19:03:04 +04:00
|
|
|
|
if (ec->capabilities & WESTON_CAP_ROTATION_ANY)
|
2015-06-26 00:03:30 +03:00
|
|
|
|
weston_compositor_add_button_binding(ec, BTN_MIDDLE, mod,
|
2013-05-22 19:03:04 +04:00
|
|
|
|
rotate_binding, NULL);
|
|
|
|
|
|
2012-05-30 19:31:58 +04:00
|
|
|
|
weston_compositor_add_key_binding(ec, KEY_TAB, mod, switcher_binding,
|
|
|
|
|
shell);
|
|
|
|
|
weston_compositor_add_key_binding(ec, KEY_F9, mod, backlight_binding,
|
|
|
|
|
ec);
|
|
|
|
|
weston_compositor_add_key_binding(ec, KEY_F10, mod, backlight_binding,
|
|
|
|
|
ec);
|
|
|
|
|
weston_compositor_add_key_binding(ec, KEY_K, mod,
|
|
|
|
|
force_kill_binding, shell);
|
2012-11-08 19:20:45 +04:00
|
|
|
|
|
2015-02-19 18:02:13 +03:00
|
|
|
|
weston_install_debug_key_binding(ec, mod);
|
2012-04-20 19:54:25 +04:00
|
|
|
|
}
|
|
|
|
|
|
2014-04-22 04:42:58 +04:00
|
|
|
|
static void
|
|
|
|
|
handle_seat_created(struct wl_listener *listener, void *data)
|
|
|
|
|
{
|
|
|
|
|
struct weston_seat *seat = data;
|
2021-08-26 16:37:24 +03:00
|
|
|
|
struct desktop_shell *shell =
|
|
|
|
|
container_of(listener, struct desktop_shell, seat_create_listener);
|
2014-04-22 04:42:58 +04:00
|
|
|
|
|
2021-08-26 16:37:24 +03:00
|
|
|
|
create_shell_seat(shell, seat);
|
2014-04-22 04:42:58 +04:00
|
|
|
|
}
|
|
|
|
|
|
2011-05-03 06:09:20 +04:00
|
|
|
|
WL_EXPORT int
|
2016-12-02 16:17:08 +03:00
|
|
|
|
wet_shell_init(struct weston_compositor *ec,
|
|
|
|
|
int *argc, char *argv[])
|
2011-01-18 15:53:49 +03:00
|
|
|
|
{
|
2012-08-10 18:05:39 +04:00
|
|
|
|
struct weston_seat *seat;
|
2012-04-16 18:31:41 +04:00
|
|
|
|
struct desktop_shell *shell;
|
2012-09-25 18:57:01 +04:00
|
|
|
|
struct wl_event_loop *loop;
|
2011-04-23 21:04:11 +04:00
|
|
|
|
|
2013-08-08 05:57:05 +04:00
|
|
|
|
shell = zalloc(sizeof *shell);
|
2011-04-23 21:04:11 +04:00
|
|
|
|
if (shell == NULL)
|
|
|
|
|
return -1;
|
|
|
|
|
|
2011-09-06 21:48:16 +04:00
|
|
|
|
shell->compositor = ec;
|
2012-04-12 17:55:26 +04:00
|
|
|
|
|
2019-11-06 13:59:32 +03:00
|
|
|
|
if (!weston_compositor_add_destroy_listener_once(ec,
|
|
|
|
|
&shell->destroy_listener,
|
|
|
|
|
shell_destroy)) {
|
|
|
|
|
free(shell);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-21 20:35:23 +04:00
|
|
|
|
shell->idle_listener.notify = idle_handler;
|
|
|
|
|
wl_signal_add(&ec->idle_signal, &shell->idle_listener);
|
|
|
|
|
shell->wake_listener.notify = wake_handler;
|
|
|
|
|
wl_signal_add(&ec->wake_signal, &shell->wake_listener);
|
2015-12-11 21:57:05 +03:00
|
|
|
|
shell->transform_listener.notify = transform_handler;
|
|
|
|
|
wl_signal_add(&ec->transform_signal, &shell->transform_listener);
|
2013-12-04 23:00:19 +04:00
|
|
|
|
|
2016-12-17 15:40:51 +03:00
|
|
|
|
weston_layer_init(&shell->fullscreen_layer, ec);
|
|
|
|
|
weston_layer_init(&shell->panel_layer, ec);
|
|
|
|
|
weston_layer_init(&shell->background_layer, ec);
|
|
|
|
|
weston_layer_init(&shell->lock_layer, ec);
|
|
|
|
|
weston_layer_init(&shell->input_panel_layer, ec);
|
|
|
|
|
|
|
|
|
|
weston_layer_set_position(&shell->fullscreen_layer,
|
|
|
|
|
WESTON_LAYER_POSITION_FULLSCREEN);
|
|
|
|
|
weston_layer_set_position(&shell->panel_layer,
|
|
|
|
|
WESTON_LAYER_POSITION_UI);
|
|
|
|
|
weston_layer_set_position(&shell->background_layer,
|
|
|
|
|
WESTON_LAYER_POSITION_BACKGROUND);
|
2012-06-13 02:01:22 +04:00
|
|
|
|
|
2021-08-26 16:37:24 +03:00
|
|
|
|
wl_list_init(&shell->seat_list);
|
2012-02-29 21:42:35 +04:00
|
|
|
|
|
2013-12-04 23:00:19 +04:00
|
|
|
|
if (input_panel_setup(shell) < 0)
|
|
|
|
|
return -1;
|
|
|
|
|
|
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 16:09:17 +03:00
|
|
|
|
shell->text_backend = text_backend_init(ec);
|
2015-06-11 00:16:02 +03:00
|
|
|
|
|
2013-05-27 05:48:14 +04:00
|
|
|
|
shell_configuration(shell);
|
2011-12-07 13:49:52 +04:00
|
|
|
|
|
2022-06-22 18:16:02 +03:00
|
|
|
|
workspace_create(shell);
|
2012-06-13 02:01:22 +04:00
|
|
|
|
|
2016-12-17 15:40:51 +03:00
|
|
|
|
weston_layer_init(&shell->minimized_layer, ec);
|
2014-02-26 18:52:13 +04:00
|
|
|
|
|
2016-08-12 11:41:36 +03:00
|
|
|
|
shell->desktop = weston_desktop_create(ec, &shell_desktop_api, shell);
|
|
|
|
|
if (!shell->desktop)
|
2013-12-03 21:35:45 +04:00
|
|
|
|
return -1;
|
|
|
|
|
|
2013-07-09 03:03:57 +04:00
|
|
|
|
if (wl_global_create(ec->wl_display,
|
2015-11-17 11:00:33 +03:00
|
|
|
|
&weston_desktop_shell_interface, 1,
|
2013-07-09 03:03:57 +04:00
|
|
|
|
shell, bind_desktop_shell) == NULL)
|
2011-09-06 21:48:16 +04:00
|
|
|
|
return -1;
|
|
|
|
|
|
2017-11-16 19:21:01 +03:00
|
|
|
|
weston_compositor_get_time(&shell->child.deathstamp);
|
2012-09-25 18:57:01 +04:00
|
|
|
|
|
2015-11-17 11:00:33 +03:00
|
|
|
|
shell->panel_position = WESTON_DESKTOP_SHELL_PANEL_POSITION_TOP;
|
2014-08-20 17:53:19 +04:00
|
|
|
|
|
2013-10-23 09:58:32 +04:00
|
|
|
|
setup_output_destroy_handler(ec, shell);
|
|
|
|
|
|
2012-09-25 18:57:01 +04:00
|
|
|
|
loop = wl_display_get_event_loop(ec->wl_display);
|
|
|
|
|
wl_event_loop_add_idle(loop, launch_desktop_shell_process, shell);
|
2011-11-03 16:11:32 +04:00
|
|
|
|
|
2014-04-22 04:42:58 +04:00
|
|
|
|
wl_list_for_each(seat, &ec->seat_list, link)
|
2021-08-26 16:37:24 +03:00
|
|
|
|
create_shell_seat(shell, seat);
|
2014-04-22 04:42:58 +04:00
|
|
|
|
shell->seat_create_listener.notify = handle_seat_created;
|
|
|
|
|
wl_signal_add(&ec->seat_created_signal, &shell->seat_create_listener);
|
2012-06-05 17:58:51 +04:00
|
|
|
|
|
2016-06-09 18:55:52 +03:00
|
|
|
|
shell->resized_listener.notify = handle_output_resized;
|
|
|
|
|
wl_signal_add(&ec->output_resized_signal, &shell->resized_listener);
|
|
|
|
|
|
2013-12-12 02:45:12 +04:00
|
|
|
|
screenshooter_create(ec);
|
|
|
|
|
|
2012-04-20 19:54:25 +04:00
|
|
|
|
shell_add_bindings(ec, shell);
|
2011-04-13 01:25:42 +04:00
|
|
|
|
|
shell: wait for desktop-shell init before fade in
On Raspberry Pi, weston-desktop-shell is so slow to start, that the
compositor has time to run the fade-in before the wallpaper is up. The
user launching Weston sees the screen flipping to black, the fbcon
fading in, and then the desktop popping up.
To fix this, wait for the weston-desktop-shell to draw
everything before starting the initial fade-in. A new request is
added to the private desktop-shell protocol to signal it. If a
desktop-shell client does not support the new request, the fade-in
happens already at bind time.
If weston-desktop-shell crashes, or does not send the 'desktop_ready'
request in 15 seconds, the compositor will fade in anyway. This should
avoid a blocked screen in case weston-desktop-shell malfunction.
shell_fade_startup() does not directly start the fade-in but schedules
an idle callback, so that the compositor can process all pending events
before starting the fade clock. Otherwise (on RPi) we risk skipping part
of the animation. Yes, it is a hack, that should have been done in
window.c and weston-desktop-shell instead.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2013-05-22 19:03:09 +04:00
|
|
|
|
shell_fade_init(shell);
|
compositor: Move fade animation out of core Weston into shell
Previously, it was impossible to override the fade in/out behavior of
Weston using a different shell, since this was implemented in core
Weston. This also led to complicated interaction between the shell and
the core when displaying lock surfaces and screensavers.
This patch starts to solve this issue by moving the fade animation out
of the core. On compositor.c, besides deleting the fade code, the idle
handler had to be changed to emit the lock signal, since it was called
from the fade_frame() function before. This causes a slight change of
behavior, since before the fade would happen with the compositor being
active, while now it is already in the idle state. That leads to the
dpms state being set when cancelling the fade with mouse movement, and
in turn, to a slight freeze with drm compositor. This problem will be
fixed in a follow up patch.
On the shell side, the fade was re-implemented in a slightly different
manner. Instead of using a custom frame function, the fade animation
from animation.c is used. The interface for starting the fade was also
changed to take the value of an enum instead of a float alpha value,
in order to improve readability.
2013-02-21 20:35:20 +04:00
|
|
|
|
|
2014-08-28 12:41:26 +04:00
|
|
|
|
clock_gettime(CLOCK_MONOTONIC, &shell->startup_time);
|
|
|
|
|
|
2011-01-18 15:53:49 +03:00
|
|
|
|
return 0;
|
|
|
|
|
}
|