This commit is contained in:
parent
bbbd248051
commit
b59ddffce6
4 changed files with 20 additions and 5 deletions
|
|
@ -169,6 +169,7 @@ struct _MwMenu {
|
|||
MwMenu* sub;
|
||||
void* opaque;
|
||||
int cleaned;
|
||||
int bold;
|
||||
};
|
||||
|
||||
struct _MwEntry {
|
||||
|
|
|
|||
|
|
@ -628,6 +628,8 @@ static void setup_popup(MwLL r, int x, int y, MwLL parent) {
|
|||
|
||||
xdg_positioner_set_anchor(r->wayland.popup->xdg_positioner, XDG_POSITIONER_ANCHOR_NONE);
|
||||
xdg_positioner_set_gravity(r->wayland.popup->xdg_positioner, XDG_POSITIONER_GRAVITY_NONE);
|
||||
/* we can't see where we are on screen, so let the compositor keep the popup on it */
|
||||
xdg_positioner_set_constraint_adjustment(r->wayland.popup->xdg_positioner, XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_X | XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_Y);
|
||||
|
||||
r->wayland.xkb_keymap = topmost_parent->wayland.xkb_keymap;
|
||||
r->wayland.xkb_state = topmost_parent->wayland.xkb_state;
|
||||
|
|
@ -1776,7 +1778,12 @@ static void MwLLDetachImpl(MwLL handle, MwPoint* point) {
|
|||
|
||||
while(p != NULL) {
|
||||
/* a layer surface's x/y is its position on screen, which like a toplevel's isn't part of the offset */
|
||||
if(p->wayland.type != MwLL_WAYLAND_TOPLEVEL && p->wayland.type != MwLL_WAYLAND_LAYER_SURFACE) {
|
||||
if(p->wayland.type == MwLL_WAYLAND_POPUP) {
|
||||
/* a popup's x/y is already relative to the topmost surface, so anything above it is counted already */
|
||||
x += p->wayland.x;
|
||||
y += p->wayland.y;
|
||||
break;
|
||||
} else if(p->wayland.type != MwLL_WAYLAND_TOPLEVEL && p->wayland.type != MwLL_WAYLAND_LAYER_SURFACE) {
|
||||
x += p->wayland.x;
|
||||
y += p->wayland.y;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -248,6 +248,7 @@ static MwMenu mwMenuAddImpl(MwWidget handle, MwMenu menu, const char* name) {
|
|||
new->wsub = NULL;
|
||||
new->keep = 0;
|
||||
new->cleaned = 0;
|
||||
new->bold = 0;
|
||||
|
||||
arrput(m->sub, new);
|
||||
|
||||
|
|
|
|||
|
|
@ -57,8 +57,9 @@ static void draw(MwWidget handle) {
|
|||
|
||||
p.y += 2 + 1;
|
||||
} else {
|
||||
int tw = MwTextWidth(handle, NULL, menu->sub[i]->name);
|
||||
int th = MwTextHeight(handle, NULL, menu->sub[i]->name);
|
||||
MwFLFont font = MwFLBuildFont(menu->sub[i]->wsub != NULL ? MwFLFlagBold : 0);
|
||||
int tw = MwTextWidth(handle, font, menu->sub[i]->name);
|
||||
int th = MwTextHeight(handle, NULL, menu->sub[i]->name);
|
||||
|
||||
if(menu->sub[i]->wsub != NULL) {
|
||||
r.x = MwGetInteger(handle, MwNleftPadding);
|
||||
|
|
@ -71,7 +72,7 @@ static void draw(MwWidget handle) {
|
|||
p.x = 5 + tw / 2 + MwGetInteger(handle, MwNleftPadding);
|
||||
|
||||
p.y += th / 2;
|
||||
MwDrawText(handle, MwFLBuildFont(menu->sub[i]->wsub != NULL ? MwFLFlagBold : 0), &p, menu->sub[i]->name, MwALIGNMENT_CENTER, text);
|
||||
MwDrawText(handle, font, &p, menu->sub[i]->name, MwALIGNMENT_CENTER, text);
|
||||
|
||||
if(arrlen(menu->sub[i]->sub) > 0) {
|
||||
MwRect tr;
|
||||
|
|
@ -182,6 +183,11 @@ static void mwSubMenuAppearImpl(MwWidget handle, MwMenu menu, MwPoint* point, in
|
|||
MwLLMakeToolWindow(handle->lowlevel);
|
||||
MwLLDetach(handle->lowlevel, &p);
|
||||
|
||||
MwVaApply(handle,
|
||||
MwNwidth, sz.width,
|
||||
MwNheight, sz.height,
|
||||
NULL);
|
||||
|
||||
if(handle->lowlevel->common.coordinate_type == MwCOORDINATE_GLOBAL) {
|
||||
if(MwGetInteger(handle, MwNy) + sz.height > rc.height) {
|
||||
MwVaApply(handle,
|
||||
|
|
@ -208,7 +214,7 @@ static void mwSubMenuGetSizeImpl(MwWidget handle, MwMenu menu, MwRect* rect) {
|
|||
if(strcmp(menu->sub[i]->name, "----") == 0) {
|
||||
rect->height += 2 + 2;
|
||||
} else {
|
||||
int tw = MwTextWidth(handle, NULL, menu->sub[i]->name);
|
||||
int tw = MwTextWidth(handle, MwFLBuildFont(arrlen(menu->sub[i]->sub) > 0 ? MwFLFlagBold : 0), menu->sub[i]->name);
|
||||
rect->height += MwTextHeight(handle, NULL, menu->sub[i]->name) + 3;
|
||||
if(tw > rect->width) {
|
||||
rect->width = tw;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue