Fixed for the wlroots xdg-positioner regression fix (see 2d623724c3)

This commit is contained in:
Keith Bowes 2022-03-15 16:52:13 -04:00
parent 5e95882436
commit 9fa7060dd4
4 changed files with 24 additions and 21 deletions

View file

@ -9,7 +9,6 @@
#include <wlr/backend.h> #include <wlr/backend.h>
#include <wlr/render/allocator.h> #include <wlr/render/allocator.h>
#include <wlr/render/wlr_renderer.h> #include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_compositor.h> #include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_data_device.h> #include <wlr/types/wlr_data_device.h>

View file

@ -55,7 +55,7 @@ static void arrange_surface(struct wb_output *output, struct wlr_box *full_area,
#if WLR_CHECK_VERSION(0, 16, 0) #if WLR_CHECK_VERSION(0, 16, 0)
struct wb_layer_surface *surface = desc->data; struct wb_layer_surface *surface = desc->data;
wlr_scene_layer_surface_v1_configure(surface->scene, wlr_scene_layer_surface_v1_configure(surface->scene,
full_area, usable_area); full_area, usable_area);
#endif #endif
} }
} }
@ -246,11 +246,11 @@ static void popup_unconstrain(struct wb_layer_popup *popup) {
int lx, ly; int lx, ly;
wlr_scene_node_coords(popup->scene, &lx, &ly); wlr_scene_node_coords(popup->scene, &lx, &ly);
/* the output box expressed in the coordinate system of the toplevel parent /* The output box expressed in the coordinate system of the toplevel
* of the popup */ * parent of the popup. */
struct wlr_box output_toplevel_sx_box = { struct wlr_box output_toplevel_sx_box = {
.x = output->geometry.x - lx, .x = output->geometry.x - MIN(lx, 0),
.y = output->geometry.y - ly, .y = output->geometry.y - MAX(ly, 0),
.width = output->geometry.width, .width = output->geometry.width,
.height = output->geometry.height, .height = output->geometry.height,
}; };
@ -271,7 +271,7 @@ static struct wb_layer_popup *create_popup(struct wlr_xdg_popup *wlr_popup,
popup->wlr_popup = wlr_popup; popup->wlr_popup = wlr_popup;
popup->scene = wlr_scene_xdg_surface_create(parent, popup->scene = wlr_scene_xdg_surface_create(parent,
wlr_popup->base); wlr_popup->base);
if (!popup->scene) { if (!popup->scene) {
free(popup); free(popup);
@ -279,7 +279,7 @@ static struct wb_layer_popup *create_popup(struct wlr_xdg_popup *wlr_popup,
} }
assign_scene_descriptor(popup->scene, WB_SCENE_DESC_LAYER_SHELL_POPUP, assign_scene_descriptor(popup->scene, WB_SCENE_DESC_LAYER_SHELL_POPUP,
popup); popup);
popup->destroy.notify = popup_handle_destroy; popup->destroy.notify = popup_handle_destroy;
wl_signal_add(&wlr_popup->base->events.destroy, &popup->destroy); wl_signal_add(&wlr_popup->base->events.destroy, &popup->destroy);
@ -288,7 +288,8 @@ static struct wb_layer_popup *create_popup(struct wlr_xdg_popup *wlr_popup,
wl_signal_add(&wlr_popup->base->events.new_popup, &popup->new_popup); wl_signal_add(&wlr_popup->base->events.new_popup, &popup->new_popup);
popup_unconstrain(popup); popup_unconstrain(popup);
return NULL;
return popup;
} }
static void popup_handle_new_popup(struct wl_listener *listener, void *data) { static void popup_handle_new_popup(struct wl_listener *listener, void *data) {
@ -310,8 +311,10 @@ void handle_layer_shell_surface(struct wl_listener *listener, void *data) {
struct wlr_layer_surface_v1 *layer_surface = data; struct wlr_layer_surface_v1 *layer_surface = data;
if (layer_surface->output == NULL) { if (layer_surface->output == NULL) {
struct wb_server *server = wl_container_of(listener, server, new_layer_surface); struct wb_server *server =
struct wb_view *view = wl_container_of(server->views.next, view, link); wl_container_of(listener, server, new_layer_surface);
struct wb_view *view =
wl_container_of(server->views.next, view, link);
layer_surface->output = get_active_output(view); layer_surface->output = get_active_output(view);
} }
struct wb_output *output = layer_surface->output->data; struct wb_output *output = layer_surface->output->data;
@ -324,7 +327,7 @@ void handle_layer_shell_surface(struct wl_listener *listener, void *data) {
enum zwlr_layer_shell_v1_layer layer_type = layer_surface->pending.layer; enum zwlr_layer_shell_v1_layer layer_type = layer_surface->pending.layer;
struct wlr_scene_node *output_layer = wb_layer_get_scene( struct wlr_scene_node *output_layer = wb_layer_get_scene(
output, layer_type); output, layer_type);
#if WLR_CHECK_VERSION(0, 16, 0) #if WLR_CHECK_VERSION(0, 16, 0)
struct wlr_scene_layer_surface_v1 *scene_surface = struct wlr_scene_layer_surface_v1 *scene_surface =
wlr_scene_layer_surface_v1_create(output_layer, layer_surface); wlr_scene_layer_surface_v1_create(output_layer, layer_surface);

View file

@ -5,9 +5,8 @@ void output_frame_notify(struct wl_listener *listener, void *data) {
* generally at the output's refresh rate (e.g. 60Hz). */ * generally at the output's refresh rate (e.g. 60Hz). */
struct wb_output *output = wl_container_of(listener, output, frame); struct wb_output *output = wl_container_of(listener, output, frame);
struct wlr_scene *scene = output->server->scene; struct wlr_scene *scene = output->server->scene;
struct wlr_scene_output *scene_output =
struct wlr_scene_output *scene_output = wlr_scene_get_scene_output( wlr_scene_get_scene_output(scene, output->wlr_output);
scene, output->wlr_output);
#if WLR_CHECK_VERSION(0, 16, 0) #if WLR_CHECK_VERSION(0, 16, 0)
wlr_output_layout_get_box(output->server->output_layout, wlr_output_layout_get_box(output->server->output_layout,
@ -35,7 +34,6 @@ void output_destroy_notify(struct wl_listener *listener, void *data) {
wl_list_remove(&output->destroy.link); wl_list_remove(&output->destroy.link);
wl_list_remove(&output->frame.link); wl_list_remove(&output->frame.link);
wl_list_remove(&output->link);
/* Frees the layers */ /* Frees the layers */
size_t num_layers = sizeof(output->layers) / sizeof(struct wlr_scene_node *); size_t num_layers = sizeof(output->layers) / sizeof(struct wlr_scene_node *);
@ -45,6 +43,7 @@ void output_destroy_notify(struct wl_listener *listener, void *data) {
wlr_scene_node_destroy(node); wlr_scene_node_destroy(node);
} }
wl_list_remove(&output->link);
free(output); free(output);
} }

View file

@ -6,8 +6,8 @@ struct wb_view *get_view_at(
/* This returns the topmost node in the scene at the given layout coords. /* This returns the topmost node in the scene at the given layout coords.
* we only care about surface nodes as we are specifically looking for a * we only care about surface nodes as we are specifically looking for a
* surface in the surface tree of a wb_view. */ * surface in the surface tree of a wb_view. */
struct wlr_scene_node *node = wlr_scene_node_at( struct wlr_scene_node *node =
&server->scene->node, lx, ly, sx, sy); wlr_scene_node_at(&server->scene->node, lx, ly, sx, sy);
if (node == NULL || node->type != WLR_SCENE_NODE_SURFACE) { if (node == NULL || node->type != WLR_SCENE_NODE_SURFACE) {
return NULL; return NULL;
} }
@ -44,8 +44,8 @@ void focus_view(struct wb_view *view, struct wlr_surface *surface) {
* it no longer has focus and the client will repaint accordingly, e.g. * it no longer has focus and the client will repaint accordingly, e.g.
* stop displaying a caret. * stop displaying a caret.
*/ */
struct wlr_xdg_surface *previous = wlr_xdg_surface_from_wlr_surface( struct wlr_xdg_surface *previous =
prev_surface); wlr_xdg_surface_from_wlr_surface(prev_surface);
#if WLR_CHECK_VERSION(0, 16, 0) #if WLR_CHECK_VERSION(0, 16, 0)
wlr_xdg_toplevel_set_activated(previous->toplevel, false); wlr_xdg_toplevel_set_activated(previous->toplevel, false);
#else #else
@ -284,11 +284,13 @@ static void handle_new_popup(struct wl_listener *listener, void *data) {
if (!wlr_output) return; if (!wlr_output) return;
struct wb_output *output = wlr_output->data; struct wb_output *output = wlr_output->data;
int top_margin = (view->server->config) ?
view->server->config->margins.top : 0;
struct wlr_box output_toplevel_box = { struct wlr_box output_toplevel_box = {
.x = output->geometry.x - view->current_position.x, .x = output->geometry.x - view->current_position.x,
.y = output->geometry.y - view->current_position.y, .y = output->geometry.y - view->current_position.y,
.width = output->geometry.width, .width = output->geometry.width,
.height = output->geometry.height, .height = output->geometry.height - top_margin,
}; };
wlr_xdg_popup_unconstrain_from_box(popup, &output_toplevel_box); wlr_xdg_popup_unconstrain_from_box(popup, &output_toplevel_box);
} }