Skip to content
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

Text selection color problem with Tk applications #3767

Open
rdiez opened this issue Nov 10, 2022 · 18 comments
Open

Text selection color problem with Tk applications #3767

rdiez opened this issue Nov 10, 2022 · 18 comments

Comments

@rdiez
Copy link

rdiez commented Nov 10, 2022

I use Git Gui (a Tcl/Tk application), and I have always had problems with the text colour, see this GitHub issue for details:

prati0100/git-gui#44

I recently upgraded my Ubuntu MATE system from version 20.04 to 22.04, and I started having trouble with the colours again in Git Gui.

After the upgrade, the Theme under "Appearance" was set to "Custom", which I do not remember doing myself. I as far as I know, I never actually customised any theme.

I then changed the Theme to Yaru, and when selecting text with the mouse, the selection is no longer visible inside Git Gui. This is a short list of colours:

xrdb -query -all | grep -i \*Text

*Text.activeBackground:    #fafafa
*Text.activeForeground:    #3d3d3d
*Text.background:          #fafafa
*Text.foreground:          #3d3d3d
*Text.highlightBackground: #fafafa
*Text.highlightColor:      #3d3d3d
*Text.selectBackground:    #fafafa
*Text.selectForeground:    #3d3d3d

Note that *Text.selectBackground is set to #fafafa, which is the same colour as other text backgrounds. Is that not a problem?

I had to change it to lightgray, in order for the text selection to be visible again in Git Gui.

This may not be a problem with Yaru only. I installed Menta, an older theme, and the same issue remains. The output of the command above is exactly the same.

Note that you seem to have to log out and in again for such theme changes to take effect in Tk applications.

@Muqtxdir
Copy link
Member

just to be sure by tk applications you don't mean gtk applications right?

@rdiez
Copy link
Author

rdiez commented Nov 10, 2022

That is correct, it's about Tk as in Tcl/Tk (and probably others like Python tkinter), and not GTK.

When reporting this issue, this was the closest option. If this is not the right place, do you know where I should file the bug report instead?

@rdiez
Copy link
Author

rdiez commented Nov 11, 2022

I just realised that my statements above are not quite right. I am sorry about the confusion.

I have disabled the workarounds I was using:

  • I reset setting "org.mate.SettingsDaemon.plugins.xrdb active")
  • I removed file ~/.Xresources

Afterwards, I repeated the tests under those conditions (the default).

If I switch to the Yaru theme, then I can no longer see the text selection in Git Gui, as described above. The colours are as listed above.

However, I not only get this problem with Git Gui, which is a Tcl/Tk application, but with Emacs, which I configured with "--with-x-toolkit=gtk3", so it should be using GTK3. The theme change is immediately visible in Emacs (no need to relogin).

I have installed package "mate-themes", which pulls some GTK2 dependencies. If I select the older Menta theme from that package, then the text selection is visible again. After relogin, I get now these colours:

$ xrdb -query -all | grep -i \*Text
*Text.activeBackground:    #d4d4d4
*Text.activeForeground:    #2c2c2c
*Text.background:          #d4d4d4
*Text.foreground:          #2c2c2c
*Text.highlightBackground: #d4d4d4
*Text.highlightColor:      #2c2c2c
*Text.selectBackground:    #accd8a
*Text.selectForeground:    #3e473e

Note that *Text.selectBackground is different from the other background colours. It is a kind of green, which is what the text selection background looks like.

The problem is that *Text.background is #d4d4d4, a kind of gray. I do not understand where this comes from, because applications like Pluma or gedit display a white text background. That gray colour is what bothers me in Git Gui.

@Jupi007
Copy link
Member

Jupi007 commented Dec 4, 2022

Any news on this?
@rdiez @Muqtxdir

Shouldn't we close this, as it is not related to Yaru?

@Muqtxdir
Copy link
Member

Muqtxdir commented Dec 4, 2022

yes, it's not related to yaru as we don't theme tk applications. If anyone is willing to contribute to making yaru theme possible for tk based applications, then they can open a pr

@rdiez
Copy link
Author

rdiez commented Dec 4, 2022

One of the problems with the text selection I mentioned also applies to Emacs, a GTK 3 application, see my comments further above.

When I select a different theme, Menta, does not have such problems. I can understand that Yaru does not feel directly responsible, but I guess that something is not working well together. If not Yaru, does anybody know what component I should file a bug against?

@Jupi007
Copy link
Member

Jupi007 commented Dec 4, 2022

I'm sorry, I have no idea.
Btw I installed emacs, but I didn't noticed any text selection problem.

@rdiez
Copy link
Author

rdiez commented Dec 5, 2022

I would like pin-point the problem. Which variant of Ubuntu are you using? I am using Ubuntu MATE, which is still using X11, as reported by:

