wayland: popup positioning
This commit is contained in:
parent
12f279e83a
commit
d784770ca9
3 changed files with 20 additions and 10 deletions
|
|
@ -74,7 +74,7 @@ struct _MwLLWaylandPopup {
|
||||||
struct xdg_positioner* xdg_positioner;
|
struct xdg_positioner* xdg_positioner;
|
||||||
struct xdg_surface_listener xdg_surface_listener;
|
struct xdg_surface_listener xdg_surface_listener;
|
||||||
struct xdg_wm_base* xdg_wm_base;
|
struct xdg_wm_base* xdg_wm_base;
|
||||||
MwLL parent;
|
MwLL topmost_parent;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Shared set of anything needed for a shm buffer. */
|
/* Shared set of anything needed for a shm buffer. */
|
||||||
|
|
|
||||||
|
|
@ -1263,12 +1263,14 @@ struct xdg_popup_listener popup_listener = {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Popup setup function */
|
/* Popup setup function */
|
||||||
static void setup_popup(MwLL r) {
|
static void setup_popup(MwLL r, int x, int y) {
|
||||||
int i;
|
int i;
|
||||||
struct xdg_surface* xdg_surface;
|
struct xdg_surface* xdg_surface;
|
||||||
MwLL topmost_parent = r->wayland.parent;
|
MwLL topmost_parent = r->wayland.parent;
|
||||||
|
|
||||||
r->wayland.type = MWLL_WAYLAND_POPUP;
|
r->wayland.type = MWLL_WAYLAND_POPUP;
|
||||||
|
r->wayland.x = x;
|
||||||
|
r->wayland.y = y;
|
||||||
|
|
||||||
while(topmost_parent->wayland.type != MWLL_WAYLAND_TOPLEVEL) {
|
while(topmost_parent->wayland.type != MWLL_WAYLAND_TOPLEVEL) {
|
||||||
topmost_parent = topmost_parent->wayland.parent;
|
topmost_parent = topmost_parent->wayland.parent;
|
||||||
|
|
@ -1276,6 +1278,7 @@ static void setup_popup(MwLL r) {
|
||||||
|
|
||||||
r->wayland.popup = malloc(sizeof(struct _MwLLWaylandPopup));
|
r->wayland.popup = malloc(sizeof(struct _MwLLWaylandPopup));
|
||||||
memset(r->wayland.popup, 0, sizeof(struct _MwLLWaylandPopup));
|
memset(r->wayland.popup, 0, sizeof(struct _MwLLWaylandPopup));
|
||||||
|
r->wayland.popup->topmost_parent = topmost_parent;
|
||||||
|
|
||||||
setup_callbacks(&r->wayland);
|
setup_callbacks(&r->wayland);
|
||||||
|
|
||||||
|
|
@ -1288,14 +1291,16 @@ static void setup_popup(MwLL r) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
r->wayland.popup->xdg_wm_base = WAYLAND_GET_INTERFACE(r->wayland, xdg_wm_base)->context;
|
r->wayland.popup->xdg_wm_base = WAYLAND_GET_INTERFACE(topmost_parent->wayland, xdg_wm_base)->context;
|
||||||
|
|
||||||
r->wayland.popup->xdg_positioner = xdg_wm_base_create_positioner(r->wayland.popup->xdg_wm_base);
|
r->wayland.popup->xdg_positioner = xdg_wm_base_create_positioner(r->wayland.popup->xdg_wm_base);
|
||||||
|
|
||||||
xdg_positioner_set_size(r->wayland.popup->xdg_positioner, r->wayland.ww, r->wayland.wh);
|
xdg_positioner_set_size(r->wayland.popup->xdg_positioner, r->wayland.ww, r->wayland.wh);
|
||||||
|
xdg_positioner_set_anchor(r->wayland.popup->xdg_positioner, XDG_POSITIONER_ANCHOR_NONE);
|
||||||
xdg_positioner_set_anchor_rect(
|
xdg_positioner_set_anchor_rect(
|
||||||
r->wayland.popup->xdg_positioner, 0, 0,
|
r->wayland.popup->xdg_positioner, 0, 0, 1, 1);
|
||||||
1, 1);
|
printf("%d, %d\n", x, y);
|
||||||
|
xdg_positioner_set_offset(r->wayland.popup->xdg_positioner, x, y);
|
||||||
|
|
||||||
xdg_surface = topmost_parent->wayland.toplevel->xdg_surface;
|
xdg_surface = topmost_parent->wayland.toplevel->xdg_surface;
|
||||||
|
|
||||||
|
|
@ -1450,13 +1455,17 @@ static void MwLLGetXYWHImpl(MwLL handle, int* x, int* y, unsigned int* w, unsign
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MwLLSetXYImpl(MwLL handle, int x, int y) {
|
static void MwLLSetXYImpl(MwLL handle, int x, int y) {
|
||||||
if(handle->wayland.type == MWLL_WAYLAND_SUBLEVEL) {
|
|
||||||
region_invalidate(handle);
|
region_invalidate(handle);
|
||||||
handle->wayland.x = x;
|
handle->wayland.x = x;
|
||||||
handle->wayland.y = y;
|
handle->wayland.y = y;
|
||||||
|
if(handle->wayland.type == MWLL_WAYLAND_SUBLEVEL) {
|
||||||
wl_subsurface_set_position(handle->wayland.sublevel->subsurface, x, y);
|
wl_subsurface_set_position(handle->wayland.sublevel->subsurface, x, y);
|
||||||
region_setup(handle);
|
|
||||||
}
|
}
|
||||||
|
if(handle->wayland.type == MWLL_WAYLAND_POPUP) {
|
||||||
|
destroy_popup(handle);
|
||||||
|
setup_popup(handle, x, y);
|
||||||
|
}
|
||||||
|
region_setup(handle);
|
||||||
|
|
||||||
MwLLDispatch(handle, draw, NULL);
|
MwLLDispatch(handle, draw, NULL);
|
||||||
}
|
}
|
||||||
|
|
@ -1761,7 +1770,7 @@ static void MwLLDetachImpl(MwLL handle, MwPoint* point) {
|
||||||
|
|
||||||
switch(handle->wayland.type_to_be) {
|
switch(handle->wayland.type_to_be) {
|
||||||
case MWLL_WAYLAND_POPUP:
|
case MWLL_WAYLAND_POPUP:
|
||||||
setup_popup(handle);
|
setup_popup(handle, point->x, point->y);
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
setup_toplevel(handle, point->x, point->y);
|
setup_toplevel(handle, point->x, point->y);
|
||||||
|
|
|
||||||
|
|
@ -188,6 +188,7 @@ static void mwSubMenuAppearImpl(MwWidget handle, MwMenu menu, MwPoint* point, in
|
||||||
MwNy, rc.height - sz.height,
|
MwNy, rc.height - sz.height,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
MwLLEndStateChange(handle->lowlevel);
|
MwLLEndStateChange(handle->lowlevel);
|
||||||
|
|
||||||
MwVaApply(handle,
|
MwVaApply(handle,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue