]> git.mdlowis.com Git - proto/labwc.git/commitdiff
menu: fix breakage caused by f857aea8
authorJohan Malm <jgm323@gmail.com>
Mon, 9 Aug 2021 16:28:39 +0000 (17:28 +0100)
committerJohan Malm <jgm323@gmail.com>
Mon, 9 Aug 2021 16:28:39 +0000 (17:28 +0100)
include/menu/menu.h
src/menu/menu.c
src/output.c

index b0c286ca6f953aa4af94bb2f539a2295930becff..f9280a7c273cb165e421bc64d3ecfb438dd184c8 100644 (file)
@@ -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);
 
index 422faf7f88887d74ab4508db223147254c61ba66..01b26de5a8960ac4fea9a9b2632ac66bd6cb53b7 100644 (file)
@@ -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
index d8738763ae6ae5595f362d0f3bc940b36c6eeafc..2b421ab65adc384c177b897a5c33f939cd9de11b 100644 (file)
@@ -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);
+               }
        }
 }