mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-26 14:45:58 +01:00
Forward-port xdg-shell-v6 positioner improvements
This commit is contained in:
parent
278aa84619
commit
2e3d901ac5
5 changed files with 79 additions and 104 deletions
|
@ -165,14 +165,19 @@ static void create_popup() {
|
||||||
}
|
}
|
||||||
struct wl_surface *surface = wl_compositor_create_surface(compositor);
|
struct wl_surface *surface = wl_compositor_create_surface(compositor);
|
||||||
assert(xdg_wm_base && surface);
|
assert(xdg_wm_base && surface);
|
||||||
struct xdg_surface *xdg_surface = xdg_wm_base_get_xdg_surface(
|
struct xdg_surface *xdg_surface =
|
||||||
xdg_wm_base, surface);
|
xdg_wm_base_get_xdg_surface(xdg_wm_base, surface);
|
||||||
struct xdg_positioner *xdg_positioner = xdg_wm_base_create_positioner(
|
struct xdg_positioner *xdg_positioner =
|
||||||
xdg_wm_base);
|
xdg_wm_base_create_positioner(xdg_wm_base);
|
||||||
assert(xdg_surface && xdg_positioner);
|
assert(xdg_surface && xdg_positioner);
|
||||||
|
|
||||||
xdg_positioner_set_size(xdg_positioner, 256, 256);
|
xdg_positioner_set_size(xdg_positioner, 256, 256);
|
||||||
xdg_positioner_set_anchor_rect(xdg_positioner, 0, 0, width, height);
|
xdg_positioner_set_offset(xdg_positioner, 0, 0);
|
||||||
|
xdg_positioner_set_anchor_rect(xdg_positioner, cur_x, cur_y, 1, 1);
|
||||||
|
xdg_positioner_set_anchor(xdg_positioner, XDG_POSITIONER_ANCHOR_TOP_LEFT);
|
||||||
|
xdg_positioner_set_gravity(xdg_positioner, XDG_POSITIONER_GRAVITY_TOP_LEFT);
|
||||||
|
xdg_positioner_set_constraint_adjustment(xdg_positioner,
|
||||||
|
XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_NONE);
|
||||||
|
|
||||||
popup = xdg_surface_get_popup(xdg_surface, NULL, xdg_positioner);
|
popup = xdg_surface_get_popup(xdg_surface, NULL, xdg_positioner);
|
||||||
assert(popup);
|
assert(popup);
|
||||||
|
@ -185,6 +190,8 @@ static void create_popup() {
|
||||||
wl_surface_commit(surface);
|
wl_surface_commit(surface);
|
||||||
wl_display_roundtrip(display);
|
wl_display_roundtrip(display);
|
||||||
|
|
||||||
|
xdg_positioner_destroy(xdg_positioner);
|
||||||
|
|
||||||
struct wl_egl_window *egl_window;
|
struct wl_egl_window *egl_window;
|
||||||
struct wlr_egl_surface *egl_surface;
|
struct wlr_egl_surface *egl_surface;
|
||||||
egl_window = wl_egl_window_create(surface, 256, 256);
|
egl_window = wl_egl_window_create(surface, 256, 256);
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef WLR_TYPES_WLR_XDG_SHELL_H
|
#ifndef WLR_TYPES_WLR_XDG_SHELL_H
|
||||||
#define WLR_TYPES_WLR_XDG_SHELL_H
|
#define WLR_TYPES_WLR_XDG_SHELL_H
|
||||||
|
|
||||||
#include <wlr/types/wlr_box.h>
|
#include <wlr/types/wlr_box.h>
|
||||||
#include <wlr/types/wlr_seat.h>
|
#include <wlr/types/wlr_seat.h>
|
||||||
#include <wayland-server.h>
|
#include <wayland-server.h>
|
||||||
|
#include "xdg-shell-protocol.h"
|
||||||
|
|
||||||
struct wlr_xdg_shell {
|
struct wlr_xdg_shell {
|
||||||
struct wl_global *wl_global;
|
struct wl_global *wl_global;
|
||||||
|
@ -32,7 +32,22 @@ struct wlr_xdg_client {
|
||||||
struct wl_event_source *ping_timer;
|
struct wl_event_source *ping_timer;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlr_xdg_positioner;
|
struct wlr_xdg_positioner {
|
||||||
|
struct wl_resource *resource;
|
||||||
|
|
||||||
|
struct wlr_box anchor_rect;
|
||||||
|
enum xdg_positioner_anchor anchor;
|
||||||
|
enum xdg_positioner_gravity gravity;
|
||||||
|
enum xdg_positioner_constraint_adjustment constraint_adjustment;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
int32_t width, height;
|
||||||
|
} size;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
int32_t x, y;
|
||||||
|
} offset;
|
||||||
|
};
|
||||||
|
|
||||||
struct wlr_xdg_popup {
|
struct wlr_xdg_popup {
|
||||||
struct wlr_xdg_surface *base;
|
struct wlr_xdg_surface *base;
|
||||||
|
@ -43,11 +58,12 @@ struct wlr_xdg_popup {
|
||||||
struct wlr_surface *parent;
|
struct wlr_surface *parent;
|
||||||
struct wlr_seat *seat;
|
struct wlr_seat *seat;
|
||||||
|
|
||||||
struct wlr_xdg_positioner *positioner;
|
|
||||||
// Position of the popup relative to the upper left corner of the window
|
// Position of the popup relative to the upper left corner of the window
|
||||||
// geometry of the parent surface
|
// geometry of the parent surface
|
||||||
struct wlr_box geometry;
|
struct wlr_box geometry;
|
||||||
|
|
||||||
|
struct wlr_xdg_positioner positioner;
|
||||||
|
|
||||||
struct wl_list grab_link; // wlr_xdg_popup_grab::popups
|
struct wl_list grab_link; // wlr_xdg_popup_grab::popups
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -186,7 +202,8 @@ struct wlr_xdg_surface *wlr_xdg_surface_from_resource(
|
||||||
struct wlr_xdg_surface *wlr_xdg_surface_from_popup_resource(
|
struct wlr_xdg_surface *wlr_xdg_surface_from_popup_resource(
|
||||||
struct wl_resource *resource);
|
struct wl_resource *resource);
|
||||||
|
|
||||||
struct wlr_box wlr_xdg_popup_get_geometry(struct wlr_xdg_popup *popup);
|
struct wlr_box wlr_xdg_positioner_get_geometry(
|
||||||
|
struct wlr_xdg_positioner *positioner);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a ping to the surface. If the surface does not respond in a reasonable
|
* Send a ping to the surface. If the surface does not respond in a reasonable
|
||||||
|
|
|
@ -142,7 +142,7 @@ static void layer_surface_handle_get_popup(struct wl_client *client,
|
||||||
assert(popup_surface->role == WLR_XDG_SURFACE_ROLE_POPUP);
|
assert(popup_surface->role == WLR_XDG_SURFACE_ROLE_POPUP);
|
||||||
struct wlr_xdg_popup *popup = popup_surface->popup;
|
struct wlr_xdg_popup *popup = popup_surface->popup;
|
||||||
popup->parent = parent->surface;
|
popup->parent = parent->surface;
|
||||||
popup->geometry = wlr_xdg_popup_get_geometry(popup);
|
popup->geometry = wlr_xdg_positioner_get_geometry(&popup->positioner);
|
||||||
wl_list_insert(&parent->popups, &popup->link);
|
wl_list_insert(&parent->popups, &popup->link);
|
||||||
wlr_signal_emit_safe(&parent->events.new_popup, popup);
|
wlr_signal_emit_safe(&parent->events.new_popup, popup);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,24 +28,11 @@ struct wlr_xdg_surface *wlr_xdg_surface_from_wlr_surface(
|
||||||
return (struct wlr_xdg_surface *)surface->role_data;
|
return (struct wlr_xdg_surface *)surface->role_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_xdg_positioner {
|
struct wlr_xdg_positioner_resource {
|
||||||
struct wl_resource *resource;
|
struct wl_resource *resource;
|
||||||
|
struct wlr_xdg_positioner attrs;
|
||||||
struct wlr_box anchor_rect;
|
|
||||||
enum xdg_positioner_anchor anchor;
|
|
||||||
enum xdg_positioner_gravity gravity;
|
|
||||||
enum xdg_positioner_constraint_adjustment constraint_adjustment;
|
|
||||||
|
|
||||||
struct {
|
|
||||||
int32_t width, height;
|
|
||||||
} size;
|
|
||||||
|
|
||||||
struct {
|
|
||||||
int32_t x, y;
|
|
||||||
} offset;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static void resource_handle_destroy(struct wl_client *client,
|
static void resource_handle_destroy(struct wl_client *client,
|
||||||
struct wl_resource *resource) {
|
struct wl_resource *resource) {
|
||||||
wl_resource_destroy(resource);
|
wl_resource_destroy(resource);
|
||||||
|
@ -301,7 +288,7 @@ static void xdg_surface_destroy(struct wlr_xdg_surface *surface) {
|
||||||
|
|
||||||
static const struct xdg_positioner_interface xdg_positioner_implementation;
|
static const struct xdg_positioner_interface xdg_positioner_implementation;
|
||||||
|
|
||||||
static struct wlr_xdg_positioner *xdg_positioner_from_resource(
|
static struct wlr_xdg_positioner_resource *xdg_positioner_from_resource(
|
||||||
struct wl_resource *resource) {
|
struct wl_resource *resource) {
|
||||||
assert(wl_resource_instance_of(resource, &xdg_positioner_interface,
|
assert(wl_resource_instance_of(resource, &xdg_positioner_interface,
|
||||||
&xdg_positioner_implementation));
|
&xdg_positioner_implementation));
|
||||||
|
@ -309,14 +296,14 @@ static struct wlr_xdg_positioner *xdg_positioner_from_resource(
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xdg_positioner_destroy(struct wl_resource *resource) {
|
static void xdg_positioner_destroy(struct wl_resource *resource) {
|
||||||
struct wlr_xdg_positioner *positioner =
|
struct wlr_xdg_positioner_resource *positioner =
|
||||||
xdg_positioner_from_resource(resource);
|
xdg_positioner_from_resource(resource);
|
||||||
free(positioner);
|
free(positioner);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xdg_positioner_handle_set_size(struct wl_client *client,
|
static void xdg_positioner_handle_set_size(struct wl_client *client,
|
||||||
struct wl_resource *resource, int32_t width, int32_t height) {
|
struct wl_resource *resource, int32_t width, int32_t height) {
|
||||||
struct wlr_xdg_positioner *positioner =
|
struct wlr_xdg_positioner_resource *positioner =
|
||||||
xdg_positioner_from_resource(resource);
|
xdg_positioner_from_resource(resource);
|
||||||
|
|
||||||
if (width < 1 || height < 1) {
|
if (width < 1 || height < 1) {
|
||||||
|
@ -326,14 +313,14 @@ static void xdg_positioner_handle_set_size(struct wl_client *client,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
positioner->size.width = width;
|
positioner->attrs.size.width = width;
|
||||||
positioner->size.height = height;
|
positioner->attrs.size.height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xdg_positioner_handle_set_anchor_rect(struct wl_client *client,
|
static void xdg_positioner_handle_set_anchor_rect(struct wl_client *client,
|
||||||
struct wl_resource *resource, int32_t x, int32_t y, int32_t width,
|
struct wl_resource *resource, int32_t x, int32_t y, int32_t width,
|
||||||
int32_t height) {
|
int32_t height) {
|
||||||
struct wlr_xdg_positioner *positioner =
|
struct wlr_xdg_positioner_resource *positioner =
|
||||||
xdg_positioner_from_resource(resource);
|
xdg_positioner_from_resource(resource);
|
||||||
|
|
||||||
if (width < 0 || height < 0) {
|
if (width < 0 || height < 0) {
|
||||||
|
@ -343,15 +330,15 @@ static void xdg_positioner_handle_set_anchor_rect(struct wl_client *client,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
positioner->anchor_rect.x = x;
|
positioner->attrs.anchor_rect.x = x;
|
||||||
positioner->anchor_rect.y = y;
|
positioner->attrs.anchor_rect.y = y;
|
||||||
positioner->anchor_rect.width = width;
|
positioner->attrs.anchor_rect.width = width;
|
||||||
positioner->anchor_rect.height = height;
|
positioner->attrs.anchor_rect.height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xdg_positioner_handle_set_anchor(struct wl_client *client,
|
static void xdg_positioner_handle_set_anchor(struct wl_client *client,
|
||||||
struct wl_resource *resource, uint32_t anchor) {
|
struct wl_resource *resource, uint32_t anchor) {
|
||||||
struct wlr_xdg_positioner *positioner =
|
struct wlr_xdg_positioner_resource *positioner =
|
||||||
xdg_positioner_from_resource(resource);
|
xdg_positioner_from_resource(resource);
|
||||||
|
|
||||||
if (anchor > XDG_POSITIONER_ANCHOR_BOTTOM_RIGHT) {
|
if (anchor > XDG_POSITIONER_ANCHOR_BOTTOM_RIGHT) {
|
||||||
|
@ -361,12 +348,12 @@ static void xdg_positioner_handle_set_anchor(struct wl_client *client,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
positioner->anchor = anchor;
|
positioner->attrs.anchor = anchor;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xdg_positioner_handle_set_gravity(struct wl_client *client,
|
static void xdg_positioner_handle_set_gravity(struct wl_client *client,
|
||||||
struct wl_resource *resource, uint32_t gravity) {
|
struct wl_resource *resource, uint32_t gravity) {
|
||||||
struct wlr_xdg_positioner *positioner =
|
struct wlr_xdg_positioner_resource *positioner =
|
||||||
xdg_positioner_from_resource(resource);
|
xdg_positioner_from_resource(resource);
|
||||||
|
|
||||||
if (gravity > XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT) {
|
if (gravity > XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT) {
|
||||||
|
@ -376,25 +363,25 @@ static void xdg_positioner_handle_set_gravity(struct wl_client *client,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
positioner->gravity = gravity;
|
positioner->attrs.gravity = gravity;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xdg_positioner_handle_set_constraint_adjustment(
|
static void xdg_positioner_handle_set_constraint_adjustment(
|
||||||
struct wl_client *client, struct wl_resource *resource,
|
struct wl_client *client, struct wl_resource *resource,
|
||||||
uint32_t constraint_adjustment) {
|
uint32_t constraint_adjustment) {
|
||||||
struct wlr_xdg_positioner *positioner =
|
struct wlr_xdg_positioner_resource *positioner =
|
||||||
xdg_positioner_from_resource(resource);
|
xdg_positioner_from_resource(resource);
|
||||||
|
|
||||||
positioner->constraint_adjustment = constraint_adjustment;
|
positioner->attrs.constraint_adjustment = constraint_adjustment;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xdg_positioner_handle_set_offset(struct wl_client *client,
|
static void xdg_positioner_handle_set_offset(struct wl_client *client,
|
||||||
struct wl_resource *resource, int32_t x, int32_t y) {
|
struct wl_resource *resource, int32_t x, int32_t y) {
|
||||||
struct wlr_xdg_positioner *positioner =
|
struct wlr_xdg_positioner_resource *positioner =
|
||||||
xdg_positioner_from_resource(resource);
|
xdg_positioner_from_resource(resource);
|
||||||
|
|
||||||
positioner->offset.x = x;
|
positioner->attrs.offset.x = x;
|
||||||
positioner->offset.y = y;
|
positioner->attrs.offset.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct xdg_positioner_interface
|
static const struct xdg_positioner_interface
|
||||||
|
@ -412,16 +399,12 @@ static const struct xdg_positioner_interface
|
||||||
static void xdg_shell_handle_create_positioner(struct wl_client *wl_client,
|
static void xdg_shell_handle_create_positioner(struct wl_client *wl_client,
|
||||||
struct wl_resource *resource, uint32_t id) {
|
struct wl_resource *resource, uint32_t id) {
|
||||||
struct wlr_xdg_positioner *positioner =
|
struct wlr_xdg_positioner *positioner =
|
||||||
calloc(1, sizeof(struct wlr_xdg_positioner));
|
calloc(1, sizeof(struct wlr_xdg_positioner_resource));
|
||||||
if (positioner == NULL) {
|
if (positioner == NULL) {
|
||||||
wl_client_post_no_memory(wl_client);
|
wl_client_post_no_memory(wl_client);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set widths to detect improper usages of get_popup */
|
|
||||||
positioner->size.width = -1;
|
|
||||||
positioner->anchor_rect.width = -1;
|
|
||||||
|
|
||||||
positioner->resource = wl_resource_create(wl_client,
|
positioner->resource = wl_resource_create(wl_client,
|
||||||
&xdg_positioner_interface,
|
&xdg_positioner_interface,
|
||||||
wl_resource_get_version(resource),
|
wl_resource_get_version(resource),
|
||||||
|
@ -437,9 +420,8 @@ static void xdg_shell_handle_create_positioner(struct wl_client *wl_client,
|
||||||
positioner, xdg_positioner_destroy);
|
positioner, xdg_positioner_destroy);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_box wlr_xdg_popup_get_geometry(struct wlr_xdg_popup *popup) {
|
struct wlr_box wlr_xdg_positioner_get_geometry(
|
||||||
assert(popup && popup->positioner);
|
struct wlr_xdg_positioner *positioner) {
|
||||||
struct wlr_xdg_positioner *positioner = popup->positioner;
|
|
||||||
struct wlr_box geometry = {
|
struct wlr_box geometry = {
|
||||||
.x = positioner->offset.x,
|
.x = positioner->offset.x,
|
||||||
.y = positioner->offset.y,
|
.y = positioner->offset.y,
|
||||||
|
@ -447,71 +429,39 @@ struct wlr_box wlr_xdg_popup_get_geometry(struct wlr_xdg_popup *popup) {
|
||||||
.height = positioner->size.height,
|
.height = positioner->size.height,
|
||||||
};
|
};
|
||||||
|
|
||||||
switch (positioner->anchor) {
|
if (positioner->anchor & XDG_POSITIONER_ANCHOR_TOP) {
|
||||||
case XDG_POSITIONER_ANCHOR_TOP:
|
|
||||||
case XDG_POSITIONER_ANCHOR_TOP_LEFT:
|
|
||||||
case XDG_POSITIONER_ANCHOR_TOP_RIGHT:
|
|
||||||
geometry.y += positioner->anchor_rect.y;
|
geometry.y += positioner->anchor_rect.y;
|
||||||
break;
|
} else if (positioner->anchor & XDG_POSITIONER_ANCHOR_BOTTOM) {
|
||||||
case XDG_POSITIONER_ANCHOR_BOTTOM:
|
|
||||||
case XDG_POSITIONER_ANCHOR_BOTTOM_LEFT:
|
|
||||||
case XDG_POSITIONER_ANCHOR_BOTTOM_RIGHT:
|
|
||||||
geometry.y +=
|
geometry.y +=
|
||||||
positioner->anchor_rect.y + positioner->anchor_rect.height;
|
positioner->anchor_rect.y + positioner->anchor_rect.height;
|
||||||
break;
|
} else {
|
||||||
default:
|
|
||||||
geometry.y +=
|
geometry.y +=
|
||||||
positioner->anchor_rect.y + positioner->anchor_rect.height / 2;
|
positioner->anchor_rect.y + positioner->anchor_rect.height / 2;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (positioner->anchor) {
|
if (positioner->anchor & XDG_POSITIONER_ANCHOR_LEFT) {
|
||||||
case XDG_POSITIONER_ANCHOR_LEFT:
|
|
||||||
case XDG_POSITIONER_ANCHOR_TOP_LEFT:
|
|
||||||
case XDG_POSITIONER_ANCHOR_BOTTOM_LEFT:
|
|
||||||
geometry.x += positioner->anchor_rect.x;
|
geometry.x += positioner->anchor_rect.x;
|
||||||
break;
|
} else if (positioner->anchor & XDG_POSITIONER_ANCHOR_RIGHT) {
|
||||||
case XDG_POSITIONER_ANCHOR_RIGHT:
|
|
||||||
case XDG_POSITIONER_ANCHOR_TOP_RIGHT:
|
|
||||||
case XDG_POSITIONER_ANCHOR_BOTTOM_RIGHT:
|
|
||||||
geometry.x += positioner->anchor_rect.x + positioner->anchor_rect.width;
|
geometry.x += positioner->anchor_rect.x + positioner->anchor_rect.width;
|
||||||
break;
|
} else {
|
||||||
default:
|
|
||||||
geometry.x +=
|
geometry.x +=
|
||||||
positioner->anchor_rect.x + positioner->anchor_rect.width / 2;
|
positioner->anchor_rect.x + positioner->anchor_rect.width / 2;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (positioner->gravity) {
|
if (positioner->gravity & XDG_POSITIONER_GRAVITY_TOP) {
|
||||||
case XDG_POSITIONER_GRAVITY_TOP:
|
|
||||||
case XDG_POSITIONER_GRAVITY_TOP_LEFT:
|
|
||||||
case XDG_POSITIONER_GRAVITY_TOP_RIGHT:
|
|
||||||
geometry.y -= geometry.height;
|
geometry.y -= geometry.height;
|
||||||
break;
|
} else if (positioner->gravity & XDG_POSITIONER_GRAVITY_BOTTOM) {
|
||||||
case XDG_POSITIONER_GRAVITY_BOTTOM:
|
|
||||||
case XDG_POSITIONER_GRAVITY_BOTTOM_LEFT:
|
|
||||||
case XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT:
|
|
||||||
geometry.y = geometry.y;
|
geometry.y = geometry.y;
|
||||||
break;
|
} else {
|
||||||
default:
|
|
||||||
geometry.y -= geometry.height / 2;
|
geometry.y -= geometry.height / 2;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (positioner->gravity) {
|
if (positioner->gravity & XDG_POSITIONER_GRAVITY_LEFT) {
|
||||||
case XDG_POSITIONER_GRAVITY_LEFT:
|
|
||||||
case XDG_POSITIONER_GRAVITY_TOP_LEFT:
|
|
||||||
case XDG_POSITIONER_GRAVITY_BOTTOM_LEFT:
|
|
||||||
geometry.x -= geometry.width;
|
geometry.x -= geometry.width;
|
||||||
break;
|
} else if (positioner->gravity & XDG_POSITIONER_GRAVITY_RIGHT) {
|
||||||
case XDG_POSITIONER_GRAVITY_RIGHT:
|
|
||||||
case XDG_POSITIONER_GRAVITY_TOP_RIGHT:
|
|
||||||
case XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT:
|
|
||||||
geometry.x = geometry.x;
|
geometry.x = geometry.x;
|
||||||
break;
|
} else {
|
||||||
default:
|
|
||||||
geometry.x -= geometry.width / 2;
|
geometry.x -= geometry.width / 2;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (positioner->constraint_adjustment ==
|
if (positioner->constraint_adjustment ==
|
||||||
|
@ -519,8 +469,6 @@ struct wlr_box wlr_xdg_popup_get_geometry(struct wlr_xdg_popup *popup) {
|
||||||
return geometry;
|
return geometry;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: add compositor policy configuration and the code here
|
|
||||||
|
|
||||||
return geometry;
|
return geometry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -620,10 +568,11 @@ static void xdg_surface_handle_get_popup(struct wl_client *client,
|
||||||
wlr_xdg_surface_from_resource(resource);
|
wlr_xdg_surface_from_resource(resource);
|
||||||
struct wlr_xdg_surface *parent =
|
struct wlr_xdg_surface *parent =
|
||||||
wlr_xdg_surface_from_resource(parent_resource);
|
wlr_xdg_surface_from_resource(parent_resource);
|
||||||
struct wlr_xdg_positioner *positioner =
|
struct wlr_xdg_positioner_resource *positioner =
|
||||||
xdg_positioner_from_resource(positioner_resource);
|
xdg_positioner_from_resource(positioner_resource);
|
||||||
|
|
||||||
if (positioner->size.width == -1 || positioner->anchor_rect.width == -1) {
|
if (positioner->attrs.size.width == 0 ||
|
||||||
|
positioner->attrs.anchor_rect.width == 0) {
|
||||||
wl_resource_post_error(resource,
|
wl_resource_post_error(resource,
|
||||||
XDG_WM_BASE_ERROR_INVALID_POSITIONER,
|
XDG_WM_BASE_ERROR_INVALID_POSITIONER,
|
||||||
"positioner object is not complete");
|
"positioner object is not complete");
|
||||||
|
@ -652,7 +601,10 @@ static void xdg_surface_handle_get_popup(struct wl_client *client,
|
||||||
|
|
||||||
surface->role = WLR_XDG_SURFACE_ROLE_POPUP;
|
surface->role = WLR_XDG_SURFACE_ROLE_POPUP;
|
||||||
surface->popup->base = surface;
|
surface->popup->base = surface;
|
||||||
surface->popup->positioner = positioner;
|
|
||||||
|
// positioner properties
|
||||||
|
memcpy(&surface->popup->positioner, &positioner->attrs,
|
||||||
|
sizeof(struct wlr_xdg_positioner));
|
||||||
|
|
||||||
wl_resource_set_implementation(surface->popup->resource,
|
wl_resource_set_implementation(surface->popup->resource,
|
||||||
&xdg_popup_implementation, surface,
|
&xdg_popup_implementation, surface,
|
||||||
|
@ -660,7 +612,8 @@ static void xdg_surface_handle_get_popup(struct wl_client *client,
|
||||||
|
|
||||||
if (parent) {
|
if (parent) {
|
||||||
surface->popup->parent = parent->surface;
|
surface->popup->parent = parent->surface;
|
||||||
surface->popup->geometry = wlr_xdg_popup_get_geometry(surface->popup);
|
surface->popup->geometry =
|
||||||
|
wlr_xdg_positioner_get_geometry(&positioner->attrs);
|
||||||
wl_list_insert(&parent->popups, &surface->popup->link);
|
wl_list_insert(&parent->popups, &surface->popup->link);
|
||||||
wlr_signal_emit_safe(&parent->events.new_popup, surface->popup);
|
wlr_signal_emit_safe(&parent->events.new_popup, surface->popup);
|
||||||
}
|
}
|
||||||
|
|
|
@ -486,8 +486,6 @@ struct wlr_box wlr_xdg_positioner_v6_get_geometry(
|
||||||
return geometry;
|
return geometry;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: add compositor policy configuration and the code here
|
|
||||||
|
|
||||||
return geometry;
|
return geometry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue