mirror of
https://github.com/swaywm/sway.git
synced 2025-11-20 06:59:46 -05:00
Merge branch 'wlroots' into split-containers2
This commit is contained in:
commit
741e3959e3
14 changed files with 386 additions and 138 deletions
|
|
@ -123,11 +123,14 @@ void terminate_swaybg(pid_t pid) {
|
|||
void apply_output_config(struct output_config *oc, struct sway_container *output) {
|
||||
assert(output->type == C_OUTPUT);
|
||||
|
||||
struct wlr_output_layout *output_layout =
|
||||
root_container.sway_root->output_layout;
|
||||
struct wlr_output *wlr_output = output->sway_output->wlr_output;
|
||||
|
||||
if (oc && oc->enabled == 0) {
|
||||
container_destroy(output);
|
||||
wlr_output_layout_remove(root_container.sway_root->output_layout,
|
||||
wlr_output);
|
||||
container_destroy(output);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -148,11 +151,9 @@ void apply_output_config(struct output_config *oc, struct sway_container *output
|
|||
// Find position for it
|
||||
if (oc && (oc->x != -1 || oc->y != -1)) {
|
||||
wlr_log(L_DEBUG, "Set %s position to %d, %d", oc->name, oc->x, oc->y);
|
||||
wlr_output_layout_add(root_container.sway_root->output_layout,
|
||||
wlr_output, oc->x, oc->y);
|
||||
wlr_output_layout_add(output_layout, wlr_output, oc->x, oc->y);
|
||||
} else {
|
||||
wlr_output_layout_add_auto(root_container.sway_root->output_layout,
|
||||
wlr_output);
|
||||
wlr_output_layout_add_auto(output_layout, wlr_output);
|
||||
}
|
||||
|
||||
if (!oc || !oc->background) {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
#include <wlr/types/wlr_output_damage.h>
|
||||
#include <wlr/types/wlr_output.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include "sway/input/input-manager.h"
|
||||
#include "sway/input/seat.h"
|
||||
#include "sway/layers.h"
|
||||
#include "sway/output.h"
|
||||
#include "sway/server.h"
|
||||
|
|
@ -187,6 +189,31 @@ void arrange_layers(struct sway_output *output) {
|
|||
&usable_area, false);
|
||||
arrange_layer(output, &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND],
|
||||
&usable_area, false);
|
||||
|
||||
// Find topmost keyboard interactive layer, if such a layer exists
|
||||
uint32_t layers_above_shell[] = {
|
||||
ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY,
|
||||
ZWLR_LAYER_SHELL_V1_LAYER_TOP,
|
||||
};
|
||||
size_t nlayers = sizeof(layers_above_shell) / sizeof(layers_above_shell[0]);
|
||||
struct sway_layer_surface *layer, *topmost = NULL;
|
||||
for (size_t i = 0; i < nlayers; ++i) {
|
||||
wl_list_for_each_reverse(layer,
|
||||
&output->layers[layers_above_shell[i]], link) {
|
||||
if (layer->layer_surface->current.keyboard_interactive) {
|
||||
topmost = layer;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (topmost != NULL) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
struct sway_seat *seat;
|
||||
wl_list_for_each(seat, &input_manager->seats, link) {
|
||||
seat_set_focus_layer(seat, topmost ? topmost->layer_surface : NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void handle_output_destroy(struct wl_listener *listener, void *data) {
|
||||
|
|
@ -251,6 +278,8 @@ static void handle_map(struct wl_listener *listener, void *data) {
|
|||
sway_layer, map);
|
||||
struct sway_output *output = sway_layer->layer_surface->output->data;
|
||||
wlr_output_damage_add_box(output->damage, &sway_layer->geo);
|
||||
wlr_surface_send_enter(sway_layer->layer_surface->surface,
|
||||
sway_layer->layer_surface->output);
|
||||
}
|
||||
|
||||
static void handle_unmap(struct wl_listener *listener, void *data) {
|
||||
|
|
|
|||
|
|
@ -57,10 +57,7 @@ static void rotate_child_position(double *sx, double *sy, double sw, double sh,
|
|||
*/
|
||||
static bool surface_intersect_output(struct wlr_surface *surface,
|
||||
struct wlr_output_layout *output_layout, struct wlr_output *wlr_output,
|
||||
double lx, double ly, float rotation, struct wlr_box *box) {
|
||||
double ox = lx, oy = ly;
|
||||
wlr_output_layout_output_coords(output_layout, wlr_output, &ox, &oy);
|
||||
|
||||
double ox, double oy, float rotation, struct wlr_box *box) {
|
||||
if (box != NULL) {
|
||||
box->x = ox * wlr_output->scale;
|
||||
box->y = oy * wlr_output->scale;
|
||||
|
|
@ -69,7 +66,7 @@ static bool surface_intersect_output(struct wlr_surface *surface,
|
|||
}
|
||||
|
||||
struct wlr_box layout_box = {
|
||||
.x = lx, .y = ly,
|
||||
.x = wlr_output->lx + ox, .y = wlr_output->ly + oy,
|
||||
.width = surface->current->width, .height = surface->current->height,
|
||||
};
|
||||
wlr_box_rotated_bounds(&layout_box, rotation, &layout_box);
|
||||
|
|
@ -78,7 +75,7 @@ static bool surface_intersect_output(struct wlr_surface *surface,
|
|||
|
||||
static void render_surface(struct wlr_surface *surface,
|
||||
struct wlr_output *wlr_output, struct timespec *when,
|
||||
double lx, double ly, float rotation) {
|
||||
double ox, double oy, float rotation) {
|
||||
struct wlr_renderer *renderer =
|
||||
wlr_backend_get_renderer(wlr_output->backend);
|
||||
|
||||
|
|
@ -90,7 +87,7 @@ static void render_surface(struct wlr_surface *surface,
|
|||
|
||||
struct wlr_box box;
|
||||
bool intersects = surface_intersect_output(surface, layout, wlr_output,
|
||||
lx, ly, rotation, &box);
|
||||
ox, oy, rotation, &box);
|
||||
if (intersects) {
|
||||
float matrix[9];
|
||||
enum wl_output_transform transform =
|
||||
|
|
@ -113,7 +110,7 @@ static void render_surface(struct wlr_surface *surface,
|
|||
surface->current->width, surface->current->height, rotation);
|
||||
|
||||
render_surface(subsurface->surface, wlr_output, when,
|
||||
lx + sx, ly + sy, rotation);
|
||||
ox + sx, oy + sy, rotation);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -211,9 +208,7 @@ static void render_view(struct sway_container *view, void *data) {
|
|||
}
|
||||
}
|
||||
|
||||
static void render_layer(struct sway_output *output,
|
||||
const struct wlr_box *output_layout_box,
|
||||
struct timespec *when,
|
||||
static void render_layer(struct sway_output *output, struct timespec *when,
|
||||
struct wl_list *layer) {
|
||||
struct sway_layer_surface *sway_layer;
|
||||
wl_list_for_each(sway_layer, layer, link) {
|
||||
|
|
@ -245,14 +240,15 @@ static void render_output(struct sway_output *output, struct timespec *when,
|
|||
float clear_color[] = {0.25f, 0.25f, 0.25f, 1.0f};
|
||||
wlr_renderer_clear(renderer, clear_color);
|
||||
|
||||
struct wlr_output_layout *layout = root_container.sway_root->output_layout;
|
||||
struct wlr_output_layout *output_layout =
|
||||
root_container.sway_root->output_layout;
|
||||
const struct wlr_box *output_box =
|
||||
wlr_output_layout_get_box(layout, wlr_output);
|
||||
wlr_output_layout_get_box(output_layout, wlr_output);
|
||||
|
||||
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]);
|
||||
render_layer(output, when,
|
||||
&output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND]);
|
||||
render_layer(output, when,
|
||||
&output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM]);
|
||||
|
||||
struct sway_seat *seat = input_manager_current_seat(input_manager);
|
||||
struct sway_container *focus =
|
||||
|
|
@ -262,7 +258,7 @@ static void render_output(struct sway_output *output, struct timespec *when,
|
|||
focus = output->swayc->children->items[0];
|
||||
}
|
||||
struct sway_container *workspace = focus->type == C_WORKSPACE ?
|
||||
focus : container_parent(focus, C_WORKSPACE);
|
||||
focus : container_parent(focus, C_WORKSPACE);
|
||||
|
||||
struct render_data rdata = {
|
||||
.output = output,
|
||||
|
|
@ -296,10 +292,10 @@ static void render_output(struct sway_output *output, struct timespec *when,
|
|||
}
|
||||
|
||||
// TODO: Consider revising this when fullscreen windows are supported
|
||||
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]);
|
||||
render_layer(output, when,
|
||||
&output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]);
|
||||
render_layer(output, when,
|
||||
&output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]);
|
||||
|
||||
renderer_end:
|
||||
wlr_renderer_end(renderer);
|
||||
|
|
|
|||
|
|
@ -180,13 +180,18 @@ static void handle_cursor_button(struct wl_listener *listener, void *data) {
|
|||
double sx, sy;
|
||||
struct sway_container *cont =
|
||||
container_at_cursor(cursor, &surface, &sx, &sy);
|
||||
if (surface && wlr_surface_is_layer_surface(surface)) {
|
||||
struct wlr_layer_surface *layer =
|
||||
wlr_layer_surface_from_wlr_surface(surface);
|
||||
if (layer->current.keyboard_interactive) {
|
||||
seat_set_focus_layer(cursor->seat, layer);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Avoid moving keyboard focus from a surface that accepts it to one
|
||||
// that does not unless the change would move us to a new workspace.
|
||||
//
|
||||
// This prevents, for example, losing focus when clicking on swaybar.
|
||||
//
|
||||
// TODO: Replace this condition with something like
|
||||
// !surface_accepts_keyboard_input
|
||||
if (surface && cont && cont->type != C_VIEW) {
|
||||
struct sway_container *new_ws = cont;
|
||||
if (new_ws && new_ws->type != C_WORKSPACE) {
|
||||
|
|
|
|||
|
|
@ -352,8 +352,11 @@ void seat_configure_xcursor(struct sway_seat *seat) {
|
|||
|
||||
void seat_set_focus_warp(struct sway_seat *seat,
|
||||
struct sway_container *container, bool warp) {
|
||||
struct sway_container *last_focus = seat_get_focus(seat);
|
||||
if (seat->focused_layer) {
|
||||
return;
|
||||
}
|
||||
|
||||
struct sway_container *last_focus = seat_get_focus(seat);
|
||||
if (container && last_focus == container) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -419,6 +422,37 @@ void seat_set_focus(struct sway_seat *seat,
|
|||
seat_set_focus_warp(seat, container, true);
|
||||
}
|
||||
|
||||
void seat_set_focus_layer(struct sway_seat *seat,
|
||||
struct wlr_layer_surface *layer) {
|
||||
if (!layer) {
|
||||
seat->focused_layer = NULL;
|
||||
return;
|
||||
}
|
||||
if (seat->focused_layer == layer) {
|
||||
return;
|
||||
}
|
||||
if (seat->has_focus) {
|
||||
struct sway_container *focus = seat_get_focus(seat);
|
||||
if (focus->type == C_VIEW) {
|
||||
wlr_seat_keyboard_clear_focus(seat->wlr_seat);
|
||||
view_set_activated(focus->sway_view, false);
|
||||
}
|
||||
}
|
||||
if (layer->layer >= ZWLR_LAYER_SHELL_V1_LAYER_TOP) {
|
||||
seat->focused_layer = layer;
|
||||
}
|
||||
struct wlr_keyboard *keyboard =
|
||||
wlr_seat_get_keyboard(seat->wlr_seat);
|
||||
if (keyboard) {
|
||||
wlr_seat_keyboard_notify_enter(seat->wlr_seat,
|
||||
layer->surface, keyboard->keycodes,
|
||||
keyboard->num_keycodes, &keyboard->modifiers);
|
||||
} else {
|
||||
wlr_seat_keyboard_notify_enter(seat->wlr_seat,
|
||||
layer->surface, NULL, 0, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
struct sway_container *seat_get_focus_inactive(struct sway_seat *seat,
|
||||
struct sway_container *container) {
|
||||
return seat_get_focus_by_type(seat, container, C_TYPES);
|
||||
|
|
|
|||
|
|
@ -18,10 +18,14 @@
|
|||
|
||||
struct sway_container root_container;
|
||||
|
||||
static void output_layout_change_notify(struct wl_listener *listener,
|
||||
static void output_layout_handle_change(struct wl_listener *listener,
|
||||
void *data) {
|
||||
struct wlr_box *layout_box = wlr_output_layout_get_box(
|
||||
root_container.sway_root->output_layout, NULL);
|
||||
struct wlr_output_layout *output_layout =
|
||||
root_container.sway_root->output_layout;
|
||||
const struct wlr_box *layout_box =
|
||||
wlr_output_layout_get_box(output_layout, NULL);
|
||||
root_container.x = layout_box->x;
|
||||
root_container.y = layout_box->y;
|
||||
root_container.width = layout_box->width;
|
||||
root_container.height = layout_box->height;
|
||||
|
||||
|
|
@ -33,8 +37,8 @@ static void output_layout_change_notify(struct wl_listener *listener,
|
|||
}
|
||||
struct sway_output *output = output_container->sway_output;
|
||||
|
||||
struct wlr_box *output_box = wlr_output_layout_get_box(
|
||||
root_container.sway_root->output_layout, output->wlr_output);
|
||||
const struct wlr_box *output_box =
|
||||
wlr_output_layout_get_box(output_layout, output->wlr_output);
|
||||
if (!output_box) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -74,7 +78,7 @@ void layout_init(void) {
|
|||
wl_signal_init(&root_container.sway_root->events.new_container);
|
||||
|
||||
root_container.sway_root->output_layout_change.notify =
|
||||
output_layout_change_notify;
|
||||
output_layout_handle_change;
|
||||
wl_signal_add(&root_container.sway_root->output_layout->events.change,
|
||||
&root_container.sway_root->output_layout_change);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -139,6 +139,24 @@ char *workspace_next_name(const char *output_name) {
|
|||
continue;
|
||||
}
|
||||
|
||||
// If the command is workspace number <name>, isolate the name
|
||||
if (strncmp(_target, "number ", strlen("number ")) == 0) {
|
||||
size_t length = strlen(_target) - strlen("number ") + 1;
|
||||
char *temp = malloc(length);
|
||||
strncpy(temp, _target + strlen("number "), length - 1);
|
||||
temp[length - 1] = '\0';
|
||||
free(_target);
|
||||
_target = temp;
|
||||
wlr_log(L_DEBUG, "Isolated name from workspace number: '%s'", _target);
|
||||
|
||||
// Make sure the workspace number doesn't already exist
|
||||
if (workspace_by_number(_target)) {
|
||||
free(_target);
|
||||
free(dup);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure that the workspace doesn't already exist
|
||||
if (workspace_by_name(_target)) {
|
||||
free(_target);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue