Merge pull request #1732 from emersion/view-children

Update for wlroots#824
This commit is contained in:
Drew DeVault 2018-04-04 22:12:32 -04:00 committed by GitHub
commit 21aedf1505
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 38 additions and 64 deletions

View file

@ -59,11 +59,9 @@ struct sway_wl_shell_surface {
};
enum sway_view_type {
SWAY_WL_SHELL_VIEW,
SWAY_XDG_SHELL_V6_VIEW,
SWAY_XWAYLAND_VIEW,
// Keep last
SWAY_VIEW_TYPES,
SWAY_VIEW_WL_SHELL,
SWAY_VIEW_XDG_SHELL_V6,
SWAY_VIEW_XWAYLAND,
};
enum sway_view_prop {
@ -101,9 +99,6 @@ struct sway_view {
struct sway_xwayland_surface *sway_xwayland_surface;
struct sway_wl_shell_surface *sway_wl_shell_surface;
};
// only used for unmanaged views (shell specific)
struct wl_list unmanaged_view_link; // sway_root::unmanaged_views
};
struct sway_view *view_create(enum sway_view_type type,

View file

@ -188,7 +188,7 @@ static void render_view(struct sway_container *view, void *data) {
}
switch (sway_view->type) {
case SWAY_XDG_SHELL_V6_VIEW: {
case SWAY_VIEW_XDG_SHELL_V6: {
int window_offset_x = view->sway_view->wlr_xdg_surface_v6->geometry.x;
int window_offset_y = view->sway_view->wlr_xdg_surface_v6->geometry.y;
render_surface(surface, wlr_output, when,
@ -197,15 +197,12 @@ static void render_view(struct sway_container *view, void *data) {
when, view->x - window_offset_x, view->y - window_offset_y, 0, alpha);
break;
}
case SWAY_WL_SHELL_VIEW:
case SWAY_VIEW_WL_SHELL:
render_wl_shell_surface(sway_view->wlr_wl_shell_surface, wlr_output,
when, view->x, view->y, 0, alpha, false);
break;
case SWAY_XWAYLAND_VIEW:
render_surface(surface, wlr_output, when, view->x, view->y,
0, alpha);
break;
default:
case SWAY_VIEW_XWAYLAND:
render_surface(surface, wlr_output, when, view->x, view->y, 0, alpha);
break;
}
}

View file

@ -12,7 +12,7 @@
#include "log.h"
static bool assert_wl_shell(struct sway_view *view) {
return sway_assert(view->type == SWAY_WL_SHELL_VIEW,
return sway_assert(view->type == SWAY_VIEW_WL_SHELL,
"Expecting wl_shell view!");
}
@ -97,7 +97,7 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
return;
}
struct sway_view *view = view_create(SWAY_WL_SHELL_VIEW, &view_impl);
struct sway_view *view = view_create(SWAY_VIEW_WL_SHELL, &view_impl);
if (!sway_assert(view, "Failed to allocate view")) {
return;
}

View file

@ -12,7 +12,7 @@
#include "log.h"
static bool assert_xdg(struct sway_view *view) {
return sway_assert(view->type == SWAY_XDG_SHELL_V6_VIEW,
return sway_assert(view->type == SWAY_VIEW_XDG_SHELL_V6,
"Expected xdg shell v6 view!");
}
@ -126,7 +126,7 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
return;
}
struct sway_view *view = view_create(SWAY_XDG_SHELL_V6_VIEW, &view_impl);
struct sway_view *view = view_create(SWAY_VIEW_XDG_SHELL_V6, &view_impl);
if (!sway_assert(view, "Failed to allocate view")) {
return;
}

View file

@ -42,7 +42,7 @@ static void create_unmanaged(struct wlr_xwayland_surface *xsurface) {
static bool assert_xwayland(struct sway_view *view) {
return sway_assert(view->type == SWAY_XWAYLAND_VIEW,
return sway_assert(view->type == SWAY_VIEW_XWAYLAND,
"Expected xwayland view!");
}
@ -185,7 +185,7 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
return;
}
struct sway_view *view = view_create(SWAY_XWAYLAND_VIEW, &view_impl);
struct sway_view *view = view_create(SWAY_VIEW_XWAYLAND, &view_impl);
if (!sway_assert(view, "Failed to allocate view")) {
return;
}

View file

@ -66,7 +66,7 @@ static void seat_send_focus(struct sway_seat *seat,
return;
}
struct sway_view *view = con->sway_view;
if (view->type == SWAY_XWAYLAND_VIEW) {
if (view->type == SWAY_VIEW_XWAYLAND) {
struct wlr_xwayland *xwayland =
seat->input->server->xwayland;
wlr_xwayland_set_seat(xwayland, seat->wlr_seat);

View file

@ -412,51 +412,33 @@ struct sway_container *container_at(struct sway_container *parent,
double view_sx = ox - swayc->x;
double view_sy = oy - swayc->y;
double _sx, _sy;
struct wlr_surface *_surface;
switch (sview->type) {
case SWAY_WL_SHELL_VIEW:
case SWAY_VIEW_XWAYLAND:
_surface = wlr_surface_surface_at(sview->surface,
view_sx, view_sy, &_sx, &_sy);
break;
case SWAY_XDG_SHELL_V6_VIEW:
case SWAY_VIEW_WL_SHELL:
_surface = wlr_wl_shell_surface_surface_at(
sview->wlr_wl_shell_surface,
view_sx, view_sy, &_sx, &_sy);
break;
case SWAY_VIEW_XDG_SHELL_V6:
// the top left corner of the sway container is the
// coordinate of the top left corner of the window geometry
view_sx += sview->wlr_xdg_surface_v6->geometry.x;
view_sy += sview->wlr_xdg_surface_v6->geometry.y;
// check for popups
double popup_sx, popup_sy;
struct wlr_xdg_surface_v6 *popup =
wlr_xdg_surface_v6_popup_at(sview->wlr_xdg_surface_v6,
view_sx, view_sy, &popup_sx, &popup_sy);
if (popup) {
*sx = view_sx - popup_sx;
*sy = view_sy - popup_sy;
*surface = popup->surface;
return swayc;
}
break;
case SWAY_XWAYLAND_VIEW:
break;
default:
_surface = wlr_xdg_surface_v6_surface_at(
sview->wlr_xdg_surface_v6,
view_sx, view_sy, &_sx, &_sy);
break;
}
// check for subsurfaces
double sub_x, sub_y;
struct wlr_subsurface *subsurface =
wlr_surface_subsurface_at(sview->surface,
view_sx, view_sy, &sub_x, &sub_y);
if (subsurface) {
*sx = view_sx - sub_x;
*sy = view_sy - sub_y;
*surface = subsurface->surface;
return swayc;
}
if (wlr_surface_point_accepts_input(
sview->surface, view_sx, view_sy)) {
*sx = view_sx;
*sy = view_sy;
*surface = swayc->sway_view->surface;
if (_surface) {
*sx = _sx;
*sy = _sy;
*surface = _surface;
return swayc;
}
} else {