Compare commits

..
155 Commits
Author SHA1 Message Date
Marco Raber 34302812fe Added vim like keybindings 2021-12-14 16:17:26 +01:00
phillbush 705316fabe Merge pull request #30 from paniash/master
Fixed typo
2021-06-02 11:40:07 -03:00
Ashish Panigrahi 98e801edf7 fix typo 2021-06-02 20:02:31 +05:30
phillbush 6aee410969 STOP CAT ABUSE!!! 2021-04-29 20:09:10 -03:00
phillbush c1d29e79f4 v4.5.5 2021-04-11 11:03:29 -03:00
phillbush d90841035d rm demo.gif 2021-04-11 10:33:22 -03:00
phillbush f5bc660a72 replace image url 2021-04-11 10:32:24 -03:00
phillbush c4d552d669 Merge pull request #29 from TobiasRH/fix-separator-segfault
Fix a segfault if a sub-menu is added to a separator.
2021-04-10 18:49:13 -03:00
Tobias R. Henle 2e7a6bdcf3 Fix: Handle missing (NULL pointer) output for separator. 2021-04-05 21:28:21 +02:00
Tobias R. Henle 78cdb02be6 Fix: Don't allow a separator as root for submenus. 2021-04-05 21:27:48 +02:00
phillbush 60ddf397e3 add support for mouse scrolling (#26) 2021-02-13 20:36:55 -03:00
phillbush 88341d204b fix license, add acknowledgements 2021-01-24 16:00:04 -03:00
phillbush b2a9340acb Merge pull request #25 from kawaiiamber/DESTDIR
Simplify DESTDIR
2021-01-10 21:10:53 +00:00
KawaiiAmber c90d164c0a Simplify DESTDIR 2021-01-10 14:01:51 -07:00
phillbush 06d6acdb5e fixed ESC key 2021-01-09 19:41:16 -03:00
phillbush e14d88b06c fixed missing lines 2021-01-09 19:29:08 -03:00
phillbush 289de21f8e fix missing assignment 2021-01-09 19:25:06 -03:00
phillbush cbf67e5a45 prepare for 4.5.1 2021-01-09 19:16:55 -03:00
phillbush 0129fde447 fix shift key 2021-01-09 19:11:38 -03:00
phillbush 10d457c97e add changelog 2021-01-08 22:30:08 -03:00
phillbush 78fb523f9f remove -t; prepare for mergint into master 2021-01-08 19:01:46 -03:00
phillbush 0783fd073c Merge branch 'master' into type 2021-01-08 18:39:28 -03:00
phillbush 50da9089cf Merge pull request #23 from kawaiiamber/Makefile-standard
Make standard for non-GNU
2021-01-08 21:28:37 +00:00
phillbush 9b9cb802e0 Merge pull request #24 from kawaiiamber/readme
Include Xinerama header dep in README
2021-01-08 21:23:02 +00:00
KawaiiAmber dc1afe9f63 Include Xinerama header dep in README 2021-01-08 11:50:30 -07:00
KawaiiAmber 6f740f74ea Make standard for non-GNU 2021-01-08 07:01:20 -07:00
phillbush 28f784a7a4 add -t 2020-12-31 05:47:06 -03:00
phillbush 8239f1f155 add normalizekeysym()
Also, when no item matches the typed string and a new key is pressed,
rub out the memory first and then include the character corresponding
to the typed key.
2020-12-31 05:35:15 -03:00
phillbush 693735f7eb make tab cycle through matched items 2020-12-31 04:58:05 -03:00
phillbush 7bdb3b0bf8 rub out text when no item matches it 2020-12-29 22:45:49 -03:00
phillbush b33886d7a2 add type-to-select support 2020-12-29 22:26:48 -03:00
phillbush 6bbc0e45ea move actions to end of main loop 2020-12-29 19:40:17 -03:00
phillbush f472bfacd9 prepare stuff for type-to-select 2020-12-29 19:22:50 -03:00
phillbush 6abae763c6 parse resources before command-line options 2020-12-29 18:56:50 -03:00
phillbush 9cfea60e8e Merge pull request #18 from kawaiiamber/config.mk
Formatting
2020-12-19 13:33:42 +00:00
KawaiiAmber 0c987c691c Formatting 2020-12-19 00:54:38 -07:00
phillbush 27c03246ca add alignment 2020-12-15 13:14:57 -03:00
phillbush 1146fd8114 add -r option 2020-11-09 16:46:25 -03:00
phillbush ef667106e9 fix #16 2020-10-18 12:17:46 -03:00
phillbush 1ca0d0d6dc make makefile portable 2020-10-06 13:41:49 -03:00
phillbush 1b566a9054 remove typo 2020-09-27 19:06:12 -03:00
phillbush 73a2a23dbd conform code to my new coding style 2020-09-27 19:01:13 -03:00
phillbush 112e23c3e8 fix comment on parsefonts() 2020-09-22 19:30:31 -03:00
phillbush c2959cf439 add lastitem and adapt code to general code style 2020-09-22 19:18:15 -03:00
phillbush 736d20be06 Merge pull request #14 from Malod219/master
Number key support
2020-09-22 22:12:51 +00:00
RisingThumb 02511d092b Fix loop around for number keys 2020-09-22 22:42:00 +01:00
RisingThumb 2b0484b11c Support for 1-9 numbers to select specific item 2020-09-22 22:31:12 +01:00
phillbush 45115feb15 add reference to new features on the manual 2020-09-17 00:54:35 -03:00
phillbush 7b166488b1 now user can set custom key bindings in config.h 2020-09-16 22:06:12 -03:00
phillbush 006c94ce9c Add support for Home and End keys for moving 2020-09-16 21:48:46 -03:00
phillbush d3c2131250 free stuff earlier, when they're no longer used 2020-09-16 21:04:43 -03:00
phillbush 59a8a95056 NOW IN MIT/X LICENSE 2020-09-13 16:45:22 -03:00
phillbush 883ec17fe2 add XFree(info), simplify README.md 2020-08-23 22:26:23 -03:00
phillbush f66f4c1823 Image loading error now just warns.
Rather than exiting with error.
2020-08-12 20:49:55 -03:00
phillbush ed1650a70f Improving error messages for icon loading 2020-08-12 20:29:33 -03:00
phillbush 70f5db0f88 Improving some error messages 2020-08-12 20:05:09 -03:00
phillbush 8a7bfdf89e cannot → could not 2020-08-12 20:01:05 -03:00
phillbush 70063f16f5 Adding reference to xdg-xmenu, by OliverLew. 2020-08-05 09:30:08 -03:00
phillbush 0b0faa5fc4 Adding xmenu.h 2020-08-01 15:42:34 -03:00
phillbush a48473fd8d adding tests, removing -f (it was too clumsy) 2020-08-01 15:38:26 -03:00
phillbush 6d56f2796c search the system for font containing character 2020-08-01 15:12:57 -03:00
phillbush f8d55995df Adding routine getfontucode() 2020-07-31 19:50:50 -03:00
phillbush 644a15bb2d Adding the -f option 2020-07-31 11:01:53 -03:00
phillbush 7539247be3 Freeing fonts 2020-07-31 10:09:26 -03:00
phillbush d2304ecf93 using BETWEEN macro, and fixing fallback position 2020-07-31 09:22:13 -03:00
phillbush b1cf3ebd74 fixing comment 2020-07-30 22:07:13 -03:00
phillbush 7832d2cfa9 Simplifying manual, removing unused elements 2020-07-30 22:03:54 -03:00
phillbush 8e799bb47d Fixing y position of child menus. 2020-07-30 17:24:58 -03:00
phillbush a2ff706d6f No more needed to use -i to disable icon padding
Now xmenu detects if a menu has an icon, and if it doesn't have, the
menu will not have the gaps fgor icons, making the -i flag unecessary
to disable the padding.   The -i option is still necessary, however,
to speed up xmenu loading, since it disables imlib2 initialization
routines.
2020-07-30 17:04:04 -03:00
phillbush c15958bd96 Fixing position in some wms when using -w 2020-07-30 16:51:29 -03:00
phillbush b6cf4847ce removing variables config.screen* 2020-07-30 00:25:55 -03:00
phillbush 64240f40ee changing the computation of the text y position 2020-07-29 22:59:25 -03:00
phillbush 0bb241472b Adding reference to the wiki on README 2020-07-29 18:19:47 -03:00
phillbush 486784ca8e Merge pull request #9 from GideonWolfe/master
Reformat README to be nicer looking
2020-07-29 21:17:58 +00:00
phillbush 26cb0bfcf2 Adding config.mk 2020-07-29 18:09:06 -03:00
phillbush 237da9824c Adding Xinerama support 2020-07-29 17:55:20 -03:00
Gideon Wolfe b3419d4735 Update README.md 2020-07-29 13:16:59 -07:00
Gideon Wolfe 47f3bbaf3c Update README.md 2020-07-29 13:09:10 -07:00
Gideon Wolfe c16406852b Update README.md
little update to get people interested
2020-07-29 13:04:37 -07:00
Gideon Wolfe ba97c0d2ba Update and rename README to README.md 2020-07-29 13:03:09 -07:00
phillbush 3d8536642e Drawing menus on demand, reordering functions 2020-07-29 11:37:38 -03:00
phillbush 15362de42b computing textwidth with the function drawtext 2020-07-29 01:19:45 -03:00
phillbush cdeaefaaa2 Added support for fallback fonts.
Also changed license.
2020-07-29 00:51:08 -03:00
phillbush 675a2008a6 Fixing #7
Redrawing an icon every time the cursor moves between items costs a lot
of time.  So now each icon is drawn once, and s copied when needed.
2020-07-28 14:51:12 -03:00
phillbush ced6b0f73e Removing debug printf 2020-07-23 17:39:33 -03:00
phillbush 05cfe1a0da Adding the -p option.
Changing config.cursx and config.cursy to config.posx and config.posy.
Adding the parseposition() function.
2020-07-23 17:37:28 -03:00
phillbush 71b4db9241 added the -i option
Widths and x positions no more depend on item->h.
2020-07-15 22:57:59 -03:00
phillbush 92e7609bcd Referencing the gap X resource in the manual 2020-06-29 12:34:34 -03:00
phillbush eecf9b25ff Adding X resource for gaps 2020-06-29 12:32:02 -03:00
phillbush a3a7383740 Moving XSetWMProtocols to setupmenu() 2020-06-29 12:25:59 -03:00
phillbush 8902c43b92 Adding gaps support and more.
• Adding support for gaps (#3)
• Adding more comments and categorizing function declarations.
• Adding support for EWMH properties (xmenu look is now consistent
  in some window compositors).
• Changing how configuration is done (now all configuration belongs
  to the config structure).
2020-06-29 12:20:37 -03:00
phillbush 585e3de1a3 Squashed commit of the following:
commit b0f37c9fdb2deb09fa7af59067d57420bfaa87ea
Author: phillbush <phillbush@cock.li>
Date:   Mon Jun 29 09:58:36 2020 -0300

    Compile time error fixes

commit e6bf27768ff2ceeafb4713e90df6a35fa2294d1b
Author: Karl Martin <karlmartin895@gmail.com>
Date:   Sun Jun 28 23:08:02 2020 -0400

    v1.01

    add: user can set gap width prefs

commit 0cca2163092b9aed2823ca65b02959440ef24f41
Author: Karl Martin <karlmartin895@gmail.com>
Date:   Sun Jun 28 23:04:10 2020 -0400

    INIT: func addition + error fix

    hack + prefs: extra x,y padding for initial menu
    add: x padding for child menus
    fix: 2x compile time errors
2020-06-29 10:01:54 -03:00
phillbush d94ef32515 Adding reference to xclickroot. 2020-06-24 14:24:22 -03:00
phillbush 84de136091 Merge pull request #2 from emanuele6/patch-1
Build: remove slashes after DESTDIR from commands in uninstall target
2020-06-20 18:49:48 +00:00
Emanuele Torre 9859c2a555 Build: remove slashes after DESTDIR from commands in uninstall target 2020-06-16 18:12:09 +02:00
phillbush 685ca30d8d Configuring height directly by setting the height.
Rather than setting the padding.
2020-06-12 11:37:13 -03:00
phillbush 5a83c7dce2 Typo 2020-06-05 18:36:21 -03:00
phillbush d584fba626 Updating config.mk, manual and README 2020-06-01 11:24:24 -03:00
phillbush 721517254c Updating README 2020-05-31 22:32:26 -03:00
phillbush 3bec05ea77 Readding the -w option 2020-05-31 22:26:33 -03:00
phillbush 7b867888e0 Adding some icons samples 2020-05-31 20:32:05 -03:00
phillbush 33376f5420 Merging icons branch on master branch.
And adjusting the geometry of items.
2020-05-31 20:29:46 -03:00
phillbush f8ffe0b2e4 Renaming routine and spliting it into subroutines
Renaming calcmenu() to setupmenu() and shrinking it by calling two
new functions: setupmenusize() and setupmenupos().
2020-05-30 18:56:59 -03:00
phillbush 0dfd6fa00e Removing patches, using branches approach 2020-05-30 11:52:47 -03:00
phillbush a966c86682 Updating README to mention patches 2020-05-30 11:07:25 -03:00
phillbush 0704f950ad Adding icons patch 2020-05-30 11:04:03 -03:00
phillbush 207c3312d5 typo 2020-05-30 09:45:11 -03:00
phillbush 738ed9d5f5 comment 2020-05-30 07:31:46 -03:00
phillbush beae67a6a7 Making geom local to main().
I moved all the geometry related code to calcmenu().

The pro is that geom is now a local variable rather than global;
and that all geometry-related code is now in one place.

The con is that it weakens performance a little bit since some
variables, such as the border, have to be reset after the window
creation.
2020-05-30 05:45:28 -03:00
phillbush ddeb6e1ef2 Mentioning dmenu.gif in the README §Files section 2020-05-30 00:05:47 -03:00
phillbush ddb15acfde Fixing segfault in case of empty input 2020-05-29 23:55:37 -03:00
phillbush a5ddd2cd22 Simplifying parsing and data structure building
• Parsing of stdin was simplified by using conventional stdlib functions
  rather than parsing the stdin byte-by-byte.
• Splited parsing of textual input and building of internal data
  structures into two different functions.
2020-05-29 23:48:49 -03:00
phillbush 15dfafdfb1 Saving users memory.
When the item->label and item->output are the same, XMenu now only
strdup() the item->label and make item->output equal to item->label.
This saves memory when the user do not write a output specification
in the input.
2020-05-29 22:52:55 -03:00
phillbush 4f898cc3af Adding the demo gif to the repository. 2020-05-29 22:41:52 -03:00
phillbush 6b5123e793 Updated manpage, removed unused variables, etc.
• Updated manual page (removing mention to the removed -w option).
• Removed unused variables (dc.d).
• Freeing item's label and output.
2020-05-29 22:37:55 -03:00
phillbush ec4ed1ac1e Fixing calculation of menu position.
The position didn't take into account the menu borders.
Also, freeing allocated menus and items.
2020-05-27 21:43:10 -03:00
phillbush 95e47cc023 Updating install commands in Makefile 2020-05-27 20:57:38 -03:00
phillbush cdc4d51fee removed a goto 2020-05-27 15:10:53 -03:00
phillbush c6d9174ec2 Reordering stuff, removing unused variables 2020-05-27 14:34:55 -03:00
phillbush 257e42cc23 Getting rid of some global variables
They are local now.
2020-05-27 13:40:11 -03:00
phillbush 571d99e165 Improved README 2020-05-27 11:19:49 -03:00
phillbush 0c1a78642c Separated getmenuitem into two functions 2020-05-27 00:15:10 -03:00
phillbush fd530f3f68 Refactored code, changed resources and config.h 2020-05-26 18:43:45 -03:00
phillbush 2744390027 Removed the -w option (it was too buggy) 2020-05-23 22:06:21 -03:00
phillbush 21a9aaecb1 Creating windowed branch for -w
I will remove the -w (windowed) option from the master branch, for it
raises more problems than solutions, I will maintain it in the windowed
branch.
2020-05-23 20:41:09 -03:00
phillbush 8455c36913 Menu windows are recalculated with -w
Every time a window is opened, its position is recalculated with
recalcmenu().
2020-05-19 13:41:11 -03:00
phillbush 88afe438b1 trapping sighup in xmenu.sh 2020-05-19 10:22:24 -03:00
phillbush 85003546a2 Make xmenu wait for another process to ungrab
Xmenu didn't wait for another process to ungrab the poiter or keyboard,
ending up in erroneous behavior.  Now it waits.
2020-05-19 09:17:06 -03:00
phillbush c49dad285c Simplifying the example script. 2020-05-19 06:22:00 -03:00
phillbush c0cff00dc8 Referring to the new changes in the manpage. 2020-05-19 05:56:06 -03:00
phillbush d2435fcd5f Correctly setting WM_CLASS. 2020-05-19 05:51:21 -03:00
phillbush 813ade537f The script now supposes that xmenu is installed 2020-05-19 04:49:33 -03:00
phillbush 4e219dd8f3 simple tweak on xmenu.sh
The script now runs in the background.
2020-05-19 04:47:35 -03:00
phillbush 465d07dbe9 Fixed order of function calls
You must grab the keyboard after reading the input.
2020-05-18 23:05:14 -03:00
phillbush 697f63c474 Fixed makefile 2020-05-18 23:00:29 -03:00
phillbush 9c891da8b3 Fixed man page installation. 2020-05-18 22:56:53 -03:00
phillbush dbeb994054 Added xft support (smooth fonts) 2020-05-18 22:27:56 -03:00
phillbush 858338d978 xmenu now can be operated by keyboard 2020-05-17 17:01:46 -03:00
phillbush 54931d1465 make install now install the manpage 2020-05-17 01:28:04 -03:00
phillbush f644b8bc22 xmenu now supports x resources 2020-05-17 01:22:21 -03:00
phillbush dddba407f4 config.h 2020-05-17 00:12:59 -03:00
phillbush 08f165897c Xmenu now has a man page. 2020-05-17 00:08:23 -03:00
phillbush 873c080ceb The README file referred to dwm 2020-05-16 18:01:14 -03:00
phillbush 12af0e7136 better-looking color scheme
I just stole the colors from firefox's context menu.
2020-05-16 15:08:25 -03:00
phillbush d8a7caf2e3 improved algorithm for mapping/unmapping
In previous versions, all the previous current visible menus are
unmapped and the new currently visible menus are mapped when the
current visible menu changed. Now, using an algorithm that finds
the lowest common ancestor between current and current_new menus,
only the necessary menus are remapped on the display.
2020-05-16 14:43:07 -03:00
phillbush d888f2cae4 improved algorithm that draw menus 2020-05-16 02:14:29 -03:00
phillbush f70a900c8e NOW IN PUBLIC DOMAIN! 2020-05-16 01:28:57 -03:00
phillbush f158328539 width is now calculated from the font 2020-05-16 01:24:43 -03:00
phillbush 2b6968f911 A better triangle
Now the triangle indicating submenus is smaller and better looking.
2020-05-16 00:58:32 -03:00
phillbush f15fc33987 using pixmaps
Using pixmaps rather than drawing directly on windows.
2020-05-16 00:43:59 -03:00
phillbush c58c645637 xmenu now works on tile window managers
The windows now set size hints for maximum and minimum size.
2020-05-15 23:10:16 -03:00
phillbush 09c13122cc Test 2020-05-15 23:08:05 -03:00
phillbush 7fbd1c5ed0 Added separators
Now lines without labels in the input generate a menu separator.
2020-05-15 22:51:26 -03:00
phillbush a80fee227a item->y is now relative to menu, not to root 2020-05-15 22:25:05 -03:00
phillbush a77326901f Initial commit 2020-05-15 19:02:23 -03:00
12 changed files with 2333 additions and 7 deletions
+167
View File
@@ -0,0 +1,167 @@
CHANGELOG
4.5.5 (2021-04-11)
• Added support for mouse scrolling (#26).
• Changed Makefile; simplify ${DESTDIR} (#25).
• Changed README; removed demo.gif.
• Fixed LICENSE.
• Fixed segfault if a sub-menu is added to a separator (#29).
4.5.4 (2021-01-09)
• Fixed ESC key.
4.5.3 (2021-01-09)
• Fixed missing lines in xmenu.c.
4.5.2 (2021-01-09)
• Fixed missing line in xmenu.c.
4.5.1 (2021-01-09)
• Fixed SHIFT key; it cleared the selection, now it doesn't.
4.5.0 (2021-01-08).
• Added type-to-select feature (#21).
• Added support for setting the text alignment.
• Added -r option to disable right mouse button (#17).
• Added CHANGELOG.
• Changed order of parsing of options.
• Fixed config.mk formatting (#18, #23).
• Fixed README's list of header dependencies (#24).
4.4.1 (2020-10-18).
• Fixed Makefile by removing -D flag of install(1) and making it portable.
• Fixed menu placement when pointer is at the very top of the menu (#16).
4.4.0 (2020-09-27).
• Added support for custom key bindings in config.h.
• Added support for 1 to 9 keys for moving (#14).
• Added support for Home and End keys for moving.
• Fixed code to free stuff earlier, when they're no longer used.
4.3.2 (2020-09-13).
• Changed license.
• Fixed initmonitor() routine to free unused data.
4.3.1 (2020-08-12).
• Added warning messages for unsuccessful icon loading.
• Changed wording in some error messages.
• Changed README to add reference to xdg-xmenu, by OliverLew.
4.3.0 (2020-08-01).
• Added ability to search the system for font containing character.
• Changed drawtext() routine (split part of it into getfontucode()).
• Fixed getfontucode() by adding sanity check tests.
• Removed the -f option.
4.2.0 (2020-07-31).
• Added the -f option.
• Changed xmenu.c to use BETWEEN macro.
• Fixed fallback position.
• Fixed manpage; simplifying description of -i option.
• Fixed xmenu.h; removed unused elements in struct Item.
• Fixed cleanup function to free fonts.
4.1.4 (2020-07-30).
• Added detection of icons in menus.
• Fixed y position of child menus.
• Fixed placement in some window managers when using -w.
• Fixed README to add reference to added features.
4.1.3 (2020-07-30).
• Fixed xmenu.c and xmenu.h: removed redundant variables.
4.1.2 (2020-07-29).
• Fixed computation of the text y position.
4.1.1 (2020-07-29).
• Changed README to README.md (#9).
• Fixed config.mk to load -lXinerama.
4.1.0 (2020-07-29).
• Added Xinerama support (#8).
4.0.2 (2020-07-29).
• Fixed menu drawing; menus are now drawed on demand.
4.0.1 (2020-07-29).
• Fixed calculation of text width.
4.0.0 (2020-07-29).
• Added support for fallback fonts.
• Changed license.
3.4.1 (2020-07-28).
• Fixed performance issue with many icons (#7).
3.4.0 (2020-07-23).
• Added the -p option (to set the root menu position).
3.3.0 (2020-07-15).
• Added the -i option (to disable icons).
• Changed code for computing widths and x position.
3.2.1 (2020-06-29).
• Fixed manpage; add reference to added features in the manual.
3.2.0 (2020-06-29).
• Added support for EWMH properties.
• Added support for gaps between menus (#3).
• Changed README to add reference to xclickroot(1).
• Changed how configuration is done; added a config structure.
• Fixed missing #include.
• Fixed missing type cast.
3.1.1 (2020-06-20).
• Changed how height is calculated; now it's set directly.
• Fix Makefile; removed slashes after DESTDIR (#2).
3.1.0 (2020-06-05).
• Fixed several typos and mismatches between code, manual and README.
3.0.0 (2020-05-31).
• Added support for icons.
• Added some icons samples (in ./icons/).
• Added demo gif.
• Added the -w option (again).
• Changed Makefile; using -D option of install(1).
• Changed input parsing to use stdlib functions rather than get byte-by-byte.
• Changed xmenu.c; making global variables local.
• Changed calcmenu() routine (split into three routines).
• Fixed segfault in case of empty input.
• Fixed calls to strdup(3); called twice only when label and output differs.
• Fixed menu position calculation (it didn't take borders into account).
• Fixed manpage; updated to new features.
• Fixed xmenu.c; removed unused code.
• Fixed cleanup routine; freeing allocated stuff.
2.0.0 (2020-05-27).
• Changed xmenu.c; making global variables local.
• Changed README; including more information.
• Changed getmenuitem() routine (split into getmenu() and getitem()).
• Changed drawing routines in xmenu.c (drawseparator() and drawitem()).
• Fixed xmenu.c; removed unused code.
• Removed the -w option.
1.0.0 (2020-05-19).
• Added keyboard navigation.
• Added manpage.
• Added support for X resources.
• Added XFT support (antialiased fonts).
• Added setting of WM_CLASS property.
• Added recalcmenu() to recalculate menu position when -w is used.
• Added support for WM_DELETE_WINDOW property (ability to close window).
• Changed xmenu.sh script to pipe into sh(1).
• Changed color scheme (stolen from firefox's context menu).
• Changed algorithm for remapping menus (find lowest common ancestor menu).
• Changed computing of menu width to be based on font.
• Changed triangle size; now it's smaller.
• Changed xmenu.sh; it now supposes that xmenu is installed.
• Fixed README; it was a copy of dwm's.
• Fixed Makefile; make install didn't install the manpage.
• Fixed pointer and keyboard grabbing race condition.
• Fixed order of function calls (grab keyboard after reading input).
0.5.0 (2020-05-16).
• Added menu separators (lines without labels in the input).
• Added double buffering, rather than drawing directly on windows.
• Added -w option.
+33 -5
View File
@@ -1,9 +1,37 @@
MIT License MIT/X Consortium License
Copyright (c) <year> <copyright holders> © 2020 Phillip Bushee <phillbush@cock.li>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: thingmenu:
© 2011 Christoph Lohmann <20h@r-36.net>
© 2011 Stephen Paul Weber <singpolyma@singpolyma.net>
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. dmenu:
© 2006-2019 Anselm R Garbe <anselm@garbe.ca>
© 2006-2008 Sander van Dijk <a.h.vandijk@gmail.com>
© 2006-2007 Michał Janeczek <janeczek@gmail.com>
© 2007 Kris Maglione <jg@suckless.org>
© 2009 Gottox <gottox@s01.de>
© 2009 Markus Schnalke <meillo@marmaro.de>
© 2009 Evan Gates <evan.gates@gmail.com>
© 2010-2012 Connor Lane Smith <cls@lubutu.com>
© 2014-2020 Hiltjo Posthuma <hiltjo@codemadness.org>
© 2015-2019 Quentin Rameau <quinq@fifth.space>
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
+32
View File
@@ -0,0 +1,32 @@
include config.mk
bindir = ${DESTDIR}${PREFIX}
mandir = ${DESTDIR}${MANPREFIX}
SRCS = ${PROG}.c
OBJS = ${SRCS:.c=.o}
all: ${PROG}
${PROG}: ${OBJS}
${CC} -o $@ ${OBJS} ${LDFLAGS}
${OBJS}: config.h ${PROG}.h
.c.o:
${CC} ${CFLAGS} -c $<
clean:
-rm ${OBJS} ${PROG}
install: all
mkdir -p ${bindir}/bin
install -m 755 ${PROG} ${bindir}/bin/${PROG}
mkdir -p ${mandir}/man1
install -m 644 ${PROG}.1 ${mandir}/man1/${PROG}.1
uninstall:
rm -f ${bindir}/bin/${PROG}
rm -f ${mandir}/man1/${PROG}.1
.PHONY: all clean install uninstall
+87 -2
View File
@@ -1,3 +1,88 @@
# xmenu # XMenu
wm-agnostic, X11 menu <p align="center">
<img src="https://user-images.githubusercontent.com/63266536/114306062-ffb67000-9ab0-11eb-9a10-be30eadc68b4.gif", title="demo"/>
</p>
XMenu is a menu utility for X.
XMenu receives a menu specification in stdin, shows a menu for the user
to select one of the options, and outputs the option selected to stdout.
XMenu can be controlled both via mouse and via keyboard.
In order to generate a menu of applications based on .desktop entries,
as specified by XDG, checkout [xdg-xmenu](https://github.com/OliverLew/xdg-xmenu)
by [OliverLew](https://github.com/OliverLew).
Check out my other project, [xclickroot](https://github.com/phillbush/xclickroot) for an application that can
spawn xmenu by right clicking on the root window (i.e. on the desktop).
## Features
XMenu comes with the following features:
* XMenu reads something in and prints something out, the UNIX way.
* Submenus (some menu entries can spawn another menu).
* Separators (menu entries can be separated by a line).
* Icons (menu entries can be preceded by an icon image).
* X resources support (you don't need to recompile xmenu for configuring it).
* Multi-head (xmenu supports multiple monitors by using Xinerama).
* Type-to-select (you can select an item by typing part of its name).
## Files
The files are:
* `./README`: This file.
* `./Makefile`: The makefile.
* `./config.h`: The hardcoded default configuration for XMenu.
* `./config.mk`: The setup for the makefile.
* `./demo.gif`: A gif demonstrating how XMenu works.
* `./xmenu.1`: The manual file (man page) for XMenu.
* `./xmenu.c`: The source code of XMenu.
* `./xmenu.sh`: A sample script illustrating how to use XMenu.
* `./icons/`: Icons for the sample script
## Installation
First, edit `./config.mk` to match your local setup.
In order to build XMenu you need the `Imlib2`, `Xlib`, `Xinerama` and `Xft` header files.
The default configuration for XMenu is specified in the file `config.h`,
you can edit it, but most configuration can be changed at runtime via
X resources. Enter the following command to build XMenu. This command
creates the binary file `./xmenu`.
make
By default, XMenu is installed into the `/usr/local` prefix. Enter the
following command to install XMenu (if necessary as root). This command
installs the binary file `./xmenu` into the `${PREFIX}/bin/` directory, and
the manual file `./xmenu.1` into `${MANPREFIX}/man1/` directory.
make install
## Running XMenu
XMenu receives as input a menu specification where each line is a menu
entry. Each line can be indented with tabs to represent nested menus.
Each line is made out of a label and a command separated by any number
of tabs. Lines without labels are menu separators.
See the script `./xmenu.sh` for an example of how to use XMenu to draw a
simple menu with submenus and separators. The file `./demo.gif` shows how
the menu generated by that script looks like.
Read the [manual](https://github.com/phillbush/xmenu/wiki) for more information on running XMenu.
## Acknowledgements
* [thingmenu](https://github.com/singpolyma/thingmenu) for being the base
for xmenu's code. However, xmenu evolved enough that it no longer resembles
thingmenu at all.
* [dmenu](https://tools.suckless.org/dmenu/) for inspiring the stdin-to-stdout
interface, and being base for drawing routines and input method code.
+61
View File
@@ -0,0 +1,61 @@
static struct Config config = {
/* font, separate different fonts with comma */
.font = "monospace:size=9,DejaVuSansMono:size=9",
/* colors */
.background_color = "#FFFFFF",
.foreground_color = "#2E3436",
.selbackground_color = "#3584E4",
.selforeground_color = "#FFFFFF",
.separator_color = "#CDC7C2",
.border_color = "#E6E6E6",
/* sizes in pixels */
.width_pixels = 130, /* minimum width of a menu */
.height_pixels = 25, /* height of a single menu item */
.border_pixels = 1, /* menu border */
.separator_pixels = 3, /* space around separator */
.gap_pixels = 0, /* gap between menus */
/* text alignment, set to LeftAlignment, CenterAlignment or RightAlignment */
.alignment = LeftAlignment,
/*
* The variables below cannot be set by X resources.
* Their values must be less than .height_pixels.
*/
/* geometry of the right-pointing isoceles triangle for submenus */
.triangle_width = 3,
.triangle_height = 7,
/* the icon size is equal to .height_pixels - .iconpadding * 2 */
.iconpadding = 2,
/* area around the icon, the triangle and the separator */
.horzpadding = 8,
};
/*
* KEYBINDINGS
*
* Look at your /usr/include/X11/keysymdef.h (or the equivalent file
* in your system) for a list of key symbol constants, and change the
* macros below accordingly. All key symbol constants begin with the
* prefix XK_.
*
* For example, to use vim-like key bindings, set KEYSYMLEFT to XK_h,
* KEYSYMDOWN to XK_j, KEYSYMUP to XK_k, etc.
*
* Note that the regular keys like ArrowUp, ArrowDown, Tab, Home, etc
* will ALWAYS work, so you do not need to set them.
*
* If you do not want to set a key binding, keep it with the value of
* XK_VoidSymbol
*/
#define KSYMFIRST XK_VoidSymbol /* select first item */
#define KSYMLAST XK_VoidSymbol /* select last item */
#define KSYMUP XK_VoidSymbol /* select previous item */
#define KSYMDOWN XK_VoidSymbol /* select next item */
#define KSYMLEFT XK_VoidSymbol /* close current menu */
#define KSYMRIGHT XK_VoidSymbol /* enter selected item */
+31
View File
@@ -0,0 +1,31 @@
# program name
PROG = xmenu
# paths
PREFIX ?= /usr/local
MANPREFIX ?= ${PREFIX}/share/man
LOCALINC ?= /usr/local/include
LOCALLIB ?= /usr/local/lib
# SHELL variable (mainly for non-GNU make)
SHELL ?= /bin/sh
X11INC ?= /usr/X11R6/include
X11LIB ?= /usr/X11R6/lib
FREETYPEINC ?= /usr/include/freetype2
# OpenBSD (uncomment)
#FREETYPEINC = ${X11INC}/freetype2
# includes and libs
INCS := -I${LOCALINC} -I${X11INC} -I${FREETYPEINC}
LIBS := -L${LOCALLIB} -L${X11LIB} -lfontconfig -lXft -lX11 -lXinerama -lImlib2
# flags
CPPFLAGS :=
CFLAGS := -Wall -Wextra ${INCS} ${CPPFLAGS}
LDFLAGS := ${LIBS}
# compiler and linker
CC = cc
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

+221
View File
@@ -0,0 +1,221 @@
.TH XMENU 1
.SH NAME
xmenu \- menu utility for X
.SH SYNOPSIS
.B xmenu
.RB [ \-irw ]
.RB [ -p
.IR position ]
.RI [ title ]
.SH DESCRIPTION
.B xmenu
is a menu for X,
it reads a list of newline-separated items from stdin,
shows a menu for the user to select one of the items,
and outputs the item selected to stdout.
.PP
The options are as follows:
.TP
.B -i
Disable icons.
This makes xmenu loading faster when not using icons.
.TP
.BI -p " position"
Set the position to spawn xmenu.
Without this option, xmenu spawns next to the cursor.
.I position
is a string of the form
.BR INTxINT[:MONITOR] ,
where the first INT is the x position and the second INT is the y position.
The monitor part between brackets is optional.
.B MONITOR
can be a number from 0 to the number of monitors minus 1;
or it can be a string like
.B current
or
.BR cursor .
If present, the monitor specifies that the position is relative to the upper left corner
of that monitor.
If
.B monitor
is
.B current
or
.BR cursor ,
the monitor to be used is that where the cursor is in.
For example,
.B -p 0x0:cursor
specifies that
.B xmenu
must spawn at the position 0x0 of the monitor where the cursor is in.
And
.B -p 100x500:0
specifies that
.B xmenu
must spawn at the position 100x500 of the monitor 0.
.TP
.B -r
If this option is set, the right mouse button is disabled;
so pressing it will not trigger any menu item.
.TP
.B -w
Asks the window manager to draw a border around the menus.
This option may be buggy in some window managers,
specially tiled ones that do not respect window hints.
.PP
Each item read from stdin has the following format:
.IP
.EX
ITEM := [TABS] [[IMAGE TABS] LABEL [TABS OUTPUT]] NEWLINE
.EE
.PP
That means that each item is composed by
tabs, followed by an optional image specification, followed by tabs
followed by a label, followed by more tabs, followed by an output,
and ended by a newline. Brackets group optional elements.
.IP
The initial tabs indicate the menu hierarchy:
items indented with a tab is shown in a submenu of the preceding item not indented.
An item without initial tabs is a top-level item.
.IP
The image is a string of the form "IMG:/path/to/image.png".
It specifies a image to be shown as icon at the left of the entry.
.IP
The label is the string that will be shown as a item in the menu.
An item without label is considered a separator and is drawn as a thin line in the menu
separating the item above from the item below.
.IP
The output is the string that will be output after selecting the item.
If an item does not have an output, its label is used as its output.
.IP
The newline terminates the item specification.
.PP
If the argument
.I title
is given, the title of the menu window is set to it.
.SH USAGE
.B xmenu
is controlled by the mouse,
but can also be controlled by the keyboard.
Items can be selected using the arrow keys,
Tab (with and without Shift),
Home, End,
Enter and Esc, and 1-9 keys.
Items can also be selected by typing the first several characters in it.
.TP
.BR Home
Select the first item in the menu.
.TP
.BR End
Select the last item in the menu.
.TP
.BR Down
Cycle through the items in the regular direction.
.TP
.BR Tab
Cycle through the items in the regular direction.
When the type\-to\-select feature is active, cycle through matching items instead.
.TP
.BR Up
Cycle through the items in the reverse direction.
.TP
.BR Shift-Tab
Cycle through the items in the reverse direction.
When the type\-to\-select feature is active, cycle through matching items instead.
.TP
.BR Right ", " Enter
Select the highlighted item.
.TP
.B Left
Go to the menu above.
.TP
.B Esc
Go to the menu above or exit xmenu.
.PP
.B xmenu
features the type\-to\-select selecting style,
where typing a string will select the first item matching it.
.PP
Additional key bindings can be set at compile time by changing the
.B config.h
file.
.SH RESOURCES
.B
xmenu
understands the following X resources.
.TP
.B xmenu.font
The font in which the labels should be drawn.
Multiple fonts can be added as fallback fonts;
they must be separated by a comma.
.TP
.B xmenu.background
The background color of non-selected items in the menu.
.TP
.B xmenu.foreground
The color of the label text of non-selected items in the menu.
.TP
.B xmenu.selbackground
The background color of selected items in the menu.
.TP
.B xmenu.selforeground
The color of the label text of selected items in the menu.
.TP
.B xmenu.border
The color of the border around the menu.
.TP
.B xmenu.separator
The color of the separator between items in the menu.
.TP
.B xmenu.gap
The gap, in pixels, between the menus.
.TP
.B xmenu.width
The minimum width, in pixels, of the items in the menu.
.TP
.B xmenu.height
The size in pixels of the height of a single menu item.
.TP
.B xmenu.borderWidth
The size in pixels of the border around the menu.
.TP
.B xmenu.separatorWidth
The size in pixels of the item separator.
.TP
.B xmenu.alignment
If set to
.BR "\(dqleft\(dq" ,
.BR "\(dqcenter\(dq" ,
or
.BR "\(dqright\(dq" ,
text is aligned to the left, center, or right of the menu, respectively.
By default, text is aligned to the left.
.SH EXAMPLES
The following script illustrates the use of
.BR xmenu .
The output is redirected to
.IR sh (1),
creating a command to be run by the shell.
.IP
.EX
#!/bin/sh
xmenu <<EOF | sh &
Applications
IMG:./web.png Web Browser firefox
IMG:./gimp.png Image editor gimp
Terminal (xterm) xterm
Terminal (urxvt) urxvt
Terminal (st) st
Shutdown poweroff
Reboot reboot
EOF
.EE
.PP
For example, by selecting \(lqApplications\(rq, a new menu will appear.
Selecting \(lqWeb Browser\(rq in the new menu opens firefox.
.SH SEE ALSO
.IR dmenu (1),
.IR 9menu (1),
.IR thingmenu (1)
+1578
View File
File diff suppressed because it is too large Load Diff
+110
View File
@@ -0,0 +1,110 @@
#define PROGNAME "xmenu"
/* Actions for the main loop */
#define ACTION_NOP 0
#define ACTION_CLEAR 1<<0 /* clear text */
#define ACTION_SELECT 1<<1 /* select item */
#define ACTION_MAP 1<<2 /* remap menu windows */
#define ACTION_DRAW 1<<3 /* redraw menu windows */
#define ACTION_WARP 1<<4 /* warp the pointer */
/* enum for keyboard menu navigation */
enum { ITEMPREV, ITEMNEXT, ITEMFIRST, ITEMLAST };
/* enum for text alignment */
enum {LeftAlignment, CenterAlignment, RightAlignment};
/* macros */
#define LEN(x) (sizeof (x) / sizeof (x[0]))
#define MAX(x,y) ((x)>(y)?(x):(y))
#define MIN(x,y) ((x)<(y)?(x):(y))
#define BETWEEN(x, a, b) ((a) <= (x) && (x) <= (b))
#define GETNUM(n, s) { \
unsigned long __TMP__; \
if ((__TMP__ = strtoul((s), NULL, 10)) < INT_MAX) \
(n) = __TMP__; \
}
/* color enum */
enum {ColorFG, ColorBG, ColorLast};
/* EWMH atoms */
enum {NetWMName, NetWMWindowType, NetWMWindowTypePopupMenu, NetLast};
/* configuration structure */
struct Config {
/* the values below are set by config.h */
const char *font;
const char *background_color;
const char *foreground_color;
const char *selbackground_color;
const char *selforeground_color;
const char *separator_color;
const char *border_color;
int width_pixels;
int height_pixels;
int border_pixels;
int separator_pixels;
int gap_pixels;
int triangle_width;
int triangle_height;
int iconpadding;
int horzpadding;
int alignment;
/* the values below are set by options */
int monitor;
int posx, posy; /* rootmenu position */
/* the value below is computed by xmenu */
int iconsize;
};
/* draw context structure */
struct DC {
XftColor normal[ColorLast];
XftColor selected[ColorLast];
XftColor border;
XftColor separator;
GC gc;
FcPattern *pattern;
XftFont **fonts;
size_t nfonts;
};
/* menu item structure */
struct Item {
char *label; /* string to be drawed on menu */
char *output; /* string to be outputed when item is clicked */
char *file; /* filename of the icon */
int y; /* item y position relative to menu */
int h; /* item height */
int textw; /* text width */
struct Item *prev; /* previous item */
struct Item *next; /* next item */
struct Menu *submenu; /* submenu spawned by clicking on item */
Drawable sel, unsel; /* pixmap for selected and unselected item */
Imlib_Image icon;
};
/* monitor geometry structure */
struct Monitor {
int x, y, w, h; /* monitor geometry */
};
/* menu structure */
struct Menu {
struct Menu *parent; /* parent menu */
struct Item *caller; /* item that spawned the menu */
struct Item *list; /* list of items contained by the menu */
struct Item *selected; /* item currently selected in the menu */
int x, y, w, h; /* menu geometry */
int hasicon; /* whether the menu has item with icons */
int drawn; /* whether the menu was already drawn */
int maxtextw; /* maximum text width */
unsigned level; /* menu level relative to root */
Window win; /* menu window to map on the screen */
XIC xic; /* input context */
};
Executable
+13
View File
@@ -0,0 +1,13 @@
#!/bin/sh
xmenu <<EOF | sh &
Applications
IMG:./icons/web.png Web Browser firefox
IMG:./icons/gimp.png Image editor gimp
Terminal (xterm) xterm
Terminal (urxvt) urxvt
Terminal (st) st
Shutdown poweroff
Reboot reboot
EOF