aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
Diffstat (limited to 'sway')
-rw-r--r--sway/config.c12
-rw-r--r--sway/desktop/xdg_shell.c50
-rw-r--r--sway/desktop/xdg_shell_v6.c50
-rw-r--r--sway/desktop/xwayland.c9
-rw-r--r--sway/input/seat.c6
-rw-r--r--sway/tree/view.c9
6 files changed, 126 insertions, 10 deletions
diff --git a/sway/config.c b/sway/config.c
index c59f4f0d..d2386f46 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -560,7 +560,7 @@ static char *expand_line(const char *block, const char *line, bool add_brace) {
bool read_config(FILE *file, struct sway_config *config) {
bool reading_main_config = false;
- char *current_config, *config_pos;
+ char *this_config = NULL, *config_pos;
long config_size = 0;
if (config->current_config == NULL) {
reading_main_config = true;
@@ -569,8 +569,8 @@ bool read_config(FILE *file, struct sway_config *config) {
config_size = ftell(file);
rewind(file);
- config_pos = current_config = malloc(config_size + 1);
- if (current_config == NULL) {
+ config_pos = this_config = malloc(config_size + 1);
+ if (this_config == NULL) {
wlr_log(WLR_ERROR, "Unable to allocate buffer for config contents");
return false;
}
@@ -616,7 +616,7 @@ bool read_config(FILE *file, struct sway_config *config) {
list_foreach(stack, free);
list_free(stack);
free(line);
- free(current_config);
+ free(this_config);
return false;
}
wlr_log(WLR_DEBUG, "Expanded line: %s", expanded);
@@ -678,8 +678,8 @@ bool read_config(FILE *file, struct sway_config *config) {
list_free(stack);
if (reading_main_config) {
- current_config[config_size - 1] = '\0';
- config->current_config = current_config;
+ this_config[config_size - 1] = '\0';
+ config->current_config = this_config;
}
return success;
}
diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c
index be14adbe..17b7b750 100644
--- a/sway/desktop/xdg_shell.c
+++ b/sway/desktop/xdg_shell.c
@@ -45,6 +45,53 @@ static void popup_handle_destroy(struct wl_listener *listener, void *data) {
view_child_destroy(&popup->child);
}
+static void popup_unconstrain(struct sway_xdg_popup *popup) {
+ // get the output of the popup's positioner anchor point and convert it to
+ // the toplevel parent's coordinate system and then pass it to
+ // wlr_xdg_popup_unconstrain_from_box
+
+ struct sway_view *view = popup->child.view;
+ struct wlr_output_layout *output_layout =
+ root_container.sway_root->output_layout;
+ struct wlr_xdg_popup *wlr_popup = popup->wlr_xdg_surface->popup;
+
+ int anchor_lx, anchor_ly;
+ wlr_xdg_popup_get_anchor_point(wlr_popup, &anchor_lx, &anchor_ly);
+
+ int popup_lx, popup_ly;
+ wlr_xdg_popup_get_toplevel_coords(wlr_popup, wlr_popup->geometry.x,
+ wlr_popup->geometry.y, &popup_lx, &popup_ly);
+ popup_lx += view->x;
+ popup_ly += view->y;
+
+ anchor_lx += popup_lx;
+ anchor_ly += popup_ly;
+
+ double dest_x = 0, dest_y = 0;
+ wlr_output_layout_closest_point(output_layout, NULL, anchor_lx, anchor_ly,
+ &dest_x, &dest_y);
+
+ struct wlr_output *output =
+ wlr_output_layout_output_at(output_layout, dest_x, dest_y);
+ if (output == NULL) {
+ return;
+ }
+
+ int width = 0, height = 0;
+ wlr_output_effective_resolution(output, &width, &height);
+
+ // the output box expressed in the coordinate system of the toplevel parent
+ // of the popup
+ struct wlr_box output_toplevel_sx_box = {
+ .x = output->lx - view->x,
+ .y = output->ly - view->y,
+ .width = width,
+ .height = height
+ };
+
+ wlr_xdg_popup_unconstrain_from_box(wlr_popup, &output_toplevel_sx_box);
+}
+
static struct sway_xdg_popup *popup_create(
struct wlr_xdg_popup *wlr_popup, struct sway_view *view) {
struct wlr_xdg_surface *xdg_surface = wlr_popup->base;
@@ -55,12 +102,15 @@ static struct sway_xdg_popup *popup_create(
return NULL;
}
view_child_init(&popup->child, &popup_impl, view, xdg_surface->surface);
+ popup->wlr_xdg_surface = xdg_surface;
wl_signal_add(&xdg_surface->events.new_popup, &popup->new_popup);
popup->new_popup.notify = popup_handle_new_popup;
wl_signal_add(&xdg_surface->events.destroy, &popup->destroy);
popup->destroy.notify = popup_handle_destroy;
+ popup_unconstrain(popup);
+
return popup;
}
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c
index f5cf085a..43e58918 100644
--- a/sway/desktop/xdg_shell_v6.c
+++ b/sway/desktop/xdg_shell_v6.c
@@ -44,6 +44,53 @@ static void popup_handle_destroy(struct wl_listener *listener, void *data) {
view_child_destroy(&popup->child);
}
+static void popup_unconstrain(struct sway_xdg_popup_v6 *popup) {
+ // get the output of the popup's positioner anchor point and convert it to
+ // the toplevel parent's coordinate system and then pass it to
+ // wlr_xdg_popup_unconstrain_from_box
+
+ struct sway_view *view = popup->child.view;
+ struct wlr_output_layout *output_layout =
+ root_container.sway_root->output_layout;
+ struct wlr_xdg_popup_v6 *wlr_popup = popup->wlr_xdg_surface_v6->popup;
+
+ int anchor_lx, anchor_ly;
+ wlr_xdg_popup_v6_get_anchor_point(wlr_popup, &anchor_lx, &anchor_ly);
+
+ int popup_lx, popup_ly;
+ wlr_xdg_popup_v6_get_toplevel_coords(wlr_popup, wlr_popup->geometry.x,
+ wlr_popup->geometry.y, &popup_lx, &popup_ly);
+ popup_lx += view->x;
+ popup_ly += view->y;
+
+ anchor_lx += popup_lx;
+ anchor_ly += popup_ly;
+
+ double dest_x = 0, dest_y = 0;
+ wlr_output_layout_closest_point(output_layout, NULL, anchor_lx, anchor_ly,
+ &dest_x, &dest_y);
+
+ struct wlr_output *output =
+ wlr_output_layout_output_at(output_layout, dest_x, dest_y);
+ if (output == NULL) {
+ return;
+ }
+
+ int width = 0, height = 0;
+ wlr_output_effective_resolution(output, &width, &height);
+
+ // the output box expressed in the coordinate system of the toplevel parent
+ // of the popup
+ struct wlr_box output_toplevel_sx_box = {
+ .x = output->lx - view->x,
+ .y = output->ly - view->y,
+ .width = width,
+ .height = height
+ };
+
+ wlr_xdg_popup_v6_unconstrain_from_box(wlr_popup, &output_toplevel_sx_box);
+}
+
static struct sway_xdg_popup_v6 *popup_create(
struct wlr_xdg_popup_v6 *wlr_popup, struct sway_view *view) {
struct wlr_xdg_surface_v6 *xdg_surface = wlr_popup->base;
@@ -54,12 +101,15 @@ static struct sway_xdg_popup_v6 *popup_create(
return NULL;
}
view_child_init(&popup->child, &popup_impl, view, xdg_surface->surface);
+ popup->wlr_xdg_surface_v6 = xdg_surface;
wl_signal_add(&xdg_surface->events.new_popup, &popup->new_popup);
popup->new_popup.notify = popup_handle_new_popup;
wl_signal_add(&xdg_surface->events.destroy, &popup->destroy);
popup->destroy.notify = popup_handle_destroy;
+ popup_unconstrain(popup);
+
return popup;
}
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c
index 4e5cea7d..460d1cc8 100644
--- a/sway/desktop/xwayland.c
+++ b/sway/desktop/xwayland.c
@@ -246,6 +246,14 @@ static bool wants_floating(struct sway_view *view) {
return false;
}
+static bool has_client_side_decorations(struct sway_view *view) {
+ if (xwayland_view_from_view(view) == NULL) {
+ return false;
+ }
+ struct wlr_xwayland_surface *surface = view->wlr_xwayland_surface;
+ return surface->decorations != WLR_XWAYLAND_SURFACE_DECORATIONS_ALL;
+}
+
static void _close(struct sway_view *view) {
if (xwayland_view_from_view(view) == NULL) {
return;
@@ -269,6 +277,7 @@ static const struct sway_view_impl view_impl = {
.set_tiled = set_tiled,
.set_fullscreen = set_fullscreen,
.wants_floating = wants_floating,
+ .has_client_side_decorations = has_client_side_decorations,
.close = _close,
.destroy = destroy,
};
diff --git a/sway/input/seat.c b/sway/input/seat.c
index bf4e8876..5e65ca70 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -669,9 +669,11 @@ void seat_set_focus_warp(struct sway_seat *seat,
// If we've focused a floating container, bring it to the front.
// We do this by putting it at the end of the floating list.
// This must happen for both the pending and current children lists.
- if (container_is_floating(container)) {
+ if (container && container_is_floating(container)) {
list_move_to_end(container->parent->children, container);
- list_move_to_end(container->parent->current.children, container);
+ if (container_has_ancestor(container, container->current.parent)) {
+ list_move_to_end(container->parent->current.children, container);
+ }
}
// clean up unfocused empty workspace on new output
diff --git a/sway/tree/view.c b/sway/tree/view.c
index f99def6c..b356183c 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -315,7 +315,11 @@ void view_set_activated(struct sway_view *view, bool activated) {
}
void view_set_tiled(struct sway_view *view, bool tiled) {
- view->border = tiled ? config->border : B_NONE;
+ bool csd = true;
+ if (view->impl->has_client_side_decorations) {
+ csd = view->impl->has_client_side_decorations(view);
+ }
+ view->border = tiled || !csd ? config->border : B_NONE;
if (view->impl->set_tiled) {
view->impl->set_tiled(view, tiled);
}
@@ -752,8 +756,9 @@ struct sway_view *view_from_wlr_surface(struct wlr_surface *wlr_surface) {
return NULL;
}
+ const char *role = wlr_surface->role ? wlr_surface->role->name : NULL;
wlr_log(WLR_DEBUG, "Surface of unknown type (role %s): %p",
- wlr_surface->role, wlr_surface);
+ role, wlr_surface);
return NULL;
}