Move implementation of ::palette to AbstractClient
Includes moving of the colorscheme and DecorationPalette related functionality.
This commit is contained in:
parent
38b418887a
commit
23862e512d
5 changed files with 85 additions and 74 deletions
|
@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************/
|
||||
#include "abstract_client.h"
|
||||
#include "decorations/decorationpalette.h"
|
||||
#include "focuschain.h"
|
||||
#ifdef KWIN_BUILD_TABBOX
|
||||
#include "tabbox.h"
|
||||
|
@ -27,11 +28,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
QHash<QString, std::weak_ptr<Decoration::DecorationPalette>> AbstractClient::s_palettes;
|
||||
std::shared_ptr<Decoration::DecorationPalette> AbstractClient::s_defaultPalette;
|
||||
|
||||
AbstractClient::AbstractClient()
|
||||
: Toplevel()
|
||||
#ifdef KWIN_BUILD_TABBOX
|
||||
, m_tabBoxClient(QSharedPointer<TabBox::TabBoxClientImpl>(new TabBox::TabBoxClientImpl(this)))
|
||||
#endif
|
||||
, m_colorScheme(QStringLiteral("kdeglobals"))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -355,4 +360,63 @@ void AbstractClient::doMinimize()
|
|||
{
|
||||
}
|
||||
|
||||
QPalette AbstractClient::palette() const
|
||||
{
|
||||
if (!m_palette) {
|
||||
return QPalette();
|
||||
}
|
||||
return m_palette->palette();
|
||||
}
|
||||
|
||||
const Decoration::DecorationPalette *AbstractClient::decorationPalette() const
|
||||
{
|
||||
return m_palette.get();
|
||||
}
|
||||
|
||||
void AbstractClient::updateColorScheme(QString path)
|
||||
{
|
||||
if (path.isEmpty()) {
|
||||
path = QStringLiteral("kdeglobals");
|
||||
}
|
||||
|
||||
if (!m_palette || m_colorScheme != path) {
|
||||
m_colorScheme = path;
|
||||
|
||||
if (m_palette) {
|
||||
disconnect(m_palette.get(), &Decoration::DecorationPalette::changed, this, &AbstractClient::handlePaletteChange);
|
||||
}
|
||||
|
||||
auto it = s_palettes.find(m_colorScheme);
|
||||
|
||||
if (it == s_palettes.end() || it->expired()) {
|
||||
m_palette = std::make_shared<Decoration::DecorationPalette>(m_colorScheme);
|
||||
if (m_palette->isValid()) {
|
||||
s_palettes[m_colorScheme] = m_palette;
|
||||
} else {
|
||||
if (!s_defaultPalette) {
|
||||
s_defaultPalette = std::make_shared<Decoration::DecorationPalette>(QStringLiteral("kdeglobals"));
|
||||
s_palettes[QStringLiteral("kdeglobals")] = s_defaultPalette;
|
||||
}
|
||||
|
||||
m_palette = s_defaultPalette;
|
||||
}
|
||||
|
||||
if (m_colorScheme == QStringLiteral("kdeglobals")) {
|
||||
s_defaultPalette = m_palette;
|
||||
}
|
||||
} else {
|
||||
m_palette = it->lock();
|
||||
}
|
||||
|
||||
connect(m_palette.get(), &Decoration::DecorationPalette::changed, this, &AbstractClient::handlePaletteChange);
|
||||
|
||||
emit paletteChanged(palette());
|
||||
}
|
||||
}
|
||||
|
||||
void AbstractClient::handlePaletteChange()
|
||||
{
|
||||
emit paletteChanged(palette());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,6 +24,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "options.h"
|
||||
#include "rules.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
|
@ -34,6 +36,11 @@ namespace TabBox
|
|||
class TabBoxClientImpl;
|
||||
}
|
||||
|
||||
namespace Decoration
|
||||
{
|
||||
class DecorationPalette;
|
||||
}
|
||||
|
||||
class AbstractClient : public Toplevel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -202,7 +209,8 @@ public:
|
|||
virtual bool noBorder() const = 0;
|
||||
virtual void setNoBorder(bool set) = 0;
|
||||
virtual void blockActivityUpdates(bool b = true) = 0;
|
||||
virtual QPalette palette() const = 0;
|
||||
QPalette palette() const;
|
||||
const Decoration::DecorationPalette *decorationPalette() const;
|
||||
virtual bool isResizable() const = 0;
|
||||
virtual bool isMovable() const = 0;
|
||||
virtual bool isMovableAcrossScreens() const = 0;
|
||||
|
@ -302,6 +310,7 @@ Q_SIGNALS:
|
|||
void minimizedChanged();
|
||||
void clientMinimized(KWin::AbstractClient* client, bool animate);
|
||||
void clientUnminimized(KWin::AbstractClient* client, bool animate);
|
||||
void paletteChanged(const QPalette &p);
|
||||
|
||||
protected:
|
||||
AbstractClient();
|
||||
|
@ -351,7 +360,10 @@ protected:
|
|||
// TODO: remove boolean trap
|
||||
virtual bool belongsToSameApplication(const AbstractClient *other, bool active_hack) const = 0;
|
||||
|
||||
void updateColorScheme(QString path);
|
||||
|
||||
private:
|
||||
void handlePaletteChange();
|
||||
QSharedPointer<TabBox::TabBoxClientImpl> m_tabBoxClient;
|
||||
bool m_firstInTabBox = false;
|
||||
bool m_skipSwitcher = false;
|
||||
|
@ -363,6 +375,11 @@ private:
|
|||
bool m_minimized = false;
|
||||
QTimer *m_autoRaiseTimer = nullptr;
|
||||
int m_desktop = 0; // 0 means not on any desktop yet
|
||||
|
||||
QString m_colorScheme;
|
||||
std::shared_ptr<Decoration::DecorationPalette> m_palette;
|
||||
static QHash<QString, std::weak_ptr<Decoration::DecorationPalette>> s_palettes;
|
||||
static std::shared_ptr<Decoration::DecorationPalette> s_defaultPalette;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
53
client.cpp
53
client.cpp
|
@ -76,9 +76,6 @@ const long ClientWinMask = XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE
|
|||
XCB_EVENT_MASK_STRUCTURE_NOTIFY |
|
||||
XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT;
|
||||
|
||||
QHash<QString, std::weak_ptr<Decoration::DecorationPalette>> Client::s_palettes;
|
||||
std::shared_ptr<Decoration::DecorationPalette> Client::s_defaultPalette;
|
||||
|
||||
// Creating a client:
|
||||
// - only by calling Workspace::createClient()
|
||||
// - it creates a new client and calls manage() for it
|
||||
|
@ -135,7 +132,6 @@ Client::Client()
|
|||
, needsXWindowMove(false)
|
||||
, m_decoInputExtent()
|
||||
, m_focusOutTimer(nullptr)
|
||||
, m_colorScheme(QStringLiteral("kdeglobals"))
|
||||
, m_clientSideDecorated(false)
|
||||
{
|
||||
// TODO: Do all as initialization
|
||||
|
@ -185,6 +181,7 @@ Client::Client()
|
|||
connect(this, &Client::clientFinishUserMovedResized, this, &Client::moveResizedChanged);
|
||||
connect(this, &Client::clientStartUserMovedResized, this, &Client::removeCheckScreenConnection);
|
||||
connect(this, &Client::clientFinishUserMovedResized, this, &Client::setupCheckScreenConnection);
|
||||
connect(this, &Client::paletteChanged, this, &Client::triggerDecorationRepaint);
|
||||
|
||||
connect(clientMachine(), &ClientMachine::localhostChanged, this, &Client::updateCaption);
|
||||
connect(options, &Options::condensedTitleChanged, this, &Client::updateCaption);
|
||||
|
@ -2119,47 +2116,7 @@ Xcb::StringProperty Client::fetchColorScheme() const
|
|||
|
||||
void Client::readColorScheme(Xcb::StringProperty &property)
|
||||
{
|
||||
QString path = QString::fromUtf8(property);
|
||||
path = rules()->checkDecoColor(path);
|
||||
|
||||
if (path.isEmpty()) {
|
||||
path = QStringLiteral("kdeglobals");
|
||||
}
|
||||
|
||||
if (!m_palette || m_colorScheme != path) {
|
||||
m_colorScheme = path;
|
||||
|
||||
if (m_palette) {
|
||||
disconnect(m_palette.get(), &Decoration::DecorationPalette::changed, this, &Client::handlePaletteChange);
|
||||
}
|
||||
|
||||
auto it = s_palettes.find(m_colorScheme);
|
||||
|
||||
if (it == s_palettes.end() || it->expired()) {
|
||||
m_palette = std::make_shared<Decoration::DecorationPalette>(m_colorScheme);
|
||||
if (m_palette->isValid()) {
|
||||
s_palettes[m_colorScheme] = m_palette;
|
||||
} else {
|
||||
if (!s_defaultPalette) {
|
||||
s_defaultPalette = std::make_shared<Decoration::DecorationPalette>(QStringLiteral("kdeglobals"));
|
||||
s_palettes[QStringLiteral("kdeglobals")] = s_defaultPalette;
|
||||
}
|
||||
|
||||
m_palette = s_defaultPalette;
|
||||
}
|
||||
|
||||
if (m_colorScheme == QStringLiteral("kdeglobals")) {
|
||||
s_defaultPalette = m_palette;
|
||||
}
|
||||
} else {
|
||||
m_palette = it->lock();
|
||||
}
|
||||
|
||||
connect(m_palette.get(), &Decoration::DecorationPalette::changed, this, &Client::handlePaletteChange);
|
||||
|
||||
emit paletteChanged(palette());
|
||||
triggerDecorationRepaint();
|
||||
}
|
||||
AbstractClient::updateColorScheme(rules()->checkDecoColor(QString::fromUtf8(property)));
|
||||
}
|
||||
|
||||
void Client::updateColorScheme()
|
||||
|
@ -2168,12 +2125,6 @@ void Client::updateColorScheme()
|
|||
readColorScheme(property);
|
||||
}
|
||||
|
||||
void Client::handlePaletteChange()
|
||||
{
|
||||
emit paletteChanged(palette());
|
||||
triggerDecorationRepaint();
|
||||
}
|
||||
|
||||
bool Client::isClient() const
|
||||
{
|
||||
return true;
|
||||
|
|
22
client.h
22
client.h
|
@ -28,7 +28,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "tabgroup.h"
|
||||
#include "abstract_client.h"
|
||||
#include "xcbutils.h"
|
||||
#include "decorations/decorationpalette.h"
|
||||
// Qt
|
||||
#include <QElapsedTimer>
|
||||
#include <QFlags>
|
||||
|
@ -524,9 +523,6 @@ public:
|
|||
|
||||
void cancelFocusOutTimer();
|
||||
|
||||
QPalette palette() const override;
|
||||
const Decoration::DecorationPalette *decorationPalette() const;
|
||||
|
||||
/**
|
||||
* Restores the Client after it had been hidden due to show on screen edge functionality.
|
||||
* In addition the property gets deleted so that the Client knows that it is visible again.
|
||||
|
@ -605,7 +601,6 @@ Q_SIGNALS:
|
|||
void moveResizedChanged();
|
||||
void skipTaskbarChanged();
|
||||
void skipPagerChanged();
|
||||
void paletteChanged(const QPalette &p);
|
||||
|
||||
/**
|
||||
* Emitted whenever the Client's TabGroup changed. That is whenever the Client is moved to
|
||||
|
@ -726,8 +721,6 @@ private:
|
|||
**/
|
||||
void updateShowOnScreenEdge();
|
||||
|
||||
void handlePaletteChange();
|
||||
|
||||
Xcb::Window m_client;
|
||||
Xcb::Window m_wrapper;
|
||||
Xcb::Window m_frame;
|
||||
|
@ -861,11 +854,6 @@ private:
|
|||
|
||||
QTimer *m_focusOutTimer;
|
||||
|
||||
QString m_colorScheme;
|
||||
std::shared_ptr<Decoration::DecorationPalette> m_palette;
|
||||
static QHash<QString, std::weak_ptr<Decoration::DecorationPalette>> s_palettes;
|
||||
static std::shared_ptr<Decoration::DecorationPalette> s_defaultPalette;
|
||||
|
||||
QList<QMetaObject::Connection> m_connections;
|
||||
bool m_clientSideDecorated;
|
||||
};
|
||||
|
@ -1081,16 +1069,6 @@ inline bool Client::hiddenPreview() const
|
|||
return mapping_state == Kept;
|
||||
}
|
||||
|
||||
inline QPalette Client::palette() const
|
||||
{
|
||||
return m_palette->palette();
|
||||
}
|
||||
|
||||
inline const Decoration::DecorationPalette *Client::decorationPalette() const
|
||||
{
|
||||
return m_palette.get();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void Client::print(T &stream) const
|
||||
{
|
||||
|
|
|
@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************/
|
||||
#include "decoratedclient.h"
|
||||
#include "decorationpalette.h"
|
||||
#include "decorationrenderer.h"
|
||||
#include "client.h"
|
||||
#include "composite.h"
|
||||
|
|
Loading…
Reference in a new issue