aboutsummaryrefslogtreecommitdiff
path: root/sway/desktop
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2018-03-30 19:04:06 -0400
committeremersion <contact@emersion.fr>2018-03-30 19:04:06 -0400
commit96656427656118f2e4d725359cc880270b0e51be (patch)
treee2596e9cfa113efa43f2a411176c31e6208a58b1 /sway/desktop
parent6c9d67b1059409750de683aec3b8b9be2da987cc (diff)
parent1b88eaee6b14987c585fcf149cc26f665c584d77 (diff)
Merge branch 'wlroots' into client-cursors
Diffstat (limited to 'sway/desktop')
-rw-r--r--sway/desktop/layer_shell.c26
-rw-r--r--sway/desktop/output.c167
-rw-r--r--sway/desktop/wl_shell.c1
-rw-r--r--sway/desktop/xdg_shell_v6.c52
-rw-r--r--sway/desktop/xwayland.c92
5 files changed, 203 insertions, 135 deletions
diff --git a/sway/desktop/layer_shell.c b/sway/desktop/layer_shell.c
index f7e5d19c..5c96659a 100644
--- a/sway/desktop/layer_shell.c
+++ b/sway/desktop/layer_shell.c
@@ -4,12 +4,13 @@
#include <wayland-server.h>
#include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_layer_shell.h>
+#include <wlr/types/wlr_output_damage.h>
#include <wlr/types/wlr_output.h>
#include <wlr/util/log.h>
#include "sway/layers.h"
-#include "sway/tree/layout.h"
#include "sway/output.h"
#include "sway/server.h"
+#include "sway/tree/layout.h"
static void apply_exclusive(struct wlr_box *usable_area,
uint32_t anchor, int32_t exclusive,
@@ -210,20 +211,26 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) {
} else {
// TODO DAMAGE from surface damage
}
+ wlr_output_damage_add_box(output->damage, &old_geo);
+ wlr_output_damage_add_box(output->damage, &layer->geo);
}
}
-static void unmap(struct wlr_layer_surface *layer_surface) {
- // TODO DAMAGE
+static void unmap(struct sway_layer_surface *sway_layer) {
+ struct wlr_output *wlr_output = sway_layer->layer_surface->output;
+ if (wlr_output != NULL) {
+ struct sway_output *output = wlr_output->data;
+ wlr_output_damage_add_box(output->damage, &sway_layer->geo);
+ }
}
static void handle_destroy(struct wl_listener *listener, void *data) {
- struct sway_layer_surface *sway_layer = wl_container_of(
- listener, sway_layer, destroy);
+ struct sway_layer_surface *sway_layer = wl_container_of(listener,
+ sway_layer, destroy);
wlr_log(L_DEBUG, "Layer surface destroyed (%s)",
sway_layer->layer_surface->namespace);
if (sway_layer->layer_surface->mapped) {
- unmap(sway_layer->layer_surface);
+ unmap(sway_layer);
}
wl_list_remove(&sway_layer->link);
wl_list_remove(&sway_layer->destroy.link);
@@ -239,13 +246,16 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
}
static void handle_map(struct wl_listener *listener, void *data) {
- // TODO DAMAGE
+ struct sway_layer_surface *sway_layer = wl_container_of(listener,
+ sway_layer, map);
+ struct sway_output *output = sway_layer->layer_surface->output->data;
+ wlr_output_damage_add_box(output->damage, &sway_layer->geo);
}
static void handle_unmap(struct wl_listener *listener, void *data) {
struct sway_layer_surface *sway_layer = wl_container_of(
listener, sway_layer, unmap);
- unmap(sway_layer->layer_surface);
+ unmap(sway_layer);
}
void handle_layer_shell_surface(struct wl_listener *listener, void *data) {
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index 87eb80fe..c248b29e 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -6,18 +6,19 @@
#include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_matrix.h>
-#include <wlr/types/wlr_output.h>
+#include <wlr/types/wlr_output_damage.h>
#include <wlr/types/wlr_output_layout.h>
+#include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_surface.h>
#include <wlr/types/wlr_wl_shell.h>
#include "log.h"
-#include "sway/tree/container.h"
#include "sway/input/input-manager.h"
#include "sway/input/seat.h"
#include "sway/layers.h"
-#include "sway/tree/layout.h"
#include "sway/output.h"
#include "sway/server.h"
+#include "sway/tree/container.h"
+#include "sway/tree/layout.h"
#include "sway/tree/view.h"
/**
@@ -41,6 +42,9 @@ static void rotate_child_position(double *sx, double *sy, double sw, double sh,
static void render_surface(struct wlr_surface *surface,
struct wlr_output *wlr_output, struct timespec *when,
double lx, double ly, float rotation) {
+ struct wlr_renderer *renderer =
+ wlr_backend_get_renderer(wlr_output->backend);
+
if (!wlr_surface_has_buffer(surface)) {
return;
}
@@ -65,8 +69,8 @@ static void render_surface(struct wlr_surface *surface,
float matrix[9];
wlr_matrix_project_box(matrix, &render_box, surface->current->transform,
0, wlr_output->transform_matrix);
- wlr_render_texture_with_matrix(server.renderer, surface->texture,
- matrix, 1.0f); // TODO: configurable alpha
+ wlr_render_texture_with_matrix(renderer, surface->texture, matrix,
+ 1.0f); // TODO: configurable alpha
wlr_surface_send_frame_done(surface, when);
}
@@ -142,13 +146,13 @@ static void render_wl_shell_surface(struct wlr_wl_shell_surface *surface,
struct render_data {
struct sway_output *output;
- struct timespec *now;
+ struct timespec *when;
};
-static void output_frame_view(struct sway_container *view, void *data) {
+static void render_view(struct sway_container *view, void *data) {
struct render_data *rdata = data;
struct sway_output *output = rdata->output;
- struct timespec *now = rdata->now;
+ struct timespec *when = rdata->when;
struct wlr_output *wlr_output = output->wlr_output;
struct sway_view *sway_view = view->sway_view;
struct wlr_surface *surface = sway_view->surface;
@@ -161,18 +165,18 @@ static void output_frame_view(struct sway_container *view, void *data) {
case SWAY_XDG_SHELL_V6_VIEW: {
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, now,
+ render_surface(surface, wlr_output, when,
view->x - window_offset_x, view->y - window_offset_y, 0);
render_xdg_v6_popups(sway_view->wlr_xdg_surface_v6, wlr_output,
- now, view->x - window_offset_x, view->y - window_offset_y, 0);
+ when, view->x - window_offset_x, view->y - window_offset_y, 0);
break;
}
case SWAY_WL_SHELL_VIEW:
render_wl_shell_surface(sway_view->wlr_wl_shell_surface, wlr_output,
- now, view->x, view->y, 0, false);
+ when, view->x, view->y, 0, false);
break;
case SWAY_XWAYLAND_VIEW:
- render_surface(surface, wlr_output, now, view->x, view->y, 0);
+ render_surface(surface, wlr_output, when, view->x, view->y, 0);
break;
default:
break;
@@ -192,82 +196,132 @@ static void render_layer(struct sway_output *output,
}
}
-static void output_frame_notify(struct wl_listener *listener, void *data) {
- struct sway_output *soutput = wl_container_of(listener, soutput, frame);
- struct wlr_output *wlr_output = data;
- struct sway_server *server = soutput->server;
- struct wlr_renderer *renderer = wlr_backend_get_renderer(wlr_output->backend);
+static void render_output(struct sway_output *output, struct timespec *when,
+ pixman_region32_t *damage) {
+ struct wlr_output *wlr_output = output->wlr_output;
+ struct wlr_renderer *renderer =
+ wlr_backend_get_renderer(wlr_output->backend);
+
+ wlr_renderer_begin(renderer, wlr_output->width, wlr_output->height);
+
+ if (!pixman_region32_not_empty(damage)) {
+ // Output isn't damaged but needs buffer swap
+ goto renderer_end;
+ }
- int buffer_age = -1;
- wlr_output_make_current(wlr_output, &buffer_age);
- wlr_renderer_begin(server->renderer, wlr_output->width, wlr_output->height);
+ // TODO: don't damage the whole output here
+ int width, height;
+ wlr_output_transformed_resolution(wlr_output, &width, &height);
+ pixman_region32_union_rect(damage, damage, 0, 0, width, height);
float clear_color[] = {0.25f, 0.25f, 0.25f, 1.0f};
wlr_renderer_clear(renderer, clear_color);
- struct timespec now;
- clock_gettime(CLOCK_MONOTONIC, &now);
-
struct wlr_output_layout *layout = root_container.sway_root->output_layout;
- const struct wlr_box *output_box = wlr_output_layout_get_box(
- layout, wlr_output);
+ const struct wlr_box *output_box =
+ wlr_output_layout_get_box(layout, wlr_output);
- render_layer(soutput, output_box, &now,
- &soutput->layers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND]);
- render_layer(soutput, output_box, &now,
- &soutput->layers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM]);
+ render_layer(output, output_box, when,
+ &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND]);
+ render_layer(output, output_box, when,
+ &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM]);
struct sway_seat *seat = input_manager_current_seat(input_manager);
- struct sway_container *focus = sway_seat_get_focus_inactive(seat, soutput->swayc);
+ struct sway_container *focus =
+ sway_seat_get_focus_inactive(seat, output->swayc);
struct sway_container *workspace = (focus->type == C_WORKSPACE ?
focus :
container_parent(focus, C_WORKSPACE));
struct render_data rdata = {
- .output = soutput,
- .now = &now,
+ .output = output,
+ .when = when,
};
- container_descendants(workspace, C_VIEW, output_frame_view, &rdata);
+ container_descendants(workspace, C_VIEW, render_view, &rdata);
// render unmanaged views on top
struct sway_view *view;
wl_list_for_each(view, &root_container.sway_root->unmanaged_views,
unmanaged_view_link) {
if (view->type == SWAY_XWAYLAND_VIEW) {
- // the only kind of unamanged view right now is xwayland override redirect
+ // the only kind of unamanged view right now is xwayland override
+ // redirect
int view_x = view->wlr_xwayland_surface->x;
int view_y = view->wlr_xwayland_surface->y;
- render_surface(view->surface, wlr_output, &soutput->last_frame,
+ render_surface(view->surface, wlr_output, &output->last_frame,
view_x, view_y, 0);
}
}
// TODO: Consider revising this when fullscreen windows are supported
- render_layer(soutput, output_box, &now,
- &soutput->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]);
- render_layer(soutput, output_box, &now,
- &soutput->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]);
-
- wlr_renderer_end(server->renderer);
- wlr_output_swap_buffers(wlr_output, &now, NULL);
- soutput->last_frame = now;
+ render_layer(output, output_box, when,
+ &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]);
+ render_layer(output, output_box, when,
+ &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]);
+
+renderer_end:
+ wlr_renderer_end(renderer);
+ if (!wlr_output_damage_swap_buffers(output->damage, when, damage)) {
+ return;
+ }
+ output->last_frame = *when;
}
-static void handle_output_destroy(struct wl_listener *listener, void *data) {
- struct sway_output *output = wl_container_of(listener, output, destroy);
- struct wlr_output *wlr_output = data;
- wlr_log(L_DEBUG, "Output %p %s removed", wlr_output, wlr_output->name);
+static void damage_handle_frame(struct wl_listener *listener, void *data) {
+ struct sway_output *output =
+ wl_container_of(listener, output, damage_frame);
+
+ if (!output->wlr_output->enabled) {
+ return;
+ }
+ struct timespec now;
+ clock_gettime(CLOCK_MONOTONIC, &now);
+
+ bool needs_swap;
+ pixman_region32_t damage;
+ pixman_region32_init(&damage);
+ if (!wlr_output_damage_make_current(output->damage, &needs_swap, &damage)) {
+ return;
+ }
+
+ if (needs_swap) {
+ render_output(output, &now, &damage);
+ }
+
+ pixman_region32_fini(&damage);
+
+ // TODO: send frame done events here instead of inside render_surface
+}
+
+void output_damage_whole(struct sway_output *output) {
+ wlr_output_damage_add_whole(output->damage);
+}
+
+void output_damage_whole_view(struct sway_output *output,
+ struct sway_view *view) {
+ // TODO
+ output_damage_whole(output);
+}
+
+static void damage_handle_destroy(struct wl_listener *listener, void *data) {
+ struct sway_output *output =
+ wl_container_of(listener, output, damage_destroy);
+ container_output_destroy(output->swayc);
+}
+
+static void handle_destroy(struct wl_listener *listener, void *data) {
+ struct sway_output *output = wl_container_of(listener, output, destroy);
container_output_destroy(output->swayc);
}
-static void handle_output_mode(struct wl_listener *listener, void *data) {
+static void handle_mode(struct wl_listener *listener, void *data) {
struct sway_output *output = wl_container_of(listener, output, mode);
arrange_layers(output);
arrange_windows(output->swayc, -1, -1);
}
-static void handle_output_transform(struct wl_listener *listener, void *data) {
+static void handle_transform(struct wl_listener *listener, void *data) {
struct sway_output *output = wl_container_of(listener, output, transform);
arrange_layers(output);
arrange_windows(output->swayc, -1, -1);
@@ -292,6 +346,8 @@ void handle_new_output(struct wl_listener *listener, void *data) {
wlr_output_set_mode(wlr_output, mode);
}
+ output->damage = wlr_output_damage_create(wlr_output);
+
output->swayc = container_output_create(output);
if (!output->swayc) {
free(output);
@@ -305,14 +361,17 @@ void handle_new_output(struct wl_listener *listener, void *data) {
sway_input_manager_configure_xcursor(input_manager);
- wl_signal_add(&wlr_output->events.frame, &output->frame);
- output->frame.notify = output_frame_notify;
wl_signal_add(&wlr_output->events.destroy, &output->destroy);
- output->destroy.notify = handle_output_destroy;
+ output->destroy.notify = handle_destroy;
wl_signal_add(&wlr_output->events.mode, &output->mode);
- output->mode.notify = handle_output_mode;
+ output->mode.notify = handle_mode;
wl_signal_add(&wlr_output->events.transform, &output->transform);
- output->transform.notify = handle_output_transform;
+ output->transform.notify = handle_transform;
+
+ wl_signal_add(&output->damage->events.frame, &output->damage_frame);
+ output->damage_frame.notify = damage_handle_frame;
+ wl_signal_add(&output->damage->events.destroy, &output->damage_destroy);
+ output->damage_destroy.notify = damage_handle_destroy;
arrange_layers(output);
arrange_windows(&root_container, -1, -1);
diff --git a/sway/desktop/wl_shell.c b/sway/desktop/wl_shell.c
index 4d4d1ed7..4fcc6317 100644
--- a/sway/desktop/wl_shell.c
+++ b/sway/desktop/wl_shell.c
@@ -67,6 +67,7 @@ static void handle_commit(struct wl_listener *listener, void *data) {
// TODO: Let floating views do whatever
view->width = sway_surface->pending_width;
view->height = sway_surface->pending_height;
+ view_damage_from(view);
}
static void handle_destroy(struct wl_listener *listener, void *data) {
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c
index 25c0cbca..713437f2 100644
--- a/sway/desktop/xdg_shell_v6.c
+++ b/sway/desktop/xdg_shell_v6.c
@@ -76,6 +76,35 @@ static void handle_commit(struct wl_listener *listener, void *data) {
// TODO: Let floating views do whatever
view->width = sway_surface->pending_width;
view->height = sway_surface->pending_height;
+ view_damage_from(view);
+}
+
+static void handle_unmap(struct wl_listener *listener, void *data) {
+ struct sway_xdg_surface_v6 *sway_surface =
+ wl_container_of(listener, sway_surface, unmap);
+ view_damage_whole(sway_surface->view);
+ container_view_destroy(sway_surface->view->swayc);
+ sway_surface->view->swayc = NULL;
+ sway_surface->view->surface = NULL;
+}
+
+static void handle_map(struct wl_listener *listener, void *data) {
+ struct sway_xdg_surface_v6 *sway_surface =
+ wl_container_of(listener, sway_surface, map);
+ struct sway_view *view = sway_surface->view;
+
+ sway_surface->view->surface = view->wlr_xdg_surface_v6->surface;
+
+ container_view_destroy(view->swayc);
+
+ struct sway_seat *seat = input_manager_current_seat(input_manager);
+ struct sway_container *focus = sway_seat_get_focus_inactive(seat, &root_container);
+ struct sway_container *cont = container_view_create(focus, view);
+ view->swayc = cont;
+ arrange_windows(cont->parent, -1, -1);
+ sway_input_manager_set_focus(input_manager, cont);
+
+ view_damage_whole(sway_surface->view);
}
static void handle_destroy(struct wl_listener *listener, void *data) {
@@ -83,10 +112,9 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
wl_container_of(listener, sway_xdg_surface, destroy);
wl_list_remove(&sway_xdg_surface->commit.link);
wl_list_remove(&sway_xdg_surface->destroy.link);
- struct sway_container *parent = container_view_destroy(sway_xdg_surface->view->swayc);
+ container_view_destroy(sway_xdg_surface->view->swayc);
free(sway_xdg_surface->view);
free(sway_xdg_surface);
- arrange_windows(parent, -1, -1);
}
void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
@@ -122,26 +150,22 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
sway_view->iface.close = close;
sway_view->wlr_xdg_surface_v6 = xdg_surface;
sway_view->sway_xdg_surface_v6 = sway_surface;
- sway_view->surface = xdg_surface->surface;
sway_surface->view = sway_view;
-
+
// TODO:
// - Look up pid and open on appropriate workspace
// - Set new view to maximized so it behaves nicely
// - Criteria
-
+
sway_surface->commit.notify = handle_commit;
wl_signal_add(&xdg_surface->surface->events.commit, &sway_surface->commit);
- sway_surface->destroy.notify = handle_destroy;
- wl_signal_add(&xdg_surface->events.destroy, &sway_surface->destroy);
+ sway_surface->map.notify = handle_map;
+ wl_signal_add(&xdg_surface->events.map, &sway_surface->map);
- struct sway_seat *seat = input_manager_current_seat(input_manager);
- struct sway_container *focus = sway_seat_get_focus_inactive(seat, &root_container);
- struct sway_container *cont = container_view_create(focus, sway_view);
- sway_view->swayc = cont;
-
- arrange_windows(cont->parent, -1, -1);
+ sway_surface->unmap.notify = handle_unmap;
+ wl_signal_add(&xdg_surface->events.unmap, &sway_surface->unmap);
- sway_input_manager_set_focus(input_manager, cont);
+ sway_surface->destroy.notify = handle_destroy;
+ wl_signal_add(&xdg_surface->events.destroy, &sway_surface->destroy);
}
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c
index 38ee4656..01c993b3 100644
--- a/sway/desktop/xwayland.c
+++ b/sway/desktop/xwayland.c
@@ -14,10 +14,10 @@
#include "sway/input/input-manager.h"
#include "log.h"
- static bool assert_xwayland(struct sway_view *view) {
- return sway_assert(view->type == SWAY_XWAYLAND_VIEW && view->wlr_xwayland_surface,
- "Expected xwayland view!");
- }
+static bool assert_xwayland(struct sway_view *view) {
+ return sway_assert(view->type == SWAY_XWAYLAND_VIEW,
+ "Expected xwayland view!");
+}
static const char *get_prop(struct sway_view *view, enum sway_view_prop prop) {
if (!assert_xwayland(view)) {
@@ -99,73 +99,59 @@ static void handle_commit(struct wl_listener *listener, void *data) {
// TODO: Let floating views do whatever
view->width = sway_surface->pending_width;
view->height = sway_surface->pending_height;
+ view_damage_from(view);
}
static void handle_destroy(struct wl_listener *listener, void *data) {
struct sway_xwayland_surface *sway_surface =
wl_container_of(listener, sway_surface, destroy);
- struct wlr_xwayland_surface *xsurface = data;
+
wl_list_remove(&sway_surface->commit.link);
wl_list_remove(&sway_surface->destroy.link);
wl_list_remove(&sway_surface->request_configure.link);
- if (xsurface->override_redirect && xsurface->mapped) {
- wl_list_remove(&sway_surface->view->unmanaged_view_link);
- wl_list_init(&sway_surface->view->unmanaged_view_link);
- }
-
- struct sway_container *parent = container_view_destroy(sway_surface->view->swayc);
- if (parent) {
- arrange_windows(parent, -1, -1);
- }
-
- free(sway_surface->view);
- free(sway_surface);
+ wl_list_remove(&sway_surface->view->unmanaged_view_link);
+ container_view_destroy(sway_surface->view->swayc);
+ sway_surface->view->swayc = NULL;
+ sway_surface->view->surface = NULL;
}
-static void handle_unmap_notify(struct wl_listener *listener, void *data) {
+static void handle_unmap(struct wl_listener *listener, void *data) {
struct sway_xwayland_surface *sway_surface =
- wl_container_of(listener, sway_surface, unmap_notify);
- struct wlr_xwayland_surface *xsurface = data;
- if (xsurface->override_redirect && xsurface->mapped) {
- wl_list_remove(&sway_surface->view->unmanaged_view_link);
- wl_list_init(&sway_surface->view->unmanaged_view_link);
- }
-
- // take it out of the tree
- struct sway_container *parent = container_view_destroy(sway_surface->view->swayc);
- if (parent) {
- arrange_windows(parent, -1, -1);
- }
-
+ wl_container_of(listener, sway_surface, unmap);
+ view_damage_whole(sway_surface->view);
+ wl_list_remove(&sway_surface->view->unmanaged_view_link);
+ wl_list_init(&sway_surface->view->unmanaged_view_link);
+ container_view_destroy(sway_surface->view->swayc);
sway_surface->view->swayc = NULL;
sway_surface->view->surface = NULL;
}
-static void handle_map_notify(struct wl_listener *listener, void *data) {
- // TODO put the view back into the tree
+static void handle_map(struct wl_listener *listener, void *data) {
struct sway_xwayland_surface *sway_surface =
- wl_container_of(listener, sway_surface, map_notify);
+ wl_container_of(listener, sway_surface, map);
struct wlr_xwayland_surface *xsurface = data;
sway_surface->view->surface = xsurface->surface;
// put it back into the tree
- if (xsurface->override_redirect) {
+ if (wlr_xwayland_surface_is_unmanaged(xsurface) ||
+ xsurface->override_redirect) {
+ wl_list_remove(&sway_surface->view->unmanaged_view_link);
wl_list_insert(&root_container.sway_root->unmanaged_views,
&sway_surface->view->unmanaged_view_link);
} else {
struct sway_view *view = sway_surface->view;
container_view_destroy(view->swayc);
- struct sway_container *parent = root_container.children->items[0];
- parent = parent->children->items[0]; // workspace
-
- struct sway_container *cont = container_view_create(parent, view);
+ struct sway_seat *seat = input_manager_current_seat(input_manager);
+ struct sway_container *focus = sway_seat_get_focus_inactive(seat, &root_container);
+ struct sway_container *cont = container_view_create(focus, view);
view->swayc = cont;
-
arrange_windows(cont->parent, -1, -1);
sway_input_manager_set_focus(input_manager, cont);
}
+
+ view_damage_whole(sway_surface->view);
}
static void handle_configure_request(struct wl_listener *listener, void *data) {
@@ -206,9 +192,10 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
sway_view->iface.close = close_view;
sway_view->wlr_xwayland_surface = xsurface;
sway_view->sway_xwayland_surface = sway_surface;
- sway_view->surface = xsurface->surface;
sway_surface->view = sway_view;
+ wl_list_init(&sway_view->unmanaged_view_link);
+
// TODO:
// - Look up pid and open on appropriate workspace
// - Set new view to maximized so it behaves nicely
@@ -224,24 +211,11 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
&sway_surface->request_configure);
sway_surface->request_configure.notify = handle_configure_request;
- wl_signal_add(&xsurface->events.unmap_notify, &sway_surface->unmap_notify);
- sway_surface->unmap_notify.notify = handle_unmap_notify;
-
- wl_signal_add(&xsurface->events.map_notify, &sway_surface->map_notify);
- sway_surface->map_notify.notify = handle_map_notify;
-
- if (wlr_xwayland_surface_is_unmanaged(xsurface)) {
- // these don't get a container in the tree
- wl_list_insert(&root_container.sway_root->unmanaged_views,
- &sway_view->unmanaged_view_link);
- return;
- }
+ wl_signal_add(&xsurface->events.unmap, &sway_surface->unmap);
+ sway_surface->unmap.notify = handle_unmap;
- struct sway_seat *seat = input_manager_current_seat(input_manager);
- struct sway_container *focus = sway_seat_get_focus_inactive(seat, &root_container);
- struct sway_container *cont = container_view_create(focus, sway_view);
- sway_view->swayc = cont;
+ wl_signal_add(&xsurface->events.map, &sway_surface->map);
+ sway_surface->map.notify = handle_map;
- arrange_windows(cont->parent, -1, -1);
- sway_input_manager_set_focus(input_manager, cont);
+ handle_map(&sway_surface->map, xsurface);
}