Open Bug 1562507 Opened 5 years ago Updated 1 year ago

:backdrop selector doesn't have any effect when it's applied to #MozillaGtkWidget menubar

Categories

(Core :: Widget: Gtk, defect, P3)

69 Branch
defect

Tracking

()

People

(Reporter: zzag, Unassigned)

References

(Blocks 2 open bugs)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0

Steps to reproduce:

Apparently it's not possible to specify text color in the menu bar for inactive Firefox windows, or at least :backdrop selector doesn't have any effect when it's applied to #MozillaWidgetGtk menubar.

Steps to reproduce:

  1. Put this stylesheet to your GTK theme

#MozillaWidgetGtk menubar,
#MozillaWidgetGtk .menubar {
color: red;
}

#MozillaWidgetGtk menubar:backdrop,
#MozillaWidgetGtk .menubar:backdrop {
color: blue;
}

  1. Make Firefox inactive

Actual results:

Text in the menubar stays red.

Expected results:

Text in the menubar becomes blue.

Component: Untriaged → Widget: Gtk
Product: Firefox → Core

I use KDE Plasma, but it shouldn't matter because we added support for _NET_WM_STATE_FOCUSED in 5.16.0.

Yes, it's because we set the backdrop state for titlebar and scrollbars:

https://dxr.mozilla.org/mozilla-central/rev/adc59d50adf815ad6764ff235f833a5ba74291b6/widget/gtk/nsNativeThemeGTK.cpp#442

I didn't expected anyone want to style menus for instance. Does your style script work for other Gtk3 applications? like gtk3-demo or gtk3-widget-factory.

I expect the construction from nsNativeThemeGTK.cpp:

  EventStates docState =
      aFrame->GetContent()->OwnerDoc()->GetDocumentState();
  aState->backdrop = docState.HasState(NS_DOCUMENT_STATE_WINDOW_INACTIVE);

can be used for all elements. Do you mind to write a patch for it?

Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(vladzzag)
Priority: -- → P3

(In reply to Martin Stránský [:stransky] from comment #2)

I didn't expected anyone want to style menus for instance.

Depending on the GTK theme, headerbar may have different background color when the client is active or inactive, e.g. black when active, and white when inactive. Thus we need some way to change text color in the menubar when Firefox window becomes inactive to ensure that text is still readable.

Does your style script work for other Gtk3 applications? like gtk3-demo or gtk3-widget-factory.

Yes and no, I'm able to specify background-color for inactive windows, but not color for some reason.

I expect the construction from nsNativeThemeGTK.cpp:

  EventStates docState =
      aFrame->GetContent()->OwnerDoc()->GetDocumentState();
  aState->backdrop = docState.HasState(NS_DOCUMENT_STATE_WINDOW_INACTIVE);

can be used for all elements. Do you mind to write a patch for it?

What do you mean?

(In reply to Vlad Zagorodniy from comment #3)

(In reply to Martin Stránský [:stransky] from comment #2)

I didn't expected anyone want to style menus for instance.

Depending on the GTK theme, headerbar may have different background color
when the client is active or inactive, e.g. black when active, and white
when inactive. Thus we need some way to change text color in the menubar
when Firefox window becomes inactive to ensure that text is still readable.

Yes, I understand.

Does your style script work for other Gtk3 applications? like gtk3-demo or gtk3-widget-factory.

Yes and no, I'm able to specify background-color for inactive windows, but
not color for some reason.

That's interesting. I expect the backdrop should be supported by Gtk themes. Which theme do you tune/write?

I expect the construction from nsNativeThemeGTK.cpp:

  EventStates docState =
      aFrame->GetContent()->OwnerDoc()->GetDocumentState();
  aState->backdrop = docState.HasState(NS_DOCUMENT_STATE_WINDOW_INACTIVE);

can be used for all elements. Do you mind to write a patch for it?

What do you mean?

Write a patch to Firefox to fix that. See https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/How_to_Submit_a_Patch for details.

I see that Gtk+ sets the backdrop for all elements and also redraw menubar when the state changes. I can reproduce that on mate-terminal which draws the menubar.

(In reply to Martin Stránský [:stransky] from comment #5)

That's interesting. I expect the backdrop should be supported by Gtk themes. Which theme do you tune/write?

Breeze, though if I switch to Adwaita, it works.

Write a patch to Firefox to fix that. See https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/How_to_Submit_a_Patch for details.

Sure, I can try. :-)

Flags: needinfo?(vladzzag)

Hmm, the CSS machinery doesn't actually control the value of text color in the menu bar.

https://hg.mozilla.org/mozilla-central/file/781f53bf9c789c27bc9d788a2b435c6304f03c88/widget/gtk/nsLookAndFeel.cpp#l1152

Not sure whether that's a really good idea but perhaps we could expose the backdrop text color of menubar items to chrome stylesheets, e.g. https://paste.ubuntu.com/p/NY5k39P6PS/. It looks a bit hacky but should work. The right thing would be to let the GTK theme set text color, though.

Severity: normal → S3
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.