Tk Source Code

View Ticket
Login
Ticket UUID: 807b2f891651ebe2c453feb2457516519f60a830
Title: TIP 645 expects colors not defined by system theming
Type: Support Version: trunk
Submitter: chrstphrchvz Created on: 2023-08-24 21:36:36
Subsystem: 88. Themed Tk Assigned To: nobody
Priority: 5 Medium Severity: Important
Status: Closed Last Modified: 2026-11-01 16:12:59
Resolution: Fixed Closed By: nemethi
    Closed on: 2026-11-01 16:12:59
Description:

Using MATE 1.26.1. I originally observed this while using the Materia-dark-compact theme, but I am not aware of a theme without this issue.

I am not familiar with how GTK theming works and how it is translated to X resources colors. But I find that the only X resource colors which get defined are foreground and background, whereas the TIP 645 default Ttk theme expects additional colors such as active background. If those are not defined, then fallback colors are used, which may contrast poorly with the system background and foreground colors. An example of this is button text being difficult to read when hovered:
 

I currently do not know what should be done about this, so marking as “Support” for now.

User Comments: nemethi (claiming to be Csaba Nemethi) added on 2026-11-01 16:12:59:

Serhiy, many thanks for the provided solution! Merged into main and core-9-0-branch by commits [5cb696db] and [f0c5986e]. No plans for a backport to core-8-6-branch.


serhiy.storchaka added on 2026-10-26 12:39:32:

The theme reads its palette from the option database, but only for the colours an X resource actually sets. background and foreground reach three of its thirteen entries; the other ten keep values chosen for a light grey palette, which is how a dark background comes to sit beside a near-white -activebg and a light -darker.

Proposed fix in branch ttk-derive-missing-colors [d0c3cb85ea]: compute the colours the option database does not answer for from the ones it does, by the rules tk_setPalette already applies to the classic widgets, so that the two agree. The selection colour is the exception — it is an accent rather than a shade of the frame, and the theme's blue reads against a light frame and a dark one alike.

Four of those rules are factored into ::tk::ContrastColor, ::tk::Lighten, ::tk::BlendColors and the existing ::tk::Darken, which tk_setPalette now calls instead of writing them out; its output is unchanged. ::tk::Darken no longer loses precision to double rounding.

tests/palette.test covers the derivations and checks that a palette with no X resources set is identical to before.