New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic top-level menus #221

Closed
joewing opened this Issue Sep 3, 2015 · 14 comments

Comments

Projects
None yet
3 participants
@joewing
Owner

joewing commented Sep 3, 2015

Currently it is only possible to have dynamic menus as members of a menu. It would be nice to have RootMenu be a dynamic menu. See issue #203.

@joewing joewing added the enhancement label Sep 3, 2015

@Israel-D

This comment has been minimized.

Show comment
Hide comment
@Israel-D

Israel-D Sep 3, 2015

Contributor

If include could be dynamic this could solve the issue as well. simply triggering the equivalent of jwm -reload each time the menu is access would be sufficient to solve this.
<Include dynamic=true>exec:my-menu</Include>
If this is a more simple method of addressing this, I think it would be great

Contributor

Israel-D commented Sep 3, 2015

If include could be dynamic this could solve the issue as well. simply triggering the equivalent of jwm -reload each time the menu is access would be sufficient to solve this.
<Include dynamic=true>exec:my-menu</Include>
If this is a more simple method of addressing this, I think it would be great

@joewing

This comment has been minimized.

Show comment
Hide comment
@joewing

joewing Sep 3, 2015

Owner

I don't really know what it would mean for "Include" to by dynamic. How would JWM know when to re-read the include? Dynamic menus are possible since JWM reloads them each time they are accessed.

Owner

joewing commented Sep 3, 2015

I don't really know what it would mean for "Include" to by dynamic. How would JWM know when to re-read the include? Dynamic menus are possible since JWM reloads them each time they are accessed.

@Israel-D

This comment has been minimized.

Show comment
Hide comment
@Israel-D

Israel-D Jun 9, 2016

Contributor

Hi @joewing
I forgot to reply to this...

<Include dynamic=true>exec:my-menu</Include>

Basically Include shows a top level menu
Dynamic creates things each time, but is a sub menu.
So using Include dynamic=true was simply to express this.
I suppose something like

<Dynamic level="root">exec:jwm-menu</Dynamic>

Would be better, and more clear.
default could be submenu, as it is now.

Contributor

Israel-D commented Jun 9, 2016

Hi @joewing
I forgot to reply to this...

<Include dynamic=true>exec:my-menu</Include>

Basically Include shows a top level menu
Dynamic creates things each time, but is a sub menu.
So using Include dynamic=true was simply to express this.
I suppose something like

<Dynamic level="root">exec:jwm-menu</Dynamic>

Would be better, and more clear.
default could be submenu, as it is now.

@Israel-D

This comment has been minimized.

Show comment
Hide comment
@Israel-D

Israel-D Jan 25, 2017

Contributor

@joewing @roandbox
I really like this idea, however I have some serious issues when using it.

  • I cannot select items with a mouse (keyboard navigation works) like in a normal menu (clicking on an item often works, but not in every circumstance)
  • if I click outside the menu it does not disappear and JWM is forever unresponsive
Contributor

Israel-D commented Jan 25, 2017

@joewing @roandbox
I really like this idea, however I have some serious issues when using it.

  • I cannot select items with a mouse (keyboard navigation works) like in a normal menu (clicking on an item often works, but not in every circumstance)
  • if I click outside the menu it does not disappear and JWM is forever unresponsive
@rdnvndr

This comment has been minimized.

Show comment
Hide comment
@rdnvndr

rdnvndr Jan 25, 2017

Contributor

Please write a fragment of the setting file for dynamic menu

Contributor

rdnvndr commented Jan 25, 2017

Please write a fragment of the setting file for dynamic menu

@Israel-D

This comment has been minimized.

Show comment
Hide comment
@Israel-D

Israel-D Jan 26, 2017

Contributor
<RootMenu onroot="7" dynamic="exec:jwm-places||jwm-places-bash" />

Does your testing allow choosing items via mouse, or clicking outside the menu to close it?
The code for the menu is here:
https://github.com/Israel-/jwm-menus

Contributor

Israel-D commented Jan 26, 2017

<RootMenu onroot="7" dynamic="exec:jwm-places||jwm-places-bash" />

Does your testing allow choosing items via mouse, or clicking outside the menu to close it?
The code for the menu is here:
https://github.com/Israel-/jwm-menus

@Israel-D

This comment has been minimized.

Show comment
Hide comment
@Israel-D

Israel-D Jan 26, 2017

Contributor

@joewing I have been hacking around in parse.c and got the menu to act normally by changing the very end of: Menu *ParseMenu(const TokenNode *start)

   value = FindAttribute(start->attributes, DYNAMIC_ATTRIBUTE);
   if(value){
      menu->dynamic = CopyString(value);
      menu = ParseDynamicMenu(value);
   }
   else{
      menu->items = NULL;
      ParseMenuItem(start->subnodeHead, menu, NULL);
   }

