mirror of
https://github.com/labwc/labwc.git
synced 2025-11-02 09:01:47 -05:00
menu: support menu.overlap.x with pipemenus
No inteded functional change intended with refactoring of get_submenu_position(). Fixes #1870
This commit is contained in:
parent
74e1ba72e3
commit
b8c3e064e7
1 changed files with 10 additions and 19 deletions
|
|
@ -702,22 +702,23 @@ menu_get_full_width(struct menu *menu)
|
||||||
return width + max_child_width;
|
return width + max_child_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get_submenu_position() - get output layout coordinates of menu window
|
||||||
|
* @item: the menuitem that triggers the submenu (static or dynamic)
|
||||||
|
*/
|
||||||
static struct wlr_box
|
static struct wlr_box
|
||||||
get_submenu_position(struct menuitem *item, enum menu_align align)
|
get_submenu_position(struct menuitem *item, enum menu_align align)
|
||||||
{
|
{
|
||||||
struct wlr_box pos = { 0 };
|
struct wlr_box pos = { 0 };
|
||||||
struct menu *menu = item->parent;
|
struct menu *menu = item->parent;
|
||||||
struct theme *theme = menu->server->theme;
|
struct theme *theme = menu->server->theme;
|
||||||
int lx = menu->scene_tree->node.x;
|
pos.x = menu->scene_tree->node.x;
|
||||||
int ly = menu->scene_tree->node.y;
|
pos.y = menu->scene_tree->node.y;
|
||||||
|
|
||||||
if (align & LAB_MENU_OPEN_RIGHT) {
|
if (align & LAB_MENU_OPEN_RIGHT) {
|
||||||
pos.x = lx + menu->size.width - theme->menu_overlap_x;
|
pos.x += menu->size.width - theme->menu_overlap_x;
|
||||||
} else {
|
|
||||||
pos.x = lx;
|
|
||||||
}
|
}
|
||||||
int rel_y = item->tree->node.y;
|
pos.y += item->tree->node.y - theme->menu_overlap_y;
|
||||||
pos.y = ly + rel_y - theme->menu_overlap_y;
|
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1117,19 +1118,9 @@ create_pipe_menu(struct pipe_context *ctx)
|
||||||
/* Set menu-widths before configuring */
|
/* Set menu-widths before configuring */
|
||||||
post_processing(ctx->server);
|
post_processing(ctx->server);
|
||||||
|
|
||||||
/*
|
|
||||||
* TODO:
|
|
||||||
* (1) Combine this with the code in get_submenu_position()
|
|
||||||
* and/or menu_configure()
|
|
||||||
* (2) Take into account menu_overlap_{x,y}
|
|
||||||
*/
|
|
||||||
enum menu_align align = ctx->item->parent->align;
|
enum menu_align align = ctx->item->parent->align;
|
||||||
int x = pipe_parent->scene_tree->node.x;
|
struct wlr_box pos = get_submenu_position(ctx->item, align);
|
||||||
int y = pipe_parent->scene_tree->node.y + ctx->item->tree->node.y;
|
menu_configure(pipe_menu, pos.x, pos.y, align);
|
||||||
if (align & LAB_MENU_OPEN_RIGHT) {
|
|
||||||
x += pipe_parent->size.width;
|
|
||||||
}
|
|
||||||
menu_configure(pipe_menu, x, y, align);
|
|
||||||
|
|
||||||
validate(ctx->server);
|
validate(ctx->server);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue