aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Simon Ser <contact@emersion.fr>2023-02-08 15:25:14 +0100
committerLibravatar Kenny Levinsen <kl@kl.wtf>2023-02-10 20:36:15 +0100
commit1cab17ada243385798b3340f88144f64ac33ee63 (patch)
treeefb573543dc226d9f35a26ff21481d61ad6ae717
parentClarify documentation for window_rect (diff)
downloadsway-1cab17ada243385798b3340f88144f64ac33ee63.tar.gz
sway-1cab17ada243385798b3340f88144f64ac33ee63.tar.zst
sway-1cab17ada243385798b3340f88144f64ac33ee63.zip
Introduce surface_{enter,leave}_output()
We can centralize all output-related surface events from there.
-rw-r--r--include/sway/surface.h5
-rw-r--r--sway/desktop/layer_shell.c6
-rw-r--r--sway/desktop/surface.c11
-rw-r--r--sway/lock.c3
-rw-r--r--sway/tree/container.c13
-rw-r--r--sway/tree/view.c3
6 files changed, 30 insertions, 11 deletions
diff --git a/include/sway/surface.h b/include/sway/surface.h
index fb1cd775..50681897 100644
--- a/include/sway/surface.h
+++ b/include/sway/surface.h
@@ -15,4 +15,9 @@ struct sway_surface {
15 struct wl_event_source *frame_done_timer; 15 struct wl_event_source *frame_done_timer;
16}; 16};
17 17
18void surface_enter_output(struct wlr_surface *surface,
19 struct sway_output *output);
20void surface_leave_output(struct wlr_surface *surface,
21 struct sway_output *output);
22
18#endif 23#endif
diff --git a/sway/desktop/layer_shell.c b/sway/desktop/layer_shell.c
index 6e3cc0e2..795eb4cd 100644
--- a/sway/desktop/layer_shell.c
+++ b/sway/desktop/layer_shell.c
@@ -13,6 +13,7 @@
13#include "sway/layers.h" 13#include "sway/layers.h"
14#include "sway/output.h" 14#include "sway/output.h"
15#include "sway/server.h" 15#include "sway/server.h"
16#include "sway/surface.h"
16#include "sway/tree/arrange.h" 17#include "sway/tree/arrange.h"
17#include "sway/tree/workspace.h" 18#include "sway/tree/workspace.h"
18 19
@@ -382,8 +383,7 @@ static void handle_map(struct wl_listener *listener, void *data) {
382 struct sway_output *output = wlr_output->data; 383 struct sway_output *output = wlr_output->data;
383 output_damage_surface(output, sway_layer->geo.x, sway_layer->geo.y, 384 output_damage_surface(output, sway_layer->geo.x, sway_layer->geo.y,
384 sway_layer->layer_surface->surface, true); 385 sway_layer->layer_surface->surface, true);
385 wlr_surface_send_enter(sway_layer->layer_surface->surface, 386 surface_enter_output(sway_layer->layer_surface->surface, output);
386 sway_layer->layer_surface->output);
387 cursor_rebase_all(); 387 cursor_rebase_all();
388} 388}
389 389
@@ -510,7 +510,7 @@ static void popup_handle_map(struct wl_listener *listener, void *data) {
510 struct sway_layer_surface *layer = popup_get_layer(popup); 510 struct sway_layer_surface *layer = popup_get_layer(popup);
511 struct wlr_output *wlr_output = layer->layer_surface->output; 511 struct wlr_output *wlr_output = layer->layer_surface->output;
512 sway_assert(wlr_output, "wlr_layer_surface_v1 has null output"); 512 sway_assert(wlr_output, "wlr_layer_surface_v1 has null output");
513 wlr_surface_send_enter(popup->wlr_popup->base->surface, wlr_output); 513 surface_enter_output(popup->wlr_popup->base->surface, wlr_output->data);
514 popup_damage(popup, true); 514 popup_damage(popup, true);
515} 515}
516 516
diff --git a/sway/desktop/surface.c b/sway/desktop/surface.c
index 1d7b536d..a5a18917 100644
--- a/sway/desktop/surface.c
+++ b/sway/desktop/surface.c
@@ -4,6 +4,7 @@
4#include <wlr/types/wlr_compositor.h> 4#include <wlr/types/wlr_compositor.h>
5#include "sway/server.h" 5#include "sway/server.h"
6#include "sway/surface.h" 6#include "sway/surface.h"
7#include "sway/output.h"
7 8
8static void handle_destroy(struct wl_listener *listener, void *data) { 9static void handle_destroy(struct wl_listener *listener, void *data) {
9 struct sway_surface *surface = wl_container_of(listener, surface, destroy); 10 struct sway_surface *surface = wl_container_of(listener, surface, destroy);
@@ -44,3 +45,13 @@ void handle_compositor_new_surface(struct wl_listener *listener, void *data) {
44 wl_resource_post_no_memory(wlr_surface->resource); 45 wl_resource_post_no_memory(wlr_surface->resource);
45 } 46 }
46} 47}
48
49void surface_enter_output(struct wlr_surface *surface,
50 struct sway_output *output) {
51 wlr_surface_send_enter(surface, output->wlr_output);
52}
53
54void surface_leave_output(struct wlr_surface *surface,
55 struct sway_output *output) {
56 wlr_surface_send_leave(surface, output->wlr_output);
57}
diff --git a/sway/lock.c b/sway/lock.c
index 96af19c4..6d9e991b 100644
--- a/sway/lock.c
+++ b/sway/lock.c
@@ -5,6 +5,7 @@
5#include "sway/input/seat.h" 5#include "sway/input/seat.h"
6#include "sway/output.h" 6#include "sway/output.h"
7#include "sway/server.h" 7#include "sway/server.h"
8#include "sway/surface.h"
8 9
9struct sway_session_lock_surface { 10struct sway_session_lock_surface {
10 struct wlr_session_lock_surface_v1 *lock_surface; 11 struct wlr_session_lock_surface_v1 *lock_surface;
@@ -31,7 +32,7 @@ static void handle_surface_map(struct wl_listener *listener, void *data) {
31 if (server.session_lock.focused == NULL) { 32 if (server.session_lock.focused == NULL) {
32 set_lock_focused_surface(surf->surface); 33 set_lock_focused_surface(surf->surface);
33 } 34 }
34 wlr_surface_send_enter(surf->surface, surf->output->wlr_output); 35 surface_enter_output(surf->surface, surf->output);
35 output_damage_whole(surf->output); 36 output_damage_whole(surf->output);
36} 37}
37 38
diff --git a/sway/tree/container.c b/sway/tree/container.c
index fa76dd6a..20701081 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -18,6 +18,7 @@
18#include "sway/ipc-server.h" 18#include "sway/ipc-server.h"
19#include "sway/output.h" 19#include "sway/output.h"
20#include "sway/server.h" 20#include "sway/server.h"
21#include "sway/surface.h"
21#include "sway/tree/arrange.h" 22#include "sway/tree/arrange.h"
22#include "sway/tree/view.h" 23#include "sway/tree/view.h"
23#include "sway/tree/workspace.h" 24#include "sway/tree/workspace.h"
@@ -1265,14 +1266,14 @@ bool container_is_fullscreen_or_child(struct sway_container *container) {
1265 1266
1266static void surface_send_enter_iterator(struct wlr_surface *surface, 1267static void surface_send_enter_iterator(struct wlr_surface *surface,
1267 int x, int y, void *data) { 1268 int x, int y, void *data) {
1268 struct wlr_output *wlr_output = data; 1269 struct sway_output *output = data;
1269 wlr_surface_send_enter(surface, wlr_output); 1270 surface_enter_output(surface, output);
1270} 1271}
1271 1272
1272static void surface_send_leave_iterator(struct wlr_surface *surface, 1273static void surface_send_leave_iterator(struct wlr_surface *surface,
1273 int x, int y, void *data) { 1274 int x, int y, void *data) {
1274 struct wlr_output *wlr_output = data; 1275 struct sway_output *output = data;
1275 wlr_surface_send_leave(surface, wlr_output); 1276 surface_leave_output(surface, output);
1276} 1277}
1277 1278
1278void container_discover_outputs(struct sway_container *con) { 1279void container_discover_outputs(struct sway_container *con) {
@@ -1298,7 +1299,7 @@ void container_discover_outputs(struct sway_container *con) {
1298 sway_log(SWAY_DEBUG, "Container %p entered output %p", con, output); 1299 sway_log(SWAY_DEBUG, "Container %p entered output %p", con, output);
1299 if (con->view) { 1300 if (con->view) {
1300 view_for_each_surface(con->view, 1301 view_for_each_surface(con->view,
1301 surface_send_enter_iterator, output->wlr_output); 1302 surface_send_enter_iterator, output);
1302 if (con->view->foreign_toplevel) { 1303 if (con->view->foreign_toplevel) {
1303 wlr_foreign_toplevel_handle_v1_output_enter( 1304 wlr_foreign_toplevel_handle_v1_output_enter(
1304 con->view->foreign_toplevel, output->wlr_output); 1305 con->view->foreign_toplevel, output->wlr_output);
@@ -1310,7 +1311,7 @@ void container_discover_outputs(struct sway_container *con) {
1310 sway_log(SWAY_DEBUG, "Container %p left output %p", con, output); 1311 sway_log(SWAY_DEBUG, "Container %p left output %p", con, output);
1311 if (con->view) { 1312 if (con->view) {
1312 view_for_each_surface(con->view, 1313 view_for_each_surface(con->view,
1313 surface_send_leave_iterator, output->wlr_output); 1314 surface_send_leave_iterator, output);
1314 if (con->view->foreign_toplevel) { 1315 if (con->view->foreign_toplevel) {
1315 wlr_foreign_toplevel_handle_v1_output_leave( 1316 wlr_foreign_toplevel_handle_v1_output_leave(
1316 con->view->foreign_toplevel, output->wlr_output); 1317 con->view->foreign_toplevel, output->wlr_output);
diff --git a/sway/tree/view.c b/sway/tree/view.c
index ba3ef489..fcb78de3 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -25,6 +25,7 @@
25#include "sway/output.h" 25#include "sway/output.h"
26#include "sway/input/seat.h" 26#include "sway/input/seat.h"
27#include "sway/server.h" 27#include "sway/server.h"
28#include "sway/surface.h"
28#include "sway/tree/arrange.h" 29#include "sway/tree/arrange.h"
29#include "sway/tree/container.h" 30#include "sway/tree/container.h"
30#include "sway/tree/view.h" 31#include "sway/tree/view.h"
@@ -1148,7 +1149,7 @@ void view_child_init(struct sway_view_child *child,
1148 if (container != NULL) { 1149 if (container != NULL) {
1149 struct sway_workspace *workspace = container->pending.workspace; 1150 struct sway_workspace *workspace = container->pending.workspace;
1150 if (workspace) { 1151 if (workspace) {
1151 wlr_surface_send_enter(child->surface, workspace->output->wlr_output); 1152 surface_enter_output(child->surface, workspace->output);
1152 } 1153 }
1153 } 1154 }
1154 1155