But I cannot figure out how to make the menu generate new each time dynamically.
By adding the bit of code I did it now shows up allows mouse navigation and does not hang JWM.
What controls when a menu is re-parsed, like with a tag?

Contributor

Israel-D commented Jan 26, 2017

@joewing I have been hacking around in parse.c and got the menu to act normally by changing the very end of: Menu *ParseMenu(const TokenNode *start)

   value = FindAttribute(start->attributes, DYNAMIC_ATTRIBUTE);
   if(value){
      menu->dynamic = CopyString(value);
      menu = ParseDynamicMenu(value);
   }
   else{
      menu->items = NULL;
      ParseMenuItem(start->subnodeHead, menu, NULL);
   }

But I cannot figure out how to make the menu generate new each time dynamically.
By adding the bit of code I did it now shows up allows mouse navigation and does not hang JWM.
What controls when a menu is re-parsed, like with a tag?

@rdnvndr

This comment has been minimized.

Show comment
Hide comment
@rdnvndr

rdnvndr Jan 26, 2017

Contributor

<RootMenu onroot="7" dynamic="exec:jwm-places||jwm-places-bash" />

@Israel- It is works without problems on the last commit of master.

Contributor

rdnvndr commented Jan 26, 2017

<RootMenu onroot="7" dynamic="exec:jwm-places||jwm-places-bash" />

@Israel- It is works without problems on the last commit of master.

@Israel-D

This comment has been minimized.

Show comment
Hide comment
@Israel-D

Israel-D Jan 26, 2017

Contributor

@roandbox I just made a clean clone and install, and I am back to the issue I initially described.
The menu freezes. The mouse cannot navigate it, and if I click outside of it I crash JWM.
My addition (above) makes the menu responsive and accessible to the mouse, but it is no longer dynamic.
I also added the menu in a tag in a separate menu for the desktop... it works fine there.

My initial test was of the latest commit, I for some reason thought you may have pushed a fix.

Contributor

Israel-D commented Jan 26, 2017

@roandbox I just made a clean clone and install, and I am back to the issue I initially described.
The menu freezes. The mouse cannot navigate it, and if I click outside of it I crash JWM.
My addition (above) makes the menu responsive and accessible to the mouse, but it is no longer dynamic.
I also added the menu in a tag in a separate menu for the desktop... it works fine there.

My initial test was of the latest commit, I for some reason thought you may have pushed a fix.

@Israel-D

This comment has been minimized.

Show comment
Hide comment
@Israel-D

Israel-D Jan 26, 2017

Contributor

What part of the code controls when a menu is shown? I know the PatchMenu code does the job to recreate the Dynamic menus, and the window menus, etc... but only for a sub menu.
I have added my hack into a number of places and have not had any significant change to make it always redraw, as well as function.

Contributor

Israel-D commented Jan 26, 2017

What part of the code controls when a menu is shown? I know the PatchMenu code does the job to recreate the Dynamic menus, and the window menus, etc... but only for a sub menu.
I have added my hack into a number of places and have not had any significant change to make it always redraw, as well as function.

@rdnvndr

This comment has been minimized.

Show comment
Hide comment
@rdnvndr

rdnvndr Jan 28, 2017

Contributor

@Israel- Can you attach a core dump for crash of JWM?

Contributor

rdnvndr commented Jan 28, 2017

@Israel- Can you attach a core dump for crash of JWM?

@joewing

This comment has been minimized.

Show comment
Hide comment
@joewing

joewing Jan 29, 2017

Owner

@Israel- I am unable to reproduce this. Is there a minimal, self-contained shell script you can provide that, when used as the dynamic menu, causes the problem? Here's what I'm using:

#!/bin/bash

echo "<JWM>"
echo "<Program label=\"xterm $RANDOM\">xterm</Program>"
echo "<Separator/>A"
echo "<Restart/>"
echo "<Exit/>"
echo "</JWM>"

And in ~.jwmrc:

<RootMenu onroot="1" dynamic="exec:$HOME/genmenu.sh"/>

This works exactly as I would expect, with a different random number each time and I'm able to click or use the keyboard to select items, etc.

As far as the code is concerned, in root.c, there is a function called ShowRootMenu, which handles setting up loading the dynamic menu when needed. There were problems with how this was originally implemented, so are you sure you're using a recent version?

Owner

joewing commented Jan 29, 2017

@Israel- I am unable to reproduce this. Is there a minimal, self-contained shell script you can provide that, when used as the dynamic menu, causes the problem? Here's what I'm using:

#!/bin/bash

echo "<JWM>"
echo "<Program label=\"xterm $RANDOM\">xterm</Program>"
echo "<Separator/>A"
echo "<Restart/>"
echo "<Exit/>"
echo "</JWM>"

And in ~.jwmrc:

<RootMenu onroot="1" dynamic="exec:$HOME/genmenu.sh"/>

This works exactly as I would expect, with a different random number each time and I'm able to click or use the keyboard to select items, etc.

As far as the code is concerned, in root.c, there is a function called ShowRootMenu, which handles setting up loading the dynamic menu when needed. There were problems with how this was originally implemented, so are you sure you're using a recent version?

@Israel-D

This comment has been minimized.

Show comment
Hide comment
@Israel-D

Israel-D Jan 29, 2017

Contributor

@joewing It is very odd that I have this issue.
I JUST rebuilt, and used your exact code.
And I get very odd artefacts. It does not say "xterm n" it has "/"
And it will hide the lower menu items
The " is causing issues.
So this works fine

#!/bin/bash
echo "<JWM>"
echo '<Program label="cool">xterm</Program>'
echo "<Separator/>A"
echo "<Restart/>"
echo "<Exit/>"
echo "</JWM>"

I am not sure how you cannot reproduce this issue...

~/git/jwm$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean

~/git/jwm$ which jwm
/usr/local/bin/jwm

##in ~/git/jwm/src/
1047440 Jan 29 16:44 jwm*
##in /usr/local/bin/
1047440 Jan 29 16:57 jwm*

Perhaps the menu cannot handle having many sub-directories?
My places menu goes one directory deep, reads the XDG user dirs, and reads the gtk bookmarks to generate a menu of 'Places' like many other DE do.
It works well as an include, and shows no errors via jwm -p nor anything in my error logs
perhaps a test with many submenu items..
A slimmed down version of my menu (still crashes JWM)
has 10 submenus and 2 programs
one submenu has over 50 items, one over 30 and the rest are 15 or less (all the way down to 1)

could JWM be unable to handle that many menus being generated?
Or, could it be the TIME it takes to generate the menu.

My places menu program does not cache itself, as it is fairly quick

real 0m0.061s
user 0m0.024s
sys 0m0.004s
And this has problems...
The other menu
jwm-menu caches itself, and takes less time (unless regenerating)
real 0m0.010s
user 0m0.004s
sys 0m0.004s
And when I tested it as a dynamic root menu it preformed a bit better...
Both do quite well in a tag, so I am unable to discern why this always fails.
The places menu shows almost instantaneously in a Dynamic tag

Contributor

Israel-D commented Jan 29, 2017

@joewing It is very odd that I have this issue.
I JUST rebuilt, and used your exact code.
And I get very odd artefacts. It does not say "xterm n" it has "/"
And it will hide the lower menu items
The " is causing issues.
So this works fine

#!/bin/bash
echo "<JWM>"
echo '<Program label="cool">xterm</Program>'
echo "<Separator/>A"
echo "<Restart/>"
echo "<Exit/>"
echo "</JWM>"

I am not sure how you cannot reproduce this issue...

~/git/jwm$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean

~/git/jwm$ which jwm
/usr/local/bin/jwm

##in ~/git/jwm/src/
1047440 Jan 29 16:44 jwm*
##in /usr/local/bin/
1047440 Jan 29 16:57 jwm*

Perhaps the menu cannot handle having many sub-directories?
My places menu goes one directory deep, reads the XDG user dirs, and reads the gtk bookmarks to generate a menu of 'Places' like many other DE do.
It works well as an include, and shows no errors via jwm -p nor anything in my error logs
perhaps a test with many submenu items..
A slimmed down version of my menu (still crashes JWM)
has 10 submenus and 2 programs
one submenu has over 50 items, one over 30 and the rest are 15 or less (all the way down to 1)

could JWM be unable to handle that many menus being generated?
Or, could it be the TIME it takes to generate the menu.

My places menu program does not cache itself, as it is fairly quick

real 0m0.061s
user 0m0.024s
sys 0m0.004s
And this has problems...
The other menu
jwm-menu caches itself, and takes less time (unless regenerating)
real 0m0.010s
user 0m0.004s
sys 0m0.004s
And when I tested it as a dynamic root menu it preformed a bit better...
Both do quite well in a tag, so I am unable to discern why this always fails.
The places menu shows almost instantaneously in a Dynamic tag

@rdnvndr

This comment has been minimized.

Show comment
Hide comment
@rdnvndr

rdnvndr Jan 30, 2017

Contributor

@Israel- Run the command in console:
jwm-places||jwm-places-bash > menu.txt
and attach the file "menu.txt`" to the issue

Contributor

rdnvndr commented Jan 30, 2017

@Israel- Run the command in console:
jwm-places||jwm-places-bash > menu.txt
and attach the file "menu.txt`" to the issue

@joewing joewing added this to the Version 2.3.7 milestone Feb 4, 2017

@joewing joewing closed this Jul 8, 2017

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