From 23a510c0b5efced82587c262fd74fd1b31c3d4f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 14 Oct 2013 07:21:44 +0200 Subject: [PATCH] [kdecorations] Add a ::palette() to the decoration API The ::palette() in KDecoration and KCommonDecoration returns the QPalette the decoration should use for the decorated window. The call delegates into the bridge and KWin core might provide a special QPalette for a given Client depending on the _KDE_NET_WM_COLOR_SCHEME property. --- bridge.cpp | 1 + bridge.h | 1 + kcmkwin/kwindecoration/preview.cpp | 5 +++++ kcmkwin/kwindecoration/preview.h | 1 + libkdecorations/kcommondecoration.cpp | 5 +++++ libkdecorations/kcommondecoration.h | 2 ++ libkdecorations/kdecoration.cpp | 5 +++++ libkdecorations/kdecoration.h | 5 +++++ libkdecorations/kdecorationbridge.h | 1 + 9 files changed, 26 insertions(+) diff --git a/bridge.cpp b/bridge.cpp index b416a8abf2..84bc890af5 100644 --- a/bridge.cpp +++ b/bridge.cpp @@ -65,6 +65,7 @@ BRIDGE_HELPER(void, maximize, MaximizeMode m, m,) BRIDGE_HELPER(void, minimize, , ,) BRIDGE_HELPER(void, showContextHelp, , ,) BRIDGE_HELPER(void, setDesktop, int desktop, desktop,) +BRIDGE_HELPER(QPalette, palette, , , const) bool Bridge::isActive() const { diff --git a/bridge.h b/bridge.h index 6958d7a696..56da287536 100644 --- a/bridge.h +++ b/bridge.h @@ -81,6 +81,7 @@ public: virtual QRect transparentRect() const override; virtual void update(const QRegion ®ion) override; + virtual QPalette palette() const override; // Window tabbing virtual QString caption(int idx) const override; diff --git a/kcmkwin/kwindecoration/preview.cpp b/kcmkwin/kwindecoration/preview.cpp index 379c698842..b6e2ef9980 100644 --- a/kcmkwin/kwindecoration/preview.cpp +++ b/kcmkwin/kwindecoration/preview.cpp @@ -552,6 +552,11 @@ KDecoration::WindowOperation KDecorationPreviewBridge::buttonToWindowOperation(Q return KDecoration::NoOp; } +QPalette KDecorationPreviewBridge::palette() const +{ + return QApplication::palette(); +} + KDecorationPreviewOptions::KDecorationPreviewOptions() { customBorderSize = BordersCount; // invalid diff --git a/kcmkwin/kwindecoration/preview.h b/kcmkwin/kwindecoration/preview.h index aa2851ac22..df3ef3bdab 100644 --- a/kcmkwin/kwindecoration/preview.h +++ b/kcmkwin/kwindecoration/preview.h @@ -150,6 +150,7 @@ public: virtual QRect transparentRect() const override; virtual void update(const QRegion ®ion) override; + virtual QPalette palette() const override; // Window tabbing virtual QString caption(int idx) const override; diff --git a/libkdecorations/kcommondecoration.cpp b/libkdecorations/kcommondecoration.cpp index e9f73bd27f..886363f619 100644 --- a/libkdecorations/kcommondecoration.cpp +++ b/libkdecorations/kcommondecoration.cpp @@ -1056,6 +1056,11 @@ void KCommonDecoration::update(const QRegion ®ion) d->wrapper->update(region); } +QPalette KCommonDecoration::palette() const +{ + return d->wrapper->palette(); +} + class KCommonDecorationButtonPrivate { public: diff --git a/libkdecorations/kcommondecoration.h b/libkdecorations/kcommondecoration.h index 310a10dc78..7c1536e173 100644 --- a/libkdecorations/kcommondecoration.h +++ b/libkdecorations/kcommondecoration.h @@ -235,6 +235,8 @@ public: */ QRect transparentRect() const; + QPalette palette() const; + public: /** * Handles widget and layout creation, call the base implementation when subclassing this member. diff --git a/libkdecorations/kdecoration.cpp b/libkdecorations/kdecoration.cpp index bbac5ead77..cb467c7a9c 100644 --- a/libkdecorations/kdecoration.cpp +++ b/libkdecorations/kdecoration.cpp @@ -453,6 +453,11 @@ bool KDecoration::compositingActive() const return d->bridge->compositingActive(); } +QPalette KDecoration::palette() const +{ + return d->bridge->palette(); +} + void KDecoration::padding(int &left, int &right, int &top, int &bottom) const { left = right = top = bottom = 0; diff --git a/libkdecorations/kdecoration.h b/libkdecorations/kdecoration.h index 956bea0754..78624aa67e 100644 --- a/libkdecorations/kdecoration.h +++ b/libkdecorations/kdecoration.h @@ -823,6 +823,11 @@ public: **/ bool isAlphaEnabled() const; + /** + * The recommended palette for the decoration. This can be different per decorated client. + */ + QPalette palette() const; + // requests to decoration /** diff --git a/libkdecorations/kdecorationbridge.h b/libkdecorations/kdecorationbridge.h index bfdd38fdd6..0b58d6de0e 100644 --- a/libkdecorations/kdecorationbridge.h +++ b/libkdecorations/kdecorationbridge.h @@ -88,6 +88,7 @@ public: virtual QRect transparentRect() const = 0; virtual void update(const QRegion ®ion) = 0; + virtual QPalette palette() const = 0; // Window tabbing virtual QString caption(int idx) const = 0;