[RFC weston 5/6] desktop-shell: Remove stuff handled by libweston-desktop
Quentin Glidic
sardemff7+wayland at sardemff7.net
Sun Jul 17 08:59:22 UTC 2016
From: Quentin Glidic <sardemff7+git at sardemff7.net>
Signed-off-by: Quentin Glidic <sardemff7+git at sardemff7.net>
---
desktop-shell/shell.c | 1557 +++++++-----------------------------------------
desktop-shell/shell.h | 2 +-
libweston/compositor.h | 29 -
shared/helpers.h | 11 +
4 files changed, 220 insertions(+), 1379 deletions(-)
diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index d077883..4c103fd 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -40,7 +40,6 @@
#include "weston-desktop-shell-server-protocol.h"
#include "shared/config-parser.h"
#include "shared/helpers.h"
-#include "xdg-shell-unstable-v5-server-protocol.h"
#include "libweston-desktop/libweston-desktop.h"
#define DEFAULT_NUM_WORKSPACES 1
@@ -59,13 +58,6 @@ struct focus_state {
struct wl_listener surface_destroy_listener;
};
-enum shell_surface_type {
- SHELL_SURFACE_NONE,
- SHELL_SURFACE_TOPLEVEL,
- SHELL_SURFACE_POPUP,
- SHELL_SURFACE_XWAYLAND
-};
-
struct shell_client;
/*
@@ -109,23 +101,16 @@ struct shell_client;
struct shell_surface {
struct wl_resource *resource;
struct wl_signal destroy_signal;
- struct shell_client *owner;
struct wl_resource *owner_resource;
struct weston_desktop_surface *desktop_surface;
struct weston_surface *surface;
struct weston_view *view;
int32_t last_width, last_height;
- struct wl_listener surface_destroy_listener;
struct wl_listener resource_destroy_listener;
- struct weston_surface *parent;
- struct wl_list children_list; /* child surfaces of this one */
- struct wl_list children_link; /* sibling surfaces of this one */
struct desktop_shell *shell;
- enum shell_surface_type type;
- char *title, *class;
int32_t saved_x, saved_y;
bool saved_position_valid;
bool saved_rotation_valid;
@@ -137,18 +122,6 @@ struct shell_surface {
struct weston_matrix rotation;
} rotation;
- struct {
- struct wl_list grab_link;
- int32_t x, y;
- struct shell_seat *shseat;
- uint32_t serial;
- } popup;
-
- struct {
- int32_t x, y;
- uint32_t flags;
- } transient;
-
struct {
enum wl_shell_surface_fullscreen_method type;
struct weston_transform transform; /* matrix from x, y */
@@ -160,23 +133,10 @@ struct shell_surface {
struct weston_output *fullscreen_output;
struct weston_output *output;
- struct wl_list link;
-
- const struct weston_shell_client *client;
struct surface_state {
- bool maximized;
- bool fullscreen;
- bool relative;
bool lowered;
- } state, next_state, requested_state; /* surface states */
- bool state_changed;
- bool state_requested;
-
- struct {
- int32_t x, y, width, height;
- } geometry, next_geometry;
- bool has_set_geometry, has_next_geometry;
+ } state;
int focus_count;
@@ -223,17 +183,7 @@ struct shell_seat {
struct weston_surface *focused_surface;
struct wl_listener caps_changed_listener;
- struct wl_listener pointer_focus_listener;
struct wl_listener keyboard_focus_listener;
-
- struct {
- struct weston_pointer_grab grab;
- struct weston_touch_grab touch_grab;
- struct wl_list surfaces_list;
- struct wl_client *client;
- int32_t initial_up;
- enum { POINTER, TOUCH } type;
- } popup_grab;
};
struct shell_client {
@@ -267,47 +217,18 @@ get_output_panel_size(struct desktop_shell *shell,
static void
shell_surface_update_child_surface_layers(struct shell_surface *shsurf);
-static bool
-shell_surface_is_wl_shell_surface(struct shell_surface *shsurf);
-
-static bool
-shell_surface_is_xdg_surface(struct shell_surface *shsurf);
-
-static bool
-shell_surface_is_xdg_popup(struct shell_surface *shsurf);
-
-static void
-shell_surface_set_parent(struct shell_surface *shsurf,
- struct weston_surface *parent);
-
static int
shell_surface_get_label(struct weston_surface *surface, char *buf, size_t len)
{
- struct shell_surface *shsurf;
- const char *typestr[] = {
- [SHELL_SURFACE_NONE] = "unidentified",
- [SHELL_SURFACE_TOPLEVEL] = "top-level",
- [SHELL_SURFACE_POPUP] = "popup",
- [SHELL_SURFACE_XWAYLAND] = "Xwayland",
- };
const char *t, *c;
+ struct weston_desktop_surface *desktop_surface =
+ weston_surface_get_desktop_surface(surface);
- shsurf = get_shell_surface(surface);
- if (!shsurf)
- return snprintf(buf, len, "unidentified window");
-
- if (weston_surface_is_desktop_surface(surface)) {
- struct weston_desktop_surface *desktop_surface =
- weston_surface_get_desktop_surface(surface);
- t = weston_desktop_surface_get_title(desktop_surface);
- c = weston_desktop_surface_get_app_id(desktop_surface);
- } else {
- t = shsurf->title;
- c = shsurf->class;
- }
+ t = weston_desktop_surface_get_title(desktop_surface);
+ c = weston_desktop_surface_get_app_id(desktop_surface);
return snprintf(buf, len, "%s window%s%s%s%s%s",
- typestr[shsurf->type],
+ "top-level",
t ? " '" : "", t ?: "", t ? "'" : "",
c ? " of " : "", c ?: "");
}
@@ -372,11 +293,6 @@ get_default_view(struct weston_surface *surface)
return container_of(surface->views.next, struct weston_view, surface_link);
}
-static void
-popup_grab_end(struct weston_pointer *pointer);
-static void
-touch_popup_grab_end(struct weston_touch *touch);
-
static void
shell_grab_start(struct shell_grab *grab,
const struct weston_pointer_grab_interface *interface,
@@ -385,11 +301,8 @@ shell_grab_start(struct shell_grab *grab,
enum weston_desktop_shell_cursor cursor)
{
struct desktop_shell *shell = shsurf->shell;
- struct weston_touch *touch = weston_seat_get_touch(pointer->seat);
- popup_grab_end(pointer);
- if (touch)
- touch_popup_grab_end(touch);
+ /* TODO: undo popup grabs */
grab->grab.interface = interface;
grab->shsurf = shsurf;
@@ -492,62 +405,11 @@ get_output_work_area(void *data,
static struct shell_surface *
find_toplevel_surface(struct shell_surface *in_surface)
{
- struct shell_surface *surface = in_surface;
-
- while (surface) {
- if (surface->type == SHELL_SURFACE_TOPLEVEL)
- return surface;
- surface = get_shell_surface(surface->parent);
- }
-
/* If no top level surface was found, just use whatever surface was
originally provided. */
return in_surface;
}
-static void
-send_configure_for_surface(struct shell_surface *shsurf)
-{
- int32_t width, height;
- struct surface_state *state;
-
- if (shsurf->state_requested)
- state = &shsurf->requested_state;
- else if (shsurf->state_changed)
- state = &shsurf->next_state;
- else
- state = &shsurf->state;
-
- if (state->fullscreen) {
- width = shsurf->output->width;
- height = shsurf->output->height;
- } else if (state->maximized) {
- struct desktop_shell *shell;
- pixman_rectangle32_t area;
-
- shell = shell_surface_get_shell(shsurf);
- get_output_work_area(shell, shsurf->output, &area);
-
- width = area.width;
- height = area.height;
- } else if (shsurf->resize_edges) {
- width = shsurf->geometry.width;
- height = shsurf->geometry.height;
- } else {
- width = 0;
- height = 0;
- }
-
- shsurf->client->send_configure(shsurf->surface, width, height);
-}
-
-static void
-shell_surface_state_changed(struct shell_surface *shsurf)
-{
- if (shell_surface_is_xdg_surface(shsurf))
- send_configure_for_surface(shsurf);
-}
-
static void
shell_grab_end(struct shell_grab *grab)
{
@@ -557,7 +419,6 @@ shell_grab_end(struct shell_grab *grab)
if (grab->shsurf->resize_edges) {
grab->shsurf->resize_edges = 0;
- shell_surface_state_changed(grab->shsurf);
}
}
@@ -571,11 +432,8 @@ shell_touch_grab_start(struct shell_touch_grab *grab,
struct weston_touch *touch)
{
struct desktop_shell *shell = shsurf->shell;
- struct weston_pointer *pointer = weston_seat_get_pointer(touch->seat);
- touch_popup_grab_end(touch);
- if (pointer)
- popup_grab_end(pointer);
+ /* TODO: undop popup grabs */
grab->grab.interface = interface;
grab->shsurf = shsurf;
@@ -1586,7 +1444,8 @@ surface_touch_move(struct shell_surface *shsurf, struct weston_touch *touch)
if (!shsurf)
return -1;
- if (shsurf->state.fullscreen || shsurf->state.maximized)
+ if (weston_desktop_surface_get_fullscreen(shsurf->desktop_surface) ||
+ weston_desktop_surface_get_maximized(shsurf->desktop_surface))
return 0;
move = malloc(sizeof *move);
@@ -1635,6 +1494,7 @@ constrain_position(struct weston_move_grab *move, int *cx, int *cy)
int x, y, bottom;
const int safety = 50;
pixman_rectangle32_t area;
+ struct weston_desktop_surface_geometry geometry;
x = wl_fixed_to_int(pointer->x + move->dx);
y = wl_fixed_to_int(pointer->y + move->dy);
@@ -1644,15 +1504,17 @@ constrain_position(struct weston_move_grab *move, int *cx, int *cy)
get_output_work_area(shsurf->shell,
shsurf->surface->output,
&area);
+ geometry =
+ weston_desktop_surface_get_geometry(shsurf->desktop_surface);
- bottom = y + shsurf->geometry.height + shsurf->geometry.y;
+ bottom = y + geometry.height + geometry.y;
if (bottom - safety < area.y)
- y = area.y + safety - shsurf->geometry.height
- - shsurf->geometry.y;
+ y = area.y + safety - geometry.height
+ - geometry.y;
if (move->client_initiated &&
- y + shsurf->geometry.y < area.y)
- y = area.y - shsurf->geometry.y;
+ y + geometry.y < area.y)
+ y = area.y - geometry.y;
}
@@ -1728,7 +1590,8 @@ surface_move(struct shell_surface *shsurf, struct weston_pointer *pointer,
shsurf = find_toplevel_surface(shsurf);
if (shsurf->grabbed ||
- shsurf->state.fullscreen || shsurf->state.maximized)
+ weston_desktop_surface_get_fullscreen(shsurf->desktop_surface) ||
+ weston_desktop_surface_get_maximized(shsurf->desktop_surface))
return 0;
move = malloc(sizeof *move);
@@ -1761,6 +1624,7 @@ resize_grab_motion(struct weston_pointer_grab *grab, uint32_t time,
struct weston_pointer *pointer = grab->pointer;
struct shell_surface *shsurf = resize->base.shsurf;
int32_t width, height;
+ struct weston_desktop_surface_size min_size, max_size;
wl_fixed_t from_x, from_y;
wl_fixed_t to_x, to_y;
@@ -1789,31 +1653,23 @@ resize_grab_motion(struct weston_pointer_grab *grab, uint32_t time,
height += wl_fixed_to_int(to_y - from_y);
}
- if (width < 1)
- width = 1;
- if (height < 1)
- height = 1;
- shsurf->client->send_configure(shsurf->surface, width, height);
-}
-
-static void
-send_configure(struct weston_surface *surface, int32_t width, int32_t height)
-{
- struct shell_surface *shsurf = get_shell_surface(surface);
+ max_size = weston_desktop_surface_get_max_size(shsurf->desktop_surface);
+ min_size = weston_desktop_surface_get_min_size(shsurf->desktop_surface);
- assert(shsurf);
+ min_size.width = MAX(1, min_size.width);
+ min_size.height = MAX(1, min_size.height);
- if (shsurf->resource)
- wl_shell_surface_send_configure(shsurf->resource,
- shsurf->resize_edges,
- width, height);
+ if (width < min_size.width)
+ width = min_size.width;
+ else if (max_size.width > 0 && width > max_size.width)
+ width = max_size.width;
+ if (height < min_size.height)
+ height = min_size.height;
+ else if (max_size.width > 0 && width > max_size.width)
+ width = max_size.width;
+ weston_desktop_surface_set_size(shsurf->desktop_surface, width, height);
}
-static const struct weston_shell_client shell_client = {
- send_configure,
- NULL
-};
-
static void
resize_grab_button(struct weston_pointer_grab *grab,
uint32_t time, uint32_t button, uint32_t state_w)
@@ -1893,9 +1749,11 @@ surface_resize(struct shell_surface *shsurf,
const unsigned resize_leftright =
WL_SHELL_SURFACE_RESIZE_LEFT | WL_SHELL_SURFACE_RESIZE_RIGHT;
const unsigned resize_any = resize_topbottom | resize_leftright;
+ struct weston_desktop_surface_geometry geometry;
if (shsurf->grabbed ||
- shsurf->state.fullscreen || shsurf->state.maximized)
+ weston_desktop_surface_get_fullscreen(shsurf->desktop_surface) ||
+ weston_desktop_surface_get_maximized(shsurf->desktop_surface))
return 0;
/* Check for invalid edge combinations. */
@@ -1910,11 +1768,11 @@ surface_resize(struct shell_surface *shsurf,
resize->edges = edges;
- resize->width = shsurf->geometry.width;
- resize->height = shsurf->geometry.height;
+ geometry = weston_desktop_surface_get_geometry(shsurf->desktop_surface);
+ resize->width = geometry.width;
+ resize->height = geometry.height;
shsurf->resize_edges = edges;
- shell_surface_state_changed(shsurf);
shell_grab_start(&resize->base, &resize_grab_interface, shsurf,
pointer, edges);
@@ -1983,128 +1841,18 @@ static const struct weston_pointer_grab_interface busy_cursor_grab_interface = {
busy_cursor_grab_cancel,
};
-static void
-set_busy_cursor(struct shell_surface *shsurf, struct weston_pointer *pointer)
-{
- struct shell_grab *grab;
-
- if (pointer->grab->interface == &busy_cursor_grab_interface)
- return;
-
- grab = malloc(sizeof *grab);
- if (!grab)
- return;
-
- shell_grab_start(grab, &busy_cursor_grab_interface, shsurf, pointer,
- WESTON_DESKTOP_SHELL_CURSOR_BUSY);
- /* Mark the shsurf as ungrabbed so that button binding is able
- * to move it. */
- shsurf->grabbed = 0;
-}
-
-static int
-xdg_ping_timeout_handler(void *data)
-{
- struct shell_client *sc = data;
- struct weston_seat *seat;
- struct shell_surface *shsurf;
-
- /* Client is not responding */
- sc->unresponsive = 1;
- wl_list_for_each(seat, &sc->shell->compositor->seat_list, link) {
- struct weston_pointer *pointer = weston_seat_get_pointer(seat);
-
- if (!pointer ||
- !pointer->focus ||
- !pointer->focus->surface->resource)
- continue;
-
- shsurf = get_shell_surface(pointer->focus->surface);
- if (shsurf && shsurf->resource &&
- wl_resource_get_client(shsurf->resource) == sc->client)
- set_busy_cursor(shsurf, pointer);
- }
-
- return 1;
-}
-
-static void
-handle_xdg_ping(struct shell_surface *shsurf, uint32_t serial)
-{
- struct weston_compositor *compositor = shsurf->shell->compositor;
- struct shell_client *sc = shsurf->owner;
- struct wl_event_loop *loop;
- static const int ping_timeout = 200;
-
- if (sc->unresponsive) {
- xdg_ping_timeout_handler(sc);
- return;
- }
-
- sc->ping_serial = serial;
- loop = wl_display_get_event_loop(compositor->wl_display);
- if (sc->ping_timer == NULL)
- sc->ping_timer =
- wl_event_loop_add_timer(loop,
- xdg_ping_timeout_handler, sc);
- if (sc->ping_timer == NULL)
- return;
-
- wl_event_source_timer_update(sc->ping_timer, ping_timeout);
-
- if (shell_surface_is_xdg_surface(shsurf) ||
- shell_surface_is_xdg_popup(shsurf))
- xdg_shell_send_ping(sc->resource, serial);
- else if (shell_surface_is_wl_shell_surface(shsurf)
- && shsurf->resource)
- wl_shell_surface_send_ping(shsurf->resource, serial);
-}
-
-static void
-ping_handler(struct weston_surface *surface, uint32_t serial)
-{
- struct shell_surface *shsurf = get_shell_surface(surface);
-
- if (!shsurf)
- return;
- if (!shsurf->resource)
- return;
- if (shsurf->surface == shsurf->shell->grab_surface)
- return;
- if (!shsurf->owner)
- return;
-
- handle_xdg_ping(shsurf, serial);
-}
-
-static void
-handle_pointer_focus(struct wl_listener *listener, void *data)
-{
- struct weston_pointer *pointer = data;
- struct weston_view *view = pointer->focus;
- struct weston_compositor *compositor;
- uint32_t serial;
-
- if (!view)
- return;
-
- compositor = view->surface->compositor;
- serial = wl_display_next_serial(compositor->wl_display);
- ping_handler(view->surface, serial);
-}
-
static void
shell_surface_lose_keyboard_focus(struct shell_surface *shsurf)
{
if (--shsurf->focus_count == 0)
- shell_surface_state_changed(shsurf);
+ weston_desktop_surface_set_activated(shsurf->desktop_surface, false);
}
static void
shell_surface_gain_keyboard_focus(struct shell_surface *shsurf)
{
if (shsurf->focus_count++ == 0)
- shell_surface_state_changed(shsurf);
+ weston_desktop_surface_set_activated(shsurf->desktop_surface, true);
}
static void
@@ -2128,38 +1876,6 @@ handle_keyboard_focus(struct wl_listener *listener, void *data)
}
}
-static void
-set_title(struct shell_surface *shsurf, const char *title)
-{
- free(shsurf->title);
- shsurf->title = strdup(title);
- shsurf->surface->timeline.force_refresh = 1;
-}
-
-static void
-set_pid(struct shell_surface *shsurf, pid_t pid)
-{
- /* We have no use for it */
-}
-
-static void
-set_type(struct shell_surface *shsurf, enum shell_surface_type t)
-{
- shsurf->type = t;
- shsurf->surface->timeline.force_refresh = 1;
-}
-
-static void
-set_window_geometry(struct shell_surface *shsurf,
- int32_t x, int32_t y, int32_t width, int32_t height)
-{
- shsurf->next_geometry.x = x;
- shsurf->next_geometry.y = y;
- shsurf->next_geometry.width = width;
- shsurf->next_geometry.height = height;
- shsurf->has_next_geometry = true;
-}
-
static void
restore_output_mode(struct weston_output *output)
{
@@ -2183,76 +1899,23 @@ static struct weston_layer_entry *
shell_surface_calculate_layer_link (struct shell_surface *shsurf)
{
struct workspace *ws;
- struct weston_view *parent;
- switch (shsurf->type) {
- case SHELL_SURFACE_XWAYLAND:
+ if (weston_desktop_surface_get_fullscreen(shsurf->desktop_surface) &&
+ !shsurf->state.lowered) {
return &shsurf->shell->fullscreen_layer.view_list;
-
- case SHELL_SURFACE_NONE:
- return NULL;
-
- case SHELL_SURFACE_POPUP:
- case SHELL_SURFACE_TOPLEVEL:
- if (shsurf->state.fullscreen && !shsurf->state.lowered) {
- return &shsurf->shell->fullscreen_layer.view_list;
- } else if (shsurf->parent) {
- /* Move the surface to its parent layer so
- * that surfaces which are transient for
- * fullscreen surfaces don't get hidden by the
- * fullscreen surfaces. */
-
- /* TODO: Handle a parent with multiple views */
- parent = get_default_view(shsurf->parent);
- if (parent)
- return container_of(parent->layer_link.link.prev,
- struct weston_layer_entry, link);
- }
-
- /* Move the surface to a normal workspace layer so that surfaces
- * which were previously fullscreen or transient are no longer
- * rendered on top. */
- ws = get_current_workspace(shsurf->shell);
- return &ws->layer.view_list;
}
- assert(0 && "Unknown shell surface type");
+ /* Move the surface to a normal workspace layer so that surfaces
+ * which were previously fullscreen or transient are no longer
+ * rendered on top. */
+ ws = get_current_workspace(shsurf->shell);
+ return &ws->layer.view_list;
}
static void
shell_surface_update_child_surface_layers (struct shell_surface *shsurf)
{
- struct shell_surface *child;
- struct weston_layer_entry *prev;
-
- if (weston_surface_is_desktop_surface(shsurf->surface)) {
- struct weston_desktop_surface* desktop_surface =
- weston_surface_get_desktop_surface(shsurf->surface);
- weston_desktop_surface_update_layer(desktop_surface);
- return;
- }
-
- /* Move the child layers to the same workspace as shsurf. They will be
- * stacked above shsurf. */
- wl_list_for_each_reverse(child, &shsurf->children_list, children_link) {
- if (shsurf->view->layer_link.link.prev != &child->view->layer_link.link) {
- weston_view_damage_below(child->view);
- weston_view_geometry_dirty(child->view);
- prev = container_of(shsurf->view->layer_link.link.prev,
- struct weston_layer_entry, link);
- weston_layer_entry_remove(&child->view->layer_link);
- weston_layer_entry_insert(prev,
- &child->view->layer_link);
- weston_view_geometry_dirty(child->view);
- weston_surface_damage(child->surface);
-
- /* Recurse. We don’t expect this to recurse very far (if
- * at all) because that would imply we have transient
- * (or popup) children of transient surfaces, which
- * would be unusual. */
- shell_surface_update_child_surface_layers(child);
- }
- }
+ weston_desktop_surface_update_layer(shsurf->desktop_surface);
}
/* Update the surface’s layer. Mark both the old and new views as having dirty
@@ -2281,24 +1944,6 @@ shell_surface_update_layer(struct shell_surface *shsurf)
shell_surface_update_child_surface_layers(shsurf);
}
-static void
-shell_surface_set_parent(struct shell_surface *shsurf,
- struct weston_surface *parent)
-{
- shsurf->parent = parent;
-
- wl_list_remove(&shsurf->children_link);
- wl_list_init(&shsurf->children_link);
-
- /* Insert into the parent surface’s child list. */
- if (parent != NULL) {
- struct shell_surface *parent_shsurf = get_shell_surface(parent);
- if (parent_shsurf != NULL)
- wl_list_insert(&parent_shsurf->children_list,
- &shsurf->children_link);
- }
-}
-
static void
shell_surface_set_output(struct shell_surface *shsurf,
struct weston_output *output)
@@ -2315,66 +1960,6 @@ shell_surface_set_output(struct shell_surface *shsurf,
shsurf->output = get_default_output(es->compositor);
}
-static void
-surface_clear_next_states(struct shell_surface *shsurf)
-{
- shsurf->next_state.maximized = false;
- shsurf->next_state.fullscreen = false;
-
- if ((shsurf->next_state.maximized != shsurf->state.maximized) ||
- (shsurf->next_state.fullscreen != shsurf->state.fullscreen))
- shsurf->state_changed = true;
-}
-
-static void
-set_toplevel(struct shell_surface *shsurf)
-{
- shell_surface_set_parent(shsurf, NULL);
- surface_clear_next_states(shsurf);
- set_type(shsurf, SHELL_SURFACE_TOPLEVEL);
-
- /* The layer_link is updated in set_surface_type(),
- * called from configure. */
-}
-
-static void
-set_transient(struct shell_surface *shsurf,
- struct weston_surface *parent, int x, int y, uint32_t flags)
-{
- assert(parent != NULL);
-
- shell_surface_set_parent(shsurf, parent);
-
- surface_clear_next_states(shsurf);
-
- shsurf->transient.x = x;
- shsurf->transient.y = y;
- shsurf->transient.flags = flags;
-
- shsurf->next_state.relative = true;
- shsurf->state_changed = true;
- set_type(shsurf, SHELL_SURFACE_TOPLEVEL);
-
- /* The layer_link is updated in set_surface_type(),
- * called from configure. */
-}
-
-static void
-set_fullscreen(struct shell_surface *shsurf,
- uint32_t method,
- uint32_t framerate,
- struct weston_output *output)
-{
- shell_surface_set_output(shsurf, output);
- set_type(shsurf, SHELL_SURFACE_TOPLEVEL);
-
- shsurf->fullscreen_output = shsurf->output;
- shsurf->fullscreen.type = method;
- shsurf->fullscreen.framerate = framerate;
-
- send_configure_for_surface(shsurf);
-}
-
static void
weston_view_set_initial_position(struct weston_view *view,
struct desktop_shell *shell);
@@ -2461,71 +2046,6 @@ set_minimized(struct weston_surface *surface)
}
-/* This is only ever called from set_surface_type(), so there’s no need to
- * update layer_links here, since they’ll be updated when we return. */
-static int
-reset_surface_type(struct shell_surface *surface)
-{
- if (surface->state.fullscreen)
- unset_fullscreen(surface);
- if (surface->state.maximized)
- unset_maximized(surface);
-
- return 0;
-}
-
-static void
-set_full_output(struct shell_surface *shsurf)
-{
- shsurf->saved_x = shsurf->view->geometry.x;
- shsurf->saved_y = shsurf->view->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);
- weston_view_geometry_dirty(shsurf->view);
- shsurf->saved_rotation_valid = true;
- }
-}
-
-static void
-set_surface_type(struct shell_surface *shsurf)
-{
- struct weston_surface *pes = shsurf->parent;
- struct weston_view *pev = get_default_view(pes);
-
- reset_surface_type(shsurf);
-
- shsurf->state = shsurf->next_state;
- shsurf->state_changed = false;
-
- switch (shsurf->type) {
- case SHELL_SURFACE_TOPLEVEL:
- if (shsurf->state.maximized || shsurf->state.fullscreen) {
- set_full_output(shsurf);
- } else if (shsurf->state.relative && pev) {
- weston_view_set_position(shsurf->view,
- pev->geometry.x + shsurf->transient.x,
- pev->geometry.y + shsurf->transient.y);
- }
- break;
-
- case SHELL_SURFACE_XWAYLAND:
- weston_view_set_position(shsurf->view, shsurf->transient.x,
- shsurf->transient.y);
- break;
-
- case SHELL_SURFACE_POPUP:
- case SHELL_SURFACE_NONE:
- default:
- break;
- }
-
- /* Update the surface’s layer. */
- shell_surface_update_layer(shsurf);
-}
-
static struct desktop_shell *
shell_surface_get_shell(struct shell_surface *shsurf)
{
@@ -2602,7 +2122,7 @@ shell_ensure_fullscreen_black_view(struct shell_surface *shsurf)
{
struct weston_output *output = shsurf->fullscreen_output;
- assert(shsurf->state.fullscreen);
+ assert(weston_desktop_surface_get_fullscreen(shsurf->desktop_surface));
if (!shsurf->fullscreen.black_view)
shsurf->fullscreen.black_view =
@@ -2724,34 +2244,6 @@ shell_map_fullscreen(struct shell_surface *shsurf)
shell_configure_fullscreen(shsurf);
}
-static void
-set_xwayland(struct shell_surface *shsurf, int x, int y, uint32_t flags)
-{
- /* XXX: using the same fields for transient type */
- surface_clear_next_states(shsurf);
- shsurf->transient.x = x;
- shsurf->transient.y = y;
- shsurf->transient.flags = flags;
-
- shell_surface_set_parent(shsurf, NULL);
-
- set_type(shsurf, SHELL_SURFACE_XWAYLAND);
- shsurf->state_changed = true;
-}
-
-static void
-shell_interface_set_fullscreen(struct shell_surface *shsurf,
- uint32_t method,
- uint32_t framerate,
- struct weston_output *output)
-{
- surface_clear_next_states(shsurf);
- shsurf->next_state.fullscreen = true;
- shsurf->state_changed = true;
-
- set_fullscreen(shsurf, method, framerate, output);
-}
-
static struct weston_output *
get_focused_output(struct weston_compositor *compositor)
{
@@ -2783,39 +2275,6 @@ get_focused_output(struct weston_compositor *compositor)
return output;
}
-static void
-shell_interface_set_maximized(struct shell_surface *shsurf)
-{
- struct weston_output *output;
-
- surface_clear_next_states(shsurf);
- shsurf->next_state.maximized = true;
- shsurf->state_changed = true;
- shsurf->type = SHELL_SURFACE_TOPLEVEL;
-
- if (!weston_surface_is_mapped(shsurf->surface))
- output = get_focused_output(shsurf->surface->compositor);
- else
- output = shsurf->surface->output;
-
- shell_surface_set_output(shsurf, output);
- send_configure_for_surface(shsurf);
-}
-
-static int
-shell_interface_move(struct shell_surface *shsurf, struct weston_pointer *pointer)
-{
- return surface_move(shsurf, pointer, true);
-}
-
-static int
-shell_interface_resize(struct shell_surface *shsurf,
- struct weston_pointer *pointer,
- uint32_t edges)
-{
- return surface_resize(shsurf, pointer, edges);
-}
-
static const struct weston_pointer_grab_interface popup_grab_interface;
static void
@@ -2824,19 +2283,6 @@ destroy_shell_seat(struct wl_listener *listener, void *data)
struct shell_seat *shseat =
container_of(listener,
struct shell_seat, seat_destroy_listener);
- struct shell_surface *shsurf, *next;
-
- if (shseat->popup_grab.grab.interface == &popup_grab_interface) {
- weston_pointer_end_grab(shseat->popup_grab.grab.pointer);
- shseat->popup_grab.client = NULL;
-
- wl_list_for_each_safe(shsurf, next,
- &shseat->popup_grab.surfaces_list,
- popup.grab_link) {
- shsurf->popup.shseat = NULL;
- wl_list_init(&shsurf->popup.grab_link);
- }
- }
wl_list_remove(&shseat->seat_destroy_listener.link);
free(shseat);
@@ -2846,12 +2292,10 @@ static void
shell_seat_caps_changed(struct wl_listener *listener, void *data)
{
struct weston_keyboard *keyboard;
- struct weston_pointer *pointer;
struct shell_seat *seat;
seat = container_of(listener, struct shell_seat, caps_changed_listener);
keyboard = weston_seat_get_keyboard(seat->seat);
- pointer = weston_seat_get_pointer(seat->seat);
if (keyboard &&
wl_list_empty(&seat->keyboard_focus_listener.link)) {
@@ -2861,15 +2305,6 @@ shell_seat_caps_changed(struct wl_listener *listener, void *data)
wl_list_remove(&seat->keyboard_focus_listener.link);
wl_list_init(&seat->keyboard_focus_listener.link);
}
-
- if (pointer &&
- wl_list_empty(&seat->pointer_focus_listener.link)) {
- wl_signal_add(&pointer->focus_signal,
- &seat->pointer_focus_listener);
- } else if (!pointer) {
- wl_list_remove(&seat->pointer_focus_listener.link);
- wl_list_init(&seat->pointer_focus_listener.link);
- }
}
static struct shell_seat *
@@ -2884,7 +2319,6 @@ create_shell_seat(struct weston_seat *seat)
}
shseat->seat = seat;
- wl_list_init(&shseat->popup_grab.surfaces_list);
shseat->seat_destroy_listener.notify = destroy_shell_seat;
wl_signal_add(&seat->destroy_signal,
@@ -2893,8 +2327,6 @@ create_shell_seat(struct weston_seat *seat)
shseat->keyboard_focus_listener.notify = handle_keyboard_focus;
wl_list_init(&shseat->keyboard_focus_listener.link);
- shseat->pointer_focus_listener.notify = handle_pointer_focus;
- wl_list_init(&shseat->pointer_focus_listener.link);
shseat->caps_changed_listener.notify = shell_seat_caps_changed;
wl_signal_add(&seat->updated_caps_signal,
@@ -2917,412 +2349,9 @@ get_shell_seat(struct weston_seat *seat)
}
static void
-popup_grab_focus(struct weston_pointer_grab *grab)
+destroy_shell_surface(struct shell_surface *shsurf)
{
- struct weston_pointer *pointer = grab->pointer;
- struct weston_view *view;
- struct shell_seat *shseat =
- container_of(grab, struct shell_seat, popup_grab.grab);
- struct wl_client *client = shseat->popup_grab.client;
- wl_fixed_t sx, sy;
-
- view = weston_compositor_pick_view(pointer->seat->compositor,
- pointer->x, pointer->y,
- &sx, &sy);
-
- if (view && view->surface->resource &&
- wl_resource_get_client(view->surface->resource) == client) {
- weston_pointer_set_focus(pointer, view, sx, sy);
- } else {
- weston_pointer_clear_focus(pointer);
- }
-}
-
-static void
-popup_grab_motion(struct weston_pointer_grab *grab, uint32_t time,
- struct weston_pointer_motion_event *event)
-{
- struct weston_pointer *pointer = grab->pointer;
- struct wl_resource *resource;
- struct wl_list *resource_list;
- wl_fixed_t x, y;
- wl_fixed_t sx, sy;
-
- if (pointer->focus) {
- weston_pointer_motion_to_abs(pointer, event, &x, &y);
- weston_view_from_global_fixed(pointer->focus, x, y,
- &pointer->sx, &pointer->sy);
- }
-
- weston_pointer_move(pointer, event);
-
- if (!pointer->focus_client)
- return;
-
- resource_list = &pointer->focus_client->pointer_resources;
- wl_resource_for_each(resource, resource_list) {
- weston_view_from_global_fixed(pointer->focus,
- pointer->x, pointer->y,
- &sx, &sy);
- wl_pointer_send_motion(resource, time, sx, sy);
- }
-}
-
-static void
-popup_grab_button(struct weston_pointer_grab *grab,
- uint32_t time, uint32_t button, uint32_t state_w)
-{
- struct wl_resource *resource;
- struct shell_seat *shseat =
- container_of(grab, struct shell_seat, popup_grab.grab);
- struct wl_display *display = shseat->seat->compositor->wl_display;
- enum wl_pointer_button_state state = state_w;
- uint32_t serial;
- struct wl_list *resource_list = NULL;
-
- if (grab->pointer->focus_client)
- resource_list = &grab->pointer->focus_client->pointer_resources;
- if (resource_list && !wl_list_empty(resource_list)) {
- serial = wl_display_get_serial(display);
- wl_resource_for_each(resource, resource_list) {
- wl_pointer_send_button(resource, serial,
- time, button, state);
- }
- } else if (state == WL_POINTER_BUTTON_STATE_RELEASED &&
- (shseat->popup_grab.initial_up ||
- time - grab->pointer->grab_time > 500)) {
- popup_grab_end(grab->pointer);
- }
-
- if (state == WL_POINTER_BUTTON_STATE_RELEASED)
- shseat->popup_grab.initial_up = 1;
-}
-
-static void
-popup_grab_axis(struct weston_pointer_grab *grab,
- uint32_t time,
- struct weston_pointer_axis_event *event)
-{
- weston_pointer_send_axis(grab->pointer, time, event);
-}
-
-static void
-popup_grab_axis_source(struct weston_pointer_grab *grab, uint32_t source)
-{
- weston_pointer_send_axis_source(grab->pointer, source);
-}
-
-static void
-popup_grab_frame(struct weston_pointer_grab *grab)
-{
- weston_pointer_send_frame(grab->pointer);
-}
-
-static void
-popup_grab_cancel(struct weston_pointer_grab *grab)
-{
- popup_grab_end(grab->pointer);
-}
-
-static const struct weston_pointer_grab_interface popup_grab_interface = {
- popup_grab_focus,
- popup_grab_motion,
- popup_grab_button,
- popup_grab_axis,
- popup_grab_axis_source,
- popup_grab_frame,
- popup_grab_cancel,
-};
-
-static void
-touch_popup_grab_down(struct weston_touch_grab *grab, uint32_t time,
- int touch_id, wl_fixed_t x, wl_fixed_t y)
-{
- struct wl_resource *resource;
- struct shell_seat *shseat =
- container_of(grab, struct shell_seat, popup_grab.touch_grab);
- struct wl_display *display = shseat->seat->compositor->wl_display;
- uint32_t serial;
- struct wl_list *resource_list;
- wl_fixed_t sx, sy;
-
- weston_view_from_global_fixed(grab->touch->focus, x, y, &sx, &sy);
-
- resource_list = &grab->touch->focus_resource_list;
- if (!wl_list_empty(resource_list)) {
- serial = wl_display_get_serial(display);
- wl_resource_for_each(resource, resource_list) {
- wl_touch_send_down(resource, serial, time,
- grab->touch->focus->surface->resource,
- touch_id, sx, sy);
- }
- }
-}
-
-static void
-touch_popup_grab_up(struct weston_touch_grab *grab, uint32_t time, int touch_id)
-{
- struct wl_resource *resource;
- struct shell_seat *shseat =
- container_of(grab, struct shell_seat, popup_grab.touch_grab);
- struct wl_display *display = shseat->seat->compositor->wl_display;
- uint32_t serial;
- struct wl_list *resource_list;
-
- resource_list = &grab->touch->focus_resource_list;
- if (!wl_list_empty(resource_list)) {
- serial = wl_display_get_serial(display);
- wl_resource_for_each(resource, resource_list) {
- wl_touch_send_up(resource, serial, time, touch_id);
- }
- }
-}
-
-static void
-touch_popup_grab_motion(struct weston_touch_grab *grab, uint32_t time,
- int touch_id, wl_fixed_t x, wl_fixed_t y)
-{
- struct wl_resource *resource;
- struct wl_list *resource_list;
- wl_fixed_t sx, sy;
-
- weston_view_from_global_fixed(grab->touch->focus, x, y, &sx, &sy);
-
- resource_list = &grab->touch->focus_resource_list;
- if (!wl_list_empty(resource_list)) {
- wl_resource_for_each(resource, resource_list) {
- wl_touch_send_motion(resource, time, touch_id, sx, sy);
- }
- }
-}
-
-static void
-touch_popup_grab_frame(struct weston_touch_grab *grab)
-{
-}
-
-static void
-touch_popup_grab_cancel(struct weston_touch_grab *grab)
-{
- touch_popup_grab_end(grab->touch);
-}
-
-static const struct weston_touch_grab_interface touch_popup_grab_interface = {
- touch_popup_grab_down,
- touch_popup_grab_up,
- touch_popup_grab_motion,
- touch_popup_grab_frame,
- touch_popup_grab_cancel,
-};
-
-static void
-shell_surface_send_popup_done(struct shell_surface *shsurf)
-{
- if (shsurf->resource == NULL)
- return;
- else if (shell_surface_is_wl_shell_surface(shsurf))
- wl_shell_surface_send_popup_done(shsurf->resource);
- else if (shell_surface_is_xdg_popup(shsurf))
- xdg_popup_send_popup_done(shsurf->resource);
-}
-
-static void
-popup_grab_end(struct weston_pointer *pointer)
-{
- struct weston_pointer_grab *grab = pointer->grab;
- struct shell_seat *shseat =
- container_of(grab, struct shell_seat, popup_grab.grab);
- struct shell_surface *shsurf;
- struct shell_surface *next;
-
- if (pointer->grab->interface == &popup_grab_interface) {
- weston_pointer_end_grab(grab->pointer);
- shseat->popup_grab.client = NULL;
- shseat->popup_grab.grab.interface = NULL;
- assert(!wl_list_empty(&shseat->popup_grab.surfaces_list));
- /* Send the popup_done event to all the popups open */
- wl_list_for_each_safe(shsurf, next,
- &shseat->popup_grab.surfaces_list,
- popup.grab_link) {
- shell_surface_send_popup_done(shsurf);
- shsurf->popup.shseat = NULL;
- wl_list_init(&shsurf->popup.grab_link);
- }
- wl_list_init(&shseat->popup_grab.surfaces_list);
- }
-}
-
-static void
-touch_popup_grab_end(struct weston_touch *touch)
-{
- struct weston_touch_grab *grab = touch->grab;
- struct shell_seat *shseat =
- container_of(grab, struct shell_seat, popup_grab.touch_grab);
- struct shell_surface *shsurf;
- struct shell_surface *next;
-
- if (touch->grab->interface == &touch_popup_grab_interface) {
- weston_touch_end_grab(grab->touch);
- shseat->popup_grab.client = NULL;
- shseat->popup_grab.touch_grab.interface = NULL;
- assert(!wl_list_empty(&shseat->popup_grab.surfaces_list));
- /* Send the popup_done event to all the popups open */
- wl_list_for_each_safe(shsurf, next,
- &shseat->popup_grab.surfaces_list,
- popup.grab_link) {
- shell_surface_send_popup_done(shsurf);
- shsurf->popup.shseat = NULL;
- wl_list_init(&shsurf->popup.grab_link);
- }
- wl_list_init(&shseat->popup_grab.surfaces_list);
- }
-}
-
-static struct shell_surface *
-get_top_popup(struct shell_seat *shseat)
-{
- struct shell_surface *shsurf;
-
- if (wl_list_empty(&shseat->popup_grab.surfaces_list)) {
- return NULL;
- } else {
- shsurf = container_of(shseat->popup_grab.surfaces_list.next,
- struct shell_surface,
- popup.grab_link);
- return shsurf;
- }
-}
-
-static int
-add_popup_grab(struct shell_surface *shsurf,
- struct shell_seat *shseat,
- int32_t type)
-{
- struct weston_seat *seat = shseat->seat;
- struct shell_surface *parent, *top_surface;
- struct weston_pointer *pointer = weston_seat_get_pointer(seat);
- struct weston_touch *touch = weston_seat_get_touch(seat);
-
- parent = get_shell_surface(shsurf->parent);
- top_surface = get_top_popup(shseat);
- if (shell_surface_is_xdg_popup(shsurf) &&
- (!parent ||
- (top_surface == NULL && !shell_surface_is_xdg_surface(parent)) ||
- (top_surface != NULL && parent != top_surface))) {
- wl_resource_post_error(shsurf->owner_resource,
- XDG_SHELL_ERROR_NOT_THE_TOPMOST_POPUP,
- "xdg_popup was not created on the "
- "topmost popup");
- return -1;
- }
-
- if (wl_list_empty(&shseat->popup_grab.surfaces_list)) {
- shseat->popup_grab.type = type;
- shseat->popup_grab.client =
- wl_resource_get_client(shsurf->resource);
-
- if (type == POINTER) {
- shseat->popup_grab.grab.interface =
- &popup_grab_interface;
-
- /* We must make sure here that this popup was opened
- * after a mouse press, and not just by moving around
- * with other popups already open. */
- if (pointer->button_count > 0)
- shseat->popup_grab.initial_up = 0;
- } else if (type == TOUCH) {
- shseat->popup_grab.touch_grab.interface =
- &touch_popup_grab_interface;
- }
-
- wl_list_insert(&shseat->popup_grab.surfaces_list,
- &shsurf->popup.grab_link);
-
- if (type == POINTER) {
- weston_pointer_start_grab(pointer,
- &shseat->popup_grab.grab);
- } else if (type == TOUCH) {
- weston_touch_start_grab(touch,
- &shseat->popup_grab.touch_grab);
- }
- } else {
- wl_list_insert(&shseat->popup_grab.surfaces_list,
- &shsurf->popup.grab_link);
- }
-
- return 0;
-}
-
-static void
-remove_popup_grab(struct shell_surface *shsurf)
-{
- struct shell_seat *shseat = shsurf->popup.shseat;
-
- if (shell_surface_is_xdg_popup(shsurf) &&
- get_top_popup(shseat) != shsurf) {
- wl_resource_post_error(shsurf->owner_resource,
- XDG_SHELL_ERROR_NOT_THE_TOPMOST_POPUP,
- "xdg_popup was destroyed while it was "
- "not the topmost popup.");
- return;
- }
-
- wl_list_remove(&shsurf->popup.grab_link);
- wl_list_init(&shsurf->popup.grab_link);
- if (wl_list_empty(&shseat->popup_grab.surfaces_list)) {
- if (shseat->popup_grab.type == POINTER) {
- weston_pointer_end_grab(shseat->popup_grab.grab.pointer);
- shseat->popup_grab.grab.interface = NULL;
- } else if (shseat->popup_grab.type == TOUCH) {
- weston_touch_end_grab(shseat->popup_grab.touch_grab.touch);
- shseat->popup_grab.touch_grab.interface = NULL;
- }
- }
-}
-
-static int
-shell_map_popup(struct shell_surface *shsurf)
-{
- struct shell_seat *shseat = shsurf->popup.shseat;
- struct weston_view *parent_view = get_default_view(shsurf->parent);
- struct weston_pointer *pointer = weston_seat_get_pointer(shseat->seat);
- struct weston_touch *touch = weston_seat_get_touch(shseat->seat);
-
- shsurf->surface->output = parent_view->output;
- shsurf->surface->is_mapped = true;
- shsurf->view->output = parent_view->output;
-
- weston_view_set_transform_parent(shsurf->view, parent_view);
- weston_view_set_position(shsurf->view, shsurf->popup.x, shsurf->popup.y);
- weston_view_update_transform(shsurf->view);
- shsurf->view->is_mapped = true;
-
- if (pointer &&
- pointer->grab_serial == shsurf->popup.serial) {
- if (add_popup_grab(shsurf, shseat, POINTER) != 0)
- return -1;
- } else if (touch &&
- touch->grab_serial == shsurf->popup.serial) {
- if (add_popup_grab(shsurf, shseat, TOUCH) != 0)
- return -1;
- } else {
- shell_surface_send_popup_done(shsurf);
- shseat->popup_grab.client = NULL;
- }
-
- return 0;
-}
-
-static void
-destroy_shell_surface(struct shell_surface *shsurf)
-{
- struct shell_surface *child, *next;
-
- wl_signal_emit(&shsurf->destroy_signal, shsurf);
-
- if (!wl_list_empty(&shsurf->popup.grab_link)) {
- remove_popup_grab(shsurf);
- }
+ wl_signal_emit(&shsurf->destroy_signal, shsurf);
if (shsurf->fullscreen.type == WL_SHELL_SURFACE_FULLSCREEN_METHOD_DRIVER &&
shell_surface_is_top_fullscreen(shsurf))
@@ -3334,34 +2363,13 @@ destroy_shell_surface(struct shell_surface *shsurf)
/* 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;
weston_surface_set_label_func(shsurf->surface, NULL);
- free(shsurf->title);
weston_view_destroy(shsurf->view);
- wl_list_remove(&shsurf->children_link);
- wl_list_for_each_safe(child, next, &shsurf->children_list, children_link)
- shell_surface_set_parent(child, NULL);
-
- wl_list_remove(&shsurf->link);
free(shsurf);
}
-static void
-shell_handle_surface_destroy(struct wl_listener *listener, void *data)
-{
- struct shell_surface *shsurf = container_of(listener,
- struct shell_surface,
- surface_destroy_listener);
-
- if (shsurf->resource)
- wl_resource_destroy(shsurf->resource);
-
- destroy_shell_surface(shsurf);
-}
-
static void
fade_out_done_idle_cb(void *data)
{
@@ -3409,9 +2417,6 @@ handle_resource_destroy(struct wl_listener *listener, void *data)
}
}
-static void
-shell_surface_configure(struct weston_surface *, int32_t, int32_t);
-
struct shell_surface *
get_shell_surface(struct weston_surface *surface)
{
@@ -3420,44 +2425,25 @@ get_shell_surface(struct weston_surface *surface)
weston_surface_get_desktop_surface(surface);
return weston_desktop_surface_get_user_data(desktop_surface);
}
-
-
- if (surface->configure == shell_surface_configure)
- return surface->configure_private;
- else
- return NULL;
+ return NULL;
}
static struct shell_surface *
-create_common_surface(struct shell_client *owner, void *shell,
- struct weston_surface *surface,
- const struct weston_shell_client *client)
+create_common_surface(void *shell, struct weston_surface *surface)
{
struct shell_surface *shsurf;
- assert(surface->configure == NULL);
-
shsurf = calloc(1, sizeof *shsurf);
if (!shsurf) {
weston_log("no memory to allocate shell surface\n");
return NULL;
}
- shsurf->view = weston_view_create(surface);
- if (!shsurf->view) {
- weston_log("no memory to allocate shell surface\n");
- free(shsurf);
- return NULL;
- }
-
- surface->configure = shell_surface_configure;
- surface->configure_private = shsurf;
weston_surface_set_label_func(surface, shell_surface_get_label);
shsurf->resource_destroy_listener.notify = handle_resource_destroy;
wl_resource_add_destroy_listener(surface->resource,
&shsurf->resource_destroy_listener);
- shsurf->owner = owner;
shsurf->shell = (struct desktop_shell *) shell;
shsurf->unresponsive = 0;
@@ -3472,13 +2458,6 @@ create_common_surface(struct shell_client *owner, void *shell,
shsurf->output = get_default_output(shsurf->shell->compositor);
wl_signal_init(&shsurf->destroy_signal);
- shsurf->surface_destroy_listener.notify = shell_handle_surface_destroy;
- wl_signal_add(&surface->destroy_signal,
- &shsurf->surface_destroy_listener);
-
- /* init link so its safe to always remove it in destroy_shell_surface */
- wl_list_init(&shsurf->link);
- wl_list_init(&shsurf->popup.grab_link);
/* empty when not in use */
wl_list_init(&shsurf->rotation.transform.link);
@@ -3486,130 +2465,55 @@ create_common_surface(struct shell_client *owner, void *shell,
wl_list_init(&shsurf->workspace_transform.link);
- wl_list_init(&shsurf->children_link);
- wl_list_init(&shsurf->children_list);
- shsurf->parent = NULL;
-
- set_type(shsurf, SHELL_SURFACE_NONE);
-
- shsurf->client = client;
-
return shsurf;
}
-static struct shell_surface *
-create_shell_surface(void *shell, struct weston_surface *surface,
- const struct weston_shell_client *client)
-{
- return create_common_surface(NULL, shell, surface, client);
-}
-
-static bool
-shell_surface_is_wl_shell_surface(struct shell_surface *shsurf)
-{
- /* A shell surface without a resource is created from xwayland
- * and is considered a wl_shell surface for now. */
- return false;
-}
-
-
-static bool
-shell_surface_is_xdg_surface(struct shell_surface *shsurf)
-{
- return weston_surface_is_desktop_surface(shsurf->surface);
-}
-
-static bool
-shell_surface_is_xdg_popup(struct shell_surface *shsurf)
-{
- return false;
-}
-
/*
* libweston-desktop
*/
-
-static void
-desktop_surface_configure(struct weston_surface *surface, int32_t width, int32_t height)
-{
- struct weston_desktop_surface *desktop_surface =
- weston_surface_get_desktop_surface(surface);
- struct shell_surface *shsurf =
- weston_desktop_surface_get_user_data(desktop_surface);
-
- weston_desktop_surface_set_activated(desktop_surface, shsurf->focus_count > 0);
- if (shsurf->state_requested) {
- weston_desktop_surface_set_maximized(desktop_surface,
- shsurf->requested_state.maximized);
- weston_desktop_surface_set_fullscreen(desktop_surface,
- shsurf->requested_state.fullscreen);
- }
- weston_desktop_surface_set_size(desktop_surface, width, height);
-}
-
-static const struct weston_shell_client desktop_surface_client = {
- desktop_surface_configure,
- NULL
-};
static void
desktop_surface_new(struct weston_desktop_surface *desktop_surface, void *shell)
{
- weston_log("NEW \\o/\n");
struct weston_surface *surface =
weston_desktop_surface_get_surface(desktop_surface);
struct shell_surface *shsurf;
- void *one = surface->configure;
- void *two = surface->configure_private;
- surface->configure = NULL;
- surface->configure_private = NULL;
-
- shsurf = create_common_surface(NULL, shell, surface,
- &desktop_surface_client);
- set_type(shsurf, SHELL_SURFACE_TOPLEVEL);
-
- weston_view_destroy(shsurf->view);
+ shsurf = create_common_surface(shell, surface);
+ shsurf->desktop_surface = desktop_surface;
shsurf->view = weston_desktop_surface_get_view(desktop_surface);
- surface->configure = one;
- surface->configure_private = two;
- wl_list_remove(&shsurf->surface_destroy_listener.link);
- wl_list_init(&shsurf->surface_destroy_listener.link);
weston_desktop_surface_set_user_data(desktop_surface, shsurf);
+ weston_desktop_surface_set_activated(desktop_surface,
+ shsurf->focus_count > 0);
}
static void
desktop_surface_free(struct weston_desktop_surface *desktop_surface, void *shell)
{
- weston_log("FREE \\o/\n");
struct shell_surface *shsurf =
weston_desktop_surface_get_user_data(desktop_surface);
- struct weston_surface *surface =
- weston_desktop_surface_get_surface(desktop_surface);
- void *one = surface->configure;
destroy_shell_surface(shsurf);
- surface->configure = one;
}
static void
-desktop_surface_configured(struct weston_desktop_surface *desktop_surface, void *shell)
+shell_surface_configure(struct weston_surface *es, int32_t sx, int32_t sy);
+static void
+desktop_surface_commit(struct weston_desktop_surface *desktop_surface, int32_t sx, int32_t sy, void *shell)
{
- weston_log("CONFIGURED \\o/\n");
struct weston_surface *surface =
weston_desktop_surface_get_surface(desktop_surface);
- shell_surface_configure(surface, 0, 0);
+ shell_surface_configure(surface, sx, sy);
}
static void
-desktop_surface_ask_fullscreen(struct weston_desktop_surface *desktop_surface, bool fullscreen, void *shell)
+set_fullscreen(struct shell_surface *shsurf, bool fullscreen)
{
- struct shell_surface *shsurf =
- weston_desktop_surface_get_user_data(desktop_surface);
+ struct weston_desktop_surface *desktop_surface =
+ desktop_surface = weston_surface_get_desktop_surface(shsurf->surface);
+ int32_t width = 0, height = 0;
- shsurf->state_requested = true;
- shsurf->requested_state.maximized = fullscreen;
if (fullscreen) {
struct weston_output *output = NULL;
@@ -3622,22 +2526,87 @@ desktop_surface_ask_fullscreen(struct weston_desktop_surface *desktop_surface, b
shell_surface_set_output(shsurf, output);
shsurf->fullscreen_output = shsurf->output;
+
+ width = shsurf->output->width;
+ height = shsurf->output->height;
+ } else {
+ unset_fullscreen(shsurf);
}
- send_configure_for_surface(shsurf);
+ weston_desktop_surface_set_fullscreen(desktop_surface, fullscreen);
+ weston_desktop_surface_set_size(desktop_surface, width, height);
}
static void
-desktop_surface_ask_maximized(struct weston_desktop_surface *desktop_surface, bool maximized, void *shell)
+desktop_surface_move(struct weston_desktop_surface *desktop_surface, struct weston_seat *seat, uint32_t serial, void *shell)
{
+ struct weston_pointer *pointer = weston_seat_get_pointer(seat);
+ struct weston_touch *touch = weston_seat_get_touch(seat);
+ struct shell_surface *shsurf =
+ weston_desktop_surface_get_user_data(desktop_surface);
+ struct weston_surface *surface;
+ struct wl_resource *resource = shsurf->surface->resource;
+
+ if (pointer &&
+ pointer->focus &&
+ pointer->button_count > 0 &&
+ pointer->grab_serial == serial) {
+ surface = weston_surface_get_main_surface(pointer->focus->surface);
+ if ((surface == shsurf->surface) &&
+ (surface_move(shsurf, pointer, true) < 0))
+ wl_resource_post_no_memory(resource);
+ } else if (touch &&
+ touch->focus &&
+ touch->grab_serial == serial) {
+ surface = weston_surface_get_main_surface(touch->focus->surface);
+ if ((surface == shsurf->surface) &&
+ (surface_touch_move(shsurf, touch) < 0))
+ wl_resource_post_no_memory(resource);
+ }
+}
+
+static void
+desktop_surface_resize(struct weston_desktop_surface *desktop_surface, struct weston_seat *seat, uint32_t serial, enum weston_desktop_surface_edge edges, void *shell)
+{
+ struct weston_pointer *pointer = weston_seat_get_pointer(seat);
struct shell_surface *shsurf =
weston_desktop_surface_get_user_data(desktop_surface);
+ struct weston_surface *surface;
+ struct wl_resource *resource = shsurf->surface->resource;
+
+ if (!pointer ||
+ pointer->button_count == 0 ||
+ pointer->grab_serial != serial ||
+ pointer->focus == NULL)
+ return;
+
+ surface = weston_surface_get_main_surface(pointer->focus->surface);
+ if (surface != shsurf->surface)
+ return;
+
+ if (surface_resize(shsurf, pointer, edges) < 0)
+ wl_resource_post_no_memory(resource);
+}
+
+static void
+desktop_surface_ask_fullscreen(struct weston_desktop_surface *desktop_surface, bool fullscreen, void *shell)
+{
+ struct shell_surface *shsurf =
+ weston_desktop_surface_get_user_data(desktop_surface);
+
+ set_fullscreen(shsurf, fullscreen);
+}
+
+static void
+set_maximized(struct shell_surface *shsurf, bool maximized)
+{
+ struct weston_desktop_surface *desktop_surface =
+ desktop_surface = weston_surface_get_desktop_surface(shsurf->surface);
+ int32_t width = 0, height = 0;
- shsurf->state_requested = true;
- shsurf->requested_state.maximized = maximized;
if (maximized) {
struct weston_output *output;
-
- shsurf->requested_state.maximized = true;
+ struct desktop_shell *shell;
+ pixman_rectangle32_t area;
if (!weston_surface_is_mapped(shsurf->surface))
output = get_focused_output(shsurf->surface->compositor);
@@ -3645,8 +2614,26 @@ desktop_surface_ask_maximized(struct weston_desktop_surface *desktop_surface, bo
output = shsurf->surface->output;
shell_surface_set_output(shsurf, output);
+
+ shell = shell_surface_get_shell(shsurf);
+ get_output_work_area(shell, shsurf->output, &area);
+
+ width = area.width;
+ height = area.height;
+ } else {
+ unset_maximized(shsurf);
}
- send_configure_for_surface(shsurf);
+ weston_desktop_surface_set_maximized(desktop_surface, maximized);
+ weston_desktop_surface_set_size(desktop_surface, width, height);
+}
+
+static void
+desktop_surface_ask_maximized(struct weston_desktop_surface *desktop_surface, bool maximized, void *shell)
+{
+ struct shell_surface *shsurf =
+ weston_desktop_surface_get_user_data(desktop_surface);
+
+ set_maximized(shsurf, maximized);
}
static void
@@ -3663,7 +2650,9 @@ static const struct weston_desktop_api shell_desktop_api = {
.struct_size = sizeof(struct weston_desktop_api),
.surface_new = desktop_surface_new,
.surface_free = desktop_surface_free,
- .configured = desktop_surface_configured,
+ .commit = desktop_surface_commit,
+ .move = desktop_surface_move,
+ .resize = desktop_surface_resize,
.ask_fullscreen = desktop_surface_ask_fullscreen,
.ask_maximized = desktop_surface_ask_maximized,
.ask_minimized = desktop_surface_ask_minimized,
@@ -4003,17 +2992,6 @@ static const struct weston_desktop_shell_interface desktop_shell_implementation
desktop_shell_set_panel_position
};
-static enum shell_surface_type
-get_shell_surface_type(struct weston_surface *surface)
-{
- struct shell_surface *shsurf;
-
- shsurf = get_shell_surface(surface);
- if (!shsurf)
- return SHELL_SURFACE_NONE;
- return shsurf->type;
-}
-
static void
move_binding(struct weston_pointer *pointer, uint32_t time,
uint32_t button, void *data)
@@ -4032,8 +3010,9 @@ move_binding(struct weston_pointer *pointer, uint32_t time,
return;
shsurf = get_shell_surface(surface);
- if (shsurf == NULL || shsurf->state.fullscreen ||
- shsurf->state.maximized)
+ if (shsurf == NULL ||
+ weston_desktop_surface_get_fullscreen(shsurf->desktop_surface) ||
+ weston_desktop_surface_get_maximized(shsurf->desktop_surface))
return;
surface_move(shsurf, pointer, false);
@@ -4055,12 +3034,7 @@ maximize_binding(struct weston_keyboard *keyboard, uint32_t time,
if (shsurf == NULL)
return;
- if (!shell_surface_is_xdg_surface(shsurf))
- return;
-
- shsurf->state_requested = true;
- shsurf->requested_state.maximized = !shsurf->state.maximized;
- send_configure_for_surface(shsurf);
+ set_maximized(shsurf, !weston_desktop_surface_get_maximized(shsurf->desktop_surface));
}
static void
@@ -4079,13 +3053,7 @@ fullscreen_binding(struct weston_keyboard *keyboard, uint32_t time,
if (shsurf == NULL)
return;
- if (!shell_surface_is_xdg_surface(shsurf))
- return;
-
- shsurf->state_requested = true;
- shsurf->requested_state.fullscreen = !shsurf->state.fullscreen;
- shsurf->fullscreen_output = shsurf->output;
- send_configure_for_surface(shsurf);
+ set_fullscreen(shsurf, !weston_desktop_surface_get_fullscreen(shsurf->desktop_surface));
}
static void
@@ -4104,8 +3072,9 @@ touch_move_binding(struct weston_touch *touch, uint32_t time, void *data)
return;
shsurf = get_shell_surface(surface);
- if (shsurf == NULL || shsurf->state.fullscreen ||
- shsurf->state.maximized)
+ if (shsurf == NULL ||
+ weston_desktop_surface_get_fullscreen(shsurf->desktop_surface) ||
+ weston_desktop_surface_get_maximized(shsurf->desktop_surface))
return;
surface_touch_move(shsurf, touch);
@@ -4131,8 +3100,9 @@ resize_binding(struct weston_pointer *pointer, uint32_t time,
return;
shsurf = get_shell_surface(surface);
- if (shsurf == NULL || shsurf->state.fullscreen ||
- shsurf->state.maximized)
+ if (shsurf == NULL ||
+ weston_desktop_surface_get_fullscreen(shsurf->desktop_surface) ||
+ weston_desktop_surface_get_maximized(shsurf->desktop_surface))
return;
weston_view_from_global(shsurf->view,
@@ -4423,8 +3393,9 @@ rotate_binding(struct weston_pointer *pointer, uint32_t time, uint32_t button,
return;
surface = get_shell_surface(base_surface);
- if (surface == NULL || surface->state.fullscreen ||
- surface->state.maximized)
+ if (surface == NULL ||
+ weston_desktop_surface_get_fullscreen(surface->desktop_surface) ||
+ weston_desktop_surface_get_maximized(surface->desktop_surface))
return;
surface_rotate(surface, pointer);
@@ -4464,7 +3435,7 @@ lower_fullscreen_layer(struct desktop_shell *shell,
/* We can have a non-fullscreen popup for a fullscreen surface
* in the fullscreen layer. */
- if (shsurf->state.fullscreen) {
+ if (weston_desktop_surface_get_fullscreen(shsurf->desktop_surface)) {
/* Hide the black view */
weston_layer_entry_remove(&shsurf->fullscreen.black_view->layer_link);
wl_list_init(&shsurf->fullscreen.black_view->layer_link.link);
@@ -4509,7 +3480,7 @@ activate(struct desktop_shell *shell, struct weston_surface *es,
old_es = state->keyboard_focus;
focus_state_set_focus(state, es);
- if (shsurf->state.fullscreen && configure)
+ if (weston_desktop_surface_get_fullscreen(shsurf->desktop_surface) && configure)
shell_configure_fullscreen(shsurf);
else
restore_output_mode(shsurf->output);
@@ -4556,7 +3527,7 @@ activate_binding(struct weston_seat *seat,
focus = main_surface;
main_surface = weston_surface_get_main_surface(focus);
- if (get_shell_surface_type(main_surface) == SHELL_SURFACE_NONE)
+ if (!get_shell_surface(main_surface))
return;
state = ensure_focus_state(shell, seat);
@@ -4841,17 +3812,8 @@ idle_handler(struct wl_listener *listener, void *data)
{
struct desktop_shell *shell =
container_of(listener, struct desktop_shell, idle_listener);
- struct weston_seat *seat;
- wl_list_for_each(seat, &shell->compositor->seat_list, link) {
- struct weston_touch *touch = weston_seat_get_touch(seat);
- struct weston_pointer *pointer = weston_seat_get_pointer(seat);
-
- if (pointer)
- popup_grab_end(pointer);
- if (touch)
- touch_popup_grab_end(touch);
- }
+ /* TODO: undo popup grabs */
shell_fade(shell, FADE_OUT);
/* lock() is called from shell_fade_done() */
@@ -4866,27 +3828,6 @@ wake_handler(struct wl_listener *listener, void *data)
unlock(shell);
}
-static void
-transform_handler(struct wl_listener *listener, void *data)
-{
- struct weston_surface *surface = data;
- struct shell_surface *shsurf = get_shell_surface(surface);
- struct weston_view *view;;
- int x, y;
-
- if (!shsurf || !shsurf->client->send_position)
- return;
-
- view = shsurf->view;
- if (!view || !weston_view_is_mapped(view))
- return;
-
- x = view->geometry.x;
- y = view->geometry.y;
-
- shsurf->client->send_position(surface, x, y);
-}
-
static void
center_on_output(struct weston_view *view, struct weston_output *output)
{
@@ -4965,21 +3906,15 @@ static void
set_maximized_position(struct desktop_shell *shell,
struct shell_surface *shsurf)
{
- int32_t surf_x, surf_y;
pixman_rectangle32_t area;
+ struct weston_desktop_surface_geometry geometry;
get_output_work_area(shell, shsurf->output, &area);
- if (shsurf->has_set_geometry) {
- surf_x = shsurf->geometry.x;
- surf_y = shsurf->geometry.y;
- } else {
- surface_subsurfaces_boundingbox(shsurf->surface,
- &surf_x, &surf_y, NULL, NULL);
- }
+ geometry = weston_desktop_surface_get_geometry(shsurf->desktop_surface);
weston_view_set_position(shsurf->view,
- area.x - surf_x,
- area.y - surf_y);
+ area.x - geometry.x,
+ area.y - geometry.y);
}
static void
@@ -4990,66 +3925,32 @@ map(struct desktop_shell *shell, struct shell_surface *shsurf,
struct weston_seat *seat;
/* initial positioning, see also configure() */
- switch (shsurf->type) {
- case SHELL_SURFACE_TOPLEVEL:
- if (shsurf->state.fullscreen) {
- center_on_output(shsurf->view, shsurf->fullscreen_output);
- shell_map_fullscreen(shsurf);
- } else if (shsurf->state.maximized) {
- set_maximized_position(shell, shsurf);
- } else if (!shsurf->state.relative) {
- weston_view_set_initial_position(shsurf->view, shell);
- }
- break;
- case SHELL_SURFACE_POPUP:
- if (shell_map_popup(shsurf) != 0)
- return;
- break;
- case SHELL_SURFACE_NONE:
- weston_view_set_position(shsurf->view,
- shsurf->view->geometry.x + sx,
- shsurf->view->geometry.y + sy);
- break;
- case SHELL_SURFACE_XWAYLAND:
- default:
- ;
+ if (weston_desktop_surface_get_fullscreen(shsurf->desktop_surface)) {
+ center_on_output(shsurf->view, shsurf->fullscreen_output);
+ shell_map_fullscreen(shsurf);
+ } else if (weston_desktop_surface_get_maximized(shsurf->desktop_surface)) {
+ set_maximized_position(shell, shsurf);
+ } else {
+ weston_view_set_initial_position(shsurf->view, shell);
}
/* Surface stacking order, see also activate(). */
shell_surface_update_layer(shsurf);
- if (shsurf->type != SHELL_SURFACE_NONE) {
- weston_view_update_transform(shsurf->view);
- shsurf->view->is_mapped = true;
- if (shsurf->state.maximized) {
- shsurf->surface->output = shsurf->output;
- shsurf->view->output = shsurf->output;
- }
+ weston_view_update_transform(shsurf->view);
+ shsurf->view->is_mapped = true;
+ if (weston_desktop_surface_get_maximized(shsurf->desktop_surface)) {
+ shsurf->surface->output = shsurf->output;
+ shsurf->view->output = shsurf->output;
}
- switch (shsurf->type) {
- /* XXX: xwayland's using the same fields for transient type */
- case SHELL_SURFACE_XWAYLAND:
- if (shsurf->transient.flags ==
- WL_SHELL_SURFACE_TRANSIENT_INACTIVE)
- break;
- case SHELL_SURFACE_TOPLEVEL:
- if (shsurf->state.relative &&
- shsurf->transient.flags == WL_SHELL_SURFACE_TRANSIENT_INACTIVE)
- break;
- if (shell->locked)
- break;
+ if (!shell->locked) {
wl_list_for_each(seat, &compositor->seat_list, link)
activate(shell, shsurf->surface, seat, true);
- break;
- case SHELL_SURFACE_POPUP:
- case SHELL_SURFACE_NONE:
- default:
- break;
}
- if (shsurf->type == SHELL_SURFACE_TOPLEVEL &&
- !shsurf->state.maximized && !shsurf->state.fullscreen)
+ if (!weston_desktop_surface_get_maximized(shsurf->desktop_surface) &&
+ !weston_desktop_surface_get_fullscreen(shsurf->desktop_surface))
{
switch (shell->win_animation_type) {
case ANIMATION_FADE:
@@ -5076,10 +3977,11 @@ configure(struct desktop_shell *shell, struct weston_surface *surface,
assert(shsurf);
- if (shsurf->state.fullscreen)
+ if (weston_desktop_surface_get_fullscreen(shsurf->desktop_surface))
shell_configure_fullscreen(shsurf);
- else if (shsurf->state.maximized) {
+ else if (weston_desktop_surface_get_maximized(shsurf->desktop_surface)) {
set_maximized_position(shell, shsurf);
+ surface->output = shsurf->output;
} else {
weston_view_set_position(shsurf->view, x, y);
}
@@ -5088,9 +3990,6 @@ configure(struct desktop_shell *shell, struct weston_surface *surface,
if (surface->output) {
wl_list_for_each(view, &surface->views, surface_link)
weston_view_update_transform(view);
-
- if (shsurf->state.maximized)
- surface->output = shsurf->output;
}
}
@@ -5099,41 +3998,18 @@ shell_surface_configure(struct weston_surface *es, int32_t sx, int32_t sy)
{
struct shell_surface *shsurf = get_shell_surface(es);
struct desktop_shell *shell;
- int type_changed = 0;
assert(shsurf);
shell = shsurf->shell;
- if (!weston_surface_is_mapped(es) &&
- !wl_list_empty(&shsurf->popup.grab_link)) {
- remove_popup_grab(shsurf);
- }
-
if (es->width == 0)
return;
- if (shsurf->has_next_geometry) {
- shsurf->geometry = shsurf->next_geometry;
- shsurf->has_next_geometry = false;
- shsurf->has_set_geometry = true;
- } else if (!shsurf->has_set_geometry) {
- surface_subsurfaces_boundingbox(shsurf->surface,
- &shsurf->geometry.x,
- &shsurf->geometry.y,
- &shsurf->geometry.width,
- &shsurf->geometry.height);
- }
-
- if (shsurf->state_changed) {
- set_surface_type(shsurf);
- type_changed = 1;
- }
-
if (!weston_surface_is_mapped(es)) {
map(shell, shsurf, sx, sy);
es->is_mapped = true;
- } else if (type_changed || sx != 0 || sy != 0 ||
+ } else if (sx != 0 || sy != 0 ||
shsurf->last_width != es->width ||
shsurf->last_height != es->height) {
float from_x, from_y;
@@ -5315,9 +4191,7 @@ switcher_next(struct switcher *switcher)
wl_list_for_each(view, &ws->layer.view_list.link, layer_link.link) {
shsurf = get_shell_surface(view->surface);
- if (shsurf &&
- shsurf->type == SHELL_SURFACE_TOPLEVEL &&
- shsurf->parent == NULL) {
+ if (shsurf) {
if (first == NULL)
first = view->surface;
if (prev == switcher->current)
@@ -5349,7 +4223,7 @@ switcher_next(struct switcher *switcher)
view->alpha = 1.0;
shsurf = get_shell_surface(switcher->current);
- if (shsurf && shsurf->state.fullscreen)
+ if (shsurf && shsurf->fullscreen.black_view)
shsurf->fullscreen.black_view->alpha = 1.0;
}
@@ -5635,13 +4509,12 @@ shell_reposition_view_on_output_destroy(struct weston_view *view)
shsurf = get_shell_surface(view->surface);
+ if (!shsurf)
+ return;
- if (shsurf) {
- shsurf->saved_position_valid = false;
- shsurf->next_state.maximized = false;
- shsurf->next_state.fullscreen = false;
- shsurf->state_changed = true;
- }
+ shsurf->saved_position_valid = false;
+ set_maximized(shsurf, false);
+ set_fullscreen(shsurf, false);
}
void
@@ -5812,7 +4685,6 @@ shell_destroy(struct wl_listener *listener, void *data)
wl_list_remove(&shell->idle_listener.link);
wl_list_remove(&shell->wake_listener.link);
- wl_list_remove(&shell->transform_listener.link);
text_backend_destroy(shell->text_backend);
input_panel_destroy(shell);
@@ -5960,21 +4832,8 @@ module_init(struct weston_compositor *ec,
wl_signal_add(&ec->idle_signal, &shell->idle_listener);
shell->wake_listener.notify = wake_handler;
wl_signal_add(&ec->wake_signal, &shell->wake_listener);
- shell->transform_listener.notify = transform_handler;
- wl_signal_add(&ec->transform_signal, &shell->transform_listener);
ec->shell_interface.shell = shell;
- ec->shell_interface.create_shell_surface = create_shell_surface;
- ec->shell_interface.set_toplevel = set_toplevel;
- ec->shell_interface.set_transient = set_transient;
- ec->shell_interface.set_fullscreen = shell_interface_set_fullscreen;
- ec->shell_interface.set_xwayland = set_xwayland;
- ec->shell_interface.move = shell_interface_move;
- ec->shell_interface.resize = shell_interface_resize;
- ec->shell_interface.set_title = set_title;
- ec->shell_interface.set_window_geometry = set_window_geometry;
- ec->shell_interface.set_maximized = shell_interface_set_maximized;
- ec->shell_interface.set_pid = set_pid;
ec->shell_interface.get_output_work_area = get_output_work_area;
weston_layer_init(&shell->fullscreen_layer, &ec->cursor_layer.link);
diff --git a/desktop-shell/shell.h b/desktop-shell/shell.h
index c956824..475e76f 100644
--- a/desktop-shell/shell.h
+++ b/desktop-shell/shell.h
@@ -129,7 +129,7 @@ struct desktop_shell {
struct wl_listener idle_listener;
struct wl_listener wake_listener;
- struct wl_listener transform_listener;
+ //struct wl_listener transform_listener;
struct wl_listener resized_listener;
struct wl_listener destroy_listener;
struct wl_listener show_input_panel_listener;
diff --git a/libweston/compositor.h b/libweston/compositor.h
index e78d75c..a55c406 100644
--- a/libweston/compositor.h
+++ b/libweston/compositor.h
@@ -85,38 +85,9 @@ struct weston_mode {
struct wl_list link;
};
-struct weston_shell_client {
- void (*send_configure)(struct weston_surface *surface, int32_t width, int32_t height);
- void (*send_position)(struct weston_surface *surface, int32_t x, int32_t y);
-};
-
struct weston_shell_interface {
void *shell; /* either desktop or tablet */
- struct shell_surface *(*create_shell_surface)(void *shell,
- struct weston_surface *surface,
- const struct weston_shell_client *client);
- void (*set_toplevel)(struct shell_surface *shsurf);
-
- void (*set_transient)(struct shell_surface *shsurf,
- struct weston_surface *parent,
- int x, int y, uint32_t flags);
- void (*set_fullscreen)(struct shell_surface *shsurf,
- uint32_t method,
- uint32_t framerate,
- struct weston_output *output);
- void (*set_xwayland)(struct shell_surface *shsurf,
- int x, int y, uint32_t flags);
- int (*move)(struct shell_surface *shsurf, struct weston_pointer *pointer);
- int (*resize)(struct shell_surface *shsurf,
- struct weston_pointer *pointer, uint32_t edges);
- void (*set_title)(struct shell_surface *shsurf,
- const char *title);
- void (*set_window_geometry)(struct shell_surface *shsurf,
- int32_t x, int32_t y,
- int32_t width, int32_t height);
- void (*set_maximized)(struct shell_surface *shsurf);
- void (*set_pid)(struct shell_surface *shsurf, pid_t pid);
void (*get_output_work_area)(void *shell, struct weston_output *output, pixman_rectangle32_t *area);
};
diff --git a/shared/helpers.h b/shared/helpers.h
index 1d1e458..ac9ea8b 100644
--- a/shared/helpers.h
+++ b/shared/helpers.h
@@ -52,6 +52,17 @@ extern "C" {
#define MIN(x,y) (((x) < (y)) ? (x) : (y))
#endif
+/**
+ * Returns the bigger of two values.
+ *
+ * @param x the first item to compare.
+ * @param y the second item to compare.
+ * @return the value that evaluates to more than the other.
+ */
+#ifndef MAX
+#define MAX(x,y) (((x) > (y)) ? (x) : (y))
+#endif
+
/**
* Returns a pointer the the containing struct of a given member item.
*
--
2.9.0
More information about the wayland-devel
mailing list