aboutsummaryrefslogtreecommitdiff
path: root/rootston
diff options
context:
space:
mode:
Diffstat (limited to 'rootston')
-rw-r--r--rootston/cursor.c145
-rw-r--r--rootston/desktop.c124
-rw-r--r--rootston/layer_shell.c315
-rw-r--r--rootston/meson.build1
-rw-r--r--rootston/output.c101
-rw-r--r--rootston/xdg_shell.c31
-rw-r--r--rootston/xdg_shell_v6.c88
-rw-r--r--rootston/xwayland.c20
8 files changed, 694 insertions, 131 deletions
diff --git a/rootston/cursor.c b/rootston/cursor.c
index ac597590..1ee195c2 100644
--- a/rootston/cursor.c
+++ b/rootston/cursor.c
@@ -10,6 +10,7 @@
#include <dev/evdev/input-event-codes.h>
#endif
#include "rootston/cursor.h"
+#include "rootston/desktop.h"
#include "rootston/xcursor.h"
struct roots_cursor *roots_cursor_create(struct roots_seat *seat) {
@@ -98,52 +99,59 @@ static void seat_view_deco_button(struct roots_seat_view *view, double sx,
}
}
-static void roots_cursor_update_position(struct roots_cursor *cursor,
+static void roots_passthrough_cursor(struct roots_cursor *cursor,
uint32_t time) {
- struct roots_desktop *desktop = cursor->seat->input->server->desktop;
- struct roots_seat *seat = cursor->seat;
- struct roots_view *view;
- struct wlr_surface *surface = NULL;
double sx, sy;
- switch (cursor->mode) {
- case ROOTS_CURSOR_PASSTHROUGH:
- view = desktop_view_at(desktop, cursor->cursor->x, cursor->cursor->y,
- &surface, &sx, &sy);
+ struct roots_view *view = NULL;
+ struct roots_seat *seat = cursor->seat;
+ struct roots_desktop *desktop = seat->input->server->desktop;
+ struct wlr_surface *surface = desktop_surface_at(desktop,
+ cursor->cursor->x, cursor->cursor->y, &sx, &sy, &view);
+ struct wl_client *client = NULL;
+ if (surface) {
+ client = wl_resource_get_client(surface->resource);
+ }
+
+ if (cursor->cursor_client != client) {
+ wlr_xcursor_manager_set_cursor_image(cursor->xcursor_manager,
+ cursor->default_xcursor, cursor->cursor);
+ cursor->cursor_client = client;
+ }
+
+ if (view) {
struct roots_seat_view *seat_view =
roots_seat_view_from_view(seat, view);
- if (cursor->pointer_view && (surface || seat_view != cursor->pointer_view)) {
+ if (cursor->pointer_view && (surface ||
+ seat_view != cursor->pointer_view)) {
seat_view_deco_leave(cursor->pointer_view);
cursor->pointer_view = NULL;
}
- bool set_compositor_cursor = !view && !surface && cursor->cursor_client;
- if (view && surface) {
- struct wl_client *view_client =
- wl_resource_get_client(view->wlr_surface->resource);
- set_compositor_cursor = view_client != cursor->cursor_client;
- }
- if (set_compositor_cursor) {
- wlr_xcursor_manager_set_cursor_image(cursor->xcursor_manager,
- cursor->default_xcursor, cursor->cursor);
- cursor->cursor_client = NULL;
- }
- if (view && !surface) {
- if (seat_view) {
- cursor->pointer_view = seat_view;
- seat_view_deco_motion(seat_view, sx, sy);
- }
- }
- if (view && surface) {
- // motion over a view surface
- wlr_seat_pointer_notify_enter(seat->seat, surface, sx, sy);
- wlr_seat_pointer_notify_motion(seat->seat, time, sx, sy);
- } else {
- wlr_seat_pointer_clear_focus(seat->seat);
+ if (!surface) {
+ cursor->pointer_view = seat_view;
+ seat_view_deco_motion(seat_view, sx, sy);
}
+ }
- struct roots_drag_icon *drag_icon;
- wl_list_for_each(drag_icon, &seat->drag_icons, link) {
- roots_drag_icon_update_position(drag_icon);
- }
+ if (surface) {
+ wlr_seat_pointer_notify_enter(seat->seat, surface, sx, sy);
+ wlr_seat_pointer_notify_motion(seat->seat, time, sx, sy);
+ } else {
+ wlr_seat_pointer_clear_focus(seat->seat);
+ }
+
+ struct roots_drag_icon *drag_icon;
+ wl_list_for_each(drag_icon, &seat->drag_icons, link) {
+ roots_drag_icon_update_position(drag_icon);
+ }
+}
+
+static void roots_cursor_update_position(
+ struct roots_cursor *cursor, uint32_t time) {
+ struct roots_seat *seat = cursor->seat;
+ struct roots_view *view;
+ switch (cursor->mode) {
+ case ROOTS_CURSOR_PASSTHROUGH:
+ roots_passthrough_cursor(cursor, time);
break;
case ROOTS_CURSOR_MOVE:
view = roots_seat_get_focus(seat);
@@ -181,15 +189,9 @@ static void roots_cursor_update_position(struct roots_cursor *cursor,
} else if (cursor->resize_edges & WLR_EDGE_RIGHT) {
width += dx;
}
-
- if (width < 1) {
- width = 1;
- }
- if (height < 1) {
- height = 1;
- }
-
- view_move_resize(view, x, y, width, height);
+ view_move_resize(view, x, y,
+ width < 1 ? 1 : width,
+ height < 1 ? 1 : height);
}
break;
case ROOTS_CURSOR_ROTATE:
@@ -215,15 +217,15 @@ static void roots_cursor_press_button(struct roots_cursor *cursor,
uint32_t state, double lx, double ly) {
struct roots_seat *seat = cursor->seat;
struct roots_desktop *desktop = seat->input->server->desktop;
+
bool is_touch = device->type == WLR_INPUT_DEVICE_TOUCH;
- struct wlr_surface *surface = NULL;
double sx, sy;
- struct roots_view *view =
- desktop_view_at(desktop, lx, ly, &surface, &sx, &sy);
+ struct roots_view *view;
+ struct wlr_surface *surface = desktop_surface_at(desktop,
+ lx, ly, &sx, &sy, &view);
- if (state == WLR_BUTTON_PRESSED &&
- view &&
+ if (state == WLR_BUTTON_PRESSED && view &&
roots_seat_has_meta_pressed(seat)) {
roots_seat_set_focus(seat, view);
@@ -251,11 +253,9 @@ static void roots_cursor_press_button(struct roots_cursor *cursor,
break;
}
} else {
-
- if (view && !surface) {
- if (cursor->pointer_view) {
- seat_view_deco_button(cursor->pointer_view, sx, sy, button, state);
- }
+ if (view && !surface && cursor->pointer_view) {
+ seat_view_deco_button(cursor->pointer_view,
+ sx, sy, button, state);
}
if (state == WLR_BUTTON_RELEASED &&
@@ -289,8 +289,8 @@ void roots_cursor_handle_motion(struct roots_cursor *cursor,
void roots_cursor_handle_motion_absolute(struct roots_cursor *cursor,
struct wlr_event_pointer_motion_absolute *event) {
- wlr_cursor_warp_absolute(cursor->cursor, event->device,
- event->x_mm / event->width_mm, event->y_mm / event->height_mm);
+ wlr_cursor_warp_absolute(cursor->cursor,
+ event->device, event->x, event->y);
roots_cursor_update_position(cursor, event->time_msec);
}
@@ -309,17 +309,15 @@ void roots_cursor_handle_axis(struct roots_cursor *cursor,
void roots_cursor_handle_touch_down(struct roots_cursor *cursor,
struct wlr_event_touch_down *event) {
struct roots_desktop *desktop = cursor->seat->input->server->desktop;
- struct wlr_surface *surface = NULL;
double lx, ly;
- bool result =
- wlr_cursor_absolute_to_layout_coords(cursor->cursor,
- event->device, event->x_mm, event->y_mm, event->width_mm,
- event->height_mm, &lx, &ly);
+ bool result = wlr_cursor_absolute_to_layout_coords(cursor->cursor,
+ event->device, event->x, event->y, &lx, &ly);
if (!result) {
return;
}
double sx, sy;
- desktop_view_at(desktop, lx, ly, &surface, &sx, &sy);
+ struct wlr_surface *surface = desktop_surface_at(
+ desktop, lx, ly, &sx, &sy, NULL);
uint32_t serial = 0;
if (surface) {
@@ -362,18 +360,16 @@ void roots_cursor_handle_touch_motion(struct roots_cursor *cursor,
return;
}
- struct wlr_surface *surface = NULL;
double lx, ly;
- bool result =
- wlr_cursor_absolute_to_layout_coords(cursor->cursor,
- event->device, event->x_mm, event->y_mm, event->width_mm,
- event->height_mm, &lx, &ly);
+ bool result = wlr_cursor_absolute_to_layout_coords(cursor->cursor,
+ event->device, event->x, event->y, &lx, &ly);
if (!result) {
return;
}
double sx, sy;
- desktop_view_at(desktop, lx, ly, &surface, &sx, &sy);
+ struct wlr_surface *surface = desktop_surface_at(
+ desktop, lx, ly, &sx, &sy, NULL);
if (surface) {
wlr_seat_touch_point_focus(cursor->seat->seat, surface,
@@ -396,15 +392,13 @@ void roots_cursor_handle_tool_axis(struct roots_cursor *cursor,
if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_X) &&
(event->updated_axes & WLR_TABLET_TOOL_AXIS_Y)) {
wlr_cursor_warp_absolute(cursor->cursor, event->device,
- event->x_mm / event->width_mm, event->y_mm / event->height_mm);
+ event->x, event->y);
roots_cursor_update_position(cursor, event->time_msec);
} else if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_X)) {
- wlr_cursor_warp_absolute(cursor->cursor, event->device,
- event->x_mm / event->width_mm, -1);
+ wlr_cursor_warp_absolute(cursor->cursor, event->device, event->x, -1);
roots_cursor_update_position(cursor, event->time_msec);
} else if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_Y)) {
- wlr_cursor_warp_absolute(cursor->cursor, event->device,
- -1, event->y_mm / event->height_mm);
+ wlr_cursor_warp_absolute(cursor->cursor, event->device, -1, event->y);
roots_cursor_update_position(cursor, event->time_msec);
}
}
@@ -432,7 +426,6 @@ void roots_cursor_handle_request_set_cursor(struct roots_cursor *cursor,
return;
}
- wlr_log(L_DEBUG, "Setting client cursor");
wlr_cursor_set_surface(cursor->cursor, event->surface, event->hotspot_x,
event->hotspot_y);
cursor->cursor_client = event->seat_client->client;
diff --git a/rootston/desktop.c b/rootston/desktop.c
index 65d9a280..ab16ed3d 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>
@@ -19,10 +20,12 @@
#include <wlr/types/wlr_xdg_shell_v6.h>
#include <wlr/types/wlr_xdg_shell.h>
#include <wlr/util/log.h>
+#include "rootston/layers.h"
#include "rootston/seat.h"
#include "rootston/server.h"
#include "rootston/view.h"
#include "rootston/xcursor.h"
+#include "wlr-layer-shell-unstable-v1-protocol.h"
struct roots_view *view_create(struct roots_desktop *desktop) {
struct roots_view *view = calloc(1, sizeof(struct roots_view));
@@ -187,6 +190,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 +219,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) {
@@ -609,9 +622,7 @@ static bool view_at(struct roots_view *view, double lx, double ly,
return true;
}
- if (wlr_box_contains_point(&box, view_sx, view_sy) &&
- pixman_region32_contains_point(&view->wlr_surface->current->input,
- view_sx, view_sy, NULL)) {
+ if (wlr_surface_point_accepts_input(view->wlr_surface, view_sx, view_sy)) {
*sx = view_sx;
*sy = view_sy;
*surface = view->wlr_surface;
@@ -621,8 +632,9 @@ static bool view_at(struct roots_view *view, double lx, double ly,
return false;
}
-struct roots_view *desktop_view_at(struct roots_desktop *desktop, double lx,
- double ly, struct wlr_surface **surface, double *sx, double *sy) {
+static struct roots_view *desktop_view_at(struct roots_desktop *desktop,
+ double lx, double ly, struct wlr_surface **surface,
+ double *sx, double *sy) {
struct wlr_output *wlr_output =
wlr_output_layout_output_at(desktop->layout, lx, ly);
if (wlr_output != NULL) {
@@ -646,6 +658,75 @@ struct roots_view *desktop_view_at(struct roots_desktop *desktop, double lx,
return NULL;
}
+static struct wlr_surface *layer_surface_at(struct roots_output *output,
+ struct wl_list *layer, double ox, double oy, double *sx, double *sy) {
+ struct roots_layer_surface *roots_surface;
+ wl_list_for_each_reverse(roots_surface, layer, link) {
+ struct wlr_surface *wlr_surface =
+ roots_surface->layer_surface->surface;
+ double _sx = ox - roots_surface->geo.x;
+ double _sy = oy - roots_surface->geo.y;
+ // TODO: Test popups/subsurfaces
+ if (wlr_surface_point_accepts_input(wlr_surface, _sx, _sy)) {
+ *sx = _sx;
+ *sy = _sy;
+ return wlr_surface;
+ }
+ }
+ return NULL;
+}
+
+struct wlr_surface *desktop_surface_at(struct roots_desktop *desktop,
+ double lx, double ly, double *sx, double *sy,
+ struct roots_view **view) {
+ struct wlr_surface *surface = NULL;
+ struct wlr_output *wlr_output =
+ wlr_output_layout_output_at(desktop->layout, lx, ly);
+ struct roots_output *roots_output = NULL;
+ double ox = lx, oy = ly;
+ if (view) {
+ *view = NULL;
+ }
+
+ if (wlr_output) {
+ roots_output = wlr_output->data;
+ wlr_output_layout_output_coords(desktop->layout, wlr_output, &ox, &oy);
+
+ if ((surface = layer_surface_at(roots_output,
+ &roots_output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY],
+ ox, oy, sx, sy))) {
+ return surface;
+ }
+ if ((surface = layer_surface_at(roots_output,
+ &roots_output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP],
+ ox, oy, sx, sy))) {
+ return surface;
+ }
+ }
+
+ struct roots_view *_view;
+ if ((_view = desktop_view_at(desktop, lx, ly, &surface, sx, sy))) {
+ if (view) {
+ *view = _view;
+ }
+ return surface;
+ }
+
+ if (wlr_output) {
+ if ((surface = layer_surface_at(roots_output,
+ &roots_output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM],
+ ox, oy, sx, sy))) {
+ return surface;
+ }
+ if ((surface = layer_surface_at(roots_output,
+ &roots_output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND],
+ ox, oy, sx, sy))) {
+ return surface;
+ }
+ }
+ return NULL;
+}
+
static void handle_layout_change(struct wl_listener *listener, void *data) {
struct roots_desktop *desktop =
wl_container_of(listener, desktop, layout_change);
@@ -714,6 +795,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;
@@ -750,7 +836,7 @@ struct roots_desktop *desktop_create(struct roots_server *server,
if (xcursor != NULL) {
struct wlr_xcursor_image *image = xcursor->images[0];
wlr_xwayland_set_cursor(desktop->xwayland, image->buffer,
- image->width, image->width, image->height, image->hotspot_x,
+ image->width * 4, image->width, image->height, image->hotspot_x,
image->hotspot_y);
}
}
diff --git a/rootston/layer_shell.c b/rootston/layer_shell.c
new file mode 100644
index 00000000..d3a91659
--- /dev/null
+++ b/rootston/layer_shell.c
@@ -0,0 +1,315 @@
+#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);
+ }
+}
+
+void arrange_layers(struct roots_output *output) {
+ 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
+ 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);
+ wlr_layer_surface_close(layer->layer_surface);
+}
+
+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(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);
+ arrange_layers((struct roots_output *)layer->layer_surface->output->data);
+ 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->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);
+
+ 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 52ece54d..bf2bbdc2 100644
--- a/rootston/output.c
+++ b/rootston/output.c
@@ -13,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"
@@ -417,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;
@@ -433,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 +
@@ -498,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;
@@ -520,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);
@@ -570,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) {
@@ -626,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) {
@@ -691,6 +739,15 @@ static void damage_from_surface(struct wlr_surface *surface,
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,
struct roots_view *view) {
if (!view_accept_damage(output, view)) {
@@ -759,6 +816,18 @@ static void output_damage_handle_destroy(struct wl_listener *listener,
output_destroy(output);
}
+static void output_handle_mode(struct wl_listener *listener, void *data) {
+ struct roots_output *output =
+ wl_container_of(listener, output, mode);
+ arrange_layers(output);
+}
+
+static void output_handle_transform(struct wl_listener *listener, void *data) {
+ struct roots_output *output =
+ wl_container_of(listener, output, transform);
+ arrange_layers(output);
+}
+
void handle_new_output(struct wl_listener *listener, void *data) {
struct roots_desktop *desktop = wl_container_of(listener, desktop,
new_output);
@@ -781,17 +850,28 @@ 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);
output->destroy.notify = output_handle_destroy;
wl_signal_add(&wlr_output->events.destroy, &output->destroy);
+ output->mode.notify = output_handle_mode;
+ wl_signal_add(&wlr_output->events.mode, &output->mode);
+ output->transform.notify = output_handle_transform;
+ wl_signal_add(&wlr_output->events.transform, &output->transform);
+
output->damage_frame.notify = output_damage_handle_frame;
wl_signal_add(&output->damage->events.frame, &output->damage_frame);
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) {
@@ -816,5 +896,6 @@ void handle_new_output(struct wl_listener *listener, void *data) {
roots_seat_configure_xcursor(seat);
}
+ arrange_layers(output);
output_damage_whole(output);
}
diff --git a/rootston/xdg_shell.c b/rootston/xdg_shell.c
index 099e622c..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;
@@ -238,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,
@@ -339,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 =
@@ -357,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);
@@ -388,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 001232ab..39e8a4b7 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);
@@ -38,6 +50,58 @@ static void popup_handle_new_popup(struct wl_listener *listener, void *data) {
popup_create(popup->view_child.view, wlr_popup);
}
+static void popup_unconstrain(struct roots_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_v6_unconstrain_from_box
+
+ // TODO: unconstrain popups for rotated windows
+ if (popup->view_child.view->rotation != 0.0) {
+ return;
+ }
+
+ struct roots_view *view = popup->view_child.view;
+ struct wlr_output_layout *layout = view->desktop->layout;
+ struct wlr_xdg_popup_v6 *wlr_popup = popup->wlr_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(layout, NULL, anchor_lx, anchor_ly,
+ &dest_x, &dest_y);
+
+ struct wlr_output *output =
+ wlr_output_layout_output_at(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(popup->wlr_popup, &output_toplevel_sx_box);
+}
+
static struct roots_xdg_popup_v6 *popup_create(struct roots_view *view,
struct wlr_xdg_popup_v6 *wlr_popup) {
struct roots_xdg_popup_v6 *popup =
@@ -50,8 +114,15 @@ 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);
+
+ popup_unconstrain(popup);
+
return popup;
}
@@ -238,7 +309,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,
@@ -339,7 +410,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 =
@@ -357,15 +428,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);
@@ -388,10 +460,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);
}
}
diff --git a/rootston/xwayland.c b/rootston/xwayland.c
index 53331b1f..92f37362 100644
--- a/rootston/xwayland.c
+++ b/rootston/xwayland.c
@@ -114,8 +114,8 @@ static void destroy(struct roots_view *view) {
wl_list_remove(&roots_surface->request_move.link);
wl_list_remove(&roots_surface->request_resize.link);
wl_list_remove(&roots_surface->request_maximize.link);
- wl_list_remove(&roots_surface->map_notify.link);
- wl_list_remove(&roots_surface->unmap_notify.link);
+ wl_list_remove(&roots_surface->map.link);
+ wl_list_remove(&roots_surface->unmap.link);
free(roots_surface);
}
@@ -225,9 +225,9 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) {
view_update_position(view, x, y);
}
-static void handle_map_notify(struct wl_listener *listener, void *data) {
+static void handle_map(struct wl_listener *listener, void *data) {
struct roots_xwayland_surface *roots_surface =
- wl_container_of(listener, roots_surface, map_notify);
+ wl_container_of(listener, roots_surface, map);
struct wlr_xwayland_surface *xsurface = data;
struct roots_view *view = roots_surface->view;
@@ -243,9 +243,9 @@ static void handle_map_notify(struct wl_listener *listener, void *data) {
&roots_surface->surface_commit);
}
-static void handle_unmap_notify(struct wl_listener *listener, void *data) {
+static void handle_unmap(struct wl_listener *listener, void *data) {
struct roots_xwayland_surface *roots_surface =
- wl_container_of(listener, roots_surface, unmap_notify);
+ wl_container_of(listener, roots_surface, unmap);
struct roots_view *view = roots_surface->view;
wl_list_remove(&roots_surface->surface_commit.link);
@@ -272,10 +272,10 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
roots_surface->request_configure.notify = handle_request_configure;
wl_signal_add(&surface->events.request_configure,
&roots_surface->request_configure);
- roots_surface->map_notify.notify = handle_map_notify;
- wl_signal_add(&surface->events.map_notify, &roots_surface->map_notify);
- roots_surface->unmap_notify.notify = handle_unmap_notify;
- wl_signal_add(&surface->events.unmap_notify, &roots_surface->unmap_notify);
+ roots_surface->map.notify = handle_map;
+ wl_signal_add(&surface->events.map, &roots_surface->map);
+ 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);
roots_surface->request_resize.notify = handle_request_resize;