echo $XDG_SESSION_TYPE

If you are using "plain" Ubuntu, then you are probably using Wayland. May this kind of issue does not happen on Wayland.

I just tried again on 2 computers running Ubuntu MATE 22.04.1. One of them is running the Emacs that comes with the distribution. I checked with describe-variable, system-configuration-options, and it was configured with --with-x-toolkit=gtk3. I do not think that Emacs uses Tk at all.

This system has no ~/.Xresources file at all. On this computer, I see or stop seeing the text selection in Emacs straightaway as I click on the different themes under "Appearance". With Yaru, I would expect the text selection background to be orange, instead of not being visible (same a non-selected text).

The other computer is running Ubuntu MATE 22.04.1 too, has a ~/.Xresources file with the Tk workarounds, and I built Emacs myself from sources, but also with --with-x-toolkit=gtk3. When I switch themes on this system, the text selection colour changes straightaway too.

When I select Menta (a GTK 2 theme), the text selection on Emacs becomes green. On Pluma (MATE's text editor), it's the same green. On Git Gui (a Tk application), it is a strong gray, due to the work-around in ~/.Xresources .

When I select Yaru, the text selection on Emacs changes to a very pale gray (not very usable). Maybe it is the same colour on the other system, but the monitor is different, so I may have missed it. On Pluma, the text selection is orange, as expected. Git Gui is not affected, due to the work-around in ~/.Xresources, so it remains a strong gray.

I have a third Ubuntu MATE at work with a similar behaviour.

I dug a bit deeper. In Emacs, I ran customize-face for face (font) region. Option Background was ticked and had value gtk_selection_bg_color. As I clicked from Yaru to Menta, and viceversa, I could see the colour changing automatically (dynamically) between green for Menta, and pale gray for Yaru. That is why I think that something is wrong with GTK3 theming. The trouble is knowing exactly what.

@rdiez
Copy link
Author

rdiez commented Dec 5, 2022

I have done some more tests:

Theme Numix (package numix-gtk-theme) has no such problems with Emacs. Its website states "GTK+ 3.18 or above".

Theme Clearlooks-Phénix (package clearlooks-phenix-theme) has no such problems with Emacs. It even does not have the Git Gui problem (a Tk application).

@Jupi007
Copy link
Member

Jupi007 commented Dec 5, 2022

Thanks for all your very detailed description @rdiez, but can you provide some screenshots of the problem(s) you are trying to report? 🙂
Very honestly, I'm not able to clearly visualise all that.

@rdiez
Copy link
Author

rdiez commented Dec 6, 2022

This first screenshot shows theme Clearlooks-Phénix. I highlighted the word "bbbbb" in Pluma editor, so its background colour is blue. On Emacs, setting gtk_selection_bg_color shows the word "sample" in the same blue colour, as expected.

Clearlooks-Phenix

This second screenshot shows theme Yaru. In the Pluma editor, the background of the selected word "bbbbb" is now orange. But in Emacs, the word "sample" next to gtk_selection_bg_color is no longer visible. However, if you zoom in the area where it should be (for example, with Gimp), you will see that the word "sample" is still there, only with a barely visible pale gray colour.

Yaru

@Jupi007
Copy link
Member

Jupi007 commented Dec 8, 2022

Thanks for the screenshots @rdiez
Now I better understand what you mean 🙂

Can you try to select the same text, but with using the Adwaita theme:

GTK_THEME=Adwaita emacs-gtk

This is the default Gtk theme, and we are based on it.
If the problem is still present with, this would mean that the problem is not on the Yaru side.

@rdiez
Copy link
Author

rdiez commented Dec 8, 2022

I tested it, and the problem is the same. I also tried with a wrong theme name, and it's the same:

GTK_THEME=wrong-name emacs-gtk

It is as if Emacs wouldn't find the GTK theme at all. I wonder whether that is what is happening with Yaru too, and also with the Tk applications.

Mind you, theme Adwaita should be currently installed on my system via package gnome-themes-standard, but it is described as a GTK+2 theme. Therefore, it may not be surprising that Emacs, which should be using GTK+ 3, does not find it. After all, it is not listed either in the "Appearance Preferences" window.

I find it a little worrying that you supply the name of an invalid GTK theme, and you do not get warning at all on the console. The same happens with Pluma:

GTK_THEME=wrong-name pluma

@Jupi007
Copy link
Member

Jupi007 commented Dec 8, 2022

So you don't have the Adwaita theme 🤔
This is completely weird, because it is the Gtk built-in stylesheet, it shouldn't be installable/uninstallable.

Just to be sure, even if you get a warning, is the theme different than Yaru, and with blue accent?
Also, can you list me your installed Gtk themes, please?

@rdiez
Copy link
Author

rdiez commented Dec 8, 2022

I am not quite following you. I am not getting any warnings at all that the theme is not available, even if the theme name is obviously wrong.

It's hard to say whether the theme has a blue accent. First of all, I just switched the desktop to Yaru. This is what Emacs looks like (I had to disable my config, because otherwise I am using a newer, a self-compiled Emacs, like I mentioned above):

GTK_THEME=Adwaita emacs-gtk --no-init-file

EmacsWithAdwaita

And this is Pluma:

GTK_THEME=Adwaita pluma

PlumaWithAdwaita

I am now trying to find a way to list all installed themes. I have installed and removed quite a few while testing this issue.

@rdiez
Copy link
Author

rdiez commented Dec 8, 2022

I do not really know where to look. I found some common directories on the Internet:

/usr/share/themes:

Adwaita
Adwaita-dark
Atlanta
BlackMATE
BlueMenta
Blue-Submarine
Clearlooks
Clearlooks-Phenix
ClearlooksRe
ContrastHigh
Crux
Default
Dopple
Dopple-Left
DustBlue
Emacs
eOS
Esco
Gorilla
GreenLaguna
Green-Submarine
Greybird
Greybird-accessibility
Greybird-bright
Greybird-compact
Greybird-dark
Greybird-dark-accessibility
HighContrast
HighContrastInverse
Industrial
Menta
Mist
Motif
Numix
oxygen-gtk
Raleigh
Redmond
Shiny
Spidey
Spidey-Left
Splint
Splint-Left
ThinIce
TraditionalGreen
TraditionalOk
WinMe
Yaru
Yaru-bark
Yaru-bark-dark
Yaru-blue
Yaru-blue-dark
Yaru-dark
Yaru-dark-hdpi
Yaru-dark-xhdpi
YaruGreen
Yaru-hdpi
Yaru-magenta
Yaru-magenta-dark
Yaru-MATE
Yaru-MATE-dark
Yaru-MATE-light
YaruOk
Yaru-olive
Yaru-olive-dark
Yaru-prussiangreen
Yaru-prussiangreen-dark
Yaru-purple
Yaru-purple-dark
Yaru-red
Yaru-red-dark
Yaru-sage
Yaru-sage-dark
Yaru-viridian
Yaru-viridian-dark
Yaru-xhdpi

/usr/local/share/themes does not exist
~/.local/share/themes does not exist
~/.themes is empty.

The list of themes is shorter in the "Appearence Preferences" window:

Custom
BlackMATE
BlueMenta
Blue-Submarine
Clearlooks-Phenix
GreenLaguna
Green-Submarine
Greybird
Greybird-dark
HighContrast
HighContrastInverse
Yaru
Yaru-bark
Yaru-bark-dark
Yaru-blue
Yaru-blue-dark
Yaru-dark
YaruGreen
Yaru-magenta
Yaru-magenta-dark
Yaru-MATE-dark
Yaru-MATE-light
YaruOk
Yaru-olive
Yaru-olive-dark
Yaru-prussiangreen
Yaru-prussiangreen-dark
Yaru-purple
Yaru-purple-dark
Yaru-red
Yaru-red-dark
Yaru-sage
Yaru-sage-dark
Yaru-viridian
Yaru-viridian-dark

Some themes, like Yaru-MATE or Yaru-xhdpi, are missing there.

@Jupi007
Copy link
Member

Jupi007 commented Dec 8, 2022

I am not quite following you. I am not getting any warnings at all that the theme is not available, even if the theme name is obviously wrong.

Oh okay, so I had misunderstood, sorry. I was thinking you got a warning.
In fact on my computer, I also don't have any when I select a non-existent theme.

Looking at your screenshots and your theme folders, I can affirm that you are using Adwaita.
If you confirm that the problem is still here even when using the official Gtk theme, then that mean that this issue is not related to Yaru itself.
So I am really sorry, but you should report that problem to the upstream project, I mean Gtk and/or the related apps.

Thanks a lot for your patience 🙂
Can you post here the upstream issues, so we can follow the problem resolution, and maybe import an eventually patch as fast as possible ?

@rdiez
Copy link
Author

rdiez commented Dec 8, 2022

Going further upstream looks like more work. I am sorry, but I am not prepared to invest any more time in this issue at the moment. I am facing so many little issues lately since the upgrade to Ubuntu MATE 22.04 (on 3 different systems), that I am considering switching distribution altogether.

Feel free to close this issue. In the meantime, if anybody else is having the same problem with Emacs or with Tk applications, I would say they should stop using Yaru and switch to Theme Clearlooks-Phénix (package clearlooks-phenix-theme) , which apparently works well all over the place. I would like to hear from other themes which also work well. This way, it may be easier to pin-point where the problem lies.

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

No branches or pull requests

3 participants