-
-
Notifications
You must be signed in to change notification settings - Fork 85
FvwmPager: correct fonts and balloons initialization #1189
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
Conversation
Hi @ONykyf This might fix the immediate issue, but I don't think it is the way to go. I would rather see the |
All fallback fonts initialization is in initialize_pager_window() and initialize_balloon_window() now. |
Hi @ONykyf Better. Thanks! But you need to squash those two commits together, please. |
Hi @ONykyf
But you need to be very careful with the testing you do... For reference:
|
Yes, this is because initialize_pager_size() comes before initialize_pager_window(), and font initialization is in the latter. I think it is better to move it to the first, then the proposed check Scr.Ffont != NULL is unnecessary, although can be retained for safety. |
Be careful moving the order around, it is fairly specific and moving the calls around may have other unattended consquences. Also realize not everyone uses fonts, and |
modules/FvwmPager/init_pager.c
Outdated
if (use_window_label && !Scr.Ffont) | ||
Scr.winFfont = FlocaleLoadFont(dpy, NULL, MyName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be !Scr.winFfont
here to match what you are actually setting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank You, it should be !Scr.winFfont
indeed.
modules/FvwmPager/x_update.c
Outdated
if (t == NULL || w == None || Scr.winFfont == NULL || | ||
if (t == NULL || w == None || !use_window_label || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you want to remove the Null
check here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now the logic of the code is such that once initialize_pager_size() is completed, we have either use_window_label == false and Scr.winFfont == NULL, or use_window_label == true and Scr.winFfont == whatever non-zero, which is either default or non-default font. But inside parse_options(), yes, it is safer to leave Scr.winFfont == NULL
check as is.
I can't say I like the churn on this change -- I'm not a fan. We seem to have now decided on resetting I would say "try again". I'm sure you can think of a better way, @ONykyf... |
Maybe I have not understood the intentions behind this code well, then I'd like to ask for a clarification. My idea was the following: first we declare what we are going and what we are not going to use: All fonts are set to NULL == not set. Then parse_options() can consume "Font", "WindowFont", "SmallFont", or "BalloonFont" options arbitrarily many times. Each time, if the option value is "None", then the respective boolean flag is set to false (we have no intention to use this), and the font pointer to NULL. Otherwise, if the option value is not "None", we set the respective font. We can reconsider, then the previous choice is overwritten. Finally, if we have not made a choice, but the intention to use some font has not been rejected, then the default font is used. Is this logic acceptable? |
modules/FvwmPager/init_pager.c
Outdated
} else if (StrEquals(resource, "Balloons")) { | ||
Balloon.show_in_pager = true; | ||
Balloon.show_in_icon = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be here, this is already set on lines 1225, and correctly honors the options, this is overriding what is done below and making it so the option does not work according to the manual page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see what this is doing, but it is not doing it correctly. It does appear that the parser will ignore *FvwmPager: Balloons
, without any options. It does state that this should enable balloons in the manual page, though really just use *FvwmPager: Balloons All
or anything except null and it will process correctly. I'm not sure the best thing to do here, but this is not it. This will make it so Balloons None
or Balloons Pager
will fail.
I might just update the manual page to state that you have to provide an option vs try to work around dealing with it being Null.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note the default config is using *FvwmPager: Balloons All
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see what this is doing, but it is not doing it correctly. It does appear that the parser will ignore
*FvwmPager: Balloons
, without any options. It does state that this should enable balloons in the manual page, though really just use*FvwmPager: Balloons All
or anything except null and it will process correctly. I'm not sure the best thing to do here, but this is not it. This will make it soBalloons None
orBalloons Pager
will fail.I might just update the manual page to state that you have to provide an option vs try to work around dealing with it being Null.
I just followed FvwmPager.adoc (and hence FvwmPager.1): "If type is anything else (or null) balloons are always shown", so no need to change the man page. I had *FvwmPager: Balloons
and then *FvwmPager: BalloonFont "xft:Sans:size=8:medium:antialias=True"
in my config, and this did not worked (not shown).
This will make it so Balloons None or Balloons Pager will fail.
You are right, flags = 0
should be added there to continue parsing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be here, this is already set on lines 1225, and correctly honors the options, this is overriding what is done below and making it so the option does not work according to the manual page.
I would not say so, on lines 1225-1238 Balloon.show_in_pager
and Balloon.show_in_icon
are set only if Balloons option with (and now without) parameters is used. Otherwise these flags are never initialized. Probably this should also be corrected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I updated the way the parser worked, I just overlooked this, and should have updated the manual page at that time, I think it is okay to require a parameter and not make it optional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if you added
flags = 0
to continue parsing, it would still fail because it won't continue if there is no argument. I am going to update the manual page,*FvwmPager: Balloons
is now invalid, use*FvwmPager: Balloons All
, the updates to the parser make it not worth adding a work around to acceptnull
in this case any more.
Could You explain why it would still fail? If there is no argument to Balloons, it will just free resource
and skip to the next cycle iteration, but Balloon.show_in_pager
and Balloon.show_in_icon
have been already set to true
, so everything is ok.
Of course You can remove this option, but I see no problem with it now.
if (!arg1) {
/* No inputs, nothing to do */
free(resource);
continue;
}
This statement below guards the cycle body from unnecessary continuation, doesn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 990 bellow,
if (!arg1)
/* No inputs, nothing to do. */
continue;
If there is no arg, it will also not continue processing. All options below are expected to have an argument, which is why I said I didn't want to design a special case for this option when just not allowing null and removing the comment that it is allowed from the manual page is my preferred solution. Really this would be a single exception that really isn't needed. People can update their configuration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
People can update their configuration.
Yep. I'm more than happy for this -- wouldn't be the first time, and certainly will not be the last. ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, removing (null) case.
Can you share a config that causes the crash you are trying to fix? That way we can test what is actually crashing. The default-config and I use balloon windows and I have never seen FvwmPager crash due to this when swallowed inside of FvwmButtons. I also think your fix is trying to add functionality we may not need, but if we better knew what was crashing we can maybe suggest a better way to fix the initialization issue (really testing of a font is Null is a sufficient test, a new variable doesn't need to be added). Also why are you adding a new configuration option "Balloons" without any documentation on what it does? |
In fact FvwmPager crashed always, but immediately when swallowed by FvwmButtons, or after Midnight Commander (or any other program like xterm that changes its title while running) is started. Nothing interesting in the config, just *FvwmPager: UseSkipList
As You can see, Balloons option is already there and does not work as announced, so no new new functionality, just aligning the code with the manual page. New boolean variable |
Corrected so that now Balloons option looks for an argument (thanks to @somiaj). Set initial values for |
@somiaj I would rather leave editing manpage to You, I am not a native English speaker. |
I really want to track down the crash you are experiencing, because I want to ensure that the changes are needed. So far I cannot reproduce the crash, I have used your configuration and swallowed it in FvwmButtons as shown.
I have changed the title of my |
Could You try the following with and without DestoryModuleConfig FP1:* DestoryModuleConfig FPButtons:* Module FvwmButtons FPButtons Please also check whether |
Ahh I see now, setting the font to |
That was the reason why I proposed to set NULL in this case. In fact there is a reason: I use "layered" configurations when a derived one changes settings of a parent. I believe that options parsing should be fool-proof or at least override-proof. |
I am able to fix that issue with a single line: --- a/modules/FvwmPager/init_pager.c
+++ b/modules/FvwmPager/init_pager.c
@@ -1187,6 +1187,7 @@ void parse_options(void)
StrEquals(resource, "SmallFont"))
{
FlocaleUnloadFont(dpy, Scr.winFfont);
+ Scr.winFfont = NULL;
if (strncasecmp(next, "none", 4) != 0)
Scr.winFfont = FlocaleLoadFont(
dpy, next, MyName); |
modules/FvwmPager/init_pager.c
Outdated
/* balloons are shown by default */ | ||
Balloon.show_in_pager = true; | ||
Balloon.show_in_icon = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't change default behavior. Balloons are not shown by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't change default behavior. Balloons are not shown by default.
I have not found the place where Balloon.show_in_pager
and Balloon.show_in_icon
are set to false
. I asked what is the preferred initial behaviour, but it must be set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variables are false by default, so that is why they were not explicitly set to false. Current behavior is balloon windows are not shown. This has been the default for a while now, no need to change that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variables are false by default, so that is why they were not explicitly set to false. Current behavior is balloon windows are not shown. This has been the default for a while now, no need to change that.
For global variables defined in FvwmPager.c, yes. But I have been searching through the code where Balloon struct is zeroed, and have not succeeded. Can You point me to the place?
modules/FvwmPager/init_pager.c
Outdated
if (!Balloon.Ffont) | ||
if ((Balloon.show_in_icon || Balloon.show_in_pager) && !Balloon.Ffont) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pointless, Balloon.show_in_pager
or Balloon.show_in_icon
is not set, this code is never reached in line 484 above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, You are right.
Then it is necessary to set fonts at the beginning to the default, not when pager window is initialized (whether these fonts are necessary or not), as @ThomasAdam proposed. Have You observed that setting "None" after a real font set, is ignored in other two cases as well? This is not fixed. |
Prevent some weird FvwmPager crashes and balloons not showing up because fonts and boolean flags are not initialized an start. Also the functionallity of "Balloons" option without parameters is restored. FvwmPager: Move default fonts initialization to init_pager_window() function Correct a misprint and move fonts initialization to initialize_pager_size() Scan further for an optional argument to Balloons Balloon (null) is no more allowed Remove superfluous conditions and restore defaults
The only crash or issue that I saw was with setting I'm just trying to identify what issues are being fixed. Anyways, as I see it a single line will stop the crash with setting Everything else seems to be wanting to change default behavior / add features / try to make things more unfiorm, but I don't see an issue outside of that crash. I agree that things aren't uniform, BalloonFont is treated differently than other Fonts, but this is an historical blunder I don't think we need to fix. |
Probably, as a mathematician, I prefer things to be uniform:) And I would not like a font to be loaded just to be removed. So what with initial values for |
Sure it would be nice if the fvwm code base was more uniform, welcome to 30 years of people doing adding features / patches / etc, also back in the last 90s and early 2000s when most this code was written, standards were far looser with code than they in modern times. Anyways I don't think this is going to be accepted as is, you are changing things that don't need to be changed, and the changes will probably lead to segfaults for other setups as was commented above. A lot more is going to have to be done to make sure that these changes are correctly adapted though the full code, and they aren't really achieving anything. Are you having any other issue with FvwmPager not working due to explicitly setting variables to I agree it would be great if the code was more uniform, but that would require a much larger change than just trying to piece in the pieces you are here. |
if (strncasecmp(next, "none", 4) == 0) { | ||
FlocaleUnloadFont(dpy, Scr.Ffont); | ||
if (strncasecmp(next, "none", 4) != 0) | ||
Scr.Ffont = FlocaleLoadFont( | ||
dpy, next, MyName); | ||
else { | ||
Scr.Ffont = NULL; | ||
use_desk_label = false; | ||
use_monitor_label = false; | ||
} else { | ||
FlocaleUnloadFont(dpy, Scr.Ffont); | ||
Scr.Ffont = FlocaleLoadFont(dpy, next, MyName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the reason @ThomasAdam got a segfault and will cause other segfaults. Scr.Ffont
is expected to be a valid font in the code, so that is why it was explicitly not unloaded with the None
setting. You are unloading the font when it shouldn't be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this is not possible. All references to Scr.Ffont are either guarded by use_desk_label
or use_monitor_label
, or are inside draw_desk_label()
all calls of which are guarded by use_desk_label
or use_monitor_label
, hence this cannot cause a crash. I wrote previously why @ThomasAdam got a crash.
Anyways, unless you can point out other actual issues (vs just want to unify things), we will probably just go with a simple patch to fix the crash you are experiencing vs try to refactor the code (and deal with changes due to the refactoring). I have added that fix and updated the manual page to clarify actual behavior of balloon windows in the Thanks for the discussion and if you have any actual issues that need fix with a way we can reproduce them, please share. |
Prevent some weird FvwmPager crashes and balloons not showing up because fonts and boolean flags are not initialized an start. Also restore the functionallity of "Balloons" option without parameters.
Sometimes (and almost always when swallowed by FvwmButtons) FvwmPager silently crashes. Debugging has shown that this happens in do_label_window() function because Scr.winFfont is uninitialized. Also balloons are not always shown in FvwmPager because Balloon.show_in_pager and Balloon.show_in_icon boolean flags are undetermined, and
Balloons with no parameters has no effect. This has been corrected.