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>
|
2012-05-26 21:41:06 +04:00
|
|
|
#include <sys/types.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"
|
2012-08-30 00:13:01 +04:00
|
|
|
#include "workspaces-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-06-13 02:01:22 +04:00
|
|
|
#define DEFAULT_NUM_WORKSPACES 1
|
2012-06-13 02:01:23 +04:00
|
|
|
#define DEFAULT_WORKSPACE_CHANGE_ANIMATION_LENGTH 200
|
2012-06-13 02:01:22 +04:00
|
|
|
|
2012-04-25 15:09:52 +04:00
|
|
|
enum animation_type {
|
|
|
|
ANIMATION_NONE,
|
|
|
|
|
|
|
|
ANIMATION_ZOOM,
|
|
|
|
ANIMATION_FADE
|
|
|
|
};
|
|
|
|
|
2012-06-13 02:01:24 +04:00
|
|
|
struct focus_state {
|
|
|
|
struct weston_seat *seat;
|
2012-08-01 00:36:34 +04:00
|
|
|
struct workspace *ws;
|
2012-06-13 02:01:24 +04:00
|
|
|
struct weston_surface *keyboard_focus;
|
|
|
|
struct wl_list link;
|
|
|
|
struct wl_listener seat_destroy_listener;
|
|
|
|
struct wl_listener surface_destroy_listener;
|
|
|
|
};
|
|
|
|
|
2012-06-13 02:01:22 +04:00
|
|
|
struct workspace {
|
|
|
|
struct weston_layer layer;
|
2012-06-13 02:01:24 +04:00
|
|
|
|
|
|
|
struct wl_list focus_list;
|
|
|
|
struct wl_listener seat_destroyed_listener;
|
2012-06-13 02:01:22 +04:00
|
|
|
};
|
|
|
|
|
2012-08-06 15:44:42 +04:00
|
|
|
struct input_panel_surface {
|
|
|
|
struct wl_list link;
|
|
|
|
struct weston_surface *surface;
|
|
|
|
struct wl_listener listener;
|
|
|
|
};
|
|
|
|
|
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;
|
2012-06-21 23:52:17 +04:00
|
|
|
struct wl_listener show_input_panel_listener;
|
|
|
|
struct wl_listener hide_input_panel_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 background_layer;
|
|
|
|
struct weston_layer lock_layer;
|
2012-08-09 20:50:43 +04:00
|
|
|
struct weston_layer input_panel_layer;
|
2012-02-29 21:42:35 +04:00
|
|
|
|
2012-06-05 17:58:51 +04:00
|
|
|
struct wl_listener pointer_focus_listener;
|
2012-06-28 19:08:05 +04:00
|
|
|
struct weston_surface *grab_surface;
|
2012-06-05 17:58:51 +04:00
|
|
|
|
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;
|
2012-08-09 20:50:43 +04:00
|
|
|
bool showing_input_panels;
|
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 prepare_event_sent;
|
2011-11-15 15:34:54 +04:00
|
|
|
|
2012-06-27 05:44:35 +04:00
|
|
|
struct weston_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
|
|
|
|
2012-06-13 02:01:22 +04:00
|
|
|
struct {
|
|
|
|
struct wl_array array;
|
|
|
|
unsigned int current;
|
|
|
|
unsigned int num;
|
2012-06-13 02:01:23 +04:00
|
|
|
|
2012-08-30 00:13:01 +04:00
|
|
|
struct wl_list client_list;
|
|
|
|
|
2012-06-13 02:01:23 +04:00
|
|
|
struct weston_animation animation;
|
2012-08-30 00:13:00 +04:00
|
|
|
struct wl_list anim_sticky_list;
|
2012-06-13 02:01:23 +04:00
|
|
|
int anim_dir;
|
|
|
|
uint32_t anim_timestamp;
|
|
|
|
double anim_current;
|
|
|
|
struct workspace *anim_from;
|
|
|
|
struct workspace *anim_to;
|
2012-06-13 02:01:22 +04:00
|
|
|
} workspaces;
|
|
|
|
|
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-06-21 23:52:17 +04:00
|
|
|
struct {
|
|
|
|
struct wl_resource *binding;
|
|
|
|
struct wl_list surfaces;
|
|
|
|
} input_panel;
|
|
|
|
|
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
|
|
|
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-06-27 18:22:58 +04:00
|
|
|
struct weston_surface *parent;
|
2012-04-16 18:31:41 +04:00
|
|
|
struct desktop_shell *shell;
|
2011-11-23 18:42:16 +04:00
|
|
|
|
2012-04-28 01:20:01 +04:00
|
|
|
enum shell_surface_type type, next_type;
|
2012-05-02 17:47:44 +04:00
|
|
|
char *title, *class;
|
2011-11-23 19:52:40 +04:00
|
|
|
int32_t saved_x, saved_y;
|
2012-03-01 08:57:46 +04:00
|
|
|
bool saved_position_valid;
|
2012-04-27 05:07:24 +04:00
|
|
|
bool saved_rotation_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-05-16 21:45:18 +04:00
|
|
|
struct wl_seat *seat;
|
2012-04-13 20:40:07 +04:00
|
|
|
uint32_t serial;
|
2012-01-05 07:19:14 +04:00
|
|
|
} popup;
|
|
|
|
|
2012-05-07 16:23:08 +04:00
|
|
|
struct {
|
|
|
|
int32_t x, y;
|
2012-05-19 00:37:43 +04:00
|
|
|
uint32_t flags;
|
2012-05-07 16:23:08 +04:00
|
|
|
} transient;
|
|
|
|
|
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-06-13 02:01:23 +04:00
|
|
|
struct weston_transform workspace_transform;
|
|
|
|
|
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-05-23 00:05:52 +04:00
|
|
|
|
|
|
|
const struct weston_shell_client *client;
|
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;
|
2012-06-28 19:08:05 +04:00
|
|
|
struct wl_pointer *pointer;
|
2012-04-04 18:48:05 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct weston_move_grab {
|
|
|
|
struct shell_grab base;
|
2012-05-08 20:17:55 +04:00
|
|
|
wl_fixed_t dx, dy;
|
2011-01-18 15:53:49 +03:00
|
|
|
};
|
|
|
|
|
2012-01-20 18:48:25 +04:00
|
|
|
struct rotate_grab {
|
2012-04-04 18:48:05 +04:00
|
|
|
struct shell_grab base;
|
2012-01-27 22:36:13 +04:00
|
|
|
struct weston_matrix rotation;
|
2012-01-20 18:48:25 +04:00
|
|
|
struct {
|
2012-06-08 04:10:23 +04:00
|
|
|
GLfloat x;
|
|
|
|
GLfloat y;
|
2012-01-20 18:48:25 +04:00
|
|
|
} center;
|
|
|
|
};
|
|
|
|
|
2012-08-01 00:36:34 +04:00
|
|
|
static void
|
|
|
|
activate(struct desktop_shell *shell, struct weston_surface *es,
|
|
|
|
struct weston_seat *seat);
|
|
|
|
|
|
|
|
static struct workspace *
|
|
|
|
get_current_workspace(struct desktop_shell *shell);
|
|
|
|
|
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
|
2012-06-28 19:08:05 +04:00
|
|
|
shell_grab_start(struct shell_grab *grab,
|
|
|
|
const struct wl_pointer_grab_interface *interface,
|
|
|
|
struct shell_surface *shsurf,
|
|
|
|
struct wl_pointer *pointer,
|
|
|
|
enum desktop_shell_cursor cursor)
|
2012-04-04 18:48:05 +04:00
|
|
|
{
|
2012-06-28 19:08:05 +04:00
|
|
|
struct desktop_shell *shell = shsurf->shell;
|
|
|
|
|
2012-04-04 18:48:05 +04:00
|
|
|
grab->grab.interface = interface;
|
|
|
|
grab->shsurf = shsurf;
|
2012-04-12 07:18:23 +04:00
|
|
|
grab->shsurf_destroy_listener.notify = destroy_shell_grab_shsurf;
|
|
|
|
wl_signal_add(&shsurf->resource.destroy_signal,
|
|
|
|
&grab->shsurf_destroy_listener);
|
2012-04-04 18:48:05 +04:00
|
|
|
|
2012-06-28 19:08:05 +04:00
|
|
|
grab->pointer = pointer;
|
|
|
|
grab->grab.focus = &shsurf->surface->surface;
|
|
|
|
|
|
|
|
wl_pointer_start_grab(pointer, &grab->grab);
|
|
|
|
desktop_shell_send_grab_cursor(shell->child.desktop_shell, cursor);
|
|
|
|
wl_pointer_set_focus(pointer, &shell->grab_surface->surface,
|
|
|
|
wl_fixed_from_int(0), wl_fixed_from_int(0));
|
2012-04-04 18:48:05 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-28 19:08:05 +04:00
|
|
|
shell_grab_end(struct shell_grab *grab)
|
2012-04-04 18:48:05 +04:00
|
|
|
{
|
2012-06-08 02:08:04 +04:00
|
|
|
if (grab->shsurf)
|
|
|
|
wl_list_remove(&grab->shsurf_destroy_listener.link);
|
2012-06-28 19:08:05 +04:00
|
|
|
|
|
|
|
wl_pointer_end_grab(grab->pointer);
|
2012-04-04 18:48:05 +04:00
|
|
|
}
|
|
|
|
|
2012-03-01 08:57:46 +04:00
|
|
|
static void
|
|
|
|
center_on_output(struct weston_surface *surface,
|
|
|
|
struct weston_output *output);
|
|
|
|
|
2012-05-30 19:31:42 +04:00
|
|
|
static enum weston_keyboard_modifier
|
2012-04-20 19:54:25 +04:00
|
|
|
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-06-13 02:01:22 +04:00
|
|
|
unsigned int num_workspaces = DEFAULT_NUM_WORKSPACES;
|
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-06-13 02:01:22 +04:00
|
|
|
{ "num-workspaces",
|
|
|
|
CONFIG_KEY_UNSIGNED_INTEGER, &num_workspaces },
|
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);
|
2012-06-13 02:01:22 +04:00
|
|
|
shell->workspaces.num = num_workspaces > 0 ? num_workspaces : 1;
|
|
|
|
}
|
|
|
|
|
2012-06-13 02:01:24 +04:00
|
|
|
static void
|
|
|
|
focus_state_destroy(struct focus_state *state)
|
|
|
|
{
|
|
|
|
wl_list_remove(&state->seat_destroy_listener.link);
|
|
|
|
wl_list_remove(&state->surface_destroy_listener.link);
|
|
|
|
free(state);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
focus_state_seat_destroy(struct wl_listener *listener, void *data)
|
|
|
|
{
|
|
|
|
struct focus_state *state = container_of(listener,
|
|
|
|
struct focus_state,
|
|
|
|
seat_destroy_listener);
|
|
|
|
|
|
|
|
wl_list_remove(&state->link);
|
|
|
|
focus_state_destroy(state);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
focus_state_surface_destroy(struct wl_listener *listener, void *data)
|
|
|
|
{
|
|
|
|
struct focus_state *state = container_of(listener,
|
|
|
|
struct focus_state,
|
2012-07-31 18:30:26 +04:00
|
|
|
surface_destroy_listener);
|
2012-08-01 01:29:30 +04:00
|
|
|
struct desktop_shell *shell;
|
|
|
|
struct weston_surface *surface, *next;
|
|
|
|
|
|
|
|
next = NULL;
|
|
|
|
wl_list_for_each(surface, &state->ws->layer.surface_list, layer_link) {
|
|
|
|
if (surface == state->keyboard_focus)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
next = surface;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (next) {
|
|
|
|
shell = state->seat->compositor->shell_interface.shell;
|
|
|
|
activate(shell, next, state->seat);
|
|
|
|
} else {
|
|
|
|
wl_list_remove(&state->link);
|
|
|
|
focus_state_destroy(state);
|
|
|
|
}
|
2012-06-13 02:01:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct focus_state *
|
2012-08-01 00:36:34 +04:00
|
|
|
focus_state_create(struct weston_seat *seat, struct workspace *ws)
|
2012-06-13 02:01:24 +04:00
|
|
|
{
|
|
|
|
struct focus_state *state;
|
|
|
|
|
|
|
|
state = malloc(sizeof *state);
|
|
|
|
if (state == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
2012-08-01 00:36:34 +04:00
|
|
|
state->ws = ws;
|
2012-06-13 02:01:24 +04:00
|
|
|
state->seat = seat;
|
2012-08-01 00:36:34 +04:00
|
|
|
wl_list_insert(&ws->focus_list, &state->link);
|
2012-06-13 02:01:24 +04:00
|
|
|
|
|
|
|
state->seat_destroy_listener.notify = focus_state_seat_destroy;
|
|
|
|
state->surface_destroy_listener.notify = focus_state_surface_destroy;
|
|
|
|
wl_signal_add(&seat->seat.destroy_signal,
|
|
|
|
&state->seat_destroy_listener);
|
2012-08-01 00:36:34 +04:00
|
|
|
wl_list_init(&state->surface_destroy_listener.link);
|
2012-06-13 02:01:24 +04:00
|
|
|
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2012-08-30 00:13:03 +04:00
|
|
|
static struct focus_state *
|
|
|
|
ensure_focus_state(struct desktop_shell *shell, struct weston_seat *seat)
|
|
|
|
{
|
|
|
|
struct workspace *ws = get_current_workspace(shell);
|
|
|
|
struct focus_state *state;
|
|
|
|
|
|
|
|
wl_list_for_each(state, &ws->focus_list, link)
|
|
|
|
if (state->seat == seat)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (&state->link == &ws->focus_list)
|
|
|
|
state = focus_state_create(seat, ws);
|
|
|
|
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2012-06-13 02:01:24 +04:00
|
|
|
static void
|
2012-08-01 00:36:34 +04:00
|
|
|
restore_focus_state(struct desktop_shell *shell, struct workspace *ws)
|
2012-06-13 02:01:24 +04:00
|
|
|
{
|
|
|
|
struct focus_state *state, *next;
|
2012-08-30 00:12:59 +04:00
|
|
|
struct wl_surface *surface;
|
2012-06-13 02:01:24 +04:00
|
|
|
|
|
|
|
wl_list_for_each_safe(state, next, &ws->focus_list, link) {
|
2012-08-30 00:12:59 +04:00
|
|
|
surface = state->keyboard_focus ?
|
|
|
|
&state->keyboard_focus->surface : NULL;
|
|
|
|
|
|
|
|
wl_keyboard_set_focus(state->seat->seat.keyboard, surface);
|
2012-06-13 02:01:24 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-30 00:13:00 +04:00
|
|
|
static void
|
|
|
|
replace_focus_state(struct desktop_shell *shell, struct workspace *ws,
|
|
|
|
struct weston_seat *seat)
|
|
|
|
{
|
|
|
|
struct focus_state *state;
|
|
|
|
struct wl_surface *surface;
|
|
|
|
|
|
|
|
wl_list_for_each(state, &ws->focus_list, link) {
|
|
|
|
if (state->seat == seat) {
|
|
|
|
surface = seat->seat.keyboard->focus;
|
|
|
|
state->keyboard_focus =
|
|
|
|
(struct weston_surface *) surface;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
drop_focus_state(struct desktop_shell *shell, struct workspace *ws,
|
|
|
|
struct weston_surface *surface)
|
|
|
|
{
|
|
|
|
struct focus_state *state;
|
|
|
|
|
|
|
|
wl_list_for_each(state, &ws->focus_list, link)
|
|
|
|
if (state->keyboard_focus == surface)
|
|
|
|
state->keyboard_focus = NULL;
|
|
|
|
}
|
|
|
|
|
2012-06-13 02:01:22 +04:00
|
|
|
static void
|
|
|
|
workspace_destroy(struct workspace *ws)
|
|
|
|
{
|
2012-06-13 02:01:24 +04:00
|
|
|
struct focus_state *state, *next;
|
|
|
|
|
|
|
|
wl_list_for_each_safe(state, next, &ws->focus_list, link)
|
|
|
|
focus_state_destroy(state);
|
|
|
|
|
2012-06-13 02:01:22 +04:00
|
|
|
free(ws);
|
|
|
|
}
|
|
|
|
|
2012-06-13 02:01:24 +04:00
|
|
|
static void
|
|
|
|
seat_destroyed(struct wl_listener *listener, void *data)
|
|
|
|
{
|
|
|
|
struct weston_seat *seat = data;
|
|
|
|
struct focus_state *state, *next;
|
|
|
|
struct workspace *ws = container_of(listener,
|
|
|
|
struct workspace,
|
|
|
|
seat_destroyed_listener);
|
|
|
|
|
|
|
|
wl_list_for_each_safe(state, next, &ws->focus_list, link)
|
|
|
|
if (state->seat == seat)
|
|
|
|
wl_list_remove(&state->link);
|
|
|
|
}
|
|
|
|
|
2012-06-13 02:01:22 +04:00
|
|
|
static struct workspace *
|
|
|
|
workspace_create(void)
|
|
|
|
{
|
|
|
|
struct workspace *ws = malloc(sizeof *ws);
|
|
|
|
if (ws == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
weston_layer_init(&ws->layer, NULL);
|
|
|
|
|
2012-06-13 02:01:24 +04:00
|
|
|
wl_list_init(&ws->focus_list);
|
|
|
|
wl_list_init(&ws->seat_destroyed_listener.link);
|
|
|
|
ws->seat_destroyed_listener.notify = seat_destroyed;
|
|
|
|
|
2012-06-13 02:01:22 +04:00
|
|
|
return ws;
|
|
|
|
}
|
|
|
|
|
2012-06-13 02:01:23 +04:00
|
|
|
static int
|
|
|
|
workspace_is_empty(struct workspace *ws)
|
|
|
|
{
|
|
|
|
return wl_list_empty(&ws->layer.surface_list);
|
|
|
|
}
|
|
|
|
|
2012-06-13 02:01:22 +04:00
|
|
|
static struct workspace *
|
|
|
|
get_workspace(struct desktop_shell *shell, unsigned int index)
|
|
|
|
{
|
|
|
|
struct workspace **pws = shell->workspaces.array.data;
|
2012-09-01 18:03:05 +04:00
|
|
|
assert(index < shell->workspaces.num);
|
2012-06-13 02:01:22 +04:00
|
|
|
pws += index;
|
|
|
|
return *pws;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct workspace *
|
|
|
|
get_current_workspace(struct desktop_shell *shell)
|
|
|
|
{
|
|
|
|
return get_workspace(shell, shell->workspaces.current);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
activate_workspace(struct desktop_shell *shell, unsigned int index)
|
|
|
|
{
|
|
|
|
struct workspace *ws;
|
|
|
|
|
|
|
|
ws = get_workspace(shell, index);
|
|
|
|
wl_list_insert(&shell->panel_layer.link, &ws->layer.link);
|
|
|
|
|
|
|
|
shell->workspaces.current = index;
|
|
|
|
}
|
|
|
|
|
2012-06-13 02:01:23 +04:00
|
|
|
static unsigned int
|
|
|
|
get_output_height(struct weston_output *output)
|
|
|
|
{
|
|
|
|
return abs(output->region.extents.y1 - output->region.extents.y2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
surface_translate(struct weston_surface *surface, double d)
|
|
|
|
{
|
|
|
|
struct shell_surface *shsurf = get_shell_surface(surface);
|
|
|
|
struct weston_transform *transform;
|
|
|
|
|
|
|
|
transform = &shsurf->workspace_transform;
|
|
|
|
if (wl_list_empty(&transform->link))
|
|
|
|
wl_list_insert(surface->geometry.transformation_list.prev,
|
|
|
|
&shsurf->workspace_transform.link);
|
|
|
|
|
|
|
|
weston_matrix_init(&shsurf->workspace_transform.matrix);
|
|
|
|
weston_matrix_translate(&shsurf->workspace_transform.matrix,
|
|
|
|
0.0, d, 0.0);
|
|
|
|
surface->geometry.dirty = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
workspace_translate_out(struct workspace *ws, double fraction)
|
|
|
|
{
|
|
|
|
struct weston_surface *surface;
|
|
|
|
unsigned int height;
|
|
|
|
double d;
|
|
|
|
|
|
|
|
wl_list_for_each(surface, &ws->layer.surface_list, layer_link) {
|
|
|
|
height = get_output_height(surface->output);
|
|
|
|
d = height * fraction;
|
|
|
|
|
|
|
|
surface_translate(surface, d);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
workspace_translate_in(struct workspace *ws, double fraction)
|
|
|
|
{
|
|
|
|
struct weston_surface *surface;
|
|
|
|
unsigned int height;
|
|
|
|
double d;
|
|
|
|
|
|
|
|
wl_list_for_each(surface, &ws->layer.surface_list, layer_link) {
|
|
|
|
height = get_output_height(surface->output);
|
|
|
|
|
|
|
|
if (fraction > 0)
|
|
|
|
d = -(height - height * fraction);
|
|
|
|
else
|
|
|
|
d = height + height * fraction;
|
|
|
|
|
|
|
|
surface_translate(surface, d);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-30 00:13:01 +04:00
|
|
|
static void
|
|
|
|
broadcast_current_workspace_state(struct desktop_shell *shell)
|
|
|
|
{
|
|
|
|
struct wl_resource *resource;
|
|
|
|
|
|
|
|
wl_list_for_each(resource, &shell->workspaces.client_list, link)
|
|
|
|
workspace_manager_send_state(resource,
|
|
|
|
shell->workspaces.current,
|
|
|
|
shell->workspaces.num);
|
|
|
|
}
|
|
|
|
|
2012-06-13 02:01:23 +04:00
|
|
|
static void
|
|
|
|
reverse_workspace_change_animation(struct desktop_shell *shell,
|
|
|
|
unsigned int index,
|
|
|
|
struct workspace *from,
|
|
|
|
struct workspace *to)
|
|
|
|
{
|
|
|
|
shell->workspaces.current = index;
|
|
|
|
|
|
|
|
shell->workspaces.anim_to = to;
|
|
|
|
shell->workspaces.anim_from = from;
|
|
|
|
shell->workspaces.anim_dir = -1 * shell->workspaces.anim_dir;
|
|
|
|
shell->workspaces.anim_timestamp = 0;
|
|
|
|
|
2012-08-13 19:58:41 +04:00
|
|
|
weston_compositor_schedule_repaint(shell->compositor);
|
2012-06-13 02:01:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
workspace_deactivate_transforms(struct workspace *ws)
|
|
|
|
{
|
|
|
|
struct weston_surface *surface;
|
|
|
|
struct shell_surface *shsurf;
|
|
|
|
|
|
|
|
wl_list_for_each(surface, &ws->layer.surface_list, layer_link) {
|
|
|
|
shsurf = get_shell_surface(surface);
|
2012-08-30 00:13:00 +04:00
|
|
|
if (!wl_list_empty(&shsurf->workspace_transform.link)) {
|
|
|
|
wl_list_remove(&shsurf->workspace_transform.link);
|
|
|
|
wl_list_init(&shsurf->workspace_transform.link);
|
|
|
|
}
|
2012-06-13 02:01:23 +04:00
|
|
|
shsurf->surface->geometry.dirty = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
finish_workspace_change_animation(struct desktop_shell *shell,
|
|
|
|
struct workspace *from,
|
|
|
|
struct workspace *to)
|
|
|
|
{
|
2012-08-13 19:58:41 +04:00
|
|
|
weston_compositor_schedule_repaint(shell->compositor);
|
2012-06-13 02:01:23 +04:00
|
|
|
|
|
|
|
wl_list_remove(&shell->workspaces.animation.link);
|
|
|
|
workspace_deactivate_transforms(from);
|
|
|
|
workspace_deactivate_transforms(to);
|
|
|
|
shell->workspaces.anim_to = NULL;
|
|
|
|
|
|
|
|
wl_list_remove(&shell->workspaces.anim_from->layer.link);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
animate_workspace_change_frame(struct weston_animation *animation,
|
|
|
|
struct weston_output *output, uint32_t msecs)
|
|
|
|
{
|
|
|
|
struct desktop_shell *shell =
|
|
|
|
container_of(animation, struct desktop_shell,
|
|
|
|
workspaces.animation);
|
|
|
|
struct workspace *from = shell->workspaces.anim_from;
|
|
|
|
struct workspace *to = shell->workspaces.anim_to;
|
|
|
|
uint32_t t;
|
|
|
|
double x, y;
|
|
|
|
|
|
|
|
if (workspace_is_empty(from) && workspace_is_empty(to)) {
|
|
|
|
finish_workspace_change_animation(shell, from, to);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (shell->workspaces.anim_timestamp == 0) {
|
|
|
|
if (shell->workspaces.anim_current == 0.0)
|
|
|
|
shell->workspaces.anim_timestamp = msecs;
|
|
|
|
else
|
|
|
|
shell->workspaces.anim_timestamp =
|
|
|
|
msecs -
|
|
|
|
/* Invers of movement function 'y' below. */
|
|
|
|
(asin(1.0 - shell->workspaces.anim_current) *
|
|
|
|
DEFAULT_WORKSPACE_CHANGE_ANIMATION_LENGTH *
|
|
|
|
M_2_PI);
|
|
|
|
}
|
|
|
|
|
|
|
|
t = msecs - shell->workspaces.anim_timestamp;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* x = [0, π/2]
|
|
|
|
* y(x) = sin(x)
|
|
|
|
*/
|
|
|
|
x = t * (1.0/DEFAULT_WORKSPACE_CHANGE_ANIMATION_LENGTH) * M_PI_2;
|
|
|
|
y = sin(x);
|
|
|
|
|
|
|
|
if (t < DEFAULT_WORKSPACE_CHANGE_ANIMATION_LENGTH) {
|
2012-08-13 19:58:41 +04:00
|
|
|
weston_compositor_schedule_repaint(shell->compositor);
|
2012-06-13 02:01:23 +04:00
|
|
|
|
|
|
|
workspace_translate_out(from, shell->workspaces.anim_dir * y);
|
|
|
|
workspace_translate_in(to, shell->workspaces.anim_dir * y);
|
|
|
|
shell->workspaces.anim_current = y;
|
|
|
|
|
2012-08-13 19:58:41 +04:00
|
|
|
weston_compositor_schedule_repaint(shell->compositor);
|
2012-06-13 02:01:23 +04:00
|
|
|
}
|
2012-06-13 02:01:24 +04:00
|
|
|
else
|
2012-06-13 02:01:23 +04:00
|
|
|
finish_workspace_change_animation(shell, from, to);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
animate_workspace_change(struct desktop_shell *shell,
|
|
|
|
unsigned int index,
|
|
|
|
struct workspace *from,
|
|
|
|
struct workspace *to)
|
|
|
|
{
|
|
|
|
struct weston_output *output;
|
|
|
|
|
|
|
|
int dir;
|
|
|
|
|
|
|
|
if (index > shell->workspaces.current)
|
|
|
|
dir = -1;
|
|
|
|
else
|
|
|
|
dir = 1;
|
|
|
|
|
|
|
|
shell->workspaces.current = index;
|
|
|
|
|
|
|
|
shell->workspaces.anim_dir = dir;
|
|
|
|
shell->workspaces.anim_from = from;
|
|
|
|
shell->workspaces.anim_to = to;
|
|
|
|
shell->workspaces.anim_current = 0.0;
|
|
|
|
shell->workspaces.anim_timestamp = 0;
|
|
|
|
|
|
|
|
output = container_of(shell->compositor->output_list.next,
|
|
|
|
struct weston_output, link);
|
|
|
|
wl_list_insert(&output->animation_list,
|
|
|
|
&shell->workspaces.animation.link);
|
|
|
|
|
2012-08-30 00:13:00 +04:00
|
|
|
wl_list_insert(from->layer.link.prev, &to->layer.link);
|
2012-06-13 02:01:23 +04:00
|
|
|
|
|
|
|
workspace_translate_in(to, 0);
|
|
|
|
|
2012-08-01 00:36:34 +04:00
|
|
|
restore_focus_state(shell, to);
|
2012-06-13 02:01:24 +04:00
|
|
|
|
2012-08-13 19:58:41 +04:00
|
|
|
weston_compositor_schedule_repaint(shell->compositor);
|
2012-06-13 02:01:23 +04:00
|
|
|
}
|
|
|
|
|
2012-08-30 00:13:00 +04:00
|
|
|
static void
|
|
|
|
update_workspace(struct desktop_shell *shell, unsigned int index,
|
|
|
|
struct workspace *from, struct workspace *to)
|
|
|
|
{
|
|
|
|
shell->workspaces.current = index;
|
|
|
|
wl_list_insert(&from->layer.link, &to->layer.link);
|
|
|
|
wl_list_remove(&from->layer.link);
|
|
|
|
}
|
|
|
|
|
2012-06-13 02:01:22 +04:00
|
|
|
static void
|
|
|
|
change_workspace(struct desktop_shell *shell, unsigned int index)
|
|
|
|
{
|
|
|
|
struct workspace *from;
|
|
|
|
struct workspace *to;
|
|
|
|
|
|
|
|
if (index == shell->workspaces.current)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Don't change workspace when there is any fullscreen surfaces. */
|
|
|
|
if (!wl_list_empty(&shell->fullscreen_layer.surface_list))
|
|
|
|
return;
|
|
|
|
|
|
|
|
from = get_current_workspace(shell);
|
|
|
|
to = get_workspace(shell, index);
|
|
|
|
|
2012-06-13 02:01:23 +04:00
|
|
|
if (shell->workspaces.anim_from == to &&
|
|
|
|
shell->workspaces.anim_to == from) {
|
2012-08-30 00:13:00 +04:00
|
|
|
restore_focus_state(shell, to);
|
2012-06-13 02:01:23 +04:00
|
|
|
reverse_workspace_change_animation(shell, index, from, to);
|
2012-08-30 00:13:01 +04:00
|
|
|
broadcast_current_workspace_state(shell);
|
2012-06-13 02:01:23 +04:00
|
|
|
return;
|
|
|
|
}
|
2012-06-13 02:01:22 +04:00
|
|
|
|
2012-06-13 02:01:23 +04:00
|
|
|
if (shell->workspaces.anim_to != NULL)
|
|
|
|
finish_workspace_change_animation(shell,
|
|
|
|
shell->workspaces.anim_from,
|
|
|
|
shell->workspaces.anim_to);
|
|
|
|
|
2012-08-30 00:13:00 +04:00
|
|
|
restore_focus_state(shell, to);
|
2012-06-13 02:01:24 +04:00
|
|
|
|
2012-08-30 00:13:00 +04:00
|
|
|
if (workspace_is_empty(to) && workspace_is_empty(from))
|
|
|
|
update_workspace(shell, index, from, to);
|
2012-06-13 02:01:23 +04:00
|
|
|
else
|
|
|
|
animate_workspace_change(shell, index, from, to);
|
2012-08-30 00:13:01 +04:00
|
|
|
|
|
|
|
broadcast_current_workspace_state(shell);
|
2011-12-07 13:49:52 +04:00
|
|
|
}
|
|
|
|
|
2012-08-30 00:13:00 +04:00
|
|
|
static bool
|
|
|
|
workspace_has_only(struct workspace *ws, struct weston_surface *surface)
|
|
|
|
{
|
|
|
|
struct wl_list *list = &ws->layer.surface_list;
|
|
|
|
struct wl_list *e;
|
|
|
|
|
|
|
|
if (wl_list_empty(list))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
e = list->next;
|
|
|
|
|
|
|
|
if (e->next != list)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return container_of(e, struct weston_surface, layer_link) == surface;
|
|
|
|
}
|
|
|
|
|
2012-08-30 00:13:01 +04:00
|
|
|
static void
|
|
|
|
move_surface_to_workspace(struct desktop_shell *shell,
|
|
|
|
struct weston_surface *surface,
|
|
|
|
uint32_t workspace)
|
|
|
|
{
|
|
|
|
struct workspace *from;
|
|
|
|
struct workspace *to;
|
|
|
|
struct weston_seat *seat;
|
|
|
|
|
|
|
|
if (workspace == shell->workspaces.current)
|
|
|
|
return;
|
|
|
|
|
2012-09-01 18:03:05 +04:00
|
|
|
if (workspace >= shell->workspaces.num)
|
|
|
|
workspace = shell->workspaces.num - 1;
|
|
|
|
|
2012-08-30 00:13:01 +04:00
|
|
|
from = get_current_workspace(shell);
|
|
|
|
to = get_workspace(shell, workspace);
|
|
|
|
|
|
|
|
wl_list_remove(&surface->layer_link);
|
|
|
|
wl_list_insert(&to->layer.surface_list, &surface->layer_link);
|
|
|
|
|
|
|
|
drop_focus_state(shell, from, surface);
|
|
|
|
wl_list_for_each(seat, &shell->compositor->seat_list, link)
|
|
|
|
if (seat->has_keyboard &&
|
|
|
|
seat->keyboard.focus == &surface->surface)
|
|
|
|
wl_keyboard_set_focus(&seat->keyboard, NULL);
|
|
|
|
|
|
|
|
weston_surface_damage_below(surface);
|
|
|
|
}
|
|
|
|
|
2012-08-30 00:13:00 +04:00
|
|
|
static void
|
|
|
|
take_surface_to_workspace_by_seat(struct desktop_shell *shell,
|
2012-08-30 00:13:01 +04:00
|
|
|
struct wl_seat *wl_seat,
|
2012-08-30 00:13:00 +04:00
|
|
|
unsigned int index)
|
|
|
|
{
|
2012-08-30 00:13:01 +04:00
|
|
|
struct weston_seat *seat = (struct weston_seat *) wl_seat;
|
2012-08-30 00:13:00 +04:00
|
|
|
struct weston_surface *surface =
|
2012-08-30 00:13:01 +04:00
|
|
|
(struct weston_surface *) wl_seat->keyboard->focus;
|
2012-08-30 00:13:00 +04:00
|
|
|
struct shell_surface *shsurf;
|
|
|
|
struct workspace *from;
|
|
|
|
struct workspace *to;
|
2012-08-30 00:13:03 +04:00
|
|
|
struct focus_state *state;
|
2012-08-30 00:13:00 +04:00
|
|
|
|
|
|
|
if (surface == NULL ||
|
|
|
|
index == shell->workspaces.current)
|
|
|
|
return;
|
|
|
|
|
|
|
|
from = get_current_workspace(shell);
|
|
|
|
to = get_workspace(shell, index);
|
|
|
|
|
|
|
|
wl_list_remove(&surface->layer_link);
|
|
|
|
wl_list_insert(&to->layer.surface_list, &surface->layer_link);
|
|
|
|
|
2012-08-30 00:13:01 +04:00
|
|
|
replace_focus_state(shell, to, seat);
|
2012-08-30 00:13:00 +04:00
|
|
|
drop_focus_state(shell, from, surface);
|
|
|
|
|
|
|
|
if (shell->workspaces.anim_from == to &&
|
|
|
|
shell->workspaces.anim_to == from) {
|
2012-08-30 00:13:01 +04:00
|
|
|
wl_list_remove(&to->layer.link);
|
|
|
|
wl_list_insert(from->layer.link.prev, &to->layer.link);
|
|
|
|
|
2012-08-30 00:13:00 +04:00
|
|
|
reverse_workspace_change_animation(shell, index, from, to);
|
2012-08-30 00:13:01 +04:00
|
|
|
broadcast_current_workspace_state(shell);
|
|
|
|
|
2012-08-30 00:13:00 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (shell->workspaces.anim_to != NULL)
|
|
|
|
finish_workspace_change_animation(shell,
|
|
|
|
shell->workspaces.anim_from,
|
|
|
|
shell->workspaces.anim_to);
|
|
|
|
|
|
|
|
if (workspace_is_empty(from) &&
|
|
|
|
workspace_has_only(to, surface))
|
|
|
|
update_workspace(shell, index, from, to);
|
|
|
|
else {
|
|
|
|
shsurf = get_shell_surface(surface);
|
|
|
|
if (wl_list_empty(&shsurf->workspace_transform.link))
|
|
|
|
wl_list_insert(&shell->workspaces.anim_sticky_list,
|
|
|
|
&shsurf->workspace_transform.link);
|
|
|
|
|
|
|
|
animate_workspace_change(shell, index, from, to);
|
|
|
|
}
|
2012-08-30 00:13:01 +04:00
|
|
|
|
|
|
|
broadcast_current_workspace_state(shell);
|
2012-08-30 00:13:03 +04:00
|
|
|
|
|
|
|
state = ensure_focus_state(shell, seat);
|
|
|
|
if (state != NULL)
|
|
|
|
state->keyboard_focus = surface;
|
2012-08-30 00:13:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
workspace_manager_move_surface(struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
struct wl_resource *surface_resource,
|
|
|
|
uint32_t workspace)
|
|
|
|
{
|
|
|
|
struct desktop_shell *shell = resource->data;
|
|
|
|
struct weston_surface *surface =
|
|
|
|
(struct weston_surface *) surface_resource;
|
|
|
|
|
|
|
|
move_surface_to_workspace(shell, surface, workspace);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct workspace_manager_interface workspace_manager_implementation = {
|
|
|
|
workspace_manager_move_surface,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
unbind_resource(struct wl_resource *resource)
|
|
|
|
{
|
|
|
|
wl_list_remove(&resource->link);
|
|
|
|
free(resource);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
bind_workspace_manager(struct wl_client *client,
|
|
|
|
void *data, uint32_t version, uint32_t id)
|
|
|
|
{
|
|
|
|
struct desktop_shell *shell = data;
|
|
|
|
struct wl_resource *resource;
|
|
|
|
|
|
|
|
resource = wl_client_add_object(client, &workspace_manager_interface,
|
|
|
|
&workspace_manager_implementation,
|
|
|
|
id, shell);
|
|
|
|
|
|
|
|
if (resource == NULL) {
|
|
|
|
weston_log("couldn't add workspace manager object");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
resource->destroy = unbind_resource;
|
|
|
|
wl_list_insert(&shell->workspaces.client_list, &resource->link);
|
|
|
|
|
|
|
|
workspace_manager_send_state(resource,
|
|
|
|
shell->workspaces.current,
|
|
|
|
shell->workspaces.num);
|
2012-08-30 00:13:00 +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-05-08 20:17:55 +04:00
|
|
|
struct wl_surface *surface, wl_fixed_t x, wl_fixed_t y)
|
2012-01-05 06:30:29 +04:00
|
|
|
{
|
|
|
|
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-05-08 20:17:55 +04:00
|
|
|
uint32_t time, wl_fixed_t x, wl_fixed_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-05-16 21:45:18 +04:00
|
|
|
struct wl_pointer *pointer = grab->pointer;
|
2012-04-04 18:48:05 +04:00
|
|
|
struct shell_surface *shsurf = move->base.shsurf;
|
|
|
|
struct weston_surface *es;
|
2012-05-16 21:45:18 +04:00
|
|
|
int dx = wl_fixed_to_int(pointer->x + move->dx);
|
|
|
|
int dy = wl_fixed_to_int(pointer->y + move->dy);
|
2012-04-04 18:48:05 +04:00
|
|
|
|
|
|
|
if (!shsurf)
|
|
|
|
return;
|
|
|
|
|
|
|
|
es = shsurf->surface;
|
2011-01-18 15:53:49 +03:00
|
|
|
|
2012-05-08 20:17:55 +04:00
|
|
|
weston_surface_configure(es, dx, dy,
|
2012-01-25 17:55:43 +04:00
|
|
|
es->geometry.width, es->geometry.height);
|
2012-06-21 20:06:22 +04:00
|
|
|
|
|
|
|
weston_compositor_schedule_repaint(es->compositor);
|
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-05-30 19:31:51 +04:00
|
|
|
uint32_t time, uint32_t button, uint32_t state_w)
|
2011-01-18 15:53:49 +03:00
|
|
|
{
|
2012-04-04 18:48:05 +04:00
|
|
|
struct shell_grab *shell_grab = container_of(grab, struct shell_grab,
|
|
|
|
grab);
|
2012-05-16 21:45:18 +04:00
|
|
|
struct wl_pointer *pointer = grab->pointer;
|
2012-05-30 19:31:51 +04:00
|
|
|
enum wl_pointer_button_state state = state_w;
|
2011-01-18 15:53:49 +03:00
|
|
|
|
2012-05-30 19:31:51 +04:00
|
|
|
if (pointer->button_count == 0 &&
|
|
|
|
state == WL_POINTER_BUTTON_STATE_RELEASED) {
|
2012-06-28 19:08:05 +04:00
|
|
|
shell_grab_end(shell_grab);
|
2012-01-05 06:30:29 +04:00
|
|
|
free(grab);
|
|
|
|
}
|
2011-01-18 15:53:49 +03:00
|
|
|
}
|
|
|
|
|
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-08-01 08:08:07 +04:00
|
|
|
static int
|
|
|
|
surface_move(struct shell_surface *shsurf, struct weston_seat *ws)
|
|
|
|
{
|
|
|
|
struct weston_move_grab *move;
|
|
|
|
|
|
|
|
if (!shsurf)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (shsurf->type == SHELL_SURFACE_FULLSCREEN)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
move = malloc(sizeof *move);
|
|
|
|
if (!move)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
move->dx = wl_fixed_from_double(shsurf->surface->geometry.x) -
|
|
|
|
ws->seat.pointer->grab_x;
|
|
|
|
move->dy = wl_fixed_from_double(shsurf->surface->geometry.y) -
|
|
|
|
ws->seat.pointer->grab_y;
|
|
|
|
|
|
|
|
shell_grab_start(&move->base, &move_grab_interface, shsurf,
|
|
|
|
ws->seat.pointer, DESKTOP_SHELL_CURSOR_MOVE);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
shell_surface_move(struct wl_client *client, struct wl_resource *resource,
|
|
|
|
struct wl_resource *seat_resource, uint32_t serial)
|
|
|
|
{
|
|
|
|
struct weston_seat *ws = seat_resource->data;
|
|
|
|
struct shell_surface *shsurf = resource->data;
|
|
|
|
|
|
|
|
if (ws->seat.pointer->button_count == 0 ||
|
|
|
|
ws->seat.pointer->grab_serial != serial ||
|
|
|
|
ws->seat.pointer->focus != &shsurf->surface->surface)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (surface_move(shsurf, ws) < 0)
|
|
|
|
wl_resource_post_no_memory(resource);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct weston_resize_grab {
|
|
|
|
struct shell_grab base;
|
|
|
|
uint32_t edges;
|
|
|
|
int32_t width, height;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
resize_grab_motion(struct wl_pointer_grab *grab,
|
|
|
|
uint32_t time, wl_fixed_t x, wl_fixed_t y)
|
|
|
|
{
|
|
|
|
struct weston_resize_grab *resize = (struct weston_resize_grab *) grab;
|
|
|
|
struct wl_pointer *pointer = grab->pointer;
|
|
|
|
struct shell_surface *shsurf = resize->base.shsurf;
|
|
|
|
int32_t width, height;
|
|
|
|
wl_fixed_t from_x, from_y;
|
|
|
|
wl_fixed_t to_x, to_y;
|
|
|
|
|
|
|
|
if (!shsurf)
|
|
|
|
return;
|
|
|
|
|
|
|
|
weston_surface_from_global_fixed(shsurf->surface,
|
|
|
|
pointer->grab_x, pointer->grab_y,
|
|
|
|
&from_x, &from_y);
|
|
|
|
weston_surface_from_global_fixed(shsurf->surface,
|
|
|
|
pointer->x, pointer->y, &to_x, &to_y);
|
|
|
|
|
|
|
|
width = resize->width;
|
|
|
|
if (resize->edges & WL_SHELL_SURFACE_RESIZE_LEFT) {
|
|
|
|
width += wl_fixed_to_int(from_x - to_x);
|
|
|
|
} else if (resize->edges & WL_SHELL_SURFACE_RESIZE_RIGHT) {
|
|
|
|
width += wl_fixed_to_int(to_x - from_x);
|
|
|
|
}
|
|
|
|
|
|
|
|
height = resize->height;
|
|
|
|
if (resize->edges & WL_SHELL_SURFACE_RESIZE_TOP) {
|
|
|
|
height += wl_fixed_to_int(from_y - to_y);
|
|
|
|
} else if (resize->edges & WL_SHELL_SURFACE_RESIZE_BOTTOM) {
|
|
|
|
height += wl_fixed_to_int(to_y - from_y);
|
|
|
|
}
|
|
|
|
|
|
|
|
shsurf->client->send_configure(shsurf->surface,
|
|
|
|
resize->edges, width, height);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
send_configure(struct weston_surface *surface,
|
|
|
|
uint32_t edges, int32_t width, int32_t height)
|
|
|
|
{
|
|
|
|
struct shell_surface *shsurf = get_shell_surface(surface);
|
|
|
|
|
|
|
|
wl_shell_surface_send_configure(&shsurf->resource,
|
|
|
|
edges, width, height);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct weston_shell_client shell_client = {
|
|
|
|
send_configure
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
resize_grab_button(struct wl_pointer_grab *grab,
|
|
|
|
uint32_t time, uint32_t button, uint32_t state_w)
|
|
|
|
{
|
|
|
|
struct weston_resize_grab *resize = (struct weston_resize_grab *) grab;
|
|
|
|
struct wl_pointer *pointer = grab->pointer;
|
|
|
|
enum wl_pointer_button_state state = state_w;
|
|
|
|
|
|
|
|
if (pointer->button_count == 0 &&
|
|
|
|
state == WL_POINTER_BUTTON_STATE_RELEASED) {
|
|
|
|
shell_grab_end(&resize->base);
|
|
|
|
free(grab);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct wl_pointer_grab_interface resize_grab_interface = {
|
|
|
|
noop_grab_focus,
|
|
|
|
resize_grab_motion,
|
|
|
|
resize_grab_button,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
surface_resize(struct shell_surface *shsurf,
|
|
|
|
struct weston_seat *ws, uint32_t edges)
|
|
|
|
{
|
|
|
|
struct weston_resize_grab *resize;
|
|
|
|
|
|
|
|
if (shsurf->type == SHELL_SURFACE_FULLSCREEN)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (edges == 0 || edges > 15 ||
|
|
|
|
(edges & 3) == 3 || (edges & 12) == 12)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
resize = malloc(sizeof *resize);
|
|
|
|
if (!resize)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
resize->edges = edges;
|
|
|
|
resize->width = shsurf->surface->geometry.width;
|
|
|
|
resize->height = shsurf->surface->geometry.height;
|
|
|
|
|
|
|
|
shell_grab_start(&resize->base, &resize_grab_interface, shsurf,
|
|
|
|
ws->seat.pointer, edges);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
shell_surface_resize(struct wl_client *client, struct wl_resource *resource,
|
|
|
|
struct wl_resource *seat_resource, uint32_t serial,
|
|
|
|
uint32_t edges)
|
|
|
|
{
|
|
|
|
struct weston_seat *ws = seat_resource->data;
|
|
|
|
struct shell_surface *shsurf = resource->data;
|
|
|
|
|
|
|
|
if (shsurf->type == SHELL_SURFACE_FULLSCREEN)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (ws->seat.pointer->button_count == 0 ||
|
|
|
|
ws->seat.pointer->grab_serial != serial ||
|
|
|
|
ws->seat.pointer->focus != &shsurf->surface->surface)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (surface_resize(shsurf, ws, edges) < 0)
|
|
|
|
wl_resource_post_no_memory(resource);
|
|
|
|
}
|
|
|
|
|
2012-04-18 05:06:20 +04:00
|
|
|
static void
|
2012-06-05 17:58:51 +04:00
|
|
|
busy_cursor_grab_focus(struct wl_pointer_grab *base,
|
|
|
|
struct wl_surface *surface, int32_t x, int32_t y)
|
2012-04-18 05:06:20 +04:00
|
|
|
{
|
2012-06-05 17:58:51 +04:00
|
|
|
struct shell_grab *grab = (struct shell_grab *) base;
|
2012-04-18 05:06:20 +04:00
|
|
|
|
2012-06-05 17:58:51 +04:00
|
|
|
if (grab->grab.focus != surface) {
|
2012-06-28 19:08:05 +04:00
|
|
|
shell_grab_end(grab);
|
2012-06-05 17:58:51 +04:00
|
|
|
free(grab);
|
2012-04-18 05:06:20 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-05 17:58:51 +04:00
|
|
|
busy_cursor_grab_motion(struct wl_pointer_grab *grab,
|
|
|
|
uint32_t time, int32_t x, int32_t y)
|
2012-04-18 05:06:20 +04:00
|
|
|
{
|
2012-06-05 17:58:51 +04:00
|
|
|
}
|
2012-04-18 05:06:20 +04:00
|
|
|
|
2012-06-05 17:58:51 +04:00
|
|
|
static void
|
2012-08-01 08:20:21 +04:00
|
|
|
busy_cursor_grab_button(struct wl_pointer_grab *base,
|
2012-06-05 17:58:51 +04:00
|
|
|
uint32_t time, uint32_t button, uint32_t state)
|
|
|
|
{
|
2012-08-01 08:20:21 +04:00
|
|
|
struct shell_grab *grab = (struct shell_grab *) base;
|
|
|
|
struct shell_surface *shsurf;
|
|
|
|
struct weston_surface *surface =
|
|
|
|
(struct weston_surface *) grab->grab.pointer->current;
|
|
|
|
struct weston_seat *seat =
|
|
|
|
(struct weston_seat *) grab->grab.pointer->seat;
|
|
|
|
|
|
|
|
shsurf = get_shell_surface(surface);
|
|
|
|
if (shsurf && button == BTN_LEFT && state) {
|
|
|
|
activate(shsurf->shell, shsurf->surface, seat);
|
|
|
|
surface_move(shsurf, seat);
|
|
|
|
}
|
2012-06-05 17:58:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct wl_pointer_grab_interface busy_cursor_grab_interface = {
|
|
|
|
busy_cursor_grab_focus,
|
|
|
|
busy_cursor_grab_motion,
|
|
|
|
busy_cursor_grab_button,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
set_busy_cursor(struct shell_surface *shsurf, struct wl_pointer *pointer)
|
|
|
|
{
|
|
|
|
struct shell_grab *grab;
|
|
|
|
|
|
|
|
grab = malloc(sizeof *grab);
|
|
|
|
if (!grab)
|
2012-04-18 05:06:20 +04:00
|
|
|
return;
|
|
|
|
|
2012-06-28 19:08:05 +04:00
|
|
|
shell_grab_start(grab, &busy_cursor_grab_interface, shsurf, pointer,
|
|
|
|
DESKTOP_SHELL_CURSOR_BUSY);
|
2012-06-05 17:58:51 +04:00
|
|
|
}
|
2012-04-18 05:06:20 +04:00
|
|
|
|
2012-06-05 17:58:51 +04:00
|
|
|
static void
|
|
|
|
end_busy_cursor(struct shell_surface *shsurf, struct wl_pointer *pointer)
|
|
|
|
{
|
|
|
|
struct shell_grab *grab = (struct shell_grab *) pointer->grab;
|
2012-04-18 05:06:20 +04:00
|
|
|
|
2012-06-05 17:58:51 +04:00
|
|
|
if (grab->grab.interface == &busy_cursor_grab_interface) {
|
2012-06-28 19:08:05 +04:00
|
|
|
shell_grab_end(grab);
|
2012-06-05 17:58:51 +04:00
|
|
|
free(grab);
|
2012-04-18 05:06:20 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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-06-05 17:58:51 +04:00
|
|
|
struct weston_seat *seat;
|
2012-04-18 05:06:18 +04:00
|
|
|
|
2012-04-19 23:06:17 +04:00
|
|
|
/* Client is not responding */
|
|
|
|
shsurf->unresponsive = 1;
|
2012-06-05 17:58:51 +04:00
|
|
|
|
|
|
|
wl_list_for_each(seat, &shsurf->surface->compositor->seat_list, link)
|
|
|
|
if (seat->seat.pointer->focus == &shsurf->surface->surface)
|
|
|
|
set_busy_cursor(shsurf, seat->seat.pointer);
|
2012-04-18 05:06:18 +04:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ping_handler(struct weston_surface *surface, uint32_t serial)
|
|
|
|
{
|
2012-05-10 20:28:35 +04:00
|
|
|
struct shell_surface *shsurf = get_shell_surface(surface);
|
2012-04-18 05:06:18 +04:00
|
|
|
struct wl_event_loop *loop;
|
2012-06-05 17:58:51 +04:00
|
|
|
int ping_timeout = 200;
|
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
|
|
|
|
2012-07-16 15:15:48 +04:00
|
|
|
if (shsurf->surface == shsurf->shell->grab_surface)
|
|
|
|
return;
|
|
|
|
|
2012-04-18 05:06:18 +04:00
|
|
|
if (!shsurf->ping_timer) {
|
2012-04-27 14:55:55 +04:00
|
|
|
shsurf->ping_timer = malloc(sizeof *shsurf->ping_timer);
|
2012-04-18 05:06:18 +04:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-05 17:58:51 +04:00
|
|
|
static void
|
|
|
|
handle_pointer_focus(struct wl_listener *listener, void *data)
|
|
|
|
{
|
|
|
|
struct wl_pointer *pointer = data;
|
|
|
|
struct weston_surface *surface =
|
|
|
|
(struct weston_surface *) pointer->focus;
|
|
|
|
struct weston_compositor *compositor;
|
|
|
|
struct shell_surface *shsurf;
|
|
|
|
uint32_t serial;
|
|
|
|
|
|
|
|
if (!surface)
|
|
|
|
return;
|
|
|
|
|
|
|
|
compositor = surface->compositor;
|
|
|
|
shsurf = get_shell_surface(surface);
|
|
|
|
|
shell: fix a crash during 'make check'
$ abs_builddir=$PWD/tests gdb -args ./src/weston --module=$PWD/tests/.libs/event-test.so
(gdb) run
Starting program: /home/pq/git/wayland-demos/src/weston --module=/home/pq/git/wayland-demos/tests/.libs/event-test.so
[Thread debugging using libthread_db enabled]
Mesa: Initializing x86-64 optimizations
launching /home/pq/git/wayland-demos/tests/test-client
created output global 0x608f50
test-client: got create-surface
got surface 5 from client
got surface id 5
Program received signal SIGSEGV, Segmentation fault.
Mesa: Initializing x86-64 optimizations
0x00007fffeff72c7c in handle_pointer_focus (listener=0x74f5c0, data=0x6faa40) at shell.c:492
492 if (shsurf->unresponsive) {
(gdb) bt
#0 0x00007fffeff72c7c in handle_pointer_focus (listener=0x74f5c0, data=0x6faa40) at shell.c:492
#1 0x00007ffff5ed8b87 in wl_signal_emit (data=0x6faa40, signal=0x6faa88) at wayland-server.h:166
#2 wl_pointer_set_focus (pointer=0x6faa40, surface=<optimized out>, sx=12800, sy=12800) at wayland-server.c:752
#3 0x0000000000407d92 in weston_device_repick (seat=0x6fa930) at compositor.c:633
#4 0x0000000000407e49 in weston_compositor_repick (compositor=0x61c510) at compositor.c:656
#5 0x00000000004092e1 in weston_output_repaint (output=0x7b85b0, msecs=-1046834186) at compositor.c:1059
#6 0x00000000004094b4 in weston_output_finish_frame (output=0x7b85b0, msecs=-1046834186) at compositor.c:1092
#7 0x00007ffff211e3c1 in finish_frame_handler (data=0x7b85b0) at compositor-x11.c:284
#8 0x00007ffff5eda603 in wl_event_source_timer_dispatch (source=0x79ee50, ep=<optimized out>) at event-loop.c:173
#9 0x00007ffff5edaca0 in wl_event_loop_dispatch (loop=0x61b940, timeout=<optimized out>) at event-loop.c:410
#10 0x00007ffff5ed8dbd in wl_display_run (display=0x61b8f0) at wayland-server.c:1025
#11 0x000000000040ecb1 in main (argc=1, argv=0x7fffffffdd98) at compositor.c:3225
(gdb) print shsurf
$1 = (struct shell_surface *) 0x0
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-06-06 17:59:45 +04:00
|
|
|
if (shsurf && shsurf->unresponsive) {
|
2012-06-05 17:58:51 +04:00
|
|
|
set_busy_cursor(shsurf, pointer);
|
|
|
|
} else {
|
|
|
|
serial = wl_display_next_serial(compositor->wl_display);
|
|
|
|
ping_handler(surface, serial);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-10 18:05:39 +04:00
|
|
|
static void
|
|
|
|
create_pointer_focus_listener(struct weston_seat *seat)
|
|
|
|
{
|
|
|
|
struct wl_listener *listener;
|
|
|
|
|
|
|
|
if (!seat->seat.pointer)
|
|
|
|
return;
|
|
|
|
|
|
|
|
listener = malloc(sizeof *listener);
|
|
|
|
listener->notify = handle_pointer_focus;
|
|
|
|
wl_signal_add(&seat->seat.pointer->focus_signal, listener);
|
|
|
|
}
|
|
|
|
|
2012-04-18 05:06:18 +04:00
|
|
|
static void
|
|
|
|
shell_surface_pong(struct wl_client *client, struct wl_resource *resource,
|
|
|
|
uint32_t serial)
|
|
|
|
{
|
|
|
|
struct shell_surface *shsurf = resource->data;
|
2012-06-05 17:58:51 +04:00
|
|
|
struct desktop_shell *shell = shsurf->shell;
|
|
|
|
struct weston_seat *seat;
|
|
|
|
struct weston_compositor *ec = shsurf->surface->compositor;
|
|
|
|
struct wl_pointer *pointer;
|
|
|
|
int was_unresponsive;
|
2012-04-18 05:06:18 +04:00
|
|
|
|
2012-08-12 06:39:12 +04:00
|
|
|
if (shsurf->ping_timer == NULL)
|
|
|
|
/* Just ignore unsolicited pong. */
|
|
|
|
return;
|
|
|
|
|
2012-04-18 05:06:18 +04:00
|
|
|
if (shsurf->ping_timer->serial == serial) {
|
2012-06-05 17:58:51 +04:00
|
|
|
was_unresponsive = shsurf->unresponsive;
|
|
|
|
shsurf->unresponsive = 0;
|
|
|
|
if (was_unresponsive) {
|
2012-04-18 05:06:20 +04:00
|
|
|
/* Received pong from previously unresponsive client */
|
2012-06-05 17:58:51 +04:00
|
|
|
wl_list_for_each(seat, &ec->seat_list, link) {
|
|
|
|
pointer = seat->seat.pointer;
|
|
|
|
if (pointer->focus ==
|
2012-06-28 19:08:05 +04:00
|
|
|
&shell->grab_surface->surface &&
|
2012-06-05 17:58:51 +04:00
|
|
|
pointer->current ==
|
|
|
|
&shsurf->surface->surface)
|
|
|
|
end_busy_cursor(shsurf, pointer);
|
|
|
|
}
|
2012-04-18 05:06:20 +04:00
|
|
|
}
|
2012-04-19 23:06:17 +04:00
|
|
|
ping_timer_destroy(shsurf);
|
2012-04-18 05:06:18 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-02 17:47:44 +04:00
|
|
|
static void
|
|
|
|
shell_surface_set_title(struct wl_client *client,
|
|
|
|
struct wl_resource *resource, const char *title)
|
|
|
|
{
|
|
|
|
struct shell_surface *shsurf = resource->data;
|
|
|
|
|
|
|
|
free(shsurf->title);
|
|
|
|
shsurf->title = strdup(title);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
shell_surface_set_class(struct wl_client *client,
|
|
|
|
struct wl_resource *resource, const char *class)
|
|
|
|
{
|
|
|
|
struct shell_surface *shsurf = resource->data;
|
|
|
|
|
|
|
|
free(shsurf->class);
|
|
|
|
shsurf->class = strdup(class);
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
weston_surface_set_position(shsurf->surface,
|
|
|
|
shsurf->saved_x, shsurf->saved_y);
|
2012-04-27 05:07:24 +04:00
|
|
|
if (shsurf->saved_rotation_valid) {
|
|
|
|
wl_list_insert(&shsurf->surface->geometry.transformation_list,
|
|
|
|
&shsurf->rotation.transform.link);
|
|
|
|
shsurf->saved_rotation_valid = false;
|
|
|
|
}
|
2012-03-01 08:57:46 +04:00
|
|
|
}
|
|
|
|
|
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_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
|
2012-04-28 01:20:01 +04:00
|
|
|
set_surface_type(struct shell_surface *shsurf)
|
2012-04-19 17:18:18 +04:00
|
|
|
{
|
2012-04-28 01:20:01 +04:00
|
|
|
struct weston_surface *surface = shsurf->surface;
|
2012-06-27 18:22:58 +04:00
|
|
|
struct weston_surface *pes = shsurf->parent;
|
2012-04-28 01:20:01 +04:00
|
|
|
|
|
|
|
reset_shell_surface_type(shsurf);
|
|
|
|
|
|
|
|
shsurf->type = shsurf->next_type;
|
|
|
|
shsurf->next_type = SHELL_SURFACE_NONE;
|
2012-04-19 17:18:18 +04:00
|
|
|
|
2012-04-28 01:20:01 +04:00
|
|
|
switch (shsurf->type) {
|
|
|
|
case SHELL_SURFACE_TOPLEVEL:
|
|
|
|
break;
|
|
|
|
case SHELL_SURFACE_TRANSIENT:
|
|
|
|
weston_surface_set_position(surface,
|
2012-05-07 16:23:08 +04:00
|
|
|
pes->geometry.x + shsurf->transient.x,
|
|
|
|
pes->geometry.y + shsurf->transient.y);
|
2012-04-28 01:20:01 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SHELL_SURFACE_MAXIMIZED:
|
|
|
|
shsurf->saved_x = surface->geometry.x;
|
|
|
|
shsurf->saved_y = surface->geometry.y;
|
|
|
|
shsurf->saved_position_valid = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SHELL_SURFACE_FULLSCREEN:
|
|
|
|
shsurf->saved_x = surface->geometry.x;
|
|
|
|
shsurf->saved_y = surface->geometry.y;
|
|
|
|
shsurf->saved_position_valid = true;
|
|
|
|
|
|
|
|
if (!wl_list_empty(&shsurf->rotation.transform.link)) {
|
|
|
|
wl_list_remove(&shsurf->rotation.transform.link);
|
|
|
|
wl_list_init(&shsurf->rotation.transform.link);
|
|
|
|
shsurf->surface->geometry.dirty = 1;
|
|
|
|
shsurf->saved_rotation_valid = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
set_toplevel(struct shell_surface *shsurf)
|
|
|
|
{
|
|
|
|
shsurf->next_type = SHELL_SURFACE_TOPLEVEL;
|
2012-04-19 17:18:18 +04:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2012-05-19 00:37:43 +04:00
|
|
|
static void
|
|
|
|
set_transient(struct shell_surface *shsurf,
|
2012-06-27 18:22:58 +04:00
|
|
|
struct weston_surface *parent, int x, int y, uint32_t flags)
|
2012-05-19 00:37:43 +04:00
|
|
|
{
|
|
|
|
/* assign to parents output */
|
2012-06-27 18:22:58 +04:00
|
|
|
shsurf->parent = parent;
|
2012-05-19 00:37:43 +04:00
|
|
|
shsurf->transient.x = x;
|
|
|
|
shsurf->transient.y = y;
|
|
|
|
shsurf->transient.flags = flags;
|
|
|
|
shsurf->next_type = SHELL_SURFACE_TRANSIENT;
|
|
|
|
}
|
|
|
|
|
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;
|
2012-06-27 18:22:58 +04:00
|
|
|
struct weston_surface *parent = parent_resource->data;
|
2011-12-01 12:42:22 +04:00
|
|
|
|
2012-06-27 18:22:58 +04:00
|
|
|
set_transient(shsurf, parent, x, y, flags);
|
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
|
|
|
{
|
2012-06-27 05:19:23 +04:00
|
|
|
struct weston_surface *surface;
|
2012-02-07 04:45:41 +04:00
|
|
|
int panel_height = 0;
|
|
|
|
|
|
|
|
if (!output)
|
|
|
|
return 0;
|
|
|
|
|
2012-07-10 09:24:09 +04:00
|
|
|
wl_list_for_each(surface, &shell->panel_layer.surface_list, layer_link) {
|
2012-06-27 05:19:23 +04:00
|
|
|
if (surface->output == output) {
|
|
|
|
panel_height = surface->geometry.height;
|
2012-02-07 04:45:41 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-06-27 05:19:23 +04:00
|
|
|
|
2012-02-07 04:45:41 +04:00
|
|
|
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;
|
2012-07-18 17:54:04 +04:00
|
|
|
else if (es->output)
|
|
|
|
shsurf->output = es->output;
|
2012-02-07 04:45:41 +04:00
|
|
|
else
|
|
|
|
shsurf->output = get_default_output(es->compositor);
|
|
|
|
|
2012-04-16 18:31:41 +04:00
|
|
|
shell = shell_surface_get_shell(shsurf);
|
2012-07-02 22:00:19 +04:00
|
|
|
panel_height = get_output_panel_height(shell, shsurf->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-05-23 00:05:52 +04:00
|
|
|
shsurf->client->send_configure(shsurf->surface, edges,
|
2012-08-18 11:04:05 +04:00
|
|
|
shsurf->output->width,
|
|
|
|
shsurf->output->height - panel_height);
|
2012-02-07 04:45:41 +04:00
|
|
|
|
2012-04-28 01:20:01 +04:00
|
|
|
shsurf->next_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) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("no memory\n");
|
2012-03-01 08:57:46 +04:00
|
|
|
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);
|
2012-08-04 00:31:36 +04:00
|
|
|
pixman_region32_init_rect(&surface->opaque, 0, 0, w, h);
|
|
|
|
|
2012-03-01 08:57:46 +04:00
|
|
|
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;
|
2012-07-12 20:32:31 +04:00
|
|
|
float scale, output_aspect, surface_aspect, x, y;
|
2012-03-01 08:57:46 +04:00
|
|
|
|
|
|
|
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,
|
2012-08-18 11:04:05 +04:00
|
|
|
output->width,
|
|
|
|
output->height);
|
2012-02-29 21:42:35 +04:00
|
|
|
|
|
|
|
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:
|
2012-07-20 23:30:36 +04:00
|
|
|
if (surface->buffer)
|
|
|
|
center_on_output(surface, shsurf->fullscreen_output);
|
2012-03-01 08:57:46 +04:00
|
|
|
break;
|
|
|
|
case WL_SHELL_SURFACE_FULLSCREEN_METHOD_SCALE:
|
|
|
|
matrix = &shsurf->fullscreen.transform.matrix;
|
|
|
|
weston_matrix_init(matrix);
|
2012-07-12 20:32:31 +04:00
|
|
|
|
2012-08-18 11:04:05 +04:00
|
|
|
output_aspect = (float) output->width /
|
|
|
|
(float) output->height;
|
2012-07-12 20:32:31 +04:00
|
|
|
surface_aspect = (float) surface->geometry.width /
|
|
|
|
(float) surface->geometry.height;
|
|
|
|
if (output_aspect < surface_aspect)
|
2012-08-18 11:04:05 +04:00
|
|
|
scale = (float) output->width /
|
2012-07-12 20:32:31 +04:00
|
|
|
(float) surface->geometry.width;
|
|
|
|
else
|
2012-08-18 11:04:05 +04:00
|
|
|
scale = (float) output->height /
|
2012-07-12 20:32:31 +04:00
|
|
|
(float) surface->geometry.height;
|
|
|
|
|
2012-03-01 08:57:46 +04:00
|
|
|
weston_matrix_scale(matrix, scale, scale, 1);
|
|
|
|
wl_list_remove(&shsurf->fullscreen.transform.link);
|
2012-07-12 20:32:31 +04:00
|
|
|
wl_list_insert(&surface->geometry.transformation_list,
|
2012-03-01 08:57:46 +04:00
|
|
|
&shsurf->fullscreen.transform.link);
|
2012-08-18 11:04:05 +04:00
|
|
|
x = output->x + (output->width - surface->geometry.width * scale) / 2;
|
|
|
|
y = output->y + (output->height - surface->geometry.height * scale) / 2;
|
2012-07-12 20:32:31 +04:00
|
|
|
weston_surface_set_position(surface, x, y);
|
|
|
|
|
2012-03-01 08:57:46 +04:00
|
|
|
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,
|
2012-08-18 11:04:05 +04:00
|
|
|
output->width,
|
|
|
|
output->height);
|
2012-04-17 13:20:49 +04:00
|
|
|
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,
|
2012-08-18 11:04:05 +04:00
|
|
|
output->width,
|
|
|
|
output->height);
|
2012-04-17 13:20:49 +04:00
|
|
|
|
|
|
|
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;
|
2012-07-18 17:54:04 +04:00
|
|
|
else if (es->output)
|
|
|
|
shsurf->output = es->output;
|
2012-03-01 08:57:46 +04:00
|
|
|
else
|
|
|
|
shsurf->output = get_default_output(es->compositor);
|
2011-06-18 14:12:54 +04:00
|
|
|
|
2012-03-01 08:57:46 +04:00
|
|
|
shsurf->fullscreen_output = shsurf->output;
|
|
|
|
shsurf->fullscreen.type = method;
|
|
|
|
shsurf->fullscreen.framerate = framerate;
|
2012-04-28 01:20:01 +04:00
|
|
|
shsurf->next_type = SHELL_SURFACE_FULLSCREEN;
|
2012-03-01 08:57:46 +04:00
|
|
|
|
2012-05-23 00:05:52 +04:00
|
|
|
shsurf->client->send_configure(shsurf->surface, 0,
|
2012-08-18 11:04:05 +04:00
|
|
|
shsurf->output->width,
|
|
|
|
shsurf->output->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-05-08 20:17:55 +04:00
|
|
|
struct wl_surface *surface,
|
|
|
|
wl_fixed_t x,
|
|
|
|
wl_fixed_t y)
|
2012-01-05 07:19:14 +04:00
|
|
|
{
|
2012-05-16 21:45:18 +04:00
|
|
|
struct wl_pointer *pointer = grab->pointer;
|
2012-01-05 07:19:14 +04:00
|
|
|
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-05-16 21:45:18 +04:00
|
|
|
wl_pointer_set_focus(pointer, surface, x, y);
|
2012-01-05 07:19:14 +04:00
|
|
|
grab->focus = surface;
|
|
|
|
} else {
|
2012-05-16 21:45:18 +04:00
|
|
|
wl_pointer_set_focus(pointer, NULL,
|
|
|
|
wl_fixed_from_int(0),
|
|
|
|
wl_fixed_from_int(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-05-08 20:17:55 +04:00
|
|
|
uint32_t time, wl_fixed_t sx, wl_fixed_t sy)
|
2012-01-05 07:19:14 +04:00
|
|
|
{
|
|
|
|
struct wl_resource *resource;
|
|
|
|
|
2012-05-16 21:45:18 +04:00
|
|
|
resource = grab->pointer->focus_resource;
|
2012-01-05 07:19:14 +04:00
|
|
|
if (resource)
|
2012-05-16 21:45:18 +04:00
|
|
|
wl_pointer_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-05-30 19:31:51 +04:00
|
|
|
uint32_t time, uint32_t button, uint32_t state_w)
|
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;
|
2012-05-30 19:31:51 +04:00
|
|
|
enum wl_pointer_button_state state = state_w;
|
2012-04-12 06:42:15 +04:00
|
|
|
uint32_t serial;
|
2012-01-05 07:19:14 +04:00
|
|
|
|
2012-05-16 21:45:18 +04:00
|
|
|
resource = grab->pointer->focus_resource;
|
2012-01-05 07:19:14 +04:00
|
|
|
if (resource) {
|
2012-04-12 06:42:15 +04:00
|
|
|
display = wl_client_get_display(resource->client);
|
|
|
|
serial = wl_display_get_serial(display);
|
2012-05-16 21:45:18 +04:00
|
|
|
wl_pointer_send_button(resource, serial, time, button, state);
|
2012-05-30 19:31:51 +04:00
|
|
|
} else if (state == WL_POINTER_BUTTON_STATE_RELEASED &&
|
2012-01-05 07:19:14 +04:00
|
|
|
(shsurf->popup.initial_up ||
|
2012-05-16 21:45:18 +04:00
|
|
|
time - shsurf->popup.seat->pointer->grab_time > 500)) {
|
2012-03-05 06:57:37 +04:00
|
|
|
wl_shell_surface_send_popup_done(&shsurf->resource);
|
2012-05-16 21:45:18 +04:00
|
|
|
wl_pointer_end_grab(grab->pointer);
|
|
|
|
shsurf->popup.grab.pointer = NULL;
|
2012-01-05 07:19:14 +04:00
|
|
|
}
|
|
|
|
|
2012-05-30 19:31:51 +04:00
|
|
|
if (state == WL_POINTER_BUTTON_STATE_RELEASED)
|
2012-01-05 07:19:14 +04:00
|
|
|
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-05-16 21:45:18 +04:00
|
|
|
struct wl_seat *seat = shsurf->popup.seat;
|
2012-01-05 07:19:14 +04:00
|
|
|
struct weston_surface *es = shsurf->surface;
|
2012-06-27 18:22:58 +04:00
|
|
|
struct weston_surface *parent = shsurf->parent;
|
2012-01-05 07:19:14 +04:00
|
|
|
|
|
|
|
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. */
|
2012-05-16 21:45:18 +04:00
|
|
|
if (seat->pointer->grab_serial == shsurf->popup.serial) {
|
|
|
|
wl_pointer_start_grab(seat->pointer, &shsurf->popup.grab);
|
2012-04-13 20:40:07 +04:00
|
|
|
} 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,
|
2012-05-16 21:45:18 +04:00
|
|
|
struct wl_resource *seat_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-05-16 21:45:18 +04:00
|
|
|
shsurf->popup.seat = seat_resource->data;
|
2012-04-13 20:40:07 +04:00
|
|
|
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,
|
2012-05-02 17:47:44 +04:00
|
|
|
shell_surface_set_maximized,
|
|
|
|
shell_surface_set_title,
|
|
|
|
shell_surface_set_class
|
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-05-16 21:45:18 +04:00
|
|
|
if (shsurf->popup.grab.pointer)
|
|
|
|
wl_pointer_end_grab(shsurf->popup.grab.pointer);
|
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-06-08 02:08:47 +04:00
|
|
|
if (shsurf->resource.client) {
|
2012-04-19 17:18:18 +04:00
|
|
|
wl_resource_destroy(&shsurf->resource);
|
2012-06-08 02:08:47 +04:00
|
|
|
} else {
|
|
|
|
wl_signal_emit(&shsurf->resource.destroy_signal,
|
|
|
|
&shsurf->resource);
|
2012-04-19 17:18:18 +04:00
|
|
|
destroy_shell_surface(shsurf);
|
2012-06-08 02:08:47 +04:00
|
|
|
}
|
2011-11-25 14:09:16 +04:00
|
|
|
}
|
|
|
|
|
2012-06-21 20:49:02 +04:00
|
|
|
static void
|
|
|
|
shell_surface_configure(struct weston_surface *, int32_t, int32_t);
|
|
|
|
|
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
|
|
|
{
|
2012-06-21 20:49:02 +04:00
|
|
|
if (surface->configure == shell_surface_configure)
|
|
|
|
return surface->private;
|
|
|
|
else
|
|
|
|
return NULL;
|
2011-11-28 17:12:34 +04:00
|
|
|
}
|
|
|
|
|
2012-05-21 22:27:33 +04:00
|
|
|
static struct shell_surface *
|
2012-05-23 00:05:52 +04:00
|
|
|
create_shell_surface(void *shell, struct weston_surface *surface,
|
|
|
|
const struct weston_shell_client *client)
|
2011-11-25 14:09:16 +04:00
|
|
|
{
|
|
|
|
struct shell_surface *shsurf;
|
|
|
|
|
2012-03-27 18:36:41 +04:00
|
|
|
if (surface->configure) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("surface->configure already set\n");
|
2012-05-21 22:27:33 +04:00
|
|
|
return NULL;
|
2012-03-27 18:36:41 +04:00
|
|
|
}
|
|
|
|
|
2011-11-25 14:09:16 +04:00
|
|
|
shsurf = calloc(1, sizeof *shsurf);
|
|
|
|
if (!shsurf) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("no memory to allocate shell surface\n");
|
2012-05-21 22:27:33 +04:00
|
|
|
return NULL;
|
2011-11-25 14:09:16 +04:00
|
|
|
}
|
|
|
|
|
2012-03-27 18:36:41 +04:00
|
|
|
surface->configure = shell_surface_configure;
|
2012-06-21 20:49:02 +04:00
|
|
|
surface->private = shsurf;
|
2012-03-27 18:36:41 +04:00
|
|
|
|
2012-04-19 17:18:18 +04:00
|
|
|
shsurf->shell = (struct desktop_shell *) shell;
|
2012-04-18 05:06:18 +04:00
|
|
|
shsurf->unresponsive = 0;
|
2012-03-01 08:57:46 +04:00
|
|
|
shsurf->saved_position_valid = false;
|
2012-04-27 05:07:24 +04:00
|
|
|
shsurf->saved_rotation_valid = false;
|
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
|
|
|
|
2012-06-13 02:01:23 +04:00
|
|
|
wl_list_init(&shsurf->workspace_transform.link);
|
|
|
|
|
2011-12-01 12:42:22 +04:00
|
|
|
shsurf->type = SHELL_SURFACE_NONE;
|
2012-04-28 01:20:01 +04:00
|
|
|
shsurf->next_type = SHELL_SURFACE_NONE;
|
2011-11-25 14:09:16 +04:00
|
|
|
|
2012-05-23 00:05:52 +04:00
|
|
|
shsurf->client = client;
|
|
|
|
|
2012-05-21 22:27:33 +04:00
|
|
|
return shsurf;
|
2012-04-19 17:18:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
2012-05-21 22:28:57 +04:00
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
|
|
|
"desktop_shell::get_shell_surface already requested");
|
2012-04-19 17:18:18 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-05-23 00:05:52 +04:00
|
|
|
shsurf = create_shell_surface(shell, surface, &shell_client);
|
2012-05-21 22:28:57 +04:00
|
|
|
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) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("old screensaver still running\n");
|
2012-03-02 02:11:36 +04:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2012-06-27 00:29:50 +04:00
|
|
|
static void
|
2012-06-27 05:19:23 +04:00
|
|
|
configure_static_surface(struct weston_surface *es, struct weston_layer *layer)
|
2012-06-27 00:29:50 +04:00
|
|
|
{
|
2012-06-27 05:19:23 +04:00
|
|
|
struct weston_surface *s, *next;
|
2012-06-27 00:29:50 +04:00
|
|
|
|
2012-06-27 05:19:23 +04:00
|
|
|
wl_list_for_each_safe(s, next, &layer->surface_list, layer_link) {
|
|
|
|
if (s->output == es->output && s != es) {
|
|
|
|
weston_surface_unmap(s);
|
2012-06-27 00:29:50 +04:00
|
|
|
s->configure = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
weston_surface_configure(es, es->output->x, es->output->y,
|
|
|
|
es->buffer->width, es->buffer->height);
|
|
|
|
|
|
|
|
if (wl_list_empty(&es->layer_link)) {
|
2012-06-27 05:19:23 +04:00
|
|
|
wl_list_insert(&layer->surface_list, &es->layer_link);
|
2012-06-28 21:46:09 +04:00
|
|
|
weston_compositor_schedule_repaint(es->compositor);
|
2012-06-27 00:29:50 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-27 05:19:23 +04:00
|
|
|
static void
|
|
|
|
background_configure(struct weston_surface *es, int32_t sx, int32_t sy)
|
|
|
|
{
|
|
|
|
struct desktop_shell *shell = es->private;
|
|
|
|
|
|
|
|
configure_static_surface(es, &shell->background_layer);
|
|
|
|
}
|
|
|
|
|
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-06-27 00:29:50 +04:00
|
|
|
struct desktop_shell *shell = resource->data;
|
|
|
|
struct weston_surface *surface = surface_resource->data;
|
2011-11-23 23:46:40 +04:00
|
|
|
|
2012-06-27 00:29:50 +04:00
|
|
|
if (surface->configure) {
|
|
|
|
wl_resource_post_error(surface_resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
|
|
|
"surface role already assigned");
|
|
|
|
return;
|
|
|
|
}
|
2011-11-22 15:43:52 +04:00
|
|
|
|
2012-06-27 00:29:50 +04:00
|
|
|
surface->configure = background_configure;
|
|
|
|
surface->private = shell;
|
|
|
|
surface->output = output_resource->data;
|
2012-04-12 06:42:15 +04:00
|
|
|
desktop_shell_send_configure(resource, 0,
|
2012-03-05 06:57:37 +04:00
|
|
|
surface_resource,
|
2012-08-18 11:04:05 +04:00
|
|
|
surface->output->width,
|
|
|
|
surface->output->height);
|
2011-09-06 21:48:16 +04:00
|
|
|
}
|
|
|
|
|
2012-06-27 05:19:23 +04:00
|
|
|
static void
|
|
|
|
panel_configure(struct weston_surface *es, int32_t sx, int32_t sy)
|
|
|
|
{
|
|
|
|
struct desktop_shell *shell = es->private;
|
|
|
|
|
|
|
|
configure_static_surface(es, &shell->panel_layer);
|
|
|
|
}
|
|
|
|
|
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-06-27 05:19:23 +04:00
|
|
|
struct desktop_shell *shell = resource->data;
|
|
|
|
struct weston_surface *surface = surface_resource->data;
|
2011-11-23 23:46:40 +04:00
|
|
|
|
2012-06-27 05:19:23 +04:00
|
|
|
if (surface->configure) {
|
|
|
|
wl_resource_post_error(surface_resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
|
|
|
"surface role already assigned");
|
|
|
|
return;
|
|
|
|
}
|
2011-09-06 21:48:16 +04:00
|
|
|
|
2012-06-27 05:19:23 +04:00
|
|
|
surface->configure = panel_configure;
|
|
|
|
surface->private = shell;
|
|
|
|
surface->output = output_resource->data;
|
2012-04-12 06:42:15 +04:00
|
|
|
desktop_shell_send_configure(resource, 0,
|
2012-06-27 05:19:23 +04:00
|
|
|
surface_resource,
|
2012-08-18 11:04:05 +04:00
|
|
|
surface->output->width,
|
|
|
|
surface->output->height);
|
2011-09-06 21:48:16 +04:00
|
|
|
}
|
|
|
|
|
2012-06-27 05:44:35 +04:00
|
|
|
static void
|
|
|
|
lock_surface_configure(struct weston_surface *surface, int32_t sx, int32_t sy)
|
|
|
|
{
|
|
|
|
struct desktop_shell *shell = surface->private;
|
|
|
|
|
|
|
|
center_on_output(surface, get_default_output(shell->compositor));
|
|
|
|
|
|
|
|
if (!weston_surface_is_mapped(surface)) {
|
|
|
|
wl_list_insert(&shell->lock_layer.surface_list,
|
|
|
|
&surface->layer_link);
|
2012-09-14 17:12:04 +04:00
|
|
|
weston_surface_update_transform(surface);
|
2012-06-27 05:44:35 +04:00
|
|
|
weston_compositor_wake(shell->compositor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-16 01:39:55 +04:00
|
|
|
static void
|
2012-04-12 07:18:23 +04:00
|
|
|
handle_lock_surface_destroy(struct wl_listener *listener, void *data)
|
2011-11-16 01:39:55 +04:00
|
|
|
{
|
2012-04-16 18:31:41 +04:00
|
|
|
struct desktop_shell *shell =
|
|
|
|
container_of(listener, struct desktop_shell, lock_surface_listener);
|
2011-11-16 01:39:55 +04:00
|
|
|
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("lock surface gone\n");
|
2011-11-16 01:39:55 +04:00
|
|
|
shell->lock_surface = NULL;
|
|
|
|
}
|
|
|
|
|
desktop-shell: screen locking protocol
Add protocol and functions for supporting screen locking, triggered by
activity timeout.
After activity timeout, compositor starts the fade to black, and then
enters SLEEPING state. At that point it calls lock() in the shell
plugin.
When input events trigger a wakeup, unlock() in the shell plugin is
called. This sends prepare_lock_surface event to the desktop-shell
client. The screen stays locked while the compositor starts fade-in.
At this point, desktop-shell client usually creates a surface for the
unlocking GUI (e.g. a password prompt), and sends it with the
set_lock_surface request. The compositor supposedly shows and allows
interaction only with the given lock surface (not yet implemented).
When desktop-shell has authenticated the user, or instead of issuing
set_lock_surface, it sends the unlock request. Upon receiving the unlock
request, the shell plugin unlocks the screen.
If desktop-shell client dies, the screen is unlocked automatically.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-15 15:34:48 +04:00
|
|
|
static void
|
|
|
|
desktop_shell_set_lock_surface(struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
struct wl_resource *surface_resource)
|
|
|
|
{
|
2012-04-16 18:31:41 +04:00
|
|
|
struct desktop_shell *shell = resource->data;
|
2012-06-27 05:44:35 +04:00
|
|
|
struct weston_surface *surface = surface_resource->data;
|
2011-12-01 12:42:22 +04:00
|
|
|
|
2011-11-15 15:34:54 +04:00
|
|
|
shell->prepare_event_sent = false;
|
|
|
|
|
|
|
|
if (!shell->locked)
|
|
|
|
return;
|
2011-11-15 15:34:49 +04:00
|
|
|
|
2011-12-01 12:42:22 +04:00
|
|
|
shell->lock_surface = surface;
|
2011-11-15 15:34:49 +04:00
|
|
|
|
2012-04-12 07:18:23 +04:00
|
|
|
shell->lock_surface_listener.notify = handle_lock_surface_destroy;
|
|
|
|
wl_signal_add(&surface_resource->destroy_signal,
|
|
|
|
&shell->lock_surface_listener);
|
2011-11-23 18:42:16 +04:00
|
|
|
|
2012-06-27 05:44:35 +04:00
|
|
|
surface->configure = lock_surface_configure;
|
|
|
|
surface->private = shell;
|
2011-11-15 15:34:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-04-16 18:31:41 +04:00
|
|
|
resume_desktop(struct desktop_shell *shell)
|
2011-11-15 15:34:54 +04:00
|
|
|
{
|
2012-06-27 06:15:53 +04:00
|
|
|
struct weston_surface *surface;
|
2012-06-25 22:03:13 +04:00
|
|
|
struct workspace *ws = get_current_workspace(shell);
|
2011-11-30 18:26:35 +04:00
|
|
|
|
2012-06-27 06:15:53 +04:00
|
|
|
wl_list_for_each(surface, &shell->screensaver.surfaces, link)
|
|
|
|
weston_surface_unmap(surface);
|
2011-11-30 18:26:35 +04:00
|
|
|
|
|
|
|
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);
|
2012-08-09 20:50:43 +04:00
|
|
|
if (shell->showing_input_panels) {
|
|
|
|
wl_list_insert(&shell->panel_layer.link,
|
|
|
|
&shell->input_panel_layer.link);
|
|
|
|
wl_list_insert(&shell->input_panel_layer.link,
|
|
|
|
&ws->layer.link);
|
|
|
|
} else {
|
|
|
|
wl_list_insert(&shell->panel_layer.link, &ws->layer.link);
|
|
|
|
}
|
2011-11-15 15:34:54 +04:00
|
|
|
|
2012-08-01 00:36:34 +04:00
|
|
|
restore_focus_state(shell, get_current_workspace(shell));
|
2012-06-13 02:01:24 +04:00
|
|
|
|
2011-11-15 15:34:54 +04:00
|
|
|
shell->locked = false;
|
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
|
|
|
}
|
|
|
|
|
2012-06-05 17:58:51 +04:00
|
|
|
static void
|
2012-06-28 19:08:05 +04:00
|
|
|
desktop_shell_set_grab_surface(struct wl_client *client,
|
2012-06-05 17:58:51 +04:00
|
|
|
struct wl_resource *resource,
|
|
|
|
struct wl_resource *surface_resource)
|
|
|
|
{
|
|
|
|
struct desktop_shell *shell = resource->data;
|
|
|
|
|
2012-06-28 19:08:05 +04:00
|
|
|
shell->grab_surface = surface_resource->data;
|
2012-06-05 17:58:51 +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,
|
2012-06-05 17:58:51 +04:00
|
|
|
desktop_shell_unlock,
|
2012-06-28 19:08:05 +04:00
|
|
|
desktop_shell_set_grab_surface
|
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
|
2012-05-30 19:31:58 +04:00
|
|
|
move_binding(struct wl_seat *seat, uint32_t time, uint32_t button, 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 =
|
2012-05-16 21:45:18 +04:00
|
|
|
(struct weston_surface *) seat->pointer->focus;
|
2012-05-18 21:46:27 +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-04-13 19:52:54 +04:00
|
|
|
|
2012-05-18 21:46:27 +04:00
|
|
|
shsurf = get_shell_surface(surface);
|
2012-06-27 18:22:15 +04:00
|
|
|
if (shsurf == NULL || shsurf->type == SHELL_SURFACE_FULLSCREEN)
|
2012-05-18 21:46:27 +04:00
|
|
|
return;
|
|
|
|
|
|
|
|
surface_move(shsurf, (struct weston_seat *) seat);
|
2011-04-13 01:25:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-05-30 19:31:58 +04:00
|
|
|
resize_binding(struct wl_seat *seat, uint32_t time, uint32_t button, 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 =
|
2012-05-16 21:45:18 +04:00
|
|
|
(struct weston_surface *) seat->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);
|
2012-06-27 18:22:15 +04:00
|
|
|
if (!shsurf || shsurf->type == SHELL_SURFACE_FULLSCREEN)
|
2011-11-28 17:34:13 +04:00
|
|
|
return;
|
|
|
|
|
2012-01-30 18:19:47 +04:00
|
|
|
weston_surface_from_global(surface,
|
2012-05-16 21:45:18 +04:00
|
|
|
wl_fixed_to_int(seat->pointer->grab_x),
|
|
|
|
wl_fixed_to_int(seat->pointer->grab_y),
|
2012-05-08 20:17:55 +04:00
|
|
|
&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
|
|
|
|
2012-05-23 00:56:23 +04:00
|
|
|
surface_resize(shsurf, (struct weston_seat *) seat, edges);
|
2011-04-23 21:04:11 +04:00
|
|
|
}
|
|
|
|
|
2012-03-22 21:01:03 +04:00
|
|
|
static void
|
2012-05-30 19:31:58 +04:00
|
|
|
surface_opacity_binding(struct wl_seat *seat, uint32_t time, uint32_t axis,
|
2012-05-30 19:31:59 +04:00
|
|
|
wl_fixed_t value, void *data)
|
2012-03-22 21:01:03 +04:00
|
|
|
{
|
2012-05-22 11:54:10 +04:00
|
|
|
float step = 0.05;
|
2012-03-22 21:01:03 +04:00
|
|
|
struct shell_surface *shsurf;
|
|
|
|
struct weston_surface *surface =
|
2012-05-16 21:45:18 +04:00
|
|
|
(struct weston_surface *) seat->pointer->focus;
|
2012-03-22 21:01:03 +04:00
|
|
|
|
|
|
|
if (surface == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
shsurf = get_shell_surface(surface);
|
|
|
|
if (!shsurf)
|
|
|
|
return;
|
|
|
|
|
2012-05-30 19:31:59 +04:00
|
|
|
surface->alpha += wl_fixed_to_double(value) * step;
|
2012-03-22 21:01:03 +04:00
|
|
|
|
2012-05-22 11:54:10 +04:00
|
|
|
if (surface->alpha > 1.0)
|
|
|
|
surface->alpha = 1.0;
|
2012-03-22 21:01:03 +04:00
|
|
|
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-05-30 19:31:58 +04:00
|
|
|
do_zoom(struct wl_seat *seat, uint32_t time, uint32_t key, uint32_t axis,
|
2012-05-30 19:31:59 +04:00
|
|
|
wl_fixed_t value)
|
2012-02-23 01:21:41 +04:00
|
|
|
{
|
2012-05-16 21:45:18 +04:00
|
|
|
struct weston_seat *ws = (struct weston_seat *) seat;
|
|
|
|
struct weston_compositor *compositor = ws->compositor;
|
2012-02-23 01:21:41 +04:00
|
|
|
struct weston_output *output;
|
2012-06-11 23:07:51 +04:00
|
|
|
float increment;
|
2012-02-23 01:21:41 +04:00
|
|
|
|
|
|
|
wl_list_for_each(output, &compositor->output_list, link) {
|
|
|
|
if (pixman_region32_contains_point(&output->region,
|
2012-05-16 21:45:18 +04:00
|
|
|
wl_fixed_to_double(seat->pointer->x),
|
|
|
|
wl_fixed_to_double(seat->pointer->y),
|
2012-05-08 20:17:55 +04:00
|
|
|
NULL)) {
|
2012-05-30 19:31:58 +04:00
|
|
|
if (key == KEY_PAGEUP)
|
2012-05-22 20:55:18 +04:00
|
|
|
increment = output->zoom.increment;
|
2012-05-30 19:31:58 +04:00
|
|
|
else if (key == KEY_PAGEDOWN)
|
2012-05-22 20:55:18 +04:00
|
|
|
increment = -output->zoom.increment;
|
|
|
|
else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL)
|
2012-05-30 19:31:59 +04:00
|
|
|
increment = output->zoom.increment *
|
|
|
|
wl_fixed_to_double(value);
|
2012-05-22 20:55:18 +04:00
|
|
|
else
|
|
|
|
increment = 0;
|
|
|
|
|
|
|
|
output->zoom.level += increment;
|
2012-02-24 09:28:37 +04:00
|
|
|
|
2012-06-11 23:07:51 +04:00
|
|
|
if (output->zoom.level < 0.0)
|
2012-05-22 01:21:25 +04:00
|
|
|
output->zoom.level = 0.0;
|
2012-06-11 23:07:51 +04:00
|
|
|
else if (output->zoom.level > output->zoom.max_level)
|
|
|
|
output->zoom.level = output->zoom.max_level;
|
2012-08-03 23:45:23 +04:00
|
|
|
else {
|
2012-06-11 23:07:51 +04:00
|
|
|
output->zoom.active = 1;
|
2012-08-03 23:45:23 +04:00
|
|
|
output->disable_planes++;
|
|
|
|
}
|
2012-05-22 01:21:25 +04:00
|
|
|
|
2012-06-11 23:07:51 +04:00
|
|
|
output->zoom.spring_z.target = output->zoom.level;
|
2012-02-23 01:21:41 +04:00
|
|
|
|
2012-06-18 04:10:58 +04:00
|
|
|
weston_output_update_zoom(output, output->zoom.type);
|
2012-02-23 01:21:41 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-20 00:18:05 +04:00
|
|
|
static void
|
2012-05-30 19:31:58 +04:00
|
|
|
zoom_axis_binding(struct wl_seat *seat, uint32_t time, uint32_t axis,
|
2012-05-30 19:31:59 +04:00
|
|
|
wl_fixed_t value, void *data)
|
2012-05-30 19:31:58 +04:00
|
|
|
{
|
|
|
|
do_zoom(seat, time, 0, axis, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
zoom_key_binding(struct wl_seat *seat, uint32_t time, uint32_t key,
|
|
|
|
void *data)
|
|
|
|
{
|
|
|
|
do_zoom(seat, time, key, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
terminate_binding(struct wl_seat *seat, uint32_t time, uint32_t key,
|
|
|
|
void *data)
|
2011-12-20 00:18:05 +04:00
|
|
|
{
|
Rename wayland-compositor to weston
This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.
1) Initially, we had one big repository with protocol code, sample
compositor and sample clients. We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code. At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message. The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.
2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor. Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example. Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.
We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
2012-01-03 19:29:47 +04:00
|
|
|
struct weston_compositor *compositor = data;
|
2011-12-20 00:18:05 +04:00
|
|
|
|
2012-05-30 19:31:58 +04:00
|
|
|
wl_display_terminate(compositor->wl_display);
|
2011-12-20 00:18:05 +04:00
|
|
|
}
|
|
|
|
|
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-05-08 20:17:55 +04:00
|
|
|
uint32_t time, wl_fixed_t x, wl_fixed_t y)
|
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-05-16 21:45:18 +04:00
|
|
|
struct wl_pointer *pointer = grab->pointer;
|
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
|
|
|
|
2012-05-16 21:45:18 +04:00
|
|
|
dx = wl_fixed_to_double(pointer->x) - rotate->center.x;
|
|
|
|
dy = wl_fixed_to_double(pointer->y) - rotate->center.y;
|
2012-01-20 18:48:25 +04:00
|
|
|
r = sqrtf(dx * dx + dy * dy);
|
|
|
|
|
2012-04-04 18:48:05 +04:00
|
|
|
wl_list_remove(&shsurf->rotation.transform.link);
|
|
|
|
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-05-30 19:31:51 +04:00
|
|
|
uint32_t time, uint32_t button, uint32_t state_w)
|
2012-01-20 18:48:25 +04:00
|
|
|
{
|
|
|
|
struct rotate_grab *rotate =
|
2012-04-04 18:48:05 +04:00
|
|
|
container_of(grab, struct rotate_grab, base.grab);
|
2012-05-16 21:45:18 +04:00
|
|
|
struct wl_pointer *pointer = grab->pointer;
|
2012-04-04 18:48:05 +04:00
|
|
|
struct shell_surface *shsurf = rotate->base.shsurf;
|
2012-05-30 19:31:51 +04:00
|
|
|
enum wl_pointer_button_state state = state_w;
|
2012-01-20 18:48:25 +04:00
|
|
|
|
2012-05-30 19:31:51 +04:00
|
|
|
if (pointer->button_count == 0 &&
|
|
|
|
state == WL_POINTER_BUTTON_STATE_RELEASED) {
|
2012-04-04 18:48:05 +04:00
|
|
|
if (shsurf)
|
|
|
|
weston_matrix_multiply(&shsurf->rotation.rotation,
|
|
|
|
&rotate->rotation);
|
2012-06-28 19:08:05 +04:00
|
|
|
shell_grab_end(&rotate->base);
|
2012-01-20 18:48:25 +04:00
|
|
|
free(rotate);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
2012-05-30 19:31:58 +04:00
|
|
|
rotate_binding(struct wl_seat *seat, uint32_t time, uint32_t button,
|
2012-05-04 14:21:57 +04:00
|
|
|
void *data)
|
2012-01-20 18:48:25 +04:00
|
|
|
{
|
|
|
|
struct weston_surface *base_surface =
|
2012-05-16 21:45:18 +04:00
|
|
|
(struct weston_surface *) seat->pointer->focus;
|
2012-01-20 18:48:25 +04:00
|
|
|
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);
|
2012-06-27 18:22:15 +04:00
|
|
|
if (!surface || surface->type == SHELL_SURFACE_FULLSCREEN)
|
2012-01-20 18:48:25 +04:00
|
|
|
return;
|
|
|
|
|
|
|
|
rotate = malloc(sizeof *rotate);
|
|
|
|
if (!rotate)
|
|
|
|
return;
|
|
|
|
|
2012-06-08 04:10:23 +04:00
|
|
|
weston_surface_to_global_float(surface->surface,
|
|
|
|
surface->surface->geometry.width / 2,
|
|
|
|
surface->surface->geometry.height / 2,
|
|
|
|
&rotate->center.x, &rotate->center.y);
|
2012-01-20 18:48:25 +04:00
|
|
|
|
2012-05-16 21:45:18 +04:00
|
|
|
dx = wl_fixed_to_double(seat->pointer->x) - rotate->center.x;
|
|
|
|
dy = wl_fixed_to_double(seat->pointer->y) - rotate->center.y;
|
2012-01-27 22:36:13 +04:00
|
|
|
r = sqrtf(dx * dx + dy * dy);
|
|
|
|
if (r > 20.0f) {
|
|
|
|
struct weston_matrix inverse;
|
|
|
|
|
|
|
|
weston_matrix_init(&inverse);
|
|
|
|
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-06-28 19:08:05 +04:00
|
|
|
shell_grab_start(&rotate->base, &rotate_grab_interface, surface,
|
|
|
|
seat->pointer, DESKTOP_SHELL_CURSOR_ARROW);
|
2012-01-20 18:48:25 +04:00
|
|
|
}
|
|
|
|
|
2012-06-19 00:34:58 +04:00
|
|
|
static void
|
|
|
|
lower_fullscreen_layer(struct desktop_shell *shell)
|
|
|
|
{
|
|
|
|
struct workspace *ws;
|
|
|
|
struct weston_surface *surface, *prev;
|
|
|
|
|
|
|
|
ws = get_current_workspace(shell);
|
|
|
|
wl_list_for_each_reverse_safe(surface, prev,
|
|
|
|
&shell->fullscreen_layer.surface_list,
|
|
|
|
layer_link)
|
|
|
|
weston_surface_restack(surface, &ws->layer.surface_list);
|
|
|
|
}
|
|
|
|
|
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-05-16 21:45:18 +04:00
|
|
|
struct weston_seat *seat)
|
2011-09-06 21:48:16 +04:00
|
|
|
{
|
2012-08-01 00:36:34 +04:00
|
|
|
struct focus_state *state;
|
2012-08-30 00:13:03 +04:00
|
|
|
struct workspace *ws;
|
2011-09-06 21:48:16 +04:00
|
|
|
|
2012-05-16 21:45:18 +04:00
|
|
|
weston_surface_activate(es, seat);
|
2011-09-06 21:48:16 +04:00
|
|
|
|
2012-08-30 00:13:03 +04:00
|
|
|
state = ensure_focus_state(shell, seat);
|
|
|
|
if (state == NULL)
|
|
|
|
return;
|
2012-08-01 00:36:34 +04:00
|
|
|
|
|
|
|
state->keyboard_focus = es;
|
|
|
|
wl_list_remove(&state->surface_destroy_listener.link);
|
|
|
|
wl_signal_add(&es->surface.resource.destroy_signal,
|
|
|
|
&state->surface_destroy_listener);
|
|
|
|
|
2011-11-28 17:34:13 +04:00
|
|
|
switch (get_shell_surface_type(es)) {
|
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-06-13 02:01:22 +04:00
|
|
|
ws = get_current_workspace(shell);
|
2012-06-19 00:34:58 +04:00
|
|
|
lower_fullscreen_layer(shell);
|
|
|
|
weston_surface_restack(es, &ws->layer.surface_list);
|
2012-02-29 21:42:35 +04:00
|
|
|
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
|
2012-05-30 19:31:58 +04:00
|
|
|
click_to_activate_binding(struct wl_seat *seat, uint32_t time, uint32_t button,
|
2012-05-30 19:31:51 +04:00
|
|
|
void *data)
|
2011-12-20 00:18:05 +04:00
|
|
|
{
|
2012-05-16 21:45:18 +04:00
|
|
|
struct weston_seat *ws = (struct weston_seat *) seat;
|
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
|
|
|
|
2012-05-16 21:45:18 +04:00
|
|
|
focus = (struct weston_surface *) seat->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-06-27 18:22:15 +04:00
|
|
|
if (get_shell_surface_type(focus) == SHELL_SURFACE_NONE)
|
|
|
|
return;
|
2012-06-22 00:49:42 +04:00
|
|
|
|
2012-05-30 19:31:58 +04:00
|
|
|
if (seat->pointer->grab == &seat->pointer->default_grab)
|
2012-05-16 21:45:18 +04:00
|
|
|
activate(shell, focus, ws);
|
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);
|
2012-02-29 21:53:50 +04:00
|
|
|
struct weston_output *output;
|
2012-06-25 22:03:13 +04:00
|
|
|
struct workspace *ws = get_current_workspace(shell);
|
2011-11-15 15:34:54 +04:00
|
|
|
|
2012-02-29 21:53:50 +04:00
|
|
|
if (shell->locked) {
|
|
|
|
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->fullscreen_layer.link);
|
2012-08-09 20:50:43 +04:00
|
|
|
if (shell->showing_input_panels)
|
|
|
|
wl_list_remove(&shell->input_panel_layer.link);
|
2012-06-25 22:03:13 +04:00
|
|
|
wl_list_remove(&ws->layer.link);
|
2012-02-29 21:42:35 +04:00
|
|
|
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);
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2012-06-21 23:52:17 +04:00
|
|
|
static void
|
|
|
|
show_input_panels(struct wl_listener *listener, void *data)
|
|
|
|
{
|
|
|
|
struct desktop_shell *shell =
|
2012-08-09 20:50:43 +04:00
|
|
|
container_of(listener, struct desktop_shell,
|
|
|
|
show_input_panel_listener);
|
2012-08-06 15:44:42 +04:00
|
|
|
struct input_panel_surface *surface, *next;
|
|
|
|
struct weston_surface *ws;
|
2012-06-21 23:52:17 +04:00
|
|
|
|
2012-08-09 20:50:43 +04:00
|
|
|
shell->showing_input_panels = true;
|
|
|
|
|
|
|
|
wl_list_insert(&shell->panel_layer.link,
|
|
|
|
&shell->input_panel_layer.link);
|
|
|
|
|
2012-06-27 18:22:15 +04:00
|
|
|
wl_list_for_each_safe(surface, next,
|
2012-08-06 15:44:42 +04:00
|
|
|
&shell->input_panel.surfaces, link) {
|
|
|
|
ws = surface->surface;
|
2012-08-09 20:50:43 +04:00
|
|
|
wl_list_insert(&shell->input_panel_layer.surface_list,
|
2012-08-06 15:44:42 +04:00
|
|
|
&ws->layer_link);
|
2012-09-26 16:39:45 +04:00
|
|
|
ws->geometry.dirty = 1;
|
2012-09-14 17:12:04 +04:00
|
|
|
weston_surface_update_transform(ws);
|
2012-08-06 15:44:42 +04:00
|
|
|
weston_surface_damage(ws);
|
|
|
|
weston_slide_run(ws, ws->geometry.height, 0, NULL, NULL);
|
2012-06-21 23:52:17 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
hide_input_panels(struct wl_listener *listener, void *data)
|
|
|
|
{
|
|
|
|
struct desktop_shell *shell =
|
2012-08-09 20:50:43 +04:00
|
|
|
container_of(listener, struct desktop_shell,
|
|
|
|
hide_input_panel_listener);
|
2012-06-27 18:22:15 +04:00
|
|
|
struct weston_surface *surface, *next;
|
|
|
|
|
2012-08-09 20:50:43 +04:00
|
|
|
shell->showing_input_panels = false;
|
|
|
|
|
|
|
|
wl_list_remove(&shell->input_panel_layer.link);
|
|
|
|
|
2012-06-27 18:22:15 +04:00
|
|
|
wl_list_for_each_safe(surface, next,
|
2012-08-09 20:50:43 +04:00
|
|
|
&shell->input_panel_layer.surface_list, layer_link)
|
|
|
|
weston_surface_unmap(surface);
|
2012-06-21 23:52:17 +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
|
|
|
{
|
2012-08-18 11:04:05 +04:00
|
|
|
GLfloat x = (output->width - surface->buffer->width) / 2;
|
|
|
|
GLfloat y = (output->height - surface->buffer->height) / 2;
|
2011-11-30 18:26:35 +04:00
|
|
|
|
2012-06-27 05:44:35 +04:00
|
|
|
weston_surface_configure(surface, output->x + x, output->y + y,
|
|
|
|
surface->buffer->width,
|
|
|
|
surface->buffer->height);
|
2011-11-30 18:26:35 +04:00
|
|
|
}
|
|
|
|
|
2012-08-13 17:07:52 +04:00
|
|
|
static void
|
|
|
|
weston_surface_set_initial_position (struct weston_surface *surface,
|
|
|
|
struct desktop_shell *shell)
|
|
|
|
{
|
|
|
|
struct weston_compositor *compositor = shell->compositor;
|
|
|
|
int ix = 0, iy = 0;
|
|
|
|
int range_x, range_y;
|
|
|
|
int dx, dy, x, y, panel_height;
|
|
|
|
struct weston_output *output, *target_output = NULL;
|
|
|
|
struct weston_seat *seat;
|
|
|
|
|
|
|
|
/* As a heuristic place the new window on the same output as the
|
|
|
|
* pointer. Falling back to the output containing 0, 0.
|
|
|
|
*
|
|
|
|
* TODO: Do something clever for touch too?
|
|
|
|
*/
|
|
|
|
wl_list_for_each(seat, &compositor->seat_list, link) {
|
|
|
|
if (seat->has_pointer) {
|
|
|
|
ix = wl_fixed_to_int(seat->pointer.x);
|
|
|
|
iy = wl_fixed_to_int(seat->pointer.y);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
wl_list_for_each(output, &compositor->output_list, link) {
|
|
|
|
if (pixman_region32_contains_point(&output->region, ix, iy, NULL)) {
|
|
|
|
target_output = output;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!target_output) {
|
|
|
|
weston_surface_set_position(surface, 10 + random() % 400,
|
|
|
|
10 + random() % 400);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Valid range within output where the surface will still be onscreen.
|
|
|
|
* If this is negative it means that the surface is bigger than
|
|
|
|
* output.
|
|
|
|
*/
|
|
|
|
panel_height = get_output_panel_height(shell, target_output);
|
2012-08-18 11:04:05 +04:00
|
|
|
range_x = target_output->width - surface->geometry.width;
|
|
|
|
range_y = (target_output->height - panel_height) -
|
2012-08-13 17:07:52 +04:00
|
|
|
surface->geometry.height;
|
|
|
|
|
2012-08-13 18:18:44 +04:00
|
|
|
if (range_x > 0)
|
2012-08-13 17:07:52 +04:00
|
|
|
dx = random() % range_x;
|
|
|
|
else
|
2012-08-13 18:18:44 +04:00
|
|
|
dx = 0;
|
|
|
|
|
|
|
|
if (range_y > 0)
|
2012-08-13 17:07:52 +04:00
|
|
|
dy = panel_height + random() % range_y;
|
2012-08-13 18:18:44 +04:00
|
|
|
else
|
|
|
|
dy = panel_height;
|
2012-08-13 17:07:52 +04:00
|
|
|
|
|
|
|
x = target_output->x + dx;
|
|
|
|
y = target_output->y + dy;
|
|
|
|
|
|
|
|
weston_surface_set_position (surface, x, y);
|
|
|
|
}
|
|
|
|
|
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;
|
2012-06-13 02:01:22 +04:00
|
|
|
struct shell_surface *shsurf = get_shell_surface(surface);
|
|
|
|
enum shell_surface_type surface_type = shsurf->type;
|
2012-03-06 05:51:34 +04:00
|
|
|
struct weston_surface *parent;
|
2012-05-30 19:31:56 +04:00
|
|
|
struct weston_seat *seat;
|
2012-06-13 02:01:22 +04:00
|
|
|
struct workspace *ws;
|
2012-02-07 04:45:41 +04:00
|
|
|
int panel_height = 0;
|
2011-11-23 18:42:16 +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-08-13 17:07:52 +04:00
|
|
|
weston_surface_set_initial_position(surface, shell);
|
2011-11-30 18:26:35 +04:00
|
|
|
break;
|
2012-03-01 08:57:46 +04:00
|
|
|
case SHELL_SURFACE_FULLSCREEN:
|
2012-07-10 05:43:22 +04:00
|
|
|
center_on_output(surface, shsurf->fullscreen_output);
|
2012-03-01 08:57:46 +04:00
|
|
|
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);
|
2012-07-02 22:00:19 +04:00
|
|
|
weston_surface_set_position(surface, shsurf->output->x,
|
|
|
|
shsurf->output->y + panel_height);
|
2012-02-07 04:45:41 +04:00
|
|
|
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) {
|
2012-03-06 05:51:34 +04:00
|
|
|
case SHELL_SURFACE_POPUP:
|
|
|
|
case SHELL_SURFACE_TRANSIENT:
|
2012-06-27 18:22:58 +04:00
|
|
|
parent = shsurf->parent;
|
2012-03-06 05:51:34 +04:00
|
|
|
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-06-13 02:01:22 +04:00
|
|
|
ws = get_current_workspace(shell);
|
|
|
|
wl_list_insert(&ws->layer.surface_list, &surface->layer_link);
|
2012-02-29 21:42:35 +04:00
|
|
|
break;
|
2011-11-15 15:34:54 +04:00
|
|
|
}
|
|
|
|
|
2012-03-05 17:39:23 +04:00
|
|
|
if (surface_type != SHELL_SURFACE_NONE) {
|
2012-09-14 17:12:04 +04:00
|
|
|
weston_surface_update_transform(surface);
|
2012-03-05 17:39:23 +04:00
|
|
|
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_TRANSIENT:
|
2012-05-23 23:06:26 +04:00
|
|
|
if (shsurf->transient.flags ==
|
|
|
|
WL_SHELL_SURFACE_TRANSIENT_INACTIVE)
|
|
|
|
break;
|
|
|
|
case SHELL_SURFACE_TOPLEVEL:
|
2011-12-15 20:31:51 +04:00
|
|
|
case SHELL_SURFACE_FULLSCREEN:
|
2012-02-07 04:45:41 +04:00
|
|
|
case SHELL_SURFACE_MAXIMIZED:
|
2012-05-30 19:31:56 +04:00
|
|
|
if (!shell->locked) {
|
|
|
|
wl_list_for_each(seat, &compositor->seat_list, link)
|
|
|
|
activate(shell, surface, seat);
|
|
|
|
}
|
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) {
|
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-09-14 17:12:04 +04:00
|
|
|
weston_surface_update_transform(surface);
|
2011-11-30 18:26:35 +04:00
|
|
|
|
2012-06-27 06:15:53 +04:00
|
|
|
if (surface_type == SHELL_SURFACE_MAXIMIZED)
|
2012-02-07 04:45:41 +04:00
|
|
|
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-05-07 16:23:07 +04:00
|
|
|
int type_changed = 0;
|
2012-03-27 18:36:41 +04:00
|
|
|
|
2012-04-28 01:20:01 +04:00
|
|
|
if (shsurf->next_type != SHELL_SURFACE_NONE &&
|
2012-04-28 01:51:59 +04:00
|
|
|
shsurf->type != shsurf->next_type) {
|
2012-04-28 01:20:01 +04:00
|
|
|
set_surface_type(shsurf);
|
2012-04-28 01:51:59 +04:00
|
|
|
type_changed = 1;
|
|
|
|
}
|
2012-04-28 01:20:01 +04:00
|
|
|
|
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-04-28 01:51:59 +04:00
|
|
|
} else if (type_changed || 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-09-25 18:57:01 +04:00
|
|
|
static void launch_desktop_shell_process(void *data);
|
2012-01-17 16:36:27 +04:00
|
|
|
|
2011-11-03 16:11:32 +04:00
|
|
|
static void
|
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) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("weston-desktop-shell died, giving up.\n");
|
2012-01-17 16:36:27 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("weston-desktop-shell died, respawning...\n");
|
2012-01-17 16:36:27 +04:00
|
|
|
launch_desktop_shell_process(shell);
|
2011-11-03 16:11:32 +04:00
|
|
|
}
|
|
|
|
|
2012-09-25 18:57:01 +04:00
|
|
|
static void
|
|
|
|
launch_desktop_shell_process(void *data)
|
2011-11-03 16:11:32 +04:00
|
|
|
{
|
2012-09-25 18:57:01 +04:00
|
|
|
struct desktop_shell *shell = data;
|
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)
|
2012-09-25 18:57:01 +04:00
|
|
|
weston_log("not able to start %s\n", shell_exe);
|
2011-11-03 16:11:32 +04:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2012-06-27 06:15:53 +04:00
|
|
|
static void
|
|
|
|
screensaver_configure(struct weston_surface *surface, int32_t sx, int32_t sy)
|
|
|
|
{
|
|
|
|
struct desktop_shell *shell = surface->private;
|
|
|
|
|
|
|
|
if (!shell->locked)
|
|
|
|
return;
|
|
|
|
|
|
|
|
center_on_output(surface, surface->output);
|
|
|
|
|
|
|
|
if (wl_list_empty(&surface->layer_link)) {
|
|
|
|
wl_list_insert(shell->lock_layer.surface_list.prev,
|
|
|
|
&surface->layer_link);
|
2012-09-14 17:12:04 +04:00
|
|
|
weston_surface_update_transform(surface);
|
2012-06-27 06:15:53 +04:00
|
|
|
shell->compositor->idle_time = shell->screensaver.duration;
|
|
|
|
weston_compositor_wake(shell->compositor);
|
|
|
|
shell->compositor->state = WESTON_COMPOSITOR_IDLE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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,
|
2012-06-27 06:15:53 +04:00
|
|
|
struct wl_resource *surface_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
|
|
|
struct wl_resource *output_resource)
|
|
|
|
{
|
2012-04-16 18:31:41 +04:00
|
|
|
struct desktop_shell *shell = resource->data;
|
2012-06-27 06:15:53 +04:00
|
|
|
struct weston_surface *surface = 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
|
|
|
|
2012-06-27 06:15:53 +04:00
|
|
|
surface->configure = screensaver_configure;
|
|
|
|
surface->private = shell;
|
2011-11-30 18:26:35 +04:00
|
|
|
surface->output = output;
|
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-06-27 18:22:15 +04:00
|
|
|
static void
|
|
|
|
input_panel_configure(struct weston_surface *surface, int32_t sx, int32_t sy)
|
|
|
|
{
|
|
|
|
struct weston_mode *mode = surface->output->current;
|
|
|
|
GLfloat x = (mode->width - surface->buffer->width) / 2;
|
|
|
|
GLfloat y = mode->height - surface->buffer->height;
|
|
|
|
|
|
|
|
/* Don't map the input panel here, wait for
|
|
|
|
* show_input_panels signal. */
|
|
|
|
|
|
|
|
weston_surface_configure(surface,
|
|
|
|
surface->output->x + x,
|
|
|
|
surface->output->y + y,
|
|
|
|
surface->buffer->width,
|
|
|
|
surface->buffer->height);
|
|
|
|
}
|
|
|
|
|
2012-08-06 15:44:42 +04:00
|
|
|
static void
|
|
|
|
destroy_input_panel_surface(struct wl_listener *listener,
|
|
|
|
void *data)
|
|
|
|
{
|
|
|
|
struct input_panel_surface *input_panel_surface =
|
|
|
|
container_of(listener, struct input_panel_surface, listener);
|
|
|
|
|
|
|
|
wl_list_remove(&listener->link);
|
|
|
|
wl_list_remove(&input_panel_surface->link);
|
|
|
|
|
|
|
|
free(input_panel_surface);
|
|
|
|
}
|
|
|
|
|
2012-06-21 23:52:17 +04:00
|
|
|
static void
|
|
|
|
input_panel_set_surface(struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
2012-06-27 18:22:15 +04:00
|
|
|
struct wl_resource *surface_resource,
|
2012-06-21 23:52:17 +04:00
|
|
|
struct wl_resource *output_resource)
|
|
|
|
{
|
|
|
|
struct desktop_shell *shell = resource->data;
|
2012-06-27 18:22:15 +04:00
|
|
|
struct weston_surface *surface = surface_resource->data;
|
2012-06-21 23:52:17 +04:00
|
|
|
struct weston_output *output = output_resource->data;
|
2012-08-06 15:44:42 +04:00
|
|
|
struct input_panel_surface *input_panel_surface;
|
2012-06-21 23:52:17 +04:00
|
|
|
|
2012-06-27 18:22:15 +04:00
|
|
|
surface->configure = input_panel_configure;
|
|
|
|
surface->private = shell;
|
2012-06-21 23:52:17 +04:00
|
|
|
surface->output = output;
|
2012-08-06 15:44:42 +04:00
|
|
|
|
|
|
|
input_panel_surface = malloc(sizeof *input_panel_surface);
|
|
|
|
if (!input_panel_surface) {
|
|
|
|
wl_resource_post_no_memory(resource);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
input_panel_surface->surface = surface;
|
|
|
|
input_panel_surface->listener.notify = destroy_input_panel_surface;
|
|
|
|
|
|
|
|
wl_signal_add(&surface_resource->destroy_signal,
|
|
|
|
&input_panel_surface->listener);
|
|
|
|
|
|
|
|
wl_list_insert(&shell->input_panel.surfaces,
|
|
|
|
&input_panel_surface->link);
|
2012-06-21 23:52:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct input_panel_interface input_panel_implementation = {
|
|
|
|
input_panel_set_surface
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
unbind_input_panel(struct wl_resource *resource)
|
|
|
|
{
|
|
|
|
struct desktop_shell *shell = resource->data;
|
|
|
|
|
|
|
|
shell->input_panel.binding = NULL;
|
|
|
|
free(resource);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
bind_input_panel(struct wl_client *client,
|
|
|
|
void *data, uint32_t version, uint32_t id)
|
|
|
|
{
|
|
|
|
struct desktop_shell *shell = data;
|
|
|
|
struct wl_resource *resource;
|
|
|
|
|
|
|
|
resource = wl_client_add_object(client, &input_panel_interface,
|
|
|
|
&input_panel_implementation,
|
|
|
|
id, shell);
|
|
|
|
|
|
|
|
if (shell->input_panel.binding == NULL) {
|
|
|
|
resource->destroy = unbind_input_panel;
|
|
|
|
shell->input_panel.binding = resource;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
|
|
|
|
"interface object already bound");
|
|
|
|
wl_resource_destroy(resource);
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
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-06-19 00:34:58 +04:00
|
|
|
struct workspace *ws = get_current_workspace(switcher->shell);
|
2012-02-20 03:52:44 +04:00
|
|
|
|
2012-06-19 00:34:58 +04:00
|
|
|
wl_list_for_each(surface, &ws->layer.surface_list, layer_link) {
|
2012-02-20 03:52:44 +04:00
|
|
|
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;
|
2012-05-22 11:54:10 +04:00
|
|
|
surface->alpha = 0.25;
|
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)) {
|
2012-05-22 11:54:10 +04:00
|
|
|
surface->alpha = 0.25;
|
2012-04-01 16:13:09 +04:00
|
|
|
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;
|
2012-05-21 22:06:52 +04:00
|
|
|
next->alpha = 1.0;
|
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)
|
2012-05-21 22:06:52 +04:00
|
|
|
shsurf->fullscreen.black_surface->alpha = 1.0;
|
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
|
2012-05-31 23:27:47 +04:00
|
|
|
switcher_destroy(struct switcher *switcher)
|
2012-02-20 03:52:44 +04:00
|
|
|
{
|
|
|
|
struct weston_surface *surface;
|
2012-05-16 21:45:18 +04:00
|
|
|
struct wl_keyboard *keyboard = switcher->grab.keyboard;
|
2012-06-19 00:34:58 +04:00
|
|
|
struct workspace *ws = get_current_workspace(switcher->shell);
|
2012-02-20 03:52:44 +04:00
|
|
|
|
2012-06-19 00:34:58 +04:00
|
|
|
wl_list_for_each(surface, &ws->layer.surface_list, layer_link) {
|
2012-05-21 22:06:52 +04:00
|
|
|
surface->alpha = 1.0;
|
2012-02-20 03:52:44 +04:00
|
|
|
weston_surface_damage(surface);
|
|
|
|
}
|
|
|
|
|
2012-03-12 12:06:01 +04:00
|
|
|
if (switcher->current)
|
2012-05-16 21:45:18 +04:00
|
|
|
activate(switcher->shell, switcher->current,
|
|
|
|
(struct weston_seat *) keyboard->seat);
|
2012-02-20 03:52:44 +04:00
|
|
|
wl_list_remove(&switcher->listener.link);
|
2012-05-16 21:45:18 +04:00
|
|
|
wl_keyboard_end_grab(keyboard);
|
2012-02-20 03:52:44 +04:00
|
|
|
free(switcher);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
switcher_key(struct wl_keyboard_grab *grab,
|
2012-05-30 19:31:52 +04:00
|
|
|
uint32_t time, uint32_t key, uint32_t state_w)
|
2012-02-20 03:52:44 +04:00
|
|
|
{
|
|
|
|
struct switcher *switcher = container_of(grab, struct switcher, grab);
|
2012-05-30 19:31:52 +04:00
|
|
|
enum wl_keyboard_key_state state = state_w;
|
2012-02-20 03:52:44 +04:00
|
|
|
|
2012-05-30 19:31:52 +04:00
|
|
|
if (key == KEY_TAB && state == WL_KEYBOARD_KEY_STATE_PRESSED)
|
2012-02-20 03:52:44 +04:00
|
|
|
switcher_next(switcher);
|
2012-05-31 23:27:47 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
switcher_modifier(struct wl_keyboard_grab *grab, uint32_t serial,
|
|
|
|
uint32_t mods_depressed, uint32_t mods_latched,
|
|
|
|
uint32_t mods_locked, uint32_t group)
|
|
|
|
{
|
|
|
|
struct switcher *switcher = container_of(grab, struct switcher, grab);
|
|
|
|
struct weston_seat *seat = (struct weston_seat *) grab->keyboard->seat;
|
|
|
|
|
|
|
|
if ((seat->modifier_state & switcher->shell->binding_modifier) == 0)
|
|
|
|
switcher_destroy(switcher);
|
2012-05-10 20:28:35 +04:00
|
|
|
}
|
2012-02-20 03:52:44 +04:00
|
|
|
|
|
|
|
static const struct wl_keyboard_grab_interface switcher_grab = {
|
2012-05-31 23:27:47 +04:00
|
|
|
switcher_key,
|
|
|
|
switcher_modifier,
|
2012-02-20 03:52:44 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2012-05-30 19:31:58 +04:00
|
|
|
switcher_binding(struct wl_seat *seat, uint32_t time, uint32_t key,
|
|
|
|
void *data)
|
2012-02-20 03:52:44 +04:00
|
|
|
{
|
2012-04-16 18:31:41 +04:00
|
|
|
struct desktop_shell *shell = data;
|
2012-02-20 03:52:44 +04:00
|
|
|
struct switcher *switcher;
|
|
|
|
|
|
|
|
switcher = malloc(sizeof *switcher);
|
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);
|
|
|
|
|
2012-06-19 00:34:58 +04:00
|
|
|
lower_fullscreen_layer(switcher->shell);
|
2012-02-20 03:52:44 +04:00
|
|
|
switcher->grab.interface = &switcher_grab;
|
2012-05-16 21:45:18 +04:00
|
|
|
wl_keyboard_start_grab(seat->keyboard, &switcher->grab);
|
|
|
|
wl_keyboard_set_focus(seat->keyboard, NULL);
|
2012-02-20 03:52:44 +04:00
|
|
|
switcher_next(switcher);
|
|
|
|
}
|
|
|
|
|
2012-02-29 21:53:50 +04:00
|
|
|
static void
|
2012-05-30 19:31:58 +04:00
|
|
|
backlight_binding(struct wl_seat *seat, uint32_t time, uint32_t key,
|
|
|
|
void *data)
|
2012-02-29 21:53:50 +04:00
|
|
|
{
|
|
|
|
struct weston_compositor *compositor = data;
|
|
|
|
struct weston_output *output;
|
2012-03-13 02:40:09 +04:00
|
|
|
long backlight_new = 0;
|
2012-02-29 21:53:50 +04:00
|
|
|
|
|
|
|
/* TODO: we're limiting to simple use cases, where we assume just
|
|
|
|
* control on the primary display. We'd have to extend later if we
|
|
|
|
* ever get support for setting backlights on random desktop LCD
|
|
|
|
* panels though */
|
|
|
|
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
|
2012-05-30 19:31:58 +04:00
|
|
|
debug_repaint_binding(struct wl_seat *seat, uint32_t time, uint32_t key,
|
|
|
|
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;
|
2012-08-09 17:44:59 +04:00
|
|
|
struct weston_plane plane;
|
2012-03-04 23:53:40 +04:00
|
|
|
|
|
|
|
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);
|
|
|
|
pixman_region32_init(&surface->input);
|
|
|
|
|
|
|
|
/* Here's the dirty little trick that makes the
|
2012-08-09 17:44:59 +04:00
|
|
|
* repaint debugging work: we move the surface to a
|
|
|
|
* different plane and force an update_transform to
|
|
|
|
* update dependent state and clear the
|
|
|
|
* geometry.dirty bit. This way the call to
|
|
|
|
* damage_below() in update_transform() does not
|
|
|
|
* add damage to the primary plane. */
|
|
|
|
|
|
|
|
weston_plane_init(&plane, 0, 0);
|
|
|
|
surface->plane = &plane;
|
2012-03-04 23:53:40 +04:00
|
|
|
weston_surface_update_transform(surface);
|
|
|
|
shell->debug_repaint_surface = surface;
|
2012-08-09 17:44:59 +04:00
|
|
|
surface->plane = &compositor->primary_plane;
|
|
|
|
weston_plane_release(&plane);
|
2012-03-04 23:53:40 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-31 01:47:21 +04:00
|
|
|
|
|
|
|
static void
|
|
|
|
fan_debug_repaint_binding(struct wl_seat *seat, uint32_t time, uint32_t key,
|
|
|
|
void *data)
|
|
|
|
{
|
|
|
|
struct desktop_shell *shell = data;
|
|
|
|
struct weston_compositor *compositor = shell->compositor;
|
|
|
|
compositor->fan_debug = !compositor->fan_debug;
|
|
|
|
weston_compositor_damage_all(compositor);
|
|
|
|
}
|
|
|
|
|
2012-05-26 21:41:06 +04:00
|
|
|
static void
|
2012-05-30 19:31:58 +04:00
|
|
|
force_kill_binding(struct wl_seat *seat, uint32_t time, uint32_t key,
|
|
|
|
void *data)
|
2012-05-26 21:41:06 +04:00
|
|
|
{
|
2012-08-13 23:27:27 +04:00
|
|
|
struct wl_surface *focus_surface;
|
2012-05-26 21:41:06 +04:00
|
|
|
struct wl_client *client;
|
|
|
|
pid_t pid;
|
|
|
|
|
2012-08-13 23:27:27 +04:00
|
|
|
focus_surface = seat->keyboard->focus;
|
|
|
|
if (!focus_surface)
|
|
|
|
return;
|
|
|
|
|
|
|
|
client = focus_surface->resource.client;
|
2012-09-27 18:48:35 +04:00
|
|
|
wl_client_get_credentials(client, &pid, NULL, NULL);
|
|
|
|
|
|
|
|
/* Skip clients that we launched ourselves (the credentials of
|
|
|
|
* the socketpair is ours) */
|
|
|
|
if (pid == getpid())
|
|
|
|
return;
|
2012-05-26 21:41:06 +04:00
|
|
|
|
2012-05-30 19:31:58 +04:00
|
|
|
kill(pid, SIGKILL);
|
2012-05-26 21:41:06 +04:00
|
|
|
}
|
|
|
|
|
2012-06-13 02:01:22 +04:00
|
|
|
static void
|
|
|
|
workspace_up_binding(struct wl_seat *seat, uint32_t time,
|
|
|
|
uint32_t key, void *data)
|
|
|
|
{
|
|
|
|
struct desktop_shell *shell = data;
|
|
|
|
unsigned int new_index = shell->workspaces.current;
|
|
|
|
|
2012-06-26 05:35:29 +04:00
|
|
|
if (shell->locked)
|
2012-06-25 22:03:13 +04:00
|
|
|
return;
|
2012-06-13 02:01:22 +04:00
|
|
|
if (new_index != 0)
|
|
|
|
new_index--;
|
|
|
|
|
|
|
|
change_workspace(shell, new_index);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
workspace_down_binding(struct wl_seat *seat, uint32_t time,
|
|
|
|
uint32_t key, void *data)
|
|
|
|
{
|
|
|
|
struct desktop_shell *shell = data;
|
|
|
|
unsigned int new_index = shell->workspaces.current;
|
|
|
|
|
2012-06-26 05:35:29 +04:00
|
|
|
if (shell->locked)
|
2012-06-25 22:03:13 +04:00
|
|
|
return;
|
2012-06-13 02:01:22 +04:00
|
|
|
if (new_index < shell->workspaces.num - 1)
|
|
|
|
new_index++;
|
|
|
|
|
|
|
|
change_workspace(shell, new_index);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
workspace_f_binding(struct wl_seat *seat, uint32_t time,
|
|
|
|
uint32_t key, void *data)
|
|
|
|
{
|
|
|
|
struct desktop_shell *shell = data;
|
|
|
|
unsigned int new_index;
|
|
|
|
|
2012-06-26 05:35:29 +04:00
|
|
|
if (shell->locked)
|
2012-06-25 22:03:13 +04:00
|
|
|
return;
|
2012-06-13 02:01:22 +04:00
|
|
|
new_index = key - KEY_F1;
|
|
|
|
if (new_index >= shell->workspaces.num)
|
|
|
|
new_index = shell->workspaces.num - 1;
|
|
|
|
|
|
|
|
change_workspace(shell, new_index);
|
|
|
|
}
|
|
|
|
|
2012-08-30 00:13:00 +04:00
|
|
|
static void
|
|
|
|
workspace_move_surface_up_binding(struct wl_seat *seat, uint32_t time,
|
|
|
|
uint32_t key, void *data)
|
|
|
|
{
|
|
|
|
struct desktop_shell *shell = data;
|
|
|
|
unsigned int new_index = shell->workspaces.current;
|
|
|
|
|
|
|
|
if (shell->locked)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (new_index != 0)
|
|
|
|
new_index--;
|
|
|
|
|
|
|
|
take_surface_to_workspace_by_seat(shell, seat, new_index);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
workspace_move_surface_down_binding(struct wl_seat *seat, uint32_t time,
|
|
|
|
uint32_t key, void *data)
|
|
|
|
{
|
|
|
|
struct desktop_shell *shell = data;
|
|
|
|
unsigned int new_index = shell->workspaces.current;
|
|
|
|
|
|
|
|
if (shell->locked)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (new_index < shell->workspaces.num - 1)
|
|
|
|
new_index++;
|
|
|
|
|
|
|
|
take_surface_to_workspace_by_seat(shell, seat, new_index);
|
|
|
|
}
|
2012-06-13 02:01:22 +04:00
|
|
|
|
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);
|
2012-06-13 02:01:22 +04:00
|
|
|
struct workspace **ws;
|
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);
|
|
|
|
|
2012-05-16 16:04:19 +04:00
|
|
|
wl_list_remove(&shell->lock_listener.link);
|
|
|
|
wl_list_remove(&shell->unlock_listener.link);
|
2012-06-21 23:52:17 +04:00
|
|
|
wl_list_remove(&shell->show_input_panel_listener.link);
|
|
|
|
wl_list_remove(&shell->hide_input_panel_listener.link);
|
2012-05-16 16:04:19 +04:00
|
|
|
|
2012-06-13 02:01:22 +04:00
|
|
|
wl_array_for_each(ws, &shell->workspaces.array)
|
|
|
|
workspace_destroy(*ws);
|
|
|
|
wl_array_release(&shell->workspaces.array);
|
|
|
|
|
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;
|
2012-06-13 02:01:22 +04:00
|
|
|
int i, num_workspace_bindings;
|
2012-04-20 19:54:25 +04:00
|
|
|
|
|
|
|
/* fixed bindings */
|
2012-05-30 19:31:58 +04:00
|
|
|
weston_compositor_add_key_binding(ec, KEY_BACKSPACE,
|
|
|
|
MODIFIER_CTRL | MODIFIER_ALT,
|
|
|
|
terminate_binding, ec);
|
|
|
|
weston_compositor_add_button_binding(ec, BTN_LEFT, 0,
|
|
|
|
click_to_activate_binding,
|
|
|
|
shell);
|
|
|
|
weston_compositor_add_axis_binding(ec, WL_POINTER_AXIS_VERTICAL_SCROLL,
|
|
|
|
MODIFIER_SUPER | MODIFIER_ALT,
|
|
|
|
surface_opacity_binding, NULL);
|
|
|
|
weston_compositor_add_axis_binding(ec, WL_POINTER_AXIS_VERTICAL_SCROLL,
|
|
|
|
MODIFIER_SUPER, zoom_axis_binding,
|
|
|
|
NULL);
|
2012-04-20 19:54:25 +04:00
|
|
|
|
|
|
|
/* configurable bindings */
|
|
|
|
mod = shell->binding_modifier;
|
2012-05-30 19:31:58 +04:00
|
|
|
weston_compositor_add_key_binding(ec, KEY_PAGEUP, mod,
|
|
|
|
zoom_key_binding, NULL);
|
|
|
|
weston_compositor_add_key_binding(ec, KEY_PAGEDOWN, mod,
|
|
|
|
zoom_key_binding, NULL);
|
|
|
|
weston_compositor_add_button_binding(ec, BTN_LEFT, mod, move_binding,
|
|
|
|
shell);
|
|
|
|
weston_compositor_add_button_binding(ec, BTN_MIDDLE, mod,
|
|
|
|
resize_binding, shell);
|
|
|
|
weston_compositor_add_button_binding(ec, BTN_RIGHT, mod,
|
|
|
|
rotate_binding, NULL);
|
|
|
|
weston_compositor_add_key_binding(ec, KEY_TAB, mod, switcher_binding,
|
|
|
|
shell);
|
|
|
|
weston_compositor_add_key_binding(ec, KEY_F9, mod, backlight_binding,
|
|
|
|
ec);
|
|
|
|
weston_compositor_add_key_binding(ec, KEY_BRIGHTNESSDOWN, 0,
|
|
|
|
backlight_binding, ec);
|
|
|
|
weston_compositor_add_key_binding(ec, KEY_F10, mod, backlight_binding,
|
|
|
|
ec);
|
|
|
|
weston_compositor_add_key_binding(ec, KEY_BRIGHTNESSUP, 0,
|
|
|
|
backlight_binding, ec);
|
2012-06-28 22:13:10 +04:00
|
|
|
weston_compositor_add_key_binding(ec, KEY_SPACE, mod | MODIFIER_SHIFT,
|
2012-05-30 19:31:58 +04:00
|
|
|
debug_repaint_binding, shell);
|
2012-08-31 01:47:21 +04:00
|
|
|
weston_compositor_add_key_binding(ec, KEY_SPACE, mod | MODIFIER_ALT,
|
|
|
|
fan_debug_repaint_binding, shell);
|
2012-05-30 19:31:58 +04:00
|
|
|
weston_compositor_add_key_binding(ec, KEY_K, mod,
|
|
|
|
force_kill_binding, shell);
|
2012-06-13 02:01:22 +04:00
|
|
|
weston_compositor_add_key_binding(ec, KEY_UP, mod,
|
|
|
|
workspace_up_binding, shell);
|
|
|
|
weston_compositor_add_key_binding(ec, KEY_DOWN, mod,
|
|
|
|
workspace_down_binding, shell);
|
2012-08-30 00:13:00 +04:00
|
|
|
weston_compositor_add_key_binding(ec, KEY_UP, mod | MODIFIER_SHIFT,
|
|
|
|
workspace_move_surface_up_binding,
|
|
|
|
shell);
|
|
|
|
weston_compositor_add_key_binding(ec, KEY_DOWN, mod | MODIFIER_SHIFT,
|
|
|
|
workspace_move_surface_down_binding,
|
|
|
|
shell);
|
2012-06-13 02:01:22 +04:00
|
|
|
|
|
|
|
/* Add bindings for mod+F[1-6] for workspace 1 to 6. */
|
|
|
|
if (shell->workspaces.num > 1) {
|
|
|
|
num_workspace_bindings = shell->workspaces.num;
|
|
|
|
if (num_workspace_bindings > 6)
|
|
|
|
num_workspace_bindings = 6;
|
|
|
|
for (i = 0; i < num_workspace_bindings; i++)
|
|
|
|
weston_compositor_add_key_binding(ec, KEY_F1 + i, mod,
|
|
|
|
workspace_f_binding,
|
|
|
|
shell);
|
|
|
|
}
|
2012-04-20 19:54:25 +04:00
|
|
|
}
|
|
|
|
|
2011-05-03 06:09:20 +04:00
|
|
|
WL_EXPORT int
|
2012-09-11 22:06:27 +04:00
|
|
|
module_init(struct weston_compositor *ec)
|
2011-01-18 15:53:49 +03:00
|
|
|
{
|
2012-08-10 18:05:39 +04:00
|
|
|
struct weston_seat *seat;
|
2012-04-16 18:31:41 +04:00
|
|
|
struct desktop_shell *shell;
|
2012-06-13 02:01:22 +04:00
|
|
|
struct workspace **pws;
|
|
|
|
unsigned int i;
|
2012-09-25 18:57:01 +04:00
|
|
|
struct wl_event_loop *loop;
|
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-06-21 23:52:17 +04:00
|
|
|
shell->show_input_panel_listener.notify = show_input_panels;
|
|
|
|
wl_signal_add(&ec->show_input_panel_signal, &shell->show_input_panel_listener);
|
|
|
|
shell->hide_input_panel_listener.notify = hide_input_panels;
|
|
|
|
wl_signal_add(&ec->hide_input_panel_signal, &shell->hide_input_panel_listener);
|
2012-04-18 05:06:18 +04:00
|
|
|
ec->ping_handler = ping_handler;
|
2012-07-19 22:02:00 +04:00
|
|
|
ec->shell_interface.shell = shell;
|
2012-04-19 17:18:18 +04:00
|
|
|
ec->shell_interface.create_shell_surface = create_shell_surface;
|
|
|
|
ec->shell_interface.set_toplevel = set_toplevel;
|
2012-05-19 00:37:43 +04:00
|
|
|
ec->shell_interface.set_transient = set_transient;
|
2012-05-18 21:46:27 +04:00
|
|
|
ec->shell_interface.move = surface_move;
|
2012-05-23 00:56:23 +04:00
|
|
|
ec->shell_interface.resize = surface_resize;
|
2011-01-18 15:53:49 +03:00
|
|
|
|
2011-11-30 18:26:35 +04:00
|
|
|
wl_list_init(&shell->screensaver.surfaces);
|
2012-06-21 23:52:17 +04:00
|
|
|
wl_list_init(&shell->input_panel.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);
|
2012-06-13 02:01:22 +04:00
|
|
|
weston_layer_init(&shell->background_layer, &shell->panel_layer.link);
|
|
|
|
weston_layer_init(&shell->lock_layer, NULL);
|
2012-08-09 20:50:43 +04:00
|
|
|
weston_layer_init(&shell->input_panel_layer, NULL);
|
2012-06-13 02:01:22 +04:00
|
|
|
|
|
|
|
wl_array_init(&shell->workspaces.array);
|
2012-08-30 00:13:01 +04:00
|
|
|
wl_list_init(&shell->workspaces.client_list);
|
2012-02-29 21:42:35 +04:00
|
|
|
|
2012-01-26 01:57:11 +04:00
|
|
|
shell_configuration(shell);
|
2011-12-07 13:49:52 +04:00
|
|
|
|
2012-06-13 02:01:22 +04:00
|
|
|
for (i = 0; i < shell->workspaces.num; i++) {
|
|
|
|
pws = wl_array_add(&shell->workspaces.array, sizeof *pws);
|
|
|
|
if (pws == NULL)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
*pws = workspace_create();
|
|
|
|
if (*pws == NULL)
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
activate_workspace(shell, 0);
|
|
|
|
|
2012-08-30 00:13:00 +04:00
|
|
|
wl_list_init(&shell->workspaces.anim_sticky_list);
|
2012-06-13 02:01:23 +04:00
|
|
|
wl_list_init(&shell->workspaces.animation.link);
|
|
|
|
shell->workspaces.animation.frame = animate_workspace_change_frame;
|
|
|
|
|
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-06-21 23:52:17 +04:00
|
|
|
if (wl_display_add_global(ec->wl_display, &input_panel_interface,
|
|
|
|
shell, bind_input_panel) == NULL)
|
|
|
|
return -1;
|
|
|
|
|
2012-08-30 00:13:01 +04:00
|
|
|
if (wl_display_add_global(ec->wl_display, &workspace_manager_interface,
|
|
|
|
shell, bind_workspace_manager) == NULL)
|
|
|
|
return -1;
|
|
|
|
|
2012-01-17 20:07:42 +04:00
|
|
|
shell->child.deathstamp = weston_compositor_get_time();
|
2012-09-25 18:57:01 +04:00
|
|
|
|
|
|
|
loop = wl_display_get_event_loop(ec->wl_display);
|
|
|
|
wl_event_loop_add_idle(loop, launch_desktop_shell_process, shell);
|
2011-11-03 16:11:32 +04:00
|
|
|
|
2012-08-10 18:05:39 +04:00
|
|
|
wl_list_for_each(seat, &ec->seat_list, link)
|
|
|
|
create_pointer_focus_listener(seat);
|
2012-06-05 17:58:51 +04:00
|
|
|
|
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;
|
|
|
|
}
|