use wlr_scene_xdg_popup_create()

This commit is contained in:
Leonardo Hernandez Hernandez 2021-10-29 18:38:24 -05:00
parent 05ac420342
commit 9ff28360f6
No known key found for this signature in database
GPG Key ID: E538897EE11B9624

31
dwl.c
View File

@ -253,6 +253,7 @@ static void motionabsolute(struct wl_listener *listener, void *data);
static void motionnotify(uint32_t time);
static void motionrelative(struct wl_listener *listener, void *data);
static void moveresize(const Arg *arg);
static Client *popupgetclient(struct wlr_xdg_popup *popup);
static void outputmgrapply(struct wl_listener *listener, void *data);
static void outputmgrapplyortest(struct wlr_output_configuration_v1 *config, int test);
static void outputmgrtest(struct wl_listener *listener, void *data);
@ -876,7 +877,14 @@ createnotify(struct wl_listener *listener, void *data)
struct wlr_xdg_surface *xdg_surface = data;
Client *c;
if (xdg_surface->role != WLR_XDG_SURFACE_ROLE_TOPLEVEL)
if (xdg_surface->role == WLR_XDG_SURFACE_ROLE_POPUP) {
if (!(c = popupgetclient(xdg_surface->popup)))
return;
wlr_scene_xdg_popup_create(c->scene_surface, xdg_surface->popup);
return;
} else if (xdg_surface->role == WLR_XDG_SURFACE_ROLE_NONE)
return;
/* Allocate a Client for this surface */
@ -1445,6 +1453,27 @@ moveresize(const Arg *arg)
}
}
Client *
popupgetclient(struct wlr_xdg_popup *popup)
{
struct wlr_xdg_surface *surface = popup->base;
while (true) {
switch (surface->role) {
case WLR_XDG_SURFACE_ROLE_POPUP:
if (!wlr_surface_is_xdg_surface(surface->popup->parent)) {
return NULL;
}
surface = wlr_xdg_surface_from_wlr_surface(surface->popup->parent);
break;
case WLR_XDG_SURFACE_ROLE_TOPLEVEL:
return surface->data;
case WLR_XDG_SURFACE_ROLE_NONE:
return NULL;
}
}
}
void
outputmgrapply(struct wl_listener *listener, void *data)
{