]> git.mdlowis.com Git - proto/labwc.git/commitdiff
Add WindowMenu button
authorConsolatis <35009135+Consolatis@users.noreply.github.com>
Wed, 26 Jan 2022 01:54:03 +0000 (02:54 +0100)
committerJohan Malm <johanmalm@users.noreply.github.com>
Wed, 26 Jan 2022 06:17:41 +0000 (06:17 +0000)
docs/rc.xml.all
include/ssd.h
include/theme.h
src/action.c
src/config/mousebind.c
src/config/rcxml.c
src/output.c
src/ssd.c
src/theme.c
src/xbm/xbm.c

index 399f11ed557c67c146bb30669ad1ec99a5682bfc..2fb314033e7950d7691a008acc12f59cf8c06172 100644 (file)
       </mousebind>
     </context>
 
+    <context name="WindowMenu">
+      <mousebind button="Left" action="Click">
+        <action name="ShowMenu">
+          <menu>client-menu</menu>
+        </action>
+      </mousebind>
+    </context>
+
     <context name="Iconify">
       <mousebind button="left" action="Click">
         <action name="Iconify"/>
index 8ec56295d8a2b1b383afe8ef93b1cdbaba537dda..e61ad67612130b7cf6ff4c5c325d91461227d7d7 100644 (file)
@@ -14,6 +14,7 @@ enum ssd_part_type {
        LAB_SSD_BUTTON_CLOSE,
        LAB_SSD_BUTTON_MAXIMIZE,
        LAB_SSD_BUTTON_ICONIFY,
+       LAB_SSD_BUTTON_WINDOW_MENU,
        LAB_SSD_PART_TITLEBAR,
        LAB_SSD_PART_TITLE,
        LAB_SSD_PART_CORNER_TOP_LEFT,
index 2f97c10b570dbdf64840b0584e5c936b795c7371..38aae4c0068192e575ed8e1479f5d27f928603da 100644 (file)
@@ -35,9 +35,11 @@ struct theme {
        enum lab_justification window_label_text_justify;
 
        /* button colors */
+       float window_active_button_menu_unpressed_image_color[4];
        float window_active_button_iconify_unpressed_image_color[4];
        float window_active_button_max_unpressed_image_color[4];
        float window_active_button_close_unpressed_image_color[4];
+       float window_inactive_button_menu_unpressed_image_color[4];
        float window_inactive_button_iconify_unpressed_image_color[4];
        float window_inactive_button_max_unpressed_image_color[4];
        float window_inactive_button_close_unpressed_image_color[4];
@@ -55,10 +57,12 @@ struct theme {
        struct wlr_texture *xbm_close_active_unpressed;
        struct wlr_texture *xbm_maximize_active_unpressed;
        struct wlr_texture *xbm_iconify_active_unpressed;
+       struct wlr_texture *xbm_menu_active_unpressed;
 
        struct wlr_texture *xbm_close_inactive_unpressed;
        struct wlr_texture *xbm_maximize_inactive_unpressed;
        struct wlr_texture *xbm_iconify_inactive_unpressed;
+       struct wlr_texture *xbm_menu_inactive_unpressed;
 
        struct wlr_texture *corner_top_left_active_normal;
        struct wlr_texture *corner_top_right_active_normal;
index ad3e8dabc34679bb6e4875fb03021387f8b14bfa..dfb6ed59b183f758ea2f2a92a97fe27b2a8b03f0 100644 (file)
@@ -5,6 +5,7 @@
 #include "common/zfree.h"
 #include "labwc.h"
 #include "menu/menu.h"
+#include "ssd.h"
 #include "action.h"
 
 enum action_type {
@@ -102,6 +103,15 @@ show_menu(struct server *server, struct view *view, const char *menu_name)
        } else if (!strcasecmp(menu_name, "client-menu") && view) {
                menu = server->windowmenu;
                server->rootmenu->visible = false;
+               enum ssd_part_type type = ssd_at(view, server->seat.cursor->x,
+                       server->seat.cursor->y);
+               if (type == LAB_SSD_BUTTON_WINDOW_MENU) {
+                       force_menu_top_left = true;
+               } else if (ssd_part_contains(LAB_SSD_PART_TITLEBAR, type)) {
+                       force_menu_top_left = false;
+               } else {
+                       force_menu_top_left = true;
+               }
        } else {
                return;
        }
index 37962c3e271d9bb9f23c0069a8b9d1890e114909..9d44f7351288665e1c48bf9b5382f1fcda93d387 100644 (file)
@@ -66,6 +66,8 @@ context_from_str(const char *str)
                return LAB_SSD_BUTTON_MAXIMIZE;
        } else if (!strcasecmp(str, "Iconify")) {
                return LAB_SSD_BUTTON_ICONIFY;
+       } else if (!strcasecmp(str, "WindowMenu")) {
+               return LAB_SSD_BUTTON_WINDOW_MENU;
        } else if (!strcasecmp(str, "Titlebar")) {
                return LAB_SSD_PART_TITLEBAR;
        } else if (!strcasecmp(str, "Title")) {
index a541970f2aff770cf221c5520a7f0be0fb247720..5496dc984bb47bf502735e2fd99dc29957f4c2a7 100644 (file)
@@ -560,6 +560,7 @@ static struct {
        { "Close", "Left", "Click", "Close", NULL },
        { "Iconify", "Left", "Click", "Iconify", NULL},
        { "Maximize", "Left", "Click", "ToggleMaximize", NULL},
+       { "WindowMenu", "Left", "Click", "ShowMenu", "client-menu"},
        { "Root", "Left", "Press", "ShowMenu", "root-menu"},
        { "Root", "Right", "Press", "ShowMenu", "root-menu"},
        { "Root", "Middle", "Press", "ShowMenu", "root-menu"},
index 6295c1800b598d1663921338cceaaee70d5a530f..b5640f243b1599e0880aa4b15cae0371ef3cfafc 100644 (file)
@@ -549,7 +549,8 @@ isbutton(enum ssd_part_type type)
 {
        return type == LAB_SSD_BUTTON_CLOSE ||
               type == LAB_SSD_BUTTON_MAXIMIZE ||
-              type == LAB_SSD_BUTTON_ICONIFY;
+              type == LAB_SSD_BUTTON_ICONIFY ||
+              type == LAB_SSD_BUTTON_WINDOW_MENU;
 }
 
 static void
@@ -602,6 +603,9 @@ render_deco(struct view *view, struct output *output,
                box = ssd_visible_box(view, LAB_SSD_BUTTON_ICONIFY);
                render_icon(output, output_damage, &box,
                        theme->xbm_iconify_active_unpressed);
+               box = ssd_visible_box(view, LAB_SSD_BUTTON_WINDOW_MENU);
+               render_icon(output, output_damage, &box,
+                       theme->xbm_menu_active_unpressed);
        } else {
                box = ssd_visible_box(view, LAB_SSD_BUTTON_CLOSE);
                render_icon(output, output_damage, &box,
@@ -612,6 +616,9 @@ render_deco(struct view *view, struct output *output,
                box = ssd_visible_box(view, LAB_SSD_BUTTON_ICONIFY);
                render_icon(output, output_damage, &box,
                        theme->xbm_iconify_inactive_unpressed);
+               box = ssd_visible_box(view, LAB_SSD_BUTTON_WINDOW_MENU);
+               render_icon(output, output_damage, &box,
+                       theme->xbm_menu_inactive_unpressed);
        }
 }
 
index 533e81cc881aec18a14f8ff75c7edfd1821c5ea7..f4f36083e1bec47c418f6058b9532a05017b1f0a 100644 (file)
--- a/src/ssd.c
+++ b/src/ssd.c
@@ -40,7 +40,7 @@ ssd_max_extents(struct view *view)
        return box;
 }
 
-#define NR_BUTTONS (3)
+#define NR_BUTTONS (4)
 
 /**
  * ssd_box - the 'full' decoration geometry which includes both visible
@@ -79,6 +79,12 @@ ssd_box(struct view *view, enum ssd_part_type type)
                box.width = button_width;
                box.height = button_height;
                break;
+       case LAB_SSD_BUTTON_WINDOW_MENU:
+               box.x = view->x;
+               box.y = view->y - button_height;
+               box.width = button_width;
+               box.height = button_height;
+               break;
        case LAB_SSD_PART_TITLEBAR:
                box.x = view->x;
                box.y = view->y - theme->title_height;
@@ -86,7 +92,7 @@ ssd_box(struct view *view, enum ssd_part_type type)
                box.height = theme->title_height;
                break;
        case LAB_SSD_PART_TITLE:
-               box.x = view->x + title_x_padding;
+               box.x = view->x + button_width + title_x_padding;
                box.y = view->y - theme->title_height;
                box.width = view->w - title_x_padding * 2 - NR_BUTTONS * button_width;
                box.height = theme->title_height;
@@ -195,6 +201,9 @@ ssd_visible_box(struct view *view, enum ssd_part_type type)
        case LAB_SSD_BUTTON_ICONIFY:
                box = ssd_box(view, type);
                break;
+       case LAB_SSD_BUTTON_WINDOW_MENU:
+               box = ssd_box(view, type);
+               break;
        case LAB_SSD_PART_TITLEBAR:
                box = ssd_box(view, type);
                box.x += theme->title_height;
index 79e8c5355e4fca96449460e4af566f59e8861c82..ec07f9b0df243716f3d276b5081c88c3dc003190 100644 (file)
@@ -104,12 +104,16 @@ theme_builtin(struct theme *theme)
        parse_hexstr("#000000", theme->window_inactive_label_text_color);
        theme->window_label_text_justify = parse_justification("Left");
 
+       parse_hexstr("#000000",
+               theme->window_active_button_menu_unpressed_image_color);
        parse_hexstr("#000000",
                theme->window_active_button_iconify_unpressed_image_color);
        parse_hexstr("#000000",
                theme->window_active_button_max_unpressed_image_color);
        parse_hexstr("#000000",
                theme->window_active_button_close_unpressed_image_color);
+       parse_hexstr("#000000",
+               theme->window_inactive_button_menu_unpressed_image_color);
        parse_hexstr("#000000",
                theme->window_inactive_button_iconify_unpressed_image_color);
        parse_hexstr("#000000",
@@ -192,6 +196,8 @@ entry(struct theme *theme, const char *key, const char *value)
 
        /* universal button */
        if (match(key, "window.active.button.unpressed.image.color")) {
+               parse_hexstr(value,
+                       theme->window_active_button_menu_unpressed_image_color);
                parse_hexstr(value,
                        theme->window_active_button_iconify_unpressed_image_color);
                parse_hexstr(value,
@@ -200,6 +206,8 @@ entry(struct theme *theme, const char *key, const char *value)
                        theme->window_active_button_close_unpressed_image_color);
        }
        if (match(key, "window.inactive.button.unpressed.image.color")) {
+               parse_hexstr(value,
+                       theme->window_inactive_button_menu_unpressed_image_color);
                parse_hexstr(value,
                        theme->window_inactive_button_iconify_unpressed_image_color);
                parse_hexstr(value,
index 63f0ee1ccee4fc039d7a77db85b8ff6ead287905..35a97cfa3df01d254ebdf24f594c4c7f7fe716fb 100644 (file)
 #include "xbm/xbm.h"
 
 /* built-in 6x6 buttons */
-char close_button_normal[] = { 0x33, 0x3f, 0x1e, 0x1e, 0x3f, 0x33 };
+char menu_button_normal[] = { 0x00, 0x18, 0x3c, 0x3c, 0x18, 0x00 };
 char iconify_button_normal[] = { 0x00, 0x00, 0x00, 0x00, 0x3f, 0x3f };
 char max_button_normal[] = { 0x3f, 0x3f, 0x21, 0x21, 0x21, 0x3f };
 char max_button_toggled[] = { 0x3e, 0x22, 0x2f, 0x29, 0x39, 0x0f };
+char close_button_normal[] = { 0x33, 0x3f, 0x1e, 0x1e, 0x3f, 0x33 };
 
 static struct wlr_texture *
 texture_from_pixmap(struct wlr_renderer *renderer, struct pixmap *pixmap)
@@ -87,6 +88,9 @@ out:
 void
 xbm_load(struct theme *theme, struct wlr_renderer *r)
 {
+       parse_set_color(theme->window_active_button_menu_unpressed_image_color);
+       load_button(r, "menu.xbm", &theme->xbm_menu_active_unpressed,
+                   menu_button_normal);
        parse_set_color(theme->window_active_button_iconify_unpressed_image_color);
        load_button(r, "iconify.xbm", &theme->xbm_iconify_active_unpressed,
                    iconify_button_normal);
@@ -97,6 +101,9 @@ xbm_load(struct theme *theme, struct wlr_renderer *r)
        load_button(r, "close.xbm", &theme->xbm_close_active_unpressed,
                    close_button_normal);
 
+       parse_set_color(theme->window_inactive_button_menu_unpressed_image_color);
+       load_button(r, "menu.xbm", &theme->xbm_menu_inactive_unpressed,
+                   menu_button_normal);
        parse_set_color(theme->window_inactive_button_iconify_unpressed_image_color);
        load_button(r, "iconify.xbm", &theme->xbm_iconify_inactive_unpressed,
                    iconify_button_normal);