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.
|
2011-01-18 15:53:49 +03:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, distribute, and sell this software and
|
|
|
|
* its documentation for any purpose is hereby granted without fee, provided
|
|
|
|
* that the above copyright notice appear in all copies and that both that
|
|
|
|
* copyright notice and this permission notice appear in supporting
|
|
|
|
* documentation, and that the name of the copyright holders not be used in
|
|
|
|
* advertising or publicity pertaining to distribution of the software
|
|
|
|
* without specific, written prior permission. The copyright holders make
|
|
|
|
* no representations about the suitability of this software for any
|
|
|
|
* purpose. It is provided "as is" without express or implied warranty.
|
|
|
|
*
|
|
|
|
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
|
|
|
|
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
|
|
* FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
|
|
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
|
|
|
|
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
|
|
|
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
2011-09-06 21:48:16 +04:00
|
|
|
#include <stdio.h>
|
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
|
|
|
#include <stdbool.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>
|
2011-01-18 15:53:49 +03:00
|
|
|
|
2011-11-22 16:18:50 +04:00
|
|
|
#include <wayland-server.h>
|
2011-01-18 15:53:49 +03:00
|
|
|
#include "compositor.h"
|
2011-09-06 21:48:16 +04:00
|
|
|
#include "desktop-shell-server-protocol.h"
|
2011-12-07 13:49:52 +04:00
|
|
|
#include "../shared/config-parser.h"
|
2011-01-18 15:53:49 +03:00
|
|
|
|
2012-04-25 15:09:52 +04:00
|
|
|
enum animation_type {
|
|
|
|
ANIMATION_NONE,
|
|
|
|
|
|
|
|
ANIMATION_ZOOM,
|
|
|
|
ANIMATION_FADE
|
|
|
|
};
|
|
|
|
|
2012-04-16 18:31:41 +04:00
|
|
|
struct desktop_shell {
|
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;
|
2012-04-12 17:55:26 +04:00
|
|
|
|
|
|
|
struct wl_listener lock_listener;
|
|
|
|
struct wl_listener unlock_listener;
|
|
|
|
struct wl_listener destroy_listener;
|
2011-11-03 16:11:32 +04:00
|
|
|
|
2012-02-29 21:42:35 +04:00
|
|
|
struct weston_layer fullscreen_layer;
|
|
|
|
struct weston_layer panel_layer;
|
|
|
|
struct weston_layer toplevel_layer;
|
|
|
|
struct weston_layer background_layer;
|
|
|
|
struct weston_layer lock_layer;
|
|
|
|
|
2011-11-03 16:11:32 +04:00
|
|
|
struct {
|
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_process process;
|
2011-11-03 16:11:32 +04:00
|
|
|
struct wl_client *client;
|
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
|
|
|
struct wl_resource *desktop_shell;
|
2012-01-17 16:36:27 +04:00
|
|
|
|
|
|
|
unsigned deathcount;
|
|
|
|
uint32_t deathstamp;
|
2011-11-03 16:11:32 +04:00
|
|
|
} child;
|
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
|
|
|
|
|
|
|
bool locked;
|
|
|
|
bool prepare_event_sent;
|
2011-11-15 15:34:54 +04:00
|
|
|
|
2011-11-28 16:11:15 +04:00
|
|
|
struct shell_surface *lock_surface;
|
2011-11-16 01:39:55 +04:00
|
|
|
struct wl_listener lock_surface_listener;
|
2011-11-22 15:43:52 +04:00
|
|
|
|
|
|
|
struct wl_list backgrounds;
|
|
|
|
struct wl_list panels;
|
protocol: add screensaver interface
Add the screensaver interface to the desktop-shell protocol file. Also
add stubs for it in the compositor, and make wscreensaver to bind to the
screensaver interface. Wscreensaver gets a new option --demo to retain
the current behaviour as a regular wayland client.
When a screensaver application starts, it should bind to the screensaver
interface, enumerate all outputs, create a surface per output, and
register those surfaces via screensaver::set_surface request. Then it
continues with the usual animation loop, waiting for frame events. The
compositor will decide, when the given screensaver surfaces are
displayed. A screensaver application should respond to outputs coming
and going away by creating and destroying surfaces.
The compositor is supposed to activate a screensaver by exec'ing it, and
stop the screensaver by killing the client process. Only one client may
be bound to the screensaver interface at a time. If there already is a
client, the compositor could either kill it first, or not exec a new
one.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-24 13:34:05 +04:00
|
|
|
|
2011-11-30 18:26:35 +04:00
|
|
|
struct {
|
2011-12-22 15:43:43 +04:00
|
|
|
char *path;
|
2011-12-07 18:22:00 +04:00
|
|
|
int duration;
|
2011-11-30 18:26:35 +04:00
|
|
|
struct wl_resource *binding;
|
|
|
|
struct wl_list surfaces;
|
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_process process;
|
2011-11-30 18:26:35 +04:00
|
|
|
} screensaver;
|
2012-03-04 23:53:40 +04:00
|
|
|
|
2012-04-20 19:54:25 +04:00
|
|
|
uint32_t binding_modifier;
|
2012-04-25 15:09:52 +04:00
|
|
|
enum animation_type win_animation_type;
|
2012-03-04 23:53:40 +04:00
|
|
|
struct weston_surface *debug_repaint_surface;
|
2011-11-15 15:34:54 +04:00
|
|
|
};
|
|
|
|
|
2011-11-23 19:52:40 +04:00
|
|
|
enum shell_surface_type {
|
2011-12-01 12:42:22 +04:00
|
|
|
SHELL_SURFACE_NONE,
|
2011-11-23 19:52:40 +04:00
|
|
|
|
2011-11-23 18:42:16 +04:00
|
|
|
SHELL_SURFACE_PANEL,
|
|
|
|
SHELL_SURFACE_BACKGROUND,
|
|
|
|
SHELL_SURFACE_LOCK,
|
2011-11-30 18:26:35 +04:00
|
|
|
SHELL_SURFACE_SCREENSAVER,
|
2011-11-23 19:52:40 +04:00
|
|
|
|
|
|
|
SHELL_SURFACE_TOPLEVEL,
|
|
|
|
SHELL_SURFACE_TRANSIENT,
|
2012-01-05 07:19:14 +04:00
|
|
|
SHELL_SURFACE_FULLSCREEN,
|
2012-02-07 04:45:41 +04:00
|
|
|
SHELL_SURFACE_MAXIMIZED,
|
2012-01-05 07:19:14 +04:00
|
|
|
SHELL_SURFACE_POPUP
|
2011-11-23 18:42:16 +04:00
|
|
|
};
|
|
|
|
|
2012-04-18 05:06:18 +04:00
|
|
|
struct ping_timer {
|
|
|
|
struct wl_event_source *source;
|
|
|
|
uint32_t serial;
|
|
|
|
};
|
|
|
|
|
2011-11-23 18:14:12 +04:00
|
|
|
struct shell_surface {
|
2011-11-25 14:09:16 +04:00
|
|
|
struct wl_resource resource;
|
|
|
|
|
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_surface *surface;
|
2011-11-25 14:09:16 +04:00
|
|
|
struct wl_listener surface_destroy_listener;
|
2012-01-05 07:19:14 +04:00
|
|
|
struct shell_surface *parent;
|
2012-04-16 18:31:41 +04:00
|
|
|
struct desktop_shell *shell;
|
2011-11-23 18:42:16 +04:00
|
|
|
|
2011-11-23 19:52:40 +04:00
|
|
|
enum shell_surface_type type;
|
|
|
|
int32_t saved_x, saved_y;
|
2012-03-01 08:57:46 +04:00
|
|
|
bool saved_position_valid;
|
2012-04-18 05:06:18 +04:00
|
|
|
int unresponsive;
|
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-02-18 16:05:29 +04:00
|
|
|
struct wl_pointer_grab grab;
|
2012-01-05 07:19:14 +04:00
|
|
|
int32_t x, y;
|
2012-02-07 16:19:01 +04:00
|
|
|
struct weston_transform parent_transform;
|
2012-01-05 07:19:14 +04:00
|
|
|
int32_t initial_up;
|
2012-04-13 20:40:07 +04:00
|
|
|
struct wl_input_device *device;
|
|
|
|
uint32_t serial;
|
2012-01-05 07:19:14 +04:00
|
|
|
} popup;
|
|
|
|
|
2012-03-01 08:57:46 +04:00
|
|
|
struct {
|
|
|
|
enum wl_shell_surface_fullscreen_method type;
|
|
|
|
struct weston_transform transform; /* matrix from x, y */
|
|
|
|
uint32_t framerate;
|
|
|
|
struct weston_surface *black_surface;
|
|
|
|
} fullscreen;
|
|
|
|
|
2012-04-18 05:06:18 +04:00
|
|
|
struct ping_timer *ping_timer;
|
|
|
|
|
2012-04-18 05:06:20 +04:00
|
|
|
struct {
|
|
|
|
struct weston_animation current;
|
|
|
|
int exists;
|
|
|
|
int fading_in;
|
|
|
|
uint32_t timestamp;
|
|
|
|
} unresponsive_animation;
|
|
|
|
|
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;
|
2011-11-22 15:43:52 +04:00
|
|
|
struct wl_list link;
|
2012-03-27 18:36:42 +04:00
|
|
|
|
|
|
|
int force_configure;
|
2011-11-23 18:14:12 +04:00
|
|
|
};
|
|
|
|
|
2012-04-04 18:48:05 +04:00
|
|
|
struct shell_grab {
|
2012-02-18 16:05:29 +04:00
|
|
|
struct wl_pointer_grab grab;
|
2012-04-04 18:48:05 +04:00
|
|
|
struct shell_surface *shsurf;
|
|
|
|
struct wl_listener shsurf_destroy_listener;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct weston_move_grab {
|
|
|
|
struct shell_grab base;
|
2011-01-18 15:53:49 +03:00
|
|
|
int32_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 {
|
|
|
|
int32_t x;
|
|
|
|
int32_t y;
|
|
|
|
} center;
|
|
|
|
};
|
|
|
|
|
2012-04-17 13:20:49 +04:00
|
|
|
static struct shell_surface *
|
|
|
|
get_shell_surface(struct weston_surface *surface);
|
|
|
|
|
|
|
|
static struct desktop_shell *
|
|
|
|
shell_surface_get_shell(struct shell_surface *shsurf);
|
|
|
|
|
|
|
|
static bool
|
|
|
|
shell_surface_is_top_fullscreen(struct shell_surface *shsurf)
|
|
|
|
{
|
|
|
|
struct desktop_shell *shell;
|
|
|
|
struct weston_surface *top_fs_es;
|
|
|
|
|
|
|
|
shell = shell_surface_get_shell(shsurf);
|
|
|
|
|
|
|
|
if (wl_list_empty(&shell->fullscreen_layer.surface_list))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
top_fs_es = container_of(shell->fullscreen_layer.surface_list.next,
|
|
|
|
struct weston_surface,
|
|
|
|
layer_link);
|
|
|
|
return (shsurf == get_shell_surface(top_fs_es));
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
shell_grab_init(struct shell_grab *grab,
|
|
|
|
const struct wl_pointer_grab_interface *interface,
|
|
|
|
struct shell_surface *shsurf)
|
|
|
|
{
|
|
|
|
grab->grab.interface = interface;
|
|
|
|
grab->shsurf = shsurf;
|
2012-04-12 07:18:23 +04:00
|
|
|
grab->shsurf_destroy_listener.notify = destroy_shell_grab_shsurf;
|
|
|
|
wl_signal_add(&shsurf->resource.destroy_signal,
|
|
|
|
&grab->shsurf_destroy_listener);
|
2012-04-04 18:48:05 +04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
shell_grab_finish(struct shell_grab *grab)
|
|
|
|
{
|
|
|
|
wl_list_remove(&grab->shsurf_destroy_listener.link);
|
|
|
|
}
|
|
|
|
|
2012-03-01 08:57:46 +04:00
|
|
|
static void
|
|
|
|
center_on_output(struct weston_surface *surface,
|
|
|
|
struct weston_output *output);
|
|
|
|
|
2012-04-20 19:54:25 +04:00
|
|
|
static uint32_t
|
|
|
|
get_modifier(char *modifier)
|
|
|
|
{
|
|
|
|
if (!modifier)
|
|
|
|
return MODIFIER_SUPER;
|
|
|
|
|
|
|
|
if (!strcmp("ctrl", modifier))
|
|
|
|
return MODIFIER_CTRL;
|
|
|
|
else if (!strcmp("alt", modifier))
|
|
|
|
return MODIFIER_ALT;
|
|
|
|
else if (!strcmp("super", modifier))
|
|
|
|
return MODIFIER_SUPER;
|
|
|
|
else
|
|
|
|
return MODIFIER_SUPER;
|
|
|
|
}
|
|
|
|
|
2012-04-25 15:09:52 +04:00
|
|
|
static enum animation_type
|
|
|
|
get_animation_type(char *animation)
|
|
|
|
{
|
|
|
|
if (!animation)
|
|
|
|
return ANIMATION_NONE;
|
|
|
|
|
|
|
|
if (!strcmp("zoom", animation))
|
|
|
|
return ANIMATION_ZOOM;
|
|
|
|
else if (!strcmp("fade", animation))
|
|
|
|
return ANIMATION_FADE;
|
|
|
|
else
|
|
|
|
return ANIMATION_NONE;
|
|
|
|
}
|
|
|
|
|
2012-01-26 01:57:11 +04:00
|
|
|
static void
|
2012-04-16 18:31:41 +04:00
|
|
|
shell_configuration(struct desktop_shell *shell)
|
2011-12-07 13:49:52 +04:00
|
|
|
{
|
|
|
|
char *config_file;
|
2011-12-07 18:22:00 +04:00
|
|
|
char *path = NULL;
|
|
|
|
int duration = 60;
|
2012-04-20 19:54:25 +04:00
|
|
|
char *modifier = NULL;
|
2012-04-25 15:09:52 +04:00
|
|
|
char *win_animation = NULL;
|
2011-12-07 13:49:52 +04:00
|
|
|
|
2012-04-21 00:48:21 +04:00
|
|
|
struct config_key shell_keys[] = {
|
|
|
|
{ "binding-modifier", CONFIG_KEY_STRING, &modifier },
|
2012-04-25 15:09:52 +04:00
|
|
|
{ "animation", CONFIG_KEY_STRING, &win_animation},
|
2012-04-21 00:48:21 +04:00
|
|
|
};
|
|
|
|
|
2011-12-07 13:49:52 +04:00
|
|
|
struct config_key saver_keys[] = {
|
2011-12-07 18:22:00 +04:00
|
|
|
{ "path", CONFIG_KEY_STRING, &path },
|
|
|
|
{ "duration", CONFIG_KEY_INTEGER, &duration },
|
2011-12-07 13:49:52 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct config_section cs[] = {
|
2012-04-21 00:48:21 +04:00
|
|
|
{ "shell", shell_keys, ARRAY_LENGTH(shell_keys), NULL },
|
2011-12-07 13:49:52 +04:00
|
|
|
{ "screensaver", saver_keys, ARRAY_LENGTH(saver_keys), NULL },
|
|
|
|
};
|
|
|
|
|
2012-03-21 21:49:18 +04:00
|
|
|
config_file = config_file_path("weston.ini");
|
2012-01-26 01:57:11 +04:00
|
|
|
parse_config_file(config_file, cs, ARRAY_LENGTH(cs), shell);
|
2011-12-07 13:49:52 +04:00
|
|
|
free(config_file);
|
|
|
|
|
2011-12-07 18:22:00 +04:00
|
|
|
shell->screensaver.path = path;
|
|
|
|
shell->screensaver.duration = duration;
|
2012-04-20 19:54:25 +04:00
|
|
|
shell->binding_modifier = get_modifier(modifier);
|
2012-04-25 15:09:52 +04:00
|
|
|
shell->win_animation_type = get_animation_type(win_animation);
|
2011-12-07 13:49:52 +04:00
|
|
|
}
|
|
|
|
|
2012-01-05 06:30:29 +04:00
|
|
|
static void
|
2012-04-12 06:42:15 +04:00
|
|
|
noop_grab_focus(struct wl_pointer_grab *grab,
|
2012-01-05 06:30:29 +04:00
|
|
|
struct wl_surface *surface, int32_t x, int32_t y)
|
|
|
|
{
|
|
|
|
grab->focus = NULL;
|
|
|
|
}
|
|
|
|
|
2011-01-18 15:53:49 +03:00
|
|
|
static void
|
2012-02-18 16:05:29 +04:00
|
|
|
move_grab_motion(struct wl_pointer_grab *grab,
|
2012-01-05 06:30:29 +04:00
|
|
|
uint32_t time, int32_t x, int32_t y)
|
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;
|
2012-01-05 06:30:29 +04:00
|
|
|
struct wl_input_device *device = grab->input_device;
|
2012-04-04 18:48:05 +04:00
|
|
|
struct shell_surface *shsurf = move->base.shsurf;
|
|
|
|
struct weston_surface *es;
|
|
|
|
|
|
|
|
if (!shsurf)
|
|
|
|
return;
|
|
|
|
|
|
|
|
es = shsurf->surface;
|
2011-01-18 15:53:49 +03:00
|
|
|
|
2012-01-05 06:30:29 +04:00
|
|
|
weston_surface_configure(es,
|
|
|
|
device->x + move->dx,
|
|
|
|
device->y + move->dy,
|
2012-01-25 17:55:43 +04:00
|
|
|
es->geometry.width, es->geometry.height);
|
2011-01-18 15:53:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-02-18 16:05:29 +04:00
|
|
|
move_grab_button(struct wl_pointer_grab *grab,
|
2012-03-30 19:31:25 +04:00
|
|
|
uint32_t time, uint32_t button, int32_t state)
|
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);
|
2012-01-05 06:30:29 +04:00
|
|
|
struct wl_input_device *device = grab->input_device;
|
2011-01-18 15:53:49 +03:00
|
|
|
|
2012-01-05 06:30:29 +04:00
|
|
|
if (device->button_count == 0 && state == 0) {
|
2012-04-04 18:48:05 +04:00
|
|
|
shell_grab_finish(shell_grab);
|
2012-04-12 06:42:15 +04:00
|
|
|
wl_input_device_end_pointer_grab(device);
|
2012-01-05 06:30:29 +04:00
|
|
|
free(grab);
|
|
|
|
}
|
2011-01-18 15:53:49 +03:00
|
|
|
}
|
|
|
|
|
2012-02-18 16:05:29 +04:00
|
|
|
static const struct wl_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,
|
|
|
|
};
|
|
|
|
|
2012-04-18 05:06:20 +04:00
|
|
|
static void
|
|
|
|
unresponsive_surface_fade(struct shell_surface *shsurf, bool reverse)
|
|
|
|
{
|
|
|
|
shsurf->unresponsive_animation.fading_in = reverse ? 0 : 1;
|
|
|
|
|
|
|
|
if(!shsurf->unresponsive_animation.exists) {
|
|
|
|
wl_list_insert(&shsurf->surface->compositor->animation_list,
|
|
|
|
&shsurf->unresponsive_animation.current.link);
|
|
|
|
shsurf->unresponsive_animation.exists = 1;
|
|
|
|
shsurf->unresponsive_animation.timestamp = weston_compositor_get_time();
|
|
|
|
weston_surface_damage(shsurf->surface);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-04-19 23:06:17 +04:00
|
|
|
unresponsive_fade_frame(struct weston_animation *animation,
|
2012-04-18 05:06:20 +04:00
|
|
|
struct weston_output *output, uint32_t msecs)
|
|
|
|
{
|
|
|
|
struct shell_surface *shsurf =
|
|
|
|
container_of(animation, struct shell_surface, unresponsive_animation.current);
|
|
|
|
struct weston_surface *surface = shsurf->surface;
|
2012-04-19 23:06:17 +04:00
|
|
|
unsigned int step = 8;
|
2012-04-18 05:06:20 +04:00
|
|
|
|
|
|
|
if (!surface || !shsurf)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (shsurf->unresponsive_animation.fading_in) {
|
|
|
|
while (step < msecs - shsurf->unresponsive_animation.timestamp) {
|
|
|
|
if (surface->saturation > 1)
|
|
|
|
surface->saturation -= 5;
|
|
|
|
if (surface->brightness > 200)
|
|
|
|
surface->brightness--;
|
|
|
|
|
|
|
|
shsurf->unresponsive_animation.timestamp += step;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (surface->saturation <= 1 && surface->brightness <= 200) {
|
|
|
|
wl_list_remove(&shsurf->unresponsive_animation.current.link);
|
|
|
|
shsurf->unresponsive_animation.exists = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
while (step < msecs - shsurf->unresponsive_animation.timestamp) {
|
|
|
|
if (surface->saturation < 255)
|
|
|
|
surface->saturation += 5;
|
|
|
|
if (surface->brightness < 255)
|
|
|
|
surface->brightness++;
|
|
|
|
|
|
|
|
shsurf->unresponsive_animation.timestamp += step;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (surface->saturation >= 255 && surface->brightness >= 255) {
|
|
|
|
surface->saturation = surface->brightness = 255;
|
|
|
|
wl_list_remove(&shsurf->unresponsive_animation.current.link);
|
|
|
|
shsurf->unresponsive_animation.exists = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
surface->geometry.dirty = 1;
|
|
|
|
weston_surface_damage(surface);
|
|
|
|
}
|
|
|
|
|
2012-04-19 23:06:17 +04:00
|
|
|
static void
|
|
|
|
ping_timer_destroy(struct shell_surface *shsurf)
|
|
|
|
{
|
|
|
|
if (!shsurf || !shsurf->ping_timer)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (shsurf->ping_timer->source)
|
|
|
|
wl_event_source_remove(shsurf->ping_timer->source);
|
|
|
|
|
|
|
|
free(shsurf->ping_timer);
|
|
|
|
shsurf->ping_timer = NULL;
|
|
|
|
}
|
|
|
|
|
2012-04-18 05:06:18 +04:00
|
|
|
static int
|
|
|
|
ping_timeout_handler(void *data)
|
|
|
|
{
|
|
|
|
struct shell_surface *shsurf = data;
|
|
|
|
|
2012-04-19 23:06:17 +04:00
|
|
|
/* Client is not responding */
|
|
|
|
shsurf->unresponsive = 1;
|
|
|
|
unresponsive_surface_fade(shsurf, false);
|
2012-04-18 05:06:18 +04:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ping_handler(struct weston_surface *surface, uint32_t serial)
|
|
|
|
{
|
|
|
|
struct shell_surface *shsurf;
|
|
|
|
shsurf = get_shell_surface(surface);
|
|
|
|
struct wl_event_loop *loop;
|
2012-04-19 23:06:17 +04:00
|
|
|
int ping_timeout = 2500;
|
2012-04-18 05:06:18 +04:00
|
|
|
|
|
|
|
if (!shsurf)
|
|
|
|
return;
|
2012-04-22 07:20:07 +04:00
|
|
|
if (!shsurf->resource.client)
|
|
|
|
return;
|
2012-04-18 05:06:18 +04:00
|
|
|
|
|
|
|
if (!shsurf->ping_timer) {
|
|
|
|
shsurf->ping_timer = malloc(sizeof shsurf->ping_timer);
|
|
|
|
if (!shsurf->ping_timer)
|
|
|
|
return;
|
|
|
|
|
|
|
|
shsurf->ping_timer->serial = serial;
|
|
|
|
loop = wl_display_get_event_loop(surface->compositor->wl_display);
|
|
|
|
shsurf->ping_timer->source =
|
|
|
|
wl_event_loop_add_timer(loop, ping_timeout_handler, shsurf);
|
|
|
|
wl_event_source_timer_update(shsurf->ping_timer->source, ping_timeout);
|
|
|
|
|
|
|
|
wl_shell_surface_send_ping(&shsurf->resource, serial);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
shell_surface_pong(struct wl_client *client, struct wl_resource *resource,
|
|
|
|
uint32_t serial)
|
|
|
|
{
|
|
|
|
struct shell_surface *shsurf = resource->data;
|
|
|
|
|
|
|
|
if (shsurf->ping_timer->serial == serial) {
|
2012-04-18 05:06:20 +04:00
|
|
|
if (shsurf->unresponsive) {
|
|
|
|
/* Received pong from previously unresponsive client */
|
|
|
|
unresponsive_surface_fade(shsurf, true);
|
|
|
|
}
|
2012-04-18 05:06:18 +04:00
|
|
|
shsurf->unresponsive = 0;
|
2012-04-19 23:06:17 +04:00
|
|
|
ping_timer_destroy(shsurf);
|
2012-04-18 05:06:18 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-27 01:21:20 +04:00
|
|
|
static int
|
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
|
|
|
weston_surface_move(struct weston_surface *es,
|
2012-04-12 06:42:15 +04:00
|
|
|
struct weston_input_device *wd)
|
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;
|
2012-04-04 18:48:05 +04:00
|
|
|
struct shell_surface *shsurf = get_shell_surface(es);
|
|
|
|
|
|
|
|
if (!shsurf)
|
|
|
|
return -1;
|
2011-01-18 15:53:49 +03:00
|
|
|
|
|
|
|
move = malloc(sizeof *move);
|
2011-08-27 01:21:20 +04:00
|
|
|
if (!move)
|
|
|
|
return -1;
|
2011-01-18 15:53:49 +03:00
|
|
|
|
2012-04-04 18:48:05 +04:00
|
|
|
shell_grab_init(&move->base, &move_grab_interface, shsurf);
|
|
|
|
|
2012-01-25 18:22:05 +04:00
|
|
|
move->dx = es->geometry.x - wd->input_device.grab_x;
|
|
|
|
move->dy = es->geometry.y - wd->input_device.grab_y;
|
2011-01-18 15:53:49 +03:00
|
|
|
|
2012-04-04 18:48:05 +04:00
|
|
|
wl_input_device_start_pointer_grab(&wd->input_device,
|
2012-04-12 06:42:15 +04:00
|
|
|
&move->base.grab);
|
2011-01-18 15:53:49 +03:00
|
|
|
|
2012-04-12 06:42:15 +04:00
|
|
|
wl_input_device_set_pointer_focus(&wd->input_device, NULL, 0, 0);
|
2011-08-27 01:21:20 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-11-25 14:09:16 +04:00
|
|
|
shell_surface_move(struct wl_client *client, struct wl_resource *resource,
|
2012-04-12 06:42:15 +04:00
|
|
|
struct wl_resource *input_resource, uint32_t serial)
|
2011-08-27 01:21:20 +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_input_device *wd = input_resource->data;
|
2011-11-25 14:09:16 +04:00
|
|
|
struct shell_surface *shsurf = resource->data;
|
2011-08-27 01:21:20 +04:00
|
|
|
|
2012-01-05 06:30:29 +04:00
|
|
|
if (wd->input_device.button_count == 0 ||
|
2012-04-12 06:42:15 +04:00
|
|
|
wd->input_device.grab_serial != serial ||
|
2012-01-05 06:30:29 +04:00
|
|
|
wd->input_device.pointer_focus != &shsurf->surface->surface)
|
|
|
|
return;
|
|
|
|
|
2012-04-12 06:42:15 +04:00
|
|
|
if (weston_surface_move(shsurf->surface, wd) < 0)
|
2011-09-01 17:54:57 +04:00
|
|
|
wl_resource_post_no_memory(resource);
|
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_resize_grab {
|
2012-04-04 18:48:05 +04:00
|
|
|
struct shell_grab base;
|
2011-01-18 15:53:49 +03:00
|
|
|
uint32_t edges;
|
2012-01-30 18:19:47 +04:00
|
|
|
int32_t width, height;
|
2011-01-18 15:53:49 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2012-02-18 16:05:29 +04:00
|
|
|
resize_grab_motion(struct wl_pointer_grab *grab,
|
2011-01-18 15:53:49 +03:00
|
|
|
uint32_t time, int32_t x, int32_t y)
|
|
|
|
{
|
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_resize_grab *resize = (struct weston_resize_grab *) grab;
|
2011-01-18 15:53:49 +03:00
|
|
|
struct wl_input_device *device = grab->input_device;
|
|
|
|
int32_t width, height;
|
2012-01-30 18:19:47 +04:00
|
|
|
int32_t from_x, from_y;
|
|
|
|
int32_t to_x, to_y;
|
|
|
|
|
2012-04-04 18:48:05 +04:00
|
|
|
if (!resize->base.shsurf)
|
|
|
|
return;
|
|
|
|
|
|
|
|
weston_surface_from_global(resize->base.shsurf->surface,
|
2012-01-30 18:19:47 +04:00
|
|
|
device->grab_x, device->grab_y,
|
|
|
|
&from_x, &from_y);
|
2012-04-04 18:48:05 +04:00
|
|
|
weston_surface_from_global(resize->base.shsurf->surface,
|
2012-01-30 18:19:47 +04:00
|
|
|
device->x, device->y, &to_x, &to_y);
|
2011-01-18 15:53:49 +03:00
|
|
|
|
2011-11-25 14:09:16 +04:00
|
|
|
if (resize->edges & WL_SHELL_SURFACE_RESIZE_LEFT) {
|
2012-01-30 18:19:47 +04:00
|
|
|
width = resize->width + from_x - to_x;
|
2011-11-25 14:09:16 +04:00
|
|
|
} else if (resize->edges & WL_SHELL_SURFACE_RESIZE_RIGHT) {
|
2012-01-30 18:19:47 +04:00
|
|
|
width = resize->width + to_x - from_x;
|
2011-01-18 15:53:49 +03:00
|
|
|
} else {
|
|
|
|
width = resize->width;
|
|
|
|
}
|
|
|
|
|
2011-11-25 14:09:16 +04:00
|
|
|
if (resize->edges & WL_SHELL_SURFACE_RESIZE_TOP) {
|
2012-01-30 18:19:47 +04:00
|
|
|
height = resize->height + from_y - to_y;
|
2011-11-25 14:09:16 +04:00
|
|
|
} else if (resize->edges & WL_SHELL_SURFACE_RESIZE_BOTTOM) {
|
2012-01-30 18:19:47 +04:00
|
|
|
height = resize->height + to_y - from_y;
|
2011-01-18 15:53:49 +03:00
|
|
|
} else {
|
|
|
|
height = resize->height;
|
|
|
|
}
|
|
|
|
|
2012-04-04 18:48:05 +04:00
|
|
|
wl_shell_surface_send_configure(&resize->base.shsurf->resource,
|
2012-04-12 06:42:15 +04:00
|
|
|
resize->edges, width, height);
|
2011-01-18 15:53:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-02-18 16:05:29 +04:00
|
|
|
resize_grab_button(struct wl_pointer_grab *grab,
|
2012-03-30 19:31:25 +04:00
|
|
|
uint32_t time, uint32_t button, int32_t state)
|
2011-01-18 15:53:49 +03:00
|
|
|
{
|
2012-04-04 18:48:05 +04:00
|
|
|
struct weston_resize_grab *resize = (struct weston_resize_grab *) grab;
|
2012-01-05 06:30:29 +04:00
|
|
|
struct wl_input_device *device = grab->input_device;
|
2011-01-18 15:53:49 +03:00
|
|
|
|
2012-01-05 06:30:29 +04:00
|
|
|
if (device->button_count == 0 && state == 0) {
|
2012-04-04 18:48:05 +04:00
|
|
|
shell_grab_finish(&resize->base);
|
2012-04-12 06:42:15 +04:00
|
|
|
wl_input_device_end_pointer_grab(device);
|
2012-01-05 06:30:29 +04:00
|
|
|
free(grab);
|
|
|
|
}
|
2011-01-18 15:53:49 +03:00
|
|
|
}
|
|
|
|
|
2012-02-18 16:05:29 +04:00
|
|
|
static const struct wl_pointer_grab_interface resize_grab_interface = {
|
2012-01-05 06:30:29 +04:00
|
|
|
noop_grab_focus,
|
2011-01-18 15:53:49 +03:00
|
|
|
resize_grab_motion,
|
|
|
|
resize_grab_button,
|
|
|
|
};
|
|
|
|
|
2011-08-27 01:21:20 +04:00
|
|
|
static int
|
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
|
|
|
weston_surface_resize(struct shell_surface *shsurf,
|
2012-04-12 06:42:15 +04:00
|
|
|
struct weston_input_device *wd, uint32_t edges)
|
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_resize_grab *resize;
|
2011-01-18 15:53:49 +03:00
|
|
|
|
2012-03-01 08:57:46 +04:00
|
|
|
if (shsurf->type == SHELL_SURFACE_FULLSCREEN)
|
|
|
|
return 0;
|
2011-01-28 23:18:33 +03:00
|
|
|
|
2012-01-30 18:19:47 +04:00
|
|
|
if (edges == 0 || edges > 15 ||
|
|
|
|
(edges & 3) == 3 || (edges & 12) == 12)
|
|
|
|
return 0;
|
|
|
|
|
2011-01-18 15:53:49 +03:00
|
|
|
resize = malloc(sizeof *resize);
|
2011-08-27 01:21:20 +04:00
|
|
|
if (!resize)
|
|
|
|
return -1;
|
2011-01-18 15:53:49 +03:00
|
|
|
|
2012-04-04 18:48:05 +04:00
|
|
|
shell_grab_init(&resize->base, &resize_grab_interface, shsurf);
|
|
|
|
|
2011-01-18 15:53:49 +03:00
|
|
|
resize->edges = edges;
|
2012-01-30 18:19:47 +04:00
|
|
|
resize->width = shsurf->surface->geometry.width;
|
|
|
|
resize->height = shsurf->surface->geometry.height;
|
2011-08-19 01:55:30 +04:00
|
|
|
|
2012-04-04 18:48:05 +04:00
|
|
|
wl_input_device_start_pointer_grab(&wd->input_device,
|
2012-04-12 06:42:15 +04:00
|
|
|
&resize->base.grab);
|
2011-01-18 15:53:49 +03:00
|
|
|
|
2012-04-12 06:42:15 +04:00
|
|
|
wl_input_device_set_pointer_focus(&wd->input_device, NULL, 0, 0);
|
2011-08-27 01:21:20 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-11-25 14:09:16 +04:00
|
|
|
shell_surface_resize(struct wl_client *client, struct wl_resource *resource,
|
2012-04-12 06:42:15 +04:00
|
|
|
struct wl_resource *input_resource, uint32_t serial,
|
2011-11-25 14:09:16 +04:00
|
|
|
uint32_t edges)
|
2011-08-27 01:21:20 +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_input_device *wd = input_resource->data;
|
2011-11-25 14:09:16 +04:00
|
|
|
struct shell_surface *shsurf = resource->data;
|
2011-08-27 01:21:20 +04:00
|
|
|
|
2012-03-01 08:57:46 +04:00
|
|
|
if (shsurf->type == SHELL_SURFACE_FULLSCREEN)
|
|
|
|
return;
|
2011-08-27 01:21:20 +04:00
|
|
|
|
2012-01-05 06:30:29 +04:00
|
|
|
if (wd->input_device.button_count == 0 ||
|
2012-04-12 06:42:15 +04:00
|
|
|
wd->input_device.grab_serial != serial ||
|
2012-01-05 06:30:29 +04:00
|
|
|
wd->input_device.pointer_focus != &shsurf->surface->surface)
|
|
|
|
return;
|
|
|
|
|
2012-04-12 06:42:15 +04:00
|
|
|
if (weston_surface_resize(shsurf, wd, edges) < 0)
|
2011-09-01 17:54:57 +04:00
|
|
|
wl_resource_post_no_memory(resource);
|
2011-01-18 15:53:49 +03:00
|
|
|
}
|
|
|
|
|
2012-02-07 04:45:41 +04:00
|
|
|
static struct weston_output *
|
|
|
|
get_default_output(struct weston_compositor *compositor)
|
|
|
|
{
|
|
|
|
return container_of(compositor->output_list.next,
|
|
|
|
struct weston_output, link);
|
|
|
|
}
|
|
|
|
|
2012-03-01 08:57:46 +04:00
|
|
|
static void
|
|
|
|
shell_unset_fullscreen(struct shell_surface *shsurf)
|
|
|
|
{
|
|
|
|
/* undo all fullscreen things here */
|
2012-04-17 13:20:49 +04:00
|
|
|
if (shsurf->fullscreen.type == WL_SHELL_SURFACE_FULLSCREEN_METHOD_DRIVER &&
|
|
|
|
shell_surface_is_top_fullscreen(shsurf)) {
|
|
|
|
weston_output_switch_mode(shsurf->fullscreen_output,
|
|
|
|
shsurf->fullscreen_output->origin);
|
|
|
|
}
|
2012-03-01 08:57:46 +04:00
|
|
|
shsurf->fullscreen.type = WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT;
|
|
|
|
shsurf->fullscreen.framerate = 0;
|
|
|
|
wl_list_remove(&shsurf->fullscreen.transform.link);
|
|
|
|
wl_list_init(&shsurf->fullscreen.transform.link);
|
2012-04-17 13:20:49 +04:00
|
|
|
if (shsurf->fullscreen.black_surface)
|
|
|
|
weston_surface_destroy(shsurf->fullscreen.black_surface);
|
2012-03-01 08:57:46 +04:00
|
|
|
shsurf->fullscreen.black_surface = NULL;
|
|
|
|
shsurf->fullscreen_output = NULL;
|
2012-03-27 18:36:42 +04:00
|
|
|
shsurf->force_configure = 1;
|
2012-03-01 08:57:46 +04:00
|
|
|
weston_surface_set_position(shsurf->surface,
|
|
|
|
shsurf->saved_x, shsurf->saved_y);
|
|
|
|
}
|
|
|
|
|
2011-12-01 12:42:22 +04:00
|
|
|
static int
|
|
|
|
reset_shell_surface_type(struct shell_surface *surface)
|
|
|
|
{
|
|
|
|
switch (surface->type) {
|
|
|
|
case SHELL_SURFACE_FULLSCREEN:
|
2012-03-01 08:57:46 +04:00
|
|
|
shell_unset_fullscreen(surface);
|
2011-12-01 12:42:22 +04:00
|
|
|
break;
|
2012-02-07 04:45:41 +04:00
|
|
|
case SHELL_SURFACE_MAXIMIZED:
|
|
|
|
surface->output = get_default_output(surface->surface->compositor);
|
|
|
|
weston_surface_set_position(surface->surface,
|
|
|
|
surface->saved_x,
|
|
|
|
surface->saved_y);
|
|
|
|
break;
|
2011-12-01 12:42:22 +04:00
|
|
|
case SHELL_SURFACE_PANEL:
|
|
|
|
case SHELL_SURFACE_BACKGROUND:
|
|
|
|
wl_list_remove(&surface->link);
|
|
|
|
wl_list_init(&surface->link);
|
|
|
|
break;
|
2011-11-30 18:26:35 +04:00
|
|
|
case SHELL_SURFACE_SCREENSAVER:
|
2011-12-01 12:42:22 +04:00
|
|
|
case SHELL_SURFACE_LOCK:
|
|
|
|
wl_resource_post_error(&surface->resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_METHOD,
|
2011-11-30 18:26:35 +04:00
|
|
|
"cannot reassign surface type");
|
2011-12-01 12:42:22 +04:00
|
|
|
return -1;
|
|
|
|
case SHELL_SURFACE_NONE:
|
|
|
|
case SHELL_SURFACE_TOPLEVEL:
|
|
|
|
case SHELL_SURFACE_TRANSIENT:
|
2012-01-05 07:19:14 +04:00
|
|
|
case SHELL_SURFACE_POPUP:
|
2011-12-01 12:42:22 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
surface->type = SHELL_SURFACE_NONE;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-04-19 17:18:18 +04:00
|
|
|
static void
|
|
|
|
set_toplevel(struct shell_surface *shsurf)
|
|
|
|
{
|
|
|
|
if (reset_shell_surface_type(shsurf))
|
|
|
|
return;
|
|
|
|
|
|
|
|
shsurf->type = SHELL_SURFACE_TOPLEVEL;
|
|
|
|
}
|
|
|
|
|
2011-06-18 14:12:54 +04:00
|
|
|
static void
|
2011-11-25 14:09:16 +04:00
|
|
|
shell_surface_set_toplevel(struct wl_client *client,
|
|
|
|
struct wl_resource *resource)
|
2011-06-18 14:12:54 +04:00
|
|
|
|
|
|
|
{
|
2011-12-01 12:42:22 +04:00
|
|
|
struct shell_surface *surface = resource->data;
|
2011-06-18 14:12:54 +04:00
|
|
|
|
2012-04-19 17:18:18 +04:00
|
|
|
set_toplevel(surface);
|
2011-06-18 14:12:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-11-25 14:09:16 +04:00
|
|
|
shell_surface_set_transient(struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
struct wl_resource *parent_resource,
|
|
|
|
int x, int y, uint32_t flags)
|
2011-06-18 14:12:54 +04:00
|
|
|
{
|
2011-11-25 14:09:16 +04:00
|
|
|
struct shell_surface *shsurf = resource->data;
|
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_surface *es = shsurf->surface;
|
2011-12-08 18:42:33 +04:00
|
|
|
struct shell_surface *pshsurf = parent_resource->data;
|
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_surface *pes = pshsurf->surface;
|
2011-06-18 14:12:54 +04:00
|
|
|
|
2011-12-01 12:42:22 +04:00
|
|
|
if (reset_shell_surface_type(shsurf))
|
|
|
|
return;
|
|
|
|
|
2012-03-01 08:57:46 +04:00
|
|
|
/* assign to parents output */
|
2012-02-22 10:50:46 +04:00
|
|
|
shsurf->output = pes->output;
|
2012-02-13 15:03:59 +04:00
|
|
|
weston_surface_set_position(es, pes->geometry.x + x,
|
|
|
|
pes->geometry.y + y);
|
2011-06-18 14:12:54 +04:00
|
|
|
|
2011-11-25 14:09:16 +04:00
|
|
|
shsurf->type = SHELL_SURFACE_TRANSIENT;
|
2011-06-18 14:12:54 +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
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-04-16 18:31:41 +04:00
|
|
|
get_output_panel_height(struct desktop_shell *shell,
|
|
|
|
struct weston_output *output)
|
2012-02-07 04:45:41 +04:00
|
|
|
{
|
|
|
|
struct shell_surface *priv;
|
|
|
|
int panel_height = 0;
|
|
|
|
|
|
|
|
if (!output)
|
|
|
|
return 0;
|
|
|
|
|
2012-04-16 18:31:41 +04:00
|
|
|
wl_list_for_each(priv, &shell->panels, link) {
|
2012-02-07 04:45:41 +04:00
|
|
|
if (priv->output == output) {
|
|
|
|
panel_height = priv->surface->geometry.height;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return panel_height;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
shell_surface_set_maximized(struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
struct wl_resource *output_resource )
|
|
|
|
{
|
|
|
|
struct shell_surface *shsurf = resource->data;
|
|
|
|
struct weston_surface *es = shsurf->surface;
|
2012-04-16 18:31:41 +04:00
|
|
|
struct desktop_shell *shell = NULL;
|
2012-02-07 04:45:41 +04:00
|
|
|
uint32_t edges = 0, panel_height = 0;
|
|
|
|
|
|
|
|
/* get the default output, if the client set it as NULL
|
|
|
|
check whether the ouput is available */
|
|
|
|
if (output_resource)
|
|
|
|
shsurf->output = output_resource->data;
|
|
|
|
else
|
|
|
|
shsurf->output = get_default_output(es->compositor);
|
|
|
|
|
|
|
|
if (reset_shell_surface_type(shsurf))
|
|
|
|
return;
|
|
|
|
|
|
|
|
shsurf->saved_x = es->geometry.x;
|
|
|
|
shsurf->saved_y = es->geometry.y;
|
2012-03-01 08:57:46 +04:00
|
|
|
shsurf->saved_position_valid = true;
|
2012-02-07 04:45:41 +04:00
|
|
|
|
2012-04-16 18:31:41 +04:00
|
|
|
shell = shell_surface_get_shell(shsurf);
|
|
|
|
panel_height = get_output_panel_height(shell, es->output);
|
2012-02-07 04:45:41 +04:00
|
|
|
edges = WL_SHELL_SURFACE_RESIZE_TOP|WL_SHELL_SURFACE_RESIZE_LEFT;
|
2012-03-05 06:57:37 +04:00
|
|
|
|
2012-04-12 06:42:15 +04:00
|
|
|
wl_shell_surface_send_configure(&shsurf->resource, edges,
|
2012-03-05 06:57:37 +04:00
|
|
|
es->output->current->width,
|
|
|
|
es->output->current->height - panel_height);
|
2012-02-07 04:45:41 +04:00
|
|
|
|
|
|
|
shsurf->type = SHELL_SURFACE_MAXIMIZED;
|
2011-12-02 12:59:17 +04:00
|
|
|
}
|
|
|
|
|
2012-04-01 16:13:08 +04:00
|
|
|
static void
|
|
|
|
black_surface_configure(struct weston_surface *es, int32_t sx, int32_t sy);
|
|
|
|
|
2012-03-01 08:57:46 +04:00
|
|
|
static struct weston_surface *
|
|
|
|
create_black_surface(struct weston_compositor *ec,
|
2012-04-01 16:13:08 +04:00
|
|
|
struct weston_surface *fs_surface,
|
2012-03-01 08:57:46 +04:00
|
|
|
GLfloat x, GLfloat y, int w, int h)
|
|
|
|
{
|
|
|
|
struct weston_surface *surface = NULL;
|
|
|
|
|
|
|
|
surface = weston_surface_create(ec);
|
|
|
|
if (surface == NULL) {
|
|
|
|
fprintf(stderr, "no memory\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-04-01 16:13:08 +04:00
|
|
|
surface->configure = black_surface_configure;
|
|
|
|
surface->private = fs_surface;
|
2012-03-01 08:57:46 +04:00
|
|
|
weston_surface_configure(surface, x, y, w, h);
|
|
|
|
weston_surface_set_color(surface, 0.0, 0.0, 0.0, 1);
|
|
|
|
return surface;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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)
|
|
|
|
{
|
|
|
|
struct weston_output *output = shsurf->fullscreen_output;
|
|
|
|
struct weston_surface *surface = shsurf->surface;
|
|
|
|
struct weston_matrix *matrix;
|
|
|
|
float scale;
|
|
|
|
|
|
|
|
center_on_output(surface, output);
|
|
|
|
|
|
|
|
if (!shsurf->fullscreen.black_surface)
|
2012-02-29 21:42:35 +04:00
|
|
|
shsurf->fullscreen.black_surface =
|
|
|
|
create_black_surface(surface->compositor,
|
2012-04-01 16:13:08 +04:00
|
|
|
surface,
|
2012-02-29 21:42:35 +04:00
|
|
|
output->x, output->y,
|
|
|
|
output->current->width,
|
|
|
|
output->current->height);
|
|
|
|
|
|
|
|
wl_list_remove(&shsurf->fullscreen.black_surface->layer_link);
|
|
|
|
wl_list_insert(&surface->layer_link,
|
|
|
|
&shsurf->fullscreen.black_surface->layer_link);
|
2012-03-01 08:57:46 +04:00
|
|
|
shsurf->fullscreen.black_surface->output = output;
|
|
|
|
|
|
|
|
switch (shsurf->fullscreen.type) {
|
|
|
|
case WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT:
|
|
|
|
break;
|
|
|
|
case WL_SHELL_SURFACE_FULLSCREEN_METHOD_SCALE:
|
|
|
|
matrix = &shsurf->fullscreen.transform.matrix;
|
|
|
|
weston_matrix_init(matrix);
|
|
|
|
scale = (float)output->current->width/(float)surface->geometry.width;
|
|
|
|
weston_matrix_scale(matrix, scale, scale, 1);
|
|
|
|
wl_list_remove(&shsurf->fullscreen.transform.link);
|
|
|
|
wl_list_insert(surface->geometry.transformation_list.prev,
|
|
|
|
&shsurf->fullscreen.transform.link);
|
|
|
|
weston_surface_set_position(surface, output->x, output->y);
|
|
|
|
break;
|
|
|
|
case WL_SHELL_SURFACE_FULLSCREEN_METHOD_DRIVER:
|
2012-04-17 13:20:49 +04:00
|
|
|
if (shell_surface_is_top_fullscreen(shsurf)) {
|
|
|
|
struct weston_mode mode = {0,
|
|
|
|
surface->geometry.width,
|
|
|
|
surface->geometry.height,
|
|
|
|
shsurf->fullscreen.framerate};
|
|
|
|
|
|
|
|
if (weston_output_switch_mode(output, &mode) == 0) {
|
|
|
|
weston_surface_configure(shsurf->fullscreen.black_surface,
|
|
|
|
output->x, output->y,
|
|
|
|
output->current->width,
|
|
|
|
output->current->height);
|
|
|
|
weston_surface_set_position(surface, output->x, output->y);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-03-01 08:57:46 +04:00
|
|
|
break;
|
|
|
|
case WL_SHELL_SURFACE_FULLSCREEN_METHOD_FILL:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* make the fullscreen and black surface at the top */
|
|
|
|
static void
|
|
|
|
shell_stack_fullscreen(struct shell_surface *shsurf)
|
|
|
|
{
|
2012-04-17 13:20:49 +04:00
|
|
|
struct weston_output *output = shsurf->fullscreen_output;
|
2012-03-01 08:57:46 +04:00
|
|
|
struct weston_surface *surface = shsurf->surface;
|
2012-04-16 18:31:41 +04:00
|
|
|
struct desktop_shell *shell = shell_surface_get_shell(shsurf);
|
2012-03-01 08:57:46 +04:00
|
|
|
|
2012-02-29 21:42:35 +04:00
|
|
|
wl_list_remove(&surface->layer_link);
|
|
|
|
wl_list_insert(&shell->fullscreen_layer.surface_list,
|
|
|
|
&surface->layer_link);
|
2012-04-17 13:20:49 +04:00
|
|
|
weston_surface_damage(surface);
|
|
|
|
|
|
|
|
if (!shsurf->fullscreen.black_surface)
|
|
|
|
shsurf->fullscreen.black_surface =
|
|
|
|
create_black_surface(surface->compositor,
|
|
|
|
surface,
|
|
|
|
output->x, output->y,
|
|
|
|
output->current->width,
|
|
|
|
output->current->height);
|
|
|
|
|
|
|
|
wl_list_remove(&shsurf->fullscreen.black_surface->layer_link);
|
2012-02-29 21:42:35 +04:00
|
|
|
wl_list_insert(&surface->layer_link,
|
|
|
|
&shsurf->fullscreen.black_surface->layer_link);
|
|
|
|
weston_surface_damage(shsurf->fullscreen.black_surface);
|
2012-03-01 08:57:46 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
shell_map_fullscreen(struct shell_surface *shsurf)
|
|
|
|
{
|
|
|
|
shell_stack_fullscreen(shsurf);
|
2012-04-17 13:20:49 +04:00
|
|
|
shell_configure_fullscreen(shsurf);
|
2012-03-01 08:57:46 +04:00
|
|
|
}
|
|
|
|
|
2011-06-18 14:12:54 +04:00
|
|
|
static void
|
2011-11-25 14:09:16 +04:00
|
|
|
shell_surface_set_fullscreen(struct wl_client *client,
|
2012-02-17 00:58:14 +04:00
|
|
|
struct wl_resource *resource,
|
|
|
|
uint32_t method,
|
|
|
|
uint32_t framerate,
|
|
|
|
struct wl_resource *output_resource)
|
2011-06-18 14:12:54 +04:00
|
|
|
{
|
2011-11-25 14:09:16 +04:00
|
|
|
struct shell_surface *shsurf = resource->data;
|
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_surface *es = shsurf->surface;
|
2012-03-01 08:57:46 +04:00
|
|
|
|
|
|
|
if (output_resource)
|
|
|
|
shsurf->output = output_resource->data;
|
|
|
|
else
|
|
|
|
shsurf->output = get_default_output(es->compositor);
|
2011-06-18 14:12:54 +04:00
|
|
|
|
2011-12-01 12:42:22 +04:00
|
|
|
if (reset_shell_surface_type(shsurf))
|
|
|
|
return;
|
|
|
|
|
2012-03-01 08:57:46 +04:00
|
|
|
shsurf->fullscreen_output = shsurf->output;
|
|
|
|
shsurf->fullscreen.type = method;
|
|
|
|
shsurf->fullscreen.framerate = framerate;
|
|
|
|
shsurf->type = SHELL_SURFACE_FULLSCREEN;
|
2011-06-18 14:12:54 +04:00
|
|
|
|
2012-01-25 18:22:05 +04:00
|
|
|
shsurf->saved_x = es->geometry.x;
|
|
|
|
shsurf->saved_y = es->geometry.y;
|
2012-03-01 08:57:46 +04:00
|
|
|
shsurf->saved_position_valid = true;
|
|
|
|
|
2012-03-27 18:36:36 +04:00
|
|
|
if (weston_surface_is_mapped(es))
|
2012-03-27 18:36:42 +04:00
|
|
|
shsurf->force_configure = 1;
|
2012-02-17 08:38:14 +04:00
|
|
|
|
2012-04-12 06:42:15 +04:00
|
|
|
wl_shell_surface_send_configure(&shsurf->resource, 0,
|
2012-03-05 06:57:37 +04:00
|
|
|
shsurf->output->current->width,
|
|
|
|
shsurf->output->current->height);
|
2011-06-18 14:12:54 +04:00
|
|
|
}
|
|
|
|
|
2012-01-05 07:19:14 +04:00
|
|
|
static void
|
2012-04-12 06:42:15 +04:00
|
|
|
popup_grab_focus(struct wl_pointer_grab *grab,
|
2012-01-05 07:19:14 +04:00
|
|
|
struct wl_surface *surface, int32_t x, int32_t y)
|
|
|
|
{
|
|
|
|
struct wl_input_device *device = grab->input_device;
|
|
|
|
struct shell_surface *priv =
|
|
|
|
container_of(grab, struct shell_surface, popup.grab);
|
|
|
|
struct wl_client *client = priv->surface->surface.resource.client;
|
|
|
|
|
shell: deal with weston_compositor_pick_surface() = NULL
I could crash Weston by trying to open another menu from a panel while
one menu from it was already showing.
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff40a9872 in popup_grab_focus (grab=0x761968, time=4130706528, surface=0x0, x=-227, y=15) at shell.c:440
440 if (surface->resource.client == client) {
(gdb) bt
0 0x00007ffff40a9872 in popup_grab_focus (grab=0x761968, time=4130706528, surface=0x0, x=-227, y=15) at shell.c:440
1 0x0000000000406977 in weston_device_repick (device=0x70b4e0, time=4130706528) at compositor.c:360
2 0x0000000000406a36 in weston_compositor_repick (compositor=0x619960) at compositor.c:382
3 0x0000000000406ac8 in destroy_surface (resource=0x6fc6f0) at compositor.c:397
4 0x00007ffff7bd33d8 in destroy_resource (element=0x6fc6f0, data=0x7fffffffd9fc) at wayland-server.c:355
5 0x00007ffff7bd8d98 in for_each_helper (entries=0x757808, func=0x7ffff7bd332c <destroy_resource>, data=0x7fffffffd9fc)
at wayland-util.c:264
6 0x00007ffff7bd8dd4 in wl_map_for_each (map=0x757808, func=0x7ffff7bd332c <destroy_resource>, data=0x7fffffffd9fc)
at wayland-util.c:270
7 0x00007ffff7bd34dc in wl_client_destroy (client=0x7577d0) at wayland-server.c:385
8 0x00007ffff7bd2e36 in wl_client_connection_data (fd=17, mask=1, data=0x7577d0) at wayland-server.c:187
9 0x00007ffff7bd5bde in wl_event_source_fd_dispatch (source=0x74cda0, ep=0x7fffffffdae0) at event-loop.c:76
10 0x00007ffff7bd665b in wl_event_loop_dispatch (loop=0x618900, timeout=-1) at event-loop.c:462
11 0x00007ffff7bd42a9 in wl_display_run (display=0x6188b0) at wayland-server.c:785
12 0x000000000040b1e1 in main (argc=1, argv=0x7fffffffdef8) at compositor.c:2182
Modify popup_grab_focus() to deal with a NULL surface.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-19 18:25:40 +04:00
|
|
|
if (surface && surface->resource.client == client) {
|
2012-04-12 06:42:15 +04:00
|
|
|
wl_input_device_set_pointer_focus(device, surface, x, y);
|
2012-01-05 07:19:14 +04:00
|
|
|
grab->focus = surface;
|
|
|
|
} else {
|
2012-04-12 06:42:15 +04:00
|
|
|
wl_input_device_set_pointer_focus(device, NULL, 0, 0);
|
2012-01-05 07:19:14 +04:00
|
|
|
grab->focus = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-02-18 16:05:29 +04:00
|
|
|
popup_grab_motion(struct wl_pointer_grab *grab,
|
2012-02-14 16:59:18 +04:00
|
|
|
uint32_t time, int32_t sx, int32_t sy)
|
2012-01-05 07:19:14 +04:00
|
|
|
{
|
|
|
|
struct wl_resource *resource;
|
|
|
|
|
|
|
|
resource = grab->input_device->pointer_focus_resource;
|
|
|
|
if (resource)
|
2012-03-05 06:57:37 +04:00
|
|
|
wl_input_device_send_motion(resource, time, sx, sy);
|
2012-01-05 07:19:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-02-18 16:05:29 +04:00
|
|
|
popup_grab_button(struct wl_pointer_grab *grab,
|
2012-03-30 19:31:25 +04:00
|
|
|
uint32_t time, uint32_t button, int32_t state)
|
2012-01-05 07:19:14 +04:00
|
|
|
{
|
|
|
|
struct wl_resource *resource;
|
|
|
|
struct shell_surface *shsurf =
|
|
|
|
container_of(grab, struct shell_surface, popup.grab);
|
2012-04-12 06:42:15 +04:00
|
|
|
struct wl_display *display;
|
|
|
|
uint32_t serial;
|
2012-01-05 07:19:14 +04:00
|
|
|
|
|
|
|
resource = grab->input_device->pointer_focus_resource;
|
|
|
|
if (resource) {
|
2012-04-12 06:42:15 +04:00
|
|
|
display = wl_client_get_display(resource->client);
|
|
|
|
serial = wl_display_get_serial(display);
|
|
|
|
wl_input_device_send_button(resource, serial,
|
|
|
|
time, button, state);
|
2012-01-05 07:19:14 +04:00
|
|
|
} else if (state == 0 &&
|
|
|
|
(shsurf->popup.initial_up ||
|
2012-04-13 20:40:07 +04:00
|
|
|
time - shsurf->popup.device->grab_time > 500)) {
|
2012-03-05 06:57:37 +04:00
|
|
|
wl_shell_surface_send_popup_done(&shsurf->resource);
|
2012-04-12 06:42:15 +04:00
|
|
|
wl_input_device_end_pointer_grab(grab->input_device);
|
2012-01-05 07:19:14 +04:00
|
|
|
shsurf->popup.grab.input_device = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (state == 0)
|
|
|
|
shsurf->popup.initial_up = 1;
|
|
|
|
}
|
|
|
|
|
2012-02-18 16:05:29 +04:00
|
|
|
static const struct wl_pointer_grab_interface popup_grab_interface = {
|
2012-01-05 07:19:14 +04:00
|
|
|
popup_grab_focus,
|
|
|
|
popup_grab_motion,
|
|
|
|
popup_grab_button,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2012-04-13 20:40:07 +04:00
|
|
|
shell_map_popup(struct shell_surface *shsurf)
|
2012-01-05 07:19:14 +04:00
|
|
|
{
|
2012-04-13 20:40:07 +04:00
|
|
|
struct wl_input_device *device = shsurf->popup.device;
|
2012-01-05 07:19:14 +04:00
|
|
|
struct weston_surface *es = shsurf->surface;
|
|
|
|
struct weston_surface *parent = shsurf->parent->surface;
|
|
|
|
|
|
|
|
es->output = parent->output;
|
|
|
|
shsurf->popup.grab.interface = &popup_grab_interface;
|
|
|
|
|
2012-02-07 16:19:01 +04:00
|
|
|
weston_surface_update_transform(parent);
|
|
|
|
if (parent->transform.enabled) {
|
|
|
|
shsurf->popup.parent_transform.matrix =
|
|
|
|
parent->transform.matrix;
|
|
|
|
} else {
|
|
|
|
/* construct x, y translation matrix */
|
|
|
|
weston_matrix_init(&shsurf->popup.parent_transform.matrix);
|
|
|
|
shsurf->popup.parent_transform.matrix.d[12] =
|
|
|
|
parent->geometry.x;
|
|
|
|
shsurf->popup.parent_transform.matrix.d[13] =
|
|
|
|
parent->geometry.y;
|
|
|
|
}
|
|
|
|
wl_list_insert(es->geometry.transformation_list.prev,
|
|
|
|
&shsurf->popup.parent_transform.link);
|
2012-02-13 15:03:59 +04:00
|
|
|
weston_surface_set_position(es, shsurf->popup.x, shsurf->popup.y);
|
2012-01-05 07:19:14 +04:00
|
|
|
|
|
|
|
shsurf->popup.initial_up = 0;
|
|
|
|
|
2012-04-13 20:40:07 +04:00
|
|
|
/* We don't require the grab to still be active, but if another
|
|
|
|
* grab has started in the meantime, we end the popup now. */
|
|
|
|
if (device->grab_serial == shsurf->popup.serial) {
|
|
|
|
wl_input_device_start_pointer_grab(device,
|
|
|
|
&shsurf->popup.grab);
|
|
|
|
} else {
|
|
|
|
wl_shell_surface_send_popup_done(&shsurf->resource);
|
|
|
|
}
|
2012-01-05 07:19:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
shell_surface_set_popup(struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
struct wl_resource *input_device_resource,
|
2012-04-13 20:40:07 +04:00
|
|
|
uint32_t serial,
|
2012-01-05 07:19:14 +04:00
|
|
|
struct wl_resource *parent_resource,
|
|
|
|
int32_t x, int32_t y, uint32_t flags)
|
|
|
|
{
|
|
|
|
struct shell_surface *shsurf = resource->data;
|
|
|
|
|
|
|
|
shsurf->type = SHELL_SURFACE_POPUP;
|
|
|
|
shsurf->parent = parent_resource->data;
|
2012-04-13 20:40:07 +04:00
|
|
|
shsurf->popup.device = input_device_resource->data;
|
|
|
|
shsurf->popup.serial = serial;
|
2012-01-05 07:19:14 +04:00
|
|
|
shsurf->popup.x = x;
|
|
|
|
shsurf->popup.y = y;
|
|
|
|
}
|
|
|
|
|
2011-11-25 14:09:16 +04:00
|
|
|
static const struct wl_shell_surface_interface shell_surface_implementation = {
|
2012-04-18 05:06:18 +04:00
|
|
|
shell_surface_pong,
|
2011-11-25 14:09:16 +04:00
|
|
|
shell_surface_move,
|
|
|
|
shell_surface_resize,
|
|
|
|
shell_surface_set_toplevel,
|
|
|
|
shell_surface_set_transient,
|
2012-01-05 07:19:14 +04:00
|
|
|
shell_surface_set_fullscreen,
|
2012-02-07 04:45:41 +04:00
|
|
|
shell_surface_set_popup,
|
|
|
|
shell_surface_set_maximized
|
2011-11-25 14:09:16 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2012-04-19 17:18:18 +04:00
|
|
|
destroy_shell_surface(struct shell_surface *shsurf)
|
2011-11-25 14:09:16 +04:00
|
|
|
{
|
2012-01-05 07:19:14 +04:00
|
|
|
if (shsurf->popup.grab.input_device)
|
2012-04-12 06:42:15 +04:00
|
|
|
wl_input_device_end_pointer_grab(shsurf->popup.grab.input_device);
|
2012-01-05 07:19:14 +04:00
|
|
|
|
2012-04-17 13:20:49 +04:00
|
|
|
if (shsurf->fullscreen.type == WL_SHELL_SURFACE_FULLSCREEN_METHOD_DRIVER &&
|
|
|
|
shell_surface_is_top_fullscreen(shsurf)) {
|
|
|
|
weston_output_switch_mode(shsurf->fullscreen_output,
|
|
|
|
shsurf->fullscreen_output->origin);
|
2012-03-27 18:36:41 +04:00
|
|
|
}
|
2011-11-25 14:09:16 +04:00
|
|
|
|
2012-03-05 07:01:40 +04:00
|
|
|
if (shsurf->fullscreen.black_surface)
|
|
|
|
weston_surface_destroy(shsurf->fullscreen.black_surface);
|
|
|
|
|
2012-04-17 13:20:49 +04:00
|
|
|
/* As destroy_resource() use wl_list_for_each_safe(),
|
|
|
|
* we can always remove the listener.
|
|
|
|
*/
|
|
|
|
wl_list_remove(&shsurf->surface_destroy_listener.link);
|
|
|
|
shsurf->surface->configure = NULL;
|
2012-04-19 23:06:17 +04:00
|
|
|
ping_timer_destroy(shsurf);
|
2012-04-17 13:20:49 +04:00
|
|
|
|
2011-11-25 14:09:16 +04:00
|
|
|
wl_list_remove(&shsurf->link);
|
|
|
|
free(shsurf);
|
|
|
|
}
|
|
|
|
|
2012-04-19 17:18:18 +04:00
|
|
|
static void
|
|
|
|
shell_destroy_shell_surface(struct wl_resource *resource)
|
|
|
|
{
|
|
|
|
struct shell_surface *shsurf = resource->data;
|
|
|
|
|
|
|
|
destroy_shell_surface(shsurf);
|
|
|
|
}
|
|
|
|
|
2011-11-25 14:09:16 +04:00
|
|
|
static void
|
2012-04-12 07:18:23 +04:00
|
|
|
shell_handle_surface_destroy(struct wl_listener *listener, void *data)
|
2011-11-25 14:09:16 +04:00
|
|
|
{
|
|
|
|
struct shell_surface *shsurf = container_of(listener,
|
|
|
|
struct shell_surface,
|
|
|
|
surface_destroy_listener);
|
|
|
|
|
2012-04-19 17:18:18 +04:00
|
|
|
/* tricky way to check if resource was in fact created */
|
|
|
|
if (shsurf->resource.object.implementation != 0)
|
|
|
|
wl_resource_destroy(&shsurf->resource);
|
|
|
|
else
|
|
|
|
destroy_shell_surface(shsurf);
|
2011-11-25 14:09:16 +04:00
|
|
|
}
|
|
|
|
|
2011-11-28 17:12:34 +04:00
|
|
|
static struct shell_surface *
|
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
|
|
|
get_shell_surface(struct weston_surface *surface)
|
2011-11-28 17:12:34 +04:00
|
|
|
{
|
|
|
|
struct wl_listener *listener;
|
|
|
|
|
2012-04-12 07:18:23 +04:00
|
|
|
listener = wl_signal_get(&surface->surface.resource.destroy_signal,
|
|
|
|
shell_handle_surface_destroy);
|
|
|
|
if (listener)
|
|
|
|
return container_of(listener, struct shell_surface,
|
|
|
|
surface_destroy_listener);
|
2011-11-28 17:12:34 +04:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-03-27 18:36:41 +04:00
|
|
|
static void
|
|
|
|
shell_surface_configure(struct weston_surface *, int32_t, int32_t);
|
|
|
|
|
2011-11-25 14:09:16 +04:00
|
|
|
static void
|
2012-04-19 17:18:18 +04:00
|
|
|
create_shell_surface(void *shell, struct weston_surface *surface,
|
|
|
|
struct shell_surface **ret)
|
2011-11-25 14:09:16 +04:00
|
|
|
{
|
|
|
|
struct shell_surface *shsurf;
|
|
|
|
|
2012-03-27 18:36:41 +04:00
|
|
|
if (surface->configure) {
|
2012-04-19 17:18:18 +04:00
|
|
|
fprintf(stderr, "surface->configure already set\n");
|
2012-03-27 18:36:41 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-11-25 14:09:16 +04:00
|
|
|
shsurf = calloc(1, sizeof *shsurf);
|
|
|
|
if (!shsurf) {
|
2012-04-19 17:18:18 +04:00
|
|
|
fprintf(stderr, "no memory to allocate shell surface\n");
|
2011-11-25 14:09:16 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-27 18:36:41 +04:00
|
|
|
surface->configure = shell_surface_configure;
|
2012-04-19 17:18:18 +04:00
|
|
|
surface->compositor->shell_interface.shell = shell;
|
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-04-18 05:06:20 +04:00
|
|
|
shsurf->unresponsive_animation.exists = 0;
|
|
|
|
shsurf->unresponsive_animation.fading_in = 0;
|
2012-04-19 23:06:17 +04:00
|
|
|
shsurf->unresponsive_animation.current.frame = unresponsive_fade_frame;
|
2012-03-01 08:57:46 +04:00
|
|
|
shsurf->saved_position_valid = false;
|
2011-11-25 14:09:16 +04:00
|
|
|
shsurf->surface = surface;
|
2012-03-01 08:57:46 +04:00
|
|
|
shsurf->fullscreen.type = WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT;
|
|
|
|
shsurf->fullscreen.framerate = 0;
|
|
|
|
shsurf->fullscreen.black_surface = NULL;
|
2012-04-18 05:06:18 +04:00
|
|
|
shsurf->ping_timer = NULL;
|
2012-03-01 08:57:46 +04:00
|
|
|
wl_list_init(&shsurf->fullscreen.transform.link);
|
|
|
|
|
2012-04-19 17:18:18 +04:00
|
|
|
wl_signal_init(&shsurf->resource.destroy_signal);
|
2012-04-12 07:18:23 +04:00
|
|
|
shsurf->surface_destroy_listener.notify = shell_handle_surface_destroy;
|
|
|
|
wl_signal_add(&surface->surface.resource.destroy_signal,
|
|
|
|
&shsurf->surface_destroy_listener);
|
2011-11-25 14:09:16 +04:00
|
|
|
|
|
|
|
/* init link so its safe to always remove it in destroy_shell_surface */
|
|
|
|
wl_list_init(&shsurf->link);
|
|
|
|
|
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
|
|
|
|
2011-12-01 12:42:22 +04:00
|
|
|
shsurf->type = SHELL_SURFACE_NONE;
|
2011-11-25 14:09:16 +04:00
|
|
|
|
2012-04-19 17:18:18 +04:00
|
|
|
*ret = shsurf;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
shell_get_shell_surface(struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
uint32_t id,
|
|
|
|
struct wl_resource *surface_resource)
|
|
|
|
{
|
|
|
|
struct weston_surface *surface = surface_resource->data;
|
|
|
|
struct desktop_shell *shell = resource->data;
|
|
|
|
struct shell_surface *shsurf;
|
|
|
|
|
|
|
|
if (get_shell_surface(surface)) {
|
|
|
|
wl_resource_post_error(surface_resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
|
|
|
"desktop_shell::get_shell_surface already requested");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
create_shell_surface(shell, surface, &shsurf);
|
|
|
|
if (!shsurf) {
|
|
|
|
wl_resource_post_error(surface_resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
|
|
|
"surface->configure already set");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
shsurf->resource.destroy = shell_destroy_shell_surface;
|
|
|
|
shsurf->resource.object.id = id;
|
|
|
|
shsurf->resource.object.interface = &wl_shell_surface_interface;
|
|
|
|
shsurf->resource.object.implementation =
|
|
|
|
(void (**)(void)) &shell_surface_implementation;
|
|
|
|
shsurf->resource.data = shsurf;
|
|
|
|
|
|
|
|
wl_client_add_resource(client, &shsurf->resource);
|
2011-11-25 14:09:16 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct wl_shell_interface shell_implementation = {
|
2011-11-29 17:49:31 +04:00
|
|
|
shell_get_shell_surface
|
2011-01-18 15:53:49 +03:00
|
|
|
};
|
|
|
|
|
2011-12-02 18:31:49 +04:00
|
|
|
static void
|
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
|
|
|
handle_screensaver_sigchld(struct weston_process *proc, int status)
|
2011-12-02 18:31:49 +04:00
|
|
|
{
|
|
|
|
proc->pid = 0;
|
|
|
|
}
|
|
|
|
|
2011-11-30 18:26:35 +04:00
|
|
|
static void
|
2012-04-16 18:31:41 +04:00
|
|
|
launch_screensaver(struct desktop_shell *shell)
|
2011-11-30 18:26:35 +04:00
|
|
|
{
|
|
|
|
if (shell->screensaver.binding)
|
|
|
|
return;
|
|
|
|
|
2011-12-07 13:49:52 +04:00
|
|
|
if (!shell->screensaver.path)
|
|
|
|
return;
|
|
|
|
|
2012-03-02 02:11:36 +04:00
|
|
|
if (shell->screensaver.process.pid != 0) {
|
|
|
|
fprintf(stderr, "old screensaver still running\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
weston_client_launch(shell->compositor,
|
2011-12-02 18:31:49 +04:00
|
|
|
&shell->screensaver.process,
|
2011-12-07 13:49:52 +04:00
|
|
|
shell->screensaver.path,
|
2011-12-02 18:31:49 +04:00
|
|
|
handle_screensaver_sigchld);
|
2011-11-30 18:26:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-04-16 18:31:41 +04:00
|
|
|
terminate_screensaver(struct desktop_shell *shell)
|
2011-11-30 18:26:35 +04:00
|
|
|
{
|
2011-12-02 18:31:49 +04:00
|
|
|
if (shell->screensaver.process.pid == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
kill(shell->screensaver.process.pid, SIGTERM);
|
2011-11-30 18:26:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-04-16 18:31:41 +04:00
|
|
|
show_screensaver(struct desktop_shell *shell, struct shell_surface *surface)
|
2011-11-30 18:26:35 +04:00
|
|
|
{
|
|
|
|
struct wl_list *list;
|
|
|
|
|
|
|
|
if (shell->lock_surface)
|
2012-02-29 21:42:35 +04:00
|
|
|
list = &shell->lock_surface->surface->layer_link;
|
2011-11-30 18:26:35 +04:00
|
|
|
else
|
2012-02-29 21:42:35 +04:00
|
|
|
list = &shell->lock_layer.surface_list;
|
2011-11-30 18:26:35 +04:00
|
|
|
|
2012-02-29 21:42:35 +04:00
|
|
|
wl_list_remove(&surface->surface->layer_link);
|
|
|
|
wl_list_insert(list, &surface->surface->layer_link);
|
2011-11-30 18:26:35 +04:00
|
|
|
surface->surface->output = surface->output;
|
2012-02-10 17:33:10 +04:00
|
|
|
weston_surface_damage(surface->surface);
|
2011-11-30 18:26:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-04-16 18:31:41 +04:00
|
|
|
hide_screensaver(struct desktop_shell *shell, struct shell_surface *surface)
|
2011-11-30 18:26:35 +04:00
|
|
|
{
|
2012-02-29 21:42:35 +04:00
|
|
|
wl_list_remove(&surface->surface->layer_link);
|
|
|
|
wl_list_init(&surface->surface->layer_link);
|
2011-11-30 18:26:35 +04:00
|
|
|
surface->surface->output = 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)
|
|
|
|
{
|
2012-04-16 18:31:41 +04:00
|
|
|
struct desktop_shell *shell = resource->data;
|
2011-11-28 16:11:15 +04:00
|
|
|
struct shell_surface *shsurf = surface_resource->data;
|
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_surface *surface = shsurf->surface;
|
2011-11-23 18:42:16 +04:00
|
|
|
struct shell_surface *priv;
|
2011-09-06 21:48:16 +04:00
|
|
|
|
2011-12-01 12:42:22 +04:00
|
|
|
if (reset_shell_surface_type(shsurf))
|
|
|
|
return;
|
|
|
|
|
2011-11-23 23:46:40 +04:00
|
|
|
wl_list_for_each(priv, &shell->backgrounds, link) {
|
|
|
|
if (priv->output == output_resource->data) {
|
|
|
|
priv->surface->output = NULL;
|
2012-02-29 21:42:35 +04:00
|
|
|
wl_list_remove(&priv->surface->layer_link);
|
2011-11-23 23:46:40 +04:00
|
|
|
wl_list_remove(&priv->link);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-28 16:11:15 +04:00
|
|
|
shsurf->type = SHELL_SURFACE_BACKGROUND;
|
|
|
|
shsurf->output = output_resource->data;
|
2011-11-22 15:43:52 +04:00
|
|
|
|
2011-11-28 16:11:15 +04:00
|
|
|
wl_list_insert(&shell->backgrounds, &shsurf->link);
|
2011-11-22 15:43:52 +04:00
|
|
|
|
2012-02-13 15:03:59 +04:00
|
|
|
weston_surface_set_position(surface, shsurf->output->x,
|
|
|
|
shsurf->output->y);
|
2011-11-23 18:42:16 +04:00
|
|
|
|
2012-04-12 06:42:15 +04:00
|
|
|
desktop_shell_send_configure(resource, 0,
|
2012-03-05 06:57:37 +04:00
|
|
|
surface_resource,
|
|
|
|
shsurf->output->current->width,
|
|
|
|
shsurf->output->current->height);
|
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)
|
|
|
|
{
|
2012-04-16 18:31:41 +04:00
|
|
|
struct desktop_shell *shell = resource->data;
|
2011-11-28 16:11:15 +04:00
|
|
|
struct shell_surface *shsurf = surface_resource->data;
|
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_surface *surface = shsurf->surface;
|
2011-11-23 18:42:16 +04:00
|
|
|
struct shell_surface *priv;
|
2011-09-06 21:48:16 +04:00
|
|
|
|
2011-12-01 12:42:22 +04:00
|
|
|
if (reset_shell_surface_type(shsurf))
|
|
|
|
return;
|
|
|
|
|
2011-11-23 23:46:40 +04:00
|
|
|
wl_list_for_each(priv, &shell->panels, link) {
|
|
|
|
if (priv->output == output_resource->data) {
|
|
|
|
priv->surface->output = NULL;
|
2012-02-29 21:42:35 +04:00
|
|
|
wl_list_remove(&priv->surface->layer_link);
|
2011-11-23 23:46:40 +04:00
|
|
|
wl_list_remove(&priv->link);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-28 16:11:15 +04:00
|
|
|
shsurf->type = SHELL_SURFACE_PANEL;
|
|
|
|
shsurf->output = output_resource->data;
|
2011-09-06 21:48:16 +04:00
|
|
|
|
2011-11-28 16:11:15 +04:00
|
|
|
wl_list_insert(&shell->panels, &shsurf->link);
|
2011-09-06 21:48:16 +04:00
|
|
|
|
2012-02-13 15:03:59 +04:00
|
|
|
weston_surface_set_position(surface, shsurf->output->x,
|
|
|
|
shsurf->output->y);
|
2011-11-23 18:42:16 +04:00
|
|
|
|
2012-04-12 06:42:15 +04:00
|
|
|
desktop_shell_send_configure(resource, 0,
|
2012-03-05 06:57:37 +04:00
|
|
|
surface_resource,
|
|
|
|
shsurf->output->current->width,
|
|
|
|
shsurf->output->current->height);
|
2011-09-06 21:48:16 +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
|
|
|
|
|
|
|
fprintf(stderr, "lock surface gone\n");
|
|
|
|
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)
|
|
|
|
{
|
2012-04-16 18:31:41 +04:00
|
|
|
struct desktop_shell *shell = resource->data;
|
2011-12-01 12:42:22 +04:00
|
|
|
struct shell_surface *surface = surface_resource->data;
|
|
|
|
|
|
|
|
if (reset_shell_surface_type(surface))
|
|
|
|
return;
|
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;
|
|
|
|
wl_signal_add(&surface_resource->destroy_signal,
|
|
|
|
&shell->lock_surface_listener);
|
2011-11-23 18:42:16 +04:00
|
|
|
|
2011-11-28 16:11:15 +04:00
|
|
|
shell->lock_surface->type = SHELL_SURFACE_LOCK;
|
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
|
|
|
{
|
2011-11-30 18:26:35 +04:00
|
|
|
struct shell_surface *tmp;
|
|
|
|
|
|
|
|
wl_list_for_each(tmp, &shell->screensaver.surfaces, link)
|
|
|
|
hide_screensaver(shell, tmp);
|
|
|
|
|
|
|
|
terminate_screensaver(shell);
|
2011-11-15 15:34:54 +04:00
|
|
|
|
2012-02-29 21:42:35 +04:00
|
|
|
wl_list_remove(&shell->lock_layer.link);
|
|
|
|
wl_list_insert(&shell->compositor->cursor_layer.link,
|
|
|
|
&shell->fullscreen_layer.link);
|
|
|
|
wl_list_insert(&shell->fullscreen_layer.link,
|
|
|
|
&shell->panel_layer.link);
|
|
|
|
wl_list_insert(&shell->panel_layer.link, &shell->toplevel_layer.link);
|
2011-11-15 15:34:54 +04:00
|
|
|
|
|
|
|
shell->locked = false;
|
2011-12-07 18:22:00 +04:00
|
|
|
shell->compositor->idle_time = shell->compositor->option_idle_time;
|
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
|
|
|
weston_compositor_wake(shell->compositor);
|
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)
|
|
|
|
{
|
2012-04-16 18:31:41 +04:00
|
|
|
struct desktop_shell *shell = resource->data;
|
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
|
|
|
}
|
|
|
|
|
2011-09-06 21:48:16 +04:00
|
|
|
static const struct desktop_shell_interface desktop_shell_implementation = {
|
|
|
|
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,
|
|
|
|
desktop_shell_unlock
|
2011-09-06 21:48:16 +04:00
|
|
|
};
|
|
|
|
|
2011-11-28 17:34:13 +04:00
|
|
|
static enum shell_surface_type
|
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
|
|
|
get_shell_surface_type(struct weston_surface *surface)
|
2011-11-28 17:34:13 +04:00
|
|
|
{
|
|
|
|
struct shell_surface *shsurf;
|
|
|
|
|
|
|
|
shsurf = get_shell_surface(surface);
|
|
|
|
if (!shsurf)
|
2011-12-01 12:42:22 +04:00
|
|
|
return SHELL_SURFACE_NONE;
|
2011-11-28 17:34:13 +04:00
|
|
|
return shsurf->type;
|
|
|
|
}
|
|
|
|
|
2011-04-13 01:25:42 +04:00
|
|
|
static void
|
|
|
|
move_binding(struct wl_input_device *device, uint32_t time,
|
2012-03-20 18:47:59 +04:00
|
|
|
uint32_t key, uint32_t button, uint32_t axis, int32_t state, void *data)
|
2011-04-13 01:25:42 +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_surface *surface =
|
|
|
|
(struct weston_surface *) device->pointer_focus;
|
2011-11-23 19:52:40 +04:00
|
|
|
|
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
|
|
|
|
2011-11-28 17:34:13 +04:00
|
|
|
switch (get_shell_surface_type(surface)) {
|
2011-11-22 15:43:52 +04:00
|
|
|
case SHELL_SURFACE_PANEL:
|
|
|
|
case SHELL_SURFACE_BACKGROUND:
|
|
|
|
case SHELL_SURFACE_FULLSCREEN:
|
2011-11-30 18:26:35 +04:00
|
|
|
case SHELL_SURFACE_SCREENSAVER:
|
2011-11-22 15:43:52 +04:00
|
|
|
return;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-04-12 06:42:15 +04:00
|
|
|
weston_surface_move(surface, (struct weston_input_device *) device);
|
2011-04-13 01:25:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
resize_binding(struct wl_input_device *device, uint32_t time,
|
2012-03-20 18:47:59 +04:00
|
|
|
uint32_t key, uint32_t button, uint32_t axis, int32_t state, void *data)
|
2011-04-13 01:25:42 +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_surface *surface =
|
|
|
|
(struct weston_surface *) device->pointer_focus;
|
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;
|
2011-11-23 19:52:40 +04:00
|
|
|
|
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);
|
2011-11-28 17:34:13 +04:00
|
|
|
if (!shsurf)
|
|
|
|
return;
|
|
|
|
|
2011-11-25 14:09:16 +04:00
|
|
|
switch (shsurf->type) {
|
2011-11-22 15:43:52 +04:00
|
|
|
case SHELL_SURFACE_PANEL:
|
|
|
|
case SHELL_SURFACE_BACKGROUND:
|
|
|
|
case SHELL_SURFACE_FULLSCREEN:
|
2011-11-30 18:26:35 +04:00
|
|
|
case SHELL_SURFACE_SCREENSAVER:
|
2011-11-22 15:43:52 +04:00
|
|
|
return;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2011-04-13 19:52:54 +04:00
|
|
|
|
2012-01-30 18:19:47 +04:00
|
|
|
weston_surface_from_global(surface,
|
|
|
|
device->grab_x, device->grab_y, &x, &y);
|
2011-04-13 01:25:42 +04:00
|
|
|
|
2012-01-25 17:55:43 +04:00
|
|
|
if (x < surface->geometry.width / 3)
|
2011-11-25 14:09:16 +04:00
|
|
|
edges |= WL_SHELL_SURFACE_RESIZE_LEFT;
|
2012-01-25 17:55:43 +04:00
|
|
|
else if (x < 2 * surface->geometry.width / 3)
|
2011-04-13 01:25:42 +04:00
|
|
|
edges |= 0;
|
|
|
|
else
|
2011-11-25 14:09:16 +04:00
|
|
|
edges |= WL_SHELL_SURFACE_RESIZE_RIGHT;
|
2011-04-13 01:25:42 +04:00
|
|
|
|
2012-01-25 17:55:43 +04:00
|
|
|
if (y < surface->geometry.height / 3)
|
2011-11-25 14:09:16 +04:00
|
|
|
edges |= WL_SHELL_SURFACE_RESIZE_TOP;
|
2012-01-25 17:55:43 +04:00
|
|
|
else if (y < 2 * surface->geometry.height / 3)
|
2011-04-13 01:25:42 +04:00
|
|
|
edges |= 0;
|
|
|
|
else
|
2011-11-25 14:09:16 +04:00
|
|
|
edges |= WL_SHELL_SURFACE_RESIZE_BOTTOM;
|
2011-08-27 01:21:20 +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
|
|
|
weston_surface_resize(shsurf, (struct weston_input_device *) device,
|
2012-04-12 06:42:15 +04:00
|
|
|
edges);
|
2011-04-23 21:04:11 +04:00
|
|
|
}
|
|
|
|
|
2012-03-22 21:01:03 +04:00
|
|
|
static void
|
|
|
|
surface_opacity_binding(struct wl_input_device *device, uint32_t time,
|
|
|
|
uint32_t key, uint32_t button, uint32_t axis, int32_t value, void *data)
|
|
|
|
{
|
2012-03-30 19:52:39 +04:00
|
|
|
uint32_t step = 15;
|
2012-03-22 21:01:03 +04:00
|
|
|
struct shell_surface *shsurf;
|
|
|
|
struct weston_surface *surface =
|
|
|
|
(struct weston_surface *) device->pointer_focus;
|
|
|
|
|
|
|
|
if (surface == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
shsurf = get_shell_surface(surface);
|
|
|
|
if (!shsurf)
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch (shsurf->type) {
|
|
|
|
case SHELL_SURFACE_BACKGROUND:
|
|
|
|
case SHELL_SURFACE_SCREENSAVER:
|
|
|
|
return;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
surface->alpha += value * step;
|
|
|
|
|
|
|
|
if (surface->alpha > 255)
|
|
|
|
surface->alpha = 255;
|
|
|
|
if (surface->alpha < step)
|
|
|
|
surface->alpha = step;
|
|
|
|
|
|
|
|
surface->geometry.dirty = 1;
|
|
|
|
weston_surface_damage(surface);
|
|
|
|
}
|
|
|
|
|
2012-02-23 01:21:41 +04:00
|
|
|
static void
|
2012-03-06 02:47:15 +04:00
|
|
|
zoom_binding(struct wl_input_device *device, uint32_t time,
|
2012-03-22 20:58:23 +04:00
|
|
|
uint32_t key, uint32_t button, uint32_t axis, int32_t value, void *data)
|
2012-02-23 01:21:41 +04:00
|
|
|
{
|
|
|
|
struct weston_input_device *wd = (struct weston_input_device *) device;
|
|
|
|
struct weston_compositor *compositor = wd->compositor;
|
|
|
|
struct weston_output *output;
|
|
|
|
|
|
|
|
wl_list_for_each(output, &compositor->output_list, link) {
|
|
|
|
if (pixman_region32_contains_point(&output->region,
|
|
|
|
device->x, device->y, NULL)) {
|
2012-03-22 20:58:23 +04:00
|
|
|
output->zoom.active = 1;
|
|
|
|
output->zoom.level += output->zoom.increment * -value;
|
2012-02-24 09:28:37 +04:00
|
|
|
|
|
|
|
if (output->zoom.level >= 1.0) {
|
|
|
|
output->zoom.active = 0;
|
|
|
|
output->zoom.level = 1.0;
|
|
|
|
}
|
2012-02-23 01:21:41 +04:00
|
|
|
|
|
|
|
if (output->zoom.level < output->zoom.increment)
|
|
|
|
output->zoom.level = output->zoom.increment;
|
|
|
|
|
|
|
|
weston_output_update_zoom(output, device->x, device->y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-20 00:18:05 +04:00
|
|
|
static void
|
|
|
|
terminate_binding(struct wl_input_device *device, uint32_t time,
|
2012-03-20 18:47:59 +04:00
|
|
|
uint32_t key, uint32_t button, uint32_t axis, int32_t state, 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
|
|
|
|
|
|
|
if (state)
|
|
|
|
wl_display_terminate(compositor->wl_display);
|
|
|
|
}
|
|
|
|
|
2012-01-20 18:48:25 +04:00
|
|
|
static void
|
2012-02-18 16:05:29 +04:00
|
|
|
rotate_grab_motion(struct wl_pointer_grab *grab,
|
2012-01-20 18:48:25 +04:00
|
|
|
uint32_t time, int32_t x, int32_t y)
|
|
|
|
{
|
|
|
|
struct rotate_grab *rotate =
|
2012-04-04 18:48:05 +04:00
|
|
|
container_of(grab, struct rotate_grab, base.grab);
|
2012-01-20 18:48:25 +04:00
|
|
|
struct wl_input_device *device = grab->input_device;
|
2012-04-04 18:48:05 +04:00
|
|
|
struct shell_surface *shsurf = rotate->base.shsurf;
|
|
|
|
struct weston_surface *surface;
|
|
|
|
GLfloat cx, cy, dx, dy, cposx, cposy, dposx, dposy, r;
|
|
|
|
|
|
|
|
if (!shsurf)
|
|
|
|
return;
|
|
|
|
|
|
|
|
surface = shsurf->surface;
|
|
|
|
|
|
|
|
cx = 0.5f * surface->geometry.width;
|
|
|
|
cy = 0.5f * surface->geometry.height;
|
2012-01-20 18:48:25 +04:00
|
|
|
|
|
|
|
dx = device->x - rotate->center.x;
|
|
|
|
dy = device->y - rotate->center.y;
|
|
|
|
r = sqrtf(dx * dx + dy * dy);
|
|
|
|
|
2012-04-04 18:48:05 +04:00
|
|
|
wl_list_remove(&shsurf->rotation.transform.link);
|
|
|
|
shsurf->surface->geometry.dirty = 1;
|
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);
|
|
|
|
rotate->rotation.d[0] = dx / r;
|
|
|
|
rotate->rotation.d[4] = -dy / r;
|
|
|
|
rotate->rotation.d[1] = -rotate->rotation.d[4];
|
|
|
|
rotate->rotation.d[5] = rotate->rotation.d[0];
|
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(
|
2012-04-04 18:48:05 +04:00
|
|
|
&shsurf->surface->geometry.transformation_list,
|
|
|
|
&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 */
|
2012-04-04 18:48:05 +04:00
|
|
|
cposx = surface->geometry.x + cx;
|
|
|
|
cposy = surface->geometry.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) {
|
2012-04-04 18:48:05 +04:00
|
|
|
weston_surface_set_position(surface,
|
|
|
|
surface->geometry.x + dposx,
|
|
|
|
surface->geometry.y + dposy);
|
2012-03-23 01:22:04 +04:00
|
|
|
}
|
|
|
|
|
2012-02-09 17:58:44 +04:00
|
|
|
/* Repaint implies weston_surface_update_transform(), which
|
|
|
|
* lazily applies the damage due to rotation update.
|
|
|
|
*/
|
2012-04-04 18:48:05 +04:00
|
|
|
weston_compositor_schedule_repaint(shsurf->surface->compositor);
|
2012-01-20 18:48:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-02-18 16:05:29 +04:00
|
|
|
rotate_grab_button(struct wl_pointer_grab *grab,
|
2012-03-30 19:31:25 +04:00
|
|
|
uint32_t time, uint32_t button, int32_t state)
|
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);
|
2012-01-20 18:48:25 +04:00
|
|
|
struct wl_input_device *device = grab->input_device;
|
2012-04-04 18:48:05 +04:00
|
|
|
struct shell_surface *shsurf = rotate->base.shsurf;
|
2012-01-20 18:48:25 +04:00
|
|
|
|
|
|
|
if (device->button_count == 0 && state == 0) {
|
2012-04-04 18:48:05 +04:00
|
|
|
if (shsurf)
|
|
|
|
weston_matrix_multiply(&shsurf->rotation.rotation,
|
|
|
|
&rotate->rotation);
|
|
|
|
shell_grab_finish(&rotate->base);
|
2012-04-12 06:42:15 +04:00
|
|
|
wl_input_device_end_pointer_grab(device);
|
2012-01-20 18:48:25 +04:00
|
|
|
free(rotate);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-18 16:05:29 +04:00
|
|
|
static const struct wl_pointer_grab_interface rotate_grab_interface = {
|
2012-01-20 18:48:25 +04:00
|
|
|
noop_grab_focus,
|
|
|
|
rotate_grab_motion,
|
|
|
|
rotate_grab_button,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
rotate_binding(struct wl_input_device *device, uint32_t time,
|
2012-03-20 18:47:59 +04:00
|
|
|
uint32_t key, uint32_t button, uint32_t axis, int32_t state, void *data)
|
2012-01-20 18:48:25 +04:00
|
|
|
{
|
|
|
|
struct weston_surface *base_surface =
|
|
|
|
(struct weston_surface *) device->pointer_focus;
|
|
|
|
struct shell_surface *surface;
|
|
|
|
struct rotate_grab *rotate;
|
2012-03-23 01:22:04 +04:00
|
|
|
GLfloat dx, dy;
|
2012-01-27 22:36:13 +04:00
|
|
|
GLfloat r;
|
2012-01-20 18:48:25 +04:00
|
|
|
|
|
|
|
if (base_surface == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
surface = get_shell_surface(base_surface);
|
|
|
|
if (!surface)
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch (surface->type) {
|
|
|
|
case SHELL_SURFACE_PANEL:
|
|
|
|
case SHELL_SURFACE_BACKGROUND:
|
|
|
|
case SHELL_SURFACE_FULLSCREEN:
|
|
|
|
case SHELL_SURFACE_SCREENSAVER:
|
|
|
|
return;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
rotate = malloc(sizeof *rotate);
|
|
|
|
if (!rotate)
|
|
|
|
return;
|
|
|
|
|
2012-04-04 18:48:05 +04:00
|
|
|
shell_grab_init(&rotate->base, &rotate_grab_interface, surface);
|
2012-01-24 11:59:29 +04:00
|
|
|
|
|
|
|
weston_surface_to_global(surface->surface,
|
2012-01-25 17:55:43 +04:00
|
|
|
surface->surface->geometry.width / 2,
|
|
|
|
surface->surface->geometry.height / 2,
|
2012-01-24 11:59:29 +04:00
|
|
|
&rotate->center.x, &rotate->center.y);
|
2012-01-20 18:48:25 +04:00
|
|
|
|
2012-04-12 06:42:15 +04:00
|
|
|
wl_input_device_start_pointer_grab(device, &rotate->base.grab);
|
2012-01-27 22:36:13 +04:00
|
|
|
|
|
|
|
dx = device->x - rotate->center.x;
|
|
|
|
dy = device->y - rotate->center.y;
|
|
|
|
r = sqrtf(dx * dx + dy * dy);
|
|
|
|
if (r > 20.0f) {
|
|
|
|
struct weston_matrix inverse;
|
|
|
|
|
|
|
|
weston_matrix_init(&inverse);
|
|
|
|
inverse.d[0] = dx / r;
|
|
|
|
inverse.d[4] = dy / r;
|
|
|
|
inverse.d[1] = -inverse.d[4];
|
|
|
|
inverse.d[5] = inverse.d[0];
|
|
|
|
weston_matrix_multiply(&surface->rotation.rotation, &inverse);
|
2012-03-23 01:22:04 +04:00
|
|
|
|
|
|
|
weston_matrix_init(&rotate->rotation);
|
|
|
|
rotate->rotation.d[0] = dx / r;
|
|
|
|
rotate->rotation.d[4] = -dy / r;
|
|
|
|
rotate->rotation.d[1] = -rotate->rotation.d[4];
|
|
|
|
rotate->rotation.d[5] = rotate->rotation.d[0];
|
2012-01-27 22:36:13 +04:00
|
|
|
} else {
|
|
|
|
weston_matrix_init(&surface->rotation.rotation);
|
|
|
|
weston_matrix_init(&rotate->rotation);
|
|
|
|
}
|
|
|
|
|
2012-04-12 06:42:15 +04:00
|
|
|
wl_input_device_set_pointer_focus(device, NULL, 0, 0);
|
2012-01-20 18:48:25 +04:00
|
|
|
}
|
|
|
|
|
2011-09-06 21:48:16 +04:00
|
|
|
static void
|
2012-04-16 18:31:41 +04:00
|
|
|
activate(struct desktop_shell *shell, struct weston_surface *es,
|
2012-04-12 06:42:15 +04:00
|
|
|
struct weston_input_device *device)
|
2011-09-06 21:48:16 +04:00
|
|
|
{
|
2012-04-01 16:13:08 +04:00
|
|
|
struct weston_surface *surf, *prev;
|
2011-09-06 21:48:16 +04:00
|
|
|
|
2012-04-12 06:42:15 +04:00
|
|
|
weston_surface_activate(es, device);
|
2011-09-06 21:48:16 +04:00
|
|
|
|
2011-11-28 17:34:13 +04:00
|
|
|
switch (get_shell_surface_type(es)) {
|
2011-11-23 18:42:16 +04:00
|
|
|
case SHELL_SURFACE_BACKGROUND:
|
|
|
|
case SHELL_SURFACE_PANEL:
|
2012-02-29 21:42:35 +04:00
|
|
|
case SHELL_SURFACE_LOCK:
|
2011-11-23 18:42:16 +04:00
|
|
|
break;
|
2012-02-29 21:42:35 +04:00
|
|
|
|
2011-11-30 18:26:35 +04:00
|
|
|
case SHELL_SURFACE_SCREENSAVER:
|
|
|
|
/* always below lock surface */
|
2012-02-29 21:42:35 +04:00
|
|
|
if (shell->lock_surface)
|
|
|
|
weston_surface_restack(es,
|
|
|
|
&shell->lock_surface->surface->layer_link);
|
2011-11-30 18:26:35 +04:00
|
|
|
break;
|
2012-03-01 08:57:46 +04:00
|
|
|
case SHELL_SURFACE_FULLSCREEN:
|
|
|
|
/* should on top of panels */
|
2012-04-01 16:13:08 +04:00
|
|
|
shell_stack_fullscreen(get_shell_surface(es));
|
2012-04-17 13:20:49 +04:00
|
|
|
shell_configure_fullscreen(get_shell_surface(es));
|
2012-03-01 08:57:46 +04:00
|
|
|
break;
|
2011-11-23 18:42:16 +04:00
|
|
|
default:
|
2012-04-17 13:20:49 +04:00
|
|
|
/* move the fullscreen surfaces down into the toplevel layer */
|
2012-04-01 16:13:08 +04:00
|
|
|
if (!wl_list_empty(&shell->fullscreen_layer.surface_list)) {
|
|
|
|
wl_list_for_each_reverse_safe(surf,
|
|
|
|
prev,
|
|
|
|
&shell->fullscreen_layer.surface_list,
|
|
|
|
layer_link)
|
|
|
|
weston_surface_restack(surf,
|
|
|
|
&shell->toplevel_layer.surface_list);
|
|
|
|
}
|
|
|
|
|
2012-02-29 21:42:35 +04:00
|
|
|
weston_surface_restack(es,
|
|
|
|
&shell->toplevel_layer.surface_list);
|
|
|
|
break;
|
2011-09-06 21:48:16 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-01 16:13:08 +04:00
|
|
|
/* no-op func for checking black surface */
|
|
|
|
static void
|
|
|
|
black_surface_configure(struct weston_surface *es, int32_t sx, int32_t sy)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
is_black_surface (struct weston_surface *es, struct weston_surface **fs_surface)
|
|
|
|
{
|
|
|
|
if (es->configure == black_surface_configure) {
|
|
|
|
if (fs_surface)
|
|
|
|
*fs_surface = (struct weston_surface *)es->private;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-12-20 00:18:05 +04:00
|
|
|
static void
|
|
|
|
click_to_activate_binding(struct wl_input_device *device,
|
2012-03-01 08:57:46 +04:00
|
|
|
uint32_t time, uint32_t key,
|
2012-03-20 18:47:59 +04:00
|
|
|
uint32_t button, uint32_t axis, int32_t state, 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_input_device *wd = (struct weston_input_device *) device;
|
2012-04-16 18:31:41 +04:00
|
|
|
struct desktop_shell *shell = data;
|
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_surface *focus;
|
2012-03-01 08:57:46 +04:00
|
|
|
struct weston_surface *upper;
|
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
|
|
|
focus = (struct weston_surface *) device->pointer_focus;
|
2012-03-05 10:13:13 +04:00
|
|
|
if (!focus)
|
|
|
|
return;
|
|
|
|
|
2012-04-01 16:13:08 +04:00
|
|
|
if (is_black_surface(focus, &upper))
|
2012-03-01 08:57:46 +04:00
|
|
|
focus = upper;
|
|
|
|
|
2012-03-05 10:13:13 +04:00
|
|
|
if (state && device->pointer_grab == &device->default_pointer_grab)
|
2012-04-12 17:55:26 +04:00
|
|
|
activate(shell, focus, wd);
|
2011-12-20 00:18:05 +04:00
|
|
|
}
|
|
|
|
|
2011-04-23 21:04:11 +04:00
|
|
|
static void
|
2012-04-12 17:55:26 +04:00
|
|
|
lock(struct wl_listener *listener, void *data)
|
2011-04-23 21:04:11 +04:00
|
|
|
{
|
2012-04-16 18:31:41 +04:00
|
|
|
struct desktop_shell *shell =
|
|
|
|
container_of(listener, struct desktop_shell, lock_listener);
|
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_input_device *device;
|
2011-11-30 18:26:35 +04:00
|
|
|
struct shell_surface *shsurf;
|
2012-02-29 21:53:50 +04:00
|
|
|
struct weston_output *output;
|
2011-11-15 15:34:54 +04:00
|
|
|
|
2012-02-29 21:53:50 +04:00
|
|
|
if (shell->locked) {
|
|
|
|
wl_list_for_each(output, &shell->compositor->output_list, link)
|
|
|
|
/* TODO: find a way to jump to other DPMS levels */
|
|
|
|
if (output->set_dpms)
|
|
|
|
output->set_dpms(output, WESTON_DPMS_STANDBY);
|
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
|
|
|
|
2012-02-29 21:42:35 +04:00
|
|
|
wl_list_remove(&shell->panel_layer.link);
|
|
|
|
wl_list_remove(&shell->toplevel_layer.link);
|
|
|
|
wl_list_remove(&shell->fullscreen_layer.link);
|
|
|
|
wl_list_insert(&shell->compositor->cursor_layer.link,
|
|
|
|
&shell->lock_layer.link);
|
2011-11-15 15:34:54 +04:00
|
|
|
|
2011-11-30 18:26:35 +04:00
|
|
|
launch_screensaver(shell);
|
|
|
|
|
|
|
|
wl_list_for_each(shsurf, &shell->screensaver.surfaces, link)
|
|
|
|
show_screensaver(shell, shsurf);
|
|
|
|
|
2011-12-02 15:07:27 +04:00
|
|
|
if (!wl_list_empty(&shell->screensaver.surfaces)) {
|
2011-12-07 18:22:00 +04:00
|
|
|
shell->compositor->idle_time = shell->screensaver.duration;
|
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
|
|
|
weston_compositor_wake(shell->compositor);
|
|
|
|
shell->compositor->state = WESTON_COMPOSITOR_IDLE;
|
2011-12-02 15:07:27 +04:00
|
|
|
}
|
2011-12-01 18:23:57 +04:00
|
|
|
|
2011-11-15 15:34:54 +04:00
|
|
|
/* reset pointer foci */
|
2012-03-12 00:35:16 +04:00
|
|
|
weston_compositor_schedule_repaint(shell->compositor);
|
2011-11-15 15:34:54 +04:00
|
|
|
|
|
|
|
/* reset keyboard foci */
|
|
|
|
wl_list_for_each(device, &shell->compositor->input_device_list, link) {
|
|
|
|
wl_input_device_set_keyboard_focus(&device->input_device,
|
2012-04-12 06:42:15 +04:00
|
|
|
NULL);
|
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
|
2012-04-12 17:55:26 +04:00
|
|
|
unlock(struct wl_listener *listener, void *data)
|
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-04-16 18:31:41 +04:00
|
|
|
struct desktop_shell *shell =
|
|
|
|
container_of(listener, struct desktop_shell, unlock_listener);
|
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-11-16 15:47:34 +04:00
|
|
|
if (!shell->locked || shell->lock_surface) {
|
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
|
|
|
weston_compositor_wake(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
|
|
|
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;
|
|
|
|
|
2012-03-05 06:57:37 +04:00
|
|
|
desktop_shell_send_prepare_lock_surface(shell->child.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->prepare_event_sent = true;
|
2011-04-23 21:04:11 +04:00
|
|
|
}
|
|
|
|
|
2011-11-30 18:26:35 +04:00
|
|
|
static void
|
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
|
|
|
center_on_output(struct weston_surface *surface, struct weston_output *output)
|
2011-11-30 18:26:35 +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_mode *mode = output->current;
|
2012-02-13 15:03:59 +04:00
|
|
|
GLfloat x = (mode->width - surface->geometry.width) / 2;
|
|
|
|
GLfloat y = (mode->height - surface->geometry.height) / 2;
|
2011-11-30 18:26:35 +04:00
|
|
|
|
2012-02-13 15:03:59 +04:00
|
|
|
weston_surface_set_position(surface, output->x + x, output->y + y);
|
2011-11-30 18:26:35 +04:00
|
|
|
}
|
|
|
|
|
2011-04-23 21:04:11 +04:00
|
|
|
static void
|
2012-04-16 18:31:41 +04:00
|
|
|
map(struct desktop_shell *shell, struct weston_surface *surface,
|
2012-02-15 19:02:56 +04:00
|
|
|
int32_t width, int32_t height, int32_t sx, int32_t sy)
|
2011-04-23 21:04:11 +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 = shell->compositor;
|
2011-11-30 18:26:35 +04:00
|
|
|
struct shell_surface *shsurf;
|
|
|
|
enum shell_surface_type surface_type = SHELL_SURFACE_NONE;
|
2012-03-06 05:51:34 +04:00
|
|
|
struct weston_surface *parent;
|
2012-02-07 04:45:41 +04:00
|
|
|
int panel_height = 0;
|
2011-11-23 18:42:16 +04:00
|
|
|
|
2011-11-30 18:26:35 +04:00
|
|
|
shsurf = get_shell_surface(surface);
|
|
|
|
if (shsurf)
|
|
|
|
surface_type = shsurf->type;
|
2011-11-16 01:39:55 +04:00
|
|
|
|
2012-01-25 17:55:43 +04:00
|
|
|
surface->geometry.width = width;
|
|
|
|
surface->geometry.height = height;
|
|
|
|
surface->geometry.dirty = 1;
|
2011-11-30 18:26:35 +04:00
|
|
|
|
|
|
|
/* initial positioning, see also configure() */
|
|
|
|
switch (surface_type) {
|
|
|
|
case SHELL_SURFACE_TOPLEVEL:
|
2012-02-13 15:03:59 +04:00
|
|
|
weston_surface_set_position(surface, 10 + random() % 400,
|
|
|
|
10 + random() % 400);
|
2011-11-30 18:26:35 +04:00
|
|
|
break;
|
|
|
|
case SHELL_SURFACE_SCREENSAVER:
|
2012-02-18 08:49:07 +04:00
|
|
|
center_on_output(surface, shsurf->fullscreen_output);
|
2011-11-30 18:26:35 +04:00
|
|
|
break;
|
2012-03-01 08:57:46 +04:00
|
|
|
case SHELL_SURFACE_FULLSCREEN:
|
|
|
|
shell_map_fullscreen(shsurf);
|
|
|
|
break;
|
2012-02-07 04:45:41 +04:00
|
|
|
case SHELL_SURFACE_MAXIMIZED:
|
2012-03-01 08:57:46 +04:00
|
|
|
/* use surface configure to set the geometry */
|
2012-02-07 04:45:41 +04:00
|
|
|
panel_height = get_output_panel_height(shell,surface->output);
|
|
|
|
weston_surface_set_position(surface, surface->output->x,
|
|
|
|
surface->output->y + panel_height);
|
|
|
|
break;
|
2011-12-02 12:59:17 +04:00
|
|
|
case SHELL_SURFACE_LOCK:
|
|
|
|
center_on_output(surface, get_default_output(compositor));
|
|
|
|
break;
|
2012-02-10 18:17:23 +04:00
|
|
|
case SHELL_SURFACE_POPUP:
|
2012-04-13 20:40:07 +04:00
|
|
|
shell_map_popup(shsurf);
|
2012-02-15 19:02:56 +04:00
|
|
|
case SHELL_SURFACE_NONE:
|
|
|
|
weston_surface_set_position(surface,
|
|
|
|
surface->geometry.x + sx,
|
|
|
|
surface->geometry.y + sy);
|
2012-02-10 18:17:23 +04:00
|
|
|
break;
|
2011-11-30 18:26:35 +04:00
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
2011-09-06 21:48:16 +04:00
|
|
|
|
2011-11-16 15:47:33 +04:00
|
|
|
/* surface stacking order, see also activate() */
|
2011-11-28 17:34:13 +04:00
|
|
|
switch (surface_type) {
|
2011-11-23 18:42:16 +04:00
|
|
|
case SHELL_SURFACE_BACKGROUND:
|
2011-11-16 15:47:33 +04:00
|
|
|
/* background always visible, at the bottom */
|
2012-02-29 21:42:35 +04:00
|
|
|
wl_list_insert(&shell->background_layer.surface_list,
|
|
|
|
&surface->layer_link);
|
2011-11-23 18:42:16 +04:00
|
|
|
break;
|
|
|
|
case SHELL_SURFACE_PANEL:
|
2011-11-16 15:47:33 +04:00
|
|
|
/* panel always on top, hidden while locked */
|
2012-02-29 21:42:35 +04:00
|
|
|
wl_list_insert(&shell->panel_layer.surface_list,
|
|
|
|
&surface->layer_link);
|
2011-11-23 18:42:16 +04:00
|
|
|
break;
|
|
|
|
case SHELL_SURFACE_LOCK:
|
2011-11-16 15:47:33 +04:00
|
|
|
/* lock surface always visible, on top */
|
2012-02-29 21:42:35 +04:00
|
|
|
wl_list_insert(&shell->lock_layer.surface_list,
|
|
|
|
&surface->layer_link);
|
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
|
|
|
weston_compositor_wake(compositor);
|
2011-11-30 18:26:35 +04:00
|
|
|
break;
|
|
|
|
case SHELL_SURFACE_SCREENSAVER:
|
|
|
|
/* If locked, show it. */
|
2011-12-01 18:23:57 +04:00
|
|
|
if (shell->locked) {
|
2011-11-30 18:26:35 +04:00
|
|
|
show_screensaver(shell, shsurf);
|
2011-12-07 18:22:00 +04:00
|
|
|
compositor->idle_time = shell->screensaver.duration;
|
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
|
|
|
weston_compositor_wake(compositor);
|
2011-12-02 15:07:27 +04:00
|
|
|
if (!shell->lock_surface)
|
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
|
|
|
compositor->state = WESTON_COMPOSITOR_IDLE;
|
2011-12-01 18:23:57 +04:00
|
|
|
}
|
2011-11-23 18:42:16 +04:00
|
|
|
break;
|
2012-03-06 05:51:34 +04:00
|
|
|
case SHELL_SURFACE_POPUP:
|
|
|
|
case SHELL_SURFACE_TRANSIENT:
|
|
|
|
parent = shsurf->parent->surface;
|
|
|
|
wl_list_insert(parent->layer_link.prev, &surface->layer_link);
|
|
|
|
break;
|
2012-03-01 08:57:46 +04:00
|
|
|
case SHELL_SURFACE_FULLSCREEN:
|
2012-02-15 19:02:54 +04:00
|
|
|
case SHELL_SURFACE_NONE:
|
|
|
|
break;
|
2011-11-23 18:42:16 +04:00
|
|
|
default:
|
2012-02-29 21:42:35 +04:00
|
|
|
wl_list_insert(&shell->toplevel_layer.surface_list,
|
|
|
|
&surface->layer_link);
|
|
|
|
break;
|
2011-11-15 15:34:54 +04:00
|
|
|
}
|
|
|
|
|
2012-03-05 17:39:23 +04:00
|
|
|
if (surface_type != SHELL_SURFACE_NONE) {
|
|
|
|
weston_surface_assign_output(surface);
|
|
|
|
if (surface_type == SHELL_SURFACE_MAXIMIZED)
|
|
|
|
surface->output = shsurf->output;
|
|
|
|
}
|
2011-12-05 00:32:59 +04:00
|
|
|
|
2011-12-15 20:31:51 +04:00
|
|
|
switch (surface_type) {
|
|
|
|
case SHELL_SURFACE_TOPLEVEL:
|
|
|
|
case SHELL_SURFACE_TRANSIENT:
|
|
|
|
case SHELL_SURFACE_FULLSCREEN:
|
2012-02-07 04:45:41 +04:00
|
|
|
case SHELL_SURFACE_MAXIMIZED:
|
2011-12-15 20:31:51 +04:00
|
|
|
if (!shell->locked)
|
2012-04-12 17:55:26 +04:00
|
|
|
activate(shell, surface,
|
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_input_device *)
|
2012-04-12 06:42:15 +04:00
|
|
|
compositor->input_device);
|
2011-12-15 20:31:51 +04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-12-05 00:32:59 +04:00
|
|
|
if (surface_type == SHELL_SURFACE_TOPLEVEL)
|
2012-04-25 15:09:52 +04:00
|
|
|
{
|
|
|
|
switch (shell->win_animation_type) {
|
|
|
|
case ANIMATION_FADE:
|
|
|
|
weston_fade_run(surface, NULL, NULL);
|
|
|
|
break;
|
|
|
|
case ANIMATION_ZOOM:
|
|
|
|
weston_zoom_run(surface, 0.8, 1.0, NULL, NULL);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-11-09 21:07:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-04-16 18:31:41 +04:00
|
|
|
configure(struct desktop_shell *shell, struct weston_surface *surface,
|
2012-02-06 16:54:20 +04:00
|
|
|
GLfloat x, GLfloat y, int32_t width, int32_t height)
|
2011-11-09 21:07:35 +04:00
|
|
|
{
|
2011-11-30 18:26:35 +04:00
|
|
|
enum shell_surface_type surface_type = SHELL_SURFACE_NONE;
|
|
|
|
struct shell_surface *shsurf;
|
2011-11-09 21:07:35 +04:00
|
|
|
|
2011-11-30 18:26:35 +04:00
|
|
|
shsurf = get_shell_surface(surface);
|
|
|
|
if (shsurf)
|
|
|
|
surface_type = shsurf->type;
|
|
|
|
|
2012-02-17 08:43:59 +04:00
|
|
|
surface->geometry.x = x;
|
|
|
|
surface->geometry.y = y;
|
2012-01-25 17:55:43 +04:00
|
|
|
surface->geometry.width = width;
|
|
|
|
surface->geometry.height = height;
|
|
|
|
surface->geometry.dirty = 1;
|
2011-11-30 18:26:35 +04:00
|
|
|
|
|
|
|
switch (surface_type) {
|
|
|
|
case SHELL_SURFACE_SCREENSAVER:
|
2012-02-18 08:49:07 +04:00
|
|
|
center_on_output(surface, shsurf->fullscreen_output);
|
2011-11-23 19:52:40 +04:00
|
|
|
break;
|
2012-03-01 08:57:46 +04:00
|
|
|
case SHELL_SURFACE_FULLSCREEN:
|
2012-04-17 13:20:49 +04:00
|
|
|
shell_stack_fullscreen(shsurf);
|
2012-03-01 08:57:46 +04:00
|
|
|
shell_configure_fullscreen(shsurf);
|
|
|
|
break;
|
2012-02-07 04:45:41 +04:00
|
|
|
case SHELL_SURFACE_MAXIMIZED:
|
2012-03-01 08:57:46 +04:00
|
|
|
/* setting x, y and using configure to change that geometry */
|
2012-02-17 08:43:59 +04:00
|
|
|
surface->geometry.x = surface->output->x;
|
|
|
|
surface->geometry.y = surface->output->y +
|
|
|
|
get_output_panel_height(shell,surface->output);
|
2012-02-07 04:45:41 +04:00
|
|
|
break;
|
2012-03-01 08:57:46 +04:00
|
|
|
case SHELL_SURFACE_TOPLEVEL:
|
|
|
|
break;
|
2011-11-23 19:52:40 +04:00
|
|
|
default:
|
|
|
|
break;
|
2011-06-18 14:12:54 +04:00
|
|
|
}
|
2011-11-09 21:07:35 +04:00
|
|
|
|
2012-03-01 08:57:46 +04:00
|
|
|
/* XXX: would a fullscreen surface need the same handling? */
|
2012-02-17 08:43:59 +04:00
|
|
|
if (surface->output) {
|
2012-02-10 15:34:36 +04:00
|
|
|
weston_surface_assign_output(surface);
|
2011-11-30 18:26:35 +04:00
|
|
|
|
|
|
|
if (surface_type == SHELL_SURFACE_SCREENSAVER)
|
|
|
|
surface->output = shsurf->output;
|
2012-02-07 04:45:41 +04:00
|
|
|
else if (surface_type == SHELL_SURFACE_MAXIMIZED)
|
|
|
|
surface->output = shsurf->output;
|
2011-11-30 18:26:35 +04:00
|
|
|
}
|
2011-04-13 01:25:42 +04:00
|
|
|
}
|
|
|
|
|
2012-03-27 18:36:41 +04:00
|
|
|
static void
|
|
|
|
shell_surface_configure(struct weston_surface *es, int32_t sx, int32_t sy)
|
|
|
|
{
|
2012-03-27 18:36:42 +04:00
|
|
|
struct shell_surface *shsurf = get_shell_surface(es);
|
2012-04-16 18:31:41 +04:00
|
|
|
struct desktop_shell *shell = shsurf->shell;
|
2012-03-27 18:36:41 +04:00
|
|
|
|
|
|
|
if (!weston_surface_is_mapped(es)) {
|
|
|
|
map(shell, es, es->buffer->width, es->buffer->height, sx, sy);
|
2012-03-27 18:36:42 +04:00
|
|
|
} else if (shsurf->force_configure || sx != 0 || sy != 0 ||
|
2012-03-27 18:36:41 +04:00
|
|
|
es->geometry.width != es->buffer->width ||
|
|
|
|
es->geometry.height != es->buffer->height) {
|
|
|
|
GLfloat from_x, from_y;
|
|
|
|
GLfloat to_x, to_y;
|
|
|
|
|
|
|
|
weston_surface_to_global_float(es, 0, 0, &from_x, &from_y);
|
|
|
|
weston_surface_to_global_float(es, sx, sy, &to_x, &to_y);
|
|
|
|
configure(shell, es,
|
|
|
|
es->geometry.x + to_x - from_x,
|
|
|
|
es->geometry.y + to_y - from_y,
|
|
|
|
es->buffer->width, es->buffer->height);
|
2012-03-27 18:36:42 +04:00
|
|
|
shsurf->force_configure = 0;
|
2012-03-27 18:36:41 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-16 18:31:41 +04:00
|
|
|
static int launch_desktop_shell_process(struct desktop_shell *shell);
|
2012-01-17 16:36:27 +04:00
|
|
|
|
2011-11-03 16:11:32 +04:00
|
|
|
static void
|
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
|
|
|
desktop_shell_sigchld(struct weston_process *process, int status)
|
2011-11-03 16:11:32 +04:00
|
|
|
{
|
2012-01-17 16:36:27 +04:00
|
|
|
uint32_t time;
|
2012-04-16 18:31:41 +04:00
|
|
|
struct desktop_shell *shell =
|
|
|
|
container_of(process, struct desktop_shell, child.process);
|
2011-11-03 16:11:32 +04:00
|
|
|
|
|
|
|
shell->child.process.pid = 0;
|
|
|
|
shell->child.client = NULL; /* already destroyed by wayland */
|
2012-01-17 16:36:27 +04:00
|
|
|
|
|
|
|
/* if desktop-shell dies more than 5 times in 30 seconds, give up */
|
|
|
|
time = weston_compositor_get_time();
|
2012-01-17 20:07:42 +04:00
|
|
|
if (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) {
|
|
|
|
fprintf(stderr, "weston-desktop-shell died, giving up.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(stderr, "weston-desktop-shell died, respawning...\n");
|
|
|
|
launch_desktop_shell_process(shell);
|
2011-11-03 16:11:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-04-16 18:31:41 +04:00
|
|
|
launch_desktop_shell_process(struct desktop_shell *shell)
|
2011-11-03 16:11:32 +04:00
|
|
|
{
|
2012-01-03 23:35:49 +04:00
|
|
|
const char *shell_exe = LIBEXECDIR "/weston-desktop-shell";
|
2011-11-03 16:11:32 +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
|
|
|
shell->child.client = weston_client_launch(shell->compositor,
|
2011-12-02 17:30:21 +04:00
|
|
|
&shell->child.process,
|
|
|
|
shell_exe,
|
|
|
|
desktop_shell_sigchld);
|
2011-11-03 16:11:32 +04:00
|
|
|
|
2011-12-02 17:30:21 +04:00
|
|
|
if (!shell->child.client)
|
2011-11-03 16:11:32 +04:00
|
|
|
return -1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-08-27 01:21:20 +04:00
|
|
|
static void
|
|
|
|
bind_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-08-27 01:21:20 +04:00
|
|
|
|
|
|
|
wl_client_add_object(client, &wl_shell_interface,
|
2011-11-25 14:09:16 +04:00
|
|
|
&shell_implementation, id, shell);
|
2011-08-27 01:21:20 +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)
|
|
|
|
{
|
2012-04-16 18:31:41 +04:00
|
|
|
struct desktop_shell *shell = resource->data;
|
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;
|
|
|
|
free(resource);
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
resource = wl_client_add_object(client, &desktop_shell_interface,
|
|
|
|
&desktop_shell_implementation,
|
|
|
|
id, 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
|
|
|
if (client == shell->child.client) {
|
|
|
|
resource->destroy = unbind_desktop_shell;
|
|
|
|
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");
|
2012-04-12 06:42:15 +04:00
|
|
|
wl_resource_destroy(resource);
|
2011-09-06 21:48:16 +04:00
|
|
|
}
|
|
|
|
|
protocol: add screensaver interface
Add the screensaver interface to the desktop-shell protocol file. Also
add stubs for it in the compositor, and make wscreensaver to bind to the
screensaver interface. Wscreensaver gets a new option --demo to retain
the current behaviour as a regular wayland client.
When a screensaver application starts, it should bind to the screensaver
interface, enumerate all outputs, create a surface per output, and
register those surfaces via screensaver::set_surface request. Then it
continues with the usual animation loop, waiting for frame events. The
compositor will decide, when the given screensaver surfaces are
displayed. A screensaver application should respond to outputs coming
and going away by creating and destroying surfaces.
The compositor is supposed to activate a screensaver by exec'ing it, and
stop the screensaver by killing the client process. Only one client may
be bound to the screensaver interface at a time. If there already is a
client, the compositor could either kill it first, or not exec a new
one.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-24 13:34:05 +04:00
|
|
|
static void
|
|
|
|
screensaver_set_surface(struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
struct wl_resource *shell_surface_resource,
|
|
|
|
struct wl_resource *output_resource)
|
|
|
|
{
|
2012-04-16 18:31:41 +04:00
|
|
|
struct desktop_shell *shell = resource->data;
|
protocol: add screensaver interface
Add the screensaver interface to the desktop-shell protocol file. Also
add stubs for it in the compositor, and make wscreensaver to bind to the
screensaver interface. Wscreensaver gets a new option --demo to retain
the current behaviour as a regular wayland client.
When a screensaver application starts, it should bind to the screensaver
interface, enumerate all outputs, create a surface per output, and
register those surfaces via screensaver::set_surface request. Then it
continues with the usual animation loop, waiting for frame events. The
compositor will decide, when the given screensaver surfaces are
displayed. A screensaver application should respond to outputs coming
and going away by creating and destroying surfaces.
The compositor is supposed to activate a screensaver by exec'ing it, and
stop the screensaver by killing the client process. Only one client may
be bound to the screensaver interface at a time. If there already is a
client, the compositor could either kill it first, or not exec a new
one.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-24 13:34:05 +04:00
|
|
|
struct shell_surface *surface = shell_surface_resource->data;
|
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 = output_resource->data;
|
protocol: add screensaver interface
Add the screensaver interface to the desktop-shell protocol file. Also
add stubs for it in the compositor, and make wscreensaver to bind to the
screensaver interface. Wscreensaver gets a new option --demo to retain
the current behaviour as a regular wayland client.
When a screensaver application starts, it should bind to the screensaver
interface, enumerate all outputs, create a surface per output, and
register those surfaces via screensaver::set_surface request. Then it
continues with the usual animation loop, waiting for frame events. The
compositor will decide, when the given screensaver surfaces are
displayed. A screensaver application should respond to outputs coming
and going away by creating and destroying surfaces.
The compositor is supposed to activate a screensaver by exec'ing it, and
stop the screensaver by killing the client process. Only one client may
be bound to the screensaver interface at a time. If there already is a
client, the compositor could either kill it first, or not exec a new
one.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-24 13:34:05 +04:00
|
|
|
|
2011-12-01 12:42:22 +04:00
|
|
|
if (reset_shell_surface_type(surface))
|
|
|
|
return;
|
|
|
|
|
2011-11-30 18:26:35 +04:00
|
|
|
surface->type = SHELL_SURFACE_SCREENSAVER;
|
|
|
|
|
2012-02-18 08:49:07 +04:00
|
|
|
surface->fullscreen_output = output;
|
2011-11-30 18:26:35 +04:00
|
|
|
surface->output = output;
|
|
|
|
wl_list_insert(shell->screensaver.surfaces.prev, &surface->link);
|
protocol: add screensaver interface
Add the screensaver interface to the desktop-shell protocol file. Also
add stubs for it in the compositor, and make wscreensaver to bind to the
screensaver interface. Wscreensaver gets a new option --demo to retain
the current behaviour as a regular wayland client.
When a screensaver application starts, it should bind to the screensaver
interface, enumerate all outputs, create a surface per output, and
register those surfaces via screensaver::set_surface request. Then it
continues with the usual animation loop, waiting for frame events. The
compositor will decide, when the given screensaver surfaces are
displayed. A screensaver application should respond to outputs coming
and going away by creating and destroying surfaces.
The compositor is supposed to activate a screensaver by exec'ing it, and
stop the screensaver by killing the client process. Only one client may
be bound to the screensaver interface at a time. If there already is a
client, the compositor could either kill it first, or not exec a new
one.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-24 13:34:05 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct screensaver_interface screensaver_implementation = {
|
|
|
|
screensaver_set_surface
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
unbind_screensaver(struct wl_resource *resource)
|
|
|
|
{
|
2012-04-16 18:31:41 +04:00
|
|
|
struct desktop_shell *shell = resource->data;
|
protocol: add screensaver interface
Add the screensaver interface to the desktop-shell protocol file. Also
add stubs for it in the compositor, and make wscreensaver to bind to the
screensaver interface. Wscreensaver gets a new option --demo to retain
the current behaviour as a regular wayland client.
When a screensaver application starts, it should bind to the screensaver
interface, enumerate all outputs, create a surface per output, and
register those surfaces via screensaver::set_surface request. Then it
continues with the usual animation loop, waiting for frame events. The
compositor will decide, when the given screensaver surfaces are
displayed. A screensaver application should respond to outputs coming
and going away by creating and destroying surfaces.
The compositor is supposed to activate a screensaver by exec'ing it, and
stop the screensaver by killing the client process. Only one client may
be bound to the screensaver interface at a time. If there already is a
client, the compositor could either kill it first, or not exec a new
one.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-24 13:34:05 +04:00
|
|
|
|
2011-11-30 18:26:35 +04:00
|
|
|
shell->screensaver.binding = NULL;
|
protocol: add screensaver interface
Add the screensaver interface to the desktop-shell protocol file. Also
add stubs for it in the compositor, and make wscreensaver to bind to the
screensaver interface. Wscreensaver gets a new option --demo to retain
the current behaviour as a regular wayland client.
When a screensaver application starts, it should bind to the screensaver
interface, enumerate all outputs, create a surface per output, and
register those surfaces via screensaver::set_surface request. Then it
continues with the usual animation loop, waiting for frame events. The
compositor will decide, when the given screensaver surfaces are
displayed. A screensaver application should respond to outputs coming
and going away by creating and destroying surfaces.
The compositor is supposed to activate a screensaver by exec'ing it, and
stop the screensaver by killing the client process. Only one client may
be bound to the screensaver interface at a time. If there already is a
client, the compositor could either kill it first, or not exec a new
one.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-24 13:34:05 +04:00
|
|
|
free(resource);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
bind_screensaver(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;
|
protocol: add screensaver interface
Add the screensaver interface to the desktop-shell protocol file. Also
add stubs for it in the compositor, and make wscreensaver to bind to the
screensaver interface. Wscreensaver gets a new option --demo to retain
the current behaviour as a regular wayland client.
When a screensaver application starts, it should bind to the screensaver
interface, enumerate all outputs, create a surface per output, and
register those surfaces via screensaver::set_surface request. Then it
continues with the usual animation loop, waiting for frame events. The
compositor will decide, when the given screensaver surfaces are
displayed. A screensaver application should respond to outputs coming
and going away by creating and destroying surfaces.
The compositor is supposed to activate a screensaver by exec'ing it, and
stop the screensaver by killing the client process. Only one client may
be bound to the screensaver interface at a time. If there already is a
client, the compositor could either kill it first, or not exec a new
one.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-24 13:34:05 +04:00
|
|
|
struct wl_resource *resource;
|
|
|
|
|
|
|
|
resource = wl_client_add_object(client, &screensaver_interface,
|
|
|
|
&screensaver_implementation,
|
|
|
|
id, shell);
|
|
|
|
|
2011-11-30 18:26:35 +04:00
|
|
|
if (shell->screensaver.binding == NULL) {
|
protocol: add screensaver interface
Add the screensaver interface to the desktop-shell protocol file. Also
add stubs for it in the compositor, and make wscreensaver to bind to the
screensaver interface. Wscreensaver gets a new option --demo to retain
the current behaviour as a regular wayland client.
When a screensaver application starts, it should bind to the screensaver
interface, enumerate all outputs, create a surface per output, and
register those surfaces via screensaver::set_surface request. Then it
continues with the usual animation loop, waiting for frame events. The
compositor will decide, when the given screensaver surfaces are
displayed. A screensaver application should respond to outputs coming
and going away by creating and destroying surfaces.
The compositor is supposed to activate a screensaver by exec'ing it, and
stop the screensaver by killing the client process. Only one client may
be bound to the screensaver interface at a time. If there already is a
client, the compositor could either kill it first, or not exec a new
one.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-24 13:34:05 +04:00
|
|
|
resource->destroy = unbind_screensaver;
|
2011-11-30 18:26:35 +04:00
|
|
|
shell->screensaver.binding = resource;
|
protocol: add screensaver interface
Add the screensaver interface to the desktop-shell protocol file. Also
add stubs for it in the compositor, and make wscreensaver to bind to the
screensaver interface. Wscreensaver gets a new option --demo to retain
the current behaviour as a regular wayland client.
When a screensaver application starts, it should bind to the screensaver
interface, enumerate all outputs, create a surface per output, and
register those surfaces via screensaver::set_surface request. Then it
continues with the usual animation loop, waiting for frame events. The
compositor will decide, when the given screensaver surfaces are
displayed. A screensaver application should respond to outputs coming
and going away by creating and destroying surfaces.
The compositor is supposed to activate a screensaver by exec'ing it, and
stop the screensaver by killing the client process. Only one client may
be bound to the screensaver interface at a time. If there already is a
client, the compositor could either kill it first, or not exec a new
one.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-24 13:34:05 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
|
|
|
|
"interface object already bound");
|
2012-04-12 06:42:15 +04:00
|
|
|
wl_resource_destroy(resource);
|
protocol: add screensaver interface
Add the screensaver interface to the desktop-shell protocol file. Also
add stubs for it in the compositor, and make wscreensaver to bind to the
screensaver interface. Wscreensaver gets a new option --demo to retain
the current behaviour as a regular wayland client.
When a screensaver application starts, it should bind to the screensaver
interface, enumerate all outputs, create a surface per output, and
register those surfaces via screensaver::set_surface request. Then it
continues with the usual animation loop, waiting for frame events. The
compositor will decide, when the given screensaver surfaces are
displayed. A screensaver application should respond to outputs coming
and going away by creating and destroying surfaces.
The compositor is supposed to activate a screensaver by exec'ing it, and
stop the screensaver by killing the client process. Only one client may
be bound to the screensaver interface at a time. If there already is a
client, the compositor could either kill it first, or not exec a new
one.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-24 13:34:05 +04:00
|
|
|
}
|
|
|
|
|
2012-02-20 03:52:44 +04:00
|
|
|
struct switcher {
|
2012-04-16 18:31:41 +04:00
|
|
|
struct desktop_shell *shell;
|
2012-02-20 03:52:44 +04:00
|
|
|
struct weston_surface *current;
|
|
|
|
struct wl_listener listener;
|
|
|
|
struct wl_keyboard_grab grab;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
switcher_next(struct switcher *switcher)
|
|
|
|
{
|
2012-04-12 17:55:26 +04:00
|
|
|
struct weston_compositor *compositor = switcher->shell->compositor;
|
2012-02-20 03:52:44 +04:00
|
|
|
struct weston_surface *surface;
|
|
|
|
struct weston_surface *first = NULL, *prev = NULL, *next = NULL;
|
2012-04-03 06:18:58 +04:00
|
|
|
struct shell_surface *shsurf;
|
2012-02-20 03:52:44 +04:00
|
|
|
|
|
|
|
wl_list_for_each(surface, &compositor->surface_list, link) {
|
|
|
|
switch (get_shell_surface_type(surface)) {
|
|
|
|
case SHELL_SURFACE_TOPLEVEL:
|
|
|
|
case SHELL_SURFACE_FULLSCREEN:
|
|
|
|
case SHELL_SURFACE_MAXIMIZED:
|
|
|
|
if (first == NULL)
|
|
|
|
first = surface;
|
|
|
|
if (prev == switcher->current)
|
|
|
|
next = surface;
|
|
|
|
prev = surface;
|
|
|
|
surface->alpha = 64;
|
2012-02-28 18:20:21 +04:00
|
|
|
surface->geometry.dirty = 1;
|
2012-02-20 03:52:44 +04:00
|
|
|
weston_surface_damage(surface);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2012-04-01 16:13:09 +04:00
|
|
|
|
|
|
|
if (is_black_surface(surface, NULL)) {
|
|
|
|
surface->alpha = 64;
|
|
|
|
surface->geometry.dirty = 1;
|
|
|
|
weston_surface_damage(surface);
|
|
|
|
}
|
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);
|
2012-04-12 07:18:23 +04:00
|
|
|
wl_signal_add(&next->surface.resource.destroy_signal,
|
|
|
|
&switcher->listener);
|
2012-02-20 03:52:44 +04:00
|
|
|
|
|
|
|
switcher->current = next;
|
|
|
|
next->alpha = 255;
|
2012-04-01 16:13:09 +04:00
|
|
|
|
2012-04-03 06:18:58 +04:00
|
|
|
shsurf = get_shell_surface(switcher->current);
|
|
|
|
if (shsurf && shsurf->type ==SHELL_SURFACE_FULLSCREEN)
|
|
|
|
shsurf->fullscreen.black_surface->alpha = 255;
|
2012-02-20 03:52:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-04-12 07:18:23 +04:00
|
|
|
switcher_handle_surface_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
|
|
|
|
switcher_destroy(struct switcher *switcher, uint32_t time)
|
|
|
|
{
|
2012-04-12 17:55:26 +04:00
|
|
|
struct weston_compositor *compositor = switcher->shell->compositor;
|
2012-02-20 03:52:44 +04:00
|
|
|
struct weston_surface *surface;
|
|
|
|
struct weston_input_device *device =
|
|
|
|
(struct weston_input_device *) switcher->grab.input_device;
|
|
|
|
|
|
|
|
wl_list_for_each(surface, &compositor->surface_list, link) {
|
|
|
|
surface->alpha = 255;
|
|
|
|
weston_surface_damage(surface);
|
|
|
|
}
|
|
|
|
|
2012-03-12 12:06:01 +04:00
|
|
|
if (switcher->current)
|
2012-04-12 17:55:26 +04:00
|
|
|
activate(switcher->shell, switcher->current, device);
|
2012-02-20 03:52:44 +04:00
|
|
|
wl_list_remove(&switcher->listener.link);
|
2012-04-12 06:42:15 +04:00
|
|
|
wl_input_device_end_keyboard_grab(&device->input_device);
|
2012-02-20 03:52:44 +04:00
|
|
|
free(switcher);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
switcher_key(struct wl_keyboard_grab *grab,
|
|
|
|
uint32_t time, uint32_t key, int32_t state)
|
|
|
|
{
|
|
|
|
struct switcher *switcher = container_of(grab, struct switcher, grab);
|
|
|
|
struct weston_input_device *device =
|
|
|
|
(struct weston_input_device *) grab->input_device;
|
|
|
|
|
2012-04-20 19:54:25 +04:00
|
|
|
if ((device->modifier_state & switcher->shell->binding_modifier) == 0) {
|
2012-02-20 03:52:44 +04:00
|
|
|
switcher_destroy(switcher, time);
|
|
|
|
} else if (key == KEY_TAB && state) {
|
|
|
|
switcher_next(switcher);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct wl_keyboard_grab_interface switcher_grab = {
|
|
|
|
switcher_key
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
switcher_binding(struct wl_input_device *device, uint32_t time,
|
2012-03-20 18:47:59 +04:00
|
|
|
uint32_t key, uint32_t button, uint32_t axis,
|
|
|
|
int32_t state, 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);
|
2012-04-12 17:55:26 +04:00
|
|
|
switcher->shell = shell;
|
2012-02-20 03:52:44 +04:00
|
|
|
switcher->current = NULL;
|
2012-04-12 07:18:23 +04:00
|
|
|
switcher->listener.notify = switcher_handle_surface_destroy;
|
2012-02-20 03:52:44 +04:00
|
|
|
wl_list_init(&switcher->listener.link);
|
|
|
|
|
|
|
|
switcher->grab.interface = &switcher_grab;
|
2012-04-12 06:42:15 +04:00
|
|
|
wl_input_device_start_keyboard_grab(device, &switcher->grab);
|
|
|
|
wl_input_device_set_keyboard_focus(device, NULL);
|
2012-02-20 03:52:44 +04:00
|
|
|
switcher_next(switcher);
|
|
|
|
}
|
|
|
|
|
2012-02-29 21:53:50 +04:00
|
|
|
static void
|
|
|
|
backlight_binding(struct wl_input_device *device, uint32_t time,
|
2012-03-20 18:47:59 +04:00
|
|
|
uint32_t key, uint32_t button, uint32_t axis, int32_t state, 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 */
|
|
|
|
output = get_default_output(compositor);
|
|
|
|
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-03-04 23:53:40 +04:00
|
|
|
static void
|
|
|
|
debug_repaint_binding(struct wl_input_device *device, uint32_t time,
|
2012-03-20 18:47:59 +04:00
|
|
|
uint32_t key, uint32_t button, uint32_t axis, int32_t state, void *data)
|
2012-03-04 23:53:40 +04:00
|
|
|
{
|
2012-04-16 18:31:41 +04:00
|
|
|
struct desktop_shell *shell = data;
|
2012-04-12 17:55:26 +04:00
|
|
|
struct weston_compositor *compositor = shell->compositor;
|
2012-03-04 23:53:40 +04:00
|
|
|
struct weston_surface *surface;
|
|
|
|
|
|
|
|
if (shell->debug_repaint_surface) {
|
|
|
|
weston_surface_destroy(shell->debug_repaint_surface);
|
|
|
|
shell->debug_repaint_surface = NULL;
|
|
|
|
} else {
|
|
|
|
surface = weston_surface_create(compositor);
|
|
|
|
weston_surface_set_color(surface, 1.0, 0.0, 0.0, 0.2);
|
|
|
|
weston_surface_configure(surface, 0, 0, 8192, 8192);
|
|
|
|
wl_list_insert(&compositor->fade_layer.surface_list,
|
|
|
|
&surface->layer_link);
|
|
|
|
weston_surface_assign_output(surface);
|
|
|
|
pixman_region32_init(&surface->input);
|
|
|
|
|
|
|
|
/* Here's the dirty little trick that makes the
|
|
|
|
* repaint debugging work: we force an
|
|
|
|
* update_transform first to update dependent state
|
|
|
|
* and clear the geometry.dirty bit. Then we clear
|
|
|
|
* the surface damage so it only gets repainted
|
|
|
|
* piecewise as we repaint other things. */
|
|
|
|
|
|
|
|
weston_surface_update_transform(surface);
|
|
|
|
pixman_region32_fini(&surface->damage);
|
|
|
|
pixman_region32_init(&surface->damage);
|
|
|
|
shell->debug_repaint_surface = surface;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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);
|
2011-12-22 15:43:43 +04:00
|
|
|
|
2012-01-02 18:00:24 +04:00
|
|
|
if (shell->child.client)
|
|
|
|
wl_client_destroy(shell->child.client);
|
|
|
|
|
2011-12-22 15:43:43 +04:00
|
|
|
free(shell->screensaver.path);
|
|
|
|
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;
|
|
|
|
|
|
|
|
/* fixed bindings */
|
|
|
|
weston_compositor_add_binding(ec, KEY_BACKSPACE, 0, 0,
|
|
|
|
MODIFIER_CTRL | MODIFIER_ALT,
|
|
|
|
terminate_binding, ec);
|
|
|
|
weston_compositor_add_binding(ec, 0, BTN_LEFT, 0, 0,
|
|
|
|
click_to_activate_binding, shell);
|
|
|
|
weston_compositor_add_binding(ec, 0, 0,
|
|
|
|
WL_INPUT_DEVICE_AXIS_VERTICAL_SCROLL,
|
|
|
|
MODIFIER_SUPER | MODIFIER_ALT,
|
|
|
|
surface_opacity_binding, NULL);
|
|
|
|
weston_compositor_add_binding(ec, 0, 0,
|
|
|
|
WL_INPUT_DEVICE_AXIS_VERTICAL_SCROLL,
|
|
|
|
MODIFIER_SUPER, zoom_binding, NULL);
|
|
|
|
|
|
|
|
/* configurable bindings */
|
|
|
|
mod = shell->binding_modifier;
|
|
|
|
weston_compositor_add_binding(ec, 0, BTN_LEFT, 0, mod,
|
|
|
|
move_binding, shell);
|
|
|
|
weston_compositor_add_binding(ec, 0, BTN_MIDDLE, 0, mod,
|
|
|
|
resize_binding, shell);
|
|
|
|
weston_compositor_add_binding(ec, 0, BTN_RIGHT, 0, mod,
|
|
|
|
rotate_binding, NULL);
|
|
|
|
weston_compositor_add_binding(ec, KEY_TAB, 0, 0, mod,
|
|
|
|
switcher_binding, shell);
|
|
|
|
weston_compositor_add_binding(ec, KEY_F9, 0, 0, mod,
|
|
|
|
backlight_binding, ec);
|
|
|
|
weston_compositor_add_binding(ec, KEY_BRIGHTNESSDOWN, 0, 0, 0,
|
|
|
|
backlight_binding, ec);
|
|
|
|
weston_compositor_add_binding(ec, KEY_F10, 0, 0, mod,
|
|
|
|
backlight_binding, ec);
|
|
|
|
weston_compositor_add_binding(ec, KEY_BRIGHTNESSUP, 0, 0, 0,
|
|
|
|
backlight_binding, ec);
|
|
|
|
weston_compositor_add_binding(ec, KEY_SPACE, 0, 0, mod,
|
|
|
|
debug_repaint_binding, shell);
|
|
|
|
}
|
|
|
|
|
2011-05-06 22:52:41 +04:00
|
|
|
int
|
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
|
|
|
shell_init(struct weston_compositor *ec);
|
2011-05-06 22:52:41 +04:00
|
|
|
|
2011-05-03 06:09:20 +04:00
|
|
|
WL_EXPORT int
|
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
|
|
|
shell_init(struct weston_compositor *ec)
|
2011-01-18 15:53:49 +03:00
|
|
|
{
|
2012-04-16 18:31:41 +04:00
|
|
|
struct desktop_shell *shell;
|
2011-04-23 21:04:11 +04:00
|
|
|
|
|
|
|
shell = malloc(sizeof *shell);
|
|
|
|
if (shell == NULL)
|
|
|
|
return -1;
|
|
|
|
|
2011-10-12 06:44:23 +04:00
|
|
|
memset(shell, 0, sizeof *shell);
|
2011-09-06 21:48:16 +04:00
|
|
|
shell->compositor = ec;
|
2012-04-12 17:55:26 +04:00
|
|
|
|
|
|
|
shell->destroy_listener.notify = shell_destroy;
|
|
|
|
wl_signal_add(&ec->destroy_signal, &shell->destroy_listener);
|
|
|
|
shell->lock_listener.notify = lock;
|
|
|
|
wl_signal_add(&ec->lock_signal, &shell->lock_listener);
|
|
|
|
shell->unlock_listener.notify = unlock;
|
|
|
|
wl_signal_add(&ec->unlock_signal, &shell->unlock_listener);
|
2012-04-18 05:06:18 +04:00
|
|
|
ec->ping_handler = ping_handler;
|
2012-04-19 17:18:18 +04:00
|
|
|
ec->shell_interface.create_shell_surface = create_shell_surface;
|
|
|
|
ec->shell_interface.set_toplevel = set_toplevel;
|
2011-01-18 15:53:49 +03:00
|
|
|
|
2011-11-22 15:43:52 +04:00
|
|
|
wl_list_init(&shell->backgrounds);
|
|
|
|
wl_list_init(&shell->panels);
|
2011-11-30 18:26:35 +04:00
|
|
|
wl_list_init(&shell->screensaver.surfaces);
|
2011-11-15 15:34:54 +04:00
|
|
|
|
2012-02-29 21:42:35 +04:00
|
|
|
weston_layer_init(&shell->fullscreen_layer, &ec->cursor_layer.link);
|
|
|
|
weston_layer_init(&shell->panel_layer, &shell->fullscreen_layer.link);
|
|
|
|
weston_layer_init(&shell->toplevel_layer, &shell->panel_layer.link);
|
|
|
|
weston_layer_init(&shell->background_layer,
|
|
|
|
&shell->toplevel_layer.link);
|
|
|
|
wl_list_init(&shell->lock_layer.surface_list);
|
|
|
|
|
2012-01-26 01:57:11 +04:00
|
|
|
shell_configuration(shell);
|
2011-12-07 13:49:52 +04:00
|
|
|
|
2011-08-27 01:21:20 +04:00
|
|
|
if (wl_display_add_global(ec->wl_display, &wl_shell_interface,
|
|
|
|
shell, bind_shell) == NULL)
|
2011-01-18 15:53:49 +03:00
|
|
|
return -1;
|
|
|
|
|
2011-09-06 21:48:16 +04:00
|
|
|
if (wl_display_add_global(ec->wl_display,
|
|
|
|
&desktop_shell_interface,
|
|
|
|
shell, bind_desktop_shell) == NULL)
|
|
|
|
return -1;
|
|
|
|
|
protocol: add screensaver interface
Add the screensaver interface to the desktop-shell protocol file. Also
add stubs for it in the compositor, and make wscreensaver to bind to the
screensaver interface. Wscreensaver gets a new option --demo to retain
the current behaviour as a regular wayland client.
When a screensaver application starts, it should bind to the screensaver
interface, enumerate all outputs, create a surface per output, and
register those surfaces via screensaver::set_surface request. Then it
continues with the usual animation loop, waiting for frame events. The
compositor will decide, when the given screensaver surfaces are
displayed. A screensaver application should respond to outputs coming
and going away by creating and destroying surfaces.
The compositor is supposed to activate a screensaver by exec'ing it, and
stop the screensaver by killing the client process. Only one client may
be bound to the screensaver interface at a time. If there already is a
client, the compositor could either kill it first, or not exec a new
one.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-24 13:34:05 +04:00
|
|
|
if (wl_display_add_global(ec->wl_display, &screensaver_interface,
|
|
|
|
shell, bind_screensaver) == NULL)
|
|
|
|
return -1;
|
|
|
|
|
2012-01-17 20:07:42 +04:00
|
|
|
shell->child.deathstamp = weston_compositor_get_time();
|
2011-11-03 16:11:32 +04:00
|
|
|
if (launch_desktop_shell_process(shell) != 0)
|
|
|
|
return -1;
|
|
|
|
|
2012-04-20 19:54:25 +04:00
|
|
|
shell_add_bindings(ec, shell);
|
2011-04-13 01:25:42 +04:00
|
|
|
|
2011-01-18 15:53:49 +03:00
|
|
|
return 0;
|
|
|
|
}
|