2007-11-27 19:40:25 +00:00
|
|
|
/********************************************************************
|
2007-04-29 17:35:43 +00:00
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2006 Lubos Lunak <l.lunak@kde.org>
|
|
|
|
|
2007-11-27 19:40:25 +00:00
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
#include "effects.h"
|
|
|
|
|
|
|
|
#include "deleted.h"
|
|
|
|
#include "client.h"
|
|
|
|
#include "group.h"
|
|
|
|
#include "scene_xrender.h"
|
|
|
|
#include "scene_opengl.h"
|
2008-01-02 15:37:46 +00:00
|
|
|
#include "unmanaged.h"
|
2007-04-29 17:35:43 +00:00
|
|
|
#include "workspace.h"
|
|
|
|
#include "kwinglutils.h"
|
|
|
|
|
|
|
|
#include <QFile>
|
|
|
|
|
|
|
|
#include "kdebug.h"
|
2009-10-05 09:47:13 +00:00
|
|
|
#include "klibrary.h"
|
2007-04-29 17:35:43 +00:00
|
|
|
#include "kdesktopfile.h"
|
|
|
|
#include "kconfiggroup.h"
|
|
|
|
#include "kstandarddirs.h"
|
2007-05-28 11:12:20 +00:00
|
|
|
#include <kservice.h>
|
|
|
|
#include <kservicetypetrader.h>
|
|
|
|
#include <kplugininfo.h>
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2010-02-01 07:44:27 +00:00
|
|
|
//---------------------
|
|
|
|
// Static
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
static QByteArray readWindowProperty(Window win, long atom, long type, int format)
|
|
|
|
{
|
2010-02-01 07:44:27 +00:00
|
|
|
int len = 32768;
|
2011-01-30 14:34:42 +00:00
|
|
|
for (;;) {
|
2010-02-01 07:44:27 +00:00
|
|
|
unsigned char* data;
|
|
|
|
Atom rtype;
|
|
|
|
int rformat;
|
|
|
|
unsigned long nitems, after;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (XGetWindowProperty(QX11Info::display(), win,
|
|
|
|
atom, 0, len, False, AnyPropertyType,
|
|
|
|
&rtype, &rformat, &nitems, &after, &data) == Success) {
|
|
|
|
if (after > 0) {
|
|
|
|
XFree(data);
|
2010-02-01 07:44:27 +00:00
|
|
|
len *= 2;
|
|
|
|
continue;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
if (long(rtype) == type && rformat == format) {
|
|
|
|
int bytelen = format == 8 ? nitems : format == 16 ? nitems * sizeof(short) : nitems * sizeof(long);
|
|
|
|
QByteArray ret(reinterpret_cast< const char* >(data), bytelen);
|
|
|
|
XFree(data);
|
2010-02-01 07:44:27 +00:00
|
|
|
return ret;
|
2011-01-30 14:34:42 +00:00
|
|
|
} else { // wrong format, type or something
|
|
|
|
XFree(data);
|
2010-02-01 07:44:27 +00:00
|
|
|
return QByteArray();
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
} else // XGetWindowProperty() failed
|
2010-02-01 07:44:27 +00:00
|
|
|
return QByteArray();
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-02-01 07:44:27 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
static void deleteWindowProperty(Window win, long int atom)
|
|
|
|
{
|
|
|
|
XDeleteProperty(QX11Info::display(), win, atom);
|
|
|
|
}
|
2010-02-01 07:44:27 +00:00
|
|
|
|
|
|
|
//---------------------
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
EffectsHandlerImpl::EffectsHandlerImpl(CompositingType type)
|
|
|
|
: EffectsHandler(type)
|
2011-01-30 14:34:42 +00:00
|
|
|
, keyboard_grab_effect(NULL)
|
|
|
|
, fullscreen_effect(0)
|
|
|
|
, next_window_quad_type(EFFECT_QUAD_TYPE_START)
|
|
|
|
, mouse_poll_ref_count(0)
|
|
|
|
, current_paint_effectframe(0)
|
|
|
|
{
|
2007-05-28 11:23:00 +00:00
|
|
|
reconfigure();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
EffectsHandlerImpl::~EffectsHandlerImpl()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (keyboard_grab_effect != NULL)
|
2007-04-29 17:35:43 +00:00
|
|
|
ungrabKeyboard();
|
2011-01-30 14:34:42 +00:00
|
|
|
foreach (const EffectPair & ep, loaded_effects)
|
|
|
|
unloadEffect(ep.first);
|
|
|
|
foreach (const InputWindowPair & pos, input_windows)
|
|
|
|
XDestroyWindow(display(), pos.second);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2007-05-28 11:23:00 +00:00
|
|
|
void EffectsHandlerImpl::reconfigure()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-05-28 11:23:00 +00:00
|
|
|
KSharedConfig::Ptr _config = KGlobal::config();
|
|
|
|
KConfigGroup conf(_config, "Plugins");
|
|
|
|
|
|
|
|
KService::List offers = KServiceTypeTrader::self()->query("KWin/Effect");
|
2007-07-21 18:30:06 +00:00
|
|
|
QStringList effectsToBeLoaded;
|
|
|
|
// First unload necessary effects
|
2011-01-30 14:34:42 +00:00
|
|
|
foreach (const KService::Ptr & service, offers) {
|
|
|
|
KPluginInfo plugininfo(service);
|
|
|
|
plugininfo.load(conf);
|
2007-05-28 11:23:00 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
bool isloaded = isEffectLoaded(plugininfo.pluginName());
|
2007-05-29 11:42:47 +00:00
|
|
|
bool shouldbeloaded = plugininfo.isPluginEnabled();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!shouldbeloaded && isloaded)
|
|
|
|
unloadEffect(plugininfo.pluginName());
|
|
|
|
if (shouldbeloaded)
|
|
|
|
effectsToBeLoaded.append(plugininfo.pluginName());
|
|
|
|
}
|
2008-10-02 09:27:32 +00:00
|
|
|
QStringList newLoaded;
|
2007-07-21 18:30:06 +00:00
|
|
|
// Then load those that should be loaded
|
2011-01-30 14:34:42 +00:00
|
|
|
foreach (const QString & effectName, effectsToBeLoaded) {
|
|
|
|
if (!isEffectLoaded(effectName)) {
|
|
|
|
loadEffect(effectName);
|
|
|
|
newLoaded.append(effectName);
|
2008-10-02 09:27:32 +00:00
|
|
|
}
|
2007-05-28 11:23:00 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
foreach (const EffectPair & ep, loaded_effects) {
|
|
|
|
if (!newLoaded.contains(ep.first)) // don't reconfigure newly loaded effects
|
|
|
|
ep.second->reconfigure(Effect::ReconfigureAll);
|
|
|
|
}
|
|
|
|
}
|
2007-05-28 11:23:00 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
// the idea is that effects call this function again which calls the next one
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::prePaintScreen(ScreenPrePaintData& data, int time)
|
|
|
|
{
|
|
|
|
if (current_paint_screen < loaded_effects.size()) {
|
|
|
|
loaded_effects[current_paint_screen++].second->prePaintScreen(data, time);
|
2007-04-29 17:35:43 +00:00
|
|
|
--current_paint_screen;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
// no special final code
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::paintScreen(int mask, QRegion region, ScreenPaintData& data)
|
|
|
|
{
|
|
|
|
if (current_paint_screen < loaded_effects.size()) {
|
|
|
|
loaded_effects[current_paint_screen++].second->paintScreen(mask, region, data);
|
2007-04-29 17:35:43 +00:00
|
|
|
--current_paint_screen;
|
2011-01-30 14:34:42 +00:00
|
|
|
} else
|
|
|
|
scene->finalPaintScreen(mask, region, data);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void EffectsHandlerImpl::postPaintScreen()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (current_paint_screen < loaded_effects.size()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
loaded_effects[current_paint_screen++].second->postPaintScreen();
|
|
|
|
--current_paint_screen;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
// no special final code
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
|
|
|
|
{
|
|
|
|
if (current_paint_window < loaded_effects.size()) {
|
|
|
|
loaded_effects[current_paint_window++].second->prePaintWindow(w, data, time);
|
2007-04-29 17:35:43 +00:00
|
|
|
--current_paint_window;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
// no special final code
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
|
|
|
|
{
|
|
|
|
if (current_paint_window < loaded_effects.size()) {
|
|
|
|
loaded_effects[current_paint_window++].second->paintWindow(w, mask, region, data);
|
2007-04-29 17:35:43 +00:00
|
|
|
--current_paint_window;
|
2011-01-30 14:34:42 +00:00
|
|
|
} else
|
|
|
|
scene->finalPaintWindow(static_cast<EffectWindowImpl*>(w), mask, region, data);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::paintEffectFrame(EffectFrame* frame, QRegion region, double opacity, double frameOpacity)
|
|
|
|
{
|
|
|
|
if (current_paint_effectframe < loaded_effects.size()) {
|
|
|
|
loaded_effects[current_paint_effectframe++].second->paintEffectFrame(frame, region, opacity, frameOpacity);
|
2010-07-24 16:29:16 +00:00
|
|
|
--current_paint_effectframe;
|
2011-01-30 14:34:42 +00:00
|
|
|
} else {
|
|
|
|
const EffectFrameImpl* frameImpl = static_cast<const EffectFrameImpl*>(frame);
|
|
|
|
frameImpl->finalRender(region, opacity, frameOpacity);
|
2010-07-24 16:29:16 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-24 16:29:16 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::postPaintWindow(EffectWindow* w)
|
|
|
|
{
|
|
|
|
if (current_paint_window < loaded_effects.size()) {
|
|
|
|
loaded_effects[current_paint_window++].second->postPaintWindow(w);
|
2007-04-29 17:35:43 +00:00
|
|
|
--current_paint_window;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
// no special final code
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
bool EffectsHandlerImpl::provides(Effect::Feature ef)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < loaded_effects.size(); ++i)
|
|
|
|
if (loaded_effects.at(i).second->provides(ef))
|
2010-04-25 18:40:04 +00:00
|
|
|
return true;
|
|
|
|
return false;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-04-25 18:40:04 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::drawWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
|
|
|
|
{
|
|
|
|
if (current_draw_window < loaded_effects.size()) {
|
|
|
|
loaded_effects[current_draw_window++].second->drawWindow(w, mask, region, data);
|
2007-04-29 17:35:43 +00:00
|
|
|
--current_draw_window;
|
2011-01-30 14:34:42 +00:00
|
|
|
} else
|
|
|
|
scene->finalDrawWindow(static_cast<EffectWindowImpl*>(w), mask, region, data);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::buildQuads(EffectWindow* w, WindowQuadList& quadList)
|
|
|
|
{
|
|
|
|
if (current_build_quads < loaded_effects.size()) {
|
|
|
|
loaded_effects[current_build_quads++].second->buildQuads(w, quadList);
|
2008-10-17 10:30:43 +00:00
|
|
|
--current_build_quads;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-10-17 10:30:43 +00:00
|
|
|
|
|
|
|
bool EffectsHandlerImpl::hasDecorationShadows() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2008-10-17 10:30:43 +00:00
|
|
|
return Workspace::self()->hasDecorationShadows();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-10-17 10:30:43 +00:00
|
|
|
|
2010-03-05 18:21:14 +00:00
|
|
|
bool EffectsHandlerImpl::decorationsHaveAlpha() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2010-03-05 18:21:14 +00:00
|
|
|
return Workspace::self()->decorationHasAlpha();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-03-05 18:21:14 +00:00
|
|
|
|
2010-11-10 18:33:07 +00:00
|
|
|
bool EffectsHandlerImpl::decorationSupportsBlurBehind() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2010-11-10 18:33:07 +00:00
|
|
|
return Workspace::self()->decorationSupportsBlurBehind();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-11-10 18:33:07 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
// start another painting pass
|
|
|
|
void EffectsHandlerImpl::startPaint()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
assert(current_paint_screen == 0);
|
|
|
|
assert(current_paint_window == 0);
|
|
|
|
assert(current_draw_window == 0);
|
|
|
|
assert(current_build_quads == 0);
|
|
|
|
assert(current_transform == 0);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::windowUserMovedResized(EffectWindow* c, bool first, bool last)
|
|
|
|
{
|
|
|
|
foreach (const EffectPair & ep, loaded_effects)
|
|
|
|
ep.second->windowUserMovedResized(c, first, last);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::windowMoveResizeGeometryUpdate(EffectWindow* c, const QRect& geometry)
|
|
|
|
{
|
|
|
|
foreach (const EffectPair & ep, loaded_effects)
|
|
|
|
ep.second->windowMoveResizeGeometryUpdate(c, geometry);
|
|
|
|
}
|
2009-10-30 14:22:33 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::windowOpacityChanged(EffectWindow* c, double old_opacity)
|
|
|
|
{
|
|
|
|
if (!c)
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (static_cast<EffectWindowImpl*>(c)->window()->opacity() == old_opacity)
|
|
|
|
return;
|
|
|
|
foreach (const EffectPair & ep, loaded_effects)
|
|
|
|
ep.second->windowOpacityChanged(c, old_opacity);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::windowAdded(EffectWindow* c)
|
|
|
|
{
|
|
|
|
foreach (const EffectPair & ep, loaded_effects)
|
|
|
|
ep.second->windowAdded(c);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::windowDeleted(EffectWindow* c)
|
|
|
|
{
|
|
|
|
foreach (const EffectPair & ep, loaded_effects)
|
|
|
|
ep.second->windowDeleted(c);
|
|
|
|
elevated_windows.removeAll(c);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::windowClosed(EffectWindow* c)
|
|
|
|
{
|
|
|
|
foreach (const EffectPair & ep, loaded_effects)
|
|
|
|
ep.second->windowClosed(c);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::windowActivated(EffectWindow* c)
|
|
|
|
{
|
|
|
|
foreach (const EffectPair & ep, loaded_effects)
|
|
|
|
ep.second->windowActivated(c);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::windowMinimized(EffectWindow* c)
|
|
|
|
{
|
|
|
|
foreach (const EffectPair & ep, loaded_effects)
|
|
|
|
ep.second->windowMinimized(c);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::windowUnminimized(EffectWindow* c)
|
|
|
|
{
|
|
|
|
foreach (const EffectPair & ep, loaded_effects)
|
|
|
|
ep.second->windowUnminimized(c);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::clientGroupItemSwitched(EffectWindow* from, EffectWindow* to)
|
|
|
|
{
|
|
|
|
foreach (const EffectPair & ep, loaded_effects)
|
|
|
|
ep.second->clientGroupItemSwitched(from, to);
|
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::clientGroupItemAdded(EffectWindow* from, EffectWindow* to)
|
|
|
|
{
|
|
|
|
foreach (const EffectPair & ep, loaded_effects)
|
|
|
|
ep.second->clientGroupItemAdded(from, to);
|
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::clientGroupItemRemoved(EffectWindow* c, EffectWindow* group)
|
|
|
|
{
|
|
|
|
foreach (const EffectPair & ep, loaded_effects)
|
|
|
|
ep.second->clientGroupItemRemoved(c, group);
|
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::desktopChanged(int old)
|
|
|
|
{
|
|
|
|
foreach (const EffectPair & ep, loaded_effects)
|
|
|
|
ep.second->desktopChanged(old);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::windowDamaged(EffectWindow* w, const QRect& r)
|
|
|
|
{
|
|
|
|
if (w == NULL)
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
foreach (const EffectPair & ep, loaded_effects)
|
|
|
|
ep.second->windowDamaged(w, r);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::windowGeometryShapeChanged(EffectWindow* w, const QRect& old)
|
|
|
|
{
|
|
|
|
if (w == NULL) // during late cleanup effectWindow() may be already NULL
|
2007-04-29 17:35:43 +00:00
|
|
|
return; // in some functions that may still call this
|
2011-01-30 14:34:42 +00:00
|
|
|
foreach (const EffectPair & ep, loaded_effects)
|
|
|
|
ep.second->windowGeometryShapeChanged(w, old);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::tabBoxAdded(int mode)
|
|
|
|
{
|
|
|
|
foreach (const EffectPair & ep, loaded_effects)
|
|
|
|
ep.second->tabBoxAdded(mode);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void EffectsHandlerImpl::tabBoxClosed()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
foreach (const EffectPair & ep, loaded_effects)
|
|
|
|
ep.second->tabBoxClosed();
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void EffectsHandlerImpl::tabBoxUpdated()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
foreach (const EffectPair & ep, loaded_effects)
|
|
|
|
ep.second->tabBoxUpdated();
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::tabBoxKeyEvent(QKeyEvent* event)
|
|
|
|
{
|
|
|
|
foreach (const EffectPair & ep, loaded_effects)
|
|
|
|
ep.second->tabBoxKeyEvent(event);
|
|
|
|
}
|
2009-10-30 09:16:41 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::setActiveFullScreenEffect(Effect* e)
|
|
|
|
{
|
2007-11-01 17:47:41 +00:00
|
|
|
fullscreen_effect = e;
|
2009-01-05 12:52:27 +00:00
|
|
|
Workspace::self()->checkUnredirect();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-11-01 17:47:41 +00:00
|
|
|
|
|
|
|
Effect* EffectsHandlerImpl::activeFullScreenEffect() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-11-01 17:47:41 +00:00
|
|
|
return fullscreen_effect;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-11-01 17:47:41 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
bool EffectsHandlerImpl::borderActivated(ElectricBorder border)
|
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
bool ret = false;
|
2011-01-30 14:34:42 +00:00
|
|
|
foreach (const EffectPair & ep, loaded_effects)
|
|
|
|
if (ep.second->borderActivated(border))
|
|
|
|
ret = true; // bail out or tell all?
|
2007-04-29 17:35:43 +00:00
|
|
|
return ret;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::mouseChanged(const QPoint& pos, const QPoint& oldpos,
|
|
|
|
Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons,
|
|
|
|
Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers)
|
|
|
|
{
|
|
|
|
foreach (const EffectPair & ep, loaded_effects)
|
|
|
|
ep.second->mouseChanged(pos, oldpos, buttons, oldbuttons, modifiers, oldmodifiers);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
bool EffectsHandlerImpl::grabKeyboard(Effect* effect)
|
|
|
|
{
|
|
|
|
if (keyboard_grab_effect != NULL)
|
2007-04-29 17:35:43 +00:00
|
|
|
return false;
|
|
|
|
bool ret = grabXKeyboard();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!ret)
|
2007-04-29 17:35:43 +00:00
|
|
|
return false;
|
|
|
|
keyboard_grab_effect = effect;
|
|
|
|
return true;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void EffectsHandlerImpl::ungrabKeyboard()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
assert(keyboard_grab_effect != NULL);
|
2007-04-29 17:35:43 +00:00
|
|
|
ungrabXKeyboard();
|
|
|
|
keyboard_grab_effect = NULL;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::grabbedKeyboardEvent(QKeyEvent* e)
|
|
|
|
{
|
|
|
|
if (keyboard_grab_effect != NULL)
|
|
|
|
keyboard_grab_effect->grabbedKeyboardEvent(e);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void* EffectsHandlerImpl::getProxy(QString name)
|
|
|
|
{
|
2009-02-06 10:15:06 +00:00
|
|
|
// All effects start with "kwin4_effect_", prepend it to the name
|
2011-01-30 14:34:42 +00:00
|
|
|
name.prepend("kwin4_effect_");
|
2009-02-06 10:15:06 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
for (QVector< EffectPair >::iterator it = loaded_effects.begin(); it != loaded_effects.end(); ++it)
|
|
|
|
if ((*it).first == name)
|
2009-02-06 10:15:06 +00:00
|
|
|
return (*it).second->proxy();
|
|
|
|
|
|
|
|
return NULL;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-02-06 10:15:06 +00:00
|
|
|
|
2009-02-01 15:16:52 +00:00
|
|
|
void EffectsHandlerImpl::startMousePolling()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (!mouse_poll_ref_count) // Start timer if required
|
2009-02-01 15:16:52 +00:00
|
|
|
Workspace::self()->startMousePolling();
|
|
|
|
mouse_poll_ref_count++;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-02-01 15:16:52 +00:00
|
|
|
|
|
|
|
void EffectsHandlerImpl::stopMousePolling()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
assert(mouse_poll_ref_count);
|
2009-02-01 15:16:52 +00:00
|
|
|
mouse_poll_ref_count--;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!mouse_poll_ref_count) // Stop timer if required
|
2009-02-01 15:16:52 +00:00
|
|
|
Workspace::self()->stopMousePolling();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-02-01 15:16:52 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
bool EffectsHandlerImpl::hasKeyboardGrab() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return keyboard_grab_effect != NULL;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::propertyNotify(EffectWindow* c, long atom)
|
|
|
|
{
|
|
|
|
if (!registered_atoms.contains(atom))
|
2008-01-02 15:21:33 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
foreach (const EffectPair & ep, loaded_effects)
|
|
|
|
ep.second->propertyNotify(c, atom);
|
|
|
|
}
|
2008-01-02 15:21:33 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::numberDesktopsChanged(int old)
|
|
|
|
{
|
|
|
|
foreach (const EffectPair & ep, loaded_effects)
|
|
|
|
ep.second->numberDesktopsChanged(old);
|
|
|
|
}
|
2010-03-28 09:04:14 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::registerPropertyType(long atom, bool reg)
|
|
|
|
{
|
|
|
|
if (reg)
|
2008-01-02 15:21:33 +00:00
|
|
|
++registered_atoms[ atom ]; // initialized to 0 if not present yet
|
2011-01-30 14:34:42 +00:00
|
|
|
else {
|
|
|
|
if (--registered_atoms[ atom ] == 0)
|
|
|
|
registered_atoms.remove(atom);
|
2008-01-02 15:21:33 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-01-02 15:21:33 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
QByteArray EffectsHandlerImpl::readRootProperty(long atom, long type, int format) const
|
|
|
|
{
|
|
|
|
return readWindowProperty(rootWindow(), atom, type, format);
|
|
|
|
}
|
2010-02-01 07:44:27 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::deleteRootProperty(long atom) const
|
|
|
|
{
|
|
|
|
deleteWindowProperty(rootWindow(), atom);
|
|
|
|
}
|
2010-02-01 07:44:27 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::activateWindow(EffectWindow* c)
|
|
|
|
{
|
|
|
|
if (Client* cl = dynamic_cast< Client* >(static_cast<EffectWindowImpl*>(c)->window()))
|
|
|
|
Workspace::self()->activateClient(cl, true);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
EffectWindow* EffectsHandlerImpl::activeWindow() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return Workspace::self()->activeClient() ? Workspace::self()->activeClient()->effectWindow() : NULL;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::moveWindow(EffectWindow* w, const QPoint& pos, bool snap, double snapAdjust)
|
|
|
|
{
|
|
|
|
Client* cl = dynamic_cast< Client* >(static_cast<EffectWindowImpl*>(w)->window());
|
2009-10-05 04:06:20 +00:00
|
|
|
if (!cl || !cl->isMovable())
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (snap)
|
|
|
|
cl->move(Workspace::self()->adjustClientPosition(cl, pos, true, snapAdjust));
|
|
|
|
else
|
2011-01-30 14:34:42 +00:00
|
|
|
cl->move(pos);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::windowToDesktop(EffectWindow* w, int desktop)
|
|
|
|
{
|
|
|
|
Client* cl = dynamic_cast< Client* >(static_cast<EffectWindowImpl*>(w)->window());
|
|
|
|
if (cl && !cl->isDesktop() && !cl->isDock() && !cl->isTopMenu())
|
|
|
|
Workspace::self()->sendClientToDesktop(cl, desktop, true);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::windowToScreen(EffectWindow* w, int screen)
|
|
|
|
{
|
|
|
|
Client* cl = dynamic_cast< Client* >(static_cast<EffectWindowImpl*>(w)->window());
|
|
|
|
if (cl && !cl->isDesktop() && !cl->isDock() && !cl->isTopMenu())
|
|
|
|
Workspace::self()->sendClientToScreen(cl, screen);
|
|
|
|
}
|
2009-11-19 08:34:28 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::setShowingDesktop(bool showing)
|
|
|
|
{
|
|
|
|
Workspace::self()->setShowingDesktop(showing);
|
|
|
|
}
|
2009-06-28 17:17:29 +00:00
|
|
|
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
int EffectsHandlerImpl::currentDesktop() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return Workspace::self()->currentDesktop();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
int EffectsHandlerImpl::numberOfDesktops() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return Workspace::self()->numberOfDesktops();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::setCurrentDesktop(int desktop)
|
|
|
|
{
|
|
|
|
Workspace::self()->setCurrentDesktop(desktop);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::setNumberOfDesktops(int desktops)
|
|
|
|
{
|
|
|
|
Workspace::self()->setNumberOfDesktops(desktops);
|
|
|
|
}
|
2010-03-28 09:04:14 +00:00
|
|
|
|
2009-02-14 14:49:46 +00:00
|
|
|
QSize EffectsHandlerImpl::desktopGridSize() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-02-14 15:40:52 +00:00
|
|
|
return Workspace::self()->desktopGridSize();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2009-02-14 14:49:46 +00:00
|
|
|
int EffectsHandlerImpl::desktopGridWidth() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-02-14 15:40:52 +00:00
|
|
|
return Workspace::self()->desktopGridWidth();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2009-02-14 14:49:46 +00:00
|
|
|
int EffectsHandlerImpl::desktopGridHeight() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-02-14 15:40:52 +00:00
|
|
|
return Workspace::self()->desktopGridHeight();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2009-02-14 14:49:46 +00:00
|
|
|
int EffectsHandlerImpl::workspaceWidth() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-02-14 15:40:52 +00:00
|
|
|
return Workspace::self()->workspaceWidth();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-02-14 14:49:46 +00:00
|
|
|
|
|
|
|
int EffectsHandlerImpl::workspaceHeight() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-02-14 15:40:52 +00:00
|
|
|
return Workspace::self()->workspaceHeight();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-02-14 14:49:46 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
int EffectsHandlerImpl::desktopAtCoords(QPoint coords) const
|
|
|
|
{
|
|
|
|
return Workspace::self()->desktopAtCoords(coords);
|
|
|
|
}
|
2009-02-14 14:49:46 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
QPoint EffectsHandlerImpl::desktopGridCoords(int id) const
|
|
|
|
{
|
|
|
|
return Workspace::self()->desktopGridCoords(id);
|
|
|
|
}
|
2009-02-14 14:49:46 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
QPoint EffectsHandlerImpl::desktopCoords(int id) const
|
|
|
|
{
|
|
|
|
return Workspace::self()->desktopCoords(id);
|
|
|
|
}
|
2009-02-14 14:49:46 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
int EffectsHandlerImpl::desktopAbove(int desktop, bool wrap) const
|
|
|
|
{
|
|
|
|
return Workspace::self()->desktopAbove(desktop, wrap);
|
|
|
|
}
|
2007-11-20 16:17:08 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
int EffectsHandlerImpl::desktopToRight(int desktop, bool wrap) const
|
|
|
|
{
|
|
|
|
return Workspace::self()->desktopToRight(desktop, wrap);
|
|
|
|
}
|
2007-11-20 16:17:08 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
int EffectsHandlerImpl::desktopBelow(int desktop, bool wrap) const
|
|
|
|
{
|
|
|
|
return Workspace::self()->desktopBelow(desktop, wrap);
|
|
|
|
}
|
2007-11-20 16:17:08 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
int EffectsHandlerImpl::desktopToLeft(int desktop, bool wrap) const
|
|
|
|
{
|
|
|
|
return Workspace::self()->desktopToLeft(desktop, wrap);
|
|
|
|
}
|
2009-02-14 14:49:46 +00:00
|
|
|
|
2009-02-14 15:40:52 +00:00
|
|
|
bool EffectsHandlerImpl::isDesktopLayoutDynamic() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-02-14 15:40:52 +00:00
|
|
|
return Workspace::self()->isDesktopLayoutDynamic();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-02-14 14:49:46 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
int EffectsHandlerImpl::addDesktop(QPoint coords)
|
|
|
|
{
|
|
|
|
return Workspace::self()->addDesktop(coords);
|
|
|
|
}
|
2009-02-14 14:49:46 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::deleteDesktop(int id)
|
|
|
|
{
|
|
|
|
Workspace::self()->deleteDesktop(id);
|
|
|
|
}
|
2009-02-14 14:49:46 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
QString EffectsHandlerImpl::desktopName(int desktop) const
|
|
|
|
{
|
|
|
|
return Workspace::self()->desktopName(desktop);
|
|
|
|
}
|
2009-02-14 14:49:46 +00:00
|
|
|
|
|
|
|
bool EffectsHandlerImpl::optionRollOverDesktops() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-02-14 14:49:46 +00:00
|
|
|
return options->rollOverDesktops;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-11-20 16:17:08 +00:00
|
|
|
|
2008-08-30 07:25:54 +00:00
|
|
|
double EffectsHandlerImpl::animationTimeFactor() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2008-08-30 07:25:54 +00:00
|
|
|
return options->animationTimeFactor();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-08-30 07:25:54 +00:00
|
|
|
|
2008-10-17 10:30:43 +00:00
|
|
|
WindowQuadType EffectsHandlerImpl::newWindowQuadType()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
return WindowQuadType(next_window_quad_type++);
|
|
|
|
}
|
2008-10-17 10:30:43 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
int EffectsHandlerImpl::displayWidth() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return KWin::displayWidth();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
int EffectsHandlerImpl::displayHeight() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return KWin::displayWidth();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
EffectWindow* EffectsHandlerImpl::findWindow(WId id) const
|
|
|
|
{
|
|
|
|
if (Client* w = Workspace::self()->findClient(WindowMatchPredicate(id)))
|
2008-01-02 15:37:46 +00:00
|
|
|
return w->effectWindow();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (Unmanaged* w = Workspace::self()->findUnmanaged(WindowMatchPredicate(id)))
|
2008-01-02 15:37:46 +00:00
|
|
|
return w->effectWindow();
|
|
|
|
return NULL;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-01-02 15:37:46 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
EffectWindowList EffectsHandlerImpl::stackingOrder() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
ClientList list = Workspace::self()->stackingOrder();
|
|
|
|
EffectWindowList ret;
|
2011-01-30 14:34:42 +00:00
|
|
|
foreach (Client * c, list)
|
|
|
|
ret.append(effectWindow(c));
|
2007-04-29 17:35:43 +00:00
|
|
|
return ret;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::setElevatedWindow(EffectWindow* w, bool set)
|
|
|
|
{
|
|
|
|
elevated_windows.removeAll(w);
|
|
|
|
if (set)
|
|
|
|
elevated_windows.append(w);
|
|
|
|
}
|
2007-05-24 14:41:56 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
void EffectsHandlerImpl::setTabBoxWindow(EffectWindow* w)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (Client* c = dynamic_cast< Client* >(static_cast< EffectWindowImpl* >(w)->window()))
|
|
|
|
Workspace::self()->setTabBoxClient(c);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void EffectsHandlerImpl::setTabBoxDesktop(int desktop)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
Workspace::self()->setTabBoxDesktop(desktop);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
EffectWindowList EffectsHandlerImpl::currentTabBoxWindowList() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
EffectWindowList ret;
|
|
|
|
ClientList clients = Workspace::self()->currentTabBoxClientList();
|
2011-01-30 14:34:42 +00:00
|
|
|
foreach (Client * c, clients)
|
|
|
|
ret.append(c->effectWindow());
|
2007-04-29 17:35:43 +00:00
|
|
|
return ret;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void EffectsHandlerImpl::refTabBox()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
Workspace::self()->refTabBox();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void EffectsHandlerImpl::unrefTabBox()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
Workspace::self()->unrefTabBox();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void EffectsHandlerImpl::closeTabBox()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
Workspace::self()->closeTabBox();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
QList< int > EffectsHandlerImpl::currentTabBoxDesktopList() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return Workspace::self()->currentTabBoxDesktopList();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
int EffectsHandlerImpl::currentTabBoxDesktop() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return Workspace::self()->currentTabBoxDesktop();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
EffectWindow* EffectsHandlerImpl::currentTabBoxWindow() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (Client* c = Workspace::self()->currentTabBoxClient())
|
2007-04-29 17:35:43 +00:00
|
|
|
return c->effectWindow();
|
|
|
|
return NULL;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void EffectsHandlerImpl::pushRenderTarget(GLRenderTarget* target)
|
|
|
|
{
|
2007-12-17 14:14:53 +00:00
|
|
|
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
|
2007-04-29 17:35:43 +00:00
|
|
|
target->enable();
|
|
|
|
render_targets.push(target);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
GLRenderTarget* EffectsHandlerImpl::popRenderTarget()
|
|
|
|
{
|
2007-12-17 14:14:53 +00:00
|
|
|
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
|
2007-04-29 17:35:43 +00:00
|
|
|
GLRenderTarget* ret = render_targets.pop();
|
|
|
|
ret->disable();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!render_targets.isEmpty())
|
2007-04-29 17:35:43 +00:00
|
|
|
render_targets.top()->enable();
|
|
|
|
return ret;
|
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2010-11-01 12:09:53 +00:00
|
|
|
bool EffectsHandlerImpl::isRenderTargetBound()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2010-11-01 12:09:53 +00:00
|
|
|
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
|
|
|
|
return !render_targets.isEmpty();
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-11-01 12:09:53 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
void EffectsHandlerImpl::addRepaintFull()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
Workspace::self()->addRepaintFull();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::addRepaint(const QRect& r)
|
|
|
|
{
|
|
|
|
Workspace::self()->addRepaint(r);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::addRepaint(const QRegion& r)
|
|
|
|
{
|
|
|
|
Workspace::self()->addRepaint(r);
|
|
|
|
}
|
2008-06-19 14:16:21 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::addRepaint(int x, int y, int w, int h)
|
|
|
|
{
|
|
|
|
Workspace::self()->addRepaint(x, y, w, h);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2007-11-20 18:58:30 +00:00
|
|
|
int EffectsHandlerImpl::activeScreen() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-11-20 18:58:30 +00:00
|
|
|
return Workspace::self()->activeScreen();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-11-20 18:58:30 +00:00
|
|
|
|
2008-06-09 16:09:56 +00:00
|
|
|
int EffectsHandlerImpl::numScreens() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2008-06-09 16:09:56 +00:00
|
|
|
return Workspace::self()->numScreens();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-06-09 16:09:56 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
int EffectsHandlerImpl::screenNumber(const QPoint& pos) const
|
|
|
|
{
|
|
|
|
return Workspace::self()->screenNumber(pos);
|
|
|
|
}
|
2008-06-19 14:16:21 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
QRect EffectsHandlerImpl::clientArea(clientAreaOption opt, int screen, int desktop) const
|
|
|
|
{
|
|
|
|
return Workspace::self()->clientArea(opt, screen, desktop);
|
|
|
|
}
|
2007-11-20 18:58:30 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
QRect EffectsHandlerImpl::clientArea(clientAreaOption opt, const EffectWindow* c) const
|
|
|
|
{
|
2007-11-20 18:58:30 +00:00
|
|
|
const Toplevel* t = static_cast< const EffectWindowImpl* >(c)->window();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (const Client* cl = dynamic_cast< const Client* >(t))
|
|
|
|
return Workspace::self()->clientArea(opt, cl);
|
2007-11-20 18:58:30 +00:00
|
|
|
else
|
2011-01-30 14:34:42 +00:00
|
|
|
return Workspace::self()->clientArea(opt, t->geometry().center(), Workspace::self()->currentDesktop());
|
|
|
|
}
|
2007-11-20 18:58:30 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
QRect EffectsHandlerImpl::clientArea(clientAreaOption opt, const QPoint& p, int desktop) const
|
|
|
|
{
|
|
|
|
return Workspace::self()->clientArea(opt, p, desktop);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
Window EffectsHandlerImpl::createInputWindow(Effect* e, int x, int y, int w, int h, const QCursor& cursor)
|
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
XSetWindowAttributes attrs;
|
|
|
|
attrs.override_redirect = True;
|
2011-01-30 14:34:42 +00:00
|
|
|
Window win = XCreateWindow(display(), rootWindow(), x, y, w, h, 0, 0, InputOnly, CopyFromParent,
|
|
|
|
CWOverrideRedirect, &attrs);
|
2007-04-29 17:35:43 +00:00
|
|
|
// TODO keeping on top?
|
|
|
|
// TODO enter/leave notify?
|
2011-01-30 14:34:42 +00:00
|
|
|
XSelectInput(display(), win, ButtonPressMask | ButtonReleaseMask | PointerMotionMask);
|
|
|
|
XDefineCursor(display(), win, cursor.handle());
|
|
|
|
XMapWindow(display(), win);
|
|
|
|
input_windows.append(qMakePair(e, win));
|
2009-02-06 14:21:20 +00:00
|
|
|
|
|
|
|
// Raise electric border windows above the input windows
|
|
|
|
// so they can still be triggered.
|
|
|
|
Workspace::self()->raiseElectricBorderWindows();
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
return win;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::destroyInputWindow(Window w)
|
|
|
|
{
|
|
|
|
foreach (const InputWindowPair & pos, input_windows) {
|
|
|
|
if (pos.second == w) {
|
|
|
|
input_windows.removeAll(pos);
|
|
|
|
XDestroyWindow(display(), w);
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
abort();
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
bool EffectsHandlerImpl::checkInputWindowEvent(XEvent* e)
|
|
|
|
{
|
|
|
|
if (e->type != ButtonPress && e->type != ButtonRelease && e->type != MotionNotify)
|
2007-04-29 17:35:43 +00:00
|
|
|
return false;
|
2011-01-30 14:34:42 +00:00
|
|
|
foreach (const InputWindowPair & pos, input_windows) {
|
|
|
|
if (pos.second == e->xany.window) {
|
|
|
|
switch(e->type) {
|
|
|
|
case ButtonPress: {
|
|
|
|
XButtonEvent* e2 = &e->xbutton;
|
|
|
|
Qt::MouseButton button = x11ToQtMouseButton(e2->button);
|
|
|
|
Qt::MouseButtons buttons = x11ToQtMouseButtons(e2->state) | button;
|
|
|
|
QMouseEvent ev(QEvent::MouseButtonPress,
|
|
|
|
QPoint(e2->x, e2->y), QPoint(e2->x_root, e2->y_root),
|
|
|
|
button, buttons, x11ToQtKeyboardModifiers(e2->state));
|
|
|
|
pos.first->windowInputMouseEvent(pos.second, &ev);
|
|
|
|
break; // --->
|
|
|
|
}
|
|
|
|
case ButtonRelease: {
|
|
|
|
XButtonEvent* e2 = &e->xbutton;
|
|
|
|
Qt::MouseButton button = x11ToQtMouseButton(e2->button);
|
|
|
|
Qt::MouseButtons buttons = x11ToQtMouseButtons(e2->state) & ~button;
|
|
|
|
QMouseEvent ev(QEvent::MouseButtonRelease,
|
|
|
|
QPoint(e2->x, e2->y), QPoint(e2->x_root, e2->y_root),
|
|
|
|
button, buttons, x11ToQtKeyboardModifiers(e2->state));
|
|
|
|
pos.first->windowInputMouseEvent(pos.second, &ev);
|
|
|
|
break; // --->
|
|
|
|
}
|
|
|
|
case MotionNotify: {
|
|
|
|
XMotionEvent* e2 = &e->xmotion;
|
|
|
|
QMouseEvent ev(QEvent::MouseMove, QPoint(e2->x, e2->y), QPoint(e2->x_root, e2->y_root),
|
|
|
|
Qt::NoButton, x11ToQtMouseButtons(e2->state), x11ToQtKeyboardModifiers(e2->state));
|
|
|
|
pos.first->windowInputMouseEvent(pos.second, &ev);
|
|
|
|
break; // --->
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
return true; // eat event
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
return false;
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void EffectsHandlerImpl::checkInputWindowStacking()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (input_windows.count() == 0)
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
Window* wins = new Window[ input_windows.count()];
|
2007-04-29 17:35:43 +00:00
|
|
|
int pos = 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
foreach (const InputWindowPair & it, input_windows)
|
|
|
|
wins[ pos++ ] = it.second;
|
|
|
|
XRaiseWindow(display(), wins[ 0 ]);
|
|
|
|
XRestackWindows(display(), wins, pos);
|
2007-04-29 17:35:43 +00:00
|
|
|
delete[] wins;
|
2009-02-06 14:21:20 +00:00
|
|
|
// Raise electric border windows above the input windows
|
|
|
|
// so they can still be triggered. TODO: Do both at once.
|
|
|
|
Workspace::self()->raiseElectricBorderWindows();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
QPoint EffectsHandlerImpl::cursorPos() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return Workspace::self()->cursorPos();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void EffectsHandlerImpl::checkElectricBorder(const QPoint &pos, Time time)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
Workspace::self()->checkElectricBorder(pos, time);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::reserveElectricBorder(ElectricBorder border)
|
|
|
|
{
|
|
|
|
Workspace::self()->reserveElectricBorder(border);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::unreserveElectricBorder(ElectricBorder border)
|
|
|
|
{
|
|
|
|
Workspace::self()->unreserveElectricBorder(border);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::reserveElectricBorderSwitching(bool reserve)
|
|
|
|
{
|
|
|
|
Workspace::self()->reserveElectricBorderSwitching(reserve);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
unsigned long EffectsHandlerImpl::xrenderBufferPicture()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-12-17 14:14:53 +00:00
|
|
|
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
2011-01-30 14:34:42 +00:00
|
|
|
if (SceneXrender* s = dynamic_cast< SceneXrender* >(scene))
|
2007-04-29 17:35:43 +00:00
|
|
|
return s->bufferPicture();
|
|
|
|
#endif
|
|
|
|
return None;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
KLibrary* EffectsHandlerImpl::findEffectLibrary(KService* service)
|
|
|
|
{
|
2007-07-06 12:38:41 +00:00
|
|
|
QString libname = service->library();
|
2009-10-05 09:47:13 +00:00
|
|
|
KLibrary* library = new KLibrary(libname);
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!library) {
|
|
|
|
kError(1212) << "couldn't open library for effect '" <<
|
|
|
|
service->name() << "'" << endl;
|
2007-04-29 17:35:43 +00:00
|
|
|
return 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
return library;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::toggleEffect(const QString& name)
|
|
|
|
{
|
|
|
|
if (isEffectLoaded(name))
|
|
|
|
unloadEffect(name);
|
2007-05-29 11:42:47 +00:00
|
|
|
else
|
2011-01-30 14:34:42 +00:00
|
|
|
loadEffect(name);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-06-10 09:32:46 +00:00
|
|
|
QStringList EffectsHandlerImpl::loadedEffects() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2008-06-10 09:32:46 +00:00
|
|
|
QStringList listModules;
|
2011-01-30 14:34:42 +00:00
|
|
|
for (QVector< EffectPair >::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) {
|
|
|
|
listModules << (*it).first;
|
2008-06-02 19:52:02 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
return listModules;
|
|
|
|
}
|
2008-06-02 19:52:02 +00:00
|
|
|
|
2008-06-10 09:32:46 +00:00
|
|
|
QStringList EffectsHandlerImpl::listOfEffects() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2008-06-10 09:32:46 +00:00
|
|
|
KService::List offers = KServiceTypeTrader::self()->query("KWin/Effect");
|
|
|
|
QStringList listOfModules;
|
|
|
|
// First unload necessary effects
|
2011-01-30 14:34:42 +00:00
|
|
|
foreach (const KService::Ptr & service, offers) {
|
|
|
|
KPluginInfo plugininfo(service);
|
|
|
|
listOfModules << plugininfo.pluginName();
|
2008-06-02 20:05:17 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
return listOfModules;
|
|
|
|
}
|
2008-06-02 20:05:17 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
bool EffectsHandlerImpl::loadEffect(const QString& name)
|
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
Workspace::self()->addRepaintFull();
|
2011-01-30 14:34:42 +00:00
|
|
|
assert(current_paint_screen == 0);
|
|
|
|
assert(current_paint_window == 0);
|
|
|
|
assert(current_draw_window == 0);
|
|
|
|
assert(current_build_quads == 0);
|
|
|
|
assert(current_transform == 0);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!name.startsWith(QLatin1String("kwin4_effect_")))
|
|
|
|
kWarning(1212) << "Effect names usually have kwin4_effect_ prefix" ;
|
2007-05-28 11:12:20 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
// Make sure a single effect won't be loaded multiple times
|
2011-01-30 14:34:42 +00:00
|
|
|
for (QVector< EffectPair >::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) {
|
|
|
|
if ((*it).first == name) {
|
|
|
|
kDebug(1212) << "EffectsHandler::loadEffect : Effect already loaded : " << name;
|
2007-07-20 21:13:10 +00:00
|
|
|
return true;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
kDebug(1212) << "Trying to load " << name;
|
2007-07-06 12:38:41 +00:00
|
|
|
QString internalname = name.toLower();
|
|
|
|
|
|
|
|
QString constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg(internalname);
|
|
|
|
KService::List offers = KServiceTypeTrader::self()->query("KWin/Effect", constraint);
|
2011-01-30 14:34:42 +00:00
|
|
|
if (offers.isEmpty()) {
|
|
|
|
kError(1212) << "Couldn't find effect " << name << endl;
|
2007-07-20 21:13:10 +00:00
|
|
|
return false;
|
2007-07-06 12:38:41 +00:00
|
|
|
}
|
2007-07-21 18:30:06 +00:00
|
|
|
KService::Ptr service = offers.first();
|
2007-07-06 12:38:41 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
KLibrary* library = findEffectLibrary(service.data());
|
|
|
|
if (!library) {
|
2007-07-20 21:13:10 +00:00
|
|
|
return false;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2007-12-17 14:10:21 +00:00
|
|
|
QString version_symbol = "effect_version_" + name;
|
|
|
|
KLibrary::void_function_ptr version_func = library->resolveFunction(version_symbol.toAscii());
|
2011-01-30 14:34:42 +00:00
|
|
|
if (version_func == NULL) {
|
|
|
|
kWarning(1212) << "Effect " << name << " does not provide required API version, ignoring.";
|
2007-12-17 14:10:21 +00:00
|
|
|
return false;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-12-17 14:10:21 +00:00
|
|
|
typedef int (*t_versionfunc)();
|
2011-01-30 14:34:42 +00:00
|
|
|
int version = reinterpret_cast< t_versionfunc >(version_func)(); // call it
|
2008-01-02 15:17:58 +00:00
|
|
|
// Version must be the same or less, but major must be the same.
|
2008-01-02 15:18:34 +00:00
|
|
|
// With major 0 minor must match exactly.
|
2011-01-30 14:34:42 +00:00
|
|
|
if (version > KWIN_EFFECT_API_VERSION
|
|
|
|
|| (version >> 8) != KWIN_EFFECT_API_VERSION_MAJOR
|
|
|
|
|| (KWIN_EFFECT_API_VERSION_MAJOR == 0 && version != KWIN_EFFECT_API_VERSION)) {
|
|
|
|
kWarning(1212) << "Effect " << name << " requires unsupported API version " << version;
|
2007-12-17 14:10:21 +00:00
|
|
|
return false;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
QString supported_symbol = "effect_supported_" + name;
|
|
|
|
KLibrary::void_function_ptr supported_func = library->resolveFunction(supported_symbol.toAscii().data());
|
|
|
|
QString create_symbol = "effect_create_" + name;
|
|
|
|
KLibrary::void_function_ptr create_func = library->resolveFunction(create_symbol.toAscii().data());
|
2011-01-30 14:34:42 +00:00
|
|
|
if (supported_func) {
|
2007-04-29 17:35:43 +00:00
|
|
|
typedef bool (*t_supportedfunc)();
|
|
|
|
t_supportedfunc supported = reinterpret_cast<t_supportedfunc>(supported_func);
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!supported()) {
|
|
|
|
kWarning(1212) << "EffectsHandler::loadEffect : Effect " << name << " is not supported" ;
|
2007-04-29 17:35:43 +00:00
|
|
|
library->unload();
|
2007-07-20 21:13:10 +00:00
|
|
|
return false;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
if (!create_func) {
|
|
|
|
kError(1212) << "EffectsHandler::loadEffect : effect_create function not found" << endl;
|
2007-04-29 17:35:43 +00:00
|
|
|
library->unload();
|
2007-07-20 21:13:10 +00:00
|
|
|
return false;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
typedef Effect*(*t_createfunc)();
|
2007-04-29 17:35:43 +00:00
|
|
|
t_createfunc create = reinterpret_cast<t_createfunc>(create_func);
|
|
|
|
|
2007-07-21 18:30:06 +00:00
|
|
|
// Make sure all depenedencies have been loaded
|
|
|
|
// TODO: detect circular deps
|
2011-01-30 14:34:42 +00:00
|
|
|
KPluginInfo plugininfo(service);
|
2007-07-21 18:30:06 +00:00
|
|
|
QStringList dependencies = plugininfo.dependencies();
|
2011-01-30 14:34:42 +00:00
|
|
|
foreach (const QString & depName, dependencies) {
|
|
|
|
if (!loadEffect(depName)) {
|
2008-11-17 15:04:52 +00:00
|
|
|
kError(1212) << "EffectsHandler::loadEffect : Couldn't load dependencies for effect " << name << endl;
|
2007-07-21 18:30:06 +00:00
|
|
|
library->unload();
|
|
|
|
return false;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-07-21 18:30:06 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
Effect* e = create();
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
effect_order.insert(service->property("X-KDE-Ordering").toInt(), EffectPair(name, e));
|
2007-07-06 12:38:41 +00:00
|
|
|
effectsChanged();
|
2007-04-29 17:35:43 +00:00
|
|
|
effect_libraries[ name ] = library;
|
2007-07-20 21:13:10 +00:00
|
|
|
|
|
|
|
return true;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::unloadEffect(const QString& name)
|
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
Workspace::self()->addRepaintFull();
|
2011-01-30 14:34:42 +00:00
|
|
|
assert(current_paint_screen == 0);
|
|
|
|
assert(current_paint_window == 0);
|
|
|
|
assert(current_draw_window == 0);
|
|
|
|
assert(current_build_quads == 0);
|
|
|
|
assert(current_transform == 0);
|
|
|
|
|
|
|
|
for (QMap< int, EffectPair >::iterator it = effect_order.begin(); it != effect_order.end(); ++it) {
|
|
|
|
if (it.value().first == name) {
|
|
|
|
kDebug(1212) << "EffectsHandler::unloadEffect : Unloading Effect : " << name;
|
|
|
|
if (activeFullScreenEffect() == it.value().second) {
|
|
|
|
setActiveFullScreenEffect(0);
|
|
|
|
}
|
2007-07-06 12:38:41 +00:00
|
|
|
delete it.value().second;
|
|
|
|
effect_order.erase(it);
|
|
|
|
effectsChanged();
|
2007-04-29 17:35:43 +00:00
|
|
|
effect_libraries[ name ]->unload();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
kDebug(1212) << "EffectsHandler::unloadEffect : Effect not loaded : " << name;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::reconfigureEffect(const QString& name)
|
|
|
|
{
|
|
|
|
for (QVector< EffectPair >::iterator it = loaded_effects.begin(); it != loaded_effects.end(); ++it)
|
|
|
|
if ((*it).first == name) {
|
|
|
|
(*it).second->reconfigure(Effect::ReconfigureAll);
|
2008-10-02 09:27:32 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
}
|
2007-05-29 11:42:47 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
bool EffectsHandlerImpl::isEffectLoaded(const QString& name)
|
|
|
|
{
|
|
|
|
for (QVector< EffectPair >::iterator it = loaded_effects.begin(); it != loaded_effects.end(); ++it)
|
|
|
|
if ((*it).first == name)
|
2007-05-29 11:42:47 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-05-29 11:42:47 +00:00
|
|
|
|
2007-07-06 12:38:41 +00:00
|
|
|
void EffectsHandlerImpl::effectsChanged()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-07-06 12:38:41 +00:00
|
|
|
loaded_effects.clear();
|
2008-01-18 15:11:43 +00:00
|
|
|
// kDebug(1212) << "Recreating effects' list:";
|
2011-01-30 14:34:42 +00:00
|
|
|
foreach (const EffectPair & effect, effect_order) {
|
2008-01-18 15:11:43 +00:00
|
|
|
// kDebug(1212) << effect.first;
|
2011-01-30 14:34:42 +00:00
|
|
|
loaded_effects.append(effect);
|
2007-07-06 12:38:41 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-07-06 12:38:41 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
EffectFrame* EffectsHandlerImpl::effectFrame(EffectFrameStyle style, bool staticSize, const QPoint& position, Qt::Alignment alignment) const
|
|
|
|
{
|
|
|
|
return new EffectFrameImpl(style, staticSize, position, alignment);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
//****************************************
|
|
|
|
// EffectWindowImpl
|
|
|
|
//****************************************
|
|
|
|
|
|
|
|
EffectWindowImpl::EffectWindowImpl() : EffectWindow()
|
2011-01-30 14:34:42 +00:00
|
|
|
, toplevel(NULL)
|
|
|
|
, sw(NULL)
|
|
|
|
{
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
EffectWindowImpl::~EffectWindowImpl()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
QVariant cachedTextureVariant = data(LanczosCacheRole);
|
|
|
|
if (cachedTextureVariant.isValid()) {
|
2010-11-01 10:46:11 +00:00
|
|
|
GLTexture *cachedTexture = static_cast< GLTexture*>(cachedTextureVariant.value<void*>());
|
|
|
|
delete cachedTexture;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool EffectWindowImpl::isPaintingEnabled()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return sceneWindow()->isPaintingEnabled();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectWindowImpl::enablePainting(int reason)
|
|
|
|
{
|
|
|
|
sceneWindow()->enablePainting(reason);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectWindowImpl::disablePainting(int reason)
|
|
|
|
{
|
|
|
|
sceneWindow()->disablePainting(reason);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectWindowImpl::addRepaint(const QRect& r)
|
|
|
|
{
|
|
|
|
toplevel->addRepaint(r);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectWindowImpl::addRepaint(int x, int y, int w, int h)
|
|
|
|
{
|
|
|
|
toplevel->addRepaint(x, y, w, h);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void EffectWindowImpl::addRepaintFull()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
toplevel->addRepaintFull();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
int EffectWindowImpl::desktop() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return toplevel->desktop();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool EffectWindowImpl::isOnAllDesktops() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return desktop() == NET::OnAllDesktops;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
QString EffectWindowImpl::caption() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (Client* c = dynamic_cast<Client*>(toplevel))
|
2007-04-29 17:35:43 +00:00
|
|
|
return c->caption();
|
|
|
|
else
|
|
|
|
return "";
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
QString EffectWindowImpl::windowClass() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return toplevel->resourceName() + ' ' + toplevel->resourceClass();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2007-11-13 19:59:53 +00:00
|
|
|
QString EffectWindowImpl::windowRole() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-11-13 19:59:53 +00:00
|
|
|
return toplevel->windowRole();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-11-13 19:59:53 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
QPixmap EffectWindowImpl::icon() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (Client* c = dynamic_cast<Client*>(toplevel))
|
2007-04-29 17:35:43 +00:00
|
|
|
return c->icon();
|
|
|
|
return QPixmap(); // TODO
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
const EffectWindowGroup* EffectWindowImpl::group() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (Client* c = dynamic_cast< Client* >(toplevel))
|
2007-04-29 17:35:43 +00:00
|
|
|
return c->group()->effectGroup();
|
|
|
|
return NULL; // TODO
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool EffectWindowImpl::isMinimized() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (Client* c = dynamic_cast<Client*>(toplevel))
|
2007-04-29 17:35:43 +00:00
|
|
|
return c->isMinimized();
|
|
|
|
else
|
|
|
|
return false;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2007-09-03 15:00:43 +00:00
|
|
|
double EffectWindowImpl::opacity() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return toplevel->opacity();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2009-02-08 15:47:37 +00:00
|
|
|
bool EffectWindowImpl::hasAlpha() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-02-08 15:47:37 +00:00
|
|
|
return toplevel->hasAlpha();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-02-08 15:47:37 +00:00
|
|
|
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
bool EffectWindowImpl::isDeleted() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
return (dynamic_cast<Deleted*>(toplevel) != 0);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void EffectWindowImpl::refWindow()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (Deleted* d = dynamic_cast< Deleted* >(toplevel))
|
2007-04-29 17:35:43 +00:00
|
|
|
return d->refWindow();
|
|
|
|
abort(); // TODO
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void EffectWindowImpl::unrefWindow()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (Deleted* d = dynamic_cast< Deleted* >(toplevel))
|
|
|
|
return d->unrefWindow(true); // delayed
|
2007-04-29 17:35:43 +00:00
|
|
|
abort(); // TODO
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectWindowImpl::setWindow(Toplevel* w)
|
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
toplevel = w;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectWindowImpl::setSceneWindow(Scene::Window* w)
|
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
sw = w;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
int EffectWindowImpl::x() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return toplevel->x();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
int EffectWindowImpl::y() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return toplevel->y();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
int EffectWindowImpl::width() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return toplevel->width();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
int EffectWindowImpl::height() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return toplevel->height();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
QRect EffectWindowImpl::geometry() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return toplevel->geometry();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2007-12-07 18:03:24 +00:00
|
|
|
QRegion EffectWindowImpl::shape() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-12-07 18:03:24 +00:00
|
|
|
return sw ? sw->shape() : geometry();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-12-07 18:03:24 +00:00
|
|
|
|
2008-06-09 16:09:56 +00:00
|
|
|
int EffectWindowImpl::screen() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2008-06-09 16:09:56 +00:00
|
|
|
return toplevel->screen();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-06-09 16:09:56 +00:00
|
|
|
|
2008-01-03 19:39:18 +00:00
|
|
|
bool EffectWindowImpl::hasOwnShape() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2008-01-03 19:39:18 +00:00
|
|
|
return toplevel->shape();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-01-03 19:39:18 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
QSize EffectWindowImpl::size() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return toplevel->size();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
QPoint EffectWindowImpl::pos() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return toplevel->pos();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
QRect EffectWindowImpl::rect() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return toplevel->rect();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2007-07-19 13:32:46 +00:00
|
|
|
QRect EffectWindowImpl::contentsRect() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
return QRect(toplevel->clientPos(), toplevel->clientSize());
|
|
|
|
}
|
2007-07-19 13:32:46 +00:00
|
|
|
|
2010-03-12 16:33:01 +00:00
|
|
|
QRect EffectWindowImpl::decorationInnerRect() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2010-03-12 16:33:01 +00:00
|
|
|
Client *client = dynamic_cast<Client*>(toplevel);
|
|
|
|
return client ? client->transparentRect() : contentsRect();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-03-12 16:33:01 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
QByteArray EffectWindowImpl::readProperty(long atom, long type, int format) const
|
|
|
|
{
|
|
|
|
return readWindowProperty(window()->window(), atom, type, format);
|
|
|
|
}
|
2008-01-02 15:21:33 +00:00
|
|
|
|
2009-06-27 10:21:49 +00:00
|
|
|
void EffectWindowImpl::deleteProperty(long int atom) const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
deleteWindowProperty(window()->window(), atom);
|
|
|
|
}
|
2009-06-27 10:21:49 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
bool EffectWindowImpl::isMovable() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (Client* c = dynamic_cast< Client* >(toplevel))
|
2007-04-29 17:35:43 +00:00
|
|
|
return c->isMovable();
|
|
|
|
return false;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-07-25 10:31:47 +00:00
|
|
|
bool EffectWindowImpl::isMovableAcrossScreens() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (Client* c = dynamic_cast< Client* >(toplevel))
|
2008-07-25 10:31:47 +00:00
|
|
|
return c->isMovableAcrossScreens();
|
|
|
|
return false;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-07-25 10:31:47 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
bool EffectWindowImpl::isUserMove() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (Client* c = dynamic_cast< Client* >(toplevel))
|
2007-04-29 17:35:43 +00:00
|
|
|
return c->isMove();
|
|
|
|
return false;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool EffectWindowImpl::isUserResize() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (Client* c = dynamic_cast< Client* >(toplevel))
|
2007-04-29 17:35:43 +00:00
|
|
|
return c->isResize();
|
|
|
|
return false;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
QRect EffectWindowImpl::iconGeometry() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (Client* c = dynamic_cast< Client* >(toplevel))
|
2007-04-29 17:35:43 +00:00
|
|
|
return c->iconGeometry();
|
|
|
|
return QRect();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool EffectWindowImpl::isDesktop() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return toplevel->isDesktop();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool EffectWindowImpl::isDock() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return toplevel->isDock();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool EffectWindowImpl::isToolbar() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return toplevel->isToolbar();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool EffectWindowImpl::isTopMenu() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return toplevel->isTopMenu();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool EffectWindowImpl::isMenu() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return toplevel->isMenu();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool EffectWindowImpl::isNormalWindow() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return toplevel->isNormalWindow();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool EffectWindowImpl::isSpecialWindow() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (Client* c = dynamic_cast<Client*>(toplevel))
|
2007-04-29 17:35:43 +00:00
|
|
|
return c->isSpecialWindow();
|
|
|
|
else
|
2008-01-02 15:17:58 +00:00
|
|
|
return true;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool EffectWindowImpl::isDialog() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return toplevel->isDialog();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool EffectWindowImpl::isSplash() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return toplevel->isSplash();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool EffectWindowImpl::isUtility() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return toplevel->isUtility();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool EffectWindowImpl::isDropdownMenu() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return toplevel->isDropdownMenu();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool EffectWindowImpl::isPopupMenu() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return toplevel->isPopupMenu();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool EffectWindowImpl::isTooltip() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return toplevel->isTooltip();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool EffectWindowImpl::isNotification() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return toplevel->isNotification();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool EffectWindowImpl::isComboBox() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return toplevel->isComboBox();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool EffectWindowImpl::isDNDIcon() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return toplevel->isDNDIcon();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-01-02 15:17:58 +00:00
|
|
|
bool EffectWindowImpl::isManaged() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
return dynamic_cast< const Client* >(toplevel) != NULL;
|
|
|
|
}
|
2008-01-02 15:17:58 +00:00
|
|
|
|
2009-02-08 08:45:21 +00:00
|
|
|
bool EffectWindowImpl::acceptsFocus() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
const Client* client = dynamic_cast< const Client* >(toplevel);
|
|
|
|
if (!client)
|
2009-02-08 08:45:21 +00:00
|
|
|
return true; // We don't actually know...
|
|
|
|
return client->wantsInput();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-02-08 08:45:21 +00:00
|
|
|
|
2009-05-17 18:26:49 +00:00
|
|
|
bool EffectWindowImpl::keepAbove() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
const Client* client = dynamic_cast< const Client* >(toplevel);
|
|
|
|
if (!client)
|
2009-05-17 18:26:49 +00:00
|
|
|
return true;
|
|
|
|
return client->keepAbove();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-05-17 18:26:49 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
bool EffectWindowImpl::isModal() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (Client* c = dynamic_cast< Client* >(toplevel))
|
2007-04-29 17:35:43 +00:00
|
|
|
return c->isModal();
|
|
|
|
return false;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
EffectWindow* EffectWindowImpl::findModal()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (Client* c = dynamic_cast< Client* >(toplevel)) {
|
|
|
|
if (Client* c2 = c->findModal())
|
2007-04-29 17:35:43 +00:00
|
|
|
return c2->effectWindow();
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
EffectWindowList EffectWindowImpl::mainWindows() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (Client* c = dynamic_cast< Client* >(toplevel)) {
|
2007-04-29 17:35:43 +00:00
|
|
|
EffectWindowList ret;
|
|
|
|
ClientList mainclients = c->mainClients();
|
2011-01-30 14:34:42 +00:00
|
|
|
foreach (Client * tmp, mainclients)
|
|
|
|
ret.append(tmp->effectWindow());
|
2007-04-29 17:35:43 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
return EffectWindowList();
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2010-05-03 20:04:44 +00:00
|
|
|
bool EffectWindowImpl::isSkipSwitcher() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (Client* c = dynamic_cast< Client* >(toplevel))
|
2010-05-03 20:04:44 +00:00
|
|
|
return c->skipSwitcher();
|
|
|
|
return false;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-05-03 20:04:44 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
WindowQuadList EffectWindowImpl::buildQuads(bool force) const
|
|
|
|
{
|
|
|
|
return sceneWindow()->buildQuads(force);
|
|
|
|
}
|
2007-08-08 14:42:06 +00:00
|
|
|
|
2009-06-28 17:17:29 +00:00
|
|
|
void EffectWindowImpl::minimize() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (Client* c = dynamic_cast< Client* >(toplevel)) {
|
2009-06-28 17:17:29 +00:00
|
|
|
c->minimize();
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-06-28 17:17:29 +00:00
|
|
|
|
|
|
|
void EffectWindowImpl::unminimize() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (Client* c = dynamic_cast< Client* >(toplevel)) {
|
2009-06-28 17:17:29 +00:00
|
|
|
c->unminimize();
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-06-28 17:17:29 +00:00
|
|
|
|
|
|
|
void EffectWindowImpl::closeWindow() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (Client* c = dynamic_cast< Client* >(toplevel)) {
|
2009-06-28 17:17:29 +00:00
|
|
|
c->closeWindow();
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-06-28 17:17:29 +00:00
|
|
|
|
2009-11-15 03:24:04 +00:00
|
|
|
bool EffectWindowImpl::visibleInClientGroup() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (Client* c = dynamic_cast< Client* >(toplevel)) {
|
|
|
|
if (!c->clientGroup())
|
2009-11-16 03:58:58 +00:00
|
|
|
return true;
|
2009-11-15 03:24:04 +00:00
|
|
|
return c == c->clientGroup()->visible();
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
return false;
|
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectWindowImpl::setData(int role, const QVariant &data)
|
|
|
|
{
|
|
|
|
if (!data.isNull())
|
2010-01-03 17:50:38 +00:00
|
|
|
dataMap[ role ] = data;
|
|
|
|
else
|
2011-01-30 14:34:42 +00:00
|
|
|
dataMap.remove(role);
|
|
|
|
}
|
2010-01-03 17:50:38 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
QVariant EffectWindowImpl::data(int role) const
|
|
|
|
{
|
|
|
|
if (!dataMap.contains(role))
|
2010-01-03 17:50:38 +00:00
|
|
|
return QVariant();
|
|
|
|
return dataMap[ role ];
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-01-03 17:50:38 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
EffectWindow* effectWindow(Toplevel* w)
|
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
EffectWindowImpl* ret = w->effectWindow();
|
|
|
|
return ret;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
EffectWindow* effectWindow(Scene::Window* w)
|
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
EffectWindowImpl* ret = w->window()->effectWindow();
|
2011-01-30 14:34:42 +00:00
|
|
|
ret->setSceneWindow(w);
|
2007-04-29 17:35:43 +00:00
|
|
|
return ret;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
//****************************************
|
|
|
|
// EffectWindowGroupImpl
|
|
|
|
//****************************************
|
|
|
|
|
2008-06-02 19:52:02 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
EffectWindowList EffectWindowGroupImpl::members() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
EffectWindowList ret;
|
2011-01-30 14:34:42 +00:00
|
|
|
foreach (Toplevel * c, group->members())
|
|
|
|
ret.append(c->effectWindow());
|
2007-04-29 17:35:43 +00:00
|
|
|
return ret;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2010-07-18 16:32:37 +00:00
|
|
|
//****************************************
|
|
|
|
// EffectFrameImpl
|
|
|
|
//****************************************
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
EffectFrameImpl::EffectFrameImpl(EffectFrameStyle style, bool staticSize, QPoint position, Qt::Alignment alignment)
|
|
|
|
: QObject(0)
|
2010-07-18 16:32:37 +00:00
|
|
|
, EffectFrame()
|
2011-01-30 14:34:42 +00:00
|
|
|
, m_style(style)
|
|
|
|
, m_static(staticSize)
|
|
|
|
, m_point(position)
|
|
|
|
, m_alignment(alignment)
|
|
|
|
, m_shader(NULL)
|
|
|
|
{
|
|
|
|
if (m_style == EffectFrameStyled) {
|
|
|
|
m_frame.setImagePath("widgets/background");
|
|
|
|
m_frame.setCacheAllRenderedFrames(true);
|
|
|
|
m_selection.setImagePath("widgets/viewitem");
|
|
|
|
m_selection.setElementPrefix("hover");
|
|
|
|
m_selection.setCacheAllRenderedFrames(true);
|
|
|
|
m_selection.setEnabledBorders(Plasma::FrameSvg::AllBorders);
|
|
|
|
connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), this, SLOT(plasmaThemeChanged()));
|
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (effects->compositingType() == OpenGLCompositing) {
|
2010-11-19 20:14:03 +00:00
|
|
|
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
|
2011-01-30 14:34:42 +00:00
|
|
|
m_sceneFrame = new SceneOpenGL::EffectFrame(this);
|
2010-11-19 20:14:03 +00:00
|
|
|
#endif
|
2011-01-30 14:34:42 +00:00
|
|
|
} else if (effects->compositingType() == XRenderCompositing) {
|
|
|
|
m_sceneFrame = new SceneXrender::EffectFrame(this);
|
|
|
|
} else {
|
2010-07-18 16:32:37 +00:00
|
|
|
// that should not happen and will definitely crash!
|
|
|
|
m_sceneFrame = NULL;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
|
|
|
EffectFrameImpl::~EffectFrameImpl()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2010-07-18 16:32:37 +00:00
|
|
|
delete m_sceneFrame;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
|
|
|
const QFont& EffectFrameImpl::font() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2010-07-18 16:32:37 +00:00
|
|
|
return m_font;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectFrameImpl::setFont(const QFont& font)
|
|
|
|
{
|
|
|
|
if (m_font == font) {
|
2010-07-18 16:32:37 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
m_font = font;
|
|
|
|
QRect oldGeom = m_geometry;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!m_text.isEmpty()) {
|
2010-07-18 16:32:37 +00:00
|
|
|
autoResize();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
if (oldGeom == m_geometry) {
|
|
|
|
// Wasn't updated in autoResize()
|
2010-07-18 16:32:37 +00:00
|
|
|
m_sceneFrame->freeTextFrame();
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
|
|
|
void EffectFrameImpl::free()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2010-07-18 16:32:37 +00:00
|
|
|
m_sceneFrame->free();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
|
|
|
const QRect& EffectFrameImpl::geometry() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2010-07-18 16:32:37 +00:00
|
|
|
return m_geometry;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectFrameImpl::setGeometry(const QRect& geometry, bool force)
|
|
|
|
{
|
2010-07-18 16:32:37 +00:00
|
|
|
QRect oldGeom = m_geometry;
|
|
|
|
m_geometry = geometry;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (m_geometry == oldGeom && !force) {
|
2010-07-18 16:32:37 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
effects->addRepaint(oldGeom);
|
|
|
|
effects->addRepaint(m_geometry);
|
|
|
|
if (m_geometry.size() == oldGeom.size() && !force) {
|
2010-07-18 16:32:37 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (m_style == EffectFrameStyled) {
|
2010-07-18 16:32:37 +00:00
|
|
|
qreal left, top, right, bottom;
|
2011-01-30 14:34:42 +00:00
|
|
|
m_frame.getMargins(left, top, right, bottom); // m_geometry is the inner geometry
|
|
|
|
m_frame.resizeFrame(m_geometry.adjusted(-left, -top, right, bottom).size());
|
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
|
|
|
free();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
|
|
|
const QPixmap& EffectFrameImpl::icon() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2010-07-18 16:32:37 +00:00
|
|
|
return m_icon;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectFrameImpl::setIcon(const QPixmap& icon)
|
|
|
|
{
|
2010-07-18 16:32:37 +00:00
|
|
|
m_icon = icon;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isCrossFade()) {
|
2010-08-07 14:08:34 +00:00
|
|
|
m_sceneFrame->crossFadeIcon();
|
2010-07-18 16:32:37 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
if (m_iconSize.isEmpty()) { // Set a size if we don't already have one
|
|
|
|
setIconSize(m_icon.size());
|
|
|
|
}
|
|
|
|
m_sceneFrame->freeIconFrame();
|
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
|
|
|
const QSize& EffectFrameImpl::iconSize() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2010-07-18 16:32:37 +00:00
|
|
|
return m_iconSize;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectFrameImpl::setIconSize(const QSize& size)
|
|
|
|
{
|
|
|
|
if (m_iconSize == size) {
|
2010-07-18 16:32:37 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
m_iconSize = size;
|
|
|
|
autoResize();
|
2010-07-20 21:11:03 +00:00
|
|
|
m_sceneFrame->freeIconFrame();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
|
|
|
void EffectFrameImpl::plasmaThemeChanged()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2010-07-18 16:32:37 +00:00
|
|
|
free();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectFrameImpl::render(QRegion region, double opacity, double frameOpacity)
|
|
|
|
{
|
|
|
|
if (m_geometry.isEmpty()) {
|
2010-07-18 16:32:37 +00:00
|
|
|
return; // Nothing to display
|
2010-07-24 16:29:16 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
m_shader = NULL;
|
|
|
|
effects->paintEffectFrame(this, region, opacity, frameOpacity);
|
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectFrameImpl::finalRender(QRegion region, double opacity, double frameOpacity) const
|
|
|
|
{
|
2010-07-18 16:32:37 +00:00
|
|
|
region = infiniteRegion(); // TODO: Old region doesn't seem to work with OpenGL
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
m_sceneFrame->render(region, opacity, frameOpacity);
|
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
|
|
|
Qt::Alignment EffectFrameImpl::alignment() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2010-07-18 16:32:37 +00:00
|
|
|
return m_alignment;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
2010-12-04 10:01:57 +00:00
|
|
|
|
|
|
|
void
|
2011-01-30 14:34:42 +00:00
|
|
|
EffectFrameImpl::align(QRect &geometry)
|
2010-12-04 10:01:57 +00:00
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
if (m_alignment & Qt::AlignLeft)
|
|
|
|
geometry.moveLeft(m_point.x());
|
|
|
|
else if (m_alignment & Qt::AlignRight)
|
|
|
|
geometry.moveLeft(m_point.x() - geometry.width());
|
2010-12-04 10:01:57 +00:00
|
|
|
else
|
2011-01-30 14:34:42 +00:00
|
|
|
geometry.moveLeft(m_point.x() - geometry.width() / 2);
|
|
|
|
if (m_alignment & Qt::AlignTop)
|
|
|
|
geometry.moveTop(m_point.y());
|
|
|
|
else if (m_alignment & Qt::AlignBottom)
|
|
|
|
geometry.moveTop(m_point.y() - geometry.height());
|
2010-12-04 10:01:57 +00:00
|
|
|
else
|
2011-01-30 14:34:42 +00:00
|
|
|
geometry.moveTop(m_point.y() - geometry.height() / 2);
|
2010-12-04 10:01:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectFrameImpl::setAlignment(Qt::Alignment alignment)
|
|
|
|
{
|
2010-07-18 16:32:37 +00:00
|
|
|
m_alignment = alignment;
|
2011-01-30 14:34:42 +00:00
|
|
|
align(m_geometry);
|
|
|
|
setGeometry(m_geometry);
|
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectFrameImpl::setPosition(const QPoint& point)
|
|
|
|
{
|
2010-07-18 16:32:37 +00:00
|
|
|
m_point = point;
|
2010-12-04 10:01:57 +00:00
|
|
|
QRect geometry = m_geometry; // this is important, setGeometry need call repaint for old & new geometry
|
2011-01-30 14:34:42 +00:00
|
|
|
align(geometry);
|
|
|
|
setGeometry(geometry);
|
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
|
|
|
const QString& EffectFrameImpl::text() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2010-07-18 16:32:37 +00:00
|
|
|
return m_text;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectFrameImpl::setText(const QString& text)
|
|
|
|
{
|
|
|
|
if (m_text == text) {
|
2010-07-18 16:32:37 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
if (isCrossFade()) {
|
2010-08-07 14:08:34 +00:00
|
|
|
m_sceneFrame->crossFadeText();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
m_text = text;
|
|
|
|
QRect oldGeom = m_geometry;
|
|
|
|
autoResize();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (oldGeom == m_geometry) {
|
|
|
|
// Wasn't updated in autoResize()
|
2010-07-18 16:32:37 +00:00
|
|
|
m_sceneFrame->freeTextFrame();
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectFrameImpl::setSelection(const QRect& selection)
|
|
|
|
{
|
|
|
|
if (selection == m_selectionGeometry) {
|
2010-07-26 20:00:04 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-26 20:00:04 +00:00
|
|
|
m_selectionGeometry = selection;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (m_selectionGeometry.size() != m_selection.frameSize().toSize()) {
|
|
|
|
m_selection.resizeFrame(m_selectionGeometry.size());
|
|
|
|
}
|
2010-07-26 20:00:04 +00:00
|
|
|
// TODO; optimize to only recreate when resizing
|
|
|
|
m_sceneFrame->freeSelection();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-26 20:00:04 +00:00
|
|
|
|
2010-07-18 16:32:37 +00:00
|
|
|
void EffectFrameImpl::autoResize()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (m_static)
|
2010-07-18 16:32:37 +00:00
|
|
|
return; // Not automatically resizing
|
|
|
|
|
|
|
|
QRect geometry;
|
|
|
|
// Set size
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!m_text.isEmpty()) {
|
|
|
|
QFontMetrics metrics(m_font);
|
|
|
|
geometry.setSize(metrics.size(0, m_text));
|
|
|
|
}
|
|
|
|
if (!m_icon.isNull() && !m_iconSize.isEmpty()) {
|
|
|
|
geometry.setLeft(-m_iconSize.width());
|
|
|
|
if (m_iconSize.height() > geometry.height())
|
|
|
|
geometry.setHeight(m_iconSize.height());
|
2010-07-18 16:32:37 +00:00
|
|
|
}
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
align(geometry);
|
|
|
|
setGeometry(geometry);
|
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
} // namespace
|