Close popups when changing focus

Also reverts the send frame done changes from the previous commit.
master
Ryan Dwyer 6 years ago
parent de86d65627
commit 7a59508da4

@ -50,6 +50,7 @@ struct sway_view_impl {
void (*for_each_popup)(struct sway_view *view,
wlr_surface_iterator_func_t iterator, void *user_data);
void (*close)(struct sway_view *view);
void (*close_popups)(struct sway_view *view);
void (*destroy)(struct sway_view *view);
};
@ -248,6 +249,8 @@ void view_set_tiled(struct sway_view *view, bool tiled);
void view_close(struct sway_view *view);
void view_close_popups(struct sway_view *view);
void view_damage_from(struct sway_view *view);
/**

@ -312,9 +312,8 @@ static void send_frame_done_container_iterator(struct sway_container *con,
return;
}
// Toplevels only
output_surface_for_each_surface(data->output, con->sway_view->surface,
con->x, con->y, send_frame_done_iterator, data->when);
output_view_for_each_surface(data->output, con->sway_view,
send_frame_done_iterator, data->when);
}
static void send_frame_done_container(struct sway_output *output,
@ -327,27 +326,6 @@ static void send_frame_done_container(struct sway_output *output,
send_frame_done_container_iterator, &data);
}
static void send_frame_done_popup_iterator(struct sway_output *output,
struct wlr_surface *surface, struct wlr_box *box, float rotation,
void *data) {
// Send frame done to this popup's surface
send_frame_done_iterator(output, surface, box, rotation, data);
// Send frame done to this popup's child toplevels
output_surface_for_each_surface(output, surface, box->x, box->y,
send_frame_done_iterator, data);
}
static void send_frame_done_popups(struct sway_output *output,
struct sway_view *view, struct timespec *when) {
struct send_frame_done_data data = {
.output = output,
.when = when,
};
output_view_for_each_popup(output, view,
send_frame_done_popup_iterator, &data);
}
static void send_frame_done(struct sway_output *output, struct timespec *when) {
if (output_has_opaque_overlay_layer_surface(output)) {
goto send_frame_overlay;
@ -385,13 +363,6 @@ static void send_frame_done(struct sway_output *output, struct timespec *when) {
&output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP], when);
}
struct sway_seat *seat = input_manager_current_seat(input_manager);
struct sway_container *focus = seat_get_focus(seat);
if (focus && focus->type == C_VIEW) {
send_frame_done_popups(output, focus->sway_view, when);
}
send_frame_overlay:
send_frame_done_layer(output,
&output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY], when);

@ -197,6 +197,18 @@ static void _close(struct sway_view *view) {
}
}
static void close_popups_iterator(struct wlr_surface *surface,
int sx, int sy, void *data) {
struct wlr_xdg_surface *xdg_surface =
wlr_xdg_surface_from_wlr_surface(surface);
wlr_xdg_surface_send_close(xdg_surface);
}
static void close_popups(struct sway_view *view) {
wlr_xdg_surface_for_each_popup(view->wlr_xdg_surface,
close_popups_iterator, NULL);
}
static void destroy(struct sway_view *view) {
struct sway_xdg_shell_view *xdg_shell_view =
xdg_shell_view_from_view(view);
@ -217,6 +229,7 @@ static const struct sway_view_impl view_impl = {
.for_each_surface = for_each_surface,
.for_each_popup = for_each_popup,
.close = _close,
.close_popups = close_popups,
.destroy = destroy,
};

@ -194,6 +194,18 @@ static void _close(struct sway_view *view) {
}
}
static void close_popups_iterator(struct wlr_surface *surface,
int sx, int sy, void *data) {
struct wlr_xdg_surface_v6 *xdg_surface_v6 =
wlr_xdg_surface_v6_from_wlr_surface(surface);
wlr_xdg_surface_v6_send_close(xdg_surface_v6);
}
static void close_popups(struct sway_view *view) {
wlr_xdg_surface_v6_for_each_popup(view->wlr_xdg_surface_v6,
close_popups_iterator, NULL);
}
static void destroy(struct sway_view *view) {
struct sway_xdg_shell_v6_view *xdg_shell_v6_view =
xdg_shell_v6_view_from_view(view);
@ -214,6 +226,7 @@ static const struct sway_view_impl view_impl = {
.for_each_surface = for_each_surface,
.for_each_popup = for_each_popup,
.close = _close,
.close_popups = close_popups,
.destroy = destroy,
};

@ -737,6 +737,13 @@ void seat_set_focus_warp(struct sway_seat *seat,
}
}
// Close any popups on the old focus
if (last_focus && last_focus != container) {
if (last_focus->type == C_VIEW) {
view_close_popups(last_focus->sway_view);
}
}
if (last_focus) {
if (last_workspace) {
ipc_event_workspace(last_workspace, container, "focus");

@ -302,6 +302,12 @@ void view_close(struct sway_view *view) {
}
}
void view_close_popups(struct sway_view *view) {
if (view->impl->close_popups) {
view->impl->close_popups(view);
}
}
void view_damage_from(struct sway_view *view) {
for (int i = 0; i < root_container.children->length; ++i) {
struct sway_container *cont = root_container.children->items[i];

Loading…
Cancel
Save