mirror of
https://github.com/labwc/labwc.git
synced 2026-02-05 04:06:33 -05:00
menu: fix breakage caused by f857aea8
This commit is contained in:
parent
0e57c65393
commit
9a9cd609f6
3 changed files with 29 additions and 17 deletions
|
|
@ -15,17 +15,15 @@ struct menuitem {
|
|||
int offset_y;
|
||||
} texture;
|
||||
bool selected;
|
||||
struct wl_list link;
|
||||
struct wl_list link; /* menu::menuitems */
|
||||
};
|
||||
|
||||
struct menu {
|
||||
struct server *server;
|
||||
int x;
|
||||
int y;
|
||||
struct wlr_box box;
|
||||
struct wl_list menuitems;
|
||||
};
|
||||
|
||||
/* menu_create - create menu */
|
||||
void menu_init_rootmenu(struct server *server, struct menu *menu);
|
||||
void menu_finish(struct menu *menu);
|
||||
|
||||
|
|
|
|||
|
|
@ -231,16 +231,19 @@ menu_finish(struct menu *menu)
|
|||
void
|
||||
menu_move(struct menu *menu, int x, int y)
|
||||
{
|
||||
menu->x = x;
|
||||
menu->y = y;
|
||||
menu->box.x = x;
|
||||
menu->box.y = y;
|
||||
|
||||
int offset = 0;
|
||||
struct menuitem *menuitem;
|
||||
wl_list_for_each_reverse (menuitem, &menu->menuitems, link) {
|
||||
menuitem->box.x = menu->x;
|
||||
menuitem->box.y = menu->y + offset;
|
||||
menuitem->box.x = menu->box.x;
|
||||
menuitem->box.y = menu->box.y + offset;
|
||||
offset += menuitem->box.height;
|
||||
}
|
||||
|
||||
menu->box.width = MENUWIDTH;
|
||||
menu->box.height = offset;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
29
src/output.c
29
src/output.c
|
|
@ -535,28 +535,39 @@ static void
|
|||
render_rootmenu(struct output *output, pixman_region32_t *output_damage)
|
||||
{
|
||||
struct server *server = output->server;
|
||||
struct theme *theme = server->theme;
|
||||
float matrix[9];
|
||||
|
||||
struct wlr_output_layout *output_layout = server->output_layout;
|
||||
double ox = 0, oy = 0;
|
||||
wlr_output_layout_output_coords(output_layout, output->wlr_output,
|
||||
&ox, &oy);
|
||||
|
||||
/* background */
|
||||
render_rect(output, output_damage, &server->rootmenu->box,
|
||||
theme->menu_items_bg_color);
|
||||
|
||||
/* items */
|
||||
struct menuitem *menuitem;
|
||||
wl_list_for_each (menuitem, &server->rootmenu->menuitems, link) {
|
||||
struct wlr_texture *t;
|
||||
t = menuitem->selected ? menuitem->texture.active :
|
||||
menuitem->texture.inactive;
|
||||
struct wlr_box box = {
|
||||
.x = menuitem->box.x + ox + menuitem->texture.offset_x,
|
||||
.y = menuitem->box.y + oy + menuitem->texture.offset_y,
|
||||
.width = t->width,
|
||||
.height = t->height,
|
||||
.x = menuitem->box.x + menuitem->texture.offset_x + ox,
|
||||
.y = menuitem->box.y + menuitem->texture.offset_y + oy,
|
||||
.width = menuitem->texture.active->width,
|
||||
.height = menuitem->texture.active->height,
|
||||
};
|
||||
scale_box(&box, output->wlr_output->scale);
|
||||
wlr_matrix_project_box(matrix, &box, WL_OUTPUT_TRANSFORM_NORMAL,
|
||||
0, output->wlr_output->transform_matrix);
|
||||
render_texture(output->wlr_output, output_damage, t,
|
||||
&box, matrix);
|
||||
if (menuitem->selected) {
|
||||
render_rect(output, output_damage, &menuitem->box,
|
||||
theme->menu_items_active_bg_color);
|
||||
render_texture(output->wlr_output, output_damage,
|
||||
menuitem->texture.active, &box, matrix);
|
||||
} else {
|
||||
render_texture(output->wlr_output, output_damage,
|
||||
menuitem->texture.inactive, &box, matrix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue