KWin uses kdelibs coding style.

icc-effect-5.14.5
Martin Gräßlin 2011-01-30 15:34:42 +01:00
parent 1a5b3b4bea
commit 0a7e48f7aa
379 changed files with 51138 additions and 55402 deletions

File diff suppressed because it is too large Load Diff

View File

@ -27,7 +27,7 @@ namespace KWin
{ {
Atoms::Atoms() Atoms::Atoms()
{ {
const int max = 50; const int max = 50;
Atom* atoms[max]; Atom* atoms[max];
@ -84,41 +84,41 @@ Atoms::Atoms()
atoms[n] = &kde_system_tray_embedding; atoms[n] = &kde_system_tray_embedding;
names[n++] = (char*) "_KDE_SYSTEM_TRAY_EMBEDDING"; names[n++] = (char*) "_KDE_SYSTEM_TRAY_EMBEDDING";
atoms[n] = &net_wm_take_activity; atoms[n] = &net_wm_take_activity;
names[n++] = (char*) "_NET_WM_TAKE_ACTIVITY"; names[n++] = (char*) "_NET_WM_TAKE_ACTIVITY";
atoms[n] = &net_wm_window_opacity; atoms[n] = &net_wm_window_opacity;
names[n++] = (char*) "_NET_WM_WINDOW_OPACITY"; names[n++] = (char*) "_NET_WM_WINDOW_OPACITY";
Atom fake; Atom fake;
atoms[n] = &fake; atoms[n] = &fake;
names[n++] = (char *) "_DT_SM_WINDOW_INFO"; names[n++] = (char *) "_DT_SM_WINDOW_INFO";
atoms[n] = &fake; atoms[n] = &fake;
names[n++] = (char *) "_MOTIF_WM_INFO"; // #172028 names[n++] = (char *) "_MOTIF_WM_INFO"; // #172028
atoms[n] = &xdnd_aware; atoms[n] = &xdnd_aware;
names[n++] = (char*) "XdndAware"; names[n++] = (char*) "XdndAware";
atoms[n] = &xdnd_position; atoms[n] = &xdnd_position;
names[n++] = (char*) "XdndPosition"; names[n++] = (char*) "XdndPosition";
atoms[n] = &net_frame_extents; atoms[n] = &net_frame_extents;
names[n++] = (char*) "_NET_FRAME_EXTENTS"; names[n++] = (char*) "_NET_FRAME_EXTENTS";
atoms[n] = &kde_net_wm_frame_strut; atoms[n] = &kde_net_wm_frame_strut;
names[n++] = (char*) "_KDE_NET_WM_FRAME_STRUT"; names[n++] = (char*) "_KDE_NET_WM_FRAME_STRUT";
atoms[n] = &net_wm_sync_request_counter; atoms[n] = &net_wm_sync_request_counter;
names[n++] = (char*) "_NET_WM_SYNC_REQUEST_COUNTER"; names[n++] = (char*) "_NET_WM_SYNC_REQUEST_COUNTER";
atoms[n] = &net_wm_sync_request; atoms[n] = &net_wm_sync_request;
names[n++] = (char*) "_NET_WM_SYNC_REQUEST"; names[n++] = (char*) "_NET_WM_SYNC_REQUEST";
assert( n <= max ); assert(n <= max);
XInternAtoms( display(), names, n, false, atoms_return ); XInternAtoms(display(), names, n, false, atoms_return);
for (int i = 0; i < n; i++ ) for (int i = 0; i < n; i++)
*atoms[i] = atoms_return[i]; *atoms[i] = atoms_return[i];
} }
} // namespace } // namespace

58
atoms.h
View File

@ -29,38 +29,38 @@ namespace KWin
{ {
class Atoms class Atoms
{ {
public: public:
Atoms(); Atoms();
Atom kwin_running; Atom kwin_running;
Atom activities; Atom activities;
Atom wm_protocols; Atom wm_protocols;
Atom wm_delete_window; Atom wm_delete_window;
Atom wm_take_focus; Atom wm_take_focus;
Atom wm_change_state; Atom wm_change_state;
Atom wm_client_leader; Atom wm_client_leader;
Atom wm_window_role; Atom wm_window_role;
Atom wm_state; Atom wm_state;
Atom sm_client_id; Atom sm_client_id;
Atom motif_wm_hints; Atom motif_wm_hints;
Atom net_wm_context_help; Atom net_wm_context_help;
Atom net_wm_ping; Atom net_wm_ping;
Atom kde_wm_change_state; Atom kde_wm_change_state;
Atom net_wm_user_time; Atom net_wm_user_time;
Atom kde_net_wm_user_creation_time; Atom kde_net_wm_user_creation_time;
Atom kde_system_tray_embedding; Atom kde_system_tray_embedding;
Atom net_wm_take_activity; Atom net_wm_take_activity;
Atom net_wm_window_opacity; Atom net_wm_window_opacity;
Atom xdnd_aware; Atom xdnd_aware;
Atom xdnd_position; Atom xdnd_position;
Atom net_frame_extents; Atom net_frame_extents;
Atom kde_net_wm_frame_strut; Atom kde_net_wm_frame_strut;
Atom net_wm_sync_request_counter; Atom net_wm_sync_request_counter;
Atom net_wm_sync_request; Atom net_wm_sync_request;
}; };
extern Atoms* atoms; extern Atoms* atoms;

View File

@ -29,155 +29,151 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
namespace KWin namespace KWin
{ {
Bridge::Bridge( Client* cl ) Bridge::Bridge(Client* cl)
: c( cl ) : c(cl)
{ {
} }
#define BRIDGE_HELPER( rettype, prototype, args1, args2, cst ) \ #define BRIDGE_HELPER( rettype, prototype, args1, args2, cst ) \
rettype Bridge::prototype ( args1 ) cst \ rettype Bridge::prototype ( args1 ) cst \
{ \ { \
return c->prototype( args2 ); \ return c->prototype( args2 ); \
} }
BRIDGE_HELPER( bool, isActive,,, const ) BRIDGE_HELPER(bool, isActive, , , const)
BRIDGE_HELPER( bool, isCloseable,,, const ) BRIDGE_HELPER(bool, isCloseable, , , const)
BRIDGE_HELPER( bool, isMaximizable,,, const ) BRIDGE_HELPER(bool, isMaximizable, , , const)
BRIDGE_HELPER( Bridge::MaximizeMode, maximizeMode,,, const ) BRIDGE_HELPER(Bridge::MaximizeMode, maximizeMode, , , const)
BRIDGE_HELPER( bool, isMinimizable,,, const ) BRIDGE_HELPER(bool, isMinimizable, , , const)
BRIDGE_HELPER( bool, providesContextHelp,,, const ) BRIDGE_HELPER(bool, providesContextHelp, , , const)
BRIDGE_HELPER( int, desktop,,, const ) BRIDGE_HELPER(int, desktop, , , const)
BRIDGE_HELPER( bool, isModal,,, const ) BRIDGE_HELPER(bool, isModal, , , const)
BRIDGE_HELPER( bool, isShadeable,,, const ) BRIDGE_HELPER(bool, isShadeable, , , const)
BRIDGE_HELPER( bool, isShade,,, const ) BRIDGE_HELPER(bool, isShade, , , const)
BRIDGE_HELPER( bool, keepAbove,,, const ) BRIDGE_HELPER(bool, keepAbove, , , const)
BRIDGE_HELPER( bool, keepBelow,,, const ) BRIDGE_HELPER(bool, keepBelow, , , const)
BRIDGE_HELPER( bool, isMovable,,, const ) BRIDGE_HELPER(bool, isMovable, , , const)
BRIDGE_HELPER( bool, isResizable,,, const ) BRIDGE_HELPER(bool, isResizable, , , const)
BRIDGE_HELPER( QString, caption,,, const ) BRIDGE_HELPER(QString, caption, , , const)
BRIDGE_HELPER( void, processMousePressEvent, QMouseEvent* e, e, ) BRIDGE_HELPER(void, processMousePressEvent, QMouseEvent* e, e,)
BRIDGE_HELPER( QRect, geometry,,, const ) BRIDGE_HELPER(QRect, geometry, , , const)
BRIDGE_HELPER( void, closeWindow,,, ) BRIDGE_HELPER(void, closeWindow, , ,)
BRIDGE_HELPER( void, maximize, MaximizeMode m, m, ) BRIDGE_HELPER(void, maximize, MaximizeMode m, m,)
BRIDGE_HELPER( void, minimize,,, ) BRIDGE_HELPER(void, minimize, , ,)
BRIDGE_HELPER( void, showContextHelp,,, ) BRIDGE_HELPER(void, showContextHelp, , ,)
BRIDGE_HELPER( void, setDesktop, int desktop, desktop, ) BRIDGE_HELPER(void, setDesktop, int desktop, desktop,)
void Bridge::setKeepAbove( bool set ) void Bridge::setKeepAbove(bool set)
{ {
if( c->keepAbove() != set ) if (c->keepAbove() != set)
c->workspace()->performWindowOperation( c, KeepAboveOp ); c->workspace()->performWindowOperation(c, KeepAboveOp);
} }
void Bridge::setKeepBelow( bool set ) void Bridge::setKeepBelow(bool set)
{ {
if( c->keepBelow() != set ) if (c->keepBelow() != set)
c->workspace()->performWindowOperation( c, KeepBelowOp ); c->workspace()->performWindowOperation(c, KeepBelowOp);
} }
NET::WindowType Bridge::windowType( unsigned long supported_types ) const NET::WindowType Bridge::windowType(unsigned long supported_types) const
{ {
return c->windowType( false, supported_types ); return c->windowType(false, supported_types);
} }
QIcon Bridge::icon() const QIcon Bridge::icon() const
{ {
QIcon ret( c->icon()); QIcon ret(c->icon());
ret.addPixmap( c->miniIcon()); ret.addPixmap(c->miniIcon());
return ret; return ret;
} }
bool Bridge::isSetShade() const bool Bridge::isSetShade() const
{ {
return c->shadeMode() != ShadeNone; return c->shadeMode() != ShadeNone;
} }
void Bridge::showWindowMenu( const QPoint &p ) void Bridge::showWindowMenu(const QPoint &p)
{ {
c->workspace()->showWindowMenu( p, c ); c->workspace()->showWindowMenu(p, c);
} }
void Bridge::showWindowMenu( const QRect &p ) void Bridge::showWindowMenu(const QRect &p)
{ {
c->workspace()->showWindowMenu( p, c ); c->workspace()->showWindowMenu(p, c);
} }
void Bridge::performWindowOperation( WindowOperation op ) void Bridge::performWindowOperation(WindowOperation op)
{ {
c->workspace()->performWindowOperation( c, op ); c->workspace()->performWindowOperation(c, op);
} }
void Bridge::setMask( const QRegion& r, int mode ) void Bridge::setMask(const QRegion& r, int mode)
{ {
c->setMask( r, mode ); c->setMask(r, mode);
} }
bool Bridge::isPreview() const bool Bridge::isPreview() const
{ {
return false; return false;
} }
QRect Bridge::iconGeometry() const QRect Bridge::iconGeometry() const
{ {
NETRect r = c->info->iconGeometry(); NETRect r = c->info->iconGeometry();
return QRect( r.pos.x, r.pos.y, r.size.width, r.size.height ); return QRect(r.pos.x, r.pos.y, r.size.width, r.size.height);
} }
WId Bridge::windowId() const WId Bridge::windowId() const
{ {
return c->window(); return c->window();
} }
void Bridge::titlebarDblClickOperation() void Bridge::titlebarDblClickOperation()
{ {
c->workspace()->performWindowOperation( c, options->operationTitlebarDblClick()); c->workspace()->performWindowOperation(c, options->operationTitlebarDblClick());
} }
void Bridge::titlebarMouseWheelOperation( int delta ) void Bridge::titlebarMouseWheelOperation(int delta)
{ {
c->performMouseCommand( options->operationTitlebarMouseWheel( delta ), cursorPos()); c->performMouseCommand(options->operationTitlebarMouseWheel(delta), cursorPos());
} }
void Bridge::setShade( bool set ) void Bridge::setShade(bool set)
{ {
c->setShade( set ? ShadeNormal : ShadeNone ); c->setShade(set ? ShadeNormal : ShadeNone);
} }
int Bridge::currentDesktop() const int Bridge::currentDesktop() const
{ {
return c->workspace()->currentDesktop(); return c->workspace()->currentDesktop();
} }
QWidget* Bridge::initialParentWidget() const QWidget* Bridge::initialParentWidget() const
{ {
return NULL; return NULL;
} }
Qt::WFlags Bridge::initialWFlags() const Qt::WFlags Bridge::initialWFlags() const
{ {
return 0; return 0;
} }
QRegion Bridge::unobscuredRegion( const QRegion& r ) const QRegion Bridge::unobscuredRegion(const QRegion& r) const
{ {
QRegion reg( r ); QRegion reg(r);
const ClientList stacking_order = c->workspace()->stackingOrder(); const ClientList stacking_order = c->workspace()->stackingOrder();
int pos = stacking_order.indexOf( c ); int pos = stacking_order.indexOf(c);
++pos; ++pos;
for(; pos < stacking_order.count(); ++pos ) for (; pos < stacking_order.count(); ++pos) {
{ if (!stacking_order[pos]->isShown(true))
if( !stacking_order[pos]->isShown( true ))
continue; // these don't obscure the window continue; // these don't obscure the window
if( c->isOnAllDesktops()) if (c->isOnAllDesktops()) {
{ if (!stacking_order[ pos ]->isOnCurrentDesktop())
if( !stacking_order[ pos ]->isOnCurrentDesktop())
continue; continue;
} } else {
else if (!stacking_order[ pos ]->isOnDesktop(c->desktop()))
{
if( !stacking_order[ pos ]->isOnDesktop( c->desktop()))
continue; continue;
} }
/* the clients all have their mask-regions in local coords /* the clients all have their mask-regions in local coords
so we have to translate them to a shared coord system so we have to translate them to a shared coord system
we choose ours */ we choose ours */
@ -186,121 +182,119 @@ QRegion Bridge::unobscuredRegion( const QRegion& r ) const
QRegion creg = stacking_order[ pos ]->mask(); QRegion creg = stacking_order[ pos ]->mask();
creg.translate(dx, dy); creg.translate(dx, dy);
reg -= creg; reg -= creg;
if (reg.isEmpty()) if (reg.isEmpty()) {
{
// early out, we are completely obscured // early out, we are completely obscured
break; break;
}
} }
return reg;
} }
return reg;
}
void Bridge::grabXServer( bool grab ) void Bridge::grabXServer(bool grab)
{ {
if( grab ) if (grab)
KWin::grabXServer(); KWin::grabXServer();
else else
KWin::ungrabXServer(); KWin::ungrabXServer();
} }
bool Bridge::compositingActive() const bool Bridge::compositingActive() const
{ {
return c->workspace()->compositingActive(); return c->workspace()->compositingActive();
} }
QRect Bridge::transparentRect() const QRect Bridge::transparentRect() const
{ {
return c->transparentRect().translated(-c->decorationRect().topLeft()); return c->transparentRect().translated(-c->decorationRect().topLeft());
} }
bool Bridge::isClientGroupActive() bool Bridge::isClientGroupActive()
{ {
if( c->clientGroup() ) if (c->clientGroup())
return c->clientGroup()->containsActiveClient(); return c->clientGroup()->containsActiveClient();
return isActive(); return isActive();
} }
QList< ClientGroupItem > Bridge::clientGroupItems() const QList< ClientGroupItem > Bridge::clientGroupItems() const
{ {
if( c->clientGroup() ) if (c->clientGroup())
return c->clientGroup()->items(); return c->clientGroup()->items();
QList< ClientGroupItem > items; QList< ClientGroupItem > items;
QIcon icon( c->icon() ); QIcon icon(c->icon());
icon.addPixmap( c->miniIcon() ); icon.addPixmap(c->miniIcon());
items.append( ClientGroupItem( c->caption(), icon )); items.append(ClientGroupItem(c->caption(), icon));
return items; return items;
} }
long Bridge::itemId( int index ) long Bridge::itemId(int index)
{ {
if( !c->clientGroup() ) if (!c->clientGroup())
return 0; return 0;
const ClientList list = c->clientGroup()->clients(); const ClientList list = c->clientGroup()->clients();
return reinterpret_cast<long>( list.at( index )); return reinterpret_cast<long>(list.at(index));
} }
int Bridge::visibleClientGroupItem() int Bridge::visibleClientGroupItem()
{ {
if( c->clientGroup() ) if (c->clientGroup())
return c->clientGroup()->indexOfVisibleClient(); return c->clientGroup()->indexOfVisibleClient();
return 0; return 0;
} }
void Bridge::setVisibleClientGroupItem( int index ) void Bridge::setVisibleClientGroupItem(int index)
{ {
if( c->clientGroup() ) if (c->clientGroup())
c->clientGroup()->setVisible( index ); c->clientGroup()->setVisible(index);
} }
void Bridge::moveItemInClientGroup( int index, int before ) void Bridge::moveItemInClientGroup(int index, int before)
{ {
if( c->clientGroup() ) if (c->clientGroup())
c->clientGroup()->move( index, before ); c->clientGroup()->move(index, before);
} }
void Bridge::moveItemToClientGroup( long itemId, int before ) void Bridge::moveItemToClientGroup(long itemId, int before)
{ {
Client* item = reinterpret_cast<Client*>( itemId ); Client* item = reinterpret_cast<Client*>(itemId);
if( !c->workspace()->hasClient( item )) if (!c->workspace()->hasClient(item)) {
{
kWarning(1212) << "****** ARBITRARY CODE EXECUTION ATTEMPT DETECTED ******"; kWarning(1212) << "****** ARBITRARY CODE EXECUTION ATTEMPT DETECTED ******";
return; return;
}
if( item->clientGroup() )
c->workspace()->moveItemToClientGroup( item->clientGroup(), item->clientGroup()->indexOfClient( item ),
c->clientGroup(), before );
} }
if (item->clientGroup())
c->workspace()->moveItemToClientGroup(item->clientGroup(), item->clientGroup()->indexOfClient(item),
c->clientGroup(), before);
}
void Bridge::removeFromClientGroup( int index, const QRect& newGeom ) void Bridge::removeFromClientGroup(int index, const QRect& newGeom)
{ {
if( c->clientGroup() ) if (c->clientGroup())
c->clientGroup()->remove( index, newGeom ); c->clientGroup()->remove(index, newGeom);
} }
void Bridge::closeClientGroupItem( int index ) void Bridge::closeClientGroupItem(int index)
{ {
if( !c->clientGroup() ) if (!c->clientGroup())
return; return;
const ClientList list = c->clientGroup()->clients(); const ClientList list = c->clientGroup()->clients();
if( index >= 0 || index <= list.count() ) if (index >= 0 || index <= list.count())
list.at( index )->closeWindow(); list.at(index)->closeWindow();
} }
void Bridge::closeAllInClientGroup() void Bridge::closeAllInClientGroup()
{ {
if( c->clientGroup() ) if (c->clientGroup())
c->clientGroup()->closeAll(); c->clientGroup()->closeAll();
} }
void Bridge::displayClientMenu( int index, const QPoint& pos ) void Bridge::displayClientMenu(int index, const QPoint& pos)
{ {
if( c->clientGroup() ) if (c->clientGroup())
c->clientGroup()->displayClientMenu( index, pos ); c->clientGroup()->displayClientMenu(index, pos);
} }
KDecoration::WindowOperation Bridge::buttonToWindowOperation( Qt::MouseButtons button ) KDecoration::WindowOperation Bridge::buttonToWindowOperation(Qt::MouseButtons button)
{ {
return c->mouseButtonToWindowOperation( button ); return c->mouseButtonToWindowOperation(button);
} }
} // namespace } // namespace

126
bridge.h
View File

@ -29,72 +29,72 @@ namespace KWin
class Client; class Client;
class Bridge : public KDecorationBridgeUnstable class Bridge : public KDecorationBridgeUnstable
{ {
public: public:
Bridge( Client* cl ); Bridge(Client* cl);
virtual bool isActive() const; virtual bool isActive() const;
virtual bool isCloseable() const; virtual bool isCloseable() const;
virtual bool isMaximizable() const; virtual bool isMaximizable() const;
virtual MaximizeMode maximizeMode() const; virtual MaximizeMode maximizeMode() const;
virtual bool isMinimizable() const; virtual bool isMinimizable() const;
virtual bool providesContextHelp() const; virtual bool providesContextHelp() const;
virtual int desktop() const; virtual int desktop() const;
virtual bool isModal() const; virtual bool isModal() const;
virtual bool isShadeable() const; virtual bool isShadeable() const;
virtual bool isShade() const; virtual bool isShade() const;
virtual bool isSetShade() const; virtual bool isSetShade() const;
virtual bool keepAbove() const; virtual bool keepAbove() const;
virtual bool keepBelow() const; virtual bool keepBelow() const;
virtual bool isMovable() const; virtual bool isMovable() const;
virtual bool isResizable() const; virtual bool isResizable() const;
virtual NET::WindowType windowType( unsigned long supported_types ) const; virtual NET::WindowType windowType(unsigned long supported_types) const;
virtual QIcon icon() const; virtual QIcon icon() const;
virtual QString caption() const; virtual QString caption() const;
virtual void processMousePressEvent( QMouseEvent* ); virtual void processMousePressEvent(QMouseEvent*);
virtual void showWindowMenu( const QPoint & ); virtual void showWindowMenu(const QPoint &);
virtual void showWindowMenu( const QRect & ); virtual void showWindowMenu(const QRect &);
virtual void performWindowOperation( WindowOperation ); virtual void performWindowOperation(WindowOperation);
virtual void setMask( const QRegion&, int ); virtual void setMask(const QRegion&, int);
virtual bool isPreview() const; virtual bool isPreview() const;
virtual QRect geometry() const; virtual QRect geometry() const;
virtual QRect iconGeometry() const; virtual QRect iconGeometry() const;
virtual QRegion unobscuredRegion( const QRegion& r ) const; virtual QRegion unobscuredRegion(const QRegion& r) const;
virtual WId windowId() const; virtual WId windowId() const;
virtual void closeWindow(); virtual void closeWindow();
virtual void maximize( MaximizeMode mode ); virtual void maximize(MaximizeMode mode);
virtual void minimize(); virtual void minimize();
virtual void showContextHelp(); virtual void showContextHelp();
virtual void setDesktop( int desktop ); virtual void setDesktop(int desktop);
virtual void titlebarDblClickOperation(); virtual void titlebarDblClickOperation();
virtual void titlebarMouseWheelOperation( int delta ); virtual void titlebarMouseWheelOperation(int delta);
virtual void setShade( bool set ); virtual void setShade(bool set);
virtual void setKeepAbove( bool ); virtual void setKeepAbove(bool);
virtual void setKeepBelow( bool ); virtual void setKeepBelow(bool);
virtual int currentDesktop() const; virtual int currentDesktop() const;
virtual QWidget* initialParentWidget() const; virtual QWidget* initialParentWidget() const;
virtual Qt::WFlags initialWFlags() const; virtual Qt::WFlags initialWFlags() const;
virtual void grabXServer( bool grab ); virtual void grabXServer(bool grab);
virtual bool compositingActive() const; virtual bool compositingActive() const;
virtual QRect transparentRect() const; virtual QRect transparentRect() const;
// Window tabbing // Window tabbing
virtual bool isClientGroupActive(); virtual bool isClientGroupActive();
virtual QList< ClientGroupItem > clientGroupItems() const; virtual QList< ClientGroupItem > clientGroupItems() const;
virtual long itemId( int index ); virtual long itemId(int index);
virtual int visibleClientGroupItem(); virtual int visibleClientGroupItem();
virtual void setVisibleClientGroupItem( int index ); virtual void setVisibleClientGroupItem(int index);
virtual void moveItemInClientGroup( int index, int before ); virtual void moveItemInClientGroup(int index, int before);
virtual void moveItemToClientGroup( long itemId, int before ); virtual void moveItemToClientGroup(long itemId, int before);
virtual void removeFromClientGroup( int index, const QRect& newGeom ); virtual void removeFromClientGroup(int index, const QRect& newGeom);
virtual void closeClientGroupItem( int index ); virtual void closeClientGroupItem(int index);
virtual void closeAllInClientGroup(); virtual void closeAllInClientGroup();
virtual void displayClientMenu( int index, const QPoint& pos ); virtual void displayClientMenu(int index, const QPoint& pos);
virtual WindowOperation buttonToWindowOperation( Qt::MouseButtons button ); virtual WindowOperation buttonToWindowOperation(Qt::MouseButtons button);
private: private:
Client* c; Client* c;
}; };
} // namespace } // namespace

2230
client.cpp

File diff suppressed because it is too large Load Diff

1381
client.h

File diff suppressed because it is too large Load Diff

View File

@ -27,337 +27,323 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
namespace KWin namespace KWin
{ {
ClientGroup::ClientGroup( Client *c ) ClientGroup::ClientGroup(Client *c)
: clients_() : clients_()
, items_() , items_()
, visible_( 0 ) , visible_(0)
, minSize_( 0, 0 ) , minSize_(0, 0)
, maxSize_( INT_MAX, INT_MAX ) , maxSize_(INT_MAX, INT_MAX)
{ {
clients_.append( c ); clients_.append(c);
updateItems(); updateItems();
updateMinMaxSize(); updateMinMaxSize();
Workspace::self()->addClientGroup( this ); Workspace::self()->addClientGroup(this);
c->setClientShown( true ); // Ensure the client is visible c->setClientShown(true); // Ensure the client is visible
c->triggerDecorationRepaint(); // TODO: Required? Maybe for creating new group? c->triggerDecorationRepaint(); // TODO: Required? Maybe for creating new group?
} }
ClientGroup::~ClientGroup() ClientGroup::~ClientGroup()
{ {
Workspace::self()->removeClientGroup( this ); Workspace::self()->removeClientGroup(this);
} }
void ClientGroup::add( Client* c, int before, bool becomeVisible ) void ClientGroup::add(Client* c, int before, bool becomeVisible)
{ {
if( contains( c ) || !c->workspace()->decorationSupportsClientGrouping() ) if (contains(c) || !c->workspace()->decorationSupportsClientGrouping())
return; return;
// Remove the Client->ClientGroup reference if the client is already in another group so we // Remove the Client->ClientGroup reference if the client is already in another group so we
// don't change the geometry of other clients in their current group by accident. However // don't change the geometry of other clients in their current group by accident. However
// don't REMOVE them from the actual group until we are certain that the client will be moved. // don't REMOVE them from the actual group until we are certain that the client will be moved.
ClientGroup* oldGroup = NULL; ClientGroup* oldGroup = NULL;
if( c->clientGroup() ) if (c->clientGroup()) {
{
oldGroup = c->clientGroup(); oldGroup = c->clientGroup();
c->setClientGroup( NULL ); c->setClientGroup(NULL);
} }
// If it's not possible to have the same states then ungroup them, TODO: Check all states // If it's not possible to have the same states then ungroup them, TODO: Check all states
// We do this here as the ungroup code in updateStates() cannot be called until add() completes // We do this here as the ungroup code in updateStates() cannot be called until add() completes
ShadeMode oldShadeMode = c->shadeMode(); ShadeMode oldShadeMode = c->shadeMode();
if( c->shadeMode() != clients_[visible_]->shadeMode() ) if (c->shadeMode() != clients_[visible_]->shadeMode())
c->setShade( clients_[visible_]->shadeMode() ); c->setShade(clients_[visible_]->shadeMode());
if( c->shadeMode() != clients_[visible_]->shadeMode() ) if (c->shadeMode() != clients_[visible_]->shadeMode()) {
{ if (oldGroup) // Re-add to old group if required
if( oldGroup ) // Re-add to old group if required c->setClientGroup(oldGroup);
c->setClientGroup( oldGroup ); // One need to trigger decoration repaint on the group to
// One need to trigger decoration repaint on the group to
// make sure hover animations are properly reset. // make sure hover animations are properly reset.
clients_[visible_]->triggerDecorationRepaint(); clients_[visible_]->triggerDecorationRepaint();
return; return;
} }
QRect oldGeom = c->geometry(); QRect oldGeom = c->geometry();
if( c->geometry() != clients_[visible_]->geometry() ) if (c->geometry() != clients_[visible_]->geometry())
c->setGeometry( clients_[visible_]->geometry() ); c->setGeometry(clients_[visible_]->geometry());
if( c->geometry() != clients_[visible_]->geometry() ) if (c->geometry() != clients_[visible_]->geometry()) {
{ if (c->shadeMode() != oldShadeMode)
if( c->shadeMode() != oldShadeMode ) c->setShade(oldShadeMode); // Restore old shade mode
c->setShade( oldShadeMode ); // Restore old shade mode if (oldGroup) // Re-add to old group if required
if( oldGroup ) // Re-add to old group if required c->setClientGroup(oldGroup);
c->setClientGroup( oldGroup );
clients_[visible_]->triggerDecorationRepaint(); clients_[visible_]->triggerDecorationRepaint();
return; return;
} }
if( c->desktop() != clients_[visible_]->desktop() ) if (c->desktop() != clients_[visible_]->desktop())
c->setDesktop( clients_[visible_]->desktop() ); c->setDesktop(clients_[visible_]->desktop());
if( c->desktop() != clients_[visible_]->desktop() ) if (c->desktop() != clients_[visible_]->desktop()) {
{ if (c->geometry() != oldGeom)
if( c->geometry() != oldGeom ) c->setGeometry(oldGeom); // Restore old geometry
c->setGeometry( oldGeom ); // Restore old geometry if (c->shadeMode() != oldShadeMode)
if( c->shadeMode() != oldShadeMode ) c->setShade(oldShadeMode); // Restore old shade mode
c->setShade( oldShadeMode ); // Restore old shade mode if (oldGroup) // Re-add to old group if required
if( oldGroup ) // Re-add to old group if required c->setClientGroup(oldGroup);
c->setClientGroup( oldGroup );
clients_[visible_]->triggerDecorationRepaint(); clients_[visible_]->triggerDecorationRepaint();
return; return;
} }
// Tabbed windows MUST have a decoration // Tabbed windows MUST have a decoration
if( c->noBorder() ) if (c->noBorder())
c->setNoBorder( false ); c->setNoBorder(false);
if( clients_[visible_]->noBorder() ) if (clients_[visible_]->noBorder())
clients_[visible_]->setNoBorder( false ); clients_[visible_]->setNoBorder(false);
// Re-add to old group if required for the effect hook // Re-add to old group if required for the effect hook
if( oldGroup ) if (oldGroup)
c->setClientGroup( oldGroup ); c->setClientGroup(oldGroup);
// Notify effects of merge // Notify effects of merge
if( effects != NULL ) if (effects != NULL)
static_cast<EffectsHandlerImpl*>(effects)->clientGroupItemAdded( static_cast<EffectsHandlerImpl*>(effects)->clientGroupItemAdded(
c->effectWindow(), clients_[visible_]->effectWindow() ); c->effectWindow(), clients_[visible_]->effectWindow());
// Actually remove from old group if required and update // Actually remove from old group if required and update
if( c->clientGroup() ) if (c->clientGroup())
c->clientGroup()->remove( c ); c->clientGroup()->remove(c);
c->setClientGroup( this ); // Let the client know which group it belongs to c->setClientGroup(this); // Let the client know which group it belongs to
// Actually add to new group // Actually add to new group
if( before >= 0 ) if (before >= 0) {
{ if (visible_ >= before)
if( visible_ >= before )
visible_++; visible_++;
clients_.insert( before, c ); clients_.insert(before, c);
} } else
else clients_.append(c);
clients_.append( c ); if (!becomeVisible) // Hide before adding
if( !becomeVisible ) // Hide before adding c->setClientShown(false);
c->setClientShown( false );
updateItems(); updateItems();
updateMinMaxSize(); updateMinMaxSize();
updateStates( clients_[visible_], c ); updateStates(clients_[visible_], c);
if( becomeVisible ) // Set visible after settings geometry if (becomeVisible) // Set visible after settings geometry
setVisible( c ); setVisible(c);
// Activate the new visible window // Activate the new visible window
clients_[visible_]->setActive( true ); clients_[visible_]->setActive(true);
//clients_[visible_]->takeFocus( Allowed ); //clients_[visible_]->takeFocus( Allowed );
//clients_[visible_]->workspace()->raiseClient( clients_[visible_] ); //clients_[visible_]->workspace()->raiseClient( clients_[visible_] );
clients_[visible_]->triggerDecorationRepaint(); clients_[visible_]->triggerDecorationRepaint();
} }
void ClientGroup::remove( int index, const QRect& newGeom, bool toNullGroup ) void ClientGroup::remove(int index, const QRect& newGeom, bool toNullGroup)
{ {
remove( clients_[index], newGeom, toNullGroup ); remove(clients_[index], newGeom, toNullGroup);
} }
void ClientGroup::remove( Client* c, const QRect& newGeom, bool toNullGroup ) void ClientGroup::remove(Client* c, const QRect& newGeom, bool toNullGroup)
{ {
if( !c ) if (!c)
return; return;
if( clients_.count() < 2 ) if (clients_.count() < 2) {
{ c->setClientGroup(NULL);
c->setClientGroup( NULL ); Workspace::self()->removeClientGroup(this); // Remove immediately
Workspace::self()->removeClientGroup( this ); // Remove immediately
delete this; delete this;
return; return;
} }
ClientList::const_iterator i; ClientList::const_iterator i;
Client* newVisible = clients_[visible_]; Client* newVisible = clients_[visible_];
if( newVisible == c ) if (newVisible == c)
newVisible = ( visible_ != clients_.size() - 1 ) ? clients_[visible_ + 1] : clients_[visible_ - 1]; newVisible = (visible_ != clients_.size() - 1) ? clients_[visible_ + 1] : clients_[visible_ - 1];
// Notify effects of removal // Notify effects of removal
if( effects ) if (effects)
static_cast<EffectsHandlerImpl*>(effects)->clientGroupItemRemoved( static_cast<EffectsHandlerImpl*>(effects)->clientGroupItemRemoved(
c->effectWindow(), newVisible->effectWindow() ); c->effectWindow(), newVisible->effectWindow());
setVisible( newVisible ); // Display new window before removing old one setVisible(newVisible); // Display new window before removing old one
clients_.removeAll( c ); clients_.removeAll(c);
visible_ = indexOfClient( newVisible ); // Index may have changed visible_ = indexOfClient(newVisible); // Index may have changed
updateItems(); updateItems();
updateMinMaxSize(); updateMinMaxSize();
c->setClientGroup( toNullGroup ? NULL : new ClientGroup( c )); c->setClientGroup(toNullGroup ? NULL : new ClientGroup(c));
if( newGeom.isValid() ) if (newGeom.isValid()) {
{
// HACK: if the group was maximized, one needs to make some checks on the future client maximize mode // HACK: if the group was maximized, one needs to make some checks on the future client maximize mode
// because the transition from maximized to MaximizeRestore is not handled properly in setGeometry when // because the transition from maximized to MaximizeRestore is not handled properly in setGeometry when
// the new geometry size is unchanged. // the new geometry size is unchanged.
// since newGeom has the same size as the old client geometry, one just needs to check the topLeft position of newGeom // since newGeom has the same size as the old client geometry, one just needs to check the topLeft position of newGeom
// and compare that to the group maximize mode. // and compare that to the group maximize mode.
// when the new mode is predicted to be MaximizeRestore, one must set it manually, in order to avoid decoration artifacts // when the new mode is predicted to be MaximizeRestore, one must set it manually, in order to avoid decoration artifacts
Client::MaximizeMode groupMaxMode( newVisible->maximizeMode() ); Client::MaximizeMode groupMaxMode(newVisible->maximizeMode());
if( ( ( groupMaxMode & Client::MaximizeHorizontal ) && newGeom.left() != newVisible->geometry().left() ) || if (((groupMaxMode & Client::MaximizeHorizontal) && newGeom.left() != newVisible->geometry().left()) ||
( ( groupMaxMode & Client::MaximizeVertical ) && newGeom.top() != newVisible->geometry().top() ) ) ((groupMaxMode & Client::MaximizeVertical) && newGeom.top() != newVisible->geometry().top()))
c->maximize( Client::MaximizeRestore ); c->maximize(Client::MaximizeRestore);
c->setGeometry( newGeom ); c->setGeometry(newGeom);
}
newVisible->triggerDecorationRepaint();
} }
newVisible->triggerDecorationRepaint();
}
void ClientGroup::removeAll() void ClientGroup::removeAll()
{ {
while( clients_.count() > 1 ) while (clients_.count() > 1)
remove( clients_.at( 1 )); remove(clients_.at(1));
} }
void ClientGroup::closeAll() void ClientGroup::closeAll()
{ {
Client* front; Client* front;
ClientList list( clients_ ); ClientList list(clients_);
while( !list.isEmpty() ) while (!list.isEmpty()) {
{
front = list.front(); front = list.front();
list.pop_front(); list.pop_front();
if( front != clients_[visible_] ) if (front != clients_[visible_])
front->closeWindow(); front->closeWindow();
} }
clients_[visible_]->closeWindow(); clients_[visible_]->closeWindow();
} }
void ClientGroup::move( int index, int before ) void ClientGroup::move(int index, int before)
{ {
move( clients_[index], ( before >= 0 && before < clients_.size() ) ? clients_[before] : NULL ); move(clients_[index], (before >= 0 && before < clients_.size()) ? clients_[before] : NULL);
} }
void ClientGroup::move( Client* c, Client* before ) void ClientGroup::move(Client* c, Client* before)
{ {
if( c == before ) // Impossible to do if (c == before) // Impossible to do
return; return;
Client* wasVisible = clients_[visible_]; Client* wasVisible = clients_[visible_];
clients_.removeAll( c ); clients_.removeAll(c);
clients_.insert( before ? indexOfClient( before ) : clients_.size(), c ); clients_.insert(before ? indexOfClient(before) : clients_.size(), c);
visible_ = indexOfClient( wasVisible ); visible_ = indexOfClient(wasVisible);
updateItems(); updateItems();
clients_[visible_]->triggerDecorationRepaint(); clients_[visible_]->triggerDecorationRepaint();
} }
void ClientGroup::displayClientMenu( int index, const QPoint& pos ) void ClientGroup::displayClientMenu(int index, const QPoint& pos)
{ {
if( index == -1 ) if (index == -1)
index = visible_; index = visible_;
displayClientMenu( clients_[index], pos ); displayClientMenu(clients_[index], pos);
} }
void ClientGroup::displayClientMenu( Client* c, const QPoint& pos ) void ClientGroup::displayClientMenu(Client* c, const QPoint& pos)
{ {
c->workspace()->showWindowMenu( pos, c ); c->workspace()->showWindowMenu(pos, c);
} }
bool ClientGroup::containsActiveClient() bool ClientGroup::containsActiveClient()
{ {
return contains( Workspace::self()->activeClient() ); return contains(Workspace::self()->activeClient());
} }
void ClientGroup::setVisible( int index ) void ClientGroup::setVisible(int index)
{ {
setVisible( clients_[index] ); setVisible(clients_[index]);
} }
void ClientGroup::setVisible( Client* c ) void ClientGroup::setVisible(Client* c)
{ {
if( c == clients_[visible_] || !contains( c )) if (c == clients_[visible_] || !contains(c))
return; return;
// Notify effects of switch // Notify effects of switch
if( effects != NULL ) if (effects != NULL)
static_cast<EffectsHandlerImpl*>(effects)->clientGroupItemSwitched( static_cast<EffectsHandlerImpl*>(effects)->clientGroupItemSwitched(
clients_[visible_]->effectWindow(), c->effectWindow() ); clients_[visible_]->effectWindow(), c->effectWindow());
visible_ = indexOfClient( c ); visible_ = indexOfClient(c);
c->setClientShown( true ); c->setClientShown(true);
for( ClientList::const_iterator i = clients_.constBegin(); i != clients_.constEnd(); ++i ) for (ClientList::const_iterator i = clients_.constBegin(); i != clients_.constEnd(); ++i)
if( (*i) != c ) if ((*i) != c)
(*i)->setClientShown( false ); (*i)->setClientShown(false);
} }
void ClientGroup::updateStates( Client* main, Client* only ) void ClientGroup::updateStates(Client* main, Client* only)
{ {
for( ClientList::const_iterator i = clients_.constBegin(); i != clients_.constEnd(); i++ ) for (ClientList::const_iterator i = clients_.constBegin(); i != clients_.constEnd(); i++)
if( (*i) != main && ( !only || (*i) == only )) if ((*i) != main && (!only || (*i) == only)) {
{ if ((*i)->isMinimized() != main->isMinimized()) {
if( (*i)->isMinimized() != main->isMinimized() ) if (main->isMinimized())
{ (*i)->minimize(true);
if( main->isMinimized() )
(*i)->minimize( true );
else else
(*i)->unminimize( true ); (*i)->unminimize(true);
} }
if( (*i)->isShade() != main->isShade() ) if ((*i)->isShade() != main->isShade())
(*i)->setShade( main->isShade() ? ShadeNormal : ShadeNone ); (*i)->setShade(main->isShade() ? ShadeNormal : ShadeNone);
if( (*i)->geometry() != main->geometry() ) if ((*i)->geometry() != main->geometry())
(*i)->setGeometry( main->geometry() ); (*i)->setGeometry(main->geometry());
if( (*i)->desktop() != main->desktop() ) if ((*i)->desktop() != main->desktop())
(*i)->setDesktop( main->desktop() ); (*i)->setDesktop(main->desktop());
if( (*i)->isOnAllDesktops() != main->isOnAllDesktops() ) if ((*i)->isOnAllDesktops() != main->isOnAllDesktops())
(*i)->setOnAllDesktops( main->isOnAllDesktops() ); (*i)->setOnAllDesktops(main->isOnAllDesktops());
if( (*i)->activities() != main->activities() ) if ((*i)->activities() != main->activities())
(*i)->setOnActivities( main->activities() ); (*i)->setOnActivities(main->activities());
if( (*i)->keepAbove() != main->keepAbove() ) if ((*i)->keepAbove() != main->keepAbove())
(*i)->setKeepAbove( main->keepAbove() ); (*i)->setKeepAbove(main->keepAbove());
if( (*i)->keepBelow() != main->keepBelow() ) if ((*i)->keepBelow() != main->keepBelow())
(*i)->setKeepBelow( main->keepBelow() ); (*i)->setKeepBelow(main->keepBelow());
// If it's not possible to have the same states then ungroup them, TODO: Check all states // If it's not possible to have the same states then ungroup them, TODO: Check all states
if( (*i)->geometry() != main->geometry() ) if ((*i)->geometry() != main->geometry())
remove( *i ); remove(*i);
if( (*i)->desktop() != main->desktop() ) if ((*i)->desktop() != main->desktop())
remove( *i ); remove(*i);
} }
} }
void ClientGroup::updateItems() void ClientGroup::updateItems()
{ {
items_.clear(); items_.clear();
for( ClientList::const_iterator i = clients_.constBegin(); i != clients_.constEnd(); ++i ) for (ClientList::const_iterator i = clients_.constBegin(); i != clients_.constEnd(); ++i) {
{ QIcon icon((*i)->icon());
QIcon icon( (*i)->icon() ); icon.addPixmap((*i)->miniIcon());
icon.addPixmap( (*i)->miniIcon() ); items_.append(ClientGroupItem((*i)->caption(), icon));
items_.append( ClientGroupItem( (*i)->caption(), icon ));
}
} }
}
void ClientGroup::updateMinMaxSize() void ClientGroup::updateMinMaxSize()
{ {
// Determine entire group's minimum and maximum sizes // Determine entire group's minimum and maximum sizes
minSize_ = QSize( 0, 0 ); minSize_ = QSize(0, 0);
maxSize_ = QSize( INT_MAX, INT_MAX ); maxSize_ = QSize(INT_MAX, INT_MAX);
for( ClientList::const_iterator i = clients_.constBegin(); i != clients_.constEnd(); ++i ) for (ClientList::const_iterator i = clients_.constBegin(); i != clients_.constEnd(); ++i) {
{ if ((*i)->minSize().width() > minSize_.width())
if( (*i)->minSize().width() > minSize_.width() ) minSize_.setWidth((*i)->minSize().width());
minSize_.setWidth( (*i)->minSize().width() ); if ((*i)->minSize().height() > minSize_.height())
if( (*i)->minSize().height() > minSize_.height() ) minSize_.setHeight((*i)->minSize().height());
minSize_.setHeight( (*i)->minSize().height() ); if ((*i)->maxSize().width() < maxSize_.width())
if( (*i)->maxSize().width() < maxSize_.width() ) maxSize_.setWidth((*i)->maxSize().width());
maxSize_.setWidth( (*i)->maxSize().width() ); if ((*i)->maxSize().height() < maxSize_.height())
if( (*i)->maxSize().height() < maxSize_.height() ) maxSize_.setHeight((*i)->maxSize().height());
maxSize_.setHeight( (*i)->maxSize().height() ); }
} if (minSize_.width() > maxSize_.width() ||
if( minSize_.width() > maxSize_.width() || minSize_.height() > maxSize_.height()) {
minSize_.height() > maxSize_.height() )
{
//kWarning(1212) << "ClientGroup's min size is greater than its max size. Setting max to min."; //kWarning(1212) << "ClientGroup's min size is greater than its max size. Setting max to min.";
maxSize_ = minSize_; maxSize_ = minSize_;
} }
// Ensure all windows are within these sizes // Ensure all windows are within these sizes
const QSize size = clients_[visible_]->clientSize(); const QSize size = clients_[visible_]->clientSize();
QSize newSize( QSize newSize(
qBound( minSize_.width(), size.width(), maxSize_.width() ), qBound(minSize_.width(), size.width(), maxSize_.width()),
qBound( minSize_.height(), size.height(), maxSize_.height() )); qBound(minSize_.height(), size.height(), maxSize_.height()));
if( newSize != size ) if (newSize != size)
for( ClientList::const_iterator i = clients_.constBegin(); i != clients_.constEnd(); ++i ) for (ClientList::const_iterator i = clients_.constBegin(); i != clients_.constEnd(); ++i)
// TODO: Doesn't affect shaded windows? // TODO: Doesn't affect shaded windows?
// There seems to be a race condition when using plainResize() which causes the window // There seems to be a race condition when using plainResize() which causes the window
// to sometimes be located at new window's location instead of the visible window's location // to sometimes be located at new window's location instead of the visible window's location
// when a window with a large min size is added to a group with a small window size. // when a window with a large min size is added to a group with a small window size.
(*i)->setGeometry( QRect( clients_[visible_]->pos(), (*i)->sizeForClientSize( newSize ))); (*i)->setGeometry(QRect(clients_[visible_]->pos(), (*i)->sizeForClientSize(newSize)));
} }
} }

View File

@ -43,184 +43,185 @@ class Client;
* copies of the same client. A client MUST NOT be in two groups at the same * copies of the same client. A client MUST NOT be in two groups at the same
* time. All decorated clients SHOULD be in a group, even if it's a group of * time. All decorated clients SHOULD be in a group, even if it's a group of
* one client. * one client.
* *
* rohanp: Had to convert this object to a QObject to make it easier for adding * rohanp: Had to convert this object to a QObject to make it easier for adding
* scripting interface to ClientGroup. * scripting interface to ClientGroup.
* *
* If a group contains multiple clients then only one will ever be mapped at * If a group contains multiple clients then only one will ever be mapped at
* any given time. * any given time.
*/ */
class ClientGroup : public QObject { class ClientGroup : public QObject
{
Q_OBJECT Q_OBJECT
public: public:
/** /**
* Creates a new group containing \p c. * Creates a new group containing \p c.
*/ */
ClientGroup( Client* c ); ClientGroup(Client* c);
~ClientGroup(); ~ClientGroup();
/** /**
* Adds \p c to the group before \p before in the list. If \p becomeVisible is \i true then * Adds \p c to the group before \p before in the list. If \p becomeVisible is \i true then
* the added client will become also the visible client. * the added client will become also the visible client.
*/ */
void add( Client* c, int before = -1, bool becomeVisible = false ); void add(Client* c, int before = -1, bool becomeVisible = false);
/** /**
* Remove the client at index \p index from the group. If \p newGeom is set then the client * Remove the client at index \p index from the group. If \p newGeom is set then the client
* will move and resize to the specified geometry, otherwise it will stay where the group * will move and resize to the specified geometry, otherwise it will stay where the group
* is located. If \p toNullGroup is not true then the client will be added to a new group * is located. If \p toNullGroup is not true then the client will be added to a new group
* of its own. * of its own.
*/ */
void remove( int index, const QRect& newGeom = QRect(), bool toNullGroup = false ); void remove(int index, const QRect& newGeom = QRect(), bool toNullGroup = false);
/** /**
* Remove \p c from the group. If \p newGeom is set then the client will move and resize to * Remove \p c from the group. If \p newGeom is set then the client will move and resize to
* the specified geometry, otherwise it will stay where the group is located. If * the specified geometry, otherwise it will stay where the group is located. If
* \p toNullGroup is not true then the client will be added to a new group of its own. * \p toNullGroup is not true then the client will be added to a new group of its own.
*/ */
void remove( Client* c, const QRect& newGeom = QRect(), bool toNullGroup = false ); void remove(Client* c, const QRect& newGeom = QRect(), bool toNullGroup = false);
/** /**
* Remove all clients from this group. Results in all clients except the first being moved * Remove all clients from this group. Results in all clients except the first being moved
to a group of their own. to a group of their own.
*/ */
void removeAll(); void removeAll();
/** /**
* Close all clients in this group. * Close all clients in this group.
*/ */
void closeAll(); void closeAll();
/** /**
* Move the client at index \p index to the position before the client at index \p before * Move the client at index \p index to the position before the client at index \p before
* in the list. * in the list.
*/ */
void move( int index, int before ); void move(int index, int before);
/** /**
* Move \p c to the position before \p before in the list. * Move \p c to the position before \p before in the list.
*/ */
void move( Client* c, Client* before ); void move(Client* c, Client* before);
/** /**
* Display the right-click client menu belonging to the client at index \p index at the * Display the right-click client menu belonging to the client at index \p index at the
* global coordinates specified by \p pos. * global coordinates specified by \p pos.
*/ */
void displayClientMenu( int index, const QPoint& pos ); void displayClientMenu(int index, const QPoint& pos);
/** /**
* Display the right-click client menu belonging to \p c at the global coordinates * Display the right-click client menu belonging to \p c at the global coordinates
* specified by \p pos. * specified by \p pos.
*/ */
void displayClientMenu( Client* c, const QPoint& pos ); void displayClientMenu(Client* c, const QPoint& pos);
/** /**
* Returns the list index of \p c. * Returns the list index of \p c.
*/ */
int indexOfClient( Client* c ); int indexOfClient(Client* c);
/** /**
* Returns the list index of the currently visible client in the group. * Returns the list index of the currently visible client in the group.
*/ */
int indexOfVisibleClient(); int indexOfVisibleClient();
/** /**
* Returns whether or not this group contains \p c. * Returns whether or not this group contains \p c.
*/ */
bool contains( Client* c ); bool contains(Client* c);
/** /**
* Returns whether or not this group contains the active client. * Returns whether or not this group contains the active client.
*/ */
bool containsActiveClient(); bool containsActiveClient();
/** /**
* Returns the list of all the clients contained in this group in their current order. * Returns the list of all the clients contained in this group in their current order.
*/ */
ClientList clients() const; ClientList clients() const;
/** /**
* Returns a list of the captions and icons of all the clients contained in this group * Returns a list of the captions and icons of all the clients contained in this group
* in their current order. * in their current order.
*/ */
QList< ClientGroupItem > items() const; QList< ClientGroupItem > items() const;
/** /**
* Returns the currently visible client. * Returns the currently visible client.
*/ */
Client* visible(); Client* visible();
/** /**
* Makes the client at index \p index the visible one in the group. * Makes the client at index \p index the visible one in the group.
*/ */
void setVisible( int index ); void setVisible(int index);
/** /**
* Makes \p c the visible client in the group. * Makes \p c the visible client in the group.
*/ */
void setVisible( Client* c ); void setVisible(Client* c);
/** /**
* Returns combined minimum size of all clients in the group. * Returns combined minimum size of all clients in the group.
*/ */
QSize minSize() const; QSize minSize() const;
/** /**
* Returns combined maximum size of all clients in the group. * Returns combined maximum size of all clients in the group.
*/ */
QSize maxSize() const; QSize maxSize() const;
/** /**
* Ensures that all the clients in the group have identical geometries and states using * Ensures that all the clients in the group have identical geometries and states using
* \p main as the primary client to copy the settings off. If \p only is set then only * \p main as the primary client to copy the settings off. If \p only is set then only
* that client is updated to match \p main. * that client is updated to match \p main.
*/ */
void updateStates( Client* main, Client* only = NULL ); void updateStates(Client* main, Client* only = NULL);
private: private:
/** /**
* Regenerate the list of client captions and icons. * Regenerate the list of client captions and icons.
*/ */
void updateItems(); void updateItems();
/** /**
* Determine the combined minimum and maximum sizes of all clients in the group. * Determine the combined minimum and maximum sizes of all clients in the group.
*/ */
void updateMinMaxSize(); void updateMinMaxSize();
ClientList clients_; ClientList clients_;
QList< ClientGroupItem > items_; QList< ClientGroupItem > items_;
int visible_; int visible_;
QSize minSize_; QSize minSize_;
QSize maxSize_; QSize maxSize_;
friend class Client; friend class Client;
}; };
inline int ClientGroup::indexOfClient( Client* c ) inline int ClientGroup::indexOfClient(Client* c)
{ {
return clients_.indexOf( c ); return clients_.indexOf(c);
} }
inline int ClientGroup::indexOfVisibleClient() inline int ClientGroup::indexOfVisibleClient()
{ {
return visible_; return visible_;
} }
inline bool ClientGroup::contains( Client* c ) inline bool ClientGroup::contains(Client* c)
{ {
return clients_.contains( c ); return clients_.contains(c);
} }
inline ClientList ClientGroup::clients() const inline ClientList ClientGroup::clients() const
{ {
return clients_; return clients_;
} }
inline QList< ClientGroupItem > ClientGroup::items() const inline QList< ClientGroupItem > ClientGroup::items() const
{ {
return items_; return items_;
} }
inline Client* ClientGroup::visible() inline Client* ClientGroup::visible()
{ {
return clients_[visible_]; return clients_[visible_];
} }
inline QSize ClientGroup::minSize() const inline QSize ClientGroup::minSize() const
{ {
return minSize_; return minSize_;
} }
inline QSize ClientGroup::maxSize() const inline QSize ClientGroup::maxSize() const
{ {
return maxSize_; return maxSize_;
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -36,89 +36,84 @@ namespace KWin
{ {
CompositingPrefs::CompositingPrefs() CompositingPrefs::CompositingPrefs()
: mRecommendCompositing( false ) : mRecommendCompositing(false)
, mEnableVSync( true ) , mEnableVSync(true)
, mEnableDirectRendering( true ) , mEnableDirectRendering(true)
, mStrictBinding( true ) , mStrictBinding(true)
{ {
} }
CompositingPrefs::~CompositingPrefs() CompositingPrefs::~CompositingPrefs()
{ {
} }
bool CompositingPrefs::recommendCompositing() const bool CompositingPrefs::recommendCompositing() const
{ {
return mRecommendCompositing; return mRecommendCompositing;
} }
bool CompositingPrefs::compositingPossible() bool CompositingPrefs::compositingPossible()
{ {
#ifdef KWIN_HAVE_COMPOSITING #ifdef KWIN_HAVE_COMPOSITING
Extensions::init(); Extensions::init();
if( !Extensions::compositeAvailable()) if (!Extensions::compositeAvailable()) {
{ kDebug(1212) << "No composite extension available";
kDebug( 1212 ) << "No composite extension available";
return false; return false;
} }
if( !Extensions::damageAvailable()) if (!Extensions::damageAvailable()) {
{ kDebug(1212) << "No damage extension available";
kDebug( 1212 ) << "No damage extension available";
return false; return false;
} }
#ifdef KWIN_HAVE_OPENGL_COMPOSITING #ifdef KWIN_HAVE_OPENGL_COMPOSITING
if( Extensions::glxAvailable()) if (Extensions::glxAvailable())
return true; return true;
#endif #endif
#ifdef KWIN_HAVE_XRENDER_COMPOSITING #ifdef KWIN_HAVE_XRENDER_COMPOSITING
if( Extensions::renderAvailable() && Extensions::fixesAvailable()) if (Extensions::renderAvailable() && Extensions::fixesAvailable())
return true; return true;
#endif #endif
#ifdef KWIN_HAVE_OPENGLES #ifdef KWIN_HAVE_OPENGLES
return true; return true;
#endif #endif
kDebug( 1212 ) << "No OpenGL or XRender/XFixes support"; kDebug(1212) << "No OpenGL or XRender/XFixes support";
return false; return false;
#else #else
return false; return false;
#endif #endif
} }
QString CompositingPrefs::compositingNotPossibleReason() QString CompositingPrefs::compositingNotPossibleReason()
{ {
#ifdef KWIN_HAVE_COMPOSITING #ifdef KWIN_HAVE_COMPOSITING
Extensions::init(); Extensions::init();
if( !Extensions::compositeAvailable() || !Extensions::damageAvailable()) if (!Extensions::compositeAvailable() || !Extensions::damageAvailable()) {
{
return i18n("Required X extensions (XComposite and XDamage) are not available."); return i18n("Required X extensions (XComposite and XDamage) are not available.");
} }
#if defined( KWIN_HAVE_OPENGL_COMPOSITING ) && !defined( KWIN_HAVE_XRENDER_COMPOSITING ) #if defined( KWIN_HAVE_OPENGL_COMPOSITING ) && !defined( KWIN_HAVE_XRENDER_COMPOSITING )
if( !Extensions::glxAvailable()) if (!Extensions::glxAvailable())
return i18n( "GLX/OpenGL are not available and only OpenGL support is compiled." ); return i18n("GLX/OpenGL are not available and only OpenGL support is compiled.");
#elif !defined( KWIN_HAVE_OPENGL_COMPOSITING ) && defined( KWIN_HAVE_XRENDER_COMPOSITING ) #elif !defined( KWIN_HAVE_OPENGL_COMPOSITING ) && defined( KWIN_HAVE_XRENDER_COMPOSITING )
if( !( Extensions::renderAvailable() && Extensions::fixesAvailable())) if (!(Extensions::renderAvailable() && Extensions::fixesAvailable()))
return i18n( "XRender/XFixes extensions are not available and only XRender support" return i18n("XRender/XFixes extensions are not available and only XRender support"
" is compiled." ); " is compiled.");
#else #else
if( !( Extensions::glxAvailable() if (!(Extensions::glxAvailable()
|| ( Extensions::renderAvailable() && Extensions::fixesAvailable()))) || (Extensions::renderAvailable() && Extensions::fixesAvailable()))) {
{ return i18n("GLX/OpenGL and XRender/XFixes are not available.");
return i18n( "GLX/OpenGL and XRender/XFixes are not available." ); }
}
#endif #endif
return QString(); return QString();
#else #else
return i18n("Compositing was disabled at compile time.\n" return i18n("Compositing was disabled at compile time.\n"
"It is likely Xorg development headers were not installed."); "It is likely Xorg development headers were not installed.");
#endif #endif
} }
void CompositingPrefs::detect() void CompositingPrefs::detect()
{ {
if( !compositingPossible()) if (!compositingPossible()) {
{
return; return;
} }
#ifdef KWIN_HAVE_OPENGL_COMPOSITING #ifdef KWIN_HAVE_OPENGL_COMPOSITING
#ifdef KWIN_HAVE_OPENGLES #ifdef KWIN_HAVE_OPENGLES
@ -144,8 +139,7 @@ void CompositingPrefs::detect()
} }
#else #else
// HACK: This is needed for AIGLX // HACK: This is needed for AIGLX
if( qstrcmp( qgetenv( "KWIN_DIRECT_GL" ), "1" ) != 0 ) if (qstrcmp(qgetenv("KWIN_DIRECT_GL"), "1") != 0) {
{
// Start an external helper program that initializes GLX and returns // Start an external helper program that initializes GLX and returns
// 0 if we can use direct rendering, and 1 otherwise. // 0 if we can use direct rendering, and 1 otherwise.
// The reason we have to use an external program is that after GLX // The reason we have to use an external program is that after GLX
@ -153,40 +147,38 @@ void CompositingPrefs::detect()
// environment variable. // environment variable.
// Direct rendering is preferred, since not all OpenGL extensions are // Direct rendering is preferred, since not all OpenGL extensions are
// available with indirect rendering. // available with indirect rendering.
const QString opengl_test = KStandardDirs::findExe( "kwin_opengl_test" ); const QString opengl_test = KStandardDirs::findExe("kwin_opengl_test");
if ( QProcess::execute( opengl_test ) != 0 ) if (QProcess::execute(opengl_test) != 0)
setenv( "LIBGL_ALWAYS_INDIRECT", "1", true ); setenv("LIBGL_ALWAYS_INDIRECT", "1", true);
} }
if( !Extensions::glxAvailable()) if (!Extensions::glxAvailable()) {
{ kDebug(1212) << "No GLX available";
kDebug( 1212 ) << "No GLX available";
return; return;
} }
int glxmajor, glxminor; int glxmajor, glxminor;
glXQueryVersion( display(), &glxmajor, &glxminor ); glXQueryVersion(display(), &glxmajor, &glxminor);
kDebug( 1212 ) << "glx version is " << glxmajor << "." << glxminor; kDebug(1212) << "glx version is " << glxmajor << "." << glxminor;
bool hasglx13 = ( glxmajor > 1 || ( glxmajor == 1 && glxminor >= 3 )); bool hasglx13 = (glxmajor > 1 || (glxmajor == 1 && glxminor >= 3));
// remember and later restore active context // remember and later restore active context
GLXContext oldcontext = glXGetCurrentContext(); GLXContext oldcontext = glXGetCurrentContext();
GLXDrawable olddrawable = glXGetCurrentDrawable(); GLXDrawable olddrawable = glXGetCurrentDrawable();
GLXDrawable oldreaddrawable = None; GLXDrawable oldreaddrawable = None;
if( hasglx13 ) if (hasglx13)
oldreaddrawable = glXGetCurrentReadDrawable(); oldreaddrawable = glXGetCurrentReadDrawable();
if( initGLXContext() ) if (initGLXContext()) {
{
detectDriverAndVersion(); detectDriverAndVersion();
applyDriverSpecificOptions(); applyDriverSpecificOptions();
} }
if( hasglx13 ) if (hasglx13)
glXMakeContextCurrent( display(), olddrawable, oldreaddrawable, oldcontext ); glXMakeContextCurrent(display(), olddrawable, oldreaddrawable, oldcontext);
else else
glXMakeCurrent( display(), olddrawable, oldcontext ); glXMakeCurrent(display(), olddrawable, oldcontext);
deleteGLXContext(); deleteGLXContext();
#endif #endif
#endif #endif
} }
bool CompositingPrefs::initGLXContext() bool CompositingPrefs::initGLXContext()
{ {
@ -202,44 +194,41 @@ bool CompositingPrefs::initGLXContext()
attribs << GLX_BLUE_SIZE << 1; attribs << GLX_BLUE_SIZE << 1;
attribs << None; attribs << None;
XVisualInfo* visinfo = glXChooseVisual( display(), DefaultScreen( display()), attribs.data() ); XVisualInfo* visinfo = glXChooseVisual(display(), DefaultScreen(display()), attribs.data());
if( !visinfo ) if (!visinfo) {
{
attribs.last() = GLX_DOUBLEBUFFER; attribs.last() = GLX_DOUBLEBUFFER;
attribs << None; attribs << None;
visinfo = glXChooseVisual( display(), DefaultScreen( display()), attribs.data() ); visinfo = glXChooseVisual(display(), DefaultScreen(display()), attribs.data());
if (!visinfo) if (!visinfo) {
{ kDebug(1212) << "Error: couldn't find RGB GLX visual";
kDebug( 1212 ) << "Error: couldn't find RGB GLX visual";
return false; return false;
}
} }
}
mGLContext = glXCreateContext( display(), visinfo, NULL, True ); mGLContext = glXCreateContext(display(), visinfo, NULL, True);
if ( !mGLContext ) if (!mGLContext) {
{ kDebug(1212) << "glXCreateContext failed";
kDebug( 1212 ) << "glXCreateContext failed"; XDestroyWindow(display(), mGLWindow);
XDestroyWindow( display(), mGLWindow );
return false; return false;
} }
XSetWindowAttributes attr; XSetWindowAttributes attr;
attr.background_pixel = 0; attr.background_pixel = 0;
attr.border_pixel = 0; attr.border_pixel = 0;
attr.colormap = XCreateColormap( display(), rootWindow(), visinfo->visual, AllocNone ); attr.colormap = XCreateColormap(display(), rootWindow(), visinfo->visual, AllocNone);
attr.event_mask = StructureNotifyMask | ExposureMask; attr.event_mask = StructureNotifyMask | ExposureMask;
unsigned long mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; unsigned long mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
int width = 100, height = 100; int width = 100, height = 100;
mGLWindow = XCreateWindow( display(), rootWindow(), 0, 0, width, height, mGLWindow = XCreateWindow(display(), rootWindow(), 0, 0, width, height,
0, visinfo->depth, InputOutput, 0, visinfo->depth, InputOutput,
visinfo->visual, mask, &attr ); visinfo->visual, mask, &attr);
return glXMakeCurrent( display(), mGLWindow, mGLContext ) && !handler.error( true ); return glXMakeCurrent(display(), mGLWindow, mGLContext) && !handler.error(true);
#else #else
return false; return false;
#endif #endif
#else #else
return false; return false;
#endif #endif
} }
@ -247,10 +236,10 @@ void CompositingPrefs::deleteGLXContext()
{ {
#ifdef KWIN_HAVE_OPENGL_COMPOSITING #ifdef KWIN_HAVE_OPENGL_COMPOSITING
#ifndef KWIN_HAVE_OPENGLES #ifndef KWIN_HAVE_OPENGLES
if( mGLContext == NULL ) if (mGLContext == NULL)
return; return;
glXDestroyContext( display(), mGLContext ); glXDestroyContext(display(), mGLContext);
XDestroyWindow( display(), mGLWindow ); XDestroyWindow(display(), mGLWindow);
#endif #endif
#endif #endif
} }
@ -258,14 +247,14 @@ void CompositingPrefs::deleteGLXContext()
bool CompositingPrefs::initEGLContext() bool CompositingPrefs::initEGLContext()
{ {
#ifdef KWIN_HAVE_OPENGLES #ifdef KWIN_HAVE_OPENGLES
mEGLDisplay = eglGetDisplay( display() ); mEGLDisplay = eglGetDisplay(display());
if (mEGLDisplay == EGL_NO_DISPLAY) { if (mEGLDisplay == EGL_NO_DISPLAY) {
return false; return false;
} }
if (eglInitialize( mEGLDisplay, 0, 0 ) == EGL_FALSE) { if (eglInitialize(mEGLDisplay, 0, 0) == EGL_FALSE) {
return false; return false;
} }
eglBindAPI( EGL_OPENGL_ES_API ); eglBindAPI(EGL_OPENGL_ES_API);
const EGLint config_attribs[] = { const EGLint config_attribs[] = {
EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
@ -297,26 +286,26 @@ bool CompositingPrefs::initEGLContext()
XSetWindowAttributes attr; XSetWindowAttributes attr;
attr.background_pixel = 0; attr.background_pixel = 0;
attr.border_pixel = 0; attr.border_pixel = 0;
attr.colormap = XCreateColormap( display(), rootWindow(), (Visual*)QX11Info::appVisual(), AllocNone ); attr.colormap = XCreateColormap(display(), rootWindow(), (Visual*)QX11Info::appVisual(), AllocNone);
attr.event_mask = StructureNotifyMask | ExposureMask; attr.event_mask = StructureNotifyMask | ExposureMask;
unsigned long mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; unsigned long mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
int width = 100, height = 100; int width = 100, height = 100;
mGLWindow = XCreateWindow( display(), rootWindow(), 0, 0, width, height, mGLWindow = XCreateWindow(display(), rootWindow(), 0, 0, width, height,
0, QX11Info::appDepth(), InputOutput, 0, QX11Info::appDepth(), InputOutput,
(Visual*)QX11Info::appVisual(), mask, &attr ); (Visual*)QX11Info::appVisual(), mask, &attr);
mEGLSurface = eglCreateWindowSurface( mEGLDisplay, config, mGLWindow, 0 ); mEGLSurface = eglCreateWindowSurface(mEGLDisplay, config, mGLWindow, 0);
const EGLint context_attribs[] = { const EGLint context_attribs[] = {
EGL_CONTEXT_CLIENT_VERSION, 2, EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE EGL_NONE
}; };
mEGLContext = eglCreateContext( mEGLDisplay, config, EGL_NO_CONTEXT, context_attribs ); mEGLContext = eglCreateContext(mEGLDisplay, config, EGL_NO_CONTEXT, context_attribs);
if (mEGLContext == EGL_NO_CONTEXT) { if (mEGLContext == EGL_NO_CONTEXT) {
return false; return false;
} }
if (eglMakeCurrent( mEGLDisplay, mEGLSurface, mEGLSurface, mEGLContext ) == EGL_FALSE) { if (eglMakeCurrent(mEGLDisplay, mEGLSurface, mEGLSurface, mEGLContext) == EGL_FALSE) {
return false; return false;
} }
EGLint error = eglGetError(); EGLint error = eglGetError();
@ -337,32 +326,32 @@ void CompositingPrefs::deleteEGLContext()
eglDestroySurface(mEGLDisplay, mEGLSurface); eglDestroySurface(mEGLDisplay, mEGLSurface);
eglTerminate(mEGLDisplay); eglTerminate(mEGLDisplay);
eglReleaseThread(); eglReleaseThread();
XDestroyWindow( display(), mGLWindow ); XDestroyWindow(display(), mGLWindow);
#endif #endif
} }
void CompositingPrefs::detectDriverAndVersion() void CompositingPrefs::detectDriverAndVersion()
{ {
#ifdef KWIN_HAVE_OPENGL_COMPOSITING #ifdef KWIN_HAVE_OPENGL_COMPOSITING
GLPlatform *gl = GLPlatform::instance(); GLPlatform *gl = GLPlatform::instance();
gl->detect(); gl->detect();
gl->printResults(); gl->printResults();
#endif #endif
} }
// See http://techbase.kde.org/Projects/KWin/HW for a list of some cards that are known to work. // See http://techbase.kde.org/Projects/KWin/HW for a list of some cards that are known to work.
void CompositingPrefs::applyDriverSpecificOptions() void CompositingPrefs::applyDriverSpecificOptions()
{ {
#ifdef KWIN_HAVE_OPENGL_COMPOSITING #ifdef KWIN_HAVE_OPENGL_COMPOSITING
// Always recommend // Always recommend
mRecommendCompositing = true; mRecommendCompositing = true;
GLPlatform *gl = GLPlatform::instance(); GLPlatform *gl = GLPlatform::instance();
mStrictBinding = !gl->supports( LooseBinding ); mStrictBinding = !gl->supports(LooseBinding);
if ( gl->driver() == Driver_Intel ) if (gl->driver() == Driver_Intel)
mEnableVSync = false; mEnableVSync = false;
#endif #endif
} }
} // namespace } // namespace

View File

@ -40,9 +40,15 @@ public:
static bool compositingPossible(); static bool compositingPossible();
static QString compositingNotPossibleReason(); static QString compositingNotPossibleReason();
bool recommendCompositing() const; bool recommendCompositing() const;
bool enableVSync() const { return mEnableVSync; } bool enableVSync() const {
bool enableDirectRendering() const { return mEnableDirectRendering; } return mEnableVSync;
bool strictBinding() const { return mStrictBinding; } }
bool enableDirectRendering() const {
return mEnableDirectRendering;
}
bool strictBinding() const {
return mStrictBinding;
}
void detect(); void detect();

View File

@ -27,61 +27,59 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
namespace KWin namespace KWin
{ {
Deleted::Deleted( Workspace* ws ) Deleted::Deleted(Workspace* ws)
: Toplevel( ws ) : Toplevel(ws)
, delete_refcount( 1 ) , delete_refcount(1)
, no_border( true ) , no_border(true)
, padding_left( 0 ) , padding_left(0)
, padding_top( 0 ) , padding_top(0)
, padding_right( 0 ) , padding_right(0)
, padding_bottom( 0 ) , padding_bottom(0)
{ {
} }
Deleted::~Deleted() Deleted::~Deleted()
{ {
if( delete_refcount != 0 ) if (delete_refcount != 0)
kError(1212) << "Deleted client has non-zero reference count (" << delete_refcount << ")"; kError(1212) << "Deleted client has non-zero reference count (" << delete_refcount << ")";
assert( delete_refcount == 0 ); assert(delete_refcount == 0);
workspace()->removeDeleted( this, Allowed ); workspace()->removeDeleted(this, Allowed);
deleteEffectWindow(); deleteEffectWindow();
} }
Deleted* Deleted::create( Toplevel* c ) Deleted* Deleted::create(Toplevel* c)
{ {
Deleted* d = new Deleted( c->workspace()); Deleted* d = new Deleted(c->workspace());
d->copyToDeleted( c ); d->copyToDeleted(c);
d->workspace()->addDeleted( d, Allowed ); d->workspace()->addDeleted(d, Allowed);
return d; return d;
} }
// to be used only from Workspace::finishCompositing() // to be used only from Workspace::finishCompositing()
void Deleted::discard( allowed_t ) void Deleted::discard(allowed_t)
{ {
delete_refcount = 0; delete_refcount = 0;
delete this; delete this;
} }
void Deleted::copyToDeleted( Toplevel* c ) void Deleted::copyToDeleted(Toplevel* c)
{ {
assert( dynamic_cast< Deleted* >( c ) == NULL ); assert(dynamic_cast< Deleted* >(c) == NULL);
Toplevel::copyToDeleted( c ); Toplevel::copyToDeleted(c);
desk = c->desktop(); desk = c->desktop();
activityList = c->activities(); activityList = c->activities();
contentsRect = QRect( c->clientPos(), c->clientSize()); contentsRect = QRect(c->clientPos(), c->clientSize());
transparent_rect = c->transparentRect(); transparent_rect = c->transparentRect();
if( WinInfo* cinfo = dynamic_cast< WinInfo* >( info )) if (WinInfo* cinfo = dynamic_cast< WinInfo* >(info))
cinfo->disable(); cinfo->disable();
Client* client = dynamic_cast<Client*>(c); Client* client = dynamic_cast<Client*>(c);
if( client ) if (client) {
{
no_border = client->noBorder(); no_border = client->noBorder();
padding_left = client->paddingLeft(); padding_left = client->paddingLeft();
padding_right = client->paddingRight(); padding_right = client->paddingRight();
padding_bottom = client->paddingBottom(); padding_bottom = client->paddingBottom();
padding_top = client->paddingTop(); padding_top = client->paddingTop();
if( !no_border ) if (!no_border) {
{
client->layoutDecorationRects(decoration_left, client->layoutDecorationRects(decoration_left,
decoration_top, decoration_top,
decoration_right, decoration_right,
@ -91,64 +89,64 @@ void Deleted::copyToDeleted( Toplevel* c )
decorationPixmapRight = *client->rightDecoPixmap(); decorationPixmapRight = *client->rightDecoPixmap();
decorationPixmapTop = *client->topDecoPixmap(); decorationPixmapTop = *client->topDecoPixmap();
decorationPixmapBottom = *client->bottomDecoPixmap(); decorationPixmapBottom = *client->bottomDecoPixmap();
}
} }
} }
}
void Deleted::unrefWindow( bool delay ) void Deleted::unrefWindow(bool delay)
{ {
if( --delete_refcount > 0 ) if (--delete_refcount > 0)
return; return;
// needs to be delayed when calling from effects, otherwise it'd be rather // needs to be delayed when calling from effects, otherwise it'd be rather
// complicated to handle the case of the window going away during a painting pass // complicated to handle the case of the window going away during a painting pass
if( delay ) if (delay)
deleteLater(); deleteLater();
else else
delete this; delete this;
} }
int Deleted::desktop() const int Deleted::desktop() const
{ {
return desk; return desk;
} }
QStringList Deleted::activities() const QStringList Deleted::activities() const
{ {
return activityList; return activityList;
} }
QPoint Deleted::clientPos() const QPoint Deleted::clientPos() const
{ {
return contentsRect.topLeft(); return contentsRect.topLeft();
} }
QSize Deleted::clientSize() const QSize Deleted::clientSize() const
{ {
return contentsRect.size(); return contentsRect.size();
} }
void Deleted::debug( QDebug& stream ) const void Deleted::debug(QDebug& stream) const
{ {
stream << "\'ID:" << window() << "\' (deleted)"; stream << "\'ID:" << window() << "\' (deleted)";
} }
void Deleted::layoutDecorationRects(QRect& left, QRect& top, QRect& right, QRect& bottom) const void Deleted::layoutDecorationRects(QRect& left, QRect& top, QRect& right, QRect& bottom) const
{ {
left = decoration_left; left = decoration_left;
top = decoration_top; top = decoration_top;
right = decoration_right; right = decoration_right;
bottom = decoration_bottom; bottom = decoration_bottom;
} }
QRect Deleted::decorationRect() const QRect Deleted::decorationRect() const
{ {
return rect().adjusted(-padding_left, -padding_top, padding_top, padding_bottom); return rect().adjusted(-padding_left, -padding_top, padding_top, padding_bottom);
} }
QRect Deleted::transparentRect() const QRect Deleted::transparentRect() const
{ {
return transparent_rect; return transparent_rect;
} }
} // namespace } // namespace

102
deleted.h
View File

@ -28,57 +28,67 @@ namespace KWin
class Deleted class Deleted
: public Toplevel : public Toplevel
{ {
Q_OBJECT Q_OBJECT
public: public:
static Deleted* create( Toplevel* c ); static Deleted* create(Toplevel* c);
// used by effects to keep the window around for e.g. fadeout effects when it's destroyed // used by effects to keep the window around for e.g. fadeout effects when it's destroyed
void refWindow(); void refWindow();
void unrefWindow( bool delay = false ); void unrefWindow(bool delay = false);
void discard( allowed_t ); void discard(allowed_t);
virtual int desktop() const; virtual int desktop() const;
virtual QStringList activities() const; virtual QStringList activities() const;
virtual QPoint clientPos() const; virtual QPoint clientPos() const;
virtual QSize clientSize() const; virtual QSize clientSize() const;
virtual QRect transparentRect() const; virtual QRect transparentRect() const;
const QPixmap *topDecoPixmap() const { return &decorationPixmapTop; } const QPixmap *topDecoPixmap() const {
const QPixmap *leftDecoPixmap() const { return &decorationPixmapLeft; } return &decorationPixmapTop;
const QPixmap *bottomDecoPixmap() const { return &decorationPixmapBottom; } }
const QPixmap *rightDecoPixmap() const { return &decorationPixmapRight; } const QPixmap *leftDecoPixmap() const {
bool noBorder() const { return no_border; } return &decorationPixmapLeft;
void layoutDecorationRects(QRect &left, QRect &top, QRect &right, QRect &bottom) const; }
virtual void addRepaintFull(); // in composite.cpp const QPixmap *bottomDecoPixmap() const {
QRect decorationRect() const; return &decorationPixmapBottom;
protected: }
virtual void debug( QDebug& stream ) const; const QPixmap *rightDecoPixmap() const {
virtual bool shouldUnredirect() const; return &decorationPixmapRight;
private: }
Deleted( Workspace *ws ); // use create() bool noBorder() const {
void copyToDeleted( Toplevel* c ); return no_border;
virtual ~Deleted(); // deleted only using unrefWindow() }
int delete_refcount; void layoutDecorationRects(QRect &left, QRect &top, QRect &right, QRect &bottom) const;
double window_opacity; virtual void addRepaintFull(); // in composite.cpp
int desk; QRect decorationRect() const;
QStringList activityList; protected:
QRect contentsRect; // for clientPos()/clientSize() virtual void debug(QDebug& stream) const;
QRect transparent_rect; virtual bool shouldUnredirect() const;
private:
Deleted(Workspace *ws); // use create()
void copyToDeleted(Toplevel* c);
virtual ~Deleted(); // deleted only using unrefWindow()
int delete_refcount;
double window_opacity;
int desk;
QStringList activityList;
QRect contentsRect; // for clientPos()/clientSize()
QRect transparent_rect;
QPixmap decorationPixmapLeft; QPixmap decorationPixmapLeft;
QPixmap decorationPixmapRight; QPixmap decorationPixmapRight;
QPixmap decorationPixmapTop; QPixmap decorationPixmapTop;
QPixmap decorationPixmapBottom; QPixmap decorationPixmapBottom;
bool no_border; bool no_border;
QRect decoration_left; QRect decoration_left;
QRect decoration_right; QRect decoration_right;
QRect decoration_top; QRect decoration_top;
QRect decoration_bottom; QRect decoration_bottom;
int padding_left, padding_top, padding_right, padding_bottom; int padding_left, padding_top, padding_right, padding_bottom;
}; };
inline void Deleted::refWindow() inline void Deleted::refWindow()
{ {
++delete_refcount; ++delete_refcount;
} }
} // namespace } // namespace

View File

@ -38,597 +38,543 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
namespace KWin namespace KWin
{ {
DesktopChangeOSD::DesktopChangeOSD( Workspace* ws ) DesktopChangeOSD::DesktopChangeOSD(Workspace* ws)
: QGraphicsView() : QGraphicsView()
, m_wspace( ws ) , m_wspace(ws)
, m_scene( 0 ) , m_scene(0)
, m_active( false ) , m_active(false)
, m_show( false ) , m_show(false)
, m_delayTime( 0 ) , m_delayTime(0)
, m_textOnly( false ) , m_textOnly(false)
{ {
setWindowFlags( Qt::X11BypassWindowManagerHint ); setWindowFlags(Qt::X11BypassWindowManagerHint);
setFrameStyle( QFrame::NoFrame ); setFrameStyle(QFrame::NoFrame);
viewport()->setAutoFillBackground( false ); viewport()->setAutoFillBackground(false);
setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setAttribute( Qt::WA_TranslucentBackground ); setAttribute(Qt::WA_TranslucentBackground);
m_frame.setImagePath( "dialogs/background" ); m_frame.setImagePath("dialogs/background");
m_frame.setCacheAllRenderedFrames( true ); m_frame.setCacheAllRenderedFrames(true);
m_frame.setEnabledBorders( Plasma::FrameSvg::AllBorders ); m_frame.setEnabledBorders(Plasma::FrameSvg::AllBorders);
m_item_frame.setImagePath( "widgets/pager" ); m_item_frame.setImagePath("widgets/pager");
m_item_frame.setCacheAllRenderedFrames( true ); m_item_frame.setCacheAllRenderedFrames(true);
m_item_frame.setEnabledBorders( Plasma::FrameSvg::AllBorders ); m_item_frame.setEnabledBorders(Plasma::FrameSvg::AllBorders);
m_delayedHideTimer.setSingleShot( true ); m_delayedHideTimer.setSingleShot(true);
connect( &m_delayedHideTimer, SIGNAL(timeout()), this, SLOT(hide()) ); connect(&m_delayedHideTimer, SIGNAL(timeout()), this, SLOT(hide()));
m_scene = new QGraphicsScene( 0 ); m_scene = new QGraphicsScene(0);
setScene( m_scene ); setScene(m_scene);
reconfigure(); reconfigure();
m_scene->addItem( new DesktopChangeText( m_wspace ) ); m_scene->addItem(new DesktopChangeText(m_wspace));
} }
DesktopChangeOSD::~DesktopChangeOSD() DesktopChangeOSD::~DesktopChangeOSD()
{ {
delete m_scene; delete m_scene;
} }
void DesktopChangeOSD::reconfigure() void DesktopChangeOSD::reconfigure()
{ {
KSharedConfigPtr c(KGlobal::config()); KSharedConfigPtr c(KGlobal::config());
const KConfigGroup cg = c->group( "PopupInfo" ); const KConfigGroup cg = c->group("PopupInfo");
m_show = cg.readEntry( "ShowPopup", false ); m_show = cg.readEntry("ShowPopup", false);
m_delayTime = cg.readEntry( "PopupHideDelay", 1000 ); m_delayTime = cg.readEntry("PopupHideDelay", 1000);
m_textOnly = cg.readEntry( "TextOnly", false ); m_textOnly = cg.readEntry("TextOnly", false);
numberDesktopsChanged(); numberDesktopsChanged();
} }
void DesktopChangeOSD::desktopChanged( int old ) void DesktopChangeOSD::desktopChanged(int old)
{ {
if( !m_show ) if (!m_show)
return; return;
// we have to stop in case the old desktop does not exist anymore // we have to stop in case the old desktop does not exist anymore
if( old > m_wspace->numberOfDesktops() ) if (old > m_wspace->numberOfDesktops())
return; return;
// calculate where icons have to be shown // calculate where icons have to be shown
QPoint diff = m_wspace->desktopGridCoords( m_wspace->currentDesktop() ) - m_wspace->desktopGridCoords( old ); QPoint diff = m_wspace->desktopGridCoords(m_wspace->currentDesktop()) - m_wspace->desktopGridCoords(old);
QHash< int, DesktopChangeItem::Arrow > hash = QHash< int, DesktopChangeItem::Arrow>(); QHash< int, DesktopChangeItem::Arrow > hash = QHash< int, DesktopChangeItem::Arrow>();
int desktop = old; int desktop = old;
int target = m_wspace->currentDesktop(); int target = m_wspace->currentDesktop();
int x = diff.x(); int x = diff.x();
int y = diff.y(); int y = diff.y();
if( y >= 0 ) if (y >= 0) {
{
// first go in x direction, then in y // first go in x direction, then in y
while( desktop != target ) while (desktop != target) {
{ if (x != 0) {
if( x != 0 ) if (x < 0) {
{
if( x < 0 )
{
x++; x++;
hash.insert( desktop, DesktopChangeItem::LEFT ); hash.insert(desktop, DesktopChangeItem::LEFT);
desktop = m_wspace->desktopToLeft( desktop ); desktop = m_wspace->desktopToLeft(desktop);
} } else {
else
{
x--; x--;
hash.insert( desktop, DesktopChangeItem::RIGHT ); hash.insert(desktop, DesktopChangeItem::RIGHT);
desktop = m_wspace->desktopToRight( desktop ); desktop = m_wspace->desktopToRight(desktop);
}
continue;
} }
y--; continue;
hash.insert( desktop, DesktopChangeItem::DOWN );
desktop = m_wspace->desktopBelow( desktop );
} }
y--;
hash.insert(desktop, DesktopChangeItem::DOWN);
desktop = m_wspace->desktopBelow(desktop);
} }
else } else {
{
// first go in y direction, then in x // first go in y direction, then in x
while( target != desktop ) while (target != desktop) {
{ if (y != 0) {
if( y != 0 )
{
// only go upward // only go upward
y++; y++;
hash.insert( desktop, DesktopChangeItem::UP ); hash.insert(desktop, DesktopChangeItem::UP);
desktop = m_wspace->desktopAbove( desktop ); desktop = m_wspace->desktopAbove(desktop);
continue; continue;
} }
if( x != 0 ) if (x != 0) {
{ if (x < 0) {
if( x < 0 )
{
x++; x++;
hash.insert( desktop, DesktopChangeItem::LEFT ); hash.insert(desktop, DesktopChangeItem::LEFT);
desktop = m_wspace->desktopToLeft( desktop ); desktop = m_wspace->desktopToLeft(desktop);
} } else {
else
{
x--; x--;
hash.insert( desktop, DesktopChangeItem::RIGHT ); hash.insert(desktop, DesktopChangeItem::RIGHT);
desktop = m_wspace->desktopToRight( desktop ); desktop = m_wspace->desktopToRight(desktop);
}
} }
} }
} }
}
// now we know which desktop has to show an arrow -> set the arrow for each desktop // now we know which desktop has to show an arrow -> set the arrow for each desktop
int numberOfArrows = qAbs( diff.x() ) + qAbs( diff.y() ); int numberOfArrows = qAbs(diff.x()) + qAbs(diff.y());
foreach( QGraphicsItem* it, m_scene->items() ) foreach (QGraphicsItem * it, m_scene->items()) {
{ DesktopChangeItem* item = qgraphicsitem_cast< DesktopChangeItem* >(it);
DesktopChangeItem* item = qgraphicsitem_cast< DesktopChangeItem* >( it ); if (item) {
if( item ) if (hash.contains(item->desktop())) {
{ QPoint distance = m_wspace->desktopGridCoords(m_wspace->currentDesktop())
if( hash.contains( item->desktop() ) ) - m_wspace->desktopGridCoords(item->desktop());
{ int desktopDistance = numberOfArrows - (qAbs(distance.x()) + qAbs(distance.y()));
QPoint distance = m_wspace->desktopGridCoords( m_wspace->currentDesktop() ) int start = m_delayTime / numberOfArrows * desktopDistance - m_delayTime * 0.15f;
- m_wspace->desktopGridCoords( item->desktop() ); int stop = m_delayTime / numberOfArrows * (desktopDistance + 1) + m_delayTime * 0.15f;
int desktopDistance = numberOfArrows - ( qAbs( distance.x() ) + qAbs( distance.y() ) ); start = qMax(start, 0);
int start = m_delayTime/numberOfArrows * desktopDistance - m_delayTime*0.15f; item->setArrow(hash[ item->desktop()], start, stop);
int stop = m_delayTime/numberOfArrows * (desktopDistance + 1) + m_delayTime*0.15f; } else {
start = qMax( start, 0 ); item->setArrow(DesktopChangeItem::NONE, 0, 0);
item->setArrow( hash[ item->desktop() ], start, stop ); }
} if (old != m_wspace->currentDesktop()) {
else if (item->desktop() == m_wspace->currentDesktop())
{ item->startDesktopHighLightAnimation(m_delayTime * 0.33);
item->setArrow( DesktopChangeItem::NONE, 0, 0 ); if (m_active && item->desktop() == old)
}
if( old != m_wspace->currentDesktop() )
{
if( item->desktop() == m_wspace->currentDesktop() )
item->startDesktopHighLightAnimation( m_delayTime * 0.33 );
if( m_active && item->desktop() == old )
item->stopDesktopHighLightAnimation(); item->stopDesktopHighLightAnimation();
}
} }
} }
if( m_active ) }
{ if (m_active) {
// for text only we need to resize // for text only we need to resize
if( m_textOnly ) if (m_textOnly)
resize(); resize();
// already active - just update and reset timer // already active - just update and reset timer
update(); update();
} } else {
else
{
m_active = true; m_active = true;
resize(); resize();
show(); show();
raise(); raise();
} }
// Set a zero inputmask, effectively making clicks go "through" the popup // Set a zero inputmask, effectively making clicks go "through" the popup
// For those who impatiently wait to click on a dialog behind the it // For those who impatiently wait to click on a dialog behind the it
XShapeCombineRectangles( display(), winId(), ShapeInput, 0, 0, NULL, 0, ShapeSet, Unsorted ); XShapeCombineRectangles(display(), winId(), ShapeInput, 0, 0, NULL, 0, ShapeSet, Unsorted);
m_delayedHideTimer.start( m_delayTime ); m_delayedHideTimer.start(m_delayTime);
} }
void DesktopChangeOSD::hideEvent( QHideEvent* ) void DesktopChangeOSD::hideEvent(QHideEvent*)
{ {
m_delayedHideTimer.stop(); m_delayedHideTimer.stop();
m_active = false; m_active = false;
} }
void DesktopChangeOSD::drawBackground( QPainter* painter, const QRectF& rect ) void DesktopChangeOSD::drawBackground(QPainter* painter, const QRectF& rect)
{ {
painter->save(); painter->save();
painter->setCompositionMode( QPainter::CompositionMode_Source ); painter->setCompositionMode(QPainter::CompositionMode_Source);
qreal left, top, right, bottom; qreal left, top, right, bottom;
m_frame.getMargins( left, top, right, bottom ); m_frame.getMargins(left, top, right, bottom);
m_frame.paintFrame( painter, rect.adjusted( -left, -top, right, bottom ) ); m_frame.paintFrame(painter, rect.adjusted(-left, -top, right, bottom));
painter->restore(); painter->restore();
} }
void DesktopChangeOSD::numberDesktopsChanged() void DesktopChangeOSD::numberDesktopsChanged()
{ {
foreach( QGraphicsItem* it, m_scene->items() ) foreach (QGraphicsItem * it, m_scene->items()) {
{
DesktopChangeItem* item = qgraphicsitem_cast<DesktopChangeItem*>(it); DesktopChangeItem* item = qgraphicsitem_cast<DesktopChangeItem*>(it);
if( item ) if (item) {
{ m_scene->removeItem(item);
m_scene->removeItem( item );
}
}
if( !m_textOnly )
{
for( int i=1; i<=m_wspace->numberOfDesktops(); i++ )
{
DesktopChangeItem* item = new DesktopChangeItem( m_wspace, this, i );
m_scene->addItem( item );
}
} }
} }
if (!m_textOnly) {
for (int i = 1; i <= m_wspace->numberOfDesktops(); i++) {
DesktopChangeItem* item = new DesktopChangeItem(m_wspace, this, i);
m_scene->addItem(item);
}
}
}
void DesktopChangeOSD::resize() void DesktopChangeOSD::resize()
{ {
QRect screenRect = m_wspace->clientArea( ScreenArea, m_wspace->activeScreen(), m_wspace->currentDesktop() ); QRect screenRect = m_wspace->clientArea(ScreenArea, m_wspace->activeScreen(), m_wspace->currentDesktop());
QRect fullRect = m_wspace->clientArea( FullArea, m_wspace->activeScreen(), m_wspace->currentDesktop() ); QRect fullRect = m_wspace->clientArea(FullArea, m_wspace->activeScreen(), m_wspace->currentDesktop());
qreal left, top, right, bottom; qreal left, top, right, bottom;
m_frame.getMargins( left, top, right, bottom ); m_frame.getMargins(left, top, right, bottom);
QSize desktopGridSize = m_wspace->desktopGridSize(); QSize desktopGridSize = m_wspace->desktopGridSize();
float itemWidth = fullRect.width()*0.1f; float itemWidth = fullRect.width() * 0.1f;
float itemHeight = fullRect.height()*0.1f; float itemHeight = fullRect.height() * 0.1f;
// 2 px distance between each desktop + each desktop a width of 5 % of full screen + borders // 2 px distance between each desktop + each desktop a width of 5 % of full screen + borders
float width = (desktopGridSize.width()-1)*2 + desktopGridSize.width()*itemWidth + left + right; float width = (desktopGridSize.width() - 1) * 2 + desktopGridSize.width() * itemWidth + left + right;
float height = (desktopGridSize.height()-1)*2 + top + bottom; float height = (desktopGridSize.height() - 1) * 2 + top + bottom;
// bound width between ten and 33 percent of active screen // bound width between ten and 33 percent of active screen
float tempWidth = qBound( screenRect.width()*0.25f, width, screenRect.width()*0.5f ); float tempWidth = qBound(screenRect.width() * 0.25f, width, screenRect.width() * 0.5f);
if( tempWidth != width ) if (tempWidth != width) {
{
// have to adjust the height // have to adjust the height
width = tempWidth; width = tempWidth;
itemWidth = (width - (desktopGridSize.width()-1)*2 - left - right)/desktopGridSize.width(); itemWidth = (width - (desktopGridSize.width() - 1) * 2 - left - right) / desktopGridSize.width();
itemHeight = itemWidth*(float)((float)fullRect.height()/(float)fullRect.width()); itemHeight = itemWidth * (float)((float)fullRect.height() / (float)fullRect.width());
} }
height += itemHeight*desktopGridSize.height(); height += itemHeight * desktopGridSize.height();
height += fontMetrics().height() + 4; height += fontMetrics().height() + 4;
// we do not increase height, but it's bound to a third of screen height // we do not increase height, but it's bound to a third of screen height
float tempHeight = qMin( height, screenRect.height()*0.5f ); float tempHeight = qMin(height, screenRect.height() * 0.5f);
float itemOffset = 0.0f; float itemOffset = 0.0f;
if( tempHeight != height ) if (tempHeight != height) {
{
// have to adjust item width // have to adjust item width
height = tempHeight; height = tempHeight;
itemHeight = (height - (fontMetrics().height() + 4) - top - bottom - (desktopGridSize.height()-1)*2)/ itemHeight = (height - (fontMetrics().height() + 4) - top - bottom - (desktopGridSize.height() - 1) * 2) /
desktopGridSize.height(); desktopGridSize.height();
itemOffset = itemWidth; itemOffset = itemWidth;
itemWidth = itemHeight*(float)((float)fullRect.width()/(float)fullRect.height()); itemWidth = itemHeight * (float)((float)fullRect.width() / (float)fullRect.height());
itemOffset -= itemWidth; itemOffset -= itemWidth;
itemOffset *= (float)desktopGridSize.width()*0.5f; itemOffset *= (float)desktopGridSize.width() * 0.5f;
} }
// set size to the desktop name if the "pager" is not shown // set size to the desktop name if the "pager" is not shown
if( m_textOnly ) if (m_textOnly) {
{
height = fontMetrics().height() + 4 + top + bottom; height = fontMetrics().height() + 4 + top + bottom;
width = fontMetrics().boundingRect( m_wspace->desktopName( m_wspace->currentDesktop() ) ).width() + width = fontMetrics().boundingRect(m_wspace->desktopName(m_wspace->currentDesktop())).width() +
4 + left + right; 4 + left + right;
} }
QRect rect = QRect( screenRect.x() + (screenRect.width()-width)/2, QRect rect = QRect(screenRect.x() + (screenRect.width() - width) / 2,
screenRect.y() + (screenRect.height()-height)/2, screenRect.y() + (screenRect.height() - height) / 2,
width, width,
height ); height);
setGeometry( rect ); setGeometry(rect);
m_scene->setSceneRect( 0, 0, width, height ); m_scene->setSceneRect(0, 0, width, height);
m_frame.resizeFrame( QSize( width, height ) ); m_frame.resizeFrame(QSize(width, height));
if (Plasma::Theme::defaultTheme()->windowTranslucencyEnabled()) if (Plasma::Theme::defaultTheme()->windowTranslucencyEnabled()) {
{
// blur background // blur background
Plasma::WindowEffects::enableBlurBehind(winId(), true, m_frame.mask()); Plasma::WindowEffects::enableBlurBehind(winId(), true, m_frame.mask());
Plasma::WindowEffects::overrideShadow(winId(), true); Plasma::WindowEffects::overrideShadow(winId(), true);
} } else {
else
{
// do not trim to mask with compositing enabled, otherwise shadows are cropped // do not trim to mask with compositing enabled, otherwise shadows are cropped
setMask( m_frame.mask() ); setMask(m_frame.mask());
} }
// resize item frame // resize item frame
m_item_frame.setElementPrefix( "normal" ); m_item_frame.setElementPrefix("normal");
m_item_frame.resizeFrame( QSize( itemWidth, itemHeight ) ); m_item_frame.resizeFrame(QSize(itemWidth, itemHeight));
m_item_frame.setElementPrefix( "hover" ); m_item_frame.setElementPrefix("hover");
m_item_frame.resizeFrame( QSize( itemWidth, itemHeight ) ); m_item_frame.resizeFrame(QSize(itemWidth, itemHeight));
// reset the items // reset the items
foreach( QGraphicsItem* it, m_scene->items() ) foreach (QGraphicsItem * it, m_scene->items()) {
{
DesktopChangeItem* item = qgraphicsitem_cast<DesktopChangeItem*>(it); DesktopChangeItem* item = qgraphicsitem_cast<DesktopChangeItem*>(it);
if( item ) if (item) {
{ item->setWidth(itemWidth);
item->setWidth( itemWidth ); item->setHeight(itemHeight);
item->setHeight( itemHeight ); QPoint coords = m_wspace->desktopGridCoords(item->desktop());
QPoint coords = m_wspace->desktopGridCoords( item->desktop() ); item->setPos(left + itemOffset + coords.x()*(itemWidth + 2),
item->setPos( left + itemOffset + coords.x()*(itemWidth+2), top + fontMetrics().height() + 4 + coords.y()*(itemHeight + 4));
top + fontMetrics().height() + 4 + coords.y()*(itemHeight+4) ); }
}
DesktopChangeText* text = qgraphicsitem_cast<DesktopChangeText*>(it); DesktopChangeText* text = qgraphicsitem_cast<DesktopChangeText*>(it);
if( text ) if (text) {
{ text->setPos(left, top);
text->setPos( left, top ); text->setWidth(width - left - right);
text->setWidth( width - left - right ); if (m_textOnly)
if( m_textOnly ) text->setHeight(fontMetrics().height() + 4);
text->setHeight( fontMetrics().height() + 4 );
else else
text->setHeight( fontMetrics().height() ); text->setHeight(fontMetrics().height());
}
} }
} }
}
//******************************* //*******************************
// DesktopChangeText // DesktopChangeText
//******************************* //*******************************
DesktopChangeText::DesktopChangeText( Workspace* ws ) DesktopChangeText::DesktopChangeText(Workspace* ws)
: QGraphicsItem() : QGraphicsItem()
, m_wspace( ws ) , m_wspace(ws)
, m_width( 0.0f ) , m_width(0.0f)
, m_height( 0.0f ) , m_height(0.0f)
{ {
} }
DesktopChangeText::~DesktopChangeText() DesktopChangeText::~DesktopChangeText()
{ {
} }
QRectF DesktopChangeText::boundingRect() const QRectF DesktopChangeText::boundingRect() const
{ {
return QRectF( 0, 0, m_width, m_height ); return QRectF(0, 0, m_width, m_height);
} }
void DesktopChangeText::paint( QPainter* painter, const QStyleOptionGraphicsItem* , QWidget* ) void DesktopChangeText::paint(QPainter* painter, const QStyleOptionGraphicsItem* , QWidget*)
{ {
painter->setPen( Plasma::Theme::defaultTheme()->color( Plasma::Theme::TextColor ) ); painter->setPen(Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor));
painter->drawText( boundingRect(), Qt::AlignCenter | Qt:: AlignVCenter, painter->drawText(boundingRect(), Qt::AlignCenter | Qt:: AlignVCenter,
m_wspace->desktopName( m_wspace->currentDesktop() ) ); m_wspace->desktopName(m_wspace->currentDesktop()));
} }
//******************************* //*******************************
// DesktopChangeItem // DesktopChangeItem
//******************************* //*******************************
DesktopChangeItem::DesktopChangeItem( Workspace* ws, DesktopChangeOSD* parent, int desktop ) DesktopChangeItem::DesktopChangeItem(Workspace* ws, DesktopChangeOSD* parent, int desktop)
: QGraphicsItem() : QGraphicsItem()
, m_wspace( ws ) , m_wspace(ws)
, m_parent( parent ) , m_parent(parent)
, m_desktop( desktop ) , m_desktop(desktop)
, m_width( 0.0f ) , m_width(0.0f)
, m_height( 0.0f ) , m_height(0.0f)
, m_arrow( NONE ) , m_arrow(NONE)
, m_arrowShown( false ) , m_arrowShown(false)
, m_fadeInArrow( false ) , m_fadeInArrow(false)
, m_fadeInHighLight( false ) , m_fadeInHighLight(false)
, m_arrowValue( 0.0 ) , m_arrowValue(0.0)
, m_highLightValue( 0.0 ) , m_highLightValue(0.0)
{ {
m_delayed_show_arrow_timer.setSingleShot( true ); m_delayed_show_arrow_timer.setSingleShot(true);
m_delayed_hide_arrow_timer.setSingleShot( true ); m_delayed_hide_arrow_timer.setSingleShot(true);
connect( &m_delayed_show_arrow_timer, SIGNAL(timeout()), this, SLOT(showArrow())); connect(&m_delayed_show_arrow_timer, SIGNAL(timeout()), this, SLOT(showArrow()));
connect( &m_delayed_hide_arrow_timer, SIGNAL(timeout()), this, SLOT(hideArrow())); connect(&m_delayed_hide_arrow_timer, SIGNAL(timeout()), this, SLOT(hideArrow()));
} }
DesktopChangeItem::~DesktopChangeItem() DesktopChangeItem::~DesktopChangeItem()
{ {
} }
QRectF DesktopChangeItem::boundingRect() const QRectF DesktopChangeItem::boundingRect() const
{ {
return QRectF( 0, 0, m_width, m_height ); return QRectF(0, 0, m_width, m_height);
} }
void DesktopChangeItem::setArrow( Arrow arrow, int start_delay, int hide_delay ) void DesktopChangeItem::setArrow(Arrow arrow, int start_delay, int hide_delay)
{ {
// stop timers // stop timers
m_delayed_show_arrow_timer.stop(); m_delayed_show_arrow_timer.stop();
m_delayed_hide_arrow_timer.stop(); m_delayed_hide_arrow_timer.stop();
QPropertyAnimation *arrowAnimation = m_arrowAnimation.data(); QPropertyAnimation *arrowAnimation = m_arrowAnimation.data();
if( arrowAnimation ) if (arrowAnimation) {
{
arrowAnimation->stop(); arrowAnimation->stop();
m_arrowAnimation.clear(); m_arrowAnimation.clear();
} }
m_arrowShown = false; m_arrowShown = false;
m_arrow = arrow; m_arrow = arrow;
if( m_arrow != NONE ) if (m_arrow != NONE) {
{ m_delayed_show_arrow_timer.start(start_delay);
m_delayed_show_arrow_timer.start( start_delay ); m_delayed_hide_arrow_timer.start(hide_delay);
m_delayed_hide_arrow_timer.start( hide_delay );
}
} }
}
qreal DesktopChangeItem::arrowValue() const qreal DesktopChangeItem::arrowValue() const
{ {
qCritical() << __func__ << m_arrowValue; qCritical() << __func__ << m_arrowValue;
return m_arrowValue; return m_arrowValue;
} }
qreal DesktopChangeItem::highLightValue() const qreal DesktopChangeItem::highLightValue() const
{ {
return m_highLightValue; return m_highLightValue;
} }
void DesktopChangeItem::setArrowValue( qreal value ) void DesktopChangeItem::setArrowValue(qreal value)
{ {
m_arrowValue = value; m_arrowValue = value;
update(); update();
} }
void DesktopChangeItem::setHighLightValue( qreal value ) void DesktopChangeItem::setHighLightValue(qreal value)
{ {
m_highLightValue = value; m_highLightValue = value;
update(); update();
} }
void DesktopChangeItem::showArrow() void DesktopChangeItem::showArrow()
{ {
m_arrowShown = true; m_arrowShown = true;
QPropertyAnimation *arrowAnimation = m_arrowAnimation.data(); QPropertyAnimation *arrowAnimation = m_arrowAnimation.data();
if( !arrowAnimation ) if (!arrowAnimation) {
{ arrowAnimation = new QPropertyAnimation(this, "arrowValue");
arrowAnimation = new QPropertyAnimation( this, "arrowValue" ); arrowAnimation->setDuration(m_parent->getDelayTime() * 0.15f);
arrowAnimation->setDuration( m_parent->getDelayTime()*0.15f ); arrowAnimation->setStartValue(0.0);
arrowAnimation->setStartValue( 0.0 ); arrowAnimation->setEndValue(1.0);
arrowAnimation->setEndValue( 1.0 );
m_arrowAnimation = arrowAnimation; m_arrowAnimation = arrowAnimation;
} }
m_fadeInArrow = true; m_fadeInArrow = true;
arrowAnimation->setEasingCurve( QEasingCurve::InQuad ); arrowAnimation->setEasingCurve(QEasingCurve::InQuad);
arrowAnimation->setDirection( QAbstractAnimation::Forward ); arrowAnimation->setDirection(QAbstractAnimation::Forward);
arrowAnimation->start(); arrowAnimation->start();
} }
void DesktopChangeItem::hideArrow() void DesktopChangeItem::hideArrow()
{ {
m_fadeInArrow = false; m_fadeInArrow = false;
QPropertyAnimation *arrowAnimation = m_arrowAnimation.data(); QPropertyAnimation *arrowAnimation = m_arrowAnimation.data();
if( arrowAnimation ) if (arrowAnimation) {
{ arrowAnimation->setEasingCurve(QEasingCurve::OutQuad);
arrowAnimation->setEasingCurve( QEasingCurve::OutQuad ); arrowAnimation->setDirection(QAbstractAnimation::Backward);
arrowAnimation->setDirection( QAbstractAnimation::Backward ); arrowAnimation->start(QAbstractAnimation::DeleteWhenStopped);
arrowAnimation->start( QAbstractAnimation::DeleteWhenStopped );
connect( arrowAnimation, SIGNAL(finished()), this, SLOT(arrowAnimationFinished()) ); connect(arrowAnimation, SIGNAL(finished()), this, SLOT(arrowAnimationFinished()));
}
} }
}
void DesktopChangeItem::startDesktopHighLightAnimation( int time ) void DesktopChangeItem::startDesktopHighLightAnimation(int time)
{ {
QPropertyAnimation *highLightAnimation = m_highLightAnimation.data(); QPropertyAnimation *highLightAnimation = m_highLightAnimation.data();
if( !highLightAnimation ) if (!highLightAnimation) {
{ highLightAnimation = new QPropertyAnimation(this, "highLightValue");
highLightAnimation = new QPropertyAnimation( this, "highLightValue" ); highLightAnimation->setDuration(time);
highLightAnimation->setDuration( time ); highLightAnimation->setStartValue(0.0);
highLightAnimation->setStartValue( 0.0 ); highLightAnimation->setEndValue(1.0);
highLightAnimation->setEndValue( 1.0 );
m_highLightAnimation = highLightAnimation; m_highLightAnimation = highLightAnimation;
} }
m_fadeInHighLight = true; m_fadeInHighLight = true;
highLightAnimation->setEasingCurve( QEasingCurve::InQuad ); highLightAnimation->setEasingCurve(QEasingCurve::InQuad);
highLightAnimation->setDirection( QAbstractAnimation::Forward ); highLightAnimation->setDirection(QAbstractAnimation::Forward);
highLightAnimation->start(); highLightAnimation->start();
} }
void DesktopChangeItem::stopDesktopHighLightAnimation() void DesktopChangeItem::stopDesktopHighLightAnimation()
{ {
m_fadeInHighLight = false; m_fadeInHighLight = false;
QPropertyAnimation *highLightAnimation = m_highLightAnimation.data(); QPropertyAnimation *highLightAnimation = m_highLightAnimation.data();
if(highLightAnimation) if (highLightAnimation) {
{ highLightAnimation->setEasingCurve(QEasingCurve::OutQuad);
highLightAnimation->setEasingCurve( QEasingCurve::OutQuad ); highLightAnimation->setDirection(QAbstractAnimation::Backward);
highLightAnimation->setDirection( QAbstractAnimation::Backward ); highLightAnimation->start(QAbstractAnimation::DeleteWhenStopped);
highLightAnimation->start( QAbstractAnimation::DeleteWhenStopped );
}
} }
}
void DesktopChangeItem::arrowAnimationFinished() void DesktopChangeItem::arrowAnimationFinished()
{ {
if( !m_fadeInArrow ) if (!m_fadeInArrow)
m_arrowShown = false; m_arrowShown = false;
}
void DesktopChangeItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* , QWidget*)
{
if (m_wspace->currentDesktop() == m_desktop || (!m_highLightAnimation.isNull() &&
m_highLightAnimation.data()->state() == QAbstractAnimation::Running)) {
qreal left, top, right, bottom;
m_parent->itemFrame()->getMargins(left, top, right, bottom);
if (!m_highLightAnimation.isNull() &&
m_highLightAnimation.data()->state() == QAbstractAnimation::Running) {
// there is an animation - so we use transition from normal to active or vice versa
if (m_fadeInHighLight) {
m_parent->itemFrame()->setElementPrefix("normal");
QPixmap normal = m_parent->itemFrame()->framePixmap();
m_parent->itemFrame()->setElementPrefix("hover");
QPixmap result = Plasma::PaintUtils::transition(normal,
m_parent->itemFrame()->framePixmap(), m_highLightValue);
painter->drawPixmap(boundingRect().toRect(), result);
} else {
m_parent->itemFrame()->setElementPrefix("hover");
QPixmap normal = m_parent->itemFrame()->framePixmap();
m_parent->itemFrame()->setElementPrefix("normal");
QPixmap result = Plasma::PaintUtils::transition(normal,
m_parent->itemFrame()->framePixmap(), 1.0 - m_highLightValue);
painter->drawPixmap(boundingRect().toRect(), result);
}
} else {
// no animation - just render the active frame
m_parent->itemFrame()->setElementPrefix("hover");
m_parent->itemFrame()->paintFrame(painter, boundingRect());
}
QColor rectColor = Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor);
rectColor.setAlphaF(0.6 * m_highLightValue);
QBrush rectBrush = QBrush(rectColor);
painter->fillRect(boundingRect().adjusted(left, top, -right, -bottom), rectBrush);
} else {
m_parent->itemFrame()->setElementPrefix("normal");
m_parent->itemFrame()->paintFrame(painter, boundingRect());
} }
void DesktopChangeItem::paint( QPainter* painter, const QStyleOptionGraphicsItem* , QWidget* ) if (!m_arrowShown)
{
if( m_wspace->currentDesktop() == m_desktop || (!m_highLightAnimation.isNull() &&
m_highLightAnimation.data()->state() == QAbstractAnimation::Running) )
{
qreal left, top, right, bottom;
m_parent->itemFrame()->getMargins( left, top, right, bottom );
if( !m_highLightAnimation.isNull() &&
m_highLightAnimation.data()->state() == QAbstractAnimation::Running )
{
// there is an animation - so we use transition from normal to active or vice versa
if( m_fadeInHighLight )
{
m_parent->itemFrame()->setElementPrefix( "normal" );
QPixmap normal = m_parent->itemFrame()->framePixmap();
m_parent->itemFrame()->setElementPrefix( "hover" );
QPixmap result = Plasma::PaintUtils::transition( normal,
m_parent->itemFrame()->framePixmap(), m_highLightValue );
painter->drawPixmap( boundingRect().toRect(), result);
}
else
{
m_parent->itemFrame()->setElementPrefix( "hover" );
QPixmap normal = m_parent->itemFrame()->framePixmap();
m_parent->itemFrame()->setElementPrefix( "normal" );
QPixmap result = Plasma::PaintUtils::transition( normal,
m_parent->itemFrame()->framePixmap(), 1.0 - m_highLightValue );
painter->drawPixmap( boundingRect().toRect(), result);
}
}
else
{
// no animation - just render the active frame
m_parent->itemFrame()->setElementPrefix( "hover" );
m_parent->itemFrame()->paintFrame( painter, boundingRect() );
}
QColor rectColor = Plasma::Theme::defaultTheme()->color( Plasma::Theme::TextColor );
rectColor.setAlphaF( 0.6 * m_highLightValue );
QBrush rectBrush = QBrush( rectColor );
painter->fillRect( boundingRect().adjusted( left, top, -right, -bottom ), rectBrush );
}
else
{
m_parent->itemFrame()->setElementPrefix( "normal" );
m_parent->itemFrame()->paintFrame( painter, boundingRect() );
}
if( !m_arrowShown )
return; return;
// paint the arrow // paint the arrow
QPixmap icon; QPixmap icon;
int iconWidth = 32; int iconWidth = 32;
qreal maxsize = qMin( boundingRect().width(), boundingRect().height() ); qreal maxsize = qMin(boundingRect().width(), boundingRect().height());
if( maxsize > 128.0 ) if (maxsize > 128.0)
iconWidth = 128; iconWidth = 128;
else if( maxsize > 64.0 ) else if (maxsize > 64.0)
iconWidth = 64.0; iconWidth = 64.0;
else if( maxsize > 32.0 ) else if (maxsize > 32.0)
iconWidth = 32.0; iconWidth = 32.0;
else else
iconWidth = 16.0; iconWidth = 16.0;
QRect iconRect = QRect( boundingRect().x() + boundingRect().width()/2 - iconWidth/2, QRect iconRect = QRect(boundingRect().x() + boundingRect().width() / 2 - iconWidth / 2,
boundingRect().y() + boundingRect().height()/2 - iconWidth/2, boundingRect().y() + boundingRect().height() / 2 - iconWidth / 2,
iconWidth, iconWidth ); iconWidth, iconWidth);
switch( m_arrow ) switch(m_arrow) {
{ case UP:
case UP: icon = KIconLoader::global()->loadIcon("go-up", KIconLoader::Desktop, iconWidth);
icon = KIconLoader::global()->loadIcon( "go-up", KIconLoader::Desktop, iconWidth ); break;
break; case DOWN:
case DOWN: icon = KIconLoader::global()->loadIcon("go-down", KIconLoader::Desktop, iconWidth);
icon = KIconLoader::global()->loadIcon( "go-down", KIconLoader::Desktop, iconWidth ); break;
break; case LEFT:
case LEFT: icon = KIconLoader::global()->loadIcon("go-previous", KIconLoader::Desktop, iconWidth);
icon = KIconLoader::global()->loadIcon( "go-previous", KIconLoader::Desktop, iconWidth ); break;
break; case RIGHT:
case RIGHT: icon = KIconLoader::global()->loadIcon("go-next", KIconLoader::Desktop, iconWidth);
icon = KIconLoader::global()->loadIcon( "go-next", KIconLoader::Desktop, iconWidth ); break;
break; default:
default: break;
break; }
} if (m_arrow != NONE) {
if( m_arrow != NONE ) if (!m_arrowAnimation.isNull() &&
{
if( !m_arrowAnimation.isNull() &&
m_arrowAnimation.data()->state() == QAbstractAnimation::Running && m_arrowAnimation.data()->state() == QAbstractAnimation::Running &&
!qFuzzyCompare(m_arrowValue, qreal(1.0)) ) !qFuzzyCompare(m_arrowValue, qreal(1.0))) {
{ QPixmap temp(icon.size());
QPixmap temp( icon.size() ); temp.fill(Qt::transparent);
temp.fill( Qt::transparent );
QPainter p( &temp ); QPainter p(&temp);
p.setCompositionMode( QPainter::CompositionMode_Source ); p.setCompositionMode(QPainter::CompositionMode_Source);
p.drawPixmap( 0, 0, icon ); p.drawPixmap(0, 0, icon);
p.setCompositionMode( QPainter::CompositionMode_DestinationIn ); p.setCompositionMode(QPainter::CompositionMode_DestinationIn);
p.fillRect( temp.rect(), QColor( 0, 0, 0, 255*m_arrowValue ) ); p.fillRect(temp.rect(), QColor(0, 0, 0, 255 * m_arrowValue));
p.end(); p.end();
icon = temp; icon = temp;
}
painter->drawPixmap( iconRect, icon );
} }
painter->drawPixmap(iconRect, icon);
} }
} }
}
#include "desktopchangeosd.moc" #include "desktopchangeosd.moc"

View File

@ -37,120 +37,137 @@ namespace KWin
class Workspace; class Workspace;
class DesktopChangeText : public QGraphicsItem class DesktopChangeText : public QGraphicsItem
{ {
public: public:
DesktopChangeText( Workspace* ws ); DesktopChangeText(Workspace* ws);
~DesktopChangeText(); ~DesktopChangeText();
enum { Type = UserType + 2 }; enum { Type = UserType + 2 };
inline void setWidth( float width ) { m_width = width;}; inline void setWidth(float width) {
inline void setHeight( float height ) { m_height = height;}; m_width = width;
virtual QRectF boundingRect() const;
virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem*, QWidget* );
inline virtual int type() const { return Type; };
private:
Workspace* m_wspace;
float m_width;
float m_height;
}; };
inline void setHeight(float height) {
m_height = height;
};
virtual QRectF boundingRect() const;
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*);
inline virtual int type() const {
return Type;
};
private:
Workspace* m_wspace;
float m_width;
float m_height;
};
class DesktopChangeOSD : public QGraphicsView class DesktopChangeOSD : public QGraphicsView
{ {
public: public:
DesktopChangeOSD( Workspace* ws ); DesktopChangeOSD(Workspace* ws);
~DesktopChangeOSD(); ~DesktopChangeOSD();
void reconfigure(); void reconfigure();
void desktopChanged( int old ); void desktopChanged(int old);
void numberDesktopsChanged(); void numberDesktopsChanged();
inline Plasma::FrameSvg* itemFrame() { return &m_item_frame;}; inline Plasma::FrameSvg* itemFrame() {
inline int& getDelayTime() { return m_delayTime; }; return &m_item_frame;
protected:
virtual void hideEvent( QHideEvent* );
virtual void drawBackground( QPainter* painter, const QRectF& rect );
private:
void resize();
Workspace* m_wspace;
Plasma::FrameSvg m_frame;
Plasma::FrameSvg m_item_frame;
QGraphicsScene* m_scene;
bool m_active;
QTimer m_delayedHideTimer;
bool m_show;
int m_delayTime;
bool m_textOnly;
}; };
inline int& getDelayTime() {
return m_delayTime;
};
protected:
virtual void hideEvent(QHideEvent*);
virtual void drawBackground(QPainter* painter, const QRectF& rect);
private:
void resize();
Workspace* m_wspace;
Plasma::FrameSvg m_frame;
Plasma::FrameSvg m_item_frame;
QGraphicsScene* m_scene;
bool m_active;
QTimer m_delayedHideTimer;
bool m_show;
int m_delayTime;
bool m_textOnly;
};
class DesktopChangeItem : public QObject, public QGraphicsItem class DesktopChangeItem : public QObject, public QGraphicsItem
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY( qreal arrowValue READ arrowValue WRITE setArrowValue ) Q_PROPERTY(qreal arrowValue READ arrowValue WRITE setArrowValue)
Q_PROPERTY( qreal highLightValue READ highLightValue WRITE setHighLightValue ) Q_PROPERTY(qreal highLightValue READ highLightValue WRITE setHighLightValue)
Q_INTERFACES(QGraphicsItem) Q_INTERFACES(QGraphicsItem)
public: public:
DesktopChangeItem( Workspace* ws, DesktopChangeOSD* parent, int desktop ); DesktopChangeItem(Workspace* ws, DesktopChangeOSD* parent, int desktop);
~DesktopChangeItem(); ~DesktopChangeItem();
enum { Type = UserType + 1 }; enum { Type = UserType + 1 };
void startDesktopHighLightAnimation( int time ); void startDesktopHighLightAnimation(int time);
void stopDesktopHighLightAnimation(); void stopDesktopHighLightAnimation();
inline void setWidth( float width ) { m_width = width;}; inline void setWidth(float width) {
inline void setHeight( float height ) { m_height = height;}; m_width = width;
inline int desktop() const { return m_desktop; };
virtual QRectF boundingRect() const;
virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem*, QWidget* );
inline virtual int type() const { return Type; };
enum Arrow
{
NONE,
LEFT,
RIGHT,
UP,
DOWN
};
void setArrow( Arrow arrow, int start_delay, int hide_delay );
qreal arrowValue() const;
qreal highLightValue() const;
protected slots:
void setArrowValue( qreal value );
void setHighLightValue( qreal value );
private slots:
void showArrow();
void hideArrow();
void arrowAnimationFinished();
private:
Workspace* m_wspace;
DesktopChangeOSD* m_parent;
int m_desktop;
float m_width;
float m_height;
QTimer m_delayed_show_arrow_timer;
QTimer m_delayed_hide_arrow_timer;
Arrow m_arrow;
bool m_arrowShown;
bool m_fadeInArrow;
bool m_fadeInHighLight;
qreal m_arrowValue;
qreal m_highLightValue;
QWeakPointer<QPropertyAnimation> m_arrowAnimation;
QWeakPointer<QPropertyAnimation> m_highLightAnimation;
}; };
inline void setHeight(float height) {
m_height = height;
};
inline int desktop() const {
return m_desktop;
};
virtual QRectF boundingRect() const;
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*);
inline virtual int type() const {
return Type;
};
enum Arrow {
NONE,
LEFT,
RIGHT,
UP,
DOWN
};
void setArrow(Arrow arrow, int start_delay, int hide_delay);
qreal arrowValue() const;
qreal highLightValue() const;
protected slots:
void setArrowValue(qreal value);
void setHighLightValue(qreal value);
private slots:
void showArrow();
void hideArrow();
void arrowAnimationFinished();
private:
Workspace* m_wspace;
DesktopChangeOSD* m_parent;
int m_desktop;
float m_width;
float m_height;
QTimer m_delayed_show_arrow_timer;
QTimer m_delayed_hide_arrow_timer;
Arrow m_arrow;
bool m_arrowShown;
bool m_fadeInArrow;
bool m_fadeInHighLight;
qreal m_arrowValue;
qreal m_highLightValue;
QWeakPointer<QPropertyAnimation> m_arrowAnimation;
QWeakPointer<QPropertyAnimation> m_highLightAnimation;
};
} }

View File

@ -26,169 +26,162 @@ namespace KWin
{ {
void Workspace::updateDesktopLayout() void Workspace::updateDesktopLayout()
{ {
// TODO: Is there a sane way to avoid overriding the existing grid? // TODO: Is there a sane way to avoid overriding the existing grid?
int width = rootInfo->desktopLayoutColumnsRows().width(); int width = rootInfo->desktopLayoutColumnsRows().width();
int height = rootInfo->desktopLayoutColumnsRows().height(); int height = rootInfo->desktopLayoutColumnsRows().height();
if( width == 0 && height == 0 ) // Not given, set default layout if (width == 0 && height == 0) // Not given, set default layout
height = 2; height = 2;
setNETDesktopLayout( setNETDesktopLayout(
rootInfo->desktopLayoutOrientation() == NET::OrientationHorizontal ? Qt::Horizontal : Qt::Vertical, rootInfo->desktopLayoutOrientation() == NET::OrientationHorizontal ? Qt::Horizontal : Qt::Vertical,
width, height, 0 //rootInfo->desktopLayoutCorner() // Not really worth implementing right now. width, height, 0 //rootInfo->desktopLayoutCorner() // Not really worth implementing right now.
); );
} }
void Workspace::setNETDesktopLayout( Qt::Orientation orientation, int width, int height, void Workspace::setNETDesktopLayout(Qt::Orientation orientation, int width, int height,
int startingCorner ) int startingCorner)
{ {
Q_UNUSED( startingCorner ); // Not really worth implementing right now. Q_UNUSED(startingCorner); // Not really worth implementing right now.
// Calculate valid grid size // Calculate valid grid size
assert( width > 0 || height > 0 ); assert(width > 0 || height > 0);
if(( width <= 0 ) && ( height > 0 )) if ((width <= 0) && (height > 0))
width = ( desktopCount_ + height - 1 ) / height; width = (desktopCount_ + height - 1) / height;
else if(( height <= 0 ) && ( width > 0 )) else if ((height <= 0) && (width > 0))
height = ( desktopCount_ + width - 1 ) / width; height = (desktopCount_ + width - 1) / width;
while( width * height < desktopCount_ ) while (width * height < desktopCount_) {
{ if (orientation == Qt::Horizontal)
if( orientation == Qt::Horizontal )
++width; ++width;
else else
++height; ++height;
} }
// Set private variables // Set private variables
delete[] desktopGrid_; delete[] desktopGrid_;
desktopGridSize_ = QSize( width, height ); desktopGridSize_ = QSize(width, height);
int size = width * height; int size = width * height;
desktopGrid_ = new int[size]; desktopGrid_ = new int[size];
// Populate grid // Populate grid
int desktop = 1; int desktop = 1;
if( orientation == Qt::Horizontal ) if (orientation == Qt::Horizontal)
for( int y = 0; y < height; y++ ) for (int y = 0; y < height; y++)
for( int x = 0; x < width; x++ ) for (int x = 0; x < width; x++)
desktopGrid_[y * width + x] = (desktop <= desktopCount_ ? desktop++ : 0); desktopGrid_[y * width + x] = (desktop <= desktopCount_ ? desktop++ : 0);
else else
for( int x = 0; x < width; x++ ) for (int x = 0; x < width; x++)
for( int y = 0; y < height; y++ ) for (int y = 0; y < height; y++)
desktopGrid_[y * width + x] = (desktop <= desktopCount_ ? desktop++ : 0); desktopGrid_[y * width + x] = (desktop <= desktopCount_ ? desktop++ : 0);
} }
QPoint Workspace::desktopGridCoords( int id ) const QPoint Workspace::desktopGridCoords(int id) const
{ {
for( int y = 0; y < desktopGridSize_.height(); y++ ) for (int y = 0; y < desktopGridSize_.height(); y++)
for( int x = 0; x < desktopGridSize_.width(); x++ ) for (int x = 0; x < desktopGridSize_.width(); x++)
if( desktopGrid_[y * desktopGridSize_.width() + x] == id ) if (desktopGrid_[y * desktopGridSize_.width() + x] == id)
return QPoint( x, y ); return QPoint(x, y);
return QPoint( -1, -1 ); return QPoint(-1, -1);
} }
QPoint Workspace::desktopCoords( int id ) const QPoint Workspace::desktopCoords(int id) const
{ {
QPoint coords = desktopGridCoords( id ); QPoint coords = desktopGridCoords(id);
if( coords.x() == -1 ) if (coords.x() == -1)
return QPoint( -1, -1 ); return QPoint(-1, -1);
return QPoint( coords.x() * displayWidth(), coords.y() * displayHeight() ); return QPoint(coords.x() * displayWidth(), coords.y() * displayHeight());
} }
int Workspace::desktopAbove( int id, bool wrap ) const int Workspace::desktopAbove(int id, bool wrap) const
{ {
if( id == 0 ) if (id == 0)
id = currentDesktop(); id = currentDesktop();
QPoint coords = desktopGridCoords( id ); QPoint coords = desktopGridCoords(id);
assert( coords.x() >= 0 ); assert(coords.x() >= 0);
for(;;) for (;;) {
{
coords.ry()--; coords.ry()--;
if( coords.y() < 0 ) if (coords.y() < 0) {
{ if (wrap)
if( wrap ) coords.setY(desktopGridSize_.height() - 1);
coords.setY( desktopGridSize_.height() - 1 );
else else
return id; // Already at the top-most desktop return id; // Already at the top-most desktop
}
int desktop = desktopAtCoords( coords );
if( desktop > 0 )
return desktop;
} }
int desktop = desktopAtCoords(coords);
if (desktop > 0)
return desktop;
} }
}
int Workspace::desktopToRight( int id, bool wrap ) const int Workspace::desktopToRight(int id, bool wrap) const
{ {
if( id == 0 ) if (id == 0)
id = currentDesktop(); id = currentDesktop();
QPoint coords = desktopGridCoords( id ); QPoint coords = desktopGridCoords(id);
assert( coords.x() >= 0 ); assert(coords.x() >= 0);
for(;;) for (;;) {
{
coords.rx()++; coords.rx()++;
if( coords.x() >= desktopGridSize_.width() ) if (coords.x() >= desktopGridSize_.width()) {
{ if (wrap)
if( wrap ) coords.setX(0);
coords.setX( 0 );
else else
return id; // Already at the right-most desktop return id; // Already at the right-most desktop
}
int desktop = desktopAtCoords( coords );
if( desktop > 0 )
return desktop;
} }
int desktop = desktopAtCoords(coords);
if (desktop > 0)
return desktop;
} }
}
int Workspace::desktopBelow( int id, bool wrap ) const int Workspace::desktopBelow(int id, bool wrap) const
{ {
if( id == 0 ) if (id == 0)
id = currentDesktop(); id = currentDesktop();
QPoint coords = desktopGridCoords( id ); QPoint coords = desktopGridCoords(id);
assert( coords.x() >= 0 ); assert(coords.x() >= 0);
for(;;) for (;;) {
{
coords.ry()++; coords.ry()++;
if( coords.y() >= desktopGridSize_.height() ) if (coords.y() >= desktopGridSize_.height()) {
{ if (wrap)
if( wrap ) coords.setY(0);
coords.setY( 0 );
else else
return id; // Already at the bottom-most desktop return id; // Already at the bottom-most desktop
}
int desktop = desktopAtCoords( coords );
if( desktop > 0 )
return desktop;
} }
int desktop = desktopAtCoords(coords);
if (desktop > 0)
return desktop;
} }
}
int Workspace::desktopToLeft( int id, bool wrap ) const int Workspace::desktopToLeft(int id, bool wrap) const
{ {
if( id == 0 ) if (id == 0)
id = currentDesktop(); id = currentDesktop();
QPoint coords = desktopGridCoords( id ); QPoint coords = desktopGridCoords(id);
assert( coords.x() >= 0 ); assert(coords.x() >= 0);
for(;;) for (;;) {
{
coords.rx()--; coords.rx()--;
if( coords.x() < 0 ) if (coords.x() < 0) {
{ if (wrap)
if( wrap ) coords.setX(desktopGridSize_.width() - 1);
coords.setX( desktopGridSize_.width() - 1 );
else else
return id; // Already at the left-most desktop return id; // Already at the left-most desktop
}
int desktop = desktopAtCoords( coords );
if( desktop > 0 )
return desktop;
} }
int desktop = desktopAtCoords(coords);
if (desktop > 0)
return desktop;
} }
}
int Workspace::addDesktop( QPoint coords ) int Workspace::addDesktop(QPoint coords)
{ // TODO {
Q_UNUSED( coords ); // TODO
Q_UNUSED(coords);
return 0; return 0;
} }
void Workspace::deleteDesktop( int id ) void Workspace::deleteDesktop(int id)
{ // TODO {
Q_UNUSED( id ); // TODO
} Q_UNUSED(id);
}
} // namespace } // namespace

File diff suppressed because it is too large Load Diff

647
effects.h
View File

@ -37,406 +37,399 @@ namespace KWin
class EffectsHandlerImpl : public EffectsHandler class EffectsHandlerImpl : public EffectsHandler
{ {
public: public:
EffectsHandlerImpl(CompositingType type); EffectsHandlerImpl(CompositingType type);
virtual ~EffectsHandlerImpl(); virtual ~EffectsHandlerImpl();
virtual void prePaintScreen( ScreenPrePaintData& data, int time ); virtual void prePaintScreen(ScreenPrePaintData& data, int time);
virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data ); virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data);
virtual void postPaintScreen(); virtual void postPaintScreen();
virtual void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time ); virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time);
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
virtual void postPaintWindow( EffectWindow* w ); virtual void postPaintWindow(EffectWindow* w);
virtual void paintEffectFrame( EffectFrame* frame, QRegion region, double opacity, double frameOpacity ); virtual void paintEffectFrame(EffectFrame* frame, QRegion region, double opacity, double frameOpacity);
bool provides( Effect::Feature ef ); bool provides(Effect::Feature ef);
virtual void drawWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ); virtual void drawWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
virtual void buildQuads( EffectWindow* w, WindowQuadList& quadList ); virtual void buildQuads(EffectWindow* w, WindowQuadList& quadList);
virtual void activateWindow( EffectWindow* c ); virtual void activateWindow(EffectWindow* c);
virtual EffectWindow* activeWindow() const; virtual EffectWindow* activeWindow() const;
virtual void moveWindow( EffectWindow* w, const QPoint& pos, bool snap = false, double snapAdjust = 1.0 ); virtual void moveWindow(EffectWindow* w, const QPoint& pos, bool snap = false, double snapAdjust = 1.0);
virtual void windowToDesktop( EffectWindow* w, int desktop ); virtual void windowToDesktop(EffectWindow* w, int desktop);
virtual void windowToScreen( EffectWindow* w, int screen ); virtual void windowToScreen(EffectWindow* w, int screen);
virtual void setShowingDesktop( bool showing ); virtual void setShowingDesktop(bool showing);
virtual int currentDesktop() const; virtual int currentDesktop() const;
virtual int numberOfDesktops() const; virtual int numberOfDesktops() const;
virtual void setCurrentDesktop( int desktop ); virtual void setCurrentDesktop(int desktop);
virtual void setNumberOfDesktops( int desktops ); virtual void setNumberOfDesktops(int desktops);
virtual QSize desktopGridSize() const; virtual QSize desktopGridSize() const;
virtual int desktopGridWidth() const; virtual int desktopGridWidth() const;
virtual int desktopGridHeight() const; virtual int desktopGridHeight() const;
virtual int workspaceWidth() const; virtual int workspaceWidth() const;
virtual int workspaceHeight() const; virtual int workspaceHeight() const;
virtual int desktopAtCoords( QPoint coords ) const; virtual int desktopAtCoords(QPoint coords) const;
virtual QPoint desktopGridCoords( int id ) const; virtual QPoint desktopGridCoords(int id) const;
virtual QPoint desktopCoords( int id ) const; virtual QPoint desktopCoords(int id) const;
virtual int desktopAbove( int desktop = 0, bool wrap = true ) const; virtual int desktopAbove(int desktop = 0, bool wrap = true) const;
virtual int desktopToRight( int desktop = 0, bool wrap = true ) const; virtual int desktopToRight(int desktop = 0, bool wrap = true) const;
virtual int desktopBelow( int desktop = 0, bool wrap = true ) const; virtual int desktopBelow(int desktop = 0, bool wrap = true) const;
virtual int desktopToLeft( int desktop = 0, bool wrap = true ) const; virtual int desktopToLeft(int desktop = 0, bool wrap = true) const;
virtual bool isDesktopLayoutDynamic() const; virtual bool isDesktopLayoutDynamic() const;
virtual int addDesktop( QPoint coords ); virtual int addDesktop(QPoint coords);
virtual void deleteDesktop( int id ); virtual void deleteDesktop(int id);
virtual QString desktopName( int desktop ) const; virtual QString desktopName(int desktop) const;
virtual bool optionRollOverDesktops() const; virtual bool optionRollOverDesktops() const;
virtual int displayWidth() const; virtual int displayWidth() const;
virtual int displayHeight() const; virtual int displayHeight() const;
virtual QPoint cursorPos() const; virtual QPoint cursorPos() const;
virtual bool grabKeyboard( Effect* effect ); virtual bool grabKeyboard(Effect* effect);
virtual void ungrabKeyboard(); virtual void ungrabKeyboard();
virtual void* getProxy( QString name ); virtual void* getProxy(QString name);
virtual void startMousePolling(); virtual void startMousePolling();
virtual void stopMousePolling(); virtual void stopMousePolling();
virtual EffectWindow* findWindow( WId id ) const; virtual EffectWindow* findWindow(WId id) const;
virtual EffectWindowList stackingOrder() const; virtual EffectWindowList stackingOrder() const;
virtual void setElevatedWindow( EffectWindow* w, bool set ); virtual void setElevatedWindow(EffectWindow* w, bool set);
virtual void setTabBoxWindow(EffectWindow*); virtual void setTabBoxWindow(EffectWindow*);
virtual void setTabBoxDesktop(int); virtual void setTabBoxDesktop(int);
virtual EffectWindowList currentTabBoxWindowList() const; virtual EffectWindowList currentTabBoxWindowList() const;
virtual void refTabBox(); virtual void refTabBox();
virtual void unrefTabBox(); virtual void unrefTabBox();
virtual void closeTabBox(); virtual void closeTabBox();
virtual QList< int > currentTabBoxDesktopList() const; virtual QList< int > currentTabBoxDesktopList() const;
virtual int currentTabBoxDesktop() const; virtual int currentTabBoxDesktop() const;
virtual EffectWindow* currentTabBoxWindow() const; virtual EffectWindow* currentTabBoxWindow() const;
virtual void setActiveFullScreenEffect( Effect* e ); virtual void setActiveFullScreenEffect(Effect* e);
virtual Effect* activeFullScreenEffect() const; virtual Effect* activeFullScreenEffect() const;
virtual void pushRenderTarget(GLRenderTarget* target); virtual void pushRenderTarget(GLRenderTarget* target);
virtual GLRenderTarget* popRenderTarget(); virtual GLRenderTarget* popRenderTarget();
virtual bool isRenderTargetBound(); virtual bool isRenderTargetBound();
virtual void addRepaintFull(); virtual void addRepaintFull();
virtual void addRepaint( const QRect& r ); virtual void addRepaint(const QRect& r);
virtual void addRepaint( const QRegion& r ); virtual void addRepaint(const QRegion& r);
virtual void addRepaint( int x, int y, int w, int h ); virtual void addRepaint(int x, int y, int w, int h);
virtual int activeScreen() const; virtual int activeScreen() const;
virtual int numScreens() const; virtual int numScreens() const;
virtual int screenNumber( const QPoint& pos ) const; virtual int screenNumber(const QPoint& pos) const;
virtual QRect clientArea( clientAreaOption, int screen, int desktop ) const; virtual QRect clientArea(clientAreaOption, int screen, int desktop) const;
virtual QRect clientArea( clientAreaOption, const EffectWindow* c ) const; virtual QRect clientArea(clientAreaOption, const EffectWindow* c) const;
virtual QRect clientArea( clientAreaOption, const QPoint& p, int desktop ) const; virtual QRect clientArea(clientAreaOption, const QPoint& p, int desktop) const;
virtual double animationTimeFactor() const; virtual double animationTimeFactor() const;
virtual WindowQuadType newWindowQuadType(); virtual WindowQuadType newWindowQuadType();
virtual Window createInputWindow( Effect* e, int x, int y, int w, int h, const QCursor& cursor ); virtual Window createInputWindow(Effect* e, int x, int y, int w, int h, const QCursor& cursor);
using EffectsHandler::createInputWindow; using EffectsHandler::createInputWindow;
virtual void destroyInputWindow( Window w ); virtual void destroyInputWindow(Window w);
virtual bool checkInputWindowEvent( XEvent* e ); virtual bool checkInputWindowEvent(XEvent* e);
virtual void checkInputWindowStacking(); virtual void checkInputWindowStacking();
virtual void checkElectricBorder(const QPoint &pos, Time time); virtual void checkElectricBorder(const QPoint &pos, Time time);
virtual void reserveElectricBorder( ElectricBorder border ); virtual void reserveElectricBorder(ElectricBorder border);
virtual void unreserveElectricBorder( ElectricBorder border ); virtual void unreserveElectricBorder(ElectricBorder border);
virtual void reserveElectricBorderSwitching( bool reserve ); virtual void reserveElectricBorderSwitching(bool reserve);
virtual unsigned long xrenderBufferPicture(); virtual unsigned long xrenderBufferPicture();
virtual void reconfigure(); virtual void reconfigure();
virtual void registerPropertyType( long atom, bool reg ); virtual void registerPropertyType(long atom, bool reg);
virtual QByteArray readRootProperty( long atom, long type, int format ) const; virtual QByteArray readRootProperty(long atom, long type, int format) const;
virtual void deleteRootProperty( long atom ) const; virtual void deleteRootProperty(long atom) const;
virtual bool hasDecorationShadows() const; virtual bool hasDecorationShadows() const;
virtual bool decorationsHaveAlpha() const; virtual bool decorationsHaveAlpha() const;
virtual bool decorationSupportsBlurBehind() const; virtual bool decorationSupportsBlurBehind() const;
virtual EffectFrame* effectFrame( EffectFrameStyle style, bool staticSize, const QPoint& position, Qt::Alignment alignment ) const; virtual EffectFrame* effectFrame(EffectFrameStyle style, bool staticSize, const QPoint& position, Qt::Alignment alignment) const;
// internal (used by kwin core or compositing code) // internal (used by kwin core or compositing code)
void startPaint(); void startPaint();
void windowUserMovedResized( EffectWindow* c, bool first, bool last ); void windowUserMovedResized(EffectWindow* c, bool first, bool last);
void windowMoveResizeGeometryUpdate( EffectWindow* c, const QRect& geometry ); void windowMoveResizeGeometryUpdate(EffectWindow* c, const QRect& geometry);
void windowOpacityChanged( EffectWindow* c, double old_opacity ); void windowOpacityChanged(EffectWindow* c, double old_opacity);
void windowAdded( EffectWindow* c ); void windowAdded(EffectWindow* c);
void windowClosed( EffectWindow* c ); void windowClosed(EffectWindow* c);
void windowDeleted( EffectWindow* c ); void windowDeleted(EffectWindow* c);
void windowActivated( EffectWindow* c ); void windowActivated(EffectWindow* c);
void windowMinimized( EffectWindow* c ); void windowMinimized(EffectWindow* c);
void windowUnminimized( EffectWindow* c ); void windowUnminimized(EffectWindow* c);
void clientGroupItemSwitched( EffectWindow* from, EffectWindow* to ); void clientGroupItemSwitched(EffectWindow* from, EffectWindow* to);
void clientGroupItemAdded( EffectWindow* from, EffectWindow* to ); void clientGroupItemAdded(EffectWindow* from, EffectWindow* to);
void clientGroupItemRemoved( EffectWindow* c, EffectWindow* group ); void clientGroupItemRemoved(EffectWindow* c, EffectWindow* group);
void desktopChanged( int old ); void desktopChanged(int old);
void windowDamaged( EffectWindow* w, const QRect& r ); void windowDamaged(EffectWindow* w, const QRect& r);
void windowGeometryShapeChanged( EffectWindow* w, const QRect& old ); void windowGeometryShapeChanged(EffectWindow* w, const QRect& old);
void tabBoxAdded( int mode ); void tabBoxAdded(int mode);
void tabBoxClosed(); void tabBoxClosed();
void tabBoxUpdated(); void tabBoxUpdated();
void tabBoxKeyEvent( QKeyEvent* event ); void tabBoxKeyEvent(QKeyEvent* event);
bool borderActivated( ElectricBorder border ); bool borderActivated(ElectricBorder border);
void mouseChanged( const QPoint& pos, const QPoint& oldpos, void mouseChanged(const QPoint& pos, const QPoint& oldpos,
Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons, Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons,
Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers ); Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers);
void grabbedKeyboardEvent( QKeyEvent* e ); void grabbedKeyboardEvent(QKeyEvent* e);
bool hasKeyboardGrab() const; bool hasKeyboardGrab() const;
void propertyNotify( EffectWindow* c, long atom ); void propertyNotify(EffectWindow* c, long atom);
void numberDesktopsChanged( int old ); void numberDesktopsChanged(int old);
bool loadEffect( const QString& name ); bool loadEffect(const QString& name);
void toggleEffect( const QString& name ); void toggleEffect(const QString& name);
void unloadEffect( const QString& name ); void unloadEffect(const QString& name);
void reconfigureEffect( const QString& name ); void reconfigureEffect(const QString& name);
bool isEffectLoaded( const QString& name ); bool isEffectLoaded(const QString& name);
QStringList loadedEffects() const; QStringList loadedEffects() const;
QStringList listOfEffects() const; QStringList listOfEffects() const;
QList<EffectWindow*> elevatedWindows() const; QList<EffectWindow*> elevatedWindows() const;
protected: protected:
KLibrary* findEffectLibrary( KService* service ); KLibrary* findEffectLibrary(KService* service);
void effectsChanged(); void effectsChanged();
Effect* keyboard_grab_effect; Effect* keyboard_grab_effect;
QStack<GLRenderTarget*> render_targets; QStack<GLRenderTarget*> render_targets;
Effect* fullscreen_effect; Effect* fullscreen_effect;
QList<EffectWindow*> elevated_windows; QList<EffectWindow*> elevated_windows;
QMultiMap< int, EffectPair > effect_order; QMultiMap< int, EffectPair > effect_order;
QHash< long, int > registered_atoms; QHash< long, int > registered_atoms;
int next_window_quad_type; int next_window_quad_type;
int mouse_poll_ref_count; int mouse_poll_ref_count;
int current_paint_effectframe; int current_paint_effectframe;
}; };
class EffectWindowImpl : public EffectWindow class EffectWindowImpl : public EffectWindow
{ {
public: public:
EffectWindowImpl(); EffectWindowImpl();
virtual ~EffectWindowImpl(); virtual ~EffectWindowImpl();
virtual void enablePainting( int reason ); virtual void enablePainting(int reason);
virtual void disablePainting( int reason ); virtual void disablePainting(int reason);
virtual bool isPaintingEnabled(); virtual bool isPaintingEnabled();
virtual void addRepaint( const QRect& r ); virtual void addRepaint(const QRect& r);
virtual void addRepaint( int x, int y, int w, int h ); virtual void addRepaint(int x, int y, int w, int h);
virtual void addRepaintFull(); virtual void addRepaintFull();
virtual void refWindow(); virtual void refWindow();
virtual void unrefWindow(); virtual void unrefWindow();
virtual bool isDeleted() const; virtual bool isDeleted() const;
virtual bool isOnAllDesktops() const; virtual bool isOnAllDesktops() const;
virtual int desktop() const; // prefer isOnXXX() virtual int desktop() const; // prefer isOnXXX()
virtual bool isMinimized() const; virtual bool isMinimized() const;
virtual double opacity() const; virtual double opacity() const;
virtual bool hasAlpha() const; virtual bool hasAlpha() const;
virtual QString caption() const; virtual QString caption() const;
virtual QPixmap icon() const; virtual QPixmap icon() const;
virtual QString windowClass() const; virtual QString windowClass() const;
virtual QString windowRole() const; virtual QString windowRole() const;
virtual const EffectWindowGroup* group() const; virtual const EffectWindowGroup* group() const;
virtual int x() const; virtual int x() const;
virtual int y() const; virtual int y() const;
virtual int width() const; virtual int width() const;
virtual int height() const; virtual int height() const;
virtual QRect geometry() const; virtual QRect geometry() const;
virtual QRegion shape() const; virtual QRegion shape() const;
virtual int screen() const; virtual int screen() const;
virtual bool hasOwnShape() const; virtual bool hasOwnShape() const;
virtual QPoint pos() const; virtual QPoint pos() const;
virtual QSize size() const; virtual QSize size() const;
virtual QRect rect() const; virtual QRect rect() const;
virtual bool isMovable() const; virtual bool isMovable() const;
virtual bool isMovableAcrossScreens() const; virtual bool isMovableAcrossScreens() const;
virtual bool isUserMove() const; virtual bool isUserMove() const;
virtual bool isUserResize() const; virtual bool isUserResize() const;
virtual QRect iconGeometry() const; virtual QRect iconGeometry() const;
virtual QRect contentsRect() const; virtual QRect contentsRect() const;
virtual QRect decorationInnerRect() const; virtual QRect decorationInnerRect() const;
virtual QByteArray readProperty( long atom, long type, int format ) const; virtual QByteArray readProperty(long atom, long type, int format) const;
virtual void deleteProperty( long atom ) const; virtual void deleteProperty(long atom) const;
virtual bool isDesktop() const; virtual bool isDesktop() const;
virtual bool isDock() const; virtual bool isDock() const;
virtual bool isToolbar() const; virtual bool isToolbar() const;
virtual bool isTopMenu() const; virtual bool isTopMenu() const;
virtual bool isMenu() const; virtual bool isMenu() const;
virtual bool isNormalWindow() const; // normal as in 'NET::Normal or NET::Unknown non-transient' virtual bool isNormalWindow() const; // normal as in 'NET::Normal or NET::Unknown non-transient'
virtual bool isSpecialWindow() const; virtual bool isSpecialWindow() const;
virtual bool isDialog() const; virtual bool isDialog() const;
virtual bool isSplash() const; virtual bool isSplash() const;
virtual bool isUtility() const; virtual bool isUtility() const;
virtual bool isDropdownMenu() const; virtual bool isDropdownMenu() const;
virtual bool isPopupMenu() const; // a context popup, not dropdown, not torn-off virtual bool isPopupMenu() const; // a context popup, not dropdown, not torn-off
virtual bool isTooltip() const; virtual bool isTooltip() const;
virtual bool isNotification() const; virtual bool isNotification() const;
virtual bool isComboBox() const; virtual bool isComboBox() const;
virtual bool isDNDIcon() const; virtual bool isDNDIcon() const;
virtual bool isManaged() const; // managed or override-redirect virtual bool isManaged() const; // managed or override-redirect
virtual bool acceptsFocus() const; virtual bool acceptsFocus() const;
virtual bool keepAbove() const; virtual bool keepAbove() const;
virtual bool isModal() const; virtual bool isModal() const;
virtual EffectWindow* findModal(); virtual EffectWindow* findModal();
virtual EffectWindowList mainWindows() const; virtual EffectWindowList mainWindows() const;
virtual bool isSkipSwitcher() const; virtual bool isSkipSwitcher() const;
virtual WindowQuadList buildQuads( bool force = false ) const; virtual WindowQuadList buildQuads(bool force = false) const;
virtual void minimize() const; virtual void minimize() const;
virtual void unminimize() const; virtual void unminimize() const;
virtual void closeWindow() const; virtual void closeWindow() const;
virtual bool visibleInClientGroup() const; virtual bool visibleInClientGroup() const;
const Toplevel* window() const; const Toplevel* window() const;
Toplevel* window(); Toplevel* window();
void setWindow( Toplevel* w ); // internal void setWindow(Toplevel* w); // internal
void setSceneWindow( Scene::Window* w ); // internal void setSceneWindow(Scene::Window* w); // internal
const Scene::Window* sceneWindow() const; // internal const Scene::Window* sceneWindow() const; // internal
Scene::Window* sceneWindow(); // internal Scene::Window* sceneWindow(); // internal
void setData( int role, const QVariant &data ); void setData(int role, const QVariant &data);
QVariant data( int role ) const; QVariant data(int role) const;
private: private:
Toplevel* toplevel; Toplevel* toplevel;
Scene::Window* sw; // This one is used only during paint pass. Scene::Window* sw; // This one is used only during paint pass.
QHash<int, QVariant> dataMap; QHash<int, QVariant> dataMap;
}; };
class EffectWindowGroupImpl class EffectWindowGroupImpl
: public EffectWindowGroup : public EffectWindowGroup
{ {
public: public:
EffectWindowGroupImpl( Group* g ); EffectWindowGroupImpl(Group* g);
virtual EffectWindowList members() const; virtual EffectWindowList members() const;
private: private:
Group* group; Group* group;
}; };
class EffectFrameImpl class EffectFrameImpl
: public QObject, public EffectFrame : public QObject, public EffectFrame
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit EffectFrameImpl( EffectFrameStyle style, bool staticSize = true, QPoint position = QPoint( -1, -1 ), explicit EffectFrameImpl(EffectFrameStyle style, bool staticSize = true, QPoint position = QPoint(-1, -1),
Qt::Alignment alignment = Qt::AlignCenter ); Qt::Alignment alignment = Qt::AlignCenter);
virtual ~EffectFrameImpl(); virtual ~EffectFrameImpl();
virtual void free(); virtual void free();
virtual void render( QRegion region = infiniteRegion(), double opacity = 1.0, double frameOpacity = 1.0 ); virtual void render(QRegion region = infiniteRegion(), double opacity = 1.0, double frameOpacity = 1.0);
virtual Qt::Alignment alignment() const; virtual Qt::Alignment alignment() const;
virtual void setAlignment( Qt::Alignment alignment ); virtual void setAlignment(Qt::Alignment alignment);
virtual const QFont& font() const; virtual const QFont& font() const;
virtual void setFont( const QFont& font ); virtual void setFont(const QFont& font);
virtual const QRect& geometry() const; virtual const QRect& geometry() const;
virtual void setGeometry( const QRect& geometry, bool force = false ); virtual void setGeometry(const QRect& geometry, bool force = false);
virtual const QPixmap& icon() const; virtual const QPixmap& icon() const;
virtual void setIcon( const QPixmap& icon ); virtual void setIcon(const QPixmap& icon);
virtual const QSize& iconSize() const; virtual const QSize& iconSize() const;
virtual void setIconSize( const QSize& size ); virtual void setIconSize(const QSize& size);
virtual void setPosition( const QPoint& point ); virtual void setPosition(const QPoint& point);
virtual const QString& text() const; virtual const QString& text() const;
virtual void setText( const QString& text ); virtual void setText(const QString& text);
EffectFrameStyle style() const EffectFrameStyle style() const {
{ return m_style;
return m_style;
};
Plasma::FrameSvg& frame()
{
return m_frame;
}
bool isStatic() const
{
return m_static;
};
void finalRender( QRegion region, double opacity, double frameOpacity ) const;
virtual void setShader( GLShader* shader )
{
m_shader = shader;
}
virtual GLShader* shader() const
{
return m_shader;
}
virtual void setSelection( const QRect& selection );
const QRect& selection() const
{
return m_selectionGeometry;
}
Plasma::FrameSvg& selectionFrame()
{
return m_selection;
}
private Q_SLOTS:
void plasmaThemeChanged();
private:
Q_DISABLE_COPY( EffectFrameImpl ) // As we need to use Qt slots we cannot copy this class
void align( QRect &geometry ); // positions geometry around m_point respecting m_alignment
void autoResize(); // Auto-resize if not a static size
EffectFrameStyle m_style;
Plasma::FrameSvg m_frame; // TODO: share between all EffectFrames
Plasma::FrameSvg m_selection;
// Position
bool m_static;
QPoint m_point;
Qt::Alignment m_alignment;
QRect m_geometry;
// Contents
QString m_text;
QFont m_font;
QPixmap m_icon;
QSize m_iconSize;
QRect m_selectionGeometry;
Scene::EffectFrame* m_sceneFrame;
GLShader* m_shader;
}; };
Plasma::FrameSvg& frame() {
return m_frame;
}
bool isStatic() const {
return m_static;
};
void finalRender(QRegion region, double opacity, double frameOpacity) const;
virtual void setShader(GLShader* shader) {
m_shader = shader;
}
virtual GLShader* shader() const {
return m_shader;
}
virtual void setSelection(const QRect& selection);
const QRect& selection() const {
return m_selectionGeometry;
}
Plasma::FrameSvg& selectionFrame() {
return m_selection;
}
private Q_SLOTS:
void plasmaThemeChanged();
private:
Q_DISABLE_COPY(EffectFrameImpl) // As we need to use Qt slots we cannot copy this class
void align(QRect &geometry); // positions geometry around m_point respecting m_alignment
void autoResize(); // Auto-resize if not a static size
EffectFrameStyle m_style;
Plasma::FrameSvg m_frame; // TODO: share between all EffectFrames
Plasma::FrameSvg m_selection;
// Position
bool m_static;
QPoint m_point;
Qt::Alignment m_alignment;
QRect m_geometry;
// Contents
QString m_text;
QFont m_font;
QPixmap m_icon;
QSize m_iconSize;
QRect m_selectionGeometry;
Scene::EffectFrame* m_sceneFrame;
GLShader* m_shader;
};
inline inline
QList<EffectWindow*> EffectsHandlerImpl::elevatedWindows() const QList<EffectWindow*> EffectsHandlerImpl::elevatedWindows() const
{ {
return elevated_windows; return elevated_windows;
} }
inline inline
EffectWindowGroupImpl::EffectWindowGroupImpl( Group* g ) EffectWindowGroupImpl::EffectWindowGroupImpl(Group* g)
: group( g ) : group(g)
{ {
} }
EffectWindow* effectWindow( Toplevel* w ); EffectWindow* effectWindow(Toplevel* w);
EffectWindow* effectWindow( Scene::Window* w ); EffectWindow* effectWindow(Scene::Window* w);
inline inline
const Scene::Window* EffectWindowImpl::sceneWindow() const const Scene::Window* EffectWindowImpl::sceneWindow() const
{ {
return sw; return sw;
} }
inline inline
Scene::Window* EffectWindowImpl::sceneWindow() Scene::Window* EffectWindowImpl::sceneWindow()
{ {
return sw; return sw;
} }
inline inline
const Toplevel* EffectWindowImpl::window() const const Toplevel* EffectWindowImpl::window() const
{ {
return toplevel; return toplevel;
} }
inline inline
Toplevel* EffectWindowImpl::window() Toplevel* EffectWindowImpl::window()
{ {
return toplevel; return toplevel;
} }
} // namespace } // namespace

View File

@ -31,36 +31,35 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
namespace KWin namespace KWin
{ {
KWIN_EFFECT( demo_liquid, LiquidEffect ) KWIN_EFFECT(demo_liquid, LiquidEffect)
KWIN_EFFECT_SUPPORTED( demo_liquid, LiquidEffect::supported() ) KWIN_EFFECT_SUPPORTED(demo_liquid, LiquidEffect::supported())
LiquidEffect::LiquidEffect() : Effect() LiquidEffect::LiquidEffect() : Effect()
{ {
mTexture = 0; mTexture = 0;
mRenderTarget = 0; mRenderTarget = 0;
mShader = 0; mShader = 0;
mTime = 0.0f; mTime = 0.0f;
mValid = loadData(); mValid = loadData();
} }
LiquidEffect::~LiquidEffect() LiquidEffect::~LiquidEffect()
{ {
delete mTexture; delete mTexture;
delete mRenderTarget; delete mRenderTarget;
delete mShader; delete mShader;
} }
bool LiquidEffect::loadData() bool LiquidEffect::loadData()
{ {
// If NPOT textures are not supported, use nearest power-of-two sized // If NPOT textures are not supported, use nearest power-of-two sized
// texture. It wastes memory, but it's possible to support systems without // texture. It wastes memory, but it's possible to support systems without
// NPOT textures that way // NPOT textures that way
int texw = displayWidth(); int texw = displayWidth();
int texh = displayHeight(); int texh = displayHeight();
if( !GLTexture::NPOTTextureSupported() ) if (!GLTexture::NPOTTextureSupported()) {
{ kWarning(1212) << "NPOT textures not supported, wasting some memory" ;
kWarning( 1212 ) << "NPOT textures not supported, wasting some memory" ;
texw = nearestPowerOfTwo(texw); texw = nearestPowerOfTwo(texw);
texh = nearestPowerOfTwo(texh); texh = nearestPowerOfTwo(texh);
} }
@ -70,19 +69,17 @@ bool LiquidEffect::loadData()
mTexture->setWrapMode(GL_CLAMP); mTexture->setWrapMode(GL_CLAMP);
mRenderTarget = new GLRenderTarget(mTexture); mRenderTarget = new GLRenderTarget(mTexture);
if( !mRenderTarget->valid() ) if (!mRenderTarget->valid())
return false; return false;
QString fragmentshader = KGlobal::dirs()->findResource("data", "kwin/liquid.frag"); QString fragmentshader = KGlobal::dirs()->findResource("data", "kwin/liquid.frag");
QString vertexshader = KGlobal::dirs()->findResource("data", "kwin/liquid.vert"); QString vertexshader = KGlobal::dirs()->findResource("data", "kwin/liquid.vert");
if(fragmentshader.isEmpty() || vertexshader.isEmpty()) if (fragmentshader.isEmpty() || vertexshader.isEmpty()) {
{
kError(1212) << "Couldn't locate shader files" << endl; kError(1212) << "Couldn't locate shader files" << endl;
return false; return false;
} }
mShader = new GLShader(vertexshader, fragmentshader); mShader = new GLShader(vertexshader, fragmentshader);
if(!mShader->isValid()) if (!mShader->isValid()) {
{
kError(1212) << "The shader failed to load!" << endl; kError(1212) << "The shader failed to load!" << endl;
return false; return false;
} }
@ -93,38 +90,36 @@ bool LiquidEffect::loadData()
mShader->unbind(); mShader->unbind();
return true; return true;
} }
bool LiquidEffect::supported() bool LiquidEffect::supported()
{ {
return GLRenderTarget::supported() && return GLRenderTarget::supported() &&
GLShader::fragmentShaderSupported() && GLShader::fragmentShaderSupported() &&
(effects->compositingType() == OpenGLCompositing); (effects->compositingType() == OpenGLCompositing);
} }
void LiquidEffect::prePaintScreen( ScreenPrePaintData& data, int time ) void LiquidEffect::prePaintScreen(ScreenPrePaintData& data, int time)
{ {
mTime += time / 1000.0f; mTime += time / 1000.0f;
if(mValid) if (mValid) {
{
data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS; data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
// Start rendering to texture // Start rendering to texture
effects->pushRenderTarget(mRenderTarget); effects->pushRenderTarget(mRenderTarget);
}
effects->prePaintScreen(data, time);
} }
effects->prePaintScreen(data, time);
}
void LiquidEffect::postPaintScreen() void LiquidEffect::postPaintScreen()
{ {
// Call the next effect. // Call the next effect.
effects->postPaintScreen(); effects->postPaintScreen();
if(mValid) if (mValid) {
{
// Disable render texture // Disable render texture
assert( effects->popRenderTarget() == mRenderTarget ); assert(effects->popRenderTarget() == mRenderTarget);
mTexture->bind(); mTexture->bind();
// Use the shader // Use the shader
@ -133,10 +128,10 @@ void LiquidEffect::postPaintScreen()
// Render fullscreen quad with screen contents // Render fullscreen quad with screen contents
glBegin(GL_QUADS); glBegin(GL_QUADS);
glVertex2f(0.0, displayHeight()); glVertex2f(0.0, displayHeight());
glVertex2f(displayWidth(), displayHeight()); glVertex2f(displayWidth(), displayHeight());
glVertex2f(displayWidth(), 0.0); glVertex2f(displayWidth(), 0.0);
glVertex2f(0.0, 0.0); glVertex2f(0.0, 0.0);
glEnd(); glEnd();
mShader->unbind(); mShader->unbind();
@ -144,10 +139,10 @@ void LiquidEffect::postPaintScreen()
// Make sure the animation continues // Make sure the animation continues
effects->addRepaintFull(); effects->addRepaintFull();
}
} }
}
} // namespace } // namespace

View File

@ -35,27 +35,27 @@ class GLShader;
* Turns your desktop into a wavy (liquid) surface * Turns your desktop into a wavy (liquid) surface
**/ **/
class LiquidEffect : public Effect class LiquidEffect : public Effect
{ {
public: public:
LiquidEffect(); LiquidEffect();
~LiquidEffect(); ~LiquidEffect();
virtual void prePaintScreen( ScreenPrePaintData& data, int time ); virtual void prePaintScreen(ScreenPrePaintData& data, int time);
virtual void postPaintScreen(); virtual void postPaintScreen();
static bool supported(); static bool supported();
protected: protected:
bool loadData(); bool loadData();
private: private:
GLTexture* mTexture; GLTexture* mTexture;
GLRenderTarget* mRenderTarget; GLRenderTarget* mRenderTarget;
GLShader* mShader; GLShader* mShader;
bool mValid; bool mValid;
double mTime; double mTime;
}; };
} // namespace } // namespace

View File

@ -13,77 +13,73 @@ License. See the file "COPYING" for the exact licensing terms.
namespace KWin namespace KWin
{ {
KWIN_EFFECT( demo_shakymove, ShakyMoveEffect ) KWIN_EFFECT(demo_shakymove, ShakyMoveEffect)
ShakyMoveEffect::ShakyMoveEffect() ShakyMoveEffect::ShakyMoveEffect()
{ {
connect( &timer, SIGNAL( timeout()), SLOT( tick())); connect(&timer, SIGNAL(timeout()), SLOT(tick()));
} }
static const int shaky_diff[] = { 0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1 }; static const int shaky_diff[] = { 0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1 };
static const int SHAKY_MAX = sizeof( shaky_diff ) / sizeof( shaky_diff[ 0 ] ); static const int SHAKY_MAX = sizeof(shaky_diff) / sizeof(shaky_diff[ 0 ]);
void ShakyMoveEffect::prePaintScreen( ScreenPrePaintData& data, int time ) void ShakyMoveEffect::prePaintScreen(ScreenPrePaintData& data, int time)
{ {
if( !windows.isEmpty()) if (!windows.isEmpty())
data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS; data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
effects->prePaintScreen( data, time ); effects->prePaintScreen(data, time);
} }
void ShakyMoveEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time ) void ShakyMoveEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
{ {
if( windows.contains( w )) if (windows.contains(w))
data.setTransformed(); data.setTransformed();
effects->prePaintWindow( w, data, time ); effects->prePaintWindow(w, data, time);
} }
void ShakyMoveEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ) void ShakyMoveEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{ {
if( windows.contains( w )) if (windows.contains(w))
data.xTranslate += shaky_diff[ windows[ w ]]; data.xTranslate += shaky_diff[ windows[ w ]];
effects->paintWindow( w, mask, region, data ); effects->paintWindow(w, mask, region, data);
} }
void ShakyMoveEffect::windowUserMovedResized( EffectWindow* c, bool first, bool last ) void ShakyMoveEffect::windowUserMovedResized(EffectWindow* c, bool first, bool last)
{ {
if( first ) if (first) {
{ if (windows.isEmpty())
if( windows.isEmpty()) timer.start(50);
timer.start( 50 );
windows[ c ] = 0; windows[ c ] = 0;
} } else if (last) {
else if( last ) windows.remove(c);
{
windows.remove( c );
// just repaint whole screen, transformation is involved // just repaint whole screen, transformation is involved
effects->addRepaintFull(); effects->addRepaintFull();
if( windows.isEmpty()) if (windows.isEmpty())
timer.stop(); timer.stop();
}
} }
}
void ShakyMoveEffect::windowClosed( EffectWindow* c ) void ShakyMoveEffect::windowClosed(EffectWindow* c)
{ {
windows.remove( c ); windows.remove(c);
if( windows.isEmpty()) if (windows.isEmpty())
timer.stop(); timer.stop();
} }
// TODO use time provided with prePaintWindow() instead // TODO use time provided with prePaintWindow() instead
void ShakyMoveEffect::tick() void ShakyMoveEffect::tick()
{ {
for( QHash< const EffectWindow*, int >::Iterator it = windows.begin(); for (QHash< const EffectWindow*, int >::Iterator it = windows.begin();
it != windows.end(); it != windows.end();
++it ) ++it) {
{ if (*it == SHAKY_MAX - 1)
if( *it == SHAKY_MAX - 1 )
*it = 0; *it = 0;
else else
++(*it); ++(*it);
// just repaint whole screen, transformation is involved // just repaint whole screen, transformation is involved
effects->addRepaintFull(); effects->addRepaintFull();
}
} }
}
} // namespace } // namespace

View File

@ -20,21 +20,21 @@ namespace KWin
class ShakyMoveEffect class ShakyMoveEffect
: public QObject, public Effect : public QObject, public Effect
{ {
Q_OBJECT Q_OBJECT
public: public:
ShakyMoveEffect(); ShakyMoveEffect();
virtual void prePaintScreen( ScreenPrePaintData& data, int time ); virtual void prePaintScreen(ScreenPrePaintData& data, int time);
virtual void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time ); virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time);
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
virtual void windowUserMovedResized( EffectWindow* c, bool first, bool last ); virtual void windowUserMovedResized(EffectWindow* c, bool first, bool last);
virtual void windowClosed( EffectWindow* c ); virtual void windowClosed(EffectWindow* c);
private slots: private slots:
void tick(); void tick();
private: private:
QHash< const EffectWindow*, int > windows; QHash< const EffectWindow*, int > windows;
QTimer timer; QTimer timer;
}; };
} // namespace } // namespace

View File

@ -13,46 +13,46 @@ License. See the file "COPYING" for the exact licensing terms.
namespace KWin namespace KWin
{ {
KWIN_EFFECT( demo_shiftworkspaceup, ShiftWorkspaceUpEffect ) KWIN_EFFECT(demo_shiftworkspaceup, ShiftWorkspaceUpEffect)
ShiftWorkspaceUpEffect::ShiftWorkspaceUpEffect() ShiftWorkspaceUpEffect::ShiftWorkspaceUpEffect()
: up( false ) : up(false)
, diff( 0 ) , diff(0)
{ {
connect( &timer, SIGNAL( timeout()), SLOT( tick())); connect(&timer, SIGNAL(timeout()), SLOT(tick()));
timer.start( 2000 ); timer.start(2000);
} }
void ShiftWorkspaceUpEffect::prePaintScreen( ScreenPrePaintData& data, int time ) void ShiftWorkspaceUpEffect::prePaintScreen(ScreenPrePaintData& data, int time)
{ {
if( up && diff < 1000 ) if (up && diff < 1000)
diff = qBound( 0, diff + time, 1000 ); // KDE3: note this differs from KCLAMP diff = qBound(0, diff + time, 1000); // KDE3: note this differs from KCLAMP
if( !up && diff > 0 ) if (!up && diff > 0)
diff = qBound( 0, diff - time, 1000 ); diff = qBound(0, diff - time, 1000);
if( diff != 0 ) if (diff != 0)
data.mask |= PAINT_SCREEN_TRANSFORMED; data.mask |= PAINT_SCREEN_TRANSFORMED;
effects->prePaintScreen( data, time ); effects->prePaintScreen(data, time);
} }
void ShiftWorkspaceUpEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data ) void ShiftWorkspaceUpEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
{ {
if( diff != 0 ) if (diff != 0)
data.yTranslate -= diff / 100; data.yTranslate -= diff / 100;
effects->paintScreen( mask, region, data ); effects->paintScreen(mask, region, data);
} }
void ShiftWorkspaceUpEffect::postPaintScreen() void ShiftWorkspaceUpEffect::postPaintScreen()
{ {
if( up ? diff < 1000 : diff > 0 ) if (up ? diff < 1000 : diff > 0)
effects->addRepaintFull(); // trigger next animation repaint effects->addRepaintFull(); // trigger next animation repaint
effects->postPaintScreen(); effects->postPaintScreen();
} }
void ShiftWorkspaceUpEffect::tick() void ShiftWorkspaceUpEffect::tick()
{ {
up = !up; up = !up;
effects->addRepaintFull(); effects->addRepaintFull();
} }
} // namespace } // namespace

View File

@ -20,20 +20,20 @@ namespace KWin
class ShiftWorkspaceUpEffect class ShiftWorkspaceUpEffect
: public QObject, public Effect : public QObject, public Effect
{ {
Q_OBJECT Q_OBJECT
public: public:
ShiftWorkspaceUpEffect(); ShiftWorkspaceUpEffect();
virtual void prePaintScreen( ScreenPrePaintData& data, int time ); virtual void prePaintScreen(ScreenPrePaintData& data, int time);
virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data ); virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data);
virtual void postPaintScreen(); virtual void postPaintScreen();
private slots: private slots:
void tick(); void tick();
private: private:
QTimer timer; QTimer timer;
bool up; bool up;
int diff; int diff;
}; };
} // namespace } // namespace

View File

@ -16,49 +16,47 @@ License. See the file "COPYING" for the exact licensing terms.
namespace KWin namespace KWin
{ {
KWIN_EFFECT( demo_showpicture, ShowPictureEffect ) KWIN_EFFECT(demo_showpicture, ShowPictureEffect)
ShowPictureEffect::ShowPictureEffect() ShowPictureEffect::ShowPictureEffect()
: init( true ) : init(true)
, picture( NULL ) , picture(NULL)
{ {
} }
ShowPictureEffect::~ShowPictureEffect() ShowPictureEffect::~ShowPictureEffect()
{ {
delete picture; delete picture;
} }
void ShowPictureEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data ) void ShowPictureEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
{ {
effects->paintScreen( mask, region, data ); effects->paintScreen(mask, region, data);
if( init ) if (init) {
{
loadPicture(); loadPicture();
init = false; init = false;
} }
if( picture && region.intersects( pictureRect )) if (picture && region.intersects(pictureRect)) {
{ glPushAttrib(GL_CURRENT_BIT | GL_ENABLE_BIT);
glPushAttrib( GL_CURRENT_BIT | GL_ENABLE_BIT );
picture->bind(); picture->bind();
glEnable( GL_BLEND ); glEnable(GL_BLEND);
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
picture->render( region, pictureRect ); picture->render(region, pictureRect);
picture->unbind(); picture->unbind();
glPopAttrib(); glPopAttrib();
}
} }
}
void ShowPictureEffect::loadPicture() void ShowPictureEffect::loadPicture()
{ {
QString file = KGlobal::dirs()->findResource( "appdata", "showpicture.png" ); QString file = KGlobal::dirs()->findResource("appdata", "showpicture.png");
if( file.isEmpty()) if (file.isEmpty())
return; return;
QImage im( file ); QImage im(file);
QRect area = effects->clientArea( PlacementArea, effects->activeScreen(), effects->currentDesktop()); QRect area = effects->clientArea(PlacementArea, effects->activeScreen(), effects->currentDesktop());
picture = new GLTexture( im ); picture = new GLTexture(im);
pictureRect = QRect( area.x() + ( area.width() - im.width()) / 2, pictureRect = QRect(area.x() + (area.width() - im.width()) / 2,
area.y() + ( area.height() - im.height()) / 2, im.width(), im.height()); area.y() + (area.height() - im.height()) / 2, im.width(), im.height());
} }
} // namespace } // namespace

View File

@ -19,17 +19,17 @@ namespace KWin
class ShowPictureEffect class ShowPictureEffect
: public Effect : public Effect
{ {
public: public:
ShowPictureEffect(); ShowPictureEffect();
virtual ~ShowPictureEffect(); virtual ~ShowPictureEffect();
virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data ); virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data);
private: private:
void loadPicture(); void loadPicture();
bool init; bool init;
GLTexture* picture; GLTexture* picture;
QRect pictureRect; QRect pictureRect;
}; };
} // namespace } // namespace

View File

@ -26,16 +26,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
namespace KWin namespace KWin
{ {
KWIN_EFFECT( demo_wavywindows, WavyWindowsEffect ) KWIN_EFFECT(demo_wavywindows, WavyWindowsEffect)
WavyWindowsEffect::WavyWindowsEffect() WavyWindowsEffect::WavyWindowsEffect()
{ {
mTimeElapsed = 0.0f; mTimeElapsed = 0.0f;
} }
void WavyWindowsEffect::prePaintScreen( ScreenPrePaintData& data, int time ) void WavyWindowsEffect::prePaintScreen(ScreenPrePaintData& data, int time)
{ {
// Adjust elapsed time // Adjust elapsed time
mTimeElapsed += (time / 1000.0f); mTimeElapsed += (time / 1000.0f);
// We need to mark the screen windows as transformed. Otherwise the whole // We need to mark the screen windows as transformed. Otherwise the whole
@ -43,55 +43,53 @@ void WavyWindowsEffect::prePaintScreen( ScreenPrePaintData& data, int time )
data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS; data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
effects->prePaintScreen(data, time); effects->prePaintScreen(data, time);
} }
void WavyWindowsEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time ) void WavyWindowsEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
{ {
// This window will be transformed by the effect // This window will be transformed by the effect
data.setTransformed(); data.setTransformed();
// Check if OpenGL compositing is used // Check if OpenGL compositing is used
// Request the window to be divided into cells which are at most 30x30 // Request the window to be divided into cells which are at most 30x30
// pixels big // pixels big
data.quads = data.quads.makeGrid( 30 ); data.quads = data.quads.makeGrid(30);
effects->prePaintWindow( w, data, time ); effects->prePaintWindow(w, data, time);
} }
void WavyWindowsEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ) void WavyWindowsEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{ {
// Make sure we have OpenGL compositing and the window is vidible and not a // Make sure we have OpenGL compositing and the window is vidible and not a
// special window // special window
// TODO if( w->isVisible() && !w->isSpecialWindow() ) // TODO if ( w->isVisible() && !w->isSpecialWindow() )
if( !w->isSpecialWindow() ) if (!w->isSpecialWindow()) {
{
// We have OpenGL compositing and the window has been subdivided // We have OpenGL compositing and the window has been subdivided
// because of our request (in pre-paint pass) // because of our request (in pre-paint pass)
// Transform all the vertices to create wavy effect // Transform all the vertices to create wavy effect
for( int i = 0; for (int i = 0;
i < data.quads.count(); i < data.quads.count();
++i ) ++i)
for( int j = 0; for (int j = 0;
j < 4; j < 4;
++j ) ++j) {
{
WindowVertex& v = data.quads[ i ][ j ]; WindowVertex& v = data.quads[ i ][ j ];
v.move( v.x() + sin(mTimeElapsed + v.originalY() / 60 + 0.5f) * 10, v.move(v.x() + sin(mTimeElapsed + v.originalY() / 60 + 0.5f) * 10,
v.y() + sin(mTimeElapsed + v.originalX() / 80) * 10 ); v.y() + sin(mTimeElapsed + v.originalX() / 80) * 10);
} }
}
// Call the next effect.
effects->paintWindow( w, mask, region, data );
} }
// Call the next effect.
effects->paintWindow(w, mask, region, data);
}
void WavyWindowsEffect::postPaintScreen() void WavyWindowsEffect::postPaintScreen()
{ {
// Repaint the workspace so that everything would be repainted next time // Repaint the workspace so that everything would be repainted next time
effects->addRepaintFull(); effects->addRepaintFull();
// Call the next effect. // Call the next effect.
effects->postPaintScreen(); effects->postPaintScreen();
} }
} // namespace } // namespace

View File

@ -32,18 +32,18 @@ namespace KWin
**/ **/
class WavyWindowsEffect class WavyWindowsEffect
: public Effect : public Effect
{ {
public: public:
WavyWindowsEffect(); WavyWindowsEffect();
virtual void prePaintScreen( ScreenPrePaintData& data, int time ); virtual void prePaintScreen(ScreenPrePaintData& data, int time);
virtual void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time ); virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time);
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
virtual void postPaintScreen(); virtual void postPaintScreen();
private: private:
double mTimeElapsed; double mTimeElapsed;
}; };
} // namespace } // namespace

View File

@ -15,63 +15,61 @@ License. See the file "COPYING" for the exact licensing terms.
namespace KWin namespace KWin
{ {
KWIN_EFFECT( drunken, DrunkenEffect ) KWIN_EFFECT(drunken, DrunkenEffect)
void DrunkenEffect::prePaintScreen( ScreenPrePaintData& data, int time ) void DrunkenEffect::prePaintScreen(ScreenPrePaintData& data, int time)
{ {
if( !windows.isEmpty()) if (!windows.isEmpty())
data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS; data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
effects->prePaintScreen( data, time ); effects->prePaintScreen(data, time);
} }
void DrunkenEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time ) void DrunkenEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
{ {
if( windows.contains( w )) if (windows.contains(w)) {
{
windows[ w ] += time / 1000.; windows[ w ] += time / 1000.;
if( windows[ w ] < 1 ) if (windows[ w ] < 1)
data.setTransformed(); data.setTransformed();
else else
windows.remove( w ); windows.remove(w);
}
effects->prePaintWindow( w, data, time );
} }
effects->prePaintWindow(w, data, time);
}
void DrunkenEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ) void DrunkenEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{ {
if( !windows.contains( w )) if (!windows.contains(w)) {
{ effects->paintWindow(w, mask, region, data);
effects->paintWindow( w, mask, region, data );
return; return;
} }
WindowPaintData d1 = data; WindowPaintData d1 = data;
// 4 cycles, decreasing amplitude // 4 cycles, decreasing amplitude
int diff = int( sin( windows[ w ] * 8 * M_PI ) * ( 1 - windows[ w ] ) * 10 ); int diff = int(sin(windows[ w ] * 8 * M_PI) * (1 - windows[ w ]) * 10);
d1.xTranslate -= diff; d1.xTranslate -= diff;
d1.opacity *= 0.5; d1.opacity *= 0.5;
effects->paintWindow( w, mask, region, d1 ); effects->paintWindow(w, mask, region, d1);
WindowPaintData d2 = data; WindowPaintData d2 = data;
d2.xTranslate += diff; d2.xTranslate += diff;
d2.opacity *= 0.5; d2.opacity *= 0.5;
effects->paintWindow( w, mask, region, d2 ); effects->paintWindow(w, mask, region, d2);
} }
void DrunkenEffect::postPaintWindow( EffectWindow* w ) void DrunkenEffect::postPaintWindow(EffectWindow* w)
{ {
if( windows.contains( w )) if (windows.contains(w))
w->addRepaintFull(); w->addRepaintFull();
effects->postPaintWindow( w ); effects->postPaintWindow(w);
} }
void DrunkenEffect::windowAdded( EffectWindow* w ) void DrunkenEffect::windowAdded(EffectWindow* w)
{ {
windows[ w ] = 0; windows[ w ] = 0;
w->addRepaintFull(); w->addRepaintFull();
} }
void DrunkenEffect::windowClosed( EffectWindow* w ) void DrunkenEffect::windowClosed(EffectWindow* w)
{ {
windows.remove( w ); windows.remove(w);
} }
} // namespace } // namespace

View File

@ -18,17 +18,17 @@ namespace KWin
class DrunkenEffect class DrunkenEffect
: public Effect : public Effect
{ {
public: public:
virtual void prePaintScreen( ScreenPrePaintData& data, int time ); virtual void prePaintScreen(ScreenPrePaintData& data, int time);
virtual void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time ); virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time);
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
virtual void postPaintWindow( EffectWindow* w ); virtual void postPaintWindow(EffectWindow* w);
virtual void windowAdded( EffectWindow* w ); virtual void windowAdded(EffectWindow* w);
virtual void windowClosed( EffectWindow* w ); virtual void windowClosed(EffectWindow* w);
private: private:
QHash< EffectWindow*, double > windows; // progress QHash< EffectWindow*, double > windows; // progress
}; };
} // namespace } // namespace

View File

@ -16,70 +16,64 @@ License. See the file "COPYING" for the exact licensing terms.
namespace KWin namespace KWin
{ {
KWIN_EFFECT( flame, FlameEffect ) KWIN_EFFECT(flame, FlameEffect)
void FlameEffect::prePaintScreen( ScreenPrePaintData& data, int time ) void FlameEffect::prePaintScreen(ScreenPrePaintData& data, int time)
{ {
if( !windows.isEmpty()) if (!windows.isEmpty())
data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS; data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
effects->prePaintScreen(data, time); effects->prePaintScreen(data, time);
} }
void FlameEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time ) void FlameEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
{ {
if( windows.contains( w )) if (windows.contains(w)) {
{ if (windows[ w ] < 1) {
if( windows[ w ] < 1 )
{
windows[ w ] += time / 500.; windows[ w ] += time / 500.;
data.setTransformed(); data.setTransformed();
w->enablePainting( EffectWindow::PAINT_DISABLED_BY_DELETE ); w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DELETE);
data.quads = data.quads.splitAtY( windows[ w ] * w->height()); data.quads = data.quads.splitAtY(windows[ w ] * w->height());
} } else {
else windows.remove(w);
{
windows.remove( w );
w->unrefWindow(); w->unrefWindow();
}
} }
effects->prePaintWindow( w, data, time );
} }
effects->prePaintWindow(w, data, time);
}
void FlameEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ) void FlameEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{ {
if( windows.contains( w )) if (windows.contains(w)) {
{
WindowQuadList new_quads; WindowQuadList new_quads;
double ylimit = windows[ w ] * w->height(); // parts above this are already away double ylimit = windows[ w ] * w->height(); // parts above this are already away
foreach( const WindowQuad &quad, data.quads ) foreach (const WindowQuad & quad, data.quads) {
{ if (quad.bottom() <= ylimit)
if( quad.bottom() <= ylimit )
continue; continue;
new_quads.append( quad ); new_quads.append(quad);
} }
if( new_quads.isEmpty()) if (new_quads.isEmpty())
return; // nothing to paint return; // nothing to paint
data.quads = new_quads; data.quads = new_quads;
}
effects->paintWindow( w, mask, region, data );
} }
effects->paintWindow(w, mask, region, data);
}
void FlameEffect::postPaintWindow( EffectWindow* w ) void FlameEffect::postPaintWindow(EffectWindow* w)
{ {
if( windows.contains( w )) if (windows.contains(w))
effects->addRepaint( w->geometry()); // workspace, since the window under it will need painting too effects->addRepaint(w->geometry()); // workspace, since the window under it will need painting too
effects->postPaintScreen(); effects->postPaintScreen();
} }
void FlameEffect::windowClosed( EffectWindow* c ) void FlameEffect::windowClosed(EffectWindow* c)
{ {
windows[ c ] = 0; windows[ c ] = 0;
c->refWindow(); c->refWindow();
} }
void FlameEffect::windowDeleted( EffectWindow* c ) void FlameEffect::windowDeleted(EffectWindow* c)
{ {
windows.remove( c ); windows.remove(c);
} }
} // namespace } // namespace

View File

@ -18,17 +18,17 @@ namespace KWin
class FlameEffect class FlameEffect
: public Effect : public Effect
{ {
public: public:
virtual void prePaintScreen( ScreenPrePaintData& data, int time ); virtual void prePaintScreen(ScreenPrePaintData& data, int time);
virtual void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time ); virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time);
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
virtual void postPaintWindow( EffectWindow* w ); virtual void postPaintWindow(EffectWindow* w);
virtual void windowClosed( EffectWindow* c ); virtual void windowClosed(EffectWindow* c);
virtual void windowDeleted( EffectWindow* c ); virtual void windowDeleted(EffectWindow* c);
private: private:
QHash< const EffectWindow*, double > windows; QHash< const EffectWindow*, double > windows;
}; };
} // namespace } // namespace

View File

@ -33,77 +33,74 @@ Which is based on glxgears.c by Brian Paul:
namespace KWin namespace KWin
{ {
KWIN_EFFECT( gears, GearsEffect ) KWIN_EFFECT(gears, GearsEffect)
KWIN_EFFECT_SUPPORTED( gears, GearsEffect::supported() ) KWIN_EFFECT_SUPPORTED(gears, GearsEffect::supported())
GearsEffect::GearsEffect() GearsEffect::GearsEffect()
: CubeInsideEffect() : CubeInsideEffect()
, m_active( false ) , m_active(false)
, m_contentRotation( 0.0f ) , m_contentRotation(0.0f)
, m_angle( 0.0f ) , m_angle(0.0f)
{ {
CubeEffectProxy* proxy = CubeEffectProxy* proxy =
static_cast<CubeEffectProxy*>( effects->getProxy( "cube" ) ); static_cast<CubeEffectProxy*>(effects->getProxy("cube"));
if( proxy ) if (proxy)
proxy->registerCubeInsideEffect( this ); proxy->registerCubeInsideEffect(this);
} }
GearsEffect::~GearsEffect() GearsEffect::~GearsEffect()
{ {
CubeEffectProxy* proxy = CubeEffectProxy* proxy =
static_cast<CubeEffectProxy*>( effects->getProxy( "cube" ) ); static_cast<CubeEffectProxy*>(effects->getProxy("cube"));
if( proxy ) if (proxy)
proxy->unregisterCubeInsideEffect( this ); proxy->unregisterCubeInsideEffect(this);
} }
bool GearsEffect::supported() bool GearsEffect::supported()
{ {
return effects->compositingType() == OpenGLCompositing; return effects->compositingType() == OpenGLCompositing;
} }
void GearsEffect::prePaintScreen( ScreenPrePaintData& data, int time ) void GearsEffect::prePaintScreen(ScreenPrePaintData& data, int time)
{ {
if( m_active ) if (m_active) {
{
m_contentRotation += time * 360.0f / 20000.0f; m_contentRotation += time * 360.0f / 20000.0f;
if( m_contentRotation > 360.0f ) if (m_contentRotation > 360.0f)
m_contentRotation -= 360.0f; m_contentRotation -= 360.0f;
m_angle += time * 360.0f / 8000.0f; m_angle += time * 360.0f / 8000.0f;
if( m_angle > 360.0f ) if (m_angle > 360.0f)
m_angle -= 360.0f; m_angle -= 360.0f;
}
effects->prePaintScreen( data, time );
} }
effects->prePaintScreen(data, time);
}
void GearsEffect::postPaintScreen() void GearsEffect::postPaintScreen()
{ {
if( m_active ) if (m_active) {
{
effects->addRepaintFull(); effects->addRepaintFull();
}
effects->postPaintScreen();
} }
effects->postPaintScreen();
}
void GearsEffect::paint() void GearsEffect::paint()
{ {
if( m_active ) if (m_active) {
{
paintGears(); paintGears();
}
} }
}
void GearsEffect::setActive( bool active ) void GearsEffect::setActive(bool active)
{ {
m_active = active; m_active = active;
if( active ) if (active)
initGears(); initGears();
else else
endGears(); endGears();
} }
void GearsEffect::gear( float inner_radius, float outer_radius, float width, int teeth, float tooth_depth ) void GearsEffect::gear(float inner_radius, float outer_radius, float width, int teeth, float tooth_depth)
{ {
GLint i; GLint i;
GLfloat r0, r1, r2, maxr2, minr2; GLfloat r0, r1, r2, maxr2, minr2;
GLfloat angle, da; GLfloat angle, da;
@ -116,204 +113,196 @@ void GearsEffect::gear( float inner_radius, float outer_radius, float width, int
da = 2.0 * M_PI / teeth / 4.0; da = 2.0 * M_PI / teeth / 4.0;
glShadeModel( GL_FLAT ); glShadeModel(GL_FLAT);
glNormal3f( 0.0, 0.0, 1.0 ); glNormal3f(0.0, 0.0, 1.0);
/* draw front face */ /* draw front face */
glBegin( GL_QUAD_STRIP ); glBegin(GL_QUAD_STRIP);
for( i = 0; i <= teeth; ++i ) for (i = 0; i <= teeth; ++i) {
{
angle = i * 2.0 * M_PI / teeth; angle = i * 2.0 * M_PI / teeth;
glVertex3f( r0 * cos( angle ), r0 * sin( angle ), width * 0.5 ); glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
glVertex3f( r1 * cos( angle ), r1 * sin( angle ), width * 0.5 ); glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
if( i < teeth ) if (i < teeth) {
{ glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
glVertex3f( r0 * cos( angle ), r0 * sin( angle ), width * 0.5 ); glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5);
glVertex3f( r1 * cos( angle + 3 * da ), r1 * sin( angle + 3 * da ), width * 0.5 );
}
} }
}
glEnd(); glEnd();
/* draw front sides of teeth */ /* draw front sides of teeth */
glBegin( GL_QUADS ); glBegin(GL_QUADS);
for( i = 0; i < teeth; ++i ) for (i = 0; i < teeth; ++i) {
{
angle = i * 2.0 * M_PI / teeth; angle = i * 2.0 * M_PI / teeth;
glVertex3f( r1 * cos( angle ), r1 * sin( angle ), width * 0.5 ); glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
glVertex3f( r2 * cos( angle + da ), r2 * sin( angle + da ), width * 0.5 ); glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5);
glVertex3f( r2 * cos( angle + 2 * da ), r2 * sin( angle + 2 * da ), width * 0.5 ); glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), width * 0.5);
glVertex3f( r1 * cos( angle + 3 * da ), r1 * sin( angle + 3 * da ), width * 0.5 ); glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5);
r2 = minr2; r2 = minr2;
} }
r2 = maxr2; r2 = maxr2;
glEnd(); glEnd();
glNormal3f( 0.0, 0.0, -1.0 ); glNormal3f(0.0, 0.0, -1.0);
/* draw back face */ /* draw back face */
glBegin( GL_QUAD_STRIP ); glBegin(GL_QUAD_STRIP);
for( i = 0; i <= teeth; ++i ) for (i = 0; i <= teeth; ++i) {
{
angle = i * 2.0 * M_PI / teeth; angle = i * 2.0 * M_PI / teeth;
glVertex3f( r1 * cos( angle ), r1 * sin( angle ), -width * 0.5 ); glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
glVertex3f( r0 * cos( angle ), r0 * sin( angle ), -width * 0.5 ); glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
if( i < teeth ) if (i < teeth) {
{ glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5);
glVertex3f( r1 * cos( angle + 3 * da ), r1 * sin( angle + 3 * da ), -width * 0.5 ); glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
glVertex3f( r0 * cos( angle ), r0 * sin( angle ), -width * 0.5 );
}
} }
}
glEnd(); glEnd();
/* draw back sides of teeth */ /* draw back sides of teeth */
glBegin( GL_QUADS ); glBegin(GL_QUADS);
da = 2.0 * M_PI / teeth / 4.0; da = 2.0 * M_PI / teeth / 4.0;
for( i = 0; i < teeth; ++i ) for (i = 0; i < teeth; ++i) {
{
angle = i * 2.0 * M_PI / teeth; angle = i * 2.0 * M_PI / teeth;
glVertex3f( r1 * cos( angle + 3 * da ), r1 * sin( angle + 3 * da ), -width * 0.5 ); glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5);
glVertex3f( r2 * cos( angle + 2 * da ), r2 * sin( angle + 2 * da ), -width * 0.5 ); glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), -width * 0.5);
glVertex3f( r2 * cos (angle + da), r2 * sin (angle + da), -width * 0.5 ); glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5);
glVertex3f( r1 * cos (angle), r1 * sin (angle), -width * 0.5 ); glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
r2 = minr2; r2 = minr2;
} }
r2 = maxr2; r2 = maxr2;
glEnd(); glEnd();
/* draw outward faces of teeth */ /* draw outward faces of teeth */
glBegin( GL_QUAD_STRIP ); glBegin(GL_QUAD_STRIP);
for( i = 0; i < teeth; ++i ) for (i = 0; i < teeth; ++i) {
{
angle = i * 2.0 * M_PI / teeth; angle = i * 2.0 * M_PI / teeth;
glVertex3f( r1 * cos( angle ), r1 * sin( angle ), width * 0.5 ); glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
glVertex3f( r1 * cos( angle ), r1 * sin( angle ), -width * 0.5 ); glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
u = r2 * cos( angle + da ) - r1 * cos( angle ); u = r2 * cos(angle + da) - r1 * cos(angle);
v = r2 * sin( angle + da ) - r1 * sin( angle ); v = r2 * sin(angle + da) - r1 * sin(angle);
len = sqrt( u * u + v * v ); len = sqrt(u * u + v * v);
u /= len; u /= len;
v /= len; v /= len;
glNormal3f( v, -u, 0.0 ); glNormal3f(v, -u, 0.0);
glVertex3f( r2 * cos( angle + da ), r2 * sin( angle + da ), width * 0.5 ); glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5);
glVertex3f( r2 * cos( angle + da ), r2 * sin( angle + da ), -width * 0.5 ); glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5);
glNormal3f( cos( angle + 1.5 * da ), sin( angle + 1.5 * da ), 0.0 ); glNormal3f(cos(angle + 1.5 * da), sin(angle + 1.5 * da), 0.0);
glVertex3f( r2 * cos( angle + 2 * da ), r2 * sin( angle + 2 * da ), width * 0.5 ); glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), width * 0.5);
glVertex3f( r2 * cos( angle + 2 * da ), r2 * sin( angle + 2 * da ), -width * 0.5 ); glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), -width * 0.5);
u = r1 * cos( angle + 3 * da ) - r2 * cos( angle + 2 * da ); u = r1 * cos(angle + 3 * da) - r2 * cos(angle + 2 * da);
v = r1 * sin( angle + 3 * da ) - r2 * sin( angle + 2 * da ); v = r1 * sin(angle + 3 * da) - r2 * sin(angle + 2 * da);
glNormal3f( v, -u, 0.0 ); glNormal3f(v, -u, 0.0);
glVertex3f( r1 * cos( angle + 3 * da ), r1 * sin( angle + 3 * da ), width * 0.5 ); glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5);
glVertex3f( r1 * cos( angle + 3 * da ), r1 * sin( angle + 3 * da ), -width * 0.5 ); glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5);
glNormal3f( cos( angle + 3.5 * da ), sin( angle + 3.5 * da ), 0.0 ); glNormal3f(cos(angle + 3.5 * da), sin(angle + 3.5 * da), 0.0);
r2 = minr2; r2 = minr2;
} }
r2 = maxr2; r2 = maxr2;
glVertex3f( r1 * cos( 0 ), r1 * sin( 0 ), width * 0.5 ); glVertex3f(r1 * cos(0), r1 * sin(0), width * 0.5);
glVertex3f( r1 * cos( 0 ), r1 * sin( 0 ), -width * 0.5 ); glVertex3f(r1 * cos(0), r1 * sin(0), -width * 0.5);
glEnd(); glEnd();
glShadeModel( GL_SMOOTH ); glShadeModel(GL_SMOOTH);
/* draw inside radius cylinder */ /* draw inside radius cylinder */
glBegin( GL_QUAD_STRIP ); glBegin(GL_QUAD_STRIP);
for( i = 0; i <= teeth; ++i ) for (i = 0; i <= teeth; ++i) {
{
angle = i * 2.0 * M_PI / teeth; angle = i * 2.0 * M_PI / teeth;
glNormal3f( -cos( angle ), -sin( angle ), 0.0 ); glNormal3f(-cos(angle), -sin(angle), 0.0);
glVertex3f( r0 * cos( angle ), r0 * sin( angle ), -width * 0.5 ); glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
glVertex3f( r0 * cos( angle ), r0 * sin( angle ), width * 0.5 ); glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
}
glEnd();
} }
glEnd();
}
void GearsEffect::paintGears() void GearsEffect::paintGears()
{ {
static GLfloat white[4] = { 1.0, 1.0, 1.0, 1.0 }; static GLfloat white[4] = { 1.0, 1.0, 1.0, 1.0 };
QRect rect = effects->clientArea( FullArea, effects->activeScreen(), effects->currentDesktop() ); QRect rect = effects->clientArea(FullArea, effects->activeScreen(), effects->currentDesktop());
glPushMatrix(); glPushMatrix();
// invert scale // invert scale
float fovy = 60.0f; float fovy = 60.0f;
float zNear = 0.1f; float zNear = 0.1f;
float ymax = zNear * tan( fovy * M_PI / 360.0f ); float ymax = zNear * tan(fovy * M_PI / 360.0f);
float ymin = -ymax; float ymin = -ymax;
float xmin = ymin; float xmin = ymin;
float xmax = ymax; float xmax = ymax;
float scaleFactor = 1.1 * tan( fovy * M_PI / 360.0f )/ymax; float scaleFactor = 1.1 * tan(fovy * M_PI / 360.0f) / ymax;
glScalef( 1.0f/((xmax-xmin)*scaleFactor/displayWidth()), 1.0f/(-(ymax-ymin)*scaleFactor/displayHeight()), 1000.0f ); glScalef(1.0f / ((xmax - xmin)*scaleFactor / displayWidth()), 1.0f / (-(ymax - ymin)*scaleFactor / displayHeight()), 1000.0f);
glPushAttrib( GL_COLOR_BUFFER_BIT | GL_TEXTURE_BIT | GL_ENABLE_BIT | GL_LIGHTING_BIT ); glPushAttrib(GL_COLOR_BUFFER_BIT | GL_TEXTURE_BIT | GL_ENABLE_BIT | GL_LIGHTING_BIT);
glDisable( GL_BLEND ); glDisable(GL_BLEND);
glPushMatrix(); glPushMatrix();
// content rotation requires depth test - so disabled // content rotation requires depth test - so disabled
// glRotatef( m_contentRotation, 0.0, 1.0, 0.0 ); // glRotatef( m_contentRotation, 0.0, 1.0, 0.0 );
glScalef( 0.05, 0.05, 0.05 ); glScalef(0.05, 0.05, 0.05);
glEnable( GL_NORMALIZE ); glEnable(GL_NORMALIZE);
glEnable( GL_LIGHTING ); glEnable(GL_LIGHTING);
glEnable( GL_LIGHT1 ); glEnable(GL_LIGHT1);
glDisable( GL_COLOR_MATERIAL ); glDisable(GL_COLOR_MATERIAL);
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glPushMatrix(); glPushMatrix();
glTranslatef( -3.0, -2.0, 0.0 ); glTranslatef(-3.0, -2.0, 0.0);
glRotatef( m_angle, 0.0, 0.0, 1.0 ); glRotatef(m_angle, 0.0, 0.0, 1.0);
glCallList( m_gear1 ); glCallList(m_gear1);
glPopMatrix(); glPopMatrix();
glPushMatrix(); glPushMatrix();
glTranslatef( 3.1, -2.0, 0.0 ); glTranslatef(3.1, -2.0, 0.0);
glRotatef( -2.0 * m_angle - 9.0, 0.0, 0.0, 1.0 ); glRotatef(-2.0 * m_angle - 9.0, 0.0, 0.0, 1.0);
glCallList( m_gear2 ); glCallList(m_gear2);
glPopMatrix(); glPopMatrix();
glPushMatrix(); glPushMatrix();
glTranslatef( -3.1, 4.2, 0.0 ); glTranslatef(-3.1, 4.2, 0.0);
glRotatef( -2.0 * m_angle - 25.0, 0.0, 0.0, 1.0 ); glRotatef(-2.0 * m_angle - 25.0, 0.0, 0.0, 1.0);
glCallList( m_gear3 ); glCallList(m_gear3);
glPopMatrix(); glPopMatrix();
glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, white ); glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, white);
glPopMatrix(); glPopMatrix();
glDisable( GL_LIGHT1 ); glDisable(GL_LIGHT1);
glDisable( GL_NORMALIZE ); glDisable(GL_NORMALIZE);
glEnable( GL_COLOR_MATERIAL ); glEnable(GL_COLOR_MATERIAL);
glDisable( GL_LIGHTING ); glDisable(GL_LIGHTING);
glPopMatrix(); glPopMatrix();
glPopAttrib(); glPopAttrib();
} }
void GearsEffect::initGears() void GearsEffect::initGears()
{ {
static GLfloat pos[4] = { 5.0f, 5.0f, 10.0f, 0.0f }; static GLfloat pos[4] = { 5.0f, 5.0f, 10.0f, 0.0f };
static GLfloat red[4] = { 0.8f, 0.1f, 0.0f, 1.0f }; static GLfloat red[4] = { 0.8f, 0.1f, 0.0f, 1.0f };
static GLfloat green[4] = { 0.0f, 0.8f, 0.2f, 1.0f }; static GLfloat green[4] = { 0.0f, 0.8f, 0.2f, 1.0f };
@ -321,34 +310,34 @@ void GearsEffect::initGears()
static GLfloat ambientLight[] = { 0.3f, 0.3f, 0.3f, 0.3f }; static GLfloat ambientLight[] = { 0.3f, 0.3f, 0.3f, 0.3f };
static GLfloat diffuseLight[] = { 0.5f, 0.5f, 0.5f, 0.5f }; static GLfloat diffuseLight[] = { 0.5f, 0.5f, 0.5f, 0.5f };
glLightfv( GL_LIGHT1, GL_AMBIENT, ambientLight ); glLightfv(GL_LIGHT1, GL_AMBIENT, ambientLight);
glLightfv( GL_LIGHT1, GL_DIFFUSE, diffuseLight ); glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuseLight);
glLightfv( GL_LIGHT1, GL_POSITION, pos ); glLightfv(GL_LIGHT1, GL_POSITION, pos);
m_gear1 = glGenLists( 1 ); m_gear1 = glGenLists(1);
glNewList( m_gear1, GL_COMPILE ); glNewList(m_gear1, GL_COMPILE);
glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red ); glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
gear( 1.0f, 4.0f, 1.0f, 20, 0.7f ); gear(1.0f, 4.0f, 1.0f, 20, 0.7f);
glEndList(); glEndList();
m_gear2 = glGenLists( 1 ); m_gear2 = glGenLists(1);
glNewList( m_gear2, GL_COMPILE ); glNewList(m_gear2, GL_COMPILE);
glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green ); glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);
gear( 0.5f, 2.0f, 2.0f, 10, 0.7f ); gear(0.5f, 2.0f, 2.0f, 10, 0.7f);
glEndList(); glEndList();
m_gear3 = glGenLists( 1 ); m_gear3 = glGenLists(1);
glNewList( m_gear3, GL_COMPILE ); glNewList(m_gear3, GL_COMPILE);
glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue ); glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
gear( 1.3f, 2.0f, 0.5f, 10, 0.7f ); gear(1.3f, 2.0f, 0.5f, 10, 0.7f);
glEndList(); glEndList();
} }
void GearsEffect::endGears() void GearsEffect::endGears()
{ {
glDeleteLists( m_gear1, 1 ); glDeleteLists(m_gear1, 1);
glDeleteLists( m_gear2, 1 ); glDeleteLists(m_gear2, 1);
glDeleteLists( m_gear3, 1 ); glDeleteLists(m_gear3, 1);
} }
} // namespace } // namespace

View File

@ -33,28 +33,28 @@ namespace KWin
class GearsEffect : public CubeInsideEffect class GearsEffect : public CubeInsideEffect
{ {
public: public:
GearsEffect(); GearsEffect();
~GearsEffect(); ~GearsEffect();
virtual void paint(); virtual void paint();
virtual void setActive( bool active ); virtual void setActive(bool active);
virtual void prePaintScreen(ScreenPrePaintData& data, int time); virtual void prePaintScreen(ScreenPrePaintData& data, int time);
virtual void postPaintScreen(); virtual void postPaintScreen();
static bool supported(); static bool supported();
private: private:
void gear( float inner_radius, float outer_radius, float width, int teeth, float tooth_depth ); void gear(float inner_radius, float outer_radius, float width, int teeth, float tooth_depth);
void paintGears(); void paintGears();
void initGears(); void initGears();
void endGears(); void endGears();
bool m_active; bool m_active;
GLuint m_gear1; GLuint m_gear1;
GLuint m_gear2; GLuint m_gear2;
GLuint m_gear3; GLuint m_gear3;
float m_contentRotation; float m_contentRotation;
float m_angle; float m_angle;
}; };
} //namespace } //namespace

View File

@ -14,7 +14,7 @@ License. See the file "COPYING" for the exact licensing terms.
effect that fades out and again in a window after it has been activated. effect that fades out and again in a window after it has been activated.
Please see file howto.h first. Please see file howto.h first.
*/ */
// Include the class definition. // Include the class definition.
@ -24,7 +24,7 @@ namespace KWin
{ {
// This macro creates entry function for the plugin. First argument is name, second is class name. // This macro creates entry function for the plugin. First argument is name, second is class name.
KWIN_EFFECT( howto, HowtoEffect ) KWIN_EFFECT(howto, HowtoEffect)
// A pre-paint function that tells the compositing code how this effect will affect // A pre-paint function that tells the compositing code how this effect will affect
// the painting. During every painting pass this function is called first, before // the painting. During every painting pass this function is called first, before
@ -36,33 +36,29 @@ KWIN_EFFECT( howto, HowtoEffect )
// region - the region of the screen that needs to be painted, support for modifying it // region - the region of the screen that needs to be painted, support for modifying it
// is not fully implemented yet, do not use // is not fully implemented yet, do not use
// time - time in milliseconds since the last paint, useful for animations // time - time in milliseconds since the last paint, useful for animations
void HowtoEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time ) void HowtoEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
{ {
// Is this window the one that is going to be faded out and in again? // Is this window the one that is going to be faded out and in again?
if( w == fade_window ) if (w == fade_window) {
{
// Simply add the time to the total progress. The value of progress will be used // Simply add the time to the total progress. The value of progress will be used
// to determine how far in effect is. // to determine how far in effect is.
progress += time; progress += time;
// If progress is < 1000 (milliseconds), the effect is still in progress. // If progress is < 1000 (milliseconds), the effect is still in progress.
if( progress < 1000 ) // complete change in 1000ms if (progress < 1000) { // complete change in 1000ms
{
// Since the effect will make the window translucent, explicitly change // Since the effect will make the window translucent, explicitly change
// the flags so that the window will be painted only as translucent. // the flags so that the window will be painted only as translucent.
// Use a helper that also takes care of changing the clipping rectangle. // Use a helper that also takes care of changing the clipping rectangle.
data.setTranslucent(); data.setTranslucent();
} } else {
else
{
// If progress has reached 1000 (milliseconds), it means the effect is done // If progress has reached 1000 (milliseconds), it means the effect is done
// and there is no window to fade anymore. // and there is no window to fade anymore.
fade_window = NULL; fade_window = NULL;
}
} }
}
// Call the next effect (or the actual window painting code if this is the last effect). // Call the next effect (or the actual window painting code if this is the last effect).
// Effects are chained and they all modify something if needed and then call the next one. // Effects are chained and they all modify something if needed and then call the next one.
effects->prePaintWindow( w, data, time ); effects->prePaintWindow(w, data, time);
} }
// The function that handles the actual painting. Some simple modifications are possible // The function that handles the actual painting. Some simple modifications are possible
// by only changing the painting data. More complicated effects would do some painting // by only changing the painting data. More complicated effects would do some painting
@ -74,73 +70,67 @@ void HowtoEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int
// then special care needs to be taken, because the region may be infiniteRegion(), meaning // then special care needs to be taken, because the region may be infiniteRegion(), meaning
// everything needs to be painted // everything needs to be painted
// data - painting data that can be modified to do some simple transformations // data - painting data that can be modified to do some simple transformations
void HowtoEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ) void HowtoEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{ {
// Is this the window to be faded out and in again? // Is this the window to be faded out and in again?
if( w == fade_window ) if (w == fade_window) {
{
// This effect, after a window has been activated, fades it out to only 50% transparency // This effect, after a window has been activated, fades it out to only 50% transparency
// and then fades it in again to be fully opaque (assuming it's otherwise a fully opaque // and then fades it in again to be fully opaque (assuming it's otherwise a fully opaque
// window, otherwise the transparencies will be added). // window, otherwise the transparencies will be added).
if( progress <= 500 ) if (progress <= 500) {
{
// For the first 500 milliseconds (progress being 0 to 500), the window is faded out. // For the first 500 milliseconds (progress being 0 to 500), the window is faded out.
// progress == 0 -> opacity *= 1 // progress == 0 -> opacity *= 1
// progress == 500 -> opacity *= 0.5 // progress == 500 -> opacity *= 0.5
// Note that the division is floating-point division to avoid integer rounding down. // Note that the division is floating-point division to avoid integer rounding down.
// Note that data.opacity is not set but multiplied - this allows chaining of effects, // Note that data.opacity is not set but multiplied - this allows chaining of effects,
// for example if another effect always changes opacity of some window types. // for example if another effect always changes opacity of some window types.
data.opacity *= 1 - 0.5 * ( progress / 500.0 ); data.opacity *= 1 - 0.5 * (progress / 500.0);
} } else {
else
{
// For the second 500 milliseconds (progress being 500 to 1000), the window is // For the second 500 milliseconds (progress being 500 to 1000), the window is
// faded in again. // faded in again.
// progress == 500 -> opacity *= 0.5 // progress == 500 -> opacity *= 0.5
// progress == 1000 -> opacity *= 1 // progress == 1000 -> opacity *= 1
data.opacity *= 0.5 + 0.5 * ( progress - 500 ) / 500.0; data.opacity *= 0.5 + 0.5 * (progress - 500) / 500.0;
}
} }
// Call the next effect.
effects->paintWindow( w, mask, region, data );
} }
// Call the next effect.
effects->paintWindow(w, mask, region, data);
}
// The function that is called after the painting pass is finished. When an animation is going on, // The function that is called after the painting pass is finished. When an animation is going on,
// it can add repaints of some areas so that the next painting pass has to repaint them again. // it can add repaints of some areas so that the next painting pass has to repaint them again.
void HowtoEffect::postPaintWindow( EffectWindow* w ) void HowtoEffect::postPaintWindow(EffectWindow* w)
{ {
// Is this the window to be faded out and in again? // Is this the window to be faded out and in again?
if( w == fade_window ) if (w == fade_window) {
{
// Trigger repaint of the whole window, this will cause it to be repainted the next painting pass. // Trigger repaint of the whole window, this will cause it to be repainted the next painting pass.
w->addRepaintFull(); // trigger next animation repaint w->addRepaintFull(); // trigger next animation repaint
}
// Call the next effect.
effects->postPaintWindow( w );
} }
// Call the next effect.
effects->postPaintWindow(w);
}
// This function is called when a new window becomes active. // This function is called when a new window becomes active.
void HowtoEffect::windowActivated( EffectWindow* c ) void HowtoEffect::windowActivated(EffectWindow* c)
{ {
// Set the window to be faded (or NULL if no window is active). // Set the window to be faded (or NULL if no window is active).
fade_window = c; fade_window = c;
if( fade_window != NULL ) if (fade_window != NULL) {
{
// If there is a window to be faded, reset the progress to zero. // If there is a window to be faded, reset the progress to zero.
progress = 0; progress = 0;
// And add repaint to the window so that it needs to be repainted. // And add repaint to the window so that it needs to be repainted.
c->addRepaintFull(); c->addRepaintFull();
}
} }
}
// This function is called when a window is closed. // This function is called when a window is closed.
void HowtoEffect::windowClosed( EffectWindow* c ) void HowtoEffect::windowClosed(EffectWindow* c)
{ {
// If the window to be faded out and in is closed, just reset the pointer. // If the window to be faded out and in is closed, just reset the pointer.
// This effect then will do nothing and just call the next effect. // This effect then will do nothing and just call the next effect.
if( fade_window == c ) if (fade_window == c)
fade_window = NULL; fade_window = NULL;
} }
// That's all. Now only the matching .desktop file is needed. // That's all. Now only the matching .desktop file is needed.

View File

@ -30,39 +30,39 @@ namespace KWin
class HowtoEffect class HowtoEffect
// Inherit from the base class for effects. // Inherit from the base class for effects.
: public Effect : public Effect
{ {
public: public:
// There are two kinds of functions in an effect: // There are two kinds of functions in an effect:
// Functions related to painting: These allow the effect to affect painting.
// A pre-paint function. It tells the compositing code how the painting will // Functions related to painting: These allow the effect to affect painting.
// be affected by this effect.
virtual void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time );
// A paint function. It actually performs the modifications to the painting.
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data );
// A post-paint function. It can be used for cleanups after painting, but with animations
// it is also used to trigger repaints during the next painting pass by manually "damaging"
// areas of the window.
virtual void postPaintWindow( EffectWindow* w );
// Notification functions: These inform the effect about changes such as a new window
// being activated.
// The given window has been closed. // A pre-paint function. It tells the compositing code how the painting will
virtual void windowClosed( EffectWindow* c ); // be affected by this effect.
virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time);
// The given window has been activated.
virtual void windowActivated( EffectWindow* c ); // A paint function. It actually performs the modifications to the painting.
private: virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
// The window that will be faded out and in again.
EffectWindow* fade_window; // A post-paint function. It can be used for cleanups after painting, but with animations
// it is also used to trigger repaints during the next painting pass by manually "damaging"
// The progress of the fading. // areas of the window.
int progress; virtual void postPaintWindow(EffectWindow* w);
};
// Notification functions: These inform the effect about changes such as a new window
// being activated.
// The given window has been closed.
virtual void windowClosed(EffectWindow* c);
// The given window has been activated.
virtual void windowActivated(EffectWindow* c);
private:
// The window that will be faded out and in again.
EffectWindow* fade_window;
// The progress of the fading.
int progress;
};
} // namespace } // namespace

View File

@ -29,230 +29,212 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
namespace KWin namespace KWin
{ {
KWIN_EFFECT( kicker, KickerEffect ) KWIN_EFFECT(kicker, KickerEffect)
KickerEffect::KickerEffect() KickerEffect::KickerEffect()
: m_page( new QWebPage( this ) ) : m_page(new QWebPage(this))
, m_timer( new QTimer( this ) ) , m_timer(new QTimer(this))
, m_goalTimer( new QTimer( this ) ) , m_goalTimer(new QTimer(this))
, m_goalActive( false ) , m_goalActive(false)
, m_ascending( false ) , m_ascending(false)
{ {
connect(m_page, SIGNAL(loadFinished(bool)), this, SLOT(slotLoadFinished(bool))); connect(m_page, SIGNAL(loadFinished(bool)), this, SLOT(slotLoadFinished(bool)));
connect(m_timer, SIGNAL(timeout()), this, SLOT(timeout())); connect(m_timer, SIGNAL(timeout()), this, SLOT(timeout()));
connect(m_goalTimer, SIGNAL(timeout()), this, SLOT(goalTimeout())); connect(m_goalTimer, SIGNAL(timeout()), this, SLOT(goalTimeout()));
reconfigure( ReconfigureAll ); reconfigure(ReconfigureAll);
// reload the webpage each half a minute // reload the webpage each half a minute
m_timer->start(30*1000); m_timer->start(30 * 1000);
// goal animation should end after seven seconds // goal animation should end after seven seconds
m_goalTimer->setInterval( 7 * 1000 ); m_goalTimer->setInterval(7 * 1000);
m_goalTimer->setSingleShot( true ); m_goalTimer->setSingleShot(true);
// the animations should have a duration of half a second with an // the animations should have a duration of half a second with an
// ease in out curve // ease in out curve
m_timeLine.setCurveShape( TimeLine::EaseInOutCurve ); m_timeLine.setCurveShape(TimeLine::EaseInOutCurve);
m_timeLine.setDuration( 500 ); m_timeLine.setDuration(500);
// let's download the webpage immediatelly // let's download the webpage immediatelly
timeout(); timeout();
} }
KickerEffect::~KickerEffect() KickerEffect::~KickerEffect()
{ {
while( !m_frames.isEmpty() ) while (!m_frames.isEmpty()) {
{
delete m_frames.first(); delete m_frames.first();
m_frames.removeFirst(); m_frames.removeFirst();
} }
while( !m_goalFrames.isEmpty() ) while (!m_goalFrames.isEmpty()) {
{
delete m_goalFrames.first(); delete m_goalFrames.first();
m_goalFrames.removeFirst(); m_goalFrames.removeFirst();
}
} }
}
void KickerEffect::reconfigure( ReconfigureFlags ) void KickerEffect::reconfigure(ReconfigureFlags)
{ {
} }
void KickerEffect::prePaintScreen( ScreenPrePaintData& data, int time ) void KickerEffect::prePaintScreen(ScreenPrePaintData& data, int time)
{ {
// the goal animation uses a KWin::TimeLine to modify the opacity values // the goal animation uses a KWin::TimeLine to modify the opacity values
// as long as the goal timer has not timed out m_goalActive is true // as long as the goal timer has not timed out m_goalActive is true
// after the timeout an animation might still be running, so we continue // after the timeout an animation might still be running, so we continue
// till progress reaches 0.0 again // till progress reaches 0.0 again
if( m_goalActive || m_timeLine.progress() != 0.0 ) if (m_goalActive || m_timeLine.progress() != 0.0) {
{
// the animation might either be ascending (increasing opacity) or // the animation might either be ascending (increasing opacity) or
// descending (decreasing opacity). In case of ascending we add time // descending (decreasing opacity). In case of ascending we add time
// to the timeline till progress reaches 1.0. There we switch direction // to the timeline till progress reaches 1.0. There we switch direction
// to descending. In descending case of course vice versa. // to descending. In descending case of course vice versa.
if( m_ascending ) if (m_ascending) {
{ m_timeLine.addTime(time);
m_timeLine.addTime( time ); if (m_timeLine.progress() == 1.0) {
if( m_timeLine.progress() == 1.0 )
{
m_ascending = false; m_ascending = false;
}
} }
else } else {
{ m_timeLine.removeTime(time);
m_timeLine.removeTime( time );
// it is possible that this is the last animation. Therefore the // it is possible that this is the last animation. Therefore the
// anding with goalActive. If it has been the last animation we // anding with goalActive. If it has been the last animation we
// do not need to keep the goal EffectFrame around any more, so // do not need to keep the goal EffectFrame around any more, so
// we delete them. // we delete them.
if( m_timeLine.progress() == 0.0 && m_goalActive ) if (m_timeLine.progress() == 0.0 && m_goalActive) {
{
m_ascending = true; m_ascending = true;
} } else if (m_timeLine.progress() == 0.0) {
else if( m_timeLine.progress() == 0.0 )
{
// goal animation finshed, let's delete the EffectFrames // goal animation finshed, let's delete the EffectFrames
while( !m_goalFrames.isEmpty() ) while (!m_goalFrames.isEmpty()) {
{
delete m_goalFrames.first(); delete m_goalFrames.first();
m_goalFrames.removeFirst(); m_goalFrames.removeFirst();
}
m_goalFrames.clear();
} }
m_goalFrames.clear();
} }
} }
effects->prePaintScreen( data, time );
} }
effects->prePaintScreen(data, time);
}
void KickerEffect::paintScreen( int mask, QRegion region, ScreenPaintData &data ) void KickerEffect::paintScreen(int mask, QRegion region, ScreenPaintData &data)
{ {
effects->paintScreen( mask, region, data ); effects->paintScreen(mask, region, data);
if( m_size.isValid() ) if (m_size.isValid()) {
{
// let's paint the score EffectFrame with unmodified opacity. As it // let's paint the score EffectFrame with unmodified opacity. As it
// uses Plasma styled textures it's still translucent, but the text // uses Plasma styled textures it's still translucent, but the text
// is fully opaque. // is fully opaque.
foreach( EffectFrame* frame, m_frames ) foreach (EffectFrame * frame, m_frames)
frame->render( region, 1.0 ); frame->render(region, 1.0);
} }
if( m_goalActive || m_timeLine.progress() != 0.0 ) if (m_goalActive || m_timeLine.progress() != 0.0) {
{
// the goal animation changes the opacity. Therefore we modify the // the goal animation changes the opacity. Therefore we modify the
// opacity by multiplying with the timeline's progress. // opacity by multiplying with the timeline's progress.
// The text should be fully opaque (1.0), while the background should // The text should be fully opaque (1.0), while the background should
// be translucent (0.75) // be translucent (0.75)
foreach( EffectFrame* frame, m_goalFrames ) foreach (EffectFrame * frame, m_goalFrames)
frame->render( region, 1.0 * m_timeLine.progress(), 0.75 * m_timeLine.progress() ); frame->render(region, 1.0 * m_timeLine.progress(), 0.75 * m_timeLine.progress());
// we are animating: need a new frame // we are animating: need a new frame
effects->addRepaintFull(); effects->addRepaintFull();
}
} }
}
void KickerEffect::slotLoadFinished( bool ok ) void KickerEffect::slotLoadFinished(bool ok)
{ {
// if connection failed let's keep the last score // if connection failed let's keep the last score
if( !ok ) if (!ok)
return; return;
QWebElement doc = m_page->mainFrame()->documentElement(); QWebElement doc = m_page->mainFrame()->documentElement();
// CSS selector for the teams // CSS selector for the teams
QWebElementCollection teams = doc.findAll("td.lttabver h1 a"); QWebElementCollection teams = doc.findAll("td.lttabver h1 a");
if( teams.count() != 2 ) if (teams.count() != 2)
return; return;
QString firstTeam = teams[0].toPlainText(); QString firstTeam = teams[0].toPlainText();
QString secondTeam = teams[1].toPlainText(); QString secondTeam = teams[1].toPlainText();
// CSS selector for the current score // CSS selector for the current score
QString result = doc.findFirst("td.lttaberg h1").toPlainText(); QString result = doc.findFirst("td.lttaberg h1").toPlainText();
if( m_score != result ) if (m_score != result) {
{
// the score changed, a goal might have been scored // the score changed, a goal might have been scored
bool activate = true; bool activate = true;
// but not if the web page has been loaded for the first time // but not if the web page has been loaded for the first time
if( m_score.isNull() ) if (m_score.isNull())
activate = false; activate = false;
// not if we entered extra time // not if we entered extra time
if( !m_score.contains("i.V.") && result.contains("i.V.") ) if (!m_score.contains("i.V.") && result.contains("i.V."))
activate = false; activate = false;
// not if extra time ended // not if extra time ended
if( !m_score.contains("n.V.") && result.contains("n.V.") ) if (!m_score.contains("n.V.") && result.contains("n.V."))
activate = false; activate = false;
// not if penality shootout begins // not if penality shootout begins
if( !m_score.contains("i.E.") && result.contains("i.E.") ) if (!m_score.contains("i.E.") && result.contains("i.E."))
activate = false; activate = false;
// not if first or second half starts. // not if first or second half starts.
if( m_score.count( '-' ) > result.count( '-' ) ) if (m_score.count('-') > result.count('-'))
activate = false; activate = false;
// yeah it's a goal - generate the EffectFrame and start the animation // yeah it's a goal - generate the EffectFrame and start the animation
if( activate ) if (activate) {
{
generateGoalImage(); generateGoalImage();
m_goalActive = true; m_goalActive = true;
m_ascending = true; m_ascending = true;
m_goalTimer->start(); m_goalTimer->start();
}
m_score = result;
} }
m_score = result;
}
QString text = firstTeam + ' ' + result + ' ' + secondTeam; QString text = firstTeam + ' ' + result + ' ' + secondTeam;
QFont font; QFont font;
font.setBold( true ); font.setBold(true);
QFontMetrics fm(font); QFontMetrics fm(font);
m_size = fm.boundingRect(text).adjusted(-10, -10, 10, 10).size(); m_size = fm.boundingRect(text).adjusted(-10, -10, 10, 10).size();
// we don't want to reposition the EffectFrames, therefore we delete the // we don't want to reposition the EffectFrames, therefore we delete the
// old ones. Normally you wouldn't do that, but as we only update once in // old ones. Normally you wouldn't do that, but as we only update once in
// half a minute and it's easier to code... // half a minute and it's easier to code...
while( !m_frames.isEmpty() ) while (!m_frames.isEmpty()) {
{
delete m_frames.first(); delete m_frames.first();
m_frames.removeFirst(); m_frames.removeFirst();
} }
m_frames.clear(); m_frames.clear();
// and properly position the frame on each screen // and properly position the frame on each screen
for( int i = 0; i < effects->numScreens(); i++ ) for (int i = 0; i < effects->numScreens(); i++) {
{ QRect area = effects->clientArea(ScreenArea, i, effects->currentDesktop());
QRect area = effects->clientArea( ScreenArea, i, effects->currentDesktop()); QRect geometry = QRect(area.x() + area.width() - m_size.width() - 20, area.y() + 20, m_size.width(), m_size.height());
QRect geometry = QRect( area.x() + area.width() - m_size.width() - 20, area.y() + 20, m_size.width(), m_size.height() ); EffectFrame *frame = new EffectFrame(EffectFrame::Styled);
EffectFrame *frame = new EffectFrame( EffectFrame::Styled ); frame->setText(text);
frame->setText( text ); frame->setFont(font);
frame->setFont( font ); frame->setGeometry(geometry);
frame->setGeometry( geometry );
m_frames.append(frame); m_frames.append(frame);
} }
// effect frame changed and animation might have started - we need a full repaint // effect frame changed and animation might have started - we need a full repaint
effects->addRepaintFull(); effects->addRepaintFull();
} }
void KickerEffect::timeout() void KickerEffect::timeout()
{ {
// hard coded URL to the liveticker of the match Argentina vs Germany at World Cup 2010. // hard coded URL to the liveticker of the match Argentina vs Germany at World Cup 2010.
// If this URL is not valid anymore you can find newer examples on the referrenced web site. // If this URL is not valid anymore you can find newer examples on the referrenced web site.
m_page->mainFrame()->load(QUrl("http://www.kicker.de/news/fussball/wm/spielplan/weltmeisterschaft/2010/5/833353/livematch_argentinien_deutschland.html")); m_page->mainFrame()->load(QUrl("http://www.kicker.de/news/fussball/wm/spielplan/weltmeisterschaft/2010/5/833353/livematch_argentinien_deutschland.html"));
} }
void KickerEffect::generateGoalImage() void KickerEffect::generateGoalImage()
{ {
QFont font( "FreeMono", 172 ); QFont font("FreeMono", 172);
QString goal( "GOAL" ); QString goal("GOAL");
QFontMetrics fm( font ); QFontMetrics fm(font);
QSize size = fm.boundingRect( goal ).adjusted(-10, -10, 10, 10).size(); QSize size = fm.boundingRect(goal).adjusted(-10, -10, 10, 10).size();
for( int i = 0; i < effects->numScreens(); i++ ) for (int i = 0; i < effects->numScreens(); i++) {
{
// place one frame on the center of each screen // place one frame on the center of each screen
QRect area = effects->clientArea( ScreenArea, i, effects->currentDesktop()); QRect area = effects->clientArea(ScreenArea, i, effects->currentDesktop());
QRect geometry = QRect( area.x() + (area.width() - size.width())/2, QRect geometry = QRect(area.x() + (area.width() - size.width()) / 2,
area.y() + (area.height() - size.height())/2, area.y() + (area.height() - size.height()) / 2,
size.width(), size.height()); size.width(), size.height());
EffectFrame *frame = new EffectFrame( EffectFrame::Unstyled, false ); EffectFrame *frame = new EffectFrame(EffectFrame::Unstyled, false);
frame->setText( goal ); frame->setText(goal);
frame->setFont( font ); frame->setFont(font);
frame->setGeometry( geometry ); frame->setGeometry(geometry);
m_goalFrames.append(frame); m_goalFrames.append(frame);
}
} }
}
void KickerEffect::goalTimeout() void KickerEffect::goalTimeout()
{ {
// stop the animation // stop the animation
m_goalActive = false; m_goalActive = false;
effects->addRepaintFull(); effects->addRepaintFull();
} }
} // namespace } // namespace

View File

@ -51,33 +51,33 @@ namespace KWin
* @author Martin Gräßlin * @author Martin Gräßlin
*/ */
class KickerEffect : public QObject, public Effect class KickerEffect : public QObject, public Effect
{ {
Q_OBJECT Q_OBJECT
public: public:
KickerEffect(); KickerEffect();
~KickerEffect(); ~KickerEffect();
virtual void reconfigure( ReconfigureFlags ); virtual void reconfigure(ReconfigureFlags);
virtual void prePaintScreen( ScreenPrePaintData& data, int time ); virtual void prePaintScreen(ScreenPrePaintData& data, int time);
virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data ); virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data);
private Q_SLOTS: private Q_SLOTS:
void slotLoadFinished(bool ok); void slotLoadFinished(bool ok);
void timeout(); void timeout();
void goalTimeout(); void goalTimeout();
private: private:
void generateGoalImage(); void generateGoalImage();
QWebPage *m_page; QWebPage *m_page;
QTimer *m_timer; QTimer *m_timer;
QTimer *m_goalTimer; QTimer *m_goalTimer;
QSize m_size; QSize m_size;
QList<EffectFrame*> m_frames; QList<EffectFrame*> m_frames;
QList<EffectFrame*> m_goalFrames; QList<EffectFrame*> m_goalFrames;
bool m_goalActive; bool m_goalActive;
QString m_score; QString m_score;
TimeLine m_timeLine; TimeLine m_timeLine;
bool m_ascending; bool m_ascending;
}; };
} }

View File

@ -26,169 +26,160 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
namespace KWin namespace KWin
{ {
KWIN_EFFECT( slidetabs, SlideTabsEffect ) KWIN_EFFECT(slidetabs, SlideTabsEffect)
SlideTabsEffect::SlideTabsEffect() SlideTabsEffect::SlideTabsEffect()
{ {
reconfigure( ReconfigureAll ); reconfigure(ReconfigureAll);
} }
void SlideTabsEffect::reconfigure( ReconfigureFlags ) void SlideTabsEffect::reconfigure(ReconfigureFlags)
{ {
KConfigGroup conf = EffectsHandler::effectConfig("SlideTabs"); KConfigGroup conf = EffectsHandler::effectConfig("SlideTabs");
switching = conf.readEntry("SlideSwitching", true ); switching = conf.readEntry("SlideSwitching", true);
grouping = conf.readEntry("SlideGrouping", true ); grouping = conf.readEntry("SlideGrouping", true);
totalTime = conf.readEntry("SlideDuration", 500 ); totalTime = conf.readEntry("SlideDuration", 500);
} }
void SlideTabsEffect::prePaintWindow( EffectWindow *w, WindowPrePaintData &data, int time ) void SlideTabsEffect::prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time)
{ {
if( motionManager.isManaging( w ) ) if (motionManager.isManaging(w)) {
{
data.setTransformed(); data.setTransformed();
w->enablePainting( EffectWindow::PAINT_DISABLED ); w->enablePainting(EffectWindow::PAINT_DISABLED);
timeLine.addTime( time ); timeLine.addTime(time);
}
effects->prePaintWindow( w, data, time );
} }
effects->prePaintWindow(w, data, time);
}
void SlideTabsEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ) void SlideTabsEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{ {
if( motionManager.isManaging( w ) && w == inMove ) if (motionManager.isManaging(w) && w == inMove)
motionManager.apply( w, data ); motionManager.apply(w, data);
effects->paintWindow( w, mask, region, data ); effects->paintWindow(w, mask, region, data);
} }
void SlideTabsEffect::postPaintWindow( EffectWindow* w ) void SlideTabsEffect::postPaintWindow(EffectWindow* w)
{ {
if( motionManager.isManaging( w ) ) if (motionManager.isManaging(w)) {
{ if (w == inMove) {
if( w == inMove )
{
QRect moving = calculateNextMove(); QRect moving = calculateNextMove();
motionManager.moveWindow( w, moving ); motionManager.moveWindow(w, moving);
if( direction && timeLine.progress() >= 0.5 ) if (direction && timeLine.progress() >= 0.5) {
{
moving = target; moving = target;
target = source; target = source;
source = moving; source = moving;
direction = false; direction = false;
effects->setElevatedWindow( notMoving, false ); effects->setElevatedWindow(notMoving, false);
effects->setElevatedWindow( w, true ); effects->setElevatedWindow(w, true);
} } else if (timeLine.progress() >= 1.0) {
else if( timeLine.progress() >= 1.0 ) effects->setElevatedWindow(notMoving, false);
{ effects->setElevatedWindow(inMove, false);
effects->setElevatedWindow( notMoving, false ); motionManager.unmanage(notMoving);
effects->setElevatedWindow( inMove, false ); motionManager.unmanage(inMove);
motionManager.unmanage( notMoving );
motionManager.unmanage( inMove );
notMoving = NULL; notMoving = NULL;
inMove = NULL; inMove = NULL;
wasD = false; wasD = false;
effects->addRepaintFull(); effects->addRepaintFull();
}
} }
else if( w == notMoving && !direction && target != w->geometry() && !wasD ) } else if (w == notMoving && !direction && target != w->geometry() && !wasD) {
{
target = w->geometry(); target = w->geometry();
} }
w->addRepaintFull(); w->addRepaintFull();
}
effects->postPaintWindow( w );
} }
effects->postPaintWindow(w);
}
void SlideTabsEffect::prePaintScreen( ScreenPrePaintData &data, int time ) void SlideTabsEffect::prePaintScreen(ScreenPrePaintData &data, int time)
{ {
if( motionManager.managingWindows() ) if (motionManager.managingWindows()) {
{ motionManager.calculate(time);
motionManager.calculate( time );
data.mask |= Effect::PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS; data.mask |= Effect::PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
}
effects->prePaintScreen( data, time );
} }
effects->prePaintScreen(data, time);
}
void SlideTabsEffect::postPaintScreen() void SlideTabsEffect::postPaintScreen()
{ {
if( motionManager.managingWindows() ) if (motionManager.managingWindows())
effects->addRepaintFull(); effects->addRepaintFull();
effects->postPaintScreen(); effects->postPaintScreen();
} }
void SlideTabsEffect::clientGroupItemSwitched( EffectWindow* from, EffectWindow* to ) void SlideTabsEffect::clientGroupItemSwitched(EffectWindow* from, EffectWindow* to)
{ {
if( !switching ) if (!switching)
return; return;
inMove = to; inMove = to;
notMoving = from; notMoving = from;
source = notMoving->geometry(); source = notMoving->geometry();
QRect window = notMoving->geometry(); QRect window = notMoving->geometry();
int leftSpace = window.x(), rightSpace = displayWidth() - ( window.x() + window.width() ), int leftSpace = window.x(), rightSpace = displayWidth() - (window.x() + window.width()),
upSpace = window.y(), downSpace = displayHeight() - ( window.y() + window.height() ); upSpace = window.y(), downSpace = displayHeight() - (window.y() + window.height());
if( leftSpace >= rightSpace && leftSpace >= upSpace && leftSpace >= downSpace ) if (leftSpace >= rightSpace && leftSpace >= upSpace && leftSpace >= downSpace)
target = QRect( source.x() - ( 1.2 * source.width() ), source.y(), source.width(), source.height() ); target = QRect(source.x() - (1.2 * source.width()), source.y(), source.width(), source.height());
else if( rightSpace >= leftSpace && rightSpace >= upSpace && rightSpace >= downSpace ) else if (rightSpace >= leftSpace && rightSpace >= upSpace && rightSpace >= downSpace)
target = QRect( source.x() + ( 1.2 * source.width() ), source.y(), source.width(), source.height() ); target = QRect(source.x() + (1.2 * source.width()), source.y(), source.width(), source.height());
else if( upSpace >= leftSpace && upSpace >= rightSpace && upSpace >= downSpace ) else if (upSpace >= leftSpace && upSpace >= rightSpace && upSpace >= downSpace)
target = QRect( source.x(), source.y() - ( 1.2 * source.height() ), source.width(), source.height() ); target = QRect(source.x(), source.y() - (1.2 * source.height()), source.width(), source.height());
else else
target = QRect( source.x(), source.y() + ( 1.2 * source.height() ), source.width(), source.height() ); target = QRect(source.x(), source.y() + (1.2 * source.height()), source.width(), source.height());
timeLine.setCurveShape( TimeLine::LinearCurve ); timeLine.setCurveShape(TimeLine::LinearCurve);
timeLine.setDuration( animationTime( totalTime ) ); timeLine.setDuration(animationTime(totalTime));
timeLine.setProgress( 0.0f ); timeLine.setProgress(0.0f);
motionManager.manage( inMove ); motionManager.manage(inMove);
motionManager.manage( notMoving ); motionManager.manage(notMoving);
distance = sqrt( ( ( source.x()-target.x() ) * ( source.x()-target.x() ) ) + ( ( source.y()-target.y() ) * ( source.y()-target.y() ) ) ); distance = sqrt(((source.x() - target.x()) * (source.x() - target.x())) + ((source.y() - target.y()) * (source.y() - target.y())));
effects->setElevatedWindow( notMoving, true ); effects->setElevatedWindow(notMoving, true);
direction = wasD = true; direction = wasD = true;
QRect moving = calculateNextMove(); QRect moving = calculateNextMove();
motionManager.moveWindow( inMove, moving ); motionManager.moveWindow(inMove, moving);
} }
void SlideTabsEffect::clientGroupItemAdded( EffectWindow* from, EffectWindow* to ) void SlideTabsEffect::clientGroupItemAdded(EffectWindow* from, EffectWindow* to)
{ {
if( !grouping || from->desktop() != to->desktop() || from->isMinimized() || to->isMinimized() ) if (!grouping || from->desktop() != to->desktop() || from->isMinimized() || to->isMinimized())
return; return;
timeLine.setCurveShape( TimeLine::LinearCurve ); timeLine.setCurveShape(TimeLine::LinearCurve);
timeLine.setDuration( animationTime( totalTime ) ); timeLine.setDuration(animationTime(totalTime));
timeLine.setProgress( 0.0f ); timeLine.setProgress(0.0f);
inMove = from; inMove = from;
notMoving = to; notMoving = to;
source = inMove->geometry(); source = inMove->geometry();
target = notMoving->geometry(); target = notMoving->geometry();
distance = sqrt( ( ( source.x()-target.x() ) * ( source.x()-target.x() ) ) + ( ( source.y()-target.y() ) * ( source.y()-target.y() ) ) ); distance = sqrt(((source.x() - target.x()) * (source.x() - target.x())) + ((source.y() - target.y()) * (source.y() - target.y())));
motionManager.manage( inMove ); motionManager.manage(inMove);
motionManager.manage( notMoving ); motionManager.manage(notMoving);
QRect moving = calculateNextMove(); QRect moving = calculateNextMove();
motionManager.moveWindow( inMove, moving ); motionManager.moveWindow(inMove, moving);
effects->setElevatedWindow( notMoving, true ); effects->setElevatedWindow(notMoving, true);
direction = wasD = false; direction = wasD = false;
} }
QPoint SlideTabsEffect::calculatePointTarget( const QPoint &a, const QPoint &b ) QPoint SlideTabsEffect::calculatePointTarget(const QPoint &a, const QPoint &b)
{ {
double dy, dx, x, y, k; double dy, dx, x, y, k;
k = direction? (2.0*timeLine.progress()):(wasD?((timeLine.progress()-0.5)*2):timeLine.progress()); k = direction ? (2.0 * timeLine.progress()) : (wasD ? ((timeLine.progress() - 0.5) * 2) : timeLine.progress());
dx = fabs( a.x() - b.x() ); dx = fabs(a.x() - b.x());
dy = fabs( a.y() - b.y() ); dy = fabs(a.y() - b.y());
y = k*dy; y = k * dy;
x = k*dx; x = k * dx;
if( a.x() > b.x() ) if (a.x() > b.x())
x = -x; x = -x;
if( a.y() > b.y() ) if (a.y() > b.y())
y = -y; y = -y;
return QPoint( a.x() + x, a.y() + y ); return QPoint(a.x() + x, a.y() + y);
} }
QRect SlideTabsEffect::calculateNextMove() QRect SlideTabsEffect::calculateNextMove()
{ {
QPoint topLeft, bottomRight; QPoint topLeft, bottomRight;
int mw = source.width(), mh = source.height(), tw = target.width(), th = target.height(); int mw = source.width(), mh = source.height(), tw = target.width(), th = target.height();
topLeft = calculatePointTarget( QPoint( source.x(), source.y() ), QPoint( target.x(), target.y() ) ); topLeft = calculatePointTarget(QPoint(source.x(), source.y()), QPoint(target.x(), target.y()));
bottomRight = calculatePointTarget( QPoint( source.x() + mw, source.y() + mh ), QPoint( target.x() + tw, target.y() + th ) ); bottomRight = calculatePointTarget(QPoint(source.x() + mw, source.y() + mh), QPoint(target.x() + tw, target.y() + th));
return QRect( topLeft.x(), topLeft.y(), bottomRight.x() - topLeft.x(), bottomRight.y() - topLeft.y() ); return QRect(topLeft.x(), topLeft.y(), bottomRight.x() - topLeft.x(), bottomRight.y() - topLeft.y());
} }
} }

View File

@ -27,29 +27,29 @@ namespace KWin
{ {
class SlideTabsEffect : public Effect class SlideTabsEffect : public Effect
{ {
public: public:
SlideTabsEffect(); SlideTabsEffect();
virtual void reconfigure( ReconfigureFlags ); virtual void reconfigure(ReconfigureFlags);
virtual void prePaintWindow( EffectWindow *w, WindowPrePaintData &data, int time ); virtual void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time);
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
virtual void postPaintWindow( EffectWindow* w ); virtual void postPaintWindow(EffectWindow* w);
virtual void prePaintScreen( ScreenPrePaintData &data, int time ); virtual void prePaintScreen(ScreenPrePaintData &data, int time);
virtual void postPaintScreen(); virtual void postPaintScreen();
virtual void clientGroupItemSwitched( EffectWindow* from, EffectWindow* to ); virtual void clientGroupItemSwitched(EffectWindow* from, EffectWindow* to);
virtual void clientGroupItemAdded( EffectWindow* from, EffectWindow* to ); virtual void clientGroupItemAdded(EffectWindow* from, EffectWindow* to);
private: private:
QRect calculateNextMove(); QRect calculateNextMove();
QPoint calculatePointTarget( const QPoint &a, const QPoint &b ); QPoint calculatePointTarget(const QPoint &a, const QPoint &b);
WindowMotionManager motionManager; WindowMotionManager motionManager;
EffectWindow* inMove; EffectWindow* inMove;
EffectWindow* notMoving; EffectWindow* notMoving;
TimeLine timeLine; TimeLine timeLine;
QRect target, source; QRect target, source;
bool direction, wasD, grouping, switching; bool direction, wasD, grouping, switching;
int totalTime, distance; int totalTime, distance;
}; };
} }

View File

@ -32,63 +32,63 @@ namespace KWin
KWIN_EFFECT_CONFIG_FACTORY KWIN_EFFECT_CONFIG_FACTORY
SlideTabsEffectConfigForm::SlideTabsEffectConfigForm( QWidget* parent ) : QWidget( parent ) SlideTabsEffectConfigForm::SlideTabsEffectConfigForm(QWidget* parent) : QWidget(parent)
{ {
setupUi( this ); setupUi(this);
} }
SlideTabsEffectConfig::SlideTabsEffectConfig(QWidget* parent, const QVariantList& args) SlideTabsEffectConfig::SlideTabsEffectConfig(QWidget* parent, const QVariantList& args)
: KCModule( EffectFactory::componentData(), parent, args ) : KCModule(EffectFactory::componentData(), parent, args)
{ {
m_ui = new SlideTabsEffectConfigForm( this ); m_ui = new SlideTabsEffectConfigForm(this);
QVBoxLayout* layout = new QVBoxLayout( this ); QVBoxLayout* layout = new QVBoxLayout(this);
layout->addWidget( m_ui ); layout->addWidget(m_ui);
connect( m_ui->grouping, SIGNAL( toggled( bool )), this, SLOT( changed() ) ); connect(m_ui->grouping, SIGNAL(toggled(bool)), this, SLOT(changed()));
connect( m_ui->switching, SIGNAL( toggled( bool )), this, SLOT( changed() ) ); connect(m_ui->switching, SIGNAL(toggled(bool)), this, SLOT(changed()));
connect( m_ui->duration, SIGNAL( valueChanged( int ) ), this, SLOT( changed() ) ); connect(m_ui->duration, SIGNAL(valueChanged(int)), this, SLOT(changed()));
load(); load();
} }
void SlideTabsEffectConfig::save() void SlideTabsEffectConfig::save()
{ {
KConfigGroup conf = EffectsHandler::effectConfig( "SlideTabs" ); KConfigGroup conf = EffectsHandler::effectConfig("SlideTabs");
conf.writeEntry( "SlideGrouping", m_ui->grouping->isChecked() ); conf.writeEntry("SlideGrouping", m_ui->grouping->isChecked());
conf.writeEntry( "SlideSwitching", m_ui->switching->isChecked() ); conf.writeEntry("SlideSwitching", m_ui->switching->isChecked());
conf.writeEntry( "SlideDuration", m_ui->duration->value() ); conf.writeEntry("SlideDuration", m_ui->duration->value());
conf.sync(); conf.sync();
KCModule::save(); KCModule::save();
emit changed( false ); emit changed(false);
EffectsHandler::sendReloadMessage( "slidetabs" ); EffectsHandler::sendReloadMessage("slidetabs");
} }
void SlideTabsEffectConfig::load() void SlideTabsEffectConfig::load()
{ {
KCModule::load(); KCModule::load();
KConfigGroup conf = EffectsHandler::effectConfig( "SlideTabs" ); KConfigGroup conf = EffectsHandler::effectConfig("SlideTabs");
bool switching = conf.readEntry( "SlideSwitching", true ); bool switching = conf.readEntry("SlideSwitching", true);
bool grouping = conf.readEntry( "SlideGrouping", true ); bool grouping = conf.readEntry("SlideGrouping", true);
int duration = conf.readEntry("SlideDuration", 500 ); int duration = conf.readEntry("SlideDuration", 500);
m_ui->switching->setChecked( switching ); m_ui->switching->setChecked(switching);
m_ui->grouping->setChecked( grouping ); m_ui->grouping->setChecked(grouping);
m_ui->duration->setValue( duration ); m_ui->duration->setValue(duration);
emit changed( false ); emit changed(false);
} }
void SlideTabsEffectConfig::defaults() void SlideTabsEffectConfig::defaults()
{ {
m_ui->grouping->setChecked( true ); m_ui->grouping->setChecked(true);
m_ui->switching->setChecked( true ); m_ui->switching->setChecked(true);
m_ui->duration->setValue( 500 ); m_ui->duration->setValue(500);
emit changed( true ); emit changed(true);
} }
} }

View File

@ -29,24 +29,24 @@ namespace KWin
{ {
class SlideTabsEffectConfigForm : public QWidget, public Ui::SlideTabsEffectConfigForm class SlideTabsEffectConfigForm : public QWidget, public Ui::SlideTabsEffectConfigForm
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit SlideTabsEffectConfigForm( QWidget* parent ); explicit SlideTabsEffectConfigForm(QWidget* parent);
}; };
class SlideTabsEffectConfig : public KCModule class SlideTabsEffectConfig : public KCModule
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit SlideTabsEffectConfig( QWidget* parent = 0, const QVariantList& args = QVariantList() ); explicit SlideTabsEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
public slots: public slots:
virtual void save(); virtual void save();
virtual void load(); virtual void load();
virtual void defaults(); virtual void defaults();
private: private:
SlideTabsEffectConfigForm* m_ui; SlideTabsEffectConfigForm* m_ui;
}; };
} }

View File

@ -24,134 +24,123 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
namespace KWin namespace KWin
{ {
KWIN_EFFECT( swiveltabs, SwivelTabsEffect ) KWIN_EFFECT(swiveltabs, SwivelTabsEffect)
KWIN_EFFECT_SUPPORTED( swiveltabs, SwivelTabsEffect::supported() ) KWIN_EFFECT_SUPPORTED(swiveltabs, SwivelTabsEffect::supported())
SwivelTabsEffect::SwivelTabsEffect() SwivelTabsEffect::SwivelTabsEffect()
{ {
isActive = false; isActive = false;
PI = 2.0 * acos( 0.0 ); PI = 2.0 * acos(0.0);
reconfigure( ReconfigureAll ); reconfigure(ReconfigureAll);
} }
bool SwivelTabsEffect::supported() bool SwivelTabsEffect::supported()
{ {
return effects->compositingType() == OpenGLCompositing; return effects->compositingType() == OpenGLCompositing;
} }
void SwivelTabsEffect::reconfigure( ReconfigureFlags ) void SwivelTabsEffect::reconfigure(ReconfigureFlags)
{ {
KConfigGroup conf = EffectsHandler::effectConfig("SwivelTabs"); KConfigGroup conf = EffectsHandler::effectConfig("SwivelTabs");
vertical = conf.readEntry("SwivelVertical", true ); vertical = conf.readEntry("SwivelVertical", true);
horizontal = conf.readEntry("SwivelHorizontal", true ); horizontal = conf.readEntry("SwivelHorizontal", true);
totalTime = conf.readEntry("SwivelDuration", 500 ); totalTime = conf.readEntry("SwivelDuration", 500);
} }
void SwivelTabsEffect::prePaintScreen( ScreenPrePaintData& data, int time ) void SwivelTabsEffect::prePaintScreen(ScreenPrePaintData& data, int time)
{ {
if( isActive ) if (isActive)
data.mask |= Effect::PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS; data.mask |= Effect::PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
effects->prePaintScreen( data, time ); effects->prePaintScreen(data, time);
} }
void SwivelTabsEffect::prePaintWindow( EffectWindow *w, WindowPrePaintData &data, int time ) void SwivelTabsEffect::prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time)
{ {
if( isActive && ( w == windows.show || w == windows.hide ) ) if (isActive && (w == windows.show || w == windows.hide)) {
{ data.quads = data.quads.makeGrid(40);
data.quads = data.quads.makeGrid( 40 );
data.setTransformed(); data.setTransformed();
w->enablePainting( EffectWindow::PAINT_DISABLED ); w->enablePainting(EffectWindow::PAINT_DISABLED);
windows.time.addTime( time ); windows.time.addTime(time);
}
effects->prePaintWindow( w, data, time );
} }
effects->prePaintWindow(w, data, time);
}
void SwivelTabsEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ) void SwivelTabsEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{ {
if( isActive && ( w == windows.show || w == windows.hide ) ) if (isActive && (w == windows.show || w == windows.hide)) {
{ for (int i = 0; i < data.quads.count(); ++i)
for( int i = 0; i < data.quads.count(); ++i ) transformQuad(data.quads[i]);
transformQuad( data.quads[i] );
}
effects->paintWindow( w, mask, region, data );
} }
effects->paintWindow(w, mask, region, data);
}
void SwivelTabsEffect::postPaintWindow( EffectWindow* w ) void SwivelTabsEffect::postPaintWindow(EffectWindow* w)
{ {
if( isActive && ( w == windows.show || w == windows.hide ) ) if (isActive && (w == windows.show || w == windows.hide))
w->addRepaintFull(); w->addRepaintFull();
effects->postPaintWindow( w ); effects->postPaintWindow(w);
} }
void SwivelTabsEffect::transformQuad( WindowQuad &quad ) void SwivelTabsEffect::transformQuad(WindowQuad &quad)
{ {
double F = windows.time.progress(); double F = windows.time.progress();
int width = quad[1].x()-quad[0].x(); int width = quad[1].x() - quad[0].x();
int height = quad[3].y() - quad[0].y(); int height = quad[3].y() - quad[0].y();
int cx = quad[0].x() + ( width/2 ); int cx = quad[0].x() + (width / 2);
int cy = quad[0].y() + ( height/2 ); int cy = quad[0].y() + (height / 2);
if( lastF < 0.5 && F > 0.5 ) if (lastF < 0.5 && F > 0.5) {
{ effects->setElevatedWindow(windows.hide, false);
effects->setElevatedWindow( windows.hide, false ); effects->setElevatedWindow(windows.show, true);
effects->setElevatedWindow( windows.show, true ); }
}
lastF = F; lastF = F;
if( F >= 1.0 ) if (F >= 1.0) {
{
isActive = false; isActive = false;
effects->setElevatedWindow( windows.hide, false ); effects->setElevatedWindow(windows.hide, false);
effects->setElevatedWindow( windows.show, false ); effects->setElevatedWindow(windows.show, false);
}
if (F < 0.5) {
if (horizontal) {
quad[0].setX(quad[0].x() + (width * F));
quad[3].setX(quad[3].x() + (width * F));
quad[1].setX(quad[1].x() - (width * F));
quad[2].setX(quad[2].x() - (width * F));
} }
if( F < 0.5 ) if (vertical) {
{ quad[0].setY(quad[0].y() + (height * F));
if( horizontal ) quad[3].setY(quad[3].y() - (height * F));
{ quad[1].setY(quad[1].y() + (height * F));
quad[0].setX( quad[0].x() + ( width * F ) ); quad[2].setY(quad[2].y() - (height * F));
quad[3].setX( quad[3].x() + ( width * F ) );
quad[1].setX( quad[1].x() - ( width * F ) );
quad[2].setX( quad[2].x() - ( width * F ) );
}
if( vertical )
{
quad[0].setY( quad[0].y() + ( height * F ) );
quad[3].setY( quad[3].y() - ( height * F ) );
quad[1].setY( quad[1].y() + ( height * F ) );
quad[2].setY( quad[2].y() - ( height * F ) );
}
} }
else } else {
{
F -= 0.5; F -= 0.5;
if( horizontal ) if (horizontal) {
{ quad[0].setX(cx - (width * F));
quad[0].setX( cx - ( width * F ) ); quad[3].setX(cx - (width * F));
quad[3].setX( cx - ( width * F ) ); quad[1].setX(cx + (width * F));
quad[1].setX( cx + ( width * F ) ); quad[2].setX(cx + (width * F));
quad[2].setX( cx + ( width * F ) ); }
} if (vertical) {
if( vertical ) quad[0].setY(cy - (height * F));
{ quad[3].setY(cy + (height * F));
quad[0].setY( cy - ( height * F ) ); quad[1].setY(cy - (height * F));
quad[3].setY( cy + ( height * F ) ); quad[2].setY(cy + (height * F));
quad[1].setY( cy - ( height * F ) );
quad[2].setY( cy + ( height * F ) );
}
} }
} }
}
void SwivelTabsEffect::clientGroupItemSwitched( EffectWindow* from, EffectWindow* to ) void SwivelTabsEffect::clientGroupItemSwitched(EffectWindow* from, EffectWindow* to)
{ {
if( isActive || from->isMinimized() ) if (isActive || from->isMinimized())
return; return;
windows.show = to; windows.show = to;
windows.hide = from; windows.hide = from;
windows.time.setCurveShape( TimeLine::LinearCurve ); windows.time.setCurveShape(TimeLine::LinearCurve);
windows.time.setDuration( animationTime( totalTime ) ); windows.time.setDuration(animationTime(totalTime));
windows.time.setProgress( 0.0f ); windows.time.setProgress(0.0f);
lastF = 0.0; lastF = 0.0;
isActive = true; isActive = true;
effects->setElevatedWindow( to, false ); effects->setElevatedWindow(to, false);
effects->setElevatedWindow( from, true ); effects->setElevatedWindow(from, true);
} }
} }

View File

@ -27,35 +27,34 @@ namespace KWin
{ {
class SwivelTabsEffect : public Effect class SwivelTabsEffect : public Effect
{ {
public: public:
SwivelTabsEffect(); SwivelTabsEffect();
virtual void reconfigure( ReconfigureFlags ); virtual void reconfigure(ReconfigureFlags);
virtual void prePaintScreen( ScreenPrePaintData& data, int time ); virtual void prePaintScreen(ScreenPrePaintData& data, int time);
virtual void prePaintWindow( EffectWindow *w, WindowPrePaintData &data, int time ); virtual void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time);
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
virtual void postPaintWindow( EffectWindow* w ); virtual void postPaintWindow(EffectWindow* w);
virtual void clientGroupItemSwitched( EffectWindow* from, EffectWindow* to ); virtual void clientGroupItemSwitched(EffectWindow* from, EffectWindow* to);
static bool supported(); static bool supported();
private: private:
struct swivel struct swivel {
{ EffectWindow* hide;
EffectWindow* hide; EffectWindow* show;
EffectWindow* show; TimeLine time;
TimeLine time; // The points of the transformed window
// The points of the transformed window QPoint topLeft, topRight, bottomLeft, bottomRight;
QPoint topLeft, topRight, bottomLeft, bottomRight; // The size of the transformed window
// The size of the transformed window double left, top, right, bottom;
double left, top, right, bottom;
};
swivel windows;
bool isActive, horizontal, vertical;
int totalTime, kal;
double PI, lastF;
void nextStep( EffectWindow *w );
void transformQuad( WindowQuad &quad );
double calculateCoords( double original, double space, double newSpace );
}; };
swivel windows;
bool isActive, horizontal, vertical;
int totalTime, kal;
double PI, lastF;
void nextStep(EffectWindow *w);
void transformQuad(WindowQuad &quad);
double calculateCoords(double original, double space, double newSpace);
};
} }

View File

@ -29,63 +29,63 @@ namespace KWin
KWIN_EFFECT_CONFIG_FACTORY KWIN_EFFECT_CONFIG_FACTORY
SwivelTabsEffectConfigForm::SwivelTabsEffectConfigForm( QWidget* parent ) : QWidget( parent ) SwivelTabsEffectConfigForm::SwivelTabsEffectConfigForm(QWidget* parent) : QWidget(parent)
{ {
setupUi( this ); setupUi(this);
} }
SwivelTabsEffectConfig::SwivelTabsEffectConfig(QWidget* parent, const QVariantList& args) SwivelTabsEffectConfig::SwivelTabsEffectConfig(QWidget* parent, const QVariantList& args)
: KCModule( EffectFactory::componentData(), parent, args ) : KCModule(EffectFactory::componentData(), parent, args)
{ {
m_ui = new SwivelTabsEffectConfigForm( this ); m_ui = new SwivelTabsEffectConfigForm(this);
QVBoxLayout* layout = new QVBoxLayout( this ); QVBoxLayout* layout = new QVBoxLayout(this);
layout->addWidget( m_ui ); layout->addWidget(m_ui);
connect( m_ui->vertical, SIGNAL( toggled( bool )), this, SLOT( changed() ) ); connect(m_ui->vertical, SIGNAL(toggled(bool)), this, SLOT(changed()));
connect( m_ui->horizontal, SIGNAL( toggled( bool )), this, SLOT( changed() ) ); connect(m_ui->horizontal, SIGNAL(toggled(bool)), this, SLOT(changed()));
connect( m_ui->duration, SIGNAL( valueChanged( int ) ), this, SLOT( changed() ) ); connect(m_ui->duration, SIGNAL(valueChanged(int)), this, SLOT(changed()));
load(); load();
} }
SwivelTabsEffectConfig::~SwivelTabsEffectConfig() SwivelTabsEffectConfig::~SwivelTabsEffectConfig()
{ {
delete m_ui; delete m_ui;
} }
void SwivelTabsEffectConfig::save() void SwivelTabsEffectConfig::save()
{ {
KConfigGroup conf = EffectsHandler::effectConfig( "SwivelTabs" ); KConfigGroup conf = EffectsHandler::effectConfig("SwivelTabs");
conf.writeEntry( "SwivelVertical", m_ui->vertical->isChecked() ); conf.writeEntry("SwivelVertical", m_ui->vertical->isChecked());
conf.writeEntry( "SwivelHorizontal", m_ui->horizontal->isChecked() ); conf.writeEntry("SwivelHorizontal", m_ui->horizontal->isChecked());
conf.writeEntry( "SwivelDuration", m_ui->duration->value() ); conf.writeEntry("SwivelDuration", m_ui->duration->value());
conf.sync(); conf.sync();
KCModule::save(); KCModule::save();
emit changed( false ); emit changed(false);
EffectsHandler::sendReloadMessage( "swiveltabs" ); EffectsHandler::sendReloadMessage("swiveltabs");
} }
void SwivelTabsEffectConfig::load() void SwivelTabsEffectConfig::load()
{ {
KCModule::load(); KCModule::load();
KConfigGroup conf = EffectsHandler::effectConfig( "SwivelTabs" ); KConfigGroup conf = EffectsHandler::effectConfig("SwivelTabs");
bool vertical = conf.readEntry( "SwivelVertical", true ); bool vertical = conf.readEntry("SwivelVertical", true);
bool horizontal = conf.readEntry( "SwivelHorizontal", true ); bool horizontal = conf.readEntry("SwivelHorizontal", true);
int duration = conf.readEntry("SwivelDuration", 500 ); int duration = conf.readEntry("SwivelDuration", 500);
m_ui->vertical->setChecked( vertical ); m_ui->vertical->setChecked(vertical);
m_ui->horizontal->setChecked( horizontal ); m_ui->horizontal->setChecked(horizontal);
m_ui->duration->setValue( duration ); m_ui->duration->setValue(duration);
emit changed( false ); emit changed(false);
} }
void SwivelTabsEffectConfig::defaults() void SwivelTabsEffectConfig::defaults()
{ {
m_ui->vertical->setChecked( true ); m_ui->vertical->setChecked(true);
m_ui->horizontal->setChecked( true ); m_ui->horizontal->setChecked(true);
m_ui->duration->setValue( 500 ); m_ui->duration->setValue(500);
emit changed( true ); emit changed(true);
} }
} }

View File

@ -28,25 +28,25 @@ namespace KWin
{ {
class SwivelTabsEffectConfigForm : public QWidget, public Ui::SwivelTabsEffectConfigForm class SwivelTabsEffectConfigForm : public QWidget, public Ui::SwivelTabsEffectConfigForm
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit SwivelTabsEffectConfigForm( QWidget* parent ); explicit SwivelTabsEffectConfigForm(QWidget* parent);
}; };
class SwivelTabsEffectConfig : public KCModule class SwivelTabsEffectConfig : public KCModule
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit SwivelTabsEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList()); explicit SwivelTabsEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
~SwivelTabsEffectConfig(); ~SwivelTabsEffectConfig();
public slots: public slots:
virtual void save(); virtual void save();
virtual void load(); virtual void load();
virtual void defaults(); virtual void defaults();
private: private:
SwivelTabsEffectConfigForm *m_ui; SwivelTabsEffectConfigForm *m_ui;
}; };
} }

View File

@ -27,12 +27,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
namespace KWin namespace KWin
{ {
KWIN_EFFECT( test_fbo, TestFBOEffect ) KWIN_EFFECT(test_fbo, TestFBOEffect)
KWIN_EFFECT_SUPPORTED( test_fbo, TestFBOEffect::supported() ) KWIN_EFFECT_SUPPORTED(test_fbo, TestFBOEffect::supported())
TestFBOEffect::TestFBOEffect() : Effect() TestFBOEffect::TestFBOEffect() : Effect()
{ {
mRot = 0.0f; mRot = 0.0f;
// Create texture and render target // Create texture and render target
@ -42,66 +42,64 @@ TestFBOEffect::TestFBOEffect() : Effect()
mRenderTarget = new GLRenderTarget(mTexture); mRenderTarget = new GLRenderTarget(mTexture);
mValid = mRenderTarget->valid(); mValid = mRenderTarget->valid();
} }
TestFBOEffect::~TestFBOEffect() TestFBOEffect::~TestFBOEffect()
{ {
delete mTexture; delete mTexture;
delete mRenderTarget; delete mRenderTarget;
} }
bool TestFBOEffect::supported() bool TestFBOEffect::supported()
{ {
return GLRenderTarget::supported() && GLTexture::NPOTTextureSupported() && return GLRenderTarget::supported() && GLTexture::NPOTTextureSupported() &&
(effects->compositingType() == OpenGLCompositing); (effects->compositingType() == OpenGLCompositing);
} }
void TestFBOEffect::prePaintScreen( ScreenPrePaintData& data, int time ) void TestFBOEffect::prePaintScreen(ScreenPrePaintData& data, int time)
{ {
if(mValid) if (mValid) {
{
data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS; data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
// Start rendering to texture // Start rendering to texture
effects->pushRenderTarget(mRenderTarget); effects->pushRenderTarget(mRenderTarget);
}
effects->prePaintScreen(data, time);
} }
effects->prePaintScreen(data, time);
}
void TestFBOEffect::postPaintScreen() void TestFBOEffect::postPaintScreen()
{ {
// Call the next effect. // Call the next effect.
effects->postPaintScreen(); effects->postPaintScreen();
if(mValid) if (mValid) {
{
// Disable render texture // Disable render texture
assert( effects->popRenderTarget() == mRenderTarget ); assert(effects->popRenderTarget() == mRenderTarget);
mTexture->bind(); mTexture->bind();
// Render fullscreen quad with screen contents // Render fullscreen quad with screen contents
glBegin(GL_QUADS); glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0); glVertex2f(0.0, displayHeight()); glTexCoord2f(0.0, 0.0); glVertex2f(0.0, displayHeight());
glTexCoord2f(1.0, 0.0); glVertex2f(displayWidth(), displayHeight()); glTexCoord2f(1.0, 0.0); glVertex2f(displayWidth(), displayHeight());
glTexCoord2f(1.0, 1.0); glVertex2f(displayWidth(), 0.0); glTexCoord2f(1.0, 1.0); glVertex2f(displayWidth(), 0.0);
glTexCoord2f(0.0, 1.0); glVertex2f(0.0, 0.0); glTexCoord2f(0.0, 1.0); glVertex2f(0.0, 0.0);
glEnd(); glEnd();
// Render rotated screen thumbnail // Render rotated screen thumbnail
mRot += 0.5f; mRot += 0.5f;
glTranslatef(displayWidth()/2.0f, displayHeight()/2.0f, 0.0f); glTranslatef(displayWidth() / 2.0f, displayHeight() / 2.0f, 0.0f);
glRotatef(mRot, 0.0, 0.0, 1.0); glRotatef(mRot, 0.0, 0.0, 1.0);
glScalef(0.2, 0.2, 0.2); glScalef(0.2, 0.2, 0.2);
glTranslatef(-displayWidth()/2.0f, -displayHeight()/2.0f, 0.0f); glTranslatef(-displayWidth() / 2.0f, -displayHeight() / 2.0f, 0.0f);
glEnable(GL_BLEND); glEnable(GL_BLEND);
glColor4f(1.0, 1.0, 1.0, 0.8); glColor4f(1.0, 1.0, 1.0, 0.8);
glBegin(GL_QUADS); glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0); glVertex2f(0.0, displayHeight()); glTexCoord2f(0.0, 0.0); glVertex2f(0.0, displayHeight());
glTexCoord2f(1.0, 0.0); glVertex2f(displayWidth(), displayHeight()); glTexCoord2f(1.0, 0.0); glVertex2f(displayWidth(), displayHeight());
glTexCoord2f(1.0, 1.0); glVertex2f(displayWidth(), 0.0); glTexCoord2f(1.0, 1.0); glVertex2f(displayWidth(), 0.0);
glTexCoord2f(0.0, 1.0); glVertex2f(0.0, 0.0); glTexCoord2f(0.0, 1.0); glVertex2f(0.0, 0.0);
glEnd(); glEnd();
glColor4f(1.0, 1.0, 1.0, 1.0); glColor4f(1.0, 1.0, 1.0, 1.0);
glDisable(GL_BLEND); glDisable(GL_BLEND);
@ -113,10 +111,10 @@ void TestFBOEffect::postPaintScreen()
// Make sure the animation continues // Make sure the animation continues
effects->addRepaintFull(); effects->addRepaintFull();
}
} }
}
} // namespace } // namespace

View File

@ -36,23 +36,23 @@ class GLTexture;
* on top of the usual scene. * on top of the usual scene.
**/ **/
class TestFBOEffect : public Effect class TestFBOEffect : public Effect
{ {
public: public:
TestFBOEffect(); TestFBOEffect();
~TestFBOEffect(); ~TestFBOEffect();
virtual void prePaintScreen( ScreenPrePaintData& data, int time ); virtual void prePaintScreen(ScreenPrePaintData& data, int time);
virtual void postPaintScreen(); virtual void postPaintScreen();
static bool supported(); static bool supported();
private: private:
GLTexture* mTexture; GLTexture* mTexture;
GLRenderTarget* mRenderTarget; GLRenderTarget* mRenderTarget;
bool mValid; bool mValid;
double mRot; double mRot;
}; };
} // namespace } // namespace

View File

@ -29,46 +29,44 @@ License. See the file "COPYING" for the exact licensing terms.
namespace KWin namespace KWin
{ {
KWIN_EFFECT( test_input, TestInputEffect ) KWIN_EFFECT(test_input, TestInputEffect)
TestInputEffect::TestInputEffect() TestInputEffect::TestInputEffect()
{ {
input = effects->createInputWindow( this, 0, 0, displayWidth(), displayHeight(), Qt::CrossCursor ); input = effects->createInputWindow(this, 0, 0, displayWidth(), displayHeight(), Qt::CrossCursor);
} }
TestInputEffect::~TestInputEffect() TestInputEffect::~TestInputEffect()
{ {
effects->destroyInputWindow( input ); effects->destroyInputWindow(input);
} }
void TestInputEffect::prePaintScreen( ScreenPrePaintData& data, int time ) void TestInputEffect::prePaintScreen(ScreenPrePaintData& data, int time)
{ {
data.mask |= PAINT_SCREEN_TRANSFORMED; data.mask |= PAINT_SCREEN_TRANSFORMED;
effects->prePaintScreen( data, time ); effects->prePaintScreen(data, time);
} }
void TestInputEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data ) void TestInputEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
{ {
data.yTranslate += 100; data.yTranslate += 100;
effects->paintScreen( mask, region, data ); effects->paintScreen(mask, region, data);
} }
void TestInputEffect::windowInputMouseEvent( Window w, QEvent* e ) void TestInputEffect::windowInputMouseEvent(Window w, QEvent* e)
{ {
assert( w == input ); assert(w == input);
if( e->type() != QEvent::MouseButtonPress ) if (e->type() != QEvent::MouseButtonPress)
return; return;
QPoint pos = static_cast< QMouseEvent* >( e )->pos(); QPoint pos = static_cast< QMouseEvent* >(e)->pos();
pos -= QPoint( 0, 100 ); // adjust for transformation pos -= QPoint(0, 100); // adjust for transformation
foreach( EffectWindow* c, effects->stackingOrder()) foreach (EffectWindow * c, effects->stackingOrder()) {
{ if (/* TODO c->isShown( true ) && */c->isOnCurrentDesktop()
if( /* TODO c->isShown( true ) && */c->isOnCurrentDesktop() && c->geometry().contains(pos)) {
&& c->geometry().contains( pos )) effects->activateWindow(c);
{
effects->activateWindow( c );
return; return;
}
} }
} }
}
} // namespace } // namespace

View File

@ -24,16 +24,16 @@ namespace KWin
class TestInputEffect class TestInputEffect
: public Effect : public Effect
{ {
public: public:
TestInputEffect(); TestInputEffect();
virtual ~TestInputEffect(); virtual ~TestInputEffect();
virtual void prePaintScreen( ScreenPrePaintData& data, int time ); virtual void prePaintScreen(ScreenPrePaintData& data, int time);
virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data ); virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data);
virtual void windowInputMouseEvent( Window w, QEvent* e ); virtual void windowInputMouseEvent(Window w, QEvent* e);
private: private:
Window input; Window input;
}; };
} // namespace } // namespace

View File

@ -20,58 +20,56 @@ License. See the file "COPYING" for the exact licensing terms.
namespace KWin namespace KWin
{ {
KWIN_EFFECT( test_thumbnail, TestThumbnailEffect ) KWIN_EFFECT(test_thumbnail, TestThumbnailEffect)
TestThumbnailEffect::TestThumbnailEffect() TestThumbnailEffect::TestThumbnailEffect()
: active_window( NULL ) : active_window(NULL)
{ {
} }
void TestThumbnailEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data ) void TestThumbnailEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
{ {
effects->paintScreen( mask, region, data ); effects->paintScreen(mask, region, data);
if( active_window != NULL && region.contains( thumbnailRect())) if (active_window != NULL && region.contains(thumbnailRect())) {
{ WindowPaintData data(active_window);
WindowPaintData data( active_window );
QRect region; QRect region;
setPositionTransformations( data, region, active_window, thumbnailRect(), Qt::KeepAspectRatio ); setPositionTransformations(data, region, active_window, thumbnailRect(), Qt::KeepAspectRatio);
effects->drawWindow( active_window, effects->drawWindow(active_window,
PAINT_WINDOW_OPAQUE | PAINT_WINDOW_TRANSLUCENT | PAINT_WINDOW_TRANSFORMED, PAINT_WINDOW_OPAQUE | PAINT_WINDOW_TRANSLUCENT | PAINT_WINDOW_TRANSFORMED,
region, data ); region, data);
}
} }
}
void TestThumbnailEffect::windowActivated( EffectWindow* act ) void TestThumbnailEffect::windowActivated(EffectWindow* act)
{ {
active_window = act; active_window = act;
effects->addRepaint( thumbnailRect()); effects->addRepaint(thumbnailRect());
} }
void TestThumbnailEffect::windowDamaged( EffectWindow* w, const QRect& ) void TestThumbnailEffect::windowDamaged(EffectWindow* w, const QRect&)
{ {
if( w == active_window ) if (w == active_window)
effects->addRepaint( thumbnailRect()); effects->addRepaint(thumbnailRect());
// TODO maybe just the relevant part of the area should be repainted? // TODO maybe just the relevant part of the area should be repainted?
} }
void TestThumbnailEffect::windowGeometryShapeChanged( EffectWindow* w, const QRect& old ) void TestThumbnailEffect::windowGeometryShapeChanged(EffectWindow* w, const QRect& old)
{ {
if( w == active_window && w->size() != old.size()) if (w == active_window && w->size() != old.size())
effects->addRepaint( thumbnailRect()); effects->addRepaint(thumbnailRect());
} }
void TestThumbnailEffect::windowClosed( EffectWindow* w ) void TestThumbnailEffect::windowClosed(EffectWindow* w)
{ {
if( w == active_window ) if (w == active_window) {
{
active_window = NULL; active_window = NULL;
effects->addRepaint( thumbnailRect()); effects->addRepaint(thumbnailRect());
}
} }
}
QRect TestThumbnailEffect::thumbnailRect() const QRect TestThumbnailEffect::thumbnailRect() const
{ {
return QRect( displayWidth() - 100, displayHeight() - 100, 100, 100 ); return QRect(displayWidth() - 100, displayHeight() - 100, 100, 100);
} }
} // namespace } // namespace

View File

@ -24,18 +24,18 @@ namespace KWin
class TestThumbnailEffect class TestThumbnailEffect
: public Effect : public Effect
{ {
public: public:
TestThumbnailEffect(); TestThumbnailEffect();
virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data ); virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data);
virtual void windowActivated( EffectWindow* w ); virtual void windowActivated(EffectWindow* w);
virtual void windowDamaged( EffectWindow* w, const QRect& damage ); virtual void windowDamaged(EffectWindow* w, const QRect& damage);
virtual void windowGeometryShapeChanged( EffectWindow* w, const QRect& old ); virtual void windowGeometryShapeChanged(EffectWindow* w, const QRect& old);
virtual void windowClosed( EffectWindow* w ); virtual void windowClosed(EffectWindow* w);
private: private:
QRect thumbnailRect() const; QRect thumbnailRect() const;
EffectWindow* active_window; EffectWindow* active_window;
}; };
} // namespace } // namespace

View File

@ -59,59 +59,56 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
namespace KWin namespace KWin
{ {
KWIN_EFFECT( videorecord, VideoRecordEffect ) KWIN_EFFECT(videorecord, VideoRecordEffect)
VideoRecordEffect::VideoRecordEffect() VideoRecordEffect::VideoRecordEffect()
: client( NULL ) : client(NULL)
{ {
KActionCollection* actionCollection = new KActionCollection( this ); KActionCollection* actionCollection = new KActionCollection(this);
KAction* a = static_cast< KAction* >( actionCollection->addAction( "VideoRecord" )); KAction* a = static_cast< KAction* >(actionCollection->addAction("VideoRecord"));
a->setText( i18n("Toggle Video Recording" )); a->setText(i18n("Toggle Video Recording"));
a->setGlobalShortcut( KShortcut( Qt::CTRL + Qt::META + Qt::Key_V )); a->setGlobalShortcut(KShortcut(Qt::CTRL + Qt::META + Qt::Key_V));
connect( a, SIGNAL( triggered( bool )), this, SLOT( toggleRecording())); connect(a, SIGNAL(triggered(bool)), this, SLOT(toggleRecording()));
area = QRect( 0, 0, displayWidth(), displayHeight()); area = QRect(0, 0, displayWidth(), displayHeight());
} }
VideoRecordEffect::~VideoRecordEffect() VideoRecordEffect::~VideoRecordEffect()
{ {
stopRecording(); stopRecording();
} }
void VideoRecordEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data ) void VideoRecordEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
{ {
effects->paintScreen( mask, region, data ); effects->paintScreen(mask, region, data);
if( client != NULL ) if (client != NULL)
capture_region = ( mask & ( PAINT_WINDOW_TRANSFORMED | PAINT_SCREEN_TRANSFORMED )) capture_region = (mask & (PAINT_WINDOW_TRANSFORMED | PAINT_SCREEN_TRANSFORMED))
? QRect( 0, 0, displayWidth(), displayHeight()) : region; ? QRect(0, 0, displayWidth(), displayHeight()) : region;
} }
void VideoRecordEffect::postPaintScreen() void VideoRecordEffect::postPaintScreen()
{ {
effects->postPaintScreen(); effects->postPaintScreen();
if( client != NULL ) if (client != NULL) {
{
#if 1 #if 1
if( CapturyProcessRegionStart( client ) == CAPTURY_SUCCESS ) if (CapturyProcessRegionStart(client) == CAPTURY_SUCCESS) {
{ capture_region &= QRect(0, 0, displayWidth(), displayHeight()); // limit to screen
capture_region &= QRect( 0, 0, displayWidth(), displayHeight()); // limit to screen foreach (const QRect & r, capture_region.rects()) {
foreach( const QRect &r, capture_region.rects())
{
int gly = displayHeight() - r.y() - r.height(); // opengl coords int gly = displayHeight() - r.y() - r.height(); // opengl coords
CapturyProcessRegion( client, r.x(), gly, r.width(), r.height()); CapturyProcessRegion(client, r.x(), gly, r.width(), r.height());
}
CapturyProcessRegionCommit( client );
} }
#else CapturyProcessRegionCommit(client);
CapturyProcessFrame( client );
#endif
} }
#else
CapturyProcessFrame(client);
#endif
} }
}
void VideoRecordEffect::startRecording() void VideoRecordEffect::startRecording()
{ {
if( client != NULL ) if (client != NULL)
stopRecording(); stopRecording();
bzero( &config, sizeof( config )); bzero(&config, sizeof(config));
config.x = area.x(); config.x = area.x();
config.y = area.y(); config.y = area.y();
config.width = area.width(); config.width = area.width();
@ -122,58 +119,56 @@ void VideoRecordEffect::startRecording()
config.deviceHandle = display(); config.deviceHandle = display();
config.windowHandle = rootWindow(); // TODO config.windowHandle = rootWindow(); // TODO
config.cursor = true; config.cursor = true;
client = CapturyOpen( &config ); client = CapturyOpen(&config);
if( client == NULL ) if (client == NULL) {
{ kDebug(1212) << "Video recording init failed";
kDebug( 1212 ) << "Video recording init failed";
return; return;
} }
KConfigGroup conf = EffectsHandler::effectConfig("VideoRecord"); KConfigGroup conf = EffectsHandler::effectConfig("VideoRecord");
QString videoPath =conf.readEntry( "videopath", KGlobalSettings::documentPath() ); QString videoPath = conf.readEntry("videopath", KGlobalSettings::documentPath());
QString videoName(videoPath +"/kwin_video1.cps" ); QString videoName(videoPath + "/kwin_video1.cps");
while(QFile::exists( videoName )) { while (QFile::exists(videoName)) {
autoincFilename( videoName ); autoincFilename(videoName);
} }
if( CapturySetOutputFileName( client, QFile::encodeName( videoName ).constData() ) != CAPTURY_SUCCESS ) if (CapturySetOutputFileName(client, QFile::encodeName(videoName).constData()) != CAPTURY_SUCCESS) {
{ kDebug(1212) << "Video recording file open failed";
kDebug( 1212 ) << "Video recording file open failed";
return; return;
}
effects->addRepaintFull(); // trigger reading initial screen contents into buffer
kDebug( 1212 ) << "Video recording start";
} }
effects->addRepaintFull(); // trigger reading initial screen contents into buffer
kDebug(1212) << "Video recording start";
}
void VideoRecordEffect::autoincFilename(QString & name) void VideoRecordEffect::autoincFilename(QString & name)
{ {
// If the name contains a number then increment it // If the name contains a number then increment it
QRegExp numSearch( "(^|[^\\d])(\\d+)" ); // we want to match as far left as possible, and when the number is at the start of the name QRegExp numSearch("(^|[^\\d])(\\d+)"); // we want to match as far left as possible, and when the number is at the start of the name
// Does it have a number? // Does it have a number?
int start = numSearch.lastIndexIn( name ); int start = numSearch.lastIndexIn(name);
if (start != -1) { if (start != -1) {
// It has a number, increment it // It has a number, increment it
start = numSearch.pos( 2 ); // we are only interested in the second group start = numSearch.pos(2); // we are only interested in the second group
QString numAsStr = numSearch.capturedTexts()[ 2 ]; QString numAsStr = numSearch.capturedTexts()[ 2 ];
QString number = QString::number( numAsStr.toInt() + 1 ); QString number = QString::number(numAsStr.toInt() + 1);
number = number.rightJustified( numAsStr.length(), '0' ); number = number.rightJustified(numAsStr.length(), '0');
name.replace( start, number.length(), number ); name.replace(start, number.length(), number);
}
} }
}
void VideoRecordEffect::stopRecording() void VideoRecordEffect::stopRecording()
{ {
if( client == NULL ) if (client == NULL)
return; return;
kDebug( 1212 ) << "Video recording stop"; kDebug(1212) << "Video recording stop";
CapturyClose( client ); CapturyClose(client);
client = NULL; client = NULL;
} }
void VideoRecordEffect::toggleRecording() void VideoRecordEffect::toggleRecording()
{ {
if( client == NULL ) if (client == NULL)
startRecording(); startRecording();
else else
stopRecording(); stopRecording();
} }
} // namespace } // namespace

View File

@ -30,24 +30,24 @@ namespace KWin
class VideoRecordEffect class VideoRecordEffect
: public QObject, public Effect : public QObject, public Effect
{ {
Q_OBJECT Q_OBJECT
public: public:
VideoRecordEffect(); VideoRecordEffect();
virtual ~VideoRecordEffect(); virtual ~VideoRecordEffect();
virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data ); virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data);
virtual void postPaintScreen(); virtual void postPaintScreen();
private slots: private slots:
void toggleRecording(); void toggleRecording();
private: private:
void startRecording(); void startRecording();
void stopRecording(); void stopRecording();
void autoincFilename(QString & url); void autoincFilename(QString & url);
captury_config_t config; captury_config_t config;
captury_t* client; captury_t* client;
QRect area; QRect area;
QRegion capture_region; QRegion capture_region;
}; };
} // namespace } // namespace

View File

@ -38,35 +38,35 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
KWIN_EFFECT_CONFIG_FACTORY KWIN_EFFECT_CONFIG_FACTORY
#endif #endif
K_PLUGIN_FACTORY_DEFINITION(EffectFactory, K_PLUGIN_FACTORY_DEFINITION(EffectFactory,
registerPlugin<KWin::VideoRecordEffectConfig>("videorecord"); registerPlugin<KWin::VideoRecordEffectConfig>("videorecord");
) )
K_EXPORT_PLUGIN(EffectFactory("kwin")) K_EXPORT_PLUGIN(EffectFactory("kwin"))
namespace KWin namespace KWin
{ {
VideoRecordEffectConfig::VideoRecordEffectConfig(QWidget* parent, const QVariantList& args) : VideoRecordEffectConfig::VideoRecordEffectConfig(QWidget* parent, const QVariantList& args) :
KCModule(EffectFactory::componentData(), parent, args) KCModule(EffectFactory::componentData(), parent, args)
{ {
QVBoxLayout* layout = new QVBoxLayout(this); QVBoxLayout* layout = new QVBoxLayout(this);
QHBoxLayout* hlayout = new QHBoxLayout( this ); QHBoxLayout* hlayout = new QHBoxLayout(this);
QLabel *label = new QLabel( i18n( "Path to save video:" ), this ); QLabel *label = new QLabel(i18n("Path to save video:"), this);
hlayout->addWidget( label ); hlayout->addWidget(label);
saveVideo = new KUrlRequester( this ); saveVideo = new KUrlRequester(this);
saveVideo->setMode( KFile::Directory | KFile::LocalOnly ); saveVideo->setMode(KFile::Directory | KFile::LocalOnly);
hlayout->addWidget( saveVideo ); hlayout->addWidget(saveVideo);
layout->addLayout( hlayout ); layout->addLayout(hlayout);
// Shortcut config. The shortcut belongs to the component "kwin"! // Shortcut config. The shortcut belongs to the component "kwin"!
KActionCollection* actionCollection = new KActionCollection( this, KComponentData("kwin") ); KActionCollection* actionCollection = new KActionCollection(this, KComponentData("kwin"));
KAction* a = static_cast<KAction*>(actionCollection->addAction( "VideoRecord" )); KAction* a = static_cast<KAction*>(actionCollection->addAction("VideoRecord"));
a->setText( i18n("Toggle Video Recording" )); a->setText(i18n("Toggle Video Recording"));
a->setProperty("isConfigurationAction", true); a->setProperty("isConfigurationAction", true);
a->setGlobalShortcut(KShortcut(Qt::CTRL + Qt::META + Qt::Key_V)); a->setGlobalShortcut(KShortcut(Qt::CTRL + Qt::META + Qt::Key_V));
mShortcutEditor = new KShortcutsEditor(actionCollection, this, mShortcutEditor = new KShortcutsEditor(actionCollection, this,
KShortcutsEditor::GlobalAction, KShortcutsEditor::LetterShortcutsDisallowed); KShortcutsEditor::GlobalAction, KShortcutsEditor::LetterShortcutsDisallowed);
layout->addWidget(mShortcutEditor); layout->addWidget(mShortcutEditor);
connect(saveVideo, SIGNAL(textChanged(const QString&)), this, SLOT(changed())); connect(saveVideo, SIGNAL(textChanged(const QString&)), this, SLOT(changed()));
@ -75,48 +75,48 @@ VideoRecordEffectConfig::VideoRecordEffectConfig(QWidget* parent, const QVariant
layout->addStretch(); layout->addStretch();
load(); load();
} }
VideoRecordEffectConfig::~VideoRecordEffectConfig() VideoRecordEffectConfig::~VideoRecordEffectConfig()
{ {
// Undo (only) unsaved changes to global key shortcuts // Undo (only) unsaved changes to global key shortcuts
mShortcutEditor->undoChanges(); mShortcutEditor->undoChanges();
} }
void VideoRecordEffectConfig::load() void VideoRecordEffectConfig::load()
{ {
KCModule::load(); KCModule::load();
KConfigGroup conf = EffectsHandler::effectConfig("VideoRecord"); KConfigGroup conf = EffectsHandler::effectConfig("VideoRecord");
saveVideo->setPath( conf.readEntry( "videopath", KGlobalSettings::documentPath() ) ); saveVideo->setPath(conf.readEntry("videopath", KGlobalSettings::documentPath()));
emit changed(false); emit changed(false);
} }
void VideoRecordEffectConfig::save() void VideoRecordEffectConfig::save()
{ {
KCModule::save(); KCModule::save();
KConfigGroup conf = EffectsHandler::effectConfig("VideoRecord"); KConfigGroup conf = EffectsHandler::effectConfig("VideoRecord");
if( saveVideo->url().isEmpty() ) if (saveVideo->url().isEmpty())
conf.writeEntry("videopath", KGlobalSettings::documentPath()); conf.writeEntry("videopath", KGlobalSettings::documentPath());
else else
conf.writeEntry("videopath", saveVideo->url().path()); conf.writeEntry("videopath", saveVideo->url().path());
conf.sync(); conf.sync();
mShortcutEditor->save(); // undo() will restore to this state from now on mShortcutEditor->save(); // undo() will restore to this state from now on
emit changed(false); emit changed(false);
EffectsHandler::sendReloadMessage( "videorecord" ); EffectsHandler::sendReloadMessage("videorecord");
} }
void VideoRecordEffectConfig::defaults() void VideoRecordEffectConfig::defaults()
{ {
saveVideo->setPath(KGlobalSettings::documentPath() ); saveVideo->setPath(KGlobalSettings::documentPath());
mShortcutEditor->allDefault(); mShortcutEditor->allDefault();
emit changed(true); emit changed(true);
} }
} // namespace } // namespace

View File

@ -30,21 +30,21 @@ namespace KWin
{ {
class VideoRecordEffectConfig : public KCModule class VideoRecordEffectConfig : public KCModule
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit VideoRecordEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList()); explicit VideoRecordEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
~VideoRecordEffectConfig(); ~VideoRecordEffectConfig();
public slots: public slots:
virtual void save(); virtual void save();
virtual void load(); virtual void load();
virtual void defaults(); virtual void defaults();
private: private:
KShortcutsEditor* mShortcutEditor; KShortcutsEditor* mShortcutEditor;
KUrlRequester *saveVideo; KUrlRequester *saveVideo;
}; };
} // namespace } // namespace

View File

@ -119,7 +119,7 @@ void BlurEffect::propertyNotify(EffectWindow *w, long atom)
bool BlurEffect::supported() bool BlurEffect::supported()
{ {
bool supported = GLRenderTarget::supported() && GLTexture::NPOTTextureSupported() && bool supported = GLRenderTarget::supported() && GLTexture::NPOTTextureSupported() &&
(GLSLBlurShader::supported() || ARBBlurShader::supported()); (GLSLBlurShader::supported() || ARBBlurShader::supported());
if (supported) { if (supported) {
int maxTexSize; int maxTexSize;
@ -131,9 +131,9 @@ bool BlurEffect::supported()
if (supported) { if (supported) {
// check the blacklist // check the blacklist
KSharedConfigPtr config = KSharedConfig::openConfig( "kwinrc" ); KSharedConfigPtr config = KSharedConfig::openConfig("kwinrc");
KConfigGroup blacklist = config->group( "Blacklist" ).group( "Blur" ); KConfigGroup blacklist = config->group("Blacklist").group("Blur");
if (effects->checkDriverBlacklist( blacklist )) { if (effects->checkDriverBlacklist(blacklist)) {
kDebug() << "Blur effect disabled by driver blacklist"; kDebug() << "Blur effect disabled by driver blacklist";
supported = false; supported = false;
} }
@ -152,8 +152,8 @@ QRegion BlurEffect::expand(const QRegion &region) const
QRegion expanded; QRegion expanded;
if (region.rectCount() < 20) { if (region.rectCount() < 20) {
foreach (const QRect &rect, region.rects()) foreach (const QRect & rect, region.rects())
expanded += expand(rect); expanded += expand(rect);
} else } else
expanded += expand(region.boundingRect()); expanded += expand(region.boundingRect());
@ -172,7 +172,7 @@ QRegion BlurEffect::blurRegion(const EffectWindow *w) const
region = w->shape(); region = w->shape();
region -= w->decorationInnerRect(); region -= w->decorationInnerRect();
region |= appRegion.translated(w->contentsRect().topLeft()) & region |= appRegion.translated(w->contentsRect().topLeft()) &
w->contentsRect(); w->contentsRect();
} else } else
region = appRegion & w->contentsRect(); region = appRegion & w->contentsRect();
} else { } else {
@ -197,7 +197,7 @@ void BlurEffect::drawRegion(const QRegion &region)
vertices.resize(vertexCount); vertices.resize(vertexCount);
int i = 0; int i = 0;
foreach (const QRect &r, region.rects()) { foreach (const QRect & r, region.rects()) {
vertices[i++] = QVector2D(r.x() + r.width(), r.y()); vertices[i++] = QVector2D(r.x() + r.width(), r.y());
vertices[i++] = QVector2D(r.x(), r.y()); vertices[i++] = QVector2D(r.x(), r.y());
vertices[i++] = QVector2D(r.x(), r.y() + r.height()); vertices[i++] = QVector2D(r.x(), r.y() + r.height());
@ -230,13 +230,12 @@ void BlurEffect::drawWindow(EffectWindow *w, int mask, QRegion region, WindowPai
bool valid = target->valid() && shader->isValid(); bool valid = target->valid() && shader->isValid();
QRegion shape; QRegion shape;
const QVariant forceBlur = w->data( WindowForceBlurRole ); const QVariant forceBlur = w->data(WindowForceBlurRole);
if ((!effects->activeFullScreenEffect() || (forceBlur.isValid() && forceBlur.toBool() )) if ((!effects->activeFullScreenEffect() || (forceBlur.isValid() && forceBlur.toBool()))
&& hasAlpha && !w->isDesktop() && !transformed) && hasAlpha && !w->isDesktop() && !transformed)
shape = blurRegion(w).translated(w->geometry().topLeft()) & screen; shape = blurRegion(w).translated(w->geometry().topLeft()) & screen;
if (valid && !shape.isEmpty() && region.intersects(shape.boundingRect())) if (valid && !shape.isEmpty() && region.intersects(shape.boundingRect())) {
{
doBlur(shape, screen, data.opacity * data.contents_opacity); doBlur(shape, screen, data.opacity * data.contents_opacity);
} }
@ -248,7 +247,7 @@ void BlurEffect::paintEffectFrame(EffectFrame *frame, QRegion region, double opa
{ {
const QRect screen(0, 0, displayWidth(), displayHeight()); const QRect screen(0, 0, displayWidth(), displayHeight());
bool valid = target->valid() && shader->isValid(); bool valid = target->valid() && shader->isValid();
QRegion shape = frame->geometry().adjusted( -5, -5, 5, 5 ) & screen; QRegion shape = frame->geometry().adjusted(-5, -5, 5, 5) & screen;
if (valid && !shape.isEmpty() && region.intersects(shape.boundingRect())) { if (valid && !shape.isEmpty() && region.intersects(shape.boundingRect())) {
doBlur(shape, screen, opacity * frameOpacity); doBlur(shape, screen, opacity * frameOpacity);
} }

View File

@ -18,7 +18,7 @@
*/ */
#ifndef BLUR_H #ifndef BLUR_H
#define BLUR_H #define BLUR_H
#include <kwineffects.h> #include <kwineffects.h>
#include <kwinglutils.h> #include <kwinglutils.h>

View File

@ -68,7 +68,7 @@ void BlurShader::setDirection(Qt::Orientation direction)
float BlurShader::gaussian(float x, float sigma) const float BlurShader::gaussian(float x, float sigma) const
{ {
return (1.0 / std::sqrt(2.0 * M_PI) * sigma) return (1.0 / std::sqrt(2.0 * M_PI) * sigma)
* std::exp(-((x * x) / (2.0 * sigma * sigma))); * std::exp(-((x * x) / (2.0 * sigma * sigma)));
} }
QVector<float> BlurShader::gaussianKernel() const QVector<float> BlurShader::gaussianKernel() const
@ -380,11 +380,10 @@ void ARBBlurShader::unbind()
#ifndef KWIN_HAVE_OPENGLES #ifndef KWIN_HAVE_OPENGLES
int boundObject; int boundObject;
glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_BINDING_ARB, &boundObject); glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_BINDING_ARB, &boundObject);
if( boundObject == program ) if (boundObject == program) {
{
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 0); glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 0);
glDisable(GL_FRAGMENT_PROGRAM_ARB); glDisable(GL_FRAGMENT_PROGRAM_ARB);
} }
#endif #endif
} }
@ -418,7 +417,7 @@ void ARBBlurShader::init()
stream << "!!ARBfp1.0\n"; stream << "!!ARBfp1.0\n";
// The kernel values are hardcoded into the program // The kernel values are hardcoded into the program
for (int i = 0; i <= center; i++) for (int i = 0; i <= center; i++)
stream << "PARAM kernel" << i << " = " << kernel[center + i] << ";\n"; stream << "PARAM kernel" << i << " = " << kernel[center + i] << ";\n";
@ -442,14 +441,14 @@ void ARBBlurShader::init()
for (int i = 1; i < size; i++) for (int i = 1; i < size; i++)
stream << "TEX temp" << i << ", temp" << i << ", texture[0], 2D;\n"; stream << "TEX temp" << i << ", temp" << i << ", texture[0], 2D;\n";
// Multiply the samples with the kernel values and compute the sum // Multiply the samples with the kernel values and compute the sum
stream << "MUL temp0, temp0, kernel0;\n"; stream << "MUL temp0, temp0, kernel0;\n";
for (int i = 0, j = 1; i < center; i++) { for (int i = 0, j = 1; i < center; i++) {
stream << "MAD temp0, temp" << j++ << ", kernel" << i + 1 << ", temp0;\n"; stream << "MAD temp0, temp" << j++ << ", kernel" << i + 1 << ", temp0;\n";
stream << "MAD temp0, temp" << j++ << ", kernel" << i + 1 << ", temp0;\n"; stream << "MAD temp0, temp" << j++ << ", kernel" << i + 1 << ", temp0;\n";
} }
stream << "MOV result.color, temp0;\n"; // gl_FragColor = temp0 stream << "MOV result.color, temp0;\n"; // gl_FragColor = temp0
stream << "END\n"; stream << "END\n";
stream.flush(); stream.flush();

View File

@ -35,15 +35,21 @@ public:
static BlurShader *create(); static BlurShader *create();
bool isValid() const { return mValid; } bool isValid() const {
return mValid;
}
// Sets the radius in pixels // Sets the radius in pixels
void setRadius(int radius); void setRadius(int radius);
int radius() const { return mRadius; } int radius() const {
return mRadius;
}
// Sets the blur direction // Sets the blur direction
void setDirection(Qt::Orientation direction); void setDirection(Qt::Orientation direction);
Qt::Orientation direction() const { return mDirection; } Qt::Orientation direction() const {
return mDirection;
}
// Sets the distance between two pixels // Sets the distance between two pixels
virtual void setPixelDistance(float val) = 0; virtual void setPixelDistance(float val) = 0;
@ -55,7 +61,9 @@ public:
protected: protected:
float gaussian(float x, float sigma) const; float gaussian(float x, float sigma) const;
QVector<float> gaussianKernel() const; QVector<float> gaussianKernel() const;
void setIsValid(bool value) { mValid = value; } void setIsValid(bool value) {
mValid = value;
}
virtual void init() = 0; virtual void init() = 0;
virtual void reset() = 0; virtual void reset() = 0;
virtual int maxKernelSize() const = 0; virtual int maxKernelSize() const = 0;

File diff suppressed because it is too large Load Diff

View File

@ -40,103 +40,102 @@ namespace KWin
class BoxSwitchEffect class BoxSwitchEffect
: public Effect : public Effect
{ {
public: public:
BoxSwitchEffect(); BoxSwitchEffect();
~BoxSwitchEffect(); ~BoxSwitchEffect();
virtual void reconfigure( ReconfigureFlags ); virtual void reconfigure(ReconfigureFlags);
virtual void prePaintScreen( ScreenPrePaintData &data, int time ); virtual void prePaintScreen(ScreenPrePaintData &data, int time);
virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data ); virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data);
virtual void postPaintScreen(); virtual void postPaintScreen();
virtual void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time ); virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time);
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
virtual void windowInputMouseEvent( Window w, QEvent* e ); virtual void windowInputMouseEvent(Window w, QEvent* e);
virtual void windowDamaged( EffectWindow* w, const QRect& damage ); virtual void windowDamaged(EffectWindow* w, const QRect& damage);
virtual void windowGeometryShapeChanged( EffectWindow* w, const QRect& old ); virtual void windowGeometryShapeChanged(EffectWindow* w, const QRect& old);
virtual void tabBoxAdded( int mode ); virtual void tabBoxAdded(int mode);
virtual void tabBoxClosed(); virtual void tabBoxClosed();
virtual void tabBoxUpdated(); virtual void tabBoxUpdated();
virtual void windowClosed( EffectWindow* w ); virtual void windowClosed(EffectWindow* w);
virtual void* proxy(); virtual void* proxy();
void activateFromProxy( int mode, bool animate, bool showText, float positioningFactor ); void activateFromProxy(int mode, bool animate, bool showText, float positioningFactor);
void paintWindowsBox( const QRegion& region ); void paintWindowsBox(const QRegion& region);
private: private:
class ItemInfo; class ItemInfo;
void setActive(); void setActive();
void setInactive(); void setInactive();
void moveResizeInputWindow( int x, int y, int width, int height ); void moveResizeInputWindow(int x, int y, int width, int height);
void calculateFrameSize(); void calculateFrameSize();
void calculateItemSizes(); void calculateItemSizes();
void setSelectedWindow( EffectWindow* w ); void setSelectedWindow(EffectWindow* w);
void paintWindowThumbnail( EffectWindow* w ); void paintWindowThumbnail(EffectWindow* w);
void paintDesktopThumbnail( int iDesktop ); void paintDesktopThumbnail(int iDesktop);
void paintWindowIcon( EffectWindow* w ); void paintWindowIcon(EffectWindow* w);
bool mActivated; bool mActivated;
Window mInput; Window mInput;
int mMode; int mMode;
EffectFrame* thumbnailFrame; EffectFrame* thumbnailFrame;
QRect frame_area; QRect frame_area;
int highlight_margin; int highlight_margin;
QSize item_max_size; // maximum item display size (including highlight) QSize item_max_size; // maximum item display size (including highlight)
QRect text_area; QRect text_area;
QFont text_font; QFont text_font;
QColor color_frame; QColor color_frame;
QColor color_highlight; QColor color_highlight;
float bg_opacity; float bg_opacity;
bool elevate_window; bool elevate_window;
QHash< EffectWindow*, ItemInfo* > windows; QHash< EffectWindow*, ItemInfo* > windows;
EffectWindowList original_windows; EffectWindowList original_windows;
EffectWindowList referrencedWindows; EffectWindowList referrencedWindows;
EffectWindow* selected_window; EffectWindow* selected_window;
QHash< int, ItemInfo* > desktops; QHash< int, ItemInfo* > desktops;
QList< int > original_desktops; QList< int > original_desktops;
int selected_desktop; int selected_desktop;
int painting_desktop; int painting_desktop;
bool mAnimateSwitch; bool mAnimateSwitch;
TimeLine activeTimeLine; TimeLine activeTimeLine;
TimeLine timeLine; TimeLine timeLine;
bool animation; bool animation;
QRect highlight_area; QRect highlight_area;
bool highlight_is_set; bool highlight_is_set;
enum Direction enum Direction {
{ Left,
Left, Right
Right
};
Direction direction;
QQueue<Direction> scheduled_directions;
EffectWindow* edge_window;
EffectWindow* right_window;
bool primaryTabBox;
bool secondaryTabBox;
BoxSwitchEffectProxy mProxy;
bool mProxyActivated;
bool mProxyAnimateSwitch;
bool mProxyShowText;
float mPositioningFactor;
}; };
Direction direction;
QQueue<Direction> scheduled_directions;
EffectWindow* edge_window;
EffectWindow* right_window;
bool primaryTabBox;
bool secondaryTabBox;
BoxSwitchEffectProxy mProxy;
bool mProxyActivated;
bool mProxyAnimateSwitch;
bool mProxyShowText;
float mPositioningFactor;
};
class BoxSwitchEffect::ItemInfo class BoxSwitchEffect::ItemInfo
{ {
public: public:
ItemInfo(); ItemInfo();
~ItemInfo(); ~ItemInfo();
QRect area; // maximal painting area, including any frames/highlights/etc. QRect area; // maximal painting area, including any frames/highlights/etc.
QRegion clickable; QRegion clickable;
QRect thumbnail; QRect thumbnail;
EffectFrame* iconFrame; EffectFrame* iconFrame;
}; };
} // namespace } // namespace

View File

@ -32,72 +32,72 @@ KWIN_EFFECT_CONFIG_FACTORY
BoxSwitchEffectConfigForm::BoxSwitchEffectConfigForm(QWidget* parent) : QWidget(parent) BoxSwitchEffectConfigForm::BoxSwitchEffectConfigForm(QWidget* parent) : QWidget(parent)
{ {
setupUi(this); setupUi(this);
} }
BoxSwitchEffectConfig::BoxSwitchEffectConfig(QWidget* parent, const QVariantList& args) BoxSwitchEffectConfig::BoxSwitchEffectConfig(QWidget* parent, const QVariantList& args)
: KCModule( EffectFactory::componentData(), parent, args ) : KCModule(EffectFactory::componentData(), parent, args)
{ {
m_ui = new BoxSwitchEffectConfigForm( this ); m_ui = new BoxSwitchEffectConfigForm(this);
QVBoxLayout* layout = new QVBoxLayout( this ); QVBoxLayout* layout = new QVBoxLayout(this);
layout->addWidget( m_ui ); layout->addWidget(m_ui);
connect( m_ui->opacitySpin, SIGNAL( valueChanged(int) ), this, SLOT( changed() )); connect(m_ui->opacitySpin, SIGNAL(valueChanged(int)), this, SLOT(changed()));
connect( m_ui->elevateBox, SIGNAL( stateChanged(int) ), this, SLOT( changed() )); connect(m_ui->elevateBox, SIGNAL(stateChanged(int)), this, SLOT(changed()));
connect( m_ui->animateBox, SIGNAL( stateChanged(int) ), this, SLOT( changed() )); connect(m_ui->animateBox, SIGNAL(stateChanged(int)), this, SLOT(changed()));
load(); load();
} }
BoxSwitchEffectConfig::~BoxSwitchEffectConfig() BoxSwitchEffectConfig::~BoxSwitchEffectConfig()
{ {
} }
void BoxSwitchEffectConfig::load() void BoxSwitchEffectConfig::load()
{ {
KCModule::load(); KCModule::load();
KConfigGroup conf = EffectsHandler::effectConfig( "BoxSwitch" ); KConfigGroup conf = EffectsHandler::effectConfig("BoxSwitch");
int opacity = conf.readEntry( "BackgroundOpacity", 25 );
m_ui->opacitySpin->setValue( opacity );
bool elevate = conf.readEntry( "ElevateSelected", true ); int opacity = conf.readEntry("BackgroundOpacity", 25);
m_ui->elevateBox->setChecked( elevate ); m_ui->opacitySpin->setValue(opacity);
bool animate = conf.readEntry( "AnimateSwitch", false ); bool elevate = conf.readEntry("ElevateSelected", true);
m_ui->animateBox->setChecked( animate ); m_ui->elevateBox->setChecked(elevate);
bool animate = conf.readEntry("AnimateSwitch", false);
m_ui->animateBox->setChecked(animate);
emit changed(false); emit changed(false);
} }
void BoxSwitchEffectConfig::save() void BoxSwitchEffectConfig::save()
{ {
KCModule::save(); KCModule::save();
KConfigGroup conf = EffectsHandler::effectConfig( "BoxSwitch" ); KConfigGroup conf = EffectsHandler::effectConfig("BoxSwitch");
conf.writeEntry( "BackgroundOpacity", m_ui->opacitySpin->value() ); conf.writeEntry("BackgroundOpacity", m_ui->opacitySpin->value());
conf.writeEntry( "ElevateSelected", m_ui->elevateBox->isChecked() ); conf.writeEntry("ElevateSelected", m_ui->elevateBox->isChecked());
conf.writeEntry( "AnimateSwitch", m_ui->animateBox->isChecked() ); conf.writeEntry("AnimateSwitch", m_ui->animateBox->isChecked());
conf.sync(); conf.sync();
emit changed(false); emit changed(false);
EffectsHandler::sendReloadMessage( "boxswitch" ); EffectsHandler::sendReloadMessage("boxswitch");
} }
void BoxSwitchEffectConfig::defaults() void BoxSwitchEffectConfig::defaults()
{ {
m_ui->opacitySpin->setValue( 25 ); m_ui->opacitySpin->setValue(25);
m_ui->elevateBox->setChecked( true ); m_ui->elevateBox->setChecked(true);
m_ui->animateBox->setChecked( false ); m_ui->animateBox->setChecked(false);
emit changed(true); emit changed(true);
} }
} // namespace } // namespace

View File

@ -31,25 +31,25 @@ namespace KWin
class BoxSwitchEffectConfigForm : public QWidget, public Ui::BoxSwitchEffectConfigForm class BoxSwitchEffectConfigForm : public QWidget, public Ui::BoxSwitchEffectConfigForm
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit BoxSwitchEffectConfigForm(QWidget* parent); explicit BoxSwitchEffectConfigForm(QWidget* parent);
}; };
class BoxSwitchEffectConfig : public KCModule class BoxSwitchEffectConfig : public KCModule
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit BoxSwitchEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList()); explicit BoxSwitchEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
~BoxSwitchEffectConfig(); ~BoxSwitchEffectConfig();
public slots: public slots:
virtual void save(); virtual void save();
virtual void load(); virtual void load();
virtual void defaults(); virtual void defaults();
private: private:
BoxSwitchEffectConfigForm* m_ui; BoxSwitchEffectConfigForm* m_ui;
}; };
} // namespace } // namespace

View File

@ -24,23 +24,23 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
namespace KWin namespace KWin
{ {
BoxSwitchEffectProxy::BoxSwitchEffectProxy( BoxSwitchEffect* effect ) BoxSwitchEffectProxy::BoxSwitchEffectProxy(BoxSwitchEffect* effect)
: m_effect( effect ) : m_effect(effect)
{ {
} }
BoxSwitchEffectProxy::~BoxSwitchEffectProxy() BoxSwitchEffectProxy::~BoxSwitchEffectProxy()
{ {
} }
void BoxSwitchEffectProxy::activate( int mode, bool animate, bool showText, float positioningFactor ) void BoxSwitchEffectProxy::activate(int mode, bool animate, bool showText, float positioningFactor)
{ {
m_effect->activateFromProxy( mode, animate, showText, positioningFactor ); m_effect->activateFromProxy(mode, animate, showText, positioningFactor);
} }
void BoxSwitchEffectProxy::paintWindowsBox( const QRegion& region ) void BoxSwitchEffectProxy::paintWindowsBox(const QRegion& region)
{ {
m_effect->paintWindowsBox( region ); m_effect->paintWindowsBox(region);
} }
} // namespace } // namespace

View File

@ -30,22 +30,22 @@ class BoxSwitchEffect;
class BoxSwitchEffectProxy class BoxSwitchEffectProxy
{ {
public: public:
BoxSwitchEffectProxy( BoxSwitchEffect* effect ); BoxSwitchEffectProxy(BoxSwitchEffect* effect);
~BoxSwitchEffectProxy(); ~BoxSwitchEffectProxy();
/** /**
* Activates the BoxSwitch Effect. It will get deactivated in tabBoxClosed() * Activates the BoxSwitch Effect. It will get deactivated in tabBoxClosed()
* @param mode The TabBoxMode for which it should be activated. * @param mode The TabBoxMode for which it should be activated.
* @param animate switch will be animated * @param animate switch will be animated
* @param showText the caption of the window will be shown * @param showText the caption of the window will be shown
* @param positioningFactor where to put the frame: 0.0 == top, 1.0 == bottom * @param positioningFactor where to put the frame: 0.0 == top, 1.0 == bottom
*/ */
void activate( int mode, bool animate, bool showText, float positioningFactor ); void activate(int mode, bool animate, bool showText, float positioningFactor);
void paintWindowsBox( const QRegion& region); void paintWindowsBox(const QRegion& region);
private: private:
BoxSwitchEffect* m_effect; BoxSwitchEffect* m_effect;
}; };
} // namespace } // namespace

View File

@ -56,33 +56,33 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
namespace KWin namespace KWin
{ {
KWIN_EFFECT_CONFIG_MULTIPLE( builtins, KWIN_EFFECT_CONFIG_MULTIPLE(builtins,
KWIN_EFFECT_CONFIG_SINGLE( boxswitch, BoxSwitchEffectConfig ) KWIN_EFFECT_CONFIG_SINGLE(boxswitch, BoxSwitchEffectConfig)
KWIN_EFFECT_CONFIG_SINGLE( dashboard, DashboardEffectConfig ) KWIN_EFFECT_CONFIG_SINGLE(dashboard, DashboardEffectConfig)
KWIN_EFFECT_CONFIG_SINGLE( desktopgrid, DesktopGridEffectConfig ) KWIN_EFFECT_CONFIG_SINGLE(desktopgrid, DesktopGridEffectConfig)
KWIN_EFFECT_CONFIG_SINGLE( diminactive, DimInactiveEffectConfig ) KWIN_EFFECT_CONFIG_SINGLE(diminactive, DimInactiveEffectConfig)
KWIN_EFFECT_CONFIG_SINGLE( magiclamp, MagicLampEffectConfig ) KWIN_EFFECT_CONFIG_SINGLE(magiclamp, MagicLampEffectConfig)
KWIN_EFFECT_CONFIG_SINGLE( presentwindows, PresentWindowsEffectConfig ) KWIN_EFFECT_CONFIG_SINGLE(presentwindows, PresentWindowsEffectConfig)
KWIN_EFFECT_CONFIG_SINGLE( resize, ResizeEffectConfig ) KWIN_EFFECT_CONFIG_SINGLE(resize, ResizeEffectConfig)
KWIN_EFFECT_CONFIG_SINGLE( showfps, ShowFpsEffectConfig ) KWIN_EFFECT_CONFIG_SINGLE(showfps, ShowFpsEffectConfig)
KWIN_EFFECT_CONFIG_SINGLE( translucency, TranslucencyEffectConfig ) KWIN_EFFECT_CONFIG_SINGLE(translucency, TranslucencyEffectConfig)
KWIN_EFFECT_CONFIG_SINGLE( thumbnailaside, ThumbnailAsideEffectConfig ) KWIN_EFFECT_CONFIG_SINGLE(thumbnailaside, ThumbnailAsideEffectConfig)
KWIN_EFFECT_CONFIG_SINGLE( zoom, ZoomEffectConfig ) KWIN_EFFECT_CONFIG_SINGLE(zoom, ZoomEffectConfig)
#ifdef KWIN_HAVE_OPENGL_COMPOSITING #ifdef KWIN_HAVE_OPENGL_COMPOSITING
KWIN_EFFECT_CONFIG_SINGLE( blur, BlurEffectConfig ) KWIN_EFFECT_CONFIG_SINGLE(blur, BlurEffectConfig)
KWIN_EFFECT_CONFIG_SINGLE( coverswitch, CoverSwitchEffectConfig ) KWIN_EFFECT_CONFIG_SINGLE(coverswitch, CoverSwitchEffectConfig)
KWIN_EFFECT_CONFIG_SINGLE( cube, CubeEffectConfig ) KWIN_EFFECT_CONFIG_SINGLE(cube, CubeEffectConfig)
KWIN_EFFECT_CONFIG_SINGLE( cubeslide, CubeSlideEffectConfig ) KWIN_EFFECT_CONFIG_SINGLE(cubeslide, CubeSlideEffectConfig)
KWIN_EFFECT_CONFIG_SINGLE( flipswitch, FlipSwitchEffectConfig ) KWIN_EFFECT_CONFIG_SINGLE(flipswitch, FlipSwitchEffectConfig)
KWIN_EFFECT_CONFIG_SINGLE( glide, GlideEffectConfig ) KWIN_EFFECT_CONFIG_SINGLE(glide, GlideEffectConfig)
KWIN_EFFECT_CONFIG_SINGLE( invert, InvertEffectConfig ) KWIN_EFFECT_CONFIG_SINGLE(invert, InvertEffectConfig)
KWIN_EFFECT_CONFIG_SINGLE( lookingglass, LookingGlassEffectConfig ) KWIN_EFFECT_CONFIG_SINGLE(lookingglass, LookingGlassEffectConfig)
KWIN_EFFECT_CONFIG_SINGLE( magnifier, MagnifierEffectConfig ) KWIN_EFFECT_CONFIG_SINGLE(magnifier, MagnifierEffectConfig)
KWIN_EFFECT_CONFIG_SINGLE( mousemark, MouseMarkEffectConfig ) KWIN_EFFECT_CONFIG_SINGLE(mousemark, MouseMarkEffectConfig)
KWIN_EFFECT_CONFIG_SINGLE( trackmouse, TrackMouseEffectConfig ) KWIN_EFFECT_CONFIG_SINGLE(trackmouse, TrackMouseEffectConfig)
KWIN_EFFECT_CONFIG_SINGLE( wobblywindows, WobblyWindowsEffectConfig ) KWIN_EFFECT_CONFIG_SINGLE(wobblywindows, WobblyWindowsEffectConfig)
#endif #endif
) )
} // namespace } // namespace

File diff suppressed because it is too large Load Diff

View File

@ -35,76 +35,75 @@ namespace KWin
class CoverSwitchEffect class CoverSwitchEffect
: public Effect : public Effect
{ {
public: public:
CoverSwitchEffect(); CoverSwitchEffect();
~CoverSwitchEffect(); ~CoverSwitchEffect();
virtual void reconfigure( ReconfigureFlags ); virtual void reconfigure(ReconfigureFlags);
virtual void prePaintScreen( ScreenPrePaintData& data, int time ); virtual void prePaintScreen(ScreenPrePaintData& data, int time);
virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data ); virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data);
virtual void postPaintScreen(); virtual void postPaintScreen();
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
virtual void tabBoxAdded( int mode ); virtual void tabBoxAdded(int mode);
virtual void tabBoxClosed(); virtual void tabBoxClosed();
virtual void tabBoxUpdated(); virtual void tabBoxUpdated();
virtual void windowInputMouseEvent( Window w, QEvent* e ); virtual void windowInputMouseEvent(Window w, QEvent* e);
virtual void windowClosed( EffectWindow* c ); virtual void windowClosed(EffectWindow* c);
static bool supported(); static bool supported();
private: private:
void paintScene( EffectWindow* frontWindow, const EffectWindowList& leftWindows, const EffectWindowList& rightWindows, void paintScene(EffectWindow* frontWindow, const EffectWindowList& leftWindows, const EffectWindowList& rightWindows,
bool reflectedWindows = false ); bool reflectedWindows = false);
void paintWindowCover( EffectWindow* w, bool reflectedWindow, WindowPaintData& data ); void paintWindowCover(EffectWindow* w, bool reflectedWindow, WindowPaintData& data);
void paintFrontWindow( EffectWindow* frontWindow, int width, int leftWindows, int rightWindows, bool reflectedWindow ); void paintFrontWindow(EffectWindow* frontWindow, int width, int leftWindows, int rightWindows, bool reflectedWindow);
void paintWindows( const EffectWindowList& windows, bool left, bool reflectedWindows, EffectWindow* additionalWindow = NULL ); void paintWindows(const EffectWindowList& windows, bool left, bool reflectedWindows, EffectWindow* additionalWindow = NULL);
void abort(); void abort();
bool mActivated; bool mActivated;
float angle; float angle;
bool animateSwitch; bool animateSwitch;
bool animateStart; bool animateStart;
bool animateStop; bool animateStop;
bool animation; bool animation;
bool start; bool start;
bool stop; bool stop;
bool reflection; bool reflection;
float mirrorColor[2][4]; float mirrorColor[2][4];
bool windowTitle; bool windowTitle;
int animationDuration; int animationDuration;
bool stopRequested; bool stopRequested;
bool startRequested; bool startRequested;
TimeLine timeLine; TimeLine timeLine;
QRect area; QRect area;
Window input; Window input;
float zPosition; float zPosition;
float scaleFactor; float scaleFactor;
enum Direction enum Direction {
{ Left,
Left, Right
Right
};
Direction direction;
QQueue<Direction> scheduled_directions;
EffectWindow* selected_window;
int activeScreen;
QList< EffectWindow* > leftWindows;
QList< EffectWindow* > rightWindows;
EffectWindowList currentWindowList;
EffectWindowList referrencedWindows;
EffectFrame* captionFrame;
QFont captionFont;
bool thumbnails;
bool dynamicThumbnails;
int thumbnailWindows;
bool primaryTabBox;
bool secondaryTabBox;
GLShader *m_reflectionShader;
}; };
Direction direction;
QQueue<Direction> scheduled_directions;
EffectWindow* selected_window;
int activeScreen;
QList< EffectWindow* > leftWindows;
QList< EffectWindow* > rightWindows;
EffectWindowList currentWindowList;
EffectWindowList referrencedWindows;
EffectFrame* captionFrame;
QFont captionFont;
bool thumbnails;
bool dynamicThumbnails;
int thumbnailWindows;
bool primaryTabBox;
bool secondaryTabBox;
GLShader *m_reflectionShader;
};
} // namespace } // namespace

View File

@ -31,12 +31,12 @@ KWIN_EFFECT_CONFIG_FACTORY
CoverSwitchEffectConfigForm::CoverSwitchEffectConfigForm(QWidget* parent) : QWidget(parent) CoverSwitchEffectConfigForm::CoverSwitchEffectConfigForm(QWidget* parent) : QWidget(parent)
{ {
setupUi(this); setupUi(this);
} }
CoverSwitchEffectConfig::CoverSwitchEffectConfig(QWidget* parent, const QVariantList& args) : CoverSwitchEffectConfig::CoverSwitchEffectConfig(QWidget* parent, const QVariantList& args) :
KCModule(EffectFactory::componentData(), parent, args) KCModule(EffectFactory::componentData(), parent, args)
{ {
m_ui = new CoverSwitchEffectConfigForm(this); m_ui = new CoverSwitchEffectConfigForm(this);
QVBoxLayout* layout = new QVBoxLayout(this); QVBoxLayout* layout = new QVBoxLayout(this);
@ -60,80 +60,80 @@ CoverSwitchEffectConfig::CoverSwitchEffectConfig(QWidget* parent, const QVariant
connect(m_ui->checkDynamicThumbnails, SIGNAL(stateChanged(int)), this, SLOT(thumbnailsChanged())); connect(m_ui->checkDynamicThumbnails, SIGNAL(stateChanged(int)), this, SLOT(thumbnailsChanged()));
load(); load();
} }
void CoverSwitchEffectConfig::load() void CoverSwitchEffectConfig::load()
{ {
KCModule::load(); KCModule::load();
KConfigGroup conf = EffectsHandler::effectConfig( "CoverSwitch" ); KConfigGroup conf = EffectsHandler::effectConfig("CoverSwitch");
m_ui->spinDuration->setValue( conf.readEntry( "Duration", 0 ) ); m_ui->spinDuration->setValue(conf.readEntry("Duration", 0));
m_ui->spinDuration->setSuffix( ki18np( " millisecond", " milliseconds" ) ); m_ui->spinDuration->setSuffix(ki18np(" millisecond", " milliseconds"));
m_ui->checkAnimateSwitch->setChecked( conf.readEntry( "AnimateSwitch", true )); m_ui->checkAnimateSwitch->setChecked(conf.readEntry("AnimateSwitch", true));
m_ui->checkAnimateStart->setChecked( conf.readEntry( "AnimateStart", true )); m_ui->checkAnimateStart->setChecked(conf.readEntry("AnimateStart", true));
m_ui->checkAnimateStop->setChecked( conf.readEntry( "AnimateStop", true )); m_ui->checkAnimateStop->setChecked(conf.readEntry("AnimateStop", true));
m_ui->checkReflection->setChecked( conf.readEntry( "Reflection", true )); m_ui->checkReflection->setChecked(conf.readEntry("Reflection", true));
m_ui->colorFront->setColor( conf.readEntry( "MirrorFrontColor", QColor(0,0,0) )); m_ui->colorFront->setColor(conf.readEntry("MirrorFrontColor", QColor(0, 0, 0)));
m_ui->colorRear->setColor( conf.readEntry( "MirrorRearColor", QColor(0,0,0) )); m_ui->colorRear->setColor(conf.readEntry("MirrorRearColor", QColor(0, 0, 0)));
m_ui->checkWindowTitle->setChecked( conf.readEntry( "WindowTitle", true )); m_ui->checkWindowTitle->setChecked(conf.readEntry("WindowTitle", true));
m_ui->checkThumbnails->setChecked( conf.readEntry( "Thumbnails", true )); m_ui->checkThumbnails->setChecked(conf.readEntry("Thumbnails", true));
m_ui->checkDynamicThumbnails->setChecked( conf.readEntry( "DynamicThumbnails", true )); m_ui->checkDynamicThumbnails->setChecked(conf.readEntry("DynamicThumbnails", true));
m_ui->spinThumbnailWindows->setValue( conf.readEntry( "ThumbnailWindows", 8 )); m_ui->spinThumbnailWindows->setValue(conf.readEntry("ThumbnailWindows", 8));
m_ui->zPositionSlider->setValue( conf.readEntry( "ZPosition", 900 )); m_ui->zPositionSlider->setValue(conf.readEntry("ZPosition", 900));
thumbnailsChanged(); thumbnailsChanged();
emit changed(false); emit changed(false);
} }
void CoverSwitchEffectConfig::save() void CoverSwitchEffectConfig::save()
{ {
KConfigGroup conf = EffectsHandler::effectConfig( "CoverSwitch" ); KConfigGroup conf = EffectsHandler::effectConfig("CoverSwitch");
conf.writeEntry( "Duration", m_ui->spinDuration->value() ); conf.writeEntry("Duration", m_ui->spinDuration->value());
conf.writeEntry( "AnimateSwitch", m_ui->checkAnimateSwitch->isChecked() ); conf.writeEntry("AnimateSwitch", m_ui->checkAnimateSwitch->isChecked());
conf.writeEntry( "AnimateStart", m_ui->checkAnimateStart->isChecked() ); conf.writeEntry("AnimateStart", m_ui->checkAnimateStart->isChecked());
conf.writeEntry( "AnimateStop", m_ui->checkAnimateStop->isChecked() ); conf.writeEntry("AnimateStop", m_ui->checkAnimateStop->isChecked());
conf.writeEntry( "Reflection", m_ui->checkReflection->isChecked() ); conf.writeEntry("Reflection", m_ui->checkReflection->isChecked());
conf.writeEntry( "MirrorFrontColor", m_ui->colorFront->color() ); conf.writeEntry("MirrorFrontColor", m_ui->colorFront->color());
conf.writeEntry( "MirrorRearColor", m_ui->colorRear->color() ); conf.writeEntry("MirrorRearColor", m_ui->colorRear->color());
conf.writeEntry( "WindowTitle", m_ui->checkWindowTitle->isChecked() ); conf.writeEntry("WindowTitle", m_ui->checkWindowTitle->isChecked());
conf.writeEntry( "Thumbnails", m_ui->checkThumbnails->isChecked() ); conf.writeEntry("Thumbnails", m_ui->checkThumbnails->isChecked());
conf.writeEntry( "DynamicThumbnails", m_ui->checkDynamicThumbnails->isChecked() ); conf.writeEntry("DynamicThumbnails", m_ui->checkDynamicThumbnails->isChecked());
conf.writeEntry( "ThumbnailWindows", m_ui->spinThumbnailWindows->value() ); conf.writeEntry("ThumbnailWindows", m_ui->spinThumbnailWindows->value());
conf.writeEntry( "ZPosition", m_ui->zPositionSlider->value() ); conf.writeEntry("ZPosition", m_ui->zPositionSlider->value());
conf.sync(); conf.sync();
emit changed(false); emit changed(false);
EffectsHandler::sendReloadMessage( "coverswitch" ); EffectsHandler::sendReloadMessage("coverswitch");
} }
void CoverSwitchEffectConfig::defaults() void CoverSwitchEffectConfig::defaults()
{ {
m_ui->spinDuration->setValue( 0 ); m_ui->spinDuration->setValue(0);
m_ui->checkAnimateSwitch->setCheckState( Qt::Checked ); m_ui->checkAnimateSwitch->setCheckState(Qt::Checked);
m_ui->checkAnimateStart->setCheckState( Qt::Checked ); m_ui->checkAnimateStart->setCheckState(Qt::Checked);
m_ui->checkAnimateStop->setCheckState( Qt::Checked ); m_ui->checkAnimateStop->setCheckState(Qt::Checked);
m_ui->checkReflection->setCheckState( Qt::Checked ); m_ui->checkReflection->setCheckState(Qt::Checked);
m_ui->colorFront->setColor( QColor(0,0,0) ); m_ui->colorFront->setColor(QColor(0, 0, 0));
m_ui->colorRear->setColor( QColor(0,0,0) ); m_ui->colorRear->setColor(QColor(0, 0, 0));
m_ui->checkWindowTitle->setCheckState( Qt::Checked ); m_ui->checkWindowTitle->setCheckState(Qt::Checked);
m_ui->checkThumbnails->setCheckState( Qt::Checked ); m_ui->checkThumbnails->setCheckState(Qt::Checked);
m_ui->checkDynamicThumbnails->setCheckState( Qt::Checked ); m_ui->checkDynamicThumbnails->setCheckState(Qt::Checked);
m_ui->spinThumbnailWindows->setValue( 8 ); m_ui->spinThumbnailWindows->setValue(8);
m_ui->zPositionSlider->setValue( 900 ); m_ui->zPositionSlider->setValue(900);
emit changed(true); emit changed(true);
} }
void CoverSwitchEffectConfig::thumbnailsChanged() void CoverSwitchEffectConfig::thumbnailsChanged()
{ {
bool enabled = m_ui->checkThumbnails->isChecked() && m_ui->checkDynamicThumbnails->isChecked(); bool enabled = m_ui->checkThumbnails->isChecked() && m_ui->checkDynamicThumbnails->isChecked();
m_ui->checkDynamicThumbnails->setEnabled( m_ui->checkThumbnails->isChecked() ); m_ui->checkDynamicThumbnails->setEnabled(m_ui->checkThumbnails->isChecked());
m_ui->spinThumbnailWindows->setEnabled( enabled ); m_ui->spinThumbnailWindows->setEnabled(enabled);
m_ui->labelThumbnailWindows->setEnabled( enabled ); m_ui->labelThumbnailWindows->setEnabled(enabled);
} }
} // namespace } // namespace

View File

@ -32,27 +32,27 @@ namespace KWin
class CoverSwitchEffectConfigForm : public QWidget, public Ui::CoverSwitchEffectConfigForm class CoverSwitchEffectConfigForm : public QWidget, public Ui::CoverSwitchEffectConfigForm
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit CoverSwitchEffectConfigForm(QWidget* parent); explicit CoverSwitchEffectConfigForm(QWidget* parent);
}; };
class CoverSwitchEffectConfig : public KCModule class CoverSwitchEffectConfig : public KCModule
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit CoverSwitchEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList()); explicit CoverSwitchEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
public slots: public slots:
virtual void save(); virtual void save();
virtual void load(); virtual void load();
virtual void defaults(); virtual void defaults();
private slots: private slots:
void thumbnailsChanged(); void thumbnailsChanged();
private: private:
CoverSwitchEffectConfigForm* m_ui; CoverSwitchEffectConfigForm* m_ui;
}; };
} // namespace } // namespace

File diff suppressed because it is too large Load Diff

View File

@ -35,150 +35,147 @@ namespace KWin
class CubeEffect class CubeEffect
: public QObject, public Effect : public QObject, public Effect
{ {
Q_OBJECT Q_OBJECT
public: public:
CubeEffect(); CubeEffect();
~CubeEffect(); ~CubeEffect();
virtual void reconfigure( ReconfigureFlags ); virtual void reconfigure(ReconfigureFlags);
virtual void prePaintScreen( ScreenPrePaintData& data, int time ); virtual void prePaintScreen(ScreenPrePaintData& data, int time);
virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data ); virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data);
virtual void postPaintScreen(); virtual void postPaintScreen();
virtual void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time ); virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time);
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
virtual bool borderActivated( ElectricBorder border ); virtual bool borderActivated(ElectricBorder border);
virtual void grabbedKeyboardEvent( QKeyEvent* e ); virtual void grabbedKeyboardEvent(QKeyEvent* e);
virtual void mouseChanged( const QPoint& pos, const QPoint& oldpos, Qt::MouseButtons buttons, virtual void mouseChanged(const QPoint& pos, const QPoint& oldpos, Qt::MouseButtons buttons,
Qt::MouseButtons oldbuttons, Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers ); Qt::MouseButtons oldbuttons, Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers);
virtual void windowInputMouseEvent( Window w, QEvent* e ); virtual void windowInputMouseEvent(Window w, QEvent* e);
virtual void tabBoxAdded( int mode ); virtual void tabBoxAdded(int mode);
virtual void tabBoxUpdated(); virtual void tabBoxUpdated();
virtual void tabBoxClosed(); virtual void tabBoxClosed();
// proxy functions // proxy functions
virtual void* proxy(); virtual void* proxy();
void registerCubeInsideEffect( CubeInsideEffect* effect ); void registerCubeInsideEffect(CubeInsideEffect* effect);
void unregisterCubeInsideEffect( CubeInsideEffect* effect ); void unregisterCubeInsideEffect(CubeInsideEffect* effect);
static bool supported(); static bool supported();
private slots: private slots:
void toggleCube(); void toggleCube();
void toggleCylinder(); void toggleCylinder();
void toggleSphere(); void toggleSphere();
// slots for global shortcut changed // slots for global shortcut changed
// needed to toggle the effect // needed to toggle the effect
void cubeShortcutChanged( const QKeySequence& seq ); void cubeShortcutChanged(const QKeySequence& seq);
void cylinderShortcutChanged( const QKeySequence& seq ); void cylinderShortcutChanged(const QKeySequence& seq);
void sphereShortcutChanged( const QKeySequence& seq ); void sphereShortcutChanged(const QKeySequence& seq);
private: private:
enum RotationDirection enum RotationDirection {
{ Left,
Left, Right,
Right, Upwards,
Upwards, Downwards
Downwards
};
enum VerticalRotationPosition
{
Up,
Normal,
Down
};
enum CubeMode
{
Cube,
Cylinder,
Sphere
};
void toggle( CubeMode newMode = Cube );
void paintCube( int mask, QRegion region, ScreenPaintData& data );
void paintCap(bool frontFirst, float zOffset);
void paintCubeCap();
void paintCylinderCap();
void paintSphereCap();
bool loadShader();
void loadConfig( QString config );
void rotateCube();
void rotateToDesktop( int desktop );
void setActive( bool active );
bool activated;
bool mousePolling;
bool cube_painting;
bool keyboard_grab;
bool schedule_close;
QList<ElectricBorder> borderActivate;
QList<ElectricBorder> borderActivateCylinder;
QList<ElectricBorder> borderActivateSphere;
int painting_desktop;
Window input;
int frontDesktop;
float cubeOpacity;
bool opacityDesktopOnly;
bool displayDesktopName;
EffectFrame* desktopNameFrame;
QFont desktopNameFont;
bool reflection;
bool rotating;
bool verticalRotating;
bool desktopChangedWhileRotating;
bool paintCaps;
TimeLine timeLine;
TimeLine verticalTimeLine;
RotationDirection rotationDirection;
RotationDirection verticalRotationDirection;
VerticalRotationPosition verticalPosition;
QQueue<RotationDirection> rotations;
QQueue<RotationDirection> verticalRotations;
QColor backgroundColor;
QColor capColor;
GLTexture* wallpaper;
bool texturedCaps;
GLTexture* capTexture;
float manualAngle;
float manualVerticalAngle;
TimeLine::CurveShape currentShape;
bool start;
bool stop;
bool reflectionPainting;
int rotationDuration;
int activeScreen;
bool bottomCap;
bool closeOnMouseRelease;
float zoom;
float zPosition;
bool useForTabBox;
bool invertKeys;
bool invertMouse;
bool tabBoxMode;
bool shortcutsRegistered;
CubeMode mode;
bool useShaders;
GLShader* cylinderShader;
GLShader* sphereShader;
GLShader* m_reflectionShader;
GLShader* m_capShader;
float capDeformationFactor;
bool useZOrdering;
float zOrderingFactor;
bool useList;
// needed for reflection
float mAddedHeightCoeff1;
float mAddedHeightCoeff2;
QMatrix4x4 m_rotationMatrix;
QMatrix4x4 m_reflectionMatrix;
QMatrix4x4 m_textureMirrorMatrix;
GLVertexBuffer *m_cubeCapBuffer;
// Shortcuts - needed to toggle the effect
KShortcut cubeShortcut;
KShortcut cylinderShortcut;
KShortcut sphereShortcut;
// proxy
CubeEffectProxy m_proxy;
QList< CubeInsideEffect* > m_cubeInsideEffects;
}; };
enum VerticalRotationPosition {
Up,
Normal,
Down
};
enum CubeMode {
Cube,
Cylinder,
Sphere
};
void toggle(CubeMode newMode = Cube);
void paintCube(int mask, QRegion region, ScreenPaintData& data);
void paintCap(bool frontFirst, float zOffset);
void paintCubeCap();
void paintCylinderCap();
void paintSphereCap();
bool loadShader();
void loadConfig(QString config);
void rotateCube();
void rotateToDesktop(int desktop);
void setActive(bool active);
bool activated;
bool mousePolling;
bool cube_painting;
bool keyboard_grab;
bool schedule_close;
QList<ElectricBorder> borderActivate;
QList<ElectricBorder> borderActivateCylinder;
QList<ElectricBorder> borderActivateSphere;
int painting_desktop;
Window input;
int frontDesktop;
float cubeOpacity;
bool opacityDesktopOnly;
bool displayDesktopName;
EffectFrame* desktopNameFrame;
QFont desktopNameFont;
bool reflection;
bool rotating;
bool verticalRotating;
bool desktopChangedWhileRotating;
bool paintCaps;
TimeLine timeLine;
TimeLine verticalTimeLine;
RotationDirection rotationDirection;
RotationDirection verticalRotationDirection;
VerticalRotationPosition verticalPosition;
QQueue<RotationDirection> rotations;
QQueue<RotationDirection> verticalRotations;
QColor backgroundColor;
QColor capColor;
GLTexture* wallpaper;
bool texturedCaps;
GLTexture* capTexture;
float manualAngle;
float manualVerticalAngle;
TimeLine::CurveShape currentShape;
bool start;
bool stop;
bool reflectionPainting;
int rotationDuration;
int activeScreen;
bool bottomCap;
bool closeOnMouseRelease;
float zoom;
float zPosition;
bool useForTabBox;
bool invertKeys;
bool invertMouse;
bool tabBoxMode;
bool shortcutsRegistered;
CubeMode mode;
bool useShaders;
GLShader* cylinderShader;
GLShader* sphereShader;
GLShader* m_reflectionShader;
GLShader* m_capShader;
float capDeformationFactor;
bool useZOrdering;
float zOrderingFactor;
bool useList;
// needed for reflection
float mAddedHeightCoeff1;
float mAddedHeightCoeff2;
QMatrix4x4 m_rotationMatrix;
QMatrix4x4 m_reflectionMatrix;
QMatrix4x4 m_textureMirrorMatrix;
GLVertexBuffer *m_cubeCapBuffer;
// Shortcuts - needed to toggle the effect
KShortcut cubeShortcut;
KShortcut cylinderShortcut;
KShortcut sphereShortcut;
// proxy
CubeEffectProxy m_proxy;
QList< CubeInsideEffect* > m_cubeInsideEffects;
};
} // namespace } // namespace

View File

@ -35,39 +35,39 @@ KWIN_EFFECT_CONFIG_FACTORY
CubeEffectConfigForm::CubeEffectConfigForm(QWidget* parent) : QWidget(parent) CubeEffectConfigForm::CubeEffectConfigForm(QWidget* parent) : QWidget(parent)
{ {
setupUi(this); setupUi(this);
} }
CubeEffectConfig::CubeEffectConfig(QWidget* parent, const QVariantList& args) : CubeEffectConfig::CubeEffectConfig(QWidget* parent, const QVariantList& args) :
KCModule(EffectFactory::componentData(), parent, args) KCModule(EffectFactory::componentData(), parent, args)
{ {
m_ui = new CubeEffectConfigForm(this); m_ui = new CubeEffectConfigForm(this);
QVBoxLayout* layout = new QVBoxLayout(this); QVBoxLayout* layout = new QVBoxLayout(this);
layout->addWidget(m_ui); layout->addWidget(m_ui);
m_ui->tabWidget->setTabText( 0, i18nc("@title:tab Basic Settings", "Basic") ); m_ui->tabWidget->setTabText(0, i18nc("@title:tab Basic Settings", "Basic"));
m_ui->tabWidget->setTabText( 1, i18nc("@title:tab Advanced Settings", "Advanced") ); m_ui->tabWidget->setTabText(1, i18nc("@title:tab Advanced Settings", "Advanced"));
// Shortcut config. The shortcut belongs to the component "kwin"! // Shortcut config. The shortcut belongs to the component "kwin"!
m_actionCollection = new KActionCollection( this, KComponentData("kwin") ); m_actionCollection = new KActionCollection(this, KComponentData("kwin"));
m_actionCollection->setConfigGroup( "Cube" ); m_actionCollection->setConfigGroup("Cube");
m_actionCollection->setConfigGlobal(true); m_actionCollection->setConfigGlobal(true);
KAction* cubeAction = (KAction*) m_actionCollection->addAction( "Cube" ); KAction* cubeAction = (KAction*) m_actionCollection->addAction("Cube");
cubeAction->setText( i18n("Desktop Cube" )); cubeAction->setText(i18n("Desktop Cube"));
cubeAction->setProperty("isConfigurationAction", true); cubeAction->setProperty("isConfigurationAction", true);
cubeAction->setGlobalShortcut( KShortcut( Qt::CTRL + Qt::Key_F11 )); cubeAction->setGlobalShortcut(KShortcut(Qt::CTRL + Qt::Key_F11));
KAction* cylinderAction = (KAction*) m_actionCollection->addAction( "Cylinder" ); KAction* cylinderAction = (KAction*) m_actionCollection->addAction("Cylinder");
cylinderAction->setText( i18n("Desktop Cylinder" )); cylinderAction->setText(i18n("Desktop Cylinder"));
cylinderAction->setProperty("isConfigurationAction", true); cylinderAction->setProperty("isConfigurationAction", true);
cylinderAction->setGlobalShortcut( KShortcut(), KAction::ActiveShortcut); cylinderAction->setGlobalShortcut(KShortcut(), KAction::ActiveShortcut);
KAction* sphereAction = (KAction*) m_actionCollection->addAction( "Sphere" ); KAction* sphereAction = (KAction*) m_actionCollection->addAction("Sphere");
sphereAction->setText( i18n("Desktop Sphere" )); sphereAction->setText(i18n("Desktop Sphere"));
sphereAction->setProperty("isConfigurationAction", true); sphereAction->setProperty("isConfigurationAction", true);
sphereAction->setGlobalShortcut( KShortcut(), KAction::ActiveShortcut); sphereAction->setGlobalShortcut(KShortcut(), KAction::ActiveShortcut);
m_ui->editor->addCollection(m_actionCollection); m_ui->editor->addCollection(m_actionCollection);
@ -94,166 +94,145 @@ CubeEffectConfig::CubeEffectConfig(QWidget* parent, const QVariantList& args) :
connect(m_ui->zOrderingBox, SIGNAL(stateChanged(int)), this, SLOT(changed())); connect(m_ui->zOrderingBox, SIGNAL(stateChanged(int)), this, SLOT(changed()));
load(); load();
} }
void CubeEffectConfig::load() void CubeEffectConfig::load()
{ {
KCModule::load(); KCModule::load();
KConfigGroup conf = EffectsHandler::effectConfig( "Cube" ); KConfigGroup conf = EffectsHandler::effectConfig("Cube");
int duration = conf.readEntry( "RotationDuration", 0 ); int duration = conf.readEntry("RotationDuration", 0);
float opacity = conf.readEntry( "Opacity", 80 ); float opacity = conf.readEntry("Opacity", 80);
bool desktopOpacityOnly = conf.readEntry( "OpacityDesktopOnly", false ); bool desktopOpacityOnly = conf.readEntry("OpacityDesktopOnly", false);
bool desktopName = conf.readEntry( "DisplayDesktopName", true ); bool desktopName = conf.readEntry("DisplayDesktopName", true);
bool reflection = conf.readEntry( "Reflection", true ); bool reflection = conf.readEntry("Reflection", true);
QColor background = conf.readEntry( "BackgroundColor", QColor( Qt::black ) ); QColor background = conf.readEntry("BackgroundColor", QColor(Qt::black));
QColor capColor = conf.readEntry( "CapColor", KColorScheme( QPalette::Active, KColorScheme::Window ).background().color() ); QColor capColor = conf.readEntry("CapColor", KColorScheme(QPalette::Active, KColorScheme::Window).background().color());
bool texturedCaps = conf.readEntry( "TexturedCaps", true ); bool texturedCaps = conf.readEntry("TexturedCaps", true);
bool caps = conf.readEntry( "Caps", true ); bool caps = conf.readEntry("Caps", true);
bool closeOnMouseRelease = conf.readEntry( "CloseOnMouseRelease", false ); bool closeOnMouseRelease = conf.readEntry("CloseOnMouseRelease", false);
bool walkThroughDesktop = conf.readEntry( "TabBox", false ); bool walkThroughDesktop = conf.readEntry("TabBox", false);
m_ui->zPositionSlider->setValue( conf.readEntry( "ZPosition", 100 ) ); m_ui->zPositionSlider->setValue(conf.readEntry("ZPosition", 100));
m_ui->wallpaperRequester->setUrl( KUrl( conf.readEntry( "Wallpaper", "" ) )); m_ui->wallpaperRequester->setUrl(KUrl(conf.readEntry("Wallpaper", "")));
bool invertKeys = conf.readEntry( "InvertKeys", false ); bool invertKeys = conf.readEntry("InvertKeys", false);
bool invertMouse = conf.readEntry( "InvertMouse", false ); bool invertMouse = conf.readEntry("InvertMouse", false);
m_ui->capDeformationSlider->setValue( conf.readEntry( "CapDeformation", 0 ) ); m_ui->capDeformationSlider->setValue(conf.readEntry("CapDeformation", 0));
bool zOrdering = conf.readEntry( "ZOrdering", false ); bool zOrdering = conf.readEntry("ZOrdering", false);
m_ui->rotationDurationSpin->setValue( duration ); m_ui->rotationDurationSpin->setValue(duration);
m_ui->rotationDurationSpin->setSuffix( ki18np( " millisecond", " milliseconds" ) ); m_ui->rotationDurationSpin->setSuffix(ki18np(" millisecond", " milliseconds"));
m_ui->cubeOpacitySlider->setValue( opacity ); m_ui->cubeOpacitySlider->setValue(opacity);
m_ui->cubeOpacitySpin->setValue( opacity ); m_ui->cubeOpacitySpin->setValue(opacity);
m_ui->desktopOpacityOnlyBox->setChecked( desktopOpacityOnly ); m_ui->desktopOpacityOnlyBox->setChecked(desktopOpacityOnly);
if( desktopName ) if (desktopName) {
{ m_ui->displayDesktopNameBox->setCheckState(Qt::Checked);
m_ui->displayDesktopNameBox->setCheckState( Qt::Checked ); } else {
} m_ui->displayDesktopNameBox->setCheckState(Qt::Unchecked);
else }
{ if (reflection) {
m_ui->displayDesktopNameBox->setCheckState( Qt::Unchecked ); m_ui->reflectionBox->setCheckState(Qt::Checked);
} } else {
if( reflection ) m_ui->reflectionBox->setCheckState(Qt::Unchecked);
{ }
m_ui->reflectionBox->setCheckState( Qt::Checked ); if (caps) {
} m_ui->cubeCapsBox->setCheckState(Qt::Checked);
else } else {
{ m_ui->cubeCapsBox->setCheckState(Qt::Unchecked);
m_ui->reflectionBox->setCheckState( Qt::Unchecked ); }
} if (texturedCaps) {
if( caps ) m_ui->capsImageBox->setCheckState(Qt::Checked);
{ } else {
m_ui->cubeCapsBox->setCheckState( Qt::Checked ); m_ui->capsImageBox->setCheckState(Qt::Unchecked);
} }
else if (closeOnMouseRelease) {
{ m_ui->closeOnMouseReleaseBox->setCheckState(Qt::Checked);
m_ui->cubeCapsBox->setCheckState( Qt::Unchecked ); } else {
} m_ui->closeOnMouseReleaseBox->setCheckState(Qt::Unchecked);
if( texturedCaps ) }
{ if (walkThroughDesktop) {
m_ui->capsImageBox->setCheckState( Qt::Checked ); m_ui->walkThroughDesktopBox->setCheckState(Qt::Checked);
} } else {
else m_ui->walkThroughDesktopBox->setCheckState(Qt::Unchecked);
{ }
m_ui->capsImageBox->setCheckState( Qt::Unchecked ); m_ui->backgroundColorButton->setColor(background);
} m_ui->capColorButton->setColor(capColor);
if( closeOnMouseRelease ) m_ui->invertKeysBox->setChecked(invertKeys);
{ m_ui->invertMouseBox->setChecked(invertMouse);
m_ui->closeOnMouseReleaseBox->setCheckState( Qt::Checked ); m_ui->zOrderingBox->setChecked(zOrdering);
}
else
{
m_ui->closeOnMouseReleaseBox->setCheckState( Qt::Unchecked );
}
if( walkThroughDesktop )
{
m_ui->walkThroughDesktopBox->setCheckState( Qt::Checked );
}
else
{
m_ui->walkThroughDesktopBox->setCheckState( Qt::Unchecked );
}
m_ui->backgroundColorButton->setColor( background );
m_ui->capColorButton->setColor( capColor );
m_ui->invertKeysBox->setChecked( invertKeys );
m_ui->invertMouseBox->setChecked( invertMouse );
m_ui->zOrderingBox->setChecked( zOrdering );
capsSelectionChanged(); capsSelectionChanged();
emit changed(false); emit changed(false);
} }
void CubeEffectConfig::save() void CubeEffectConfig::save()
{ {
KConfigGroup conf = EffectsHandler::effectConfig( "Cube" ); KConfigGroup conf = EffectsHandler::effectConfig("Cube");
conf.writeEntry( "RotationDuration", m_ui->rotationDurationSpin->value() ); conf.writeEntry("RotationDuration", m_ui->rotationDurationSpin->value());
conf.writeEntry( "DisplayDesktopName", m_ui->displayDesktopNameBox->checkState() == Qt::Checked ? true : false ); conf.writeEntry("DisplayDesktopName", m_ui->displayDesktopNameBox->checkState() == Qt::Checked ? true : false);
conf.writeEntry( "Reflection", m_ui->reflectionBox->checkState() == Qt::Checked ? true : false ); conf.writeEntry("Reflection", m_ui->reflectionBox->checkState() == Qt::Checked ? true : false);
conf.writeEntry( "Opacity", m_ui->cubeOpacitySpin->value() ); conf.writeEntry("Opacity", m_ui->cubeOpacitySpin->value());
conf.writeEntry( "OpacityDesktopOnly", m_ui->desktopOpacityOnlyBox->isChecked() ); conf.writeEntry("OpacityDesktopOnly", m_ui->desktopOpacityOnlyBox->isChecked());
conf.writeEntry( "BackgroundColor", m_ui->backgroundColorButton->color() ); conf.writeEntry("BackgroundColor", m_ui->backgroundColorButton->color());
conf.writeEntry( "Caps", m_ui->cubeCapsBox->checkState() == Qt::Checked ? true : false ); conf.writeEntry("Caps", m_ui->cubeCapsBox->checkState() == Qt::Checked ? true : false);
conf.writeEntry( "CapColor", m_ui->capColorButton->color() ); conf.writeEntry("CapColor", m_ui->capColorButton->color());
conf.writeEntry( "TexturedCaps", m_ui->capsImageBox->checkState() == Qt::Checked ? true : false ); conf.writeEntry("TexturedCaps", m_ui->capsImageBox->checkState() == Qt::Checked ? true : false);
conf.writeEntry( "CloseOnMouseRelease", m_ui->closeOnMouseReleaseBox->checkState() == Qt::Checked ? true : false ); conf.writeEntry("CloseOnMouseRelease", m_ui->closeOnMouseReleaseBox->checkState() == Qt::Checked ? true : false);
conf.writeEntry( "Wallpaper", m_ui->wallpaperRequester->url().path() ); conf.writeEntry("Wallpaper", m_ui->wallpaperRequester->url().path());
conf.writeEntry( "ZPosition", m_ui->zPositionSlider->value() ); conf.writeEntry("ZPosition", m_ui->zPositionSlider->value());
conf.writeEntry( "TabBox", m_ui->walkThroughDesktopBox->checkState() == Qt::Checked ? true : false ); conf.writeEntry("TabBox", m_ui->walkThroughDesktopBox->checkState() == Qt::Checked ? true : false);
conf.writeEntry( "InvertKeys", m_ui->invertKeysBox->isChecked() ); conf.writeEntry("InvertKeys", m_ui->invertKeysBox->isChecked());
conf.writeEntry( "InvertMouse", m_ui->invertMouseBox->isChecked() ); conf.writeEntry("InvertMouse", m_ui->invertMouseBox->isChecked());
conf.writeEntry( "CapDeformation", m_ui->capDeformationSlider->value() ); conf.writeEntry("CapDeformation", m_ui->capDeformationSlider->value());
conf.writeEntry( "ZOrdering", m_ui->zOrderingBox->isChecked() ); conf.writeEntry("ZOrdering", m_ui->zOrderingBox->isChecked());
m_ui->editor->save(); m_ui->editor->save();
conf.sync(); conf.sync();
emit changed(false); emit changed(false);
EffectsHandler::sendReloadMessage( "cube" ); EffectsHandler::sendReloadMessage("cube");
} }
void CubeEffectConfig::defaults() void CubeEffectConfig::defaults()
{ {
m_ui->rotationDurationSpin->setValue( 0 ); m_ui->rotationDurationSpin->setValue(0);
m_ui->displayDesktopNameBox->setCheckState( Qt::Checked ); m_ui->displayDesktopNameBox->setCheckState(Qt::Checked);
m_ui->reflectionBox->setCheckState( Qt::Checked ); m_ui->reflectionBox->setCheckState(Qt::Checked);
m_ui->cubeOpacitySpin->setValue( 80 ); m_ui->cubeOpacitySpin->setValue(80);
m_ui->cubeOpacitySlider->setValue( 80 ); m_ui->cubeOpacitySlider->setValue(80);
m_ui->desktopOpacityOnlyBox->setChecked( false ); m_ui->desktopOpacityOnlyBox->setChecked(false);
m_ui->backgroundColorButton->setColor( QColor( Qt::black ) ); m_ui->backgroundColorButton->setColor(QColor(Qt::black));
m_ui->cubeCapsBox->setCheckState( Qt::Checked ); m_ui->cubeCapsBox->setCheckState(Qt::Checked);
m_ui->capColorButton->setColor( KColorScheme( QPalette::Active, KColorScheme::Window ).background().color() ); m_ui->capColorButton->setColor(KColorScheme(QPalette::Active, KColorScheme::Window).background().color());
m_ui->capsImageBox->setCheckState( Qt::Checked ); m_ui->capsImageBox->setCheckState(Qt::Checked);
m_ui->closeOnMouseReleaseBox->setCheckState( Qt::Unchecked ); m_ui->closeOnMouseReleaseBox->setCheckState(Qt::Unchecked);
m_ui->wallpaperRequester->setUrl( KUrl( "" )); m_ui->wallpaperRequester->setUrl(KUrl(""));
m_ui->zPositionSlider->setValue( 100 ); m_ui->zPositionSlider->setValue(100);
m_ui->walkThroughDesktopBox->setCheckState( Qt::Unchecked ); m_ui->walkThroughDesktopBox->setCheckState(Qt::Unchecked);
m_ui->invertKeysBox->setChecked( false ); m_ui->invertKeysBox->setChecked(false);
m_ui->invertMouseBox->setChecked( false ); m_ui->invertMouseBox->setChecked(false);
m_ui->capDeformationSlider->setValue( 0 ); m_ui->capDeformationSlider->setValue(0);
m_ui->zOrderingBox->setChecked( false ); m_ui->zOrderingBox->setChecked(false);
m_ui->editor->allDefault(); m_ui->editor->allDefault();
emit changed(true); emit changed(true);
} }
void CubeEffectConfig::capsSelectionChanged() void CubeEffectConfig::capsSelectionChanged()
{ {
if( m_ui->cubeCapsBox->checkState() == Qt::Checked ) if (m_ui->cubeCapsBox->checkState() == Qt::Checked) {
{
// activate cap color // activate cap color
m_ui->capColorButton->setEnabled( true ); m_ui->capColorButton->setEnabled(true);
m_ui->capColorLabel->setEnabled( true ); m_ui->capColorLabel->setEnabled(true);
m_ui->capsImageBox->setEnabled( true ); m_ui->capsImageBox->setEnabled(true);
} } else {
else
{
// deactivate cap color // deactivate cap color
m_ui->capColorButton->setEnabled( false ); m_ui->capColorButton->setEnabled(false);
m_ui->capColorLabel->setEnabled( false ); m_ui->capColorLabel->setEnabled(false);
m_ui->capsImageBox->setEnabled( false ); m_ui->capsImageBox->setEnabled(false);
} }
} }
} // namespace } // namespace

View File

@ -32,27 +32,27 @@ namespace KWin
class CubeEffectConfigForm : public QWidget, public Ui::CubeEffectConfigForm class CubeEffectConfigForm : public QWidget, public Ui::CubeEffectConfigForm
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit CubeEffectConfigForm(QWidget* parent); explicit CubeEffectConfigForm(QWidget* parent);
}; };
class CubeEffectConfig : public KCModule class CubeEffectConfig : public KCModule
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit CubeEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList()); explicit CubeEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
public slots: public slots:
virtual void save(); virtual void save();
virtual void load(); virtual void load();
virtual void defaults(); virtual void defaults();
private slots: private slots:
void capsSelectionChanged(); void capsSelectionChanged();
private: private:
CubeEffectConfigForm* m_ui; CubeEffectConfigForm* m_ui;
KActionCollection* m_actionCollection; KActionCollection* m_actionCollection;
}; };
} // namespace } // namespace

View File

@ -27,12 +27,12 @@ namespace KWin
class CubeInsideEffect : public Effect class CubeInsideEffect : public Effect
{ {
public: public:
CubeInsideEffect() {} CubeInsideEffect() {}
virtual ~CubeInsideEffect() {} virtual ~CubeInsideEffect() {}
virtual void paint() = 0; virtual void paint() = 0;
virtual void setActive( bool active ) = 0; virtual void setActive(bool active) = 0;
}; };
} // namespace } // namespace

View File

@ -25,23 +25,23 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
namespace KWin namespace KWin
{ {
CubeEffectProxy::CubeEffectProxy( CubeEffect* effect ) CubeEffectProxy::CubeEffectProxy(CubeEffect* effect)
: m_effect( effect ) : m_effect(effect)
{ {
} }
CubeEffectProxy::~CubeEffectProxy() CubeEffectProxy::~CubeEffectProxy()
{ {
} }
void CubeEffectProxy::registerCubeInsideEffect( CubeInsideEffect* effect ) void CubeEffectProxy::registerCubeInsideEffect(CubeInsideEffect* effect)
{ {
m_effect->registerCubeInsideEffect( effect ); m_effect->registerCubeInsideEffect(effect);
} }
void CubeEffectProxy::unregisterCubeInsideEffect( CubeInsideEffect* effect ) void CubeEffectProxy::unregisterCubeInsideEffect(CubeInsideEffect* effect)
{ {
m_effect->unregisterCubeInsideEffect( effect ); m_effect->unregisterCubeInsideEffect(effect);
} }
} // namespace } // namespace

View File

@ -29,15 +29,15 @@ class CubeInsideEffect;
class CubeEffectProxy class CubeEffectProxy
{ {
public: public:
CubeEffectProxy( CubeEffect* effect ); CubeEffectProxy(CubeEffect* effect);
~CubeEffectProxy(); ~CubeEffectProxy();
void registerCubeInsideEffect( CubeInsideEffect* effect ); void registerCubeInsideEffect(CubeInsideEffect* effect);
void unregisterCubeInsideEffect( CubeInsideEffect* effect ); void unregisterCubeInsideEffect(CubeInsideEffect* effect);
private: private:
CubeEffect* m_effect; CubeEffect* m_effect;
}; };
} // namespace } // namespace

File diff suppressed because it is too large Load Diff

View File

@ -30,48 +30,47 @@ namespace KWin
{ {
class CubeSlideEffect class CubeSlideEffect
: public Effect : public Effect
{ {
public: public:
CubeSlideEffect(); CubeSlideEffect();
~CubeSlideEffect(); ~CubeSlideEffect();
virtual void reconfigure( ReconfigureFlags ); virtual void reconfigure(ReconfigureFlags);
virtual void prePaintScreen( ScreenPrePaintData& data, int time ); virtual void prePaintScreen(ScreenPrePaintData& data, int time);
virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data ); virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data);
virtual void postPaintScreen(); virtual void postPaintScreen();
virtual void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time ); virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time);
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
virtual void desktopChanged( int old ); virtual void desktopChanged(int old);
virtual void windowUserMovedResized( EffectWindow* c, bool first, bool last ); virtual void windowUserMovedResized(EffectWindow* c, bool first, bool last);
static bool supported(); static bool supported();
private: private:
enum RotationDirection enum RotationDirection {
{ Left,
Left, Right,
Right, Upwards,
Upwards, Downwards
Downwards
};
void paintSlideCube( int mask, QRegion region, ScreenPaintData& data );
void windowMovingChanged( float progress, RotationDirection direction );
bool cube_painting;
int front_desktop;
int painting_desktop;
int other_desktop;
bool firstDesktop;
TimeLine timeLine;
QQueue<RotationDirection> slideRotations;
QSet<EffectWindow*> panels;
QSet<EffectWindow*> stickyWindows;
bool dontSlidePanels;
bool dontSlideStickyWindows;
bool usePagerLayout;
int rotationDuration;
bool useWindowMoving;
bool windowMoving;
bool desktopChangedWhileMoving;
double progressRestriction;
}; };
void paintSlideCube(int mask, QRegion region, ScreenPaintData& data);
void windowMovingChanged(float progress, RotationDirection direction);
bool cube_painting;
int front_desktop;
int painting_desktop;
int other_desktop;
bool firstDesktop;
TimeLine timeLine;
QQueue<RotationDirection> slideRotations;
QSet<EffectWindow*> panels;
QSet<EffectWindow*> stickyWindows;
bool dontSlidePanels;
bool dontSlideStickyWindows;
bool usePagerLayout;
int rotationDuration;
bool useWindowMoving;
bool windowMoving;
bool desktopChangedWhileMoving;
double progressRestriction;
};
} }
#endif #endif

View File

@ -30,12 +30,12 @@ KWIN_EFFECT_CONFIG_FACTORY
CubeSlideEffectConfigForm::CubeSlideEffectConfigForm(QWidget* parent) : QWidget(parent) CubeSlideEffectConfigForm::CubeSlideEffectConfigForm(QWidget* parent) : QWidget(parent)
{ {
setupUi(this); setupUi(this);
} }
CubeSlideEffectConfig::CubeSlideEffectConfig(QWidget* parent, const QVariantList& args) : CubeSlideEffectConfig::CubeSlideEffectConfig(QWidget* parent, const QVariantList& args) :
KCModule(EffectFactory::componentData(), parent, args) KCModule(EffectFactory::componentData(), parent, args)
{ {
m_ui = new CubeSlideEffectConfigForm(this); m_ui = new CubeSlideEffectConfigForm(this);
QVBoxLayout* layout = new QVBoxLayout(this); QVBoxLayout* layout = new QVBoxLayout(this);
@ -49,53 +49,53 @@ CubeSlideEffectConfig::CubeSlideEffectConfig(QWidget* parent, const QVariantList
connect(m_ui->windowsMovingBox, SIGNAL(stateChanged(int)), SLOT(changed())); connect(m_ui->windowsMovingBox, SIGNAL(stateChanged(int)), SLOT(changed()));
load(); load();
} }
void CubeSlideEffectConfig::load() void CubeSlideEffectConfig::load()
{ {
KCModule::load(); KCModule::load();
KConfigGroup conf = EffectsHandler::effectConfig( "CubeSlide" ); KConfigGroup conf = EffectsHandler::effectConfig("CubeSlide");
int duration = conf.readEntry( "RotationDuration", 0 ); int duration = conf.readEntry("RotationDuration", 0);
bool dontSlidePanels = conf.readEntry( "DontSlidePanels", true ); bool dontSlidePanels = conf.readEntry("DontSlidePanels", true);
bool dontSlideStickyWindows = conf.readEntry( "DontSlideStickyWindows", false ); bool dontSlideStickyWindows = conf.readEntry("DontSlideStickyWindows", false);
bool usePager = conf.readEntry( "UsePagerLayout", true ); bool usePager = conf.readEntry("UsePagerLayout", true);
m_ui->rotationDurationSpin->setValue( duration ); m_ui->rotationDurationSpin->setValue(duration);
m_ui->dontSlidePanelsBox->setChecked( dontSlidePanels ); m_ui->dontSlidePanelsBox->setChecked(dontSlidePanels);
m_ui->dontSlideStickyWindowsBox->setChecked( dontSlideStickyWindows ); m_ui->dontSlideStickyWindowsBox->setChecked(dontSlideStickyWindows);
m_ui->usePagerBox->setChecked( usePager ); m_ui->usePagerBox->setChecked(usePager);
m_ui->windowsMovingBox->setChecked( conf.readEntry( "UseWindowMoving", false ) ); m_ui->windowsMovingBox->setChecked(conf.readEntry("UseWindowMoving", false));
emit changed(false); emit changed(false);
} }
void CubeSlideEffectConfig::save() void CubeSlideEffectConfig::save()
{ {
KConfigGroup conf = EffectsHandler::effectConfig( "CubeSlide" ); KConfigGroup conf = EffectsHandler::effectConfig("CubeSlide");
conf.writeEntry( "RotationDuration", m_ui->rotationDurationSpin->value() ); conf.writeEntry("RotationDuration", m_ui->rotationDurationSpin->value());
conf.writeEntry( "DontSlidePanels", m_ui->dontSlidePanelsBox->isChecked() ); conf.writeEntry("DontSlidePanels", m_ui->dontSlidePanelsBox->isChecked());
conf.writeEntry( "DontSlideStickyWindows", m_ui->dontSlideStickyWindowsBox->isChecked() ); conf.writeEntry("DontSlideStickyWindows", m_ui->dontSlideStickyWindowsBox->isChecked());
conf.writeEntry( "UsePagerLayout", m_ui->usePagerBox->isChecked() ); conf.writeEntry("UsePagerLayout", m_ui->usePagerBox->isChecked());
conf.writeEntry( "UseWindowMoving", m_ui->windowsMovingBox->isChecked() ); conf.writeEntry("UseWindowMoving", m_ui->windowsMovingBox->isChecked());
conf.sync(); conf.sync();
emit changed(false); emit changed(false);
EffectsHandler::sendReloadMessage( "cubeslide" ); EffectsHandler::sendReloadMessage("cubeslide");
} }
void CubeSlideEffectConfig::defaults() void CubeSlideEffectConfig::defaults()
{ {
m_ui->rotationDurationSpin->setValue( 0 ); m_ui->rotationDurationSpin->setValue(0);
m_ui->dontSlidePanelsBox->setChecked( true ); m_ui->dontSlidePanelsBox->setChecked(true);
m_ui->dontSlideStickyWindowsBox->setChecked( false ); m_ui->dontSlideStickyWindowsBox->setChecked(false);
m_ui->usePagerBox->setChecked( true ); m_ui->usePagerBox->setChecked(true);
m_ui->windowsMovingBox->setChecked( false ); m_ui->windowsMovingBox->setChecked(false);
emit changed(true); emit changed(true);
} }
} // namespace } // namespace

View File

@ -32,23 +32,23 @@ namespace KWin
class CubeSlideEffectConfigForm : public QWidget, public Ui::CubeSlideEffectConfigForm class CubeSlideEffectConfigForm : public QWidget, public Ui::CubeSlideEffectConfigForm
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit CubeSlideEffectConfigForm(QWidget* parent); explicit CubeSlideEffectConfigForm(QWidget* parent);
}; };
class CubeSlideEffectConfig : public KCModule class CubeSlideEffectConfig : public KCModule
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit CubeSlideEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList()); explicit CubeSlideEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
public slots: public slots:
virtual void save(); virtual void save();
virtual void load(); virtual void load();
virtual void defaults(); virtual void defaults();
private: private:
CubeSlideEffectConfigForm* m_ui; CubeSlideEffectConfigForm* m_ui;
}; };
} // namespace } // namespace

View File

@ -25,41 +25,41 @@ namespace KWin
KWIN_EFFECT(dashboard, DashboardEffect) KWIN_EFFECT(dashboard, DashboardEffect)
DashboardEffect::DashboardEffect() DashboardEffect::DashboardEffect()
: transformWindow( false ) : transformWindow(false)
, activateAnimation( false ) , activateAnimation(false)
, deactivateAnimation( false ) , deactivateAnimation(false)
{ {
// propagate that the effect is loaded // propagate that the effect is loaded
propagate(); propagate();
// read settings // read settings
reconfigure(ReconfigureAll); reconfigure(ReconfigureAll);
} }
DashboardEffect::~DashboardEffect() DashboardEffect::~DashboardEffect()
{ {
unpropagate(); unpropagate();
} }
void DashboardEffect::propagate() void DashboardEffect::propagate()
{ {
// TODO: better namespacing for atoms // TODO: better namespacing for atoms
atom = XInternAtom( display(), "_WM_EFFECT_KDE_DASHBOARD", false ); atom = XInternAtom(display(), "_WM_EFFECT_KDE_DASHBOARD", false);
effects->registerPropertyType( atom, true ); effects->registerPropertyType(atom, true);
// TODO: maybe not the best way to propagate the loaded effect // TODO: maybe not the best way to propagate the loaded effect
unsigned char dummy = 0; unsigned char dummy = 0;
XChangeProperty( display(), rootWindow(), atom, atom, 8, PropModeReplace, &dummy, 1 ); XChangeProperty(display(), rootWindow(), atom, atom, 8, PropModeReplace, &dummy, 1);
} }
void DashboardEffect::unpropagate() void DashboardEffect::unpropagate()
{ {
effects->registerPropertyType(atom, false); effects->registerPropertyType(atom, false);
XDeleteProperty(display(), rootWindow(), atom); XDeleteProperty(display(), rootWindow(), atom);
} }
void DashboardEffect::reconfigure( ReconfigureFlags ) void DashboardEffect::reconfigure(ReconfigureFlags)
{ {
// read settings again // read settings again
KConfigGroup config = EffectsHandler::effectConfig("Dashboard"); KConfigGroup config = EffectsHandler::effectConfig("Dashboard");
@ -69,153 +69,132 @@ void DashboardEffect::reconfigure( ReconfigureFlags )
blur = config.readEntry("Blur", false); blur = config.readEntry("Blur", false);
timeline.setDuration( animationTime( duration.toInt() ) ); timeline.setDuration(animationTime(duration.toInt()));
} }
void DashboardEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ) void DashboardEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{ {
if( transformWindow && ( w != window ) && w->isManaged() && !isDashboard( w ) ) if (transformWindow && (w != window) && w->isManaged() && !isDashboard(w)) {
{
brightnessDelta = (1 - (brightness.toDouble() / 100)); brightnessDelta = (1 - (brightness.toDouble() / 100));
saturationDelta = (1 - (saturation.toDouble() / 100)); saturationDelta = (1 - (saturation.toDouble() / 100));
// dashboard active, transform other windows // dashboard active, transform other windows
data.brightness *= (1 - (brightnessDelta * timeline.value())); data.brightness *= (1 - (brightnessDelta * timeline.value()));
data.saturation *= (1 - (saturationDelta * timeline.value())); data.saturation *= (1 - (saturationDelta * timeline.value()));
} }
else if( transformWindow && ( w == window ) && w->isManaged() ) else if (transformWindow && (w == window) && w->isManaged()) {
{
// transform dashboard // transform dashboard
if ((timeline.value() * 2) <= 1) if ((timeline.value() * 2) <= 1) {
{
data.opacity *= timeline.value() * 2; data.opacity *= timeline.value() * 2;
} } else {
else
{
data.opacity *= 1; data.opacity *= 1;
}
} }
effects->paintWindow( w, mask, region, data );
} }
void DashboardEffect::prePaintScreen( ScreenPrePaintData& data, int time ) effects->paintWindow(w, mask, region, data);
{ }
if( transformWindow )
{ void DashboardEffect::prePaintScreen(ScreenPrePaintData& data, int time)
if( activateAnimation ) {
timeline.addTime( time ); if (transformWindow) {
if( deactivateAnimation ) if (activateAnimation)
timeline.removeTime( time ); timeline.addTime(time);
} if (deactivateAnimation)
timeline.removeTime(time);
}
effects->prePaintScreen(data, time); effects->prePaintScreen(data, time);
} }
void DashboardEffect::postPaintScreen() void DashboardEffect::postPaintScreen()
{ {
if( transformWindow ) if (transformWindow) {
{ if (retransformWindow) {
if( retransformWindow )
{
retransformWindow = false; retransformWindow = false;
transformWindow = false; transformWindow = false;
effects->addRepaintFull(); effects->addRepaintFull();
effects->setActiveFullScreenEffect( 0 ); effects->setActiveFullScreenEffect(0);
} }
if( activateAnimation ) if (activateAnimation) {
{ if (timeline.value() == 1.0)
if( timeline.value() == 1.0 )
activateAnimation = false; activateAnimation = false;
effects->addRepaintFull(); effects->addRepaintFull();
} }
if( deactivateAnimation ) if (deactivateAnimation) {
{ if (timeline.value() == 0.0) {
if( timeline.value() == 0.0 )
{
deactivateAnimation = false; deactivateAnimation = false;
transformWindow = false; transformWindow = false;
effects->setActiveFullScreenEffect( 0 ); effects->setActiveFullScreenEffect(0);
} }
effects->addRepaintFull(); effects->addRepaintFull();
}
} }
}
effects->postPaintScreen(); effects->postPaintScreen();
} }
bool DashboardEffect::isDashboard ( EffectWindow *w ) bool DashboardEffect::isDashboard(EffectWindow *w)
{ {
if( w->windowClass() == "dashboard dashboard") if (w->windowClass() == "dashboard dashboard") {
{
return true; return true;
} } else {
else
{
return false; return false;
}
} }
}
void DashboardEffect::windowActivated( EffectWindow *w ) void DashboardEffect::windowActivated(EffectWindow *w)
{ {
if( !w ) if (!w)
return; return;
// apply effect on dashboard activation // apply effect on dashboard activation
if( isDashboard( w ) ) if (isDashboard(w)) {
{ effects->setActiveFullScreenEffect(this);
effects->setActiveFullScreenEffect( this );
transformWindow = true; transformWindow = true;
window = w; window = w;
if ( blur ) if (blur) {
{ w->setData(WindowBlurBehindRole, w->geometry());
w->setData( WindowBlurBehindRole, w->geometry() ); }
}
effects->addRepaintFull(); effects->addRepaintFull();
} } else {
else if (transformWindow) {
{
if( transformWindow)
{
retransformWindow = true; retransformWindow = true;
effects->addRepaintFull(); effects->addRepaintFull();
}
} }
} }
}
void DashboardEffect::windowAdded( EffectWindow* w ) void DashboardEffect::windowAdded(EffectWindow* w)
{ {
propertyNotify( w, atom ); propertyNotify(w, atom);
if( isDashboard( w ) ) if (isDashboard(w)) {
{
// Tell other windowAdded() effects to ignore this window // Tell other windowAdded() effects to ignore this window
w->setData( WindowAddedGrabRole, QVariant::fromValue( static_cast<void*>( this ))); w->setData(WindowAddedGrabRole, QVariant::fromValue(static_cast<void*>(this)));
activateAnimation = true; activateAnimation = true;
deactivateAnimation = false; deactivateAnimation = false;
timeline.setProgress( 0.0 ); timeline.setProgress(0.0);
w->addRepaintFull(); w->addRepaintFull();
}
} }
}
void DashboardEffect::windowClosed( EffectWindow* w ) void DashboardEffect::windowClosed(EffectWindow* w)
{ {
propertyNotify( w, atom ); propertyNotify(w, atom);
if( isDashboard( w ) ) if (isDashboard(w)) {
{
// Tell other windowClosed() effects to ignore this window // Tell other windowClosed() effects to ignore this window
w->setData( WindowClosedGrabRole, QVariant::fromValue( static_cast<void*>( this ))); w->setData(WindowClosedGrabRole, QVariant::fromValue(static_cast<void*>(this)));
w->addRepaintFull(); w->addRepaintFull();
}
} }
}
} // namespace } // namespace

View File

@ -31,35 +31,35 @@ namespace KWin
class DashboardEffect : public KWin::Effect class DashboardEffect : public KWin::Effect
{ {
public: public:
DashboardEffect(); DashboardEffect();
~DashboardEffect(); ~DashboardEffect();
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
virtual void prePaintScreen( ScreenPrePaintData& data, int time ); virtual void prePaintScreen(ScreenPrePaintData& data, int time);
virtual void postPaintScreen(); virtual void postPaintScreen();
virtual void propagate(); virtual void propagate();
virtual void reconfigure( ReconfigureFlags ); virtual void reconfigure(ReconfigureFlags);
virtual void unpropagate(); virtual void unpropagate();
virtual void windowActivated( EffectWindow *w ); virtual void windowActivated(EffectWindow *w);
virtual void windowAdded( EffectWindow* c ); virtual void windowAdded(EffectWindow* c);
virtual void windowClosed( EffectWindow* c ); virtual void windowClosed(EffectWindow* c);
private: private:
bool blur; bool blur;
bool isDashboard( EffectWindow* w ); bool isDashboard(EffectWindow* w);
bool transformWindow; bool transformWindow;
bool retransformWindow; bool retransformWindow;
bool activateAnimation; bool activateAnimation;
bool deactivateAnimation; bool deactivateAnimation;
TimeLine timeline; TimeLine timeline;
long atom; long atom;
QString brightness; QString brightness;
double brightnessDelta; double brightnessDelta;
QString saturation; QString saturation;
double saturationDelta; double saturationDelta;
QString duration; QString duration;
EffectWindow* window; EffectWindow* window;
}; };
} // namespace } // namespace

View File

@ -39,7 +39,7 @@ public:
void defaults(); void defaults();
private: private:
bool isBlurEffectAvailable (); bool isBlurEffectAvailable();
long net_wm_dashboard; long net_wm_dashboard;
::Ui::DashboardEffectConfig ui; ::Ui::DashboardEffectConfig ui;

File diff suppressed because it is too large Load Diff

View File

@ -38,122 +38,122 @@ namespace KWin
class PresentWindowsEffectProxy; class PresentWindowsEffectProxy;
class DesktopButtonsView : public QGraphicsView class DesktopButtonsView : public QGraphicsView
{ {
Q_OBJECT Q_OBJECT
public: public:
DesktopButtonsView( QWidget* parent = 0 ); DesktopButtonsView(QWidget* parent = 0);
void windowInputMouseEvent( QMouseEvent* e ); void windowInputMouseEvent(QMouseEvent* e);
void setAddDesktopEnabled( bool enable ); void setAddDesktopEnabled(bool enable);
void setRemoveDesktopEnabled( bool enable ); void setRemoveDesktopEnabled(bool enable);
virtual void drawBackground( QPainter* painter, const QRectF& rect ); virtual void drawBackground(QPainter* painter, const QRectF& rect);
Q_SIGNALS: Q_SIGNALS:
void addDesktop(); void addDesktop();
void removeDesktop(); void removeDesktop();
private: private:
Plasma::PushButton* m_addDesktopButton; Plasma::PushButton* m_addDesktopButton;
Plasma::PushButton* m_removeDesktopButton; Plasma::PushButton* m_removeDesktopButton;
Plasma::FrameSvg* m_frame; Plasma::FrameSvg* m_frame;
}; };
class DesktopGridEffect class DesktopGridEffect
: public QObject, public Effect : public QObject, public Effect
{ {
Q_OBJECT Q_OBJECT
public: public:
DesktopGridEffect(); DesktopGridEffect();
~DesktopGridEffect(); ~DesktopGridEffect();
virtual void reconfigure( ReconfigureFlags ); virtual void reconfigure(ReconfigureFlags);
virtual void prePaintScreen( ScreenPrePaintData& data, int time ); virtual void prePaintScreen(ScreenPrePaintData& data, int time);
virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data ); virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data);
virtual void postPaintScreen(); virtual void postPaintScreen();
virtual void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time ); virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time);
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
virtual void windowClosed( EffectWindow* w ); virtual void windowClosed(EffectWindow* w);
virtual void windowDeleted( EffectWindow* w ); virtual void windowDeleted(EffectWindow* w);
virtual void windowAdded( EffectWindow* w ); virtual void windowAdded(EffectWindow* w);
virtual void windowGeometryShapeChanged( EffectWindow* w, const QRect& old ); virtual void windowGeometryShapeChanged(EffectWindow* w, const QRect& old);
virtual void windowInputMouseEvent( Window w, QEvent* e ); virtual void windowInputMouseEvent(Window w, QEvent* e);
virtual void grabbedKeyboardEvent( QKeyEvent* e ); virtual void grabbedKeyboardEvent(QKeyEvent* e);
virtual bool borderActivated( ElectricBorder border ); virtual bool borderActivated(ElectricBorder border);
virtual void numberDesktopsChanged( int old ); virtual void numberDesktopsChanged(int old);
enum { LayoutPager, LayoutAutomatic, LayoutCustom }; // Layout modes enum { LayoutPager, LayoutAutomatic, LayoutCustom }; // Layout modes
private slots: private slots:
void toggle(); void toggle();
// slots for global shortcut changed // slots for global shortcut changed
// needed to toggle the effect // needed to toggle the effect
void globalShortcutChanged( const QKeySequence& seq ); void globalShortcutChanged(const QKeySequence& seq);
void slotAddDesktop(); void slotAddDesktop();
void slotRemoveDesktop(); void slotRemoveDesktop();
private: private:
QPointF scalePos( const QPoint& pos, int desktop, int screen = -1 ) const; QPointF scalePos(const QPoint& pos, int desktop, int screen = -1) const;
QPoint unscalePos( const QPoint& pos, int* desktop = NULL ) const; QPoint unscalePos(const QPoint& pos, int* desktop = NULL) const;
int posToDesktop( const QPoint& pos ) const; int posToDesktop(const QPoint& pos) const;
EffectWindow* windowAt( QPoint pos ) const; EffectWindow* windowAt(QPoint pos) const;
void setCurrentDesktop( int desktop ); void setCurrentDesktop(int desktop);
void setHighlightedDesktop( int desktop ); void setHighlightedDesktop(int desktop);
int desktopToRight( int desktop, bool wrap = true ) const; int desktopToRight(int desktop, bool wrap = true) const;
int desktopToLeft( int desktop, bool wrap = true ) const; int desktopToLeft(int desktop, bool wrap = true) const;
int desktopUp( int desktop, bool wrap = true ) const; int desktopUp(int desktop, bool wrap = true) const;
int desktopDown( int desktop, bool wrap = true ) const; int desktopDown(int desktop, bool wrap = true) const;
void setActive( bool active ); void setActive(bool active);
void setup(); void setup();
void setupGrid(); void setupGrid();
void finish(); void finish();
bool isMotionManagerMovingWindows(); bool isMotionManagerMovingWindows();
bool isUsingPresentWindows() const; bool isUsingPresentWindows() const;
QRectF moveGeometryToDesktop( int desktop ) const; QRectF moveGeometryToDesktop(int desktop) const;
void desktopsAdded( int old ); void desktopsAdded(int old);
void desktopsRemoved( int old ); void desktopsRemoved(int old);
QList<ElectricBorder> borderActivate;
int zoomDuration;
int border;
Qt::Alignment desktopNameAlignment;
int layoutMode;
int customLayoutRows;
bool activated;
TimeLine timeline;
int paintingDesktop;
int highlightedDesktop;
Window input;
bool keyboardGrab;
bool wasWindowMove, wasDesktopMove;
EffectWindow* windowMove;
QPoint windowMoveDiff;
QPoint dragStartPos;
// Soft highlighting
QList<TimeLine> hoverTimeline;
QList< EffectFrame* > desktopNames; QList<ElectricBorder> borderActivate;
int zoomDuration;
int border;
Qt::Alignment desktopNameAlignment;
int layoutMode;
int customLayoutRows;
QSize gridSize; bool activated;
Qt::Orientation orientation; TimeLine timeline;
QPoint activeCell; int paintingDesktop;
// Per screen variables int highlightedDesktop;
QList<double> scale; // Because the border isn't a ratio each screen is different Window input;
QList<double> unscaledBorder; bool keyboardGrab;
QList<QSizeF> scaledSize; bool wasWindowMove, wasDesktopMove;
QList<QPointF> scaledOffset; EffectWindow* windowMove;
QPoint windowMoveDiff;
QPoint dragStartPos;
// Shortcut - needed to toggle the effect // Soft highlighting
KShortcut shortcut; QList<TimeLine> hoverTimeline;
PresentWindowsEffectProxy* m_proxy; QList< EffectFrame* > desktopNames;
QList<WindowMotionManager> m_managers;
bool m_usePresentWindows;
QRect m_windowMoveGeometry;
QPoint m_windowMoveStartPoint;
QHash< DesktopButtonsView*, EffectWindow* > m_desktopButtonsViews; QSize gridSize;
Qt::Orientation orientation;
QPoint activeCell;
// Per screen variables
QList<double> scale; // Because the border isn't a ratio each screen is different
QList<double> unscaledBorder;
QList<QSizeF> scaledSize;
QList<QPointF> scaledOffset;
}; // Shortcut - needed to toggle the effect
KShortcut shortcut;
PresentWindowsEffectProxy* m_proxy;
QList<WindowMotionManager> m_managers;
bool m_usePresentWindows;
QRect m_windowMoveGeometry;
QPoint m_windowMoveStartPoint;
QHash< DesktopButtonsView*, EffectWindow* > m_desktopButtonsViews;
};
} // namespace } // namespace

View File

@ -35,149 +35,146 @@ KWIN_EFFECT_CONFIG_FACTORY
DesktopGridEffectConfigForm::DesktopGridEffectConfigForm(QWidget* parent) : QWidget(parent) DesktopGridEffectConfigForm::DesktopGridEffectConfigForm(QWidget* parent) : QWidget(parent)
{ {
setupUi(this); setupUi(this);
} }
DesktopGridEffectConfig::DesktopGridEffectConfig(QWidget* parent, const QVariantList& args) DesktopGridEffectConfig::DesktopGridEffectConfig(QWidget* parent, const QVariantList& args)
: KCModule( EffectFactory::componentData(), parent, args ) : KCModule(EffectFactory::componentData(), parent, args)
{ {
m_ui = new DesktopGridEffectConfigForm( this ); m_ui = new DesktopGridEffectConfigForm(this);
QVBoxLayout* layout = new QVBoxLayout( this ); QVBoxLayout* layout = new QVBoxLayout(this);
layout->addWidget( m_ui ); layout->addWidget(m_ui);
// Shortcut config. The shortcut belongs to the component "kwin"! // Shortcut config. The shortcut belongs to the component "kwin"!
m_actionCollection = new KActionCollection( this, KComponentData("kwin") ); m_actionCollection = new KActionCollection(this, KComponentData("kwin"));
m_actionCollection->setConfigGroup( "DesktopGrid" ); m_actionCollection->setConfigGroup("DesktopGrid");
m_actionCollection->setConfigGlobal( true ); m_actionCollection->setConfigGlobal(true);
KAction* a = (KAction*) m_actionCollection->addAction( "ShowDesktopGrid" ); KAction* a = (KAction*) m_actionCollection->addAction("ShowDesktopGrid");
a->setText( i18n( "Show Desktop Grid" )); a->setText(i18n("Show Desktop Grid"));
a->setProperty( "isConfigurationAction", true ); a->setProperty("isConfigurationAction", true);
a->setGlobalShortcut( KShortcut( Qt::CTRL + Qt::Key_F8 )); a->setGlobalShortcut(KShortcut(Qt::CTRL + Qt::Key_F8));
m_ui->shortcutEditor->addCollection( m_actionCollection ); m_ui->shortcutEditor->addCollection(m_actionCollection);
m_alignmentItems.append( Qt::Alignment( 0 )); m_alignmentItems.append(Qt::Alignment(0));
m_ui->desktopNameAlignmentCombo->addItem( i18nc( "Desktop name alignment:", "Disabled" )); m_ui->desktopNameAlignmentCombo->addItem(i18nc("Desktop name alignment:", "Disabled"));
m_alignmentItems.append( Qt::AlignHCenter | Qt::AlignTop ); m_alignmentItems.append(Qt::AlignHCenter | Qt::AlignTop);
m_ui->desktopNameAlignmentCombo->addItem( i18n( "Top" )); m_ui->desktopNameAlignmentCombo->addItem(i18n("Top"));
m_alignmentItems.append( Qt::AlignRight | Qt::AlignTop ); m_alignmentItems.append(Qt::AlignRight | Qt::AlignTop);
m_ui->desktopNameAlignmentCombo->addItem( i18n( "Top-Right" )); m_ui->desktopNameAlignmentCombo->addItem(i18n("Top-Right"));
m_alignmentItems.append( Qt::AlignRight | Qt::AlignVCenter ); m_alignmentItems.append(Qt::AlignRight | Qt::AlignVCenter);
m_ui->desktopNameAlignmentCombo->addItem( i18n( "Right" )); m_ui->desktopNameAlignmentCombo->addItem(i18n("Right"));
m_alignmentItems.append( Qt::AlignRight | Qt::AlignBottom ); m_alignmentItems.append(Qt::AlignRight | Qt::AlignBottom);
m_ui->desktopNameAlignmentCombo->addItem( i18n( "Bottom-Right" )); m_ui->desktopNameAlignmentCombo->addItem(i18n("Bottom-Right"));
m_alignmentItems.append( Qt::AlignHCenter | Qt::AlignBottom ); m_alignmentItems.append(Qt::AlignHCenter | Qt::AlignBottom);
m_ui->desktopNameAlignmentCombo->addItem( i18n( "Bottom" )); m_ui->desktopNameAlignmentCombo->addItem(i18n("Bottom"));
m_alignmentItems.append( Qt::AlignLeft | Qt::AlignBottom ); m_alignmentItems.append(Qt::AlignLeft | Qt::AlignBottom);
m_ui->desktopNameAlignmentCombo->addItem( i18n( "Bottom-Left" )); m_ui->desktopNameAlignmentCombo->addItem(i18n("Bottom-Left"));
m_alignmentItems.append( Qt::AlignLeft | Qt::AlignVCenter ); m_alignmentItems.append(Qt::AlignLeft | Qt::AlignVCenter);
m_ui->desktopNameAlignmentCombo->addItem( i18n( "Left" )); m_ui->desktopNameAlignmentCombo->addItem(i18n("Left"));
m_alignmentItems.append( Qt::AlignLeft | Qt::AlignTop ); m_alignmentItems.append(Qt::AlignLeft | Qt::AlignTop);
m_ui->desktopNameAlignmentCombo->addItem( i18n( "Top-Left" )); m_ui->desktopNameAlignmentCombo->addItem(i18n("Top-Left"));
m_alignmentItems.append( Qt::AlignCenter ); m_alignmentItems.append(Qt::AlignCenter);
m_ui->desktopNameAlignmentCombo->addItem( i18n( "Center" )); m_ui->desktopNameAlignmentCombo->addItem(i18n("Center"));
connect( m_ui->zoomDurationSpin, SIGNAL( valueChanged( int )), this, SLOT( changed() )); connect(m_ui->zoomDurationSpin, SIGNAL(valueChanged(int)), this, SLOT(changed()));
connect( m_ui->borderWidthSpin, SIGNAL( valueChanged( int )), this, SLOT( changed() )); connect(m_ui->borderWidthSpin, SIGNAL(valueChanged(int)), this, SLOT(changed()));
connect( m_ui->desktopNameAlignmentCombo, SIGNAL( currentIndexChanged( int )), this, SLOT( changed() )); connect(m_ui->desktopNameAlignmentCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
connect( m_ui->layoutCombo, SIGNAL( currentIndexChanged( int )), this, SLOT( changed() )); connect(m_ui->layoutCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
connect( m_ui->layoutCombo, SIGNAL( currentIndexChanged( int )), this, SLOT( layoutSelectionChanged() )); connect(m_ui->layoutCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(layoutSelectionChanged()));
connect( m_ui->layoutRowsSpin, SIGNAL( valueChanged( int )), this, SLOT( changed() )); connect(m_ui->layoutRowsSpin, SIGNAL(valueChanged(int)), this, SLOT(changed()));
connect( m_ui->shortcutEditor, SIGNAL( keyChange() ), this, SLOT( changed() )); connect(m_ui->shortcutEditor, SIGNAL(keyChange()), this, SLOT(changed()));
connect( m_ui->presentWindowsCheckBox, SIGNAL( stateChanged( int )), this, SLOT( changed() )); connect(m_ui->presentWindowsCheckBox, SIGNAL(stateChanged(int)), this, SLOT(changed()));
load(); load();
} }
DesktopGridEffectConfig::~DesktopGridEffectConfig() DesktopGridEffectConfig::~DesktopGridEffectConfig()
{ {
// If save() is called undoChanges() has no effect // If save() is called undoChanges() has no effect
m_ui->shortcutEditor->undoChanges(); m_ui->shortcutEditor->undoChanges();
} }
void DesktopGridEffectConfig::load() void DesktopGridEffectConfig::load()
{ {
KCModule::load(); KCModule::load();
KConfigGroup conf = EffectsHandler::effectConfig( "DesktopGrid" ); KConfigGroup conf = EffectsHandler::effectConfig("DesktopGrid");
m_ui->zoomDurationSpin->setValue( conf.readEntry( "ZoomDuration", 0 )); m_ui->zoomDurationSpin->setValue(conf.readEntry("ZoomDuration", 0));
m_ui->zoomDurationSpin->setSuffix( ki18np( " millisecond", " milliseconds")); m_ui->zoomDurationSpin->setSuffix(ki18np(" millisecond", " milliseconds"));
m_ui->borderWidthSpin->setValue( conf.readEntry( "BorderWidth", 10 )); m_ui->borderWidthSpin->setValue(conf.readEntry("BorderWidth", 10));
m_ui->borderWidthSpin->setSuffix( ki18np( " pixel", " pixels")); m_ui->borderWidthSpin->setSuffix(ki18np(" pixel", " pixels"));
Qt::Alignment alignment = Qt::Alignment( conf.readEntry( "DesktopNameAlignment", 0 )); Qt::Alignment alignment = Qt::Alignment(conf.readEntry("DesktopNameAlignment", 0));
m_ui->desktopNameAlignmentCombo->setCurrentIndex( m_alignmentItems.indexOf( alignment )); m_ui->desktopNameAlignmentCombo->setCurrentIndex(m_alignmentItems.indexOf(alignment));
int layoutMode = conf.readEntry( "LayoutMode", int( DesktopGridEffect::LayoutPager )); int layoutMode = conf.readEntry("LayoutMode", int(DesktopGridEffect::LayoutPager));
m_ui->layoutCombo->setCurrentIndex( layoutMode ); m_ui->layoutCombo->setCurrentIndex(layoutMode);
layoutSelectionChanged(); layoutSelectionChanged();
m_ui->layoutRowsSpin->setValue( conf.readEntry( "CustomLayoutRows", 2 )); m_ui->layoutRowsSpin->setValue(conf.readEntry("CustomLayoutRows", 2));
m_ui->layoutRowsSpin->setSuffix( ki18np( " row", " rows")); m_ui->layoutRowsSpin->setSuffix(ki18np(" row", " rows"));
m_ui->presentWindowsCheckBox->setChecked( conf.readEntry( "PresentWindows", true )); m_ui->presentWindowsCheckBox->setChecked(conf.readEntry("PresentWindows", true));
emit changed(false); emit changed(false);
} }
void DesktopGridEffectConfig::save() void DesktopGridEffectConfig::save()
{ {
KCModule::save(); KCModule::save();
KConfigGroup conf = EffectsHandler::effectConfig( "DesktopGrid" ); KConfigGroup conf = EffectsHandler::effectConfig("DesktopGrid");
conf.writeEntry( "ZoomDuration", m_ui->zoomDurationSpin->value() ); conf.writeEntry("ZoomDuration", m_ui->zoomDurationSpin->value());
conf.writeEntry( "BorderWidth", m_ui->borderWidthSpin->value() ); conf.writeEntry("BorderWidth", m_ui->borderWidthSpin->value());
int alignment = m_ui->desktopNameAlignmentCombo->currentIndex(); int alignment = m_ui->desktopNameAlignmentCombo->currentIndex();
alignment = int( m_alignmentItems[alignment] ); alignment = int(m_alignmentItems[alignment]);
conf.writeEntry( "DesktopNameAlignment", alignment ); conf.writeEntry("DesktopNameAlignment", alignment);
int layoutMode = m_ui->layoutCombo->currentIndex(); int layoutMode = m_ui->layoutCombo->currentIndex();
conf.writeEntry( "LayoutMode", layoutMode ); conf.writeEntry("LayoutMode", layoutMode);
conf.writeEntry( "CustomLayoutRows", m_ui->layoutRowsSpin->value() ); conf.writeEntry("CustomLayoutRows", m_ui->layoutRowsSpin->value());
conf.writeEntry( "PresentWindows", m_ui->presentWindowsCheckBox->isChecked() ); conf.writeEntry("PresentWindows", m_ui->presentWindowsCheckBox->isChecked());
m_ui->shortcutEditor->save(); m_ui->shortcutEditor->save();
conf.sync(); conf.sync();
emit changed(false); emit changed(false);
EffectsHandler::sendReloadMessage( "desktopgrid" ); EffectsHandler::sendReloadMessage("desktopgrid");
} }
void DesktopGridEffectConfig::defaults() void DesktopGridEffectConfig::defaults()
{ {
m_ui->zoomDurationSpin->setValue( 0 ); m_ui->zoomDurationSpin->setValue(0);
m_ui->borderWidthSpin->setValue( 10 ); m_ui->borderWidthSpin->setValue(10);
m_ui->desktopNameAlignmentCombo->setCurrentIndex( 0 ); m_ui->desktopNameAlignmentCombo->setCurrentIndex(0);
m_ui->layoutCombo->setCurrentIndex( int( DesktopGridEffect::LayoutPager )); m_ui->layoutCombo->setCurrentIndex(int(DesktopGridEffect::LayoutPager));
m_ui->layoutRowsSpin->setValue( 2 ); m_ui->layoutRowsSpin->setValue(2);
m_ui->shortcutEditor->allDefault(); m_ui->shortcutEditor->allDefault();
m_ui->presentWindowsCheckBox->setChecked( true ); m_ui->presentWindowsCheckBox->setChecked(true);
emit changed(true); emit changed(true);
} }
void DesktopGridEffectConfig::layoutSelectionChanged() void DesktopGridEffectConfig::layoutSelectionChanged()
{ {
if( m_ui->layoutCombo->currentIndex() == DesktopGridEffect::LayoutCustom ) if (m_ui->layoutCombo->currentIndex() == DesktopGridEffect::LayoutCustom) {
{ m_ui->layoutRowsLabel->setEnabled(true);
m_ui->layoutRowsLabel->setEnabled( true ); m_ui->layoutRowsSpin->setEnabled(true);
m_ui->layoutRowsSpin->setEnabled( true ); } else {
} m_ui->layoutRowsLabel->setEnabled(false);
else m_ui->layoutRowsSpin->setEnabled(false);
{
m_ui->layoutRowsLabel->setEnabled( false );
m_ui->layoutRowsSpin->setEnabled( false );
}
} }
}
} // namespace } // namespace

View File

@ -33,30 +33,30 @@ namespace KWin
class DesktopGridEffectConfigForm : public QWidget, public Ui::DesktopGridEffectConfigForm class DesktopGridEffectConfigForm : public QWidget, public Ui::DesktopGridEffectConfigForm
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit DesktopGridEffectConfigForm(QWidget* parent); explicit DesktopGridEffectConfigForm(QWidget* parent);
}; };
class DesktopGridEffectConfig : public KCModule class DesktopGridEffectConfig : public KCModule
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit DesktopGridEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList()); explicit DesktopGridEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
~DesktopGridEffectConfig(); ~DesktopGridEffectConfig();
public slots: public slots:
virtual void save(); virtual void save();
virtual void load(); virtual void load();
virtual void defaults(); virtual void defaults();
private slots: private slots:
void layoutSelectionChanged(); void layoutSelectionChanged();
private: private:
DesktopGridEffectConfigForm* m_ui; DesktopGridEffectConfigForm* m_ui;
KActionCollection* m_actionCollection; KActionCollection* m_actionCollection;
QList<Qt::Alignment> m_alignmentItems; QList<Qt::Alignment> m_alignmentItems;
}; };
} // namespace } // namespace

View File

@ -23,92 +23,86 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
namespace KWin namespace KWin
{ {
KWIN_EFFECT( dialogparent, DialogParentEffect ) KWIN_EFFECT(dialogparent, DialogParentEffect)
DialogParentEffect::DialogParentEffect() DialogParentEffect::DialogParentEffect()
{ {
reconfigure( ReconfigureAll ); reconfigure(ReconfigureAll);
} }
void DialogParentEffect::reconfigure( ReconfigureFlags ) void DialogParentEffect::reconfigure(ReconfigureFlags)
{ {
// How long does it take for the effect to get it's full strength (in ms) // How long does it take for the effect to get it's full strength (in ms)
changeTime = animationTime( 200 ); changeTime = animationTime(200);
} }
void DialogParentEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time ) void DialogParentEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
{ {
// Check if this window has a modal dialog and change the window's // Check if this window has a modal dialog and change the window's
// effect's strength accordingly // effect's strength accordingly
bool hasDialog = w->findModal() != NULL; bool hasDialog = w->findModal() != NULL;
if( hasDialog ) if (hasDialog) {
{
// Increase effect strength of this window // Increase effect strength of this window
effectStrength[w] = qMin(1.0, effectStrength[w] + time/changeTime); effectStrength[w] = qMin(1.0, effectStrength[w] + time / changeTime);
} } else {
else effectStrength[w] = qMax(0.0, effectStrength[w] - time / changeTime);
{
effectStrength[w] = qMax(0.0, effectStrength[w] - time/changeTime);
}
// Call the next effect
effects->prePaintWindow( w, data, time );
} }
void DialogParentEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ) // Call the next effect
{ effects->prePaintWindow(w, data, time);
}
void DialogParentEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{
double s = effectStrength[w]; double s = effectStrength[w];
if(s > 0.0f) if (s > 0.0f) {
{
// Brightness will be within [1.0; 0.6] // Brightness will be within [1.0; 0.6]
data.brightness *= (1.0 - s * 0.4); data.brightness *= (1.0 - s * 0.4);
// Saturation within [1.0; 0.4] // Saturation within [1.0; 0.4]
data.saturation *= (1.0 - s * 0.6); data.saturation *= (1.0 - s * 0.6);
}
// Call the next effect.
effects->paintWindow( w, mask, region, data );
} }
void DialogParentEffect::postPaintWindow( EffectWindow* w ) // Call the next effect.
{ effects->paintWindow(w, mask, region, data);
}
void DialogParentEffect::postPaintWindow(EffectWindow* w)
{
double s = effectStrength[w]; double s = effectStrength[w];
// If strength is between 0 and 1, the effect is still in progress and the // If strength is between 0 and 1, the effect is still in progress and the
// window has to be repainted during the next pass // window has to be repainted during the next pass
if( s > 0.0 && s < 1.0 ) if (s > 0.0 && s < 1.0)
w->addRepaintFull(); // trigger next animation repaint w->addRepaintFull(); // trigger next animation repaint
// Call the next effect. // Call the next effect.
effects->postPaintWindow( w ); effects->postPaintWindow(w);
} }
void DialogParentEffect::windowActivated( EffectWindow* w ) void DialogParentEffect::windowActivated(EffectWindow* w)
{ {
// If this window is a dialog, we need to repaint it's parent window, so // If this window is a dialog, we need to repaint it's parent window, so
// that the effect could be run for it // that the effect could be run for it
// Set the window to be faded (or NULL if no window is active). // Set the window to be faded (or NULL if no window is active).
if( w && w->isModal() ) if (w && w->isModal()) {
{
// w is a modal dialog // w is a modal dialog
EffectWindowList mainwindows = w->mainWindows(); EffectWindowList mainwindows = w->mainWindows();
foreach( EffectWindow* parent, mainwindows ) foreach (EffectWindow * parent, mainwindows)
parent->addRepaintFull(); parent->addRepaintFull();
}
} }
}
void DialogParentEffect::windowClosed( EffectWindow* w ) void DialogParentEffect::windowClosed(EffectWindow* w)
{ {
// If this window is a dialog, we need to repaint it's parent window, so // If this window is a dialog, we need to repaint it's parent window, so
// that the effect could be run for it // that the effect could be run for it
// Set the window to be faded (or NULL if no window is active). // Set the window to be faded (or NULL if no window is active).
if ( w && w->isModal() ) if (w && w->isModal()) {
{
// w is a modal dialog // w is a modal dialog
EffectWindowList mainwindows = w->mainWindows(); EffectWindowList mainwindows = w->mainWindows();
foreach( EffectWindow* parent, mainwindows ) foreach (EffectWindow * parent, mainwindows)
parent->addRepaintFull(); parent->addRepaintFull();
}
} }
}
} // namespace } // namespace

View File

@ -36,25 +36,25 @@ namespace KWin
**/ **/
class DialogParentEffect class DialogParentEffect
: public Effect : public Effect
{ {
public: public:
DialogParentEffect(); DialogParentEffect();
virtual void reconfigure( ReconfigureFlags ); virtual void reconfigure(ReconfigureFlags);
virtual void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time ); virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time);
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
virtual void postPaintWindow( EffectWindow* w ); virtual void postPaintWindow(EffectWindow* w);
virtual void windowClosed( EffectWindow* c ); virtual void windowClosed(EffectWindow* c);
virtual void windowActivated( EffectWindow* c ); virtual void windowActivated(EffectWindow* c);
protected: protected:
bool hasModalWindow( EffectWindow* t ); bool hasModalWindow(EffectWindow* t);
private: private:
// The progress of the fading. // The progress of the fading.
QHash<EffectWindow*, double> effectStrength; QHash<EffectWindow*, double> effectStrength;
double changeTime; double changeTime;
}; };
} // namespace } // namespace

View File

@ -26,120 +26,113 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
namespace KWin namespace KWin
{ {
KWIN_EFFECT( diminactive, DimInactiveEffect ) KWIN_EFFECT(diminactive, DimInactiveEffect)
DimInactiveEffect::DimInactiveEffect() DimInactiveEffect::DimInactiveEffect()
{ {
reconfigure( ReconfigureAll ); reconfigure(ReconfigureAll);
timeline.setDuration( animationTime( 250 )); timeline.setDuration(animationTime(250));
previousActiveTimeline.setDuration( animationTime( 250 )); previousActiveTimeline.setDuration(animationTime(250));
active = effects->activeWindow(); active = effects->activeWindow();
previousActive = NULL; previousActive = NULL;
} }
void DimInactiveEffect::reconfigure( ReconfigureFlags ) void DimInactiveEffect::reconfigure(ReconfigureFlags)
{ {
KConfigGroup conf = EffectsHandler::effectConfig("DimInactive"); KConfigGroup conf = EffectsHandler::effectConfig("DimInactive");
dim_panels = conf.readEntry("DimPanels", false); dim_panels = conf.readEntry("DimPanels", false);
dim_desktop = conf.readEntry("DimDesktop", false); dim_desktop = conf.readEntry("DimDesktop", false);
dim_keepabove = conf.readEntry("DimKeepAbove", false); dim_keepabove = conf.readEntry("DimKeepAbove", false);
dim_by_group = conf.readEntry("DimByGroup", true); dim_by_group = conf.readEntry("DimByGroup", true);
dim_strength = conf.readEntry("Strength", 25); dim_strength = conf.readEntry("Strength", 25);
} }
void DimInactiveEffect::prePaintScreen( ScreenPrePaintData& data, int time ) void DimInactiveEffect::prePaintScreen(ScreenPrePaintData& data, int time)
{ {
double oldValue = timeline.value(); double oldValue = timeline.value();
if( effects->activeFullScreenEffect() ) if (effects->activeFullScreenEffect())
timeline.removeTime( time ); timeline.removeTime(time);
else else
timeline.addTime( time ); timeline.addTime(time);
if( oldValue != timeline.value() ) if (oldValue != timeline.value())
effects->addRepaintFull(); effects->addRepaintFull();
if( previousActive ) if (previousActive) {
{ // We are fading out the previous window // We are fading out the previous window
previousActive->addRepaintFull(); previousActive->addRepaintFull();
previousActiveTimeline.addTime( time ); previousActiveTimeline.addTime(time);
}
effects->prePaintScreen( data, time );
} }
effects->prePaintScreen(data, time);
}
void DimInactiveEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ) void DimInactiveEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{ {
if( dimWindow( w ) || w == previousActive ) if (dimWindow(w) || w == previousActive) {
{
double previous = 1.0; double previous = 1.0;
if( w == previousActive ) if (w == previousActive)
previous = previousActiveTimeline.value(); previous = previousActiveTimeline.value();
if( previousActiveTimeline.value() == 1.0 ) if (previousActiveTimeline.value() == 1.0)
previousActive = NULL; previousActive = NULL;
data.brightness *= (1.0 - (dim_strength / 100.0) * timeline.value() * previous ); data.brightness *= (1.0 - (dim_strength / 100.0) * timeline.value() * previous);
data.saturation *= (1.0 - (dim_strength / 100.0) * timeline.value() * previous ); data.saturation *= (1.0 - (dim_strength / 100.0) * timeline.value() * previous);
}
effects->paintWindow( w, mask, region, data );
} }
effects->paintWindow(w, mask, region, data);
}
bool DimInactiveEffect::dimWindow( const EffectWindow* w ) const bool DimInactiveEffect::dimWindow(const EffectWindow* w) const
{ {
if( effects->activeWindow() == w ) if (effects->activeWindow() == w)
return false; // never dim active window return false; // never dim active window
if( active && dim_by_group && active->group() == w->group()) if (active && dim_by_group && active->group() == w->group())
return false; // don't dim in active group if configured so return false; // don't dim in active group if configured so
if( w->isDock() && !dim_panels ) if (w->isDock() && !dim_panels)
return false; // don't dim panels if configured so return false; // don't dim panels if configured so
if( w->isDesktop() && !dim_desktop ) if (w->isDesktop() && !dim_desktop)
return false; // don't dim the desktop if configured so return false; // don't dim the desktop if configured so
if( w->keepAbove() && !dim_keepabove ) if (w->keepAbove() && !dim_keepabove)
return false; // don't dim keep-above windows if configured so return false; // don't dim keep-above windows if configured so
if( !w->isNormalWindow() && !w->isDialog() && !w->isDock() && !w->isDesktop()) if (!w->isNormalWindow() && !w->isDialog() && !w->isDock() && !w->isDesktop())
return false; // don't dim more special window types return false; // don't dim more special window types
// don't dim unmanaged windows, grouping doesn't work for them and maybe dimming // don't dim unmanaged windows, grouping doesn't work for them and maybe dimming
// them doesn't make sense in general (they should be short-lived anyway) // them doesn't make sense in general (they should be short-lived anyway)
if( !w->isManaged()) if (!w->isManaged())
return false; return false;
return true; // dim the rest return true; // dim the rest
} }
void DimInactiveEffect::windowDeleted( EffectWindow* w ) void DimInactiveEffect::windowDeleted(EffectWindow* w)
{ {
if( w == previousActive ) if (w == previousActive)
previousActive = NULL; previousActive = NULL;
} }
void DimInactiveEffect::windowActivated( EffectWindow* w ) void DimInactiveEffect::windowActivated(EffectWindow* w)
{ {
if( active != NULL ) if (active != NULL) {
{
previousActive = active; previousActive = active;
previousActiveTimeline.setProgress( 0.0 ); previousActiveTimeline.setProgress(0.0);
if( !dimWindow( previousActive ) ) if (!dimWindow(previousActive))
previousActive = NULL; previousActive = NULL;
if( dim_by_group ) if (dim_by_group) {
{ if ((w == NULL || w->group() != active->group()) && active->group() != NULL) {
if(( w == NULL || w->group() != active->group()) && active->group() != NULL ) // repaint windows that are no longer in the active group
{ // repaint windows that are no longer in the active group foreach (EffectWindow * tmp, active->group()->members())
foreach( EffectWindow* tmp, active->group()->members()) tmp->addRepaintFull();
tmp->addRepaintFull();
}
} }
else } else
active->addRepaintFull(); active->addRepaintFull();
}
active = w;
if( active != NULL )
{
if( dim_by_group )
{
if( active->group() != NULL )
{ // repaint newly active windows
foreach( EffectWindow* tmp, active->group()->members())
tmp->addRepaintFull();
}
}
else
active->addRepaintFull();
}
} }
active = w;
if (active != NULL) {
if (dim_by_group) {
if (active->group() != NULL) {
// repaint newly active windows
foreach (EffectWindow * tmp, active->group()->members())
tmp->addRepaintFull();
}
} else
active->addRepaintFull();
}
}
} // namespace } // namespace

View File

@ -31,26 +31,26 @@ namespace KWin
class DimInactiveEffect class DimInactiveEffect
: public Effect : public Effect
{ {
public: public:
DimInactiveEffect(); DimInactiveEffect();
virtual void reconfigure( ReconfigureFlags ); virtual void reconfigure(ReconfigureFlags);
virtual void prePaintScreen( ScreenPrePaintData& data, int time ); virtual void prePaintScreen(ScreenPrePaintData& data, int time);
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
virtual void windowDeleted( EffectWindow* w ); virtual void windowDeleted(EffectWindow* w);
virtual void windowActivated( EffectWindow* c ); virtual void windowActivated(EffectWindow* c);
private: private:
bool dimWindow( const EffectWindow* w ) const; bool dimWindow(const EffectWindow* w) const;
TimeLine timeline; TimeLine timeline;
EffectWindow* active; EffectWindow* active;
EffectWindow* previousActive; EffectWindow* previousActive;
TimeLine previousActiveTimeline; TimeLine previousActiveTimeline;
int dim_strength; // reduce saturation and brightness by this percentage int dim_strength; // reduce saturation and brightness by this percentage
bool dim_panels; // do/don't dim also all panels bool dim_panels; // do/don't dim also all panels
bool dim_desktop; // do/don't dim the desktop bool dim_desktop; // do/don't dim the desktop
bool dim_keepabove; // do/don't dim keep-above windows bool dim_keepabove; // do/don't dim keep-above windows
bool dim_by_group; // keep visible all windows from the active window's group or only the active window bool dim_by_group; // keep visible all windows from the active window's group or only the active window
}; };
} // namespace } // namespace

View File

@ -38,12 +38,12 @@ KWIN_EFFECT_CONFIG_FACTORY
DimInactiveEffectConfigForm::DimInactiveEffectConfigForm(QWidget* parent) : QWidget(parent) DimInactiveEffectConfigForm::DimInactiveEffectConfigForm(QWidget* parent) : QWidget(parent)
{ {
setupUi(this); setupUi(this);
} }
DimInactiveEffectConfig::DimInactiveEffectConfig(QWidget* parent, const QVariantList& args) : DimInactiveEffectConfig::DimInactiveEffectConfig(QWidget* parent, const QVariantList& args) :
KCModule(EffectFactory::componentData(), parent, args) KCModule(EffectFactory::componentData(), parent, args)
{ {
m_ui = new DimInactiveEffectConfigForm(this); m_ui = new DimInactiveEffectConfigForm(this);
QVBoxLayout* layout = new QVBoxLayout(this); QVBoxLayout* layout = new QVBoxLayout(this);
@ -57,10 +57,10 @@ DimInactiveEffectConfig::DimInactiveEffectConfig(QWidget* parent, const QVariant
connect(m_ui->checkGroup, SIGNAL(toggled(bool)), this, SLOT(changed())); connect(m_ui->checkGroup, SIGNAL(toggled(bool)), this, SLOT(changed()));
load(); load();
} }
void DimInactiveEffectConfig::load() void DimInactiveEffectConfig::load()
{ {
KCModule::load(); KCModule::load();
KConfigGroup conf = EffectsHandler::effectConfig("DimInactive"); KConfigGroup conf = EffectsHandler::effectConfig("DimInactive");
@ -77,10 +77,10 @@ void DimInactiveEffectConfig::load()
m_ui->checkGroup->setChecked(group); m_ui->checkGroup->setChecked(group);
emit changed(false); emit changed(false);
} }
void DimInactiveEffectConfig::save() void DimInactiveEffectConfig::save()
{ {
KConfigGroup conf = EffectsHandler::effectConfig("DimInactive"); KConfigGroup conf = EffectsHandler::effectConfig("DimInactive");
conf.writeEntry("Strength", m_ui->spinStrength->value()); conf.writeEntry("Strength", m_ui->spinStrength->value());
@ -93,18 +93,18 @@ void DimInactiveEffectConfig::save()
KCModule::save(); KCModule::save();
emit changed(false); emit changed(false);
EffectsHandler::sendReloadMessage( "diminactive" ); EffectsHandler::sendReloadMessage("diminactive");
} }
void DimInactiveEffectConfig::defaults() void DimInactiveEffectConfig::defaults()
{ {
m_ui->spinStrength->setValue(25); m_ui->spinStrength->setValue(25);
m_ui->checkPanel->setChecked(false); m_ui->checkPanel->setChecked(false);
m_ui->checkDesktop->setChecked(false); m_ui->checkDesktop->setChecked(false);
m_ui->checkKeepAbove->setChecked(false); m_ui->checkKeepAbove->setChecked(false);
m_ui->checkGroup->setChecked(true); m_ui->checkGroup->setChecked(true);
emit changed(true); emit changed(true);
} }
} // namespace } // namespace

View File

@ -31,23 +31,23 @@ namespace KWin
class DimInactiveEffectConfigForm : public QWidget, public Ui::DimInactiveEffectConfigForm class DimInactiveEffectConfigForm : public QWidget, public Ui::DimInactiveEffectConfigForm
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit DimInactiveEffectConfigForm(QWidget* parent); explicit DimInactiveEffectConfigForm(QWidget* parent);
}; };
class DimInactiveEffectConfig : public KCModule class DimInactiveEffectConfig : public KCModule
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit DimInactiveEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList()); explicit DimInactiveEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
virtual void save(); virtual void save();
virtual void load(); virtual void load();
virtual void defaults(); virtual void defaults();
private: private:
DimInactiveEffectConfigForm* m_ui; DimInactiveEffectConfigForm* m_ui;
}; };
} // namespace } // namespace

View File

@ -24,95 +24,87 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
namespace KWin namespace KWin
{ {
KWIN_EFFECT( dimscreen, DimScreenEffect ) KWIN_EFFECT(dimscreen, DimScreenEffect)
DimScreenEffect::DimScreenEffect() DimScreenEffect::DimScreenEffect()
: mActivated( false ) : mActivated(false)
, activateAnimation( false ) , activateAnimation(false)
, deactivateAnimation( false ) , deactivateAnimation(false)
{ {
reconfigure( ReconfigureAll ); reconfigure(ReconfigureAll);
} }
DimScreenEffect::~DimScreenEffect() DimScreenEffect::~DimScreenEffect()
{ {
} }
void DimScreenEffect::reconfigure( ReconfigureFlags ) void DimScreenEffect::reconfigure(ReconfigureFlags)
{ {
timeline.setDuration( animationTime( 250 )); timeline.setDuration(animationTime(250));
} }
void DimScreenEffect::prePaintScreen( ScreenPrePaintData& data, int time ) void DimScreenEffect::prePaintScreen(ScreenPrePaintData& data, int time)
{ {
if( mActivated && activateAnimation && !effects->activeFullScreenEffect() ) if (mActivated && activateAnimation && !effects->activeFullScreenEffect())
timeline.addTime( time ); timeline.addTime(time);
if( mActivated && deactivateAnimation ) if (mActivated && deactivateAnimation)
timeline.removeTime( time ); timeline.removeTime(time);
if( mActivated && effects->activeFullScreenEffect() ) if (mActivated && effects->activeFullScreenEffect())
timeline.removeTime( time ); timeline.removeTime(time);
if( mActivated && !activateAnimation && !deactivateAnimation && !effects->activeFullScreenEffect() && timeline.value() != 1.0 ) if (mActivated && !activateAnimation && !deactivateAnimation && !effects->activeFullScreenEffect() && timeline.value() != 1.0)
timeline.addTime( time ); timeline.addTime(time);
effects->prePaintScreen( data, time ); effects->prePaintScreen(data, time);
} }
void DimScreenEffect::postPaintScreen() void DimScreenEffect::postPaintScreen()
{ {
if( mActivated ) if (mActivated) {
{ if (activateAnimation && timeline.value() == 1.0) {
if( activateAnimation && timeline.value() == 1.0 )
{
activateAnimation = false; activateAnimation = false;
effects->addRepaintFull(); effects->addRepaintFull();
} }
if( deactivateAnimation && timeline.value() == 0.0 ) if (deactivateAnimation && timeline.value() == 0.0) {
{
deactivateAnimation = false; deactivateAnimation = false;
mActivated = false; mActivated = false;
effects->addRepaintFull(); effects->addRepaintFull();
} }
// still animating // still animating
if( timeline.value() > 0.0 && timeline.value() < 1.0 ) if (timeline.value() > 0.0 && timeline.value() < 1.0)
effects->addRepaintFull(); effects->addRepaintFull();
} }
effects->postPaintScreen(); effects->postPaintScreen();
} }
void DimScreenEffect::paintWindow( EffectWindow *w, int mask, QRegion region, WindowPaintData &data ) void DimScreenEffect::paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data)
{ {
if( mActivated && ( w != window ) && w->isManaged() ) if (mActivated && (w != window) && w->isManaged()) {
{ data.brightness *= (1.0 - 0.33 * timeline.value());
data.brightness *= (1.0 - 0.33 * timeline.value() ); data.saturation *= (1.0 - 0.33 * timeline.value());
data.saturation *= (1.0 - 0.33 * timeline.value() );
}
effects->paintWindow( w, mask, region, data );
} }
effects->paintWindow(w, mask, region, data);
}
void DimScreenEffect::windowActivated( EffectWindow *w ) void DimScreenEffect::windowActivated(EffectWindow *w)
{ {
if( !w ) return; if (!w) return;
QStringList check; QStringList check;
check << "kdesu kdesu"; check << "kdesu kdesu";
check << "kdesudo kdesudo"; check << "kdesudo kdesudo";
check << "polkit-kde-manager polkit-kde-manager"; check << "polkit-kde-manager polkit-kde-manager";
check << "polkit-kde-authentication-agent-1 polkit-kde-authentication-agent-1"; check << "polkit-kde-authentication-agent-1 polkit-kde-authentication-agent-1";
check << "pinentry pinentry"; check << "pinentry pinentry";
if( check.contains( w->windowClass() ) ) if (check.contains(w->windowClass())) {
{
mActivated = true; mActivated = true;
activateAnimation = true; activateAnimation = true;
deactivateAnimation = false; deactivateAnimation = false;
window = w; window = w;
effects->addRepaintFull(); effects->addRepaintFull();
} } else {
else if (mActivated) {
{
if( mActivated)
{
activateAnimation = false; activateAnimation = false;
deactivateAnimation = true; deactivateAnimation = true;
effects->addRepaintFull(); effects->addRepaintFull();
}
} }
} }
}
} // namespace } // namespace

View File

@ -28,24 +28,24 @@ namespace KWin
class DimScreenEffect class DimScreenEffect
: public Effect : public Effect
{ {
public: public:
DimScreenEffect(); DimScreenEffect();
~DimScreenEffect(); ~DimScreenEffect();
virtual void reconfigure( ReconfigureFlags ); virtual void reconfigure(ReconfigureFlags);
virtual void prePaintScreen( ScreenPrePaintData& data, int time ); virtual void prePaintScreen(ScreenPrePaintData& data, int time);
virtual void postPaintScreen(); virtual void postPaintScreen();
virtual void paintWindow( EffectWindow *w, int mask, QRegion region, WindowPaintData &data ); virtual void paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data);
virtual void windowActivated( EffectWindow *w ); virtual void windowActivated(EffectWindow *w);
private: private:
bool mActivated; bool mActivated;
bool activateAnimation; bool activateAnimation;
bool deactivateAnimation; bool deactivateAnimation;
TimeLine timeline; TimeLine timeline;
EffectWindow* window; EffectWindow* window;
}; };
} // namespace } // namespace

View File

@ -33,11 +33,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
namespace KWin namespace KWin
{ {
KWIN_EFFECT( explosion, ExplosionEffect ) KWIN_EFFECT(explosion, ExplosionEffect)
KWIN_EFFECT_SUPPORTED( explosion, ExplosionEffect::supported() ) KWIN_EFFECT_SUPPORTED(explosion, ExplosionEffect::supported())
ExplosionEffect::ExplosionEffect() : Effect() ExplosionEffect::ExplosionEffect() : Effect()
{ {
mShader = 0; mShader = 0;
mStartOffsetTex = 0; mStartOffsetTex = 0;
mEndOffsetTex = 0; mEndOffsetTex = 0;
@ -45,20 +45,20 @@ ExplosionEffect::ExplosionEffect() : Effect()
mActiveAnimations = 0; mActiveAnimations = 0;
mValid = true; mValid = true;
mInited = false; mInited = false;
} }
ExplosionEffect::~ExplosionEffect() ExplosionEffect::~ExplosionEffect()
{ {
delete mShader; delete mShader;
delete mStartOffsetTex; delete mStartOffsetTex;
delete mEndOffsetTex; delete mEndOffsetTex;
} }
bool ExplosionEffect::supported() bool ExplosionEffect::supported()
{ {
return GLShader::fragmentShaderSupported() && return GLShader::fragmentShaderSupported() &&
(effects->compositingType() == OpenGLCompositing); (effects->compositingType() == OpenGLCompositing);
} }
bool ExplosionEffect::loadData() bool ExplosionEffect::loadData()
{ {
@ -67,20 +67,16 @@ bool ExplosionEffect::loadData()
const QString fragmentshader = KGlobal::dirs()->findResource("data", "kwin/explosion.frag"); const QString fragmentshader = KGlobal::dirs()->findResource("data", "kwin/explosion.frag");
QString starttexture = KGlobal::dirs()->findResource("data", "kwin/explosion-start.png"); QString starttexture = KGlobal::dirs()->findResource("data", "kwin/explosion-start.png");
QString endtexture = KGlobal::dirs()->findResource("data", "kwin/explosion-end.png"); QString endtexture = KGlobal::dirs()->findResource("data", "kwin/explosion-end.png");
if(starttexture.isEmpty() || endtexture.isEmpty()) if (starttexture.isEmpty() || endtexture.isEmpty()) {
{
kError(1212) << "Couldn't locate texture files" << endl; kError(1212) << "Couldn't locate texture files" << endl;
return false; return false;
} }
mShader = ShaderManager::instance()->loadFragmentShader(ShaderManager::GenericShader, fragmentshader); mShader = ShaderManager::instance()->loadFragmentShader(ShaderManager::GenericShader, fragmentshader);
if(!mShader->isValid()) if (!mShader->isValid()) {
{
kError(1212) << "The shader failed to load!" << endl; kError(1212) << "The shader failed to load!" << endl;
return false; return false;
} } else {
else
{
ShaderManager::instance()->pushShader(mShader); ShaderManager::instance()->pushShader(mShader);
mShader->setUniform("startOffsetTexture", 4); mShader->setUniform("startOffsetTexture", 4);
mShader->setUniform("endOffsetTexture", 5); mShader->setUniform("endOffsetTexture", 5);
@ -89,70 +85,61 @@ bool ExplosionEffect::loadData()
mStartOffsetTex = new GLTexture(starttexture); mStartOffsetTex = new GLTexture(starttexture);
mEndOffsetTex = new GLTexture(endtexture); mEndOffsetTex = new GLTexture(endtexture);
if(mStartOffsetTex->isNull() || mEndOffsetTex->isNull()) if (mStartOffsetTex->isNull() || mEndOffsetTex->isNull()) {
{
kError(1212) << "The textures failed to load!" << endl; kError(1212) << "The textures failed to load!" << endl;
return false; return false;
} } else {
else mStartOffsetTex->setFilter(GL_LINEAR);
{ mEndOffsetTex->setFilter(GL_LINEAR);
mStartOffsetTex->setFilter( GL_LINEAR );
mEndOffsetTex->setFilter( GL_LINEAR );
} }
return true; return true;
} }
void ExplosionEffect::prePaintScreen( ScreenPrePaintData& data, int time ) void ExplosionEffect::prePaintScreen(ScreenPrePaintData& data, int time)
{ {
if( mActiveAnimations > 0 ) if (mActiveAnimations > 0)
// We need to mark the screen as transformed. Otherwise the whole screen // We need to mark the screen as transformed. Otherwise the whole screen
// won't be repainted, resulting in artefacts // won't be repainted, resulting in artefacts
data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS; data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
effects->prePaintScreen(data, time); effects->prePaintScreen(data, time);
} }
void ExplosionEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time ) void ExplosionEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
{ {
if( mWindows.contains( w )) if (mWindows.contains(w)) {
{ if (mValid && !mInited)
if( mValid && !mInited )
mValid = loadData(); mValid = loadData();
if( mValid ) if (mValid) {
{ mWindows[ w ] += time / animationTime(700.0); // complete change in 700ms
mWindows[ w ] += time / animationTime( 700.0 ); // complete change in 700ms if (mWindows[ w ] < 1) {
if( mWindows[ w ] < 1 )
{
data.setTranslucent(); data.setTranslucent();
data.setTransformed(); data.setTransformed();
w->enablePainting( EffectWindow::PAINT_DISABLED_BY_DELETE ); w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DELETE);
} } else {
else mWindows.remove(w);
{
mWindows.remove( w );
w->unrefWindow(); w->unrefWindow();
mActiveAnimations--; mActiveAnimations--;
}
} }
} }
effects->prePaintWindow( w, data, time );
} }
void ExplosionEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ) effects->prePaintWindow(w, data, time);
{ }
void ExplosionEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{
// Make sure we have OpenGL compositing and the window is vidible and not a // Make sure we have OpenGL compositing and the window is vidible and not a
// special window // special window
bool useshader = ( mValid && mWindows.contains( w ) ); bool useshader = (mValid && mWindows.contains(w));
if( useshader ) if (useshader) {
{
double maxscaleadd = 1.5f; double maxscaleadd = 1.5f;
double scale = 1 + maxscaleadd*mWindows[w]; double scale = 1 + maxscaleadd * mWindows[w];
data.xScale = scale; data.xScale = scale;
data.yScale = scale; data.yScale = scale;
data.xTranslate += int( w->width() / 2 * ( 1 - scale )); data.xTranslate += int(w->width() / 2 * (1 - scale));
data.yTranslate += int( w->height() / 2 * ( 1 - scale )); data.yTranslate += int(w->height() / 2 * (1 - scale));
data.opacity *= 0.99; // Force blending data.opacity *= 0.99; // Force blending
ShaderManager *manager = ShaderManager::instance(); ShaderManager *manager = ShaderManager::instance();
GLShader *shader = manager->pushShader(ShaderManager::GenericShader); GLShader *shader = manager->pushShader(ShaderManager::GenericShader);
@ -168,49 +155,47 @@ void ExplosionEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Wi
mEndOffsetTex->bind(); mEndOffsetTex->bind();
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
data.shader = mShader; data.shader = mShader;
} }
// Call the next effect. // Call the next effect.
effects->paintWindow( w, mask, region, data ); effects->paintWindow(w, mask, region, data);
if( useshader ) if (useshader) {
{
ShaderManager::instance()->popShader(); ShaderManager::instance()->popShader();
glActiveTexture(GL_TEXTURE4); glActiveTexture(GL_TEXTURE4);
mStartOffsetTex->unbind(); mStartOffsetTex->unbind();
glActiveTexture(GL_TEXTURE5); glActiveTexture(GL_TEXTURE5);
mEndOffsetTex->unbind(); mEndOffsetTex->unbind();
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
}
} }
}
void ExplosionEffect::postPaintScreen() void ExplosionEffect::postPaintScreen()
{ {
if( mActiveAnimations > 0 ) if (mActiveAnimations > 0)
effects->addRepaintFull(); effects->addRepaintFull();
// Call the next effect. // Call the next effect.
effects->postPaintScreen(); effects->postPaintScreen();
} }
void ExplosionEffect::windowClosed( EffectWindow* c ) void ExplosionEffect::windowClosed(EffectWindow* c)
{ {
const void* e = c->data( WindowClosedGrabRole ).value<void*>(); const void* e = c->data(WindowClosedGrabRole).value<void*>();
if( e && e != this ) if (e && e != this)
return; return;
if( c->isOnCurrentDesktop() && !c->isMinimized()) if (c->isOnCurrentDesktop() && !c->isMinimized()) {
{
mWindows[ c ] = 0; // count up to 1 mWindows[ c ] = 0; // count up to 1
c->addRepaintFull(); c->addRepaintFull();
c->refWindow(); c->refWindow();
mActiveAnimations++; mActiveAnimations++;
}
} }
}
void ExplosionEffect::windowDeleted( EffectWindow* c ) void ExplosionEffect::windowDeleted(EffectWindow* c)
{ {
mWindows.remove( c ); mWindows.remove(c);
} }
} // namespace } // namespace

View File

@ -37,34 +37,34 @@ class GLTexture;
**/ **/
class ExplosionEffect class ExplosionEffect
: public Effect : public Effect
{ {
public: public:
ExplosionEffect(); ExplosionEffect();
~ExplosionEffect(); ~ExplosionEffect();
virtual void prePaintScreen( ScreenPrePaintData& data, int time ); virtual void prePaintScreen(ScreenPrePaintData& data, int time);
virtual void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time ); virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time);
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
virtual void postPaintScreen(); virtual void postPaintScreen();
virtual void windowClosed( EffectWindow* c ); virtual void windowClosed(EffectWindow* c);
virtual void windowDeleted( EffectWindow* c ); virtual void windowDeleted(EffectWindow* c);
static bool supported(); static bool supported();
protected: protected:
bool loadData(); bool loadData();
private: private:
GLShader* mShader; GLShader* mShader;
GLTexture* mStartOffsetTex; GLTexture* mStartOffsetTex;
GLTexture* mEndOffsetTex; GLTexture* mEndOffsetTex;
QMap< const EffectWindow*, double > mWindows; QMap< const EffectWindow*, double > mWindows;
int mActiveAnimations; int mActiveAnimations;
bool mValid; bool mValid;
bool mInited; bool mInited;
}; };
} // namespace } // namespace

Some files were not shown because too many files have changed in this diff Show More