Skip to content

Commit 92c305e

Browse files
committed
Track background color in Window implementation
Adds a background_color_ member to Window::Impl to store the background color directly, replacing deprecated GTK API usage in GetBackgroundColor. This ensures reliable retrieval of the background color after it is set via SetBackgroundColor.
1 parent 50bedbb commit 92c305e

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/platform/linux/window_linux.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class Window::Impl {
5454
GdkWindow* gdk_window_;
5555
TitleBarStyle title_bar_style_;
5656
VisualEffect visual_effect_;
57+
Color background_color_;
5758
};
5859

5960
Window::Window() {
@@ -565,6 +566,9 @@ void Window::SetBackgroundColor(const Color& color) {
565566
if (!pimpl_->widget_)
566567
return;
567568

569+
// Store the color
570+
pimpl_->background_color_ = color;
571+
568572
// Create CSS provider for background color
569573
GtkCssProvider* provider = gtk_css_provider_new();
570574

@@ -589,17 +593,9 @@ Color Window::GetBackgroundColor() const {
589593
if (!pimpl_->widget_)
590594
return Color::White;
591595

592-
GtkStyleContext* context = gtk_widget_get_style_context(pimpl_->widget_);
593-
GdkRGBA rgba;
594-
595-
gtk_style_context_get_background_color(context, GTK_STATE_FLAG_NORMAL, &rgba);
596-
597-
return Color::FromRGBA(
598-
static_cast<unsigned char>(rgba.red * 255),
599-
static_cast<unsigned char>(rgba.green * 255),
600-
static_cast<unsigned char>(rgba.blue * 255),
601-
static_cast<unsigned char>(rgba.alpha * 255)
602-
);
596+
// Return the stored background color
597+
// Since we set it via CSS, we track it ourselves to avoid using deprecated APIs
598+
return pimpl_->background_color_;
603599
}
604600

605601
void Window::SetVisibleOnAllWorkspaces(bool is_visible_on_all_workspaces) {

0 commit comments

Comments
 (0)