mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2024-11-25 16:42:26 +00:00
examples/layer-shell: take an explicit grab on the popup
This demonstrates popups can be closed by clicking on the area outside the popup and parent.
This commit is contained in:
parent
e2ed7be0ba
commit
67a10cc1f6
@ -209,7 +209,7 @@ static const struct xdg_popup_listener xdg_popup_listener = {
|
|||||||
.popup_done = xdg_popup_done,
|
.popup_done = xdg_popup_done,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void create_popup() {
|
static void create_popup(uint32_t serial) {
|
||||||
if (popup) {
|
if (popup) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -227,6 +227,8 @@ static void create_popup() {
|
|||||||
xdg_positioner_set_anchor(xdg_positioner, XDG_POSITIONER_ANCHOR_BOTTOM_RIGHT);
|
xdg_positioner_set_anchor(xdg_positioner, XDG_POSITIONER_ANCHOR_BOTTOM_RIGHT);
|
||||||
|
|
||||||
popup = xdg_surface_get_popup(xdg_surface, NULL, xdg_positioner);
|
popup = xdg_surface_get_popup(xdg_surface, NULL, xdg_positioner);
|
||||||
|
xdg_popup_grab(popup, seat, serial);
|
||||||
|
|
||||||
assert(popup);
|
assert(popup);
|
||||||
|
|
||||||
zwlr_layer_surface_v1_get_popup(layer_surface, popup);
|
zwlr_layer_surface_v1_get_popup(layer_surface, popup);
|
||||||
@ -311,7 +313,7 @@ static void wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
|
|||||||
if (popup_wl_surface) {
|
if (popup_wl_surface) {
|
||||||
popup_destroy();
|
popup_destroy();
|
||||||
} else {
|
} else {
|
||||||
create_popup();
|
create_popup(serial);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
buttons++;
|
buttons++;
|
||||||
|
Loading…
Reference in New Issue
Block a user