From 7bf7c513757f347f5174ec676de8a22293337967 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sat, 3 Aug 2019 23:26:37 +0200 Subject: [PATCH] Investigation: inconclusive further research (context_save/restore) Indeed I had missed to connect the new "free standing" StyleContext to some Gdk::Screen, typically the default screen (connected to the current top level window). But seemingly this was not really necessary, since, somehow magically, the style context must have connected itself to some screen, otherwise it wouldn't be able to access the CSS cascade. Anyhow, fixing this omission does not resolve our problem. Nor does any combination of re-connecting, invalidating etc. I poked around in the GTK (C) code a lot, but could not spot any obvious missing initialisation step. To much magic around here. Without massive debugging into GTK internals, I don't see any way to further this investigation. And, moreover there is a viable workaround (namely to set and remove the classes explicitly, which works as intended) I posted a question on Stackoverflow and for now I'll file this topic as "inconclusive" https://stackoverflow.com/q/57342478 --- research/gtk-style-experiment.cpp | 13 +++++- src/stage/timeline/body-canvas-widget.cpp | 4 +- src/stage/workspace/ui-style.cpp | 1 + wiki/thinkPad.ichthyo.mm | 54 +++++++++++++++++++++-- 4 files changed, 65 insertions(+), 7 deletions(-) diff --git a/research/gtk-style-experiment.cpp b/research/gtk-style-experiment.cpp index ffc11f85c..466919197 100644 --- a/research/gtk-style-experiment.cpp +++ b/research/gtk-style-experiment.cpp @@ -44,6 +44,7 @@ #include "lib/error.hpp" #include "lib/util.hpp" +#include ////////////////////TODO WIP #include using util::cStr; @@ -218,6 +219,7 @@ namespace research { Gtk::WidgetPath path = srcWidget.get_path(); PStyleContext style = Gtk::StyleContext::create(); + style->set_screen(Gdk::Screen::get_default()); style->set_path(path); // style->add_class(slopeClassName(2)); return style; @@ -317,8 +319,14 @@ namespace research { { int marT = style_->get_margin().get_top(); + auto path = style_->get_path(); + if (xBorderSiz > 1) { - style_->context_save(); +// style_->invalidate(); +// style_->context_save(); +// style_->set_screen(Gdk::Screen::get_default()); +// style_->set_path(path); +// style_->invalidate(); style_->add_class(slopeClassName(xBorderSiz)); } @@ -335,7 +343,8 @@ namespace research { ); if (xBorderSiz > 1) { - style_->context_restore(); +// style_->context_restore(); + style_->remove_class(slopeClassName(xBorderSiz)); } } //////////////////TEST drawing via Gtk::StyleContext diff --git a/src/stage/timeline/body-canvas-widget.cpp b/src/stage/timeline/body-canvas-widget.cpp index 09b1569bf..b4f2c6753 100644 --- a/src/stage/timeline/body-canvas-widget.cpp +++ b/src/stage/timeline/body-canvas-widget.cpp @@ -219,7 +219,7 @@ namespace timeline { void close (uint n) override { -// style_->context_save(); +// style_->context_save(); // <<<---does not work. Asked on SO: https://stackoverflow.com/q/57342478 style_->add_class (slopeClassName(n)); style_->invalidate(); int slopeWidth = style_->get_border().get_bottom(); @@ -235,8 +235,8 @@ namespace timeline { ,visible_.b ,visible_.e ); +// style_->context_restore(); // <<<---does not work... style_->remove_class (slopeClassName(n)); -// style_->context_restore(); line_ += slopeWidth; } diff --git a/src/stage/workspace/ui-style.cpp b/src/stage/workspace/ui-style.cpp index 6839ce0ad..06b3b4a95 100644 --- a/src/stage/workspace/ui-style.cpp +++ b/src/stage/workspace/ui-style.cpp @@ -139,6 +139,7 @@ namespace workspace { for (int i=0; iset_screen(Gdk::Screen::get_default()); style->set_path (path); styleAdviceTrackBody_.setAdvice (style); // publish as Advice "style(trackBody)" INFO (stage, "Body-CSS: path=%s", util::cStr (path.to_string())); ////////////////////////TICKET #1201 : this yields "paned:dir-ltr.horizontal box:dir-ltr.vertical TrackScope.timeline" diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index dede9aef4..40a4b9859 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -23026,10 +23026,58 @@ - - + + + + + + + + +

+ Wenn man einen neuen Gtk::StyleContext erzeugt, +

+

+ und (wie in der Doku beschrieben) den path und den screen manuell setzt, +

+

+ dann führt ein context_save() dazu, daß plötzlich die CSS-Werte auf Defaults zurückspringen +

+ + +
- + + + + + + +

+ und ja, den Screen sollte man generell setzten.
Steht auch so in der Doku. +

+

+ +

+

+ Allerdings hat es bisher auch ohne das bei mir funktioniert. +

+ + +
+ +
+ + + + + + + + + +
+