diff options
author | Alexander Orzechowski <alex@ozal.ski> | 2024-01-18 10:02:41 -0500 |
---|---|---|
committer | Kirill Primak <vyivel@eclair.cafe> | 2024-01-18 18:36:54 +0300 |
commit | 6e5fc4c2aafd211323c6037aa868c075852bfe15 (patch) | |
tree | bff87217414fa981d48244c5bc1b253817646783 /sway/desktop/xwayland.c | |
parent | scene_graph: Port xdg_shell (diff) | |
download | sway-6e5fc4c2aafd211323c6037aa868c075852bfe15.tar.gz sway-6e5fc4c2aafd211323c6037aa868c075852bfe15.tar.zst sway-6e5fc4c2aafd211323c6037aa868c075852bfe15.zip |
scene_graph: Port xwayland
Diffstat (limited to 'sway/desktop/xwayland.c')
-rw-r--r-- | sway/desktop/xwayland.c | 79 |
1 files changed, 42 insertions, 37 deletions
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 8f79b5e7..183bdba2 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c | |||
@@ -6,15 +6,16 @@ | |||
6 | #include <wlr/types/wlr_output_layout.h> | 6 | #include <wlr/types/wlr_output_layout.h> |
7 | #include <wlr/types/wlr_output.h> | 7 | #include <wlr/types/wlr_output.h> |
8 | #include <wlr/types/wlr_xdg_activation_v1.h> | 8 | #include <wlr/types/wlr_xdg_activation_v1.h> |
9 | #include <wlr/types/wlr_scene.h> | ||
9 | #include <wlr/xwayland.h> | 10 | #include <wlr/xwayland.h> |
10 | #include <xcb/xcb_icccm.h> | 11 | #include <xcb/xcb_icccm.h> |
11 | #include "log.h" | 12 | #include "log.h" |
12 | #include "sway/desktop.h" | ||
13 | #include "sway/desktop/transaction.h" | 13 | #include "sway/desktop/transaction.h" |
14 | #include "sway/input/cursor.h" | 14 | #include "sway/input/cursor.h" |
15 | #include "sway/input/input-manager.h" | 15 | #include "sway/input/input-manager.h" |
16 | #include "sway/input/seat.h" | 16 | #include "sway/input/seat.h" |
17 | #include "sway/output.h" | 17 | #include "sway/output.h" |
18 | #include "sway/scene_descriptor.h" | ||
18 | #include "sway/tree/arrange.h" | 19 | #include "sway/tree/arrange.h" |
19 | #include "sway/tree/container.h" | 20 | #include "sway/tree/container.h" |
20 | #include "sway/server.h" | 21 | #include "sway/server.h" |
@@ -45,29 +46,12 @@ static void unmanaged_handle_request_configure(struct wl_listener *listener, | |||
45 | ev->width, ev->height); | 46 | ev->width, ev->height); |
46 | } | 47 | } |
47 | 48 | ||
48 | static void unmanaged_handle_commit(struct wl_listener *listener, void *data) { | ||
49 | struct sway_xwayland_unmanaged *surface = | ||
50 | wl_container_of(listener, surface, commit); | ||
51 | struct wlr_xwayland_surface *xsurface = surface->wlr_xwayland_surface; | ||
52 | |||
53 | desktop_damage_surface(xsurface->surface, surface->lx, surface->ly, | ||
54 | false); | ||
55 | } | ||
56 | |||
57 | static void unmanaged_handle_set_geometry(struct wl_listener *listener, void *data) { | 49 | static void unmanaged_handle_set_geometry(struct wl_listener *listener, void *data) { |
58 | struct sway_xwayland_unmanaged *surface = | 50 | struct sway_xwayland_unmanaged *surface = |
59 | wl_container_of(listener, surface, set_geometry); | 51 | wl_container_of(listener, surface, set_geometry); |
60 | struct wlr_xwayland_surface *xsurface = surface->wlr_xwayland_surface; | 52 | struct wlr_xwayland_surface *xsurface = surface->wlr_xwayland_surface; |
61 | 53 | ||
62 | if (xsurface->x != surface->lx || xsurface->y != surface->ly) { | 54 | wlr_scene_node_set_position(&surface->surface_scene->buffer->node, xsurface->x, xsurface->y); |
63 | // Surface has moved | ||
64 | desktop_damage_surface(xsurface->surface, surface->lx, surface->ly, | ||
65 | true); | ||
66 | surface->lx = xsurface->x; | ||
67 | surface->ly = xsurface->y; | ||
68 | desktop_damage_surface(xsurface->surface, surface->lx, surface->ly, | ||
69 | true); | ||
70 | } | ||
71 | } | 55 | } |
72 | 56 | ||
73 | static void unmanaged_handle_map(struct wl_listener *listener, void *data) { | 57 | static void unmanaged_handle_map(struct wl_listener *listener, void *data) { |
@@ -75,17 +59,18 @@ static void unmanaged_handle_map(struct wl_listener *listener, void *data) { | |||
75 | wl_container_of(listener, surface, map); | 59 | wl_container_of(listener, surface, map); |
76 | struct wlr_xwayland_surface *xsurface = surface->wlr_xwayland_surface; | 60 | struct wlr_xwayland_surface *xsurface = surface->wlr_xwayland_surface; |
77 | 61 | ||
78 | wl_list_insert(root->xwayland_unmanaged.prev, &surface->link); | 62 | surface->surface_scene = wlr_scene_surface_create(root->layers.unmanaged, |
63 | xsurface->surface); | ||
79 | 64 | ||
80 | wl_signal_add(&xsurface->events.set_geometry, &surface->set_geometry); | 65 | if (surface->surface_scene) { |
81 | surface->set_geometry.notify = unmanaged_handle_set_geometry; | 66 | scene_descriptor_assign(&surface->surface_scene->buffer->node, |
67 | SWAY_SCENE_DESC_XWAYLAND_UNMANAGED, surface); | ||
68 | wlr_scene_node_set_position(&surface->surface_scene->buffer->node, | ||
69 | xsurface->x, xsurface->y); | ||
82 | 70 | ||
83 | wl_signal_add(&xsurface->surface->events.commit, &surface->commit); | 71 | wl_signal_add(&xsurface->events.set_geometry, &surface->set_geometry); |
84 | surface->commit.notify = unmanaged_handle_commit; | 72 | surface->set_geometry.notify = unmanaged_handle_set_geometry; |
85 | 73 | } | |
86 | surface->lx = xsurface->x; | ||
87 | surface->ly = xsurface->y; | ||
88 | desktop_damage_surface(xsurface->surface, surface->lx, surface->ly, true); | ||
89 | 74 | ||
90 | if (wlr_xwayland_or_surface_wants_focus(xsurface)) { | 75 | if (wlr_xwayland_or_surface_wants_focus(xsurface)) { |
91 | struct sway_seat *seat = input_manager_current_seat(); | 76 | struct sway_seat *seat = input_manager_current_seat(); |
@@ -99,10 +84,13 @@ static void unmanaged_handle_unmap(struct wl_listener *listener, void *data) { | |||
99 | struct sway_xwayland_unmanaged *surface = | 84 | struct sway_xwayland_unmanaged *surface = |
100 | wl_container_of(listener, surface, unmap); | 85 | wl_container_of(listener, surface, unmap); |
101 | struct wlr_xwayland_surface *xsurface = surface->wlr_xwayland_surface; | 86 | struct wlr_xwayland_surface *xsurface = surface->wlr_xwayland_surface; |
102 | desktop_damage_surface(xsurface->surface, xsurface->x, xsurface->y, true); | 87 | |
103 | wl_list_remove(&surface->link); | 88 | if (surface->surface_scene) { |
104 | wl_list_remove(&surface->set_geometry.link); | 89 | wl_list_remove(&surface->set_geometry.link); |
105 | wl_list_remove(&surface->commit.link); | 90 | |
91 | wlr_scene_node_destroy(&surface->surface_scene->buffer->node); | ||
92 | surface->surface_scene = NULL; | ||
93 | } | ||
106 | 94 | ||
107 | struct sway_seat *seat = input_manager_current_seat(); | 95 | struct sway_seat *seat = input_manager_current_seat(); |
108 | if (seat->wlr_seat->keyboard_state.focused_surface == xsurface->surface) { | 96 | if (seat->wlr_seat->keyboard_state.focused_surface == xsurface->surface) { |
@@ -455,7 +443,6 @@ static void handle_commit(struct wl_listener *listener, void *data) { | |||
455 | // The client changed its surface size in this commit. For floating | 443 | // The client changed its surface size in this commit. For floating |
456 | // containers, we resize the container to match. For tiling containers, | 444 | // containers, we resize the container to match. For tiling containers, |
457 | // we only recenter the surface. | 445 | // we only recenter the surface. |
458 | desktop_damage_view(view); | ||
459 | memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box)); | 446 | memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box)); |
460 | if (container_is_floating(view->container)) { | 447 | if (container_is_floating(view->container)) { |
461 | view_update_size(view); | 448 | view_update_size(view); |
@@ -463,15 +450,12 @@ static void handle_commit(struct wl_listener *listener, void *data) { | |||
463 | } else { | 450 | } else { |
464 | view_center_surface(view); | 451 | view_center_surface(view); |
465 | } | 452 | } |
466 | desktop_damage_view(view); | ||
467 | } | 453 | } |
468 | 454 | ||
469 | if (view->container->node.instruction) { | 455 | if (view->container->node.instruction) { |
470 | transaction_notify_view_ready_by_geometry(view, | 456 | transaction_notify_view_ready_by_geometry(view, |
471 | xsurface->x, xsurface->y, state->width, state->height); | 457 | xsurface->x, xsurface->y, state->width, state->height); |
472 | } | 458 | } |
473 | |||
474 | view_damage_from(view); | ||
475 | } | 459 | } |
476 | 460 | ||
477 | static void handle_destroy(struct wl_listener *listener, void *data) { | 461 | static void handle_destroy(struct wl_listener *listener, void *data) { |
@@ -515,9 +499,21 @@ static void handle_unmap(struct wl_listener *listener, void *data) { | |||
515 | return; | 499 | return; |
516 | } | 500 | } |
517 | 501 | ||
502 | wl_list_remove(&xwayland_view->commit.link); | ||
503 | wl_list_remove(&xwayland_view->surface_tree_destroy.link); | ||
504 | |||
505 | if (xwayland_view->surface_tree) { | ||
506 | wlr_scene_node_destroy(&xwayland_view->surface_tree->node); | ||
507 | xwayland_view->surface_tree = NULL; | ||
508 | } | ||
509 | |||
518 | view_unmap(view); | 510 | view_unmap(view); |
511 | } | ||
519 | 512 | ||
520 | wl_list_remove(&xwayland_view->commit.link); | 513 | static void handle_surface_tree_destroy(struct wl_listener *listener, void *data) { |
514 | struct sway_xwayland_view *xwayland_view = wl_container_of(listener, xwayland_view, | ||
515 | surface_tree_destroy); | ||
516 | xwayland_view->surface_tree = NULL; | ||
521 | } | 517 | } |
522 | 518 | ||
523 | static void handle_map(struct wl_listener *listener, void *data) { | 519 | static void handle_map(struct wl_listener *listener, void *data) { |
@@ -537,6 +533,15 @@ static void handle_map(struct wl_listener *listener, void *data) { | |||
537 | // Put it back into the tree | 533 | // Put it back into the tree |
538 | view_map(view, xsurface->surface, xsurface->fullscreen, NULL, false); | 534 | view_map(view, xsurface->surface, xsurface->fullscreen, NULL, false); |
539 | 535 | ||
536 | xwayland_view->surface_tree = wlr_scene_subsurface_tree_create( | ||
537 | xwayland_view->view.content_tree, xsurface->surface); | ||
538 | |||
539 | if (xwayland_view->surface_tree) { | ||
540 | xwayland_view->surface_tree_destroy.notify = handle_surface_tree_destroy; | ||
541 | wl_signal_add(&xwayland_view->surface_tree->node.events.destroy, | ||
542 | &xwayland_view->surface_tree_destroy); | ||
543 | } | ||
544 | |||
540 | transaction_commit_dirty(); | 545 | transaction_commit_dirty(); |
541 | } | 546 | } |
542 | 547 | ||