aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2018-04-04 22:12:32 -0400
committerLibravatar GitHub <noreply@github.com>2018-04-04 22:12:32 -0400
commit21aedf15052df4e7f8ee72922fa0e214d690facc (patch)
tree42039b2d318ab944dd148990329b4a2cf94fd9a3
parentMerge pull request #1707 from acrisci/transparency (diff)
parentUse new wlr_*_surface_at functions (diff)
downloadsway-21aedf15052df4e7f8ee72922fa0e214d690facc.tar.gz
sway-21aedf15052df4e7f8ee72922fa0e214d690facc.tar.zst
sway-21aedf15052df4e7f8ee72922fa0e214d690facc.zip
Merge pull request #1732 from emersion/view-children
Update for wlroots#824
-rw-r--r--include/sway/tree/view.h11
-rw-r--r--sway/desktop/output.c11
-rw-r--r--sway/desktop/wl_shell.c4
-rw-r--r--sway/desktop/xdg_shell_v6.c4
-rw-r--r--sway/desktop/xwayland.c4
-rw-r--r--sway/input/seat.c2
-rw-r--r--sway/tree/container.c68
7 files changed, 39 insertions, 65 deletions
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h
index 4b84205e..f32ccc5a 100644
--- a/include/sway/tree/view.h
+++ b/include/sway/tree/view.h
@@ -59,11 +59,9 @@ struct sway_wl_shell_surface {
59}; 59};
60 60
61enum sway_view_type { 61enum sway_view_type {
62 SWAY_WL_SHELL_VIEW, 62 SWAY_VIEW_WL_SHELL,
63 SWAY_XDG_SHELL_V6_VIEW, 63 SWAY_VIEW_XDG_SHELL_V6,
64 SWAY_XWAYLAND_VIEW, 64 SWAY_VIEW_XWAYLAND,
65 // Keep last
66 SWAY_VIEW_TYPES,
67}; 65};
68 66
69enum sway_view_prop { 67enum sway_view_prop {
@@ -101,9 +99,6 @@ struct sway_view {
101 struct sway_xwayland_surface *sway_xwayland_surface; 99 struct sway_xwayland_surface *sway_xwayland_surface;
102 struct sway_wl_shell_surface *sway_wl_shell_surface; 100 struct sway_wl_shell_surface *sway_wl_shell_surface;
103 }; 101 };
104
105 // only used for unmanaged views (shell specific)
106 struct wl_list unmanaged_view_link; // sway_root::unmanaged_views
107}; 102};
108 103
109struct sway_view *view_create(enum sway_view_type type, 104struct sway_view *view_create(enum sway_view_type type,
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index 6cf5da48..0e8a9485 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -188,7 +188,7 @@ static void render_view(struct sway_container *view, void *data) {
188 } 188 }
189 189
190 switch (sway_view->type) { 190 switch (sway_view->type) {
191 case SWAY_XDG_SHELL_V6_VIEW: { 191 case SWAY_VIEW_XDG_SHELL_V6: {
192 int window_offset_x = view->sway_view->wlr_xdg_surface_v6->geometry.x; 192 int window_offset_x = view->sway_view->wlr_xdg_surface_v6->geometry.x;
193 int window_offset_y = view->sway_view->wlr_xdg_surface_v6->geometry.y; 193 int window_offset_y = view->sway_view->wlr_xdg_surface_v6->geometry.y;
194 render_surface(surface, wlr_output, when, 194 render_surface(surface, wlr_output, when,
@@ -197,15 +197,12 @@ static void render_view(struct sway_container *view, void *data) {
197 when, view->x - window_offset_x, view->y - window_offset_y, 0, alpha); 197 when, view->x - window_offset_x, view->y - window_offset_y, 0, alpha);
198 break; 198 break;
199 } 199 }
200 case SWAY_WL_SHELL_VIEW: 200 case SWAY_VIEW_WL_SHELL:
201 render_wl_shell_surface(sway_view->wlr_wl_shell_surface, wlr_output, 201 render_wl_shell_surface(sway_view->wlr_wl_shell_surface, wlr_output,
202 when, view->x, view->y, 0, alpha, false); 202 when, view->x, view->y, 0, alpha, false);
203 break; 203 break;
204 case SWAY_XWAYLAND_VIEW: 204 case SWAY_VIEW_XWAYLAND:
205 render_surface(surface, wlr_output, when, view->x, view->y, 205 render_surface(surface, wlr_output, when, view->x, view->y, 0, alpha);
206 0, alpha);
207 break;
208 default:
209 break; 206 break;
210 } 207 }
211} 208}
diff --git a/sway/desktop/wl_shell.c b/sway/desktop/wl_shell.c
index 6528a397..a470674d 100644
--- a/sway/desktop/wl_shell.c
+++ b/sway/desktop/wl_shell.c
@@ -12,7 +12,7 @@
12#include "log.h" 12#include "log.h"
13 13
14static bool assert_wl_shell(struct sway_view *view) { 14static bool assert_wl_shell(struct sway_view *view) {
15 return sway_assert(view->type == SWAY_WL_SHELL_VIEW, 15 return sway_assert(view->type == SWAY_VIEW_WL_SHELL,
16 "Expecting wl_shell view!"); 16 "Expecting wl_shell view!");
17} 17}
18 18
@@ -97,7 +97,7 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
97 return; 97 return;
98 } 98 }
99 99
100 struct sway_view *view = view_create(SWAY_WL_SHELL_VIEW, &view_impl); 100 struct sway_view *view = view_create(SWAY_VIEW_WL_SHELL, &view_impl);
101 if (!sway_assert(view, "Failed to allocate view")) { 101 if (!sway_assert(view, "Failed to allocate view")) {
102 return; 102 return;
103 } 103 }
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c
index 49305b39..5cdb8f9f 100644
--- a/sway/desktop/xdg_shell_v6.c
+++ b/sway/desktop/xdg_shell_v6.c
@@ -12,7 +12,7 @@
12#include "log.h" 12#include "log.h"
13 13
14static bool assert_xdg(struct sway_view *view) { 14static bool assert_xdg(struct sway_view *view) {
15 return sway_assert(view->type == SWAY_XDG_SHELL_V6_VIEW, 15 return sway_assert(view->type == SWAY_VIEW_XDG_SHELL_V6,
16 "Expected xdg shell v6 view!"); 16 "Expected xdg shell v6 view!");
17} 17}
18 18
@@ -126,7 +126,7 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
126 return; 126 return;
127 } 127 }
128 128
129 struct sway_view *view = view_create(SWAY_XDG_SHELL_V6_VIEW, &view_impl); 129 struct sway_view *view = view_create(SWAY_VIEW_XDG_SHELL_V6, &view_impl);
130 if (!sway_assert(view, "Failed to allocate view")) { 130 if (!sway_assert(view, "Failed to allocate view")) {
131 return; 131 return;
132 } 132 }
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c
index bfef68cf..a793928c 100644
--- a/sway/desktop/xwayland.c
+++ b/sway/desktop/xwayland.c
@@ -42,7 +42,7 @@ static void create_unmanaged(struct wlr_xwayland_surface *xsurface) {
42 42
43 43
44static bool assert_xwayland(struct sway_view *view) { 44static bool assert_xwayland(struct sway_view *view) {
45 return sway_assert(view->type == SWAY_XWAYLAND_VIEW, 45 return sway_assert(view->type == SWAY_VIEW_XWAYLAND,
46 "Expected xwayland view!"); 46 "Expected xwayland view!");
47} 47}
48 48
@@ -185,7 +185,7 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
185 return; 185 return;
186 } 186 }
187 187
188 struct sway_view *view = view_create(SWAY_XWAYLAND_VIEW, &view_impl); 188 struct sway_view *view = view_create(SWAY_VIEW_XWAYLAND, &view_impl);
189 if (!sway_assert(view, "Failed to allocate view")) { 189 if (!sway_assert(view, "Failed to allocate view")) {
190 return; 190 return;
191 } 191 }
diff --git a/sway/input/seat.c b/sway/input/seat.c
index 0699324a..87dbd870 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -66,7 +66,7 @@ static void seat_send_focus(struct sway_seat *seat,
66 return; 66 return;
67 } 67 }
68 struct sway_view *view = con->sway_view; 68 struct sway_view *view = con->sway_view;
69 if (view->type == SWAY_XWAYLAND_VIEW) { 69 if (view->type == SWAY_VIEW_XWAYLAND) {
70 struct wlr_xwayland *xwayland = 70 struct wlr_xwayland *xwayland =
71 seat->input->server->xwayland; 71 seat->input->server->xwayland;
72 wlr_xwayland_set_seat(xwayland, seat->wlr_seat); 72 wlr_xwayland_set_seat(xwayland, seat->wlr_seat);
diff --git a/sway/tree/container.c b/sway/tree/container.c
index 3be08645..bd9f1edf 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -412,51 +412,33 @@ struct sway_container *container_at(struct sway_container *parent,
412 double view_sx = ox - swayc->x; 412 double view_sx = ox - swayc->x;
413 double view_sy = oy - swayc->y; 413 double view_sy = oy - swayc->y;
414 414
415 double _sx, _sy;
416 struct wlr_surface *_surface;
415 switch (sview->type) { 417 switch (sview->type) {
416 case SWAY_WL_SHELL_VIEW: 418 case SWAY_VIEW_XWAYLAND:
417 break; 419 _surface = wlr_surface_surface_at(sview->surface,
418 case SWAY_XDG_SHELL_V6_VIEW: 420 view_sx, view_sy, &_sx, &_sy);
419 // the top left corner of the sway container is the 421 break;
420 // coordinate of the top left corner of the window geometry 422 case SWAY_VIEW_WL_SHELL:
421 view_sx += sview->wlr_xdg_surface_v6->geometry.x; 423 _surface = wlr_wl_shell_surface_surface_at(
422 view_sy += sview->wlr_xdg_surface_v6->geometry.y; 424 sview->wlr_wl_shell_surface,
423 425 view_sx, view_sy, &_sx, &_sy);
424 // check for popups 426 break;
425 double popup_sx, popup_sy; 427 case SWAY_VIEW_XDG_SHELL_V6:
426 struct wlr_xdg_surface_v6 *popup = 428 // the top left corner of the sway container is the
427 wlr_xdg_surface_v6_popup_at(sview->wlr_xdg_surface_v6, 429 // coordinate of the top left corner of the window geometry
428 view_sx, view_sy, &popup_sx, &popup_sy); 430 view_sx += sview->wlr_xdg_surface_v6->geometry.x;
429 431 view_sy += sview->wlr_xdg_surface_v6->geometry.y;
430 if (popup) { 432
431 *sx = view_sx - popup_sx; 433 _surface = wlr_xdg_surface_v6_surface_at(
432 *sy = view_sy - popup_sy; 434 sview->wlr_xdg_surface_v6,
433 *surface = popup->surface; 435 view_sx, view_sy, &_sx, &_sy);
434 return swayc; 436 break;
435 }
436 break;
437 case SWAY_XWAYLAND_VIEW:
438 break;
439 default:
440 break;
441 }
442
443 // check for subsurfaces
444 double sub_x, sub_y;
445 struct wlr_subsurface *subsurface =
446 wlr_surface_subsurface_at(sview->surface,
447 view_sx, view_sy, &sub_x, &sub_y);
448 if (subsurface) {
449 *sx = view_sx - sub_x;
450 *sy = view_sy - sub_y;
451 *surface = subsurface->surface;
452 return swayc;
453 } 437 }
454 438 if (_surface) {
455 if (wlr_surface_point_accepts_input( 439 *sx = _sx;
456 sview->surface, view_sx, view_sy)) { 440 *sy = _sy;
457 *sx = view_sx; 441 *surface = _surface;
458 *sy = view_sy;
459 *surface = swayc->sway_view->surface;
460 return swayc; 442 return swayc;
461 } 443 }
462 } else { 444 } else {