aboutsummaryrefslogtreecommitdiff
path: root/rootston
diff options
context:
space:
mode:
Diffstat (limited to 'rootston')
-rw-r--r--rootston/config.c9
-rw-r--r--rootston/desktop.c42
-rw-r--r--rootston/input.c3
-rw-r--r--rootston/layer_shell.c339
-rw-r--r--rootston/meson.build1
-rw-r--r--rootston/output.c133
-rw-r--r--rootston/seat.c27
-rw-r--r--rootston/xdg_shell.c37
-rw-r--r--rootston/xdg_shell_v6.c39
9 files changed, 558 insertions, 72 deletions
diff --git a/rootston/config.c b/rootston/config.c
index e63efc0b..0883f6d4 100644
--- a/rootston/config.c
+++ b/rootston/config.c
@@ -25,7 +25,9 @@ static void usage(const char *name, int ret) {
" (default: rootston.ini).\n"
" See `rootston.ini.example` for config\n"
" file documentation.\n"
- " -E <COMMAND> Command that will be ran at startup.\n" , name);
+ " -E <COMMAND> Command that will be ran at startup.\n"
+ " -D Enable damage tracking debugging.\n",
+ name);
exit(ret);
}
@@ -394,7 +396,7 @@ struct roots_config *roots_config_create_from_args(int argc, char *argv[]) {
wl_list_init(&config->bindings);
int c;
- while ((c = getopt(argc, argv, "C:E:h")) != -1) {
+ while ((c = getopt(argc, argv, "C:E:hD")) != -1) {
switch (c) {
case 'C':
config->config_path = strdup(optarg);
@@ -402,6 +404,9 @@ struct roots_config *roots_config_create_from_args(int argc, char *argv[]) {
case 'E':
config->startup_cmd = strdup(optarg);
break;
+ case 'D':
+ config->debug_damage_tracking = true;
+ break;
case 'h':
case '?':
usage(argv[0], c != 'h');
diff --git a/rootston/desktop.c b/rootston/desktop.c
index 65d9a280..15e0e336 100644
--- a/rootston/desktop.c
+++ b/rootston/desktop.c
@@ -9,9 +9,10 @@
#include <wlr/types/wlr_cursor.h>
#include <wlr/types/wlr_gamma_control.h>
#include <wlr/types/wlr_idle.h>
+#include <wlr/types/wlr_idle_inhibit_v1.h>
+#include <wlr/types/wlr_layer_shell.h>
#include <wlr/types/wlr_linux_dmabuf.h>
#include <wlr/types/wlr_output_layout.h>
-#include <wlr/types/wlr_idle_inhibit_v1.h>
#include <wlr/types/wlr_primary_selection.h>
#include <wlr/types/wlr_server_decoration.h>
#include <wlr/types/wlr_wl_shell.h>
@@ -187,6 +188,25 @@ static struct wlr_output *view_get_output(struct roots_view *view) {
output_y);
}
+void view_arrange_maximized(struct roots_view *view) {
+ struct wlr_box view_box;
+ view_get_box(view, &view_box);
+
+ struct wlr_output *output = view_get_output(view);
+ struct roots_output *roots_output = output->data;
+ struct wlr_box *output_box =
+ wlr_output_layout_get_box(view->desktop->layout, output);
+ struct wlr_box usable_area;
+ memcpy(&usable_area, &roots_output->usable_area,
+ sizeof(struct wlr_box));
+ usable_area.x += output_box->x;
+ usable_area.y += output_box->y;
+
+ view_move_resize(view, usable_area.x, usable_area.y,
+ usable_area.width, usable_area.height);
+ view_rotate(view, 0);
+}
+
void view_maximize(struct roots_view *view, bool maximized) {
if (view->maximized == maximized) {
return;
@@ -197,23 +217,14 @@ void view_maximize(struct roots_view *view, bool maximized) {
}
if (!view->maximized && maximized) {
- struct wlr_box view_box;
- view_get_box(view, &view_box);
-
view->maximized = true;
view->saved.x = view->x;
view->saved.y = view->y;
view->saved.rotation = view->rotation;
- view->saved.width = view_box.width;
- view->saved.height = view_box.height;
-
- struct wlr_output *output = view_get_output(view);
- struct wlr_box *output_box =
- wlr_output_layout_get_box(view->desktop->layout, output);
+ view->saved.width = view->width;
+ view->saved.height = view->height;
- view_move_resize(view, output_box->x, output_box->y, output_box->width,
- output_box->height);
- view_rotate(view, 0);
+ view_arrange_maximized(view);
}
if (view->maximized && !maximized) {
@@ -714,6 +725,11 @@ struct roots_desktop *desktop_create(struct roots_server *server,
&desktop->wl_shell_surface);
desktop->wl_shell_surface.notify = handle_wl_shell_surface;
+ desktop->layer_shell = wlr_layer_shell_create(server->wl_display);
+ wl_signal_add(&desktop->layer_shell->events.new_surface,
+ &desktop->layer_shell_surface);
+ desktop->layer_shell_surface.notify = handle_layer_shell_surface;
+
#ifdef WLR_HAS_XWAYLAND
const char *cursor_theme = NULL;
const char *cursor_default = ROOTS_XCURSOR_DEFAULT;
diff --git a/rootston/input.c b/rootston/input.c
index 657b0946..3e1b06fb 100644
--- a/rootston/input.c
+++ b/rootston/input.c
@@ -2,10 +2,13 @@
#include <stdlib.h>
#include <wayland-server.h>
#include <wlr/backend/libinput.h>
+#include <wlr/config.h>
#include <wlr/types/wlr_cursor.h>
#include <wlr/util/log.h>
#include <wlr/xcursor.h>
+#ifdef WLR_HAS_XWAYLAND
#include <wlr/xwayland.h>
+#endif
#include "rootston/config.h"
#include "rootston/input.h"
#include "rootston/keyboard.h"
diff --git a/rootston/layer_shell.c b/rootston/layer_shell.c
new file mode 100644
index 00000000..06ab15c3
--- /dev/null
+++ b/rootston/layer_shell.c
@@ -0,0 +1,339 @@
+#include <assert.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <wayland-server.h>
+#include <wlr/types/wlr_box.h>
+#include <wlr/types/wlr_surface.h>
+#include <wlr/types/wlr_layer_shell.h>
+#include <wlr/util/log.h>
+#include "rootston/desktop.h"
+#include "rootston/layers.h"
+#include "rootston/output.h"
+#include "rootston/server.h"
+
+static void apply_exclusive(struct wlr_box *usable_area,
+ uint32_t anchor, int32_t exclusive,
+ int32_t margin_top, int32_t margin_right,
+ int32_t margin_bottom, int32_t margin_left) {
+ if (exclusive <= 0) {
+ return;
+ }
+ struct {
+ uint32_t anchors;
+ int *positive_axis;
+ int *negative_axis;
+ int margin;
+ } edges[] = {
+ {
+ .anchors =
+ ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT |
+ ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT |
+ ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP,
+ .positive_axis = &usable_area->y,
+ .negative_axis = &usable_area->height,
+ .margin = margin_top,
+ },
+ {
+ .anchors =
+ ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT |
+ ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT |
+ ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM,
+ .positive_axis = NULL,
+ .negative_axis = &usable_area->height,
+ .margin = margin_bottom,
+ },
+ {
+ .anchors =
+ ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT |
+ ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP |
+ ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM,
+ .positive_axis = &usable_area->x,
+ .negative_axis = &usable_area->width,
+ .margin = margin_left,
+ },
+ {
+ .anchors =
+ ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT |
+ ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP |
+ ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM,
+ .positive_axis = NULL,
+ .negative_axis = &usable_area->width,
+ .margin = margin_right,
+ },
+ };
+ for (size_t i = 0; i < sizeof(edges) / sizeof(edges[0]); ++i) {
+ if ((anchor & edges[i].anchors) == edges[i].anchors) {
+ if (edges[i].positive_axis) {
+ *edges[i].positive_axis += exclusive + edges[i].margin;
+ }
+ if (edges[i].negative_axis) {
+ *edges[i].negative_axis -= exclusive + edges[i].margin;
+ }
+ }
+ }
+}
+
+static void arrange_layer(struct wlr_output *output, struct wl_list *list,
+ struct wlr_box *usable_area, bool exclusive) {
+ struct roots_layer_surface *roots_surface;
+ struct wlr_box full_area = { 0 };
+ wlr_output_effective_resolution(output,
+ &full_area.width, &full_area.height);
+ wl_list_for_each(roots_surface, list, link) {
+ struct wlr_layer_surface *layer = roots_surface->layer_surface;
+ struct wlr_layer_surface_state *state = &layer->current;
+ if (exclusive != (state->exclusive_zone >0)) {
+ continue;
+ }
+ struct wlr_box bounds;
+ if (state->exclusive_zone == -1) {
+ bounds = full_area;
+ } else {
+ bounds = *usable_area;
+ }
+ struct wlr_box box = {
+ .width = state->desired_width,
+ .height = state->desired_height
+ };
+ // Horizontal axis
+ const uint32_t both_horiz = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT
+ | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT;
+ if ((state->anchor & both_horiz) && box.width == 0) {
+ box.x = bounds.x;
+ box.width = bounds.width;
+ } else if ((state->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT)) {
+ box.x = bounds.x;
+ } else if ((state->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT)) {
+ box.x = bounds.x + (bounds.width - box.width);
+ } else {
+ box.x = bounds.x + ((bounds.width / 2) - (box.width / 2));
+ }
+ // Vertical axis
+ const uint32_t both_vert = ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP
+ | ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM;
+ if ((state->anchor & both_vert) && box.height == 0) {
+ box.y = bounds.y;
+ box.height = bounds.height;
+ } else if ((state->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP)) {
+ box.y = bounds.y;
+ } else if ((state->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM)) {
+ box.y = bounds.y + (bounds.height - box.height);
+ } else {
+ box.y = bounds.y + ((bounds.height / 2) - (box.height / 2));
+ }
+ // Margin
+ if ((state->anchor & both_horiz) == both_horiz) {
+ box.x += state->margin.left;
+ box.width -= state->margin.left + state->margin.right;
+ } else if ((state->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT)) {
+ box.x += state->margin.left;
+ } else if ((state->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT)) {
+ box.x -= state->margin.right;
+ }
+ if ((state->anchor & both_vert) == both_vert) {
+ box.y += state->margin.top;
+ box.height -= state->margin.top + state->margin.bottom;
+ } else if ((state->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP)) {
+ box.y += state->margin.top;
+ } else if ((state->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM)) {
+ box.y -= state->margin.bottom;
+ }
+ if (box.width < 0 || box.height < 0) {
+ // TODO: Bubble up a protocol error?
+ wlr_layer_surface_close(layer);
+ continue;
+ }
+ // Apply
+ roots_surface->geo = box;
+ apply_exclusive(usable_area, state->anchor, state->exclusive_zone,
+ state->margin.top, state->margin.right,
+ state->margin.bottom, state->margin.left);
+ wlr_layer_surface_configure(layer, box.width, box.height);
+ }
+}
+
+static void arrange_layers(struct wlr_output *_output) {
+ struct roots_output *output = _output->data;
+
+ struct wlr_box usable_area = { 0 };
+ wlr_output_effective_resolution(output->wlr_output,
+ &usable_area.width, &usable_area.height);
+
+ // Arrange exclusive surfaces from top->bottom
+ arrange_layer(output->wlr_output,
+ &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY],
+ &usable_area, true);
+ arrange_layer(output->wlr_output,
+ &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP],
+ &usable_area, true);
+ arrange_layer(output->wlr_output,
+ &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM],
+ &usable_area, true);
+ arrange_layer(output->wlr_output,
+ &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND],
+ &usable_area, true);
+ memcpy(&output->usable_area, &usable_area, sizeof(struct wlr_box));
+
+ struct roots_view *view;
+ wl_list_for_each(view, &output->desktop->views, link) {
+ if (view->maximized) {
+ view_arrange_maximized(view);
+ }
+ }
+
+ // Arrange non-exlusive surfaces from top->bottom
+ usable_area.x = usable_area.y = 0;
+ wlr_output_effective_resolution(output->wlr_output,
+ &usable_area.width, &usable_area.height);
+ arrange_layer(output->wlr_output,
+ &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY],
+ &usable_area, false);
+ arrange_layer(output->wlr_output,
+ &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP],
+ &usable_area, false);
+ arrange_layer(output->wlr_output,
+ &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM],
+ &usable_area, false);
+ arrange_layer(output->wlr_output,
+ &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND],
+ &usable_area, false);
+}
+
+static void handle_output_destroy(struct wl_listener *listener, void *data) {
+ struct roots_layer_surface *layer =
+ wl_container_of(listener, layer, output_destroy);
+ layer->layer_surface->output = NULL;
+ wl_list_remove(&layer->output_destroy.link);
+ wl_list_remove(&layer->output_mode.link);
+ wlr_layer_surface_close(layer->layer_surface);
+}
+
+static void handle_output_mode(struct wl_listener *listener, void *data) {
+ arrange_layers((struct wlr_output *)data);
+}
+
+static void handle_output_transform(struct wl_listener *listener, void *data) {
+ arrange_layers((struct wlr_output *)data);
+}
+
+static void handle_surface_commit(struct wl_listener *listener, void *data) {
+ struct roots_layer_surface *layer =
+ wl_container_of(listener, layer, surface_commit);
+ struct wlr_layer_surface *layer_surface = layer->layer_surface;
+ struct wlr_output *wlr_output = layer_surface->output;
+ if (wlr_output != NULL) {
+ struct roots_output *output = wlr_output->data;
+ struct wlr_box old_geo = layer->geo;
+ arrange_layers(wlr_output);
+ if (memcmp(&old_geo, &layer->geo, sizeof(struct wlr_box)) != 0) {
+ output_damage_whole_local_surface(output, layer_surface->surface,
+ old_geo.x, old_geo.y, 0);
+ output_damage_whole_local_surface(output, layer_surface->surface,
+ layer->geo.x, layer->geo.y, 0);
+ } else {
+ output_damage_from_local_surface(output, layer_surface->surface,
+ layer->geo.x, layer->geo.y, 0);
+ }
+ }
+}
+
+static void unmap(struct wlr_layer_surface *layer_surface) {
+ struct roots_layer_surface *layer = layer_surface->data;
+ struct wlr_output *wlr_output = layer_surface->output;
+ if (wlr_output != NULL) {
+ struct roots_output *output = wlr_output->data;
+ wlr_output_damage_add_box(output->damage, &layer->geo);
+ }
+}
+
+static void handle_destroy(struct wl_listener *listener, void *data) {
+ struct roots_layer_surface *layer = wl_container_of(
+ listener, layer, destroy);
+ if (layer->layer_surface->mapped) {
+ unmap(layer->layer_surface);
+ }
+ wl_list_remove(&layer->link);
+ wl_list_remove(&layer->destroy.link);
+ wl_list_remove(&layer->map.link);
+ wl_list_remove(&layer->unmap.link);
+ wl_list_remove(&layer->surface_commit.link);
+ wl_list_remove(&layer->output_destroy.link);
+ wl_list_remove(&layer->output_mode.link);
+ wl_list_remove(&layer->output_transform.link);
+ arrange_layers(layer->layer_surface->output);
+ free(layer);
+}
+
+static void handle_map(struct wl_listener *listener, void *data) {
+ struct wlr_layer_surface *layer_surface = data;
+ struct roots_layer_surface *layer = layer_surface->data;
+ struct wlr_output *wlr_output = layer_surface->output;
+ struct roots_output *output = wlr_output->data;
+ wlr_output_damage_add_box(output->damage, &layer->geo);
+}
+
+static void handle_unmap(struct wl_listener *listener, void *data) {
+ struct roots_layer_surface *layer = wl_container_of(
+ listener, layer, unmap);
+ unmap(layer->layer_surface);
+}
+
+void handle_layer_shell_surface(struct wl_listener *listener, void *data) {
+ struct wlr_layer_surface *layer_surface = data;
+ struct roots_desktop *desktop =
+ wl_container_of(listener, desktop, layer_shell_surface);
+ wlr_log(L_DEBUG, "new layer surface: namespace %s layer %d anchor %d "
+ "size %dx%d margin %d,%d,%d,%d",
+ layer_surface->namespace, layer_surface->layer, layer_surface->layer,
+ layer_surface->client_pending.desired_width,
+ layer_surface->client_pending.desired_height,
+ layer_surface->client_pending.margin.top,
+ layer_surface->client_pending.margin.right,
+ layer_surface->client_pending.margin.bottom,
+ layer_surface->client_pending.margin.left);
+
+ struct roots_layer_surface *roots_surface =
+ calloc(1, sizeof(struct roots_layer_surface));
+ if (!roots_surface) {
+ return;
+ }
+
+ roots_surface->surface_commit.notify = handle_surface_commit;
+ wl_signal_add(&layer_surface->surface->events.commit,
+ &roots_surface->surface_commit);
+
+ roots_surface->output_destroy.notify = handle_output_destroy;
+ wl_signal_add(&layer_surface->output->events.destroy,
+ &roots_surface->output_destroy);
+
+ roots_surface->output_mode.notify = handle_output_mode;
+ wl_signal_add(&layer_surface->output->events.mode,
+ &roots_surface->output_mode);
+
+ roots_surface->output_transform.notify = handle_output_transform;
+ wl_signal_add(&layer_surface->output->events.transform,
+ &roots_surface->output_transform);
+
+ roots_surface->destroy.notify = handle_destroy;
+ wl_signal_add(&layer_surface->events.destroy, &roots_surface->destroy);
+ roots_surface->map.notify = handle_map;
+ wl_signal_add(&layer_surface->events.map, &roots_surface->map);
+ roots_surface->unmap.notify = handle_unmap;
+ wl_signal_add(&layer_surface->events.unmap, &roots_surface->unmap);
+ // TODO: Listen for subsurfaces
+
+ roots_surface->layer_surface = layer_surface;
+ layer_surface->data = roots_surface;
+
+ struct roots_output *output = layer_surface->output->data;
+ wl_list_insert(&output->layers[layer_surface->layer], &roots_surface->link);
+
+ // Temporarily set the layer's current state to client_pending
+ // So that we can easily arrange it
+ struct wlr_layer_surface_state old_state = layer_surface->current;
+ layer_surface->current = layer_surface->client_pending;
+
+ arrange_layers(output->wlr_output);
+
+ layer_surface->current = old_state;
+}
diff --git a/rootston/meson.build b/rootston/meson.build
index 9dbe37c2..1b78c7c8 100644
--- a/rootston/meson.build
+++ b/rootston/meson.build
@@ -5,6 +5,7 @@ sources = [
'ini.c',
'input.c',
'keyboard.c',
+ 'layer_shell.c',
'main.c',
'output.c',
'seat.c',
diff --git a/rootston/output.c b/rootston/output.c
index 1284c928..d903963e 100644
--- a/rootston/output.c
+++ b/rootston/output.c
@@ -3,6 +3,7 @@
#include <stdbool.h>
#include <stdlib.h>
#include <time.h>
+#include <wlr/config.h>
#include <wlr/types/wlr_matrix.h>
#include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_output_layout.h>
@@ -12,6 +13,7 @@
#include <wlr/util/log.h>
#include <wlr/util/region.h>
#include "rootston/config.h"
+#include "rootston/layers.h"
#include "rootston/output.h"
#include "rootston/server.h"
@@ -363,7 +365,7 @@ static void render_decorations(struct roots_view *view,
pixman_region32_rectangles(&damage, &nrects);
for (int i = 0; i < nrects; ++i) {
scissor_output(output, &rects[i]);
- wlr_render_colored_quad(renderer, color, matrix);
+ wlr_render_quad_with_matrix(renderer, color, matrix);
}
damage_finish:
@@ -416,6 +418,33 @@ static void surface_send_frame_done(struct wlr_surface *surface, double lx,
wlr_surface_send_frame_done(surface, when);
}
+static void render_layer(
+ struct roots_output *output,
+ const struct wlr_box *output_layout_box,
+ struct render_data *data,
+ struct wl_list *layer) {
+ struct roots_layer_surface *roots_surface;
+ wl_list_for_each(roots_surface, layer, link) {
+ struct wlr_layer_surface *layer = roots_surface->layer_surface;
+ render_surface(layer->surface,
+ roots_surface->geo.x + output_layout_box->x,
+ roots_surface->geo.y + output_layout_box->y,
+ 0, data);
+ }
+}
+
+static void layers_send_done(
+ struct roots_output *output, struct timespec *when) {
+ size_t len = sizeof(output->layers) / sizeof(output->layers[0]);
+ for (size_t i = 0; i < len; ++i) {
+ struct roots_layer_surface *roots_surface;
+ wl_list_for_each(roots_surface, &output->layers[i], link) {
+ struct wlr_layer_surface *layer = roots_surface->layer_surface;
+ wlr_surface_send_frame_done(layer->surface, when);
+ }
+ }
+}
+
static void render_output(struct roots_output *output) {
struct wlr_output *wlr_output = output->wlr_output;
struct roots_desktop *desktop = output->desktop;
@@ -432,14 +461,15 @@ static void render_output(struct roots_output *output) {
float clear_color[] = {0.25f, 0.25f, 0.25f, 1.0f};
+ const struct wlr_box *output_box =
+ wlr_output_layout_get_box(desktop->layout, wlr_output);
+
// Check if we can delegate the fullscreen surface to the output
if (output->fullscreen_view != NULL &&
output->fullscreen_view->wlr_surface != NULL) {
struct roots_view *view = output->fullscreen_view;
// Make sure the view is centered on screen
- const struct wlr_box *output_box =
- wlr_output_layout_get_box(desktop->layout, wlr_output);
struct wlr_box view_box;
view_get_box(view, &view_box);
double view_x = (double)(output_box->width - view_box.width) / 2 +
@@ -486,6 +516,10 @@ static void render_output(struct roots_output *output) {
goto renderer_end;
}
+ if (server->config->debug_damage_tracking) {
+ wlr_renderer_clear(renderer, (float[]){1, 1, 0, 0});
+ }
+
int nrects;
pixman_box32_t *rects = pixman_region32_rectangles(&damage, &nrects);
for (int i = 0; i < nrects; ++i) {
@@ -493,6 +527,11 @@ static void render_output(struct roots_output *output) {
wlr_renderer_clear(renderer, clear_color);
}
+ render_layer(output, output_box, &data,
+ &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND]);
+ render_layer(output, output_box, &data,
+ &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM]);
+
// If a view is fullscreen on this output, render it
if (output->fullscreen_view != NULL) {
struct roots_view *view = output->fullscreen_view;
@@ -515,20 +554,24 @@ static void render_output(struct roots_output *output) {
render_surface, &data);
}
#endif
-
- goto renderer_end;
- }
-
- // Render all views
- struct roots_view *view;
- wl_list_for_each_reverse(view, &desktop->views, link) {
- render_view(view, &data);
+ } else {
+ // Render all views
+ struct roots_view *view;
+ wl_list_for_each_reverse(view, &desktop->views, link) {
+ render_view(view, &data);
+ }
+ // Render top layer above shell views
+ render_layer(output, output_box, &data,
+ &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]);
}
// Render drag icons
data.alpha = 1.0;
drag_icons_for_each_surface(server->input, render_surface, &data);
+ render_layer(output, output_box, &data,
+ &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]);
+
renderer_end:
wlr_renderer_scissor(renderer, NULL);
wlr_renderer_end(renderer);
@@ -565,6 +608,7 @@ damage_finish:
drag_icons_for_each_surface(server->input, surface_send_frame_done,
&data);
}
+ layers_send_done(output, data.when);
}
void output_damage_whole(struct roots_output *output) {
@@ -621,6 +665,15 @@ static void damage_whole_surface(struct wlr_surface *surface,
wlr_output_damage_add_box(output->damage, &box);
}
+void output_damage_whole_local_surface(struct roots_output *output,
+ struct wlr_surface *surface, double ox, double oy, float rotation) {
+ struct wlr_output_layout_output *layout = wlr_output_layout_get(
+ output->desktop->layout, output->wlr_output);
+ damage_whole_surface(surface, ox + layout->x, oy + layout->y,
+ rotation, output);
+ // TODO: subsurfaces
+}
+
static void damage_whole_decoration(struct roots_view *view,
struct roots_output *output) {
if (!view->decorated || view->wlr_surface == NULL) {
@@ -667,32 +720,32 @@ static void damage_from_surface(struct wlr_surface *surface,
surface_intersect_output(surface, output->desktop->layout,
wlr_output, lx, ly, rotation, &box);
- if (rotation == 0) {
- pixman_region32_t damage;
- pixman_region32_init(&damage);
- pixman_region32_copy(&damage, &surface->current->surface_damage);
- wlr_region_scale(&damage, &damage, wlr_output->scale);
- if (ceil(wlr_output->scale) > surface->current->scale) {
- // When scaling up a surface, it'll become blurry so we need to
- // expand the damage region
- wlr_region_expand(&damage, &damage,
- ceil(wlr_output->scale) - surface->current->scale);
- }
- pixman_region32_translate(&damage, box.x, box.y);
- wlr_output_damage_add(output->damage, &damage);
- pixman_region32_fini(&damage);
- } else {
- pixman_box32_t *extents =
- pixman_region32_extents(&surface->current->surface_damage);
- struct wlr_box damage_box = {
- .x = box.x + extents->x1 * wlr_output->scale,
- .y = box.y + extents->y1 * wlr_output->scale,
- .width = (extents->x2 - extents->x1) * wlr_output->scale,
- .height = (extents->y2 - extents->y1) * wlr_output->scale,
- };
- wlr_box_rotated_bounds(&damage_box, rotation, &damage_box);
- wlr_output_damage_add_box(output->damage, &damage_box);
- }
+ int center_x = box.x + box.width/2;
+ int center_y = box.y + box.height/2;
+
+ pixman_region32_t damage;
+ pixman_region32_init(&damage);
+ pixman_region32_copy(&damage, &surface->current->surface_damage);
+ wlr_region_scale(&damage, &damage, wlr_output->scale);
+ if (ceil(wlr_output->scale) > surface->current->scale) {
+ // When scaling up a surface, it'll become blurry so we need to
+ // expand the damage region
+ wlr_region_expand(&damage, &damage,
+ ceil(wlr_output->scale) - surface->current->scale);
+ }
+ pixman_region32_translate(&damage, box.x, box.y);
+ wlr_region_rotated_bounds(&damage, &damage, rotation, center_x, center_y);
+ wlr_output_damage_add(output->damage, &damage);
+ pixman_region32_fini(&damage);
+}
+
+void output_damage_from_local_surface(struct roots_output *output,
+ struct wlr_surface *surface, double ox, double oy, float rotation) {
+ struct wlr_output_layout_output *layout = wlr_output_layout_get(
+ output->desktop->layout, output->wlr_output);
+ damage_from_surface(surface, ox + layout->x, oy + layout->y,
+ rotation, output);
+ // TODO: Subsurfaces
}
void output_damage_from_view(struct roots_output *output,
@@ -785,6 +838,7 @@ void handle_new_output(struct wl_listener *listener, void *data) {
clock_gettime(CLOCK_MONOTONIC, &output->last_frame);
output->desktop = desktop;
output->wlr_output = wlr_output;
+ wlr_output->data = output;
wl_list_insert(&desktop->outputs, &output->link);
output->damage = wlr_output_damage_create(wlr_output);
@@ -796,6 +850,11 @@ void handle_new_output(struct wl_listener *listener, void *data) {
output->damage_destroy.notify = output_damage_handle_destroy;
wl_signal_add(&output->damage->events.destroy, &output->damage_destroy);
+ size_t len = sizeof(output->layers) / sizeof(output->layers[0]);
+ for (size_t i = 0; i < len; ++i) {
+ wl_list_init(&output->layers[i]);
+ }
+
struct roots_output_config *output_config =
roots_config_get_output(config, wlr_output);
if (output_config) {
diff --git a/rootston/seat.c b/rootston/seat.c
index d2d211ba..bdcad5c7 100644
--- a/rootston/seat.c
+++ b/rootston/seat.c
@@ -723,6 +723,33 @@ void roots_seat_set_focus(struct roots_seat *seat, struct roots_view *view) {
wl_list_insert(&seat->input->server->desktop->views, &view->link);
}
+
+ bool unfullscreen = true;
+
+#ifdef WLR_HAS_XWAYLAND
+ if (view && view->type == ROOTS_XWAYLAND_VIEW &&
+ view->xwayland_surface->override_redirect) {
+ unfullscreen = false;
+ }
+#endif
+
+ if (view && unfullscreen) {
+ struct roots_desktop *desktop = view->desktop;
+ struct roots_output *output;
+ struct wlr_box box;
+ view_get_box(view, &box);
+ wl_list_for_each(output, &desktop->outputs, link) {
+ if (output->fullscreen_view &&
+ output->fullscreen_view != view &&
+ wlr_output_layout_intersects(
+ desktop->layout,
+ output->wlr_output, &box)) {
+ view_set_fullscreen(output->fullscreen_view,
+ false, NULL);
+ }
+ }
+ }
+
struct roots_view *prev_focus = roots_seat_get_focus(seat);
if (view == prev_focus) {
return;
diff --git a/rootston/xdg_shell.c b/rootston/xdg_shell.c
index 851c0045..927bd018 100644
--- a/rootston/xdg_shell.c
+++ b/rootston/xdg_shell.c
@@ -28,6 +28,16 @@ static void popup_handle_destroy(struct wl_listener *listener, void *data) {
popup_destroy((struct roots_view_child *)popup);
}
+static void popup_handle_map(struct wl_listener *listener, void *data) {
+ struct roots_xdg_popup *popup = wl_container_of(listener, popup, map);
+ view_damage_whole(popup->view_child.view);
+}
+
+static void popup_handle_unmap(struct wl_listener *listener, void *data) {
+ struct roots_xdg_popup *popup = wl_container_of(listener, popup, unmap);
+ view_damage_whole(popup->view_child.view);
+}
+
static struct roots_xdg_popup *popup_create(struct roots_view *view,
struct wlr_xdg_popup *wlr_popup);
@@ -50,6 +60,10 @@ static struct roots_xdg_popup *popup_create(struct roots_view *view,
view_child_init(&popup->view_child, view, wlr_popup->base->surface);
popup->destroy.notify = popup_handle_destroy;
wl_signal_add(&wlr_popup->base->events.destroy, &popup->destroy);
+ popup->map.notify = popup_handle_map;
+ wl_signal_add(&wlr_popup->base->events.map, &popup->map);
+ popup->unmap.notify = popup_handle_unmap;
+ wl_signal_add(&wlr_popup->base->events.unmap, &popup->unmap);
popup->new_popup.notify = popup_handle_new_popup;
wl_signal_add(&wlr_popup->base->events.new_popup, &popup->new_popup);
return popup;
@@ -177,9 +191,11 @@ static void set_fullscreen(struct roots_view *view, bool fullscreen) {
static void close(struct roots_view *view) {
assert(view->type == ROOTS_XDG_SHELL_VIEW);
struct wlr_xdg_surface *surface = view->xdg_surface;
- if (surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
- wlr_xdg_toplevel_send_close(surface);
+ struct wlr_xdg_popup *popup = NULL;
+ wl_list_for_each(popup, &surface->popups, link) {
+ wlr_xdg_surface_send_close(popup->base);
}
+ wlr_xdg_surface_send_close(surface);
}
static void destroy(struct roots_view *view) {
@@ -236,7 +252,7 @@ static void handle_request_maximize(struct wl_listener *listener, void *data) {
return;
}
- view_maximize(view, surface->toplevel->next.maximized);
+ view_maximize(view, surface->toplevel->client_pending.maximized);
}
static void handle_request_fullscreen(struct wl_listener *listener,
@@ -337,7 +353,7 @@ void handle_xdg_shell_surface(struct wl_listener *listener, void *data) {
wl_container_of(listener, desktop, xdg_shell_surface);
wlr_log(L_DEBUG, "new xdg toplevel: title=%s, app_id=%s",
- surface->title, surface->app_id);
+ surface->toplevel->title, surface->toplevel->app_id);
wlr_xdg_surface_ping(surface);
struct roots_xdg_surface *roots_surface =
@@ -355,15 +371,16 @@ void handle_xdg_shell_surface(struct wl_listener *listener, void *data) {
roots_surface->unmap.notify = handle_unmap;
wl_signal_add(&surface->events.unmap, &roots_surface->unmap);
roots_surface->request_move.notify = handle_request_move;
- wl_signal_add(&surface->events.request_move, &roots_surface->request_move);
+ wl_signal_add(&surface->toplevel->events.request_move,
+ &roots_surface->request_move);
roots_surface->request_resize.notify = handle_request_resize;
- wl_signal_add(&surface->events.request_resize,
+ wl_signal_add(&surface->toplevel->events.request_resize,
&roots_surface->request_resize);
roots_surface->request_maximize.notify = handle_request_maximize;
- wl_signal_add(&surface->events.request_maximize,
+ wl_signal_add(&surface->toplevel->events.request_maximize,
&roots_surface->request_maximize);
roots_surface->request_fullscreen.notify = handle_request_fullscreen;
- wl_signal_add(&surface->events.request_fullscreen,
+ wl_signal_add(&surface->toplevel->events.request_fullscreen,
&roots_surface->request_fullscreen);
roots_surface->new_popup.notify = handle_new_popup;
wl_signal_add(&surface->events.new_popup, &roots_surface->new_popup);
@@ -386,10 +403,10 @@ void handle_xdg_shell_surface(struct wl_listener *listener, void *data) {
view->destroy = destroy;
roots_surface->view = view;
- if (surface->toplevel->next.maximized) {
+ if (surface->toplevel->client_pending.maximized) {
view_maximize(view, true);
}
- if (surface->toplevel->next.fullscreen) {
+ if (surface->toplevel->client_pending.fullscreen) {
view_set_fullscreen(view, true, NULL);
}
}
diff --git a/rootston/xdg_shell_v6.c b/rootston/xdg_shell_v6.c
index f5cb2cd7..e3c70e96 100644
--- a/rootston/xdg_shell_v6.c
+++ b/rootston/xdg_shell_v6.c
@@ -28,6 +28,18 @@ static void popup_handle_destroy(struct wl_listener *listener, void *data) {
popup_destroy((struct roots_view_child *)popup);
}
+static void popup_handle_map(struct wl_listener *listener, void *data) {
+ struct roots_xdg_popup_v6 *popup =
+ wl_container_of(listener, popup, map);
+ view_damage_whole(popup->view_child.view);
+}
+
+static void popup_handle_unmap(struct wl_listener *listener, void *data) {
+ struct roots_xdg_popup_v6 *popup =
+ wl_container_of(listener, popup, unmap);
+ view_damage_whole(popup->view_child.view);
+}
+
static struct roots_xdg_popup_v6 *popup_create(struct roots_view *view,
struct wlr_xdg_popup_v6 *wlr_popup);
@@ -230,6 +242,10 @@ static struct roots_xdg_popup_v6 *popup_create(struct roots_view *view,
view_child_init(&popup->view_child, view, wlr_popup->base->surface);
popup->destroy.notify = popup_handle_destroy;
wl_signal_add(&wlr_popup->base->events.destroy, &popup->destroy);
+ popup->map.notify = popup_handle_map;
+ wl_signal_add(&wlr_popup->base->events.map, &popup->map);
+ popup->unmap.notify = popup_handle_unmap;
+ wl_signal_add(&wlr_popup->base->events.unmap, &popup->unmap);
popup->new_popup.notify = popup_handle_new_popup;
wl_signal_add(&wlr_popup->base->events.new_popup, &popup->new_popup);
@@ -360,9 +376,11 @@ static void set_fullscreen(struct roots_view *view, bool fullscreen) {
static void close(struct roots_view *view) {
assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
- if (surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) {
- wlr_xdg_toplevel_v6_send_close(surface);
+ struct wlr_xdg_popup_v6 *popup = NULL;
+ wl_list_for_each(popup, &surface->popups, link) {
+ wlr_xdg_surface_v6_send_close(popup->base);
}
+ wlr_xdg_surface_v6_send_close(surface);
}
static void destroy(struct roots_view *view) {
@@ -419,7 +437,7 @@ static void handle_request_maximize(struct wl_listener *listener, void *data) {
return;
}
- view_maximize(view, surface->toplevel->next.maximized);
+ view_maximize(view, surface->toplevel->client_pending.maximized);
}
static void handle_request_fullscreen(struct wl_listener *listener,
@@ -520,7 +538,7 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
wl_container_of(listener, desktop, xdg_shell_v6_surface);
wlr_log(L_DEBUG, "new xdg toplevel: title=%s, app_id=%s",
- surface->title, surface->app_id);
+ surface->toplevel->title, surface->toplevel->app_id);
wlr_xdg_surface_v6_ping(surface);
struct roots_xdg_surface_v6 *roots_surface =
@@ -538,15 +556,16 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
roots_surface->unmap.notify = handle_unmap;
wl_signal_add(&surface->events.unmap, &roots_surface->unmap);
roots_surface->request_move.notify = handle_request_move;
- wl_signal_add(&surface->events.request_move, &roots_surface->request_move);
+ wl_signal_add(&surface->toplevel->events.request_move,
+ &roots_surface->request_move);
roots_surface->request_resize.notify = handle_request_resize;
- wl_signal_add(&surface->events.request_resize,
+ wl_signal_add(&surface->toplevel->events.request_resize,
&roots_surface->request_resize);
roots_surface->request_maximize.notify = handle_request_maximize;
- wl_signal_add(&surface->events.request_maximize,
+ wl_signal_add(&surface->toplevel->events.request_maximize,
&roots_surface->request_maximize);
roots_surface->request_fullscreen.notify = handle_request_fullscreen;
- wl_signal_add(&surface->events.request_fullscreen,
+ wl_signal_add(&surface->toplevel->events.request_fullscreen,
&roots_surface->request_fullscreen);
roots_surface->new_popup.notify = handle_new_popup;
wl_signal_add(&surface->events.new_popup, &roots_surface->new_popup);
@@ -569,10 +588,10 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
view->destroy = destroy;
roots_surface->view = view;
- if (surface->toplevel->next.maximized) {
+ if (surface->toplevel->client_pending.maximized) {
view_maximize(view, true);
}
- if (surface->toplevel->next.fullscreen) {
+ if (surface->toplevel->client_pending.fullscreen) {
view_set_fullscreen(view, true, NULL);
}
}