Skip to content

Conversation

@Qingwu-Li
Copy link

Hello fellow geeks,
I tring to implemented a built-in clickable menu feature,
Tested with wayland,

@Qingwu-Li Qingwu-Li marked this pull request as ready for review January 22, 2025 07:35
@Qingwu-Li Qingwu-Li force-pushed the add-clickable-menu branch 2 times, most recently from fbc180d to bbf6888 Compare January 23, 2025 02:37
@bynect
Copy link
Contributor

bynect commented Jan 23, 2025

hello. I like your idea and I also wanted to implement the buttons.

I tried your branch and noticed some problems with the text alignment

img-1737672610

I think the best way would be to either specify a maximum amount of buttons allowed (then dmenu is used for extra action) or to wrap the buttons to a newline. squeezing all actions in a single line is impossible when there are a lot after all

@Qingwu-Li Qingwu-Li force-pushed the add-clickable-menu branch 5 times, most recently from 3f14999 to ce35eed Compare February 8, 2025 08:52
@gujie-leica
Copy link

We revised the settings parameter in the built-in menu and added support for a rounded corner menu in the built-in menu two commits ago.

@bynect
Copy link
Contributor

bynect commented Mar 31, 2025

I will try the new changes 👍

@gujie-leica
Copy link

gujie-leica commented Apr 1, 2025

Now we add key navigation inside of notification:

  • left, right, up and down arrow keys select the button (action)
  • enter key executes action
  • add “focus“ when selected, the first key is the default focus key

Tested it in Wayland, hope this makes the built-in menu more user-friendly.

@bynect
Copy link
Contributor

bynect commented May 5, 2025

sorry for the late reply. I found two compilation errors (one in input.c and one in wl_seat.c). They could be easily solved but you should fix them.

As for the code it mostly works but somehow the text did not line up with the button. I think the scale is not taken into account. On the other hand the input and shape draws correctly

@bynect
Copy link
Contributor

bynect commented May 5, 2025

Now we add key navigation inside of notification:

* left, right, up and down arrow keys select the button (action)

* enter key executes action

* add “focus“ when selected, the first key is the default focus key

Tested it in Wayland, hope this makes the built-in menu more user-friendly.

I think splitting the keyword part in a separate pr is better since this one already quite big.

@bynect
Copy link
Contributor

bynect commented May 5, 2025

After this change

                        cairo_move_to(c, round(text_x * scale), round(text_y * scale));

It almost works correctly, with a minor offset to the text.

img-1746477429

@gujie-leica
Copy link

I think splitting the keyword part in a separate pr is better since this one already quite big.

Thank you for your reply. Basically, the drawing and navigation parts are separate, but they share some common changes in input.c. I will update it in the coming days.

@gujie-leica gujie-leica force-pushed the add-clickable-menu branch 3 times, most recently from 1dfa5ab to 22d7661 Compare May 20, 2025 09:46
@codecov-commenter
Copy link

codecov-commenter commented May 20, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 10.97561% with 146 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.94%. Comparing base (fb59a30) to head (d8af273).
⚠️ Report is 13 commits behind head on master.

Files with missing lines Patch % Lines
src/draw.c 13.86% 87 Missing ⚠️
src/menu.c 6.25% 45 Missing ⚠️
src/input.c 0.00% 14 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1436      +/-   ##
==========================================
- Coverage   64.90%   63.94%   -0.96%     
==========================================
  Files          51       51              
  Lines        9024     9181     +157     
  Branches     1048     1086      +38     
==========================================
+ Hits         5857     5871      +14     
- Misses       3167     3310     +143     
Flag Coverage Δ
unittests 63.94% <10.97%> (-0.96%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bynect
Copy link
Contributor

bynect commented Jun 24, 2025

is this ready for review?

@gujie-leica
Copy link

is this ready for review?

Yes, I think so, I just rebase to resolve conflicts. Sorry we're busy recently, didn't reponse in time.

Implement menu structure and related functions,
preparing for clickable menu feature.
Add new menus array to preserve current actions.

Signed-off-by: LI Qingwu <Qing-wu.Li@leica-geosystems.com.cn>
Introduce built-in menu settings in dunstrc.
Add corresponding settings in settings.h.
Update settings_data.h with new menu-related options.
Preparing for built-in clickable menu.

Signed-off-by: LI Qingwu <Qing-wu.Li@leica-geosystems.com.cn>
Qingwu-Li and others added 6 commits August 1, 2025 11:35
Add menu button drawing function.
Update layout calculations for menu height.
Integrate menu rendering into notification display.

Signed-off-by: LI Qingwu <Qing-wu.Li@leica-geosystems.com.cn>
Add function to handle built-in menu clicks.
Trigger action invocation on menu button click.

Signed-off-by: LI Qingwu <Qing-wu.Li@leica-geosystems.com.cn>
Add menu_free_array call in notification_invalidate_actions,
ensure proper cleanup of menu resources when invalidating actions

Signed-off-by: LI Qingwu <Qing-wu.Li@leica-geosystems.com.cn>
- Revise fixed value with settings.width.max in built-in menu.
- Revise 'h_padding' parameter to align with the offical definition
ub built-in menu.

Signed-off-by: gujie <jie.gu@leica-geosystems.com.cn>
Signed-off-by: gujie <jie.gu@leica-geosystems.com.cn>
Signed-off-by: gujie <jie.gu@leica-geosystems.com.cn>
@bynect
Copy link
Contributor

bynect commented Aug 24, 2025

hello I finally tested it properly. codewise it seems ready to merge.
I would like to add some considerations:

  • I'm not sure I would enable the menu by default since it is a new feature and it would change behavior
  • When the menu is active the old dmenu way of doing actions is still active. probably this is right, but we might consider disabling it when there are few actions
  • for consistency I would probably rename built_in_menu to enable_menu or button_menu

@bynect
Copy link
Contributor

bynect commented Aug 24, 2025

also I think that the way the background can be improved. instead of having menu_frame_fill
something like separator_color can be used (which can be either frame or a color).
personally I would also add a way to change text color inside the menu. but that's something I can add myself.

@bynect
Copy link
Contributor

bynect commented Aug 24, 2025

let me know what do you think @Qingwu-Li

@bynect
Copy link
Contributor

bynect commented Aug 24, 2025

img-1756027602

long action names should be ellipsized or truncated to avoid this

img-1756027874

a big number of items is handled correctly 👍🏻
but maybe a limit to the number of button should be added to keep in mind height limitation of the notification
so the excess buttons should be instead handled by dmenu

@Qingwu-Li
Copy link
Author

let me know what do you think @Qingwu-Li

I will have a look on it!

Copy link
Member

@fwsmit fwsmit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some suggestions that could improve the code, avoiding issues in the future. Other than that it looks good

if (!label) {
continue;
}
int text_width = strlen(label) * fontsize;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This calculation assumes the font is monospace. Do we know this is the case for the button font? This assumption can be avoided by first rendering the font and asking pango about the width. That would also handle unicode characters better


return NULL;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now the new code in menu.c is not integrated with the old code. This could lead to confusion with other similar functions in this file. I would suggest to either

  1. create a separate dmenu.c for all dmenu stuff and renaming those functions to reflect the fact that there are multiple kinds of menu's
    or 2. Merge some of the new functions with old ones and rename the other existing functions to avoid confusion.

@fwsmit
Copy link
Member

fwsmit commented Oct 7, 2025

Also, could you add some tests, for example for calculate_menu_height

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants