mirror of
https://github.com/labwc/labwc.git
synced 2026-03-10 05:33:47 -04: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;
|
int offset_y;
|
||||||
} texture;
|
} texture;
|
||||||
bool selected;
|
bool selected;
|
||||||
struct wl_list link;
|
struct wl_list link; /* menu::menuitems */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct menu {
|
struct menu {
|
||||||
struct server *server;
|
struct server *server;
|
||||||
int x;
|
struct wlr_box box;
|
||||||
int y;
|
|
||||||
struct wl_list menuitems;
|
struct wl_list menuitems;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* menu_create - create menu */
|
|
||||||
void menu_init_rootmenu(struct server *server, struct menu *menu);
|
void menu_init_rootmenu(struct server *server, struct menu *menu);
|
||||||
void menu_finish(struct menu *menu);
|
void menu_finish(struct menu *menu);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -231,16 +231,19 @@ menu_finish(struct menu *menu)
|
||||||
void
|
void
|
||||||
menu_move(struct menu *menu, int x, int y)
|
menu_move(struct menu *menu, int x, int y)
|
||||||
{
|
{
|
||||||
menu->x = x;
|
menu->box.x = x;
|
||||||
menu->y = y;
|
menu->box.y = y;
|
||||||
|
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
struct menuitem *menuitem;
|
struct menuitem *menuitem;
|
||||||
wl_list_for_each_reverse (menuitem, &menu->menuitems, link) {
|
wl_list_for_each_reverse (menuitem, &menu->menuitems, link) {
|
||||||
menuitem->box.x = menu->x;
|
menuitem->box.x = menu->box.x;
|
||||||
menuitem->box.y = menu->y + offset;
|
menuitem->box.y = menu->box.y + offset;
|
||||||
offset += menuitem->box.height;
|
offset += menuitem->box.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
menu->box.width = MENUWIDTH;
|
||||||
|
menu->box.height = offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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)
|
render_rootmenu(struct output *output, pixman_region32_t *output_damage)
|
||||||
{
|
{
|
||||||
struct server *server = output->server;
|
struct server *server = output->server;
|
||||||
|
struct theme *theme = server->theme;
|
||||||
float matrix[9];
|
float matrix[9];
|
||||||
|
|
||||||
struct wlr_output_layout *output_layout = server->output_layout;
|
struct wlr_output_layout *output_layout = server->output_layout;
|
||||||
double ox = 0, oy = 0;
|
double ox = 0, oy = 0;
|
||||||
wlr_output_layout_output_coords(output_layout, output->wlr_output,
|
wlr_output_layout_output_coords(output_layout, output->wlr_output,
|
||||||
&ox, &oy);
|
&ox, &oy);
|
||||||
|
|
||||||
|
/* background */
|
||||||
|
render_rect(output, output_damage, &server->rootmenu->box,
|
||||||
|
theme->menu_items_bg_color);
|
||||||
|
|
||||||
|
/* items */
|
||||||
struct menuitem *menuitem;
|
struct menuitem *menuitem;
|
||||||
wl_list_for_each (menuitem, &server->rootmenu->menuitems, link) {
|
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 = {
|
struct wlr_box box = {
|
||||||
.x = menuitem->box.x + ox + menuitem->texture.offset_x,
|
.x = menuitem->box.x + menuitem->texture.offset_x + ox,
|
||||||
.y = menuitem->box.y + oy + menuitem->texture.offset_y,
|
.y = menuitem->box.y + menuitem->texture.offset_y + oy,
|
||||||
.width = t->width,
|
.width = menuitem->texture.active->width,
|
||||||
.height = t->height,
|
.height = menuitem->texture.active->height,
|
||||||
};
|
};
|
||||||
scale_box(&box, output->wlr_output->scale);
|
scale_box(&box, output->wlr_output->scale);
|
||||||
wlr_matrix_project_box(matrix, &box, WL_OUTPUT_TRANSFORM_NORMAL,
|
wlr_matrix_project_box(matrix, &box, WL_OUTPUT_TRANSFORM_NORMAL,
|
||||||
0, output->wlr_output->transform_matrix);
|
0, output->wlr_output->transform_matrix);
|
||||||
render_texture(output->wlr_output, output_damage, t,
|
if (menuitem->selected) {
|
||||||
&box, matrix);
|
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