Encapsulate colormap related functionality in own class

Split out the default and installed colormap from Workspace and put them
into an own class Colormaps.

The method updateColormaps is replaced by a slot update in Colormaps and
activeClientChanged signal is connected to this slot.

At the same time the colormap related code is straight forward ported to
xcb.

REVIEW: 110248
icc-effect-5.14.5
Martin Gräßlin 2013-04-30 14:55:06 +02:00
parent ce9ce6f94c
commit 0811d17329
3 changed files with 40 additions and 23 deletions

View File

@ -264,7 +264,6 @@ void Workspace::setActiveClient(Client* c)
updateStackingOrder(); // e.g. fullscreens have different layer when active/not-active
rootInfo()->setActiveWindow(active_client ? active_client->window() : 0);
updateColormap();
emit clientActivated(active_client);
--set_active_client_recursion;

View File

@ -79,6 +79,31 @@ namespace KWin
extern int screen_number;
extern bool is_multihead;
ColorMapper::ColorMapper(QObject *parent)
: QObject(parent)
, m_default(defaultScreen()->default_colormap)
, m_installed(defaultScreen()->default_colormap)
{
}
ColorMapper::~ColorMapper()
{
}
void ColorMapper::update()
{
xcb_colormap_t cmap = m_default;
if (Client *c = Workspace::self()->activeClient()) {
if (c->colormap() != XCB_COLORMAP_NONE) {
cmap = c->colormap();
}
}
if (cmap != m_installed) {
xcb_install_colormap(connection(), cmap);
m_installed = cmap;
}
}
Workspace* Workspace::_self = 0;
Workspace::Workspace(bool restore)
@ -144,8 +169,8 @@ Workspace::Workspace(bool restore)
options->loadConfig();
options->loadCompositingConfig(false);
DecorationPlugin::create(this);
default_colormap = DefaultColormap(display(), screen_number);
installed_colormap = default_colormap;
ColorMapper *colormaps = new ColorMapper(this);
connect(this, SIGNAL(clientActivated(KWin::Client*)), colormaps, SLOT(update()));
updateXTime(); // Needed for proper initialization of user_time in Client ctor
@ -716,20 +741,6 @@ void Workspace::slotUpdateToolWindows()
updateToolWindows(true);
}
/**
* Updates the current colormap according to the currently active client
*/
void Workspace::updateColormap()
{
Colormap cmap = default_colormap;
if (activeClient() && activeClient()->colormap() != None)
cmap = activeClient()->colormap();
if (cmap != installed_colormap) {
XInstallColormap(display(), cmap);
installed_colormap = cmap;
}
}
void Workspace::slotReloadConfig()
{
reconfigure();

View File

@ -116,8 +116,6 @@ public:
return block_focus == 0;
}
void updateColormap();
/**
* Indicates that the client c is being moved around by the user.
*/
@ -530,10 +528,6 @@ private:
bool global_shortcuts_disabled;
bool global_shortcuts_disabled_for_client;
// Colormap handling
Colormap default_colormap;
Colormap installed_colormap;
// Timer to collect requests for 'reconfigure'
QTimer reconfigureTimer;
@ -585,6 +579,19 @@ private:
Workspace* ws;
};
class ColorMapper : public QObject
{
Q_OBJECT
public:
ColorMapper(QObject *parent);
virtual ~ColorMapper();
public Q_SLOTS:
void update();
private:
xcb_colormap_t m_default;
xcb_colormap_t m_installed;
};
//---------------------------------------------------------
// Unsorted