KWin uses kdelibs coding style.
parent
1a5b3b4bea
commit
0a7e48f7aa
807
activation.cpp
807
activation.cpp
File diff suppressed because it is too large
Load Diff
22
atoms.cpp
22
atoms.cpp
|
@ -27,7 +27,7 @@ namespace KWin
|
|||
{
|
||||
|
||||
Atoms::Atoms()
|
||||
{
|
||||
{
|
||||
|
||||
const int max = 50;
|
||||
Atom* atoms[max];
|
||||
|
@ -84,41 +84,41 @@ Atoms::Atoms()
|
|||
|
||||
atoms[n] = &kde_system_tray_embedding;
|
||||
names[n++] = (char*) "_KDE_SYSTEM_TRAY_EMBEDDING";
|
||||
|
||||
|
||||
atoms[n] = &net_wm_take_activity;
|
||||
names[n++] = (char*) "_NET_WM_TAKE_ACTIVITY";
|
||||
|
||||
|
||||
atoms[n] = &net_wm_window_opacity;
|
||||
names[n++] = (char*) "_NET_WM_WINDOW_OPACITY";
|
||||
|
||||
Atom fake;
|
||||
atoms[n] = &fake;
|
||||
names[n++] = (char *) "_DT_SM_WINDOW_INFO";
|
||||
|
||||
|
||||
atoms[n] = &fake;
|
||||
names[n++] = (char *) "_MOTIF_WM_INFO"; // #172028
|
||||
|
||||
|
||||
atoms[n] = &xdnd_aware;
|
||||
names[n++] = (char*) "XdndAware";
|
||||
atoms[n] = &xdnd_position;
|
||||
names[n++] = (char*) "XdndPosition";
|
||||
|
||||
|
||||
atoms[n] = &net_frame_extents;
|
||||
names[n++] = (char*) "_NET_FRAME_EXTENTS";
|
||||
atoms[n] = &kde_net_wm_frame_strut;
|
||||
names[n++] = (char*) "_KDE_NET_WM_FRAME_STRUT";
|
||||
|
||||
|
||||
atoms[n] = &net_wm_sync_request_counter;
|
||||
names[n++] = (char*) "_NET_WM_SYNC_REQUEST_COUNTER";
|
||||
|
||||
atoms[n] = &net_wm_sync_request;
|
||||
names[n++] = (char*) "_NET_WM_SYNC_REQUEST";
|
||||
|
||||
assert( n <= max );
|
||||
assert(n <= max);
|
||||
|
||||
XInternAtoms( display(), names, n, false, atoms_return );
|
||||
for (int i = 0; i < n; i++ )
|
||||
XInternAtoms(display(), names, n, false, atoms_return);
|
||||
for (int i = 0; i < n; i++)
|
||||
*atoms[i] = atoms_return[i];
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
58
atoms.h
58
atoms.h
|
@ -29,38 +29,38 @@ namespace KWin
|
|||
{
|
||||
|
||||
class Atoms
|
||||
{
|
||||
public:
|
||||
Atoms();
|
||||
{
|
||||
public:
|
||||
Atoms();
|
||||
|
||||
Atom kwin_running;
|
||||
Atom activities;
|
||||
Atom kwin_running;
|
||||
Atom activities;
|
||||
|
||||
Atom wm_protocols;
|
||||
Atom wm_delete_window;
|
||||
Atom wm_take_focus;
|
||||
Atom wm_change_state;
|
||||
Atom wm_client_leader;
|
||||
Atom wm_window_role;
|
||||
Atom wm_state;
|
||||
Atom sm_client_id;
|
||||
Atom wm_protocols;
|
||||
Atom wm_delete_window;
|
||||
Atom wm_take_focus;
|
||||
Atom wm_change_state;
|
||||
Atom wm_client_leader;
|
||||
Atom wm_window_role;
|
||||
Atom wm_state;
|
||||
Atom sm_client_id;
|
||||
|
||||
Atom motif_wm_hints;
|
||||
Atom net_wm_context_help;
|
||||
Atom net_wm_ping;
|
||||
Atom kde_wm_change_state;
|
||||
Atom net_wm_user_time;
|
||||
Atom kde_net_wm_user_creation_time;
|
||||
Atom kde_system_tray_embedding;
|
||||
Atom net_wm_take_activity;
|
||||
Atom net_wm_window_opacity;
|
||||
Atom xdnd_aware;
|
||||
Atom xdnd_position;
|
||||
Atom net_frame_extents;
|
||||
Atom kde_net_wm_frame_strut;
|
||||
Atom net_wm_sync_request_counter;
|
||||
Atom net_wm_sync_request;
|
||||
};
|
||||
Atom motif_wm_hints;
|
||||
Atom net_wm_context_help;
|
||||
Atom net_wm_ping;
|
||||
Atom kde_wm_change_state;
|
||||
Atom net_wm_user_time;
|
||||
Atom kde_net_wm_user_creation_time;
|
||||
Atom kde_system_tray_embedding;
|
||||
Atom net_wm_take_activity;
|
||||
Atom net_wm_window_opacity;
|
||||
Atom xdnd_aware;
|
||||
Atom xdnd_position;
|
||||
Atom net_frame_extents;
|
||||
Atom kde_net_wm_frame_strut;
|
||||
Atom net_wm_sync_request_counter;
|
||||
Atom net_wm_sync_request;
|
||||
};
|
||||
|
||||
|
||||
extern Atoms* atoms;
|
||||
|
|
342
bridge.cpp
342
bridge.cpp
|
@ -29,155 +29,151 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
Bridge::Bridge( Client* cl )
|
||||
: c( cl )
|
||||
{
|
||||
}
|
||||
Bridge::Bridge(Client* cl)
|
||||
: c(cl)
|
||||
{
|
||||
}
|
||||
|
||||
#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, isCloseable,,, const )
|
||||
BRIDGE_HELPER( bool, isMaximizable,,, const )
|
||||
BRIDGE_HELPER( Bridge::MaximizeMode, maximizeMode,,, const )
|
||||
BRIDGE_HELPER( bool, isMinimizable,,, const )
|
||||
BRIDGE_HELPER( bool, providesContextHelp,,, const )
|
||||
BRIDGE_HELPER( int, desktop,,, const )
|
||||
BRIDGE_HELPER( bool, isModal,,, const )
|
||||
BRIDGE_HELPER( bool, isShadeable,,, const )
|
||||
BRIDGE_HELPER( bool, isShade,,, const )
|
||||
BRIDGE_HELPER( bool, keepAbove,,, const )
|
||||
BRIDGE_HELPER( bool, keepBelow,,, const )
|
||||
BRIDGE_HELPER( bool, isMovable,,, const )
|
||||
BRIDGE_HELPER( bool, isResizable,,, const )
|
||||
BRIDGE_HELPER( QString, caption,,, const )
|
||||
BRIDGE_HELPER( void, processMousePressEvent, QMouseEvent* e, e, )
|
||||
BRIDGE_HELPER( QRect, geometry,,, const )
|
||||
BRIDGE_HELPER( void, closeWindow,,, )
|
||||
BRIDGE_HELPER( void, maximize, MaximizeMode m, m, )
|
||||
BRIDGE_HELPER( void, minimize,,, )
|
||||
BRIDGE_HELPER( void, showContextHelp,,, )
|
||||
BRIDGE_HELPER( void, setDesktop, int desktop, desktop, )
|
||||
BRIDGE_HELPER(bool, isActive, , , const)
|
||||
BRIDGE_HELPER(bool, isCloseable, , , const)
|
||||
BRIDGE_HELPER(bool, isMaximizable, , , const)
|
||||
BRIDGE_HELPER(Bridge::MaximizeMode, maximizeMode, , , const)
|
||||
BRIDGE_HELPER(bool, isMinimizable, , , const)
|
||||
BRIDGE_HELPER(bool, providesContextHelp, , , const)
|
||||
BRIDGE_HELPER(int, desktop, , , const)
|
||||
BRIDGE_HELPER(bool, isModal, , , const)
|
||||
BRIDGE_HELPER(bool, isShadeable, , , const)
|
||||
BRIDGE_HELPER(bool, isShade, , , const)
|
||||
BRIDGE_HELPER(bool, keepAbove, , , const)
|
||||
BRIDGE_HELPER(bool, keepBelow, , , const)
|
||||
BRIDGE_HELPER(bool, isMovable, , , const)
|
||||
BRIDGE_HELPER(bool, isResizable, , , const)
|
||||
BRIDGE_HELPER(QString, caption, , , const)
|
||||
BRIDGE_HELPER(void, processMousePressEvent, QMouseEvent* e, e,)
|
||||
BRIDGE_HELPER(QRect, geometry, , , const)
|
||||
BRIDGE_HELPER(void, closeWindow, , ,)
|
||||
BRIDGE_HELPER(void, maximize, MaximizeMode m, m,)
|
||||
BRIDGE_HELPER(void, minimize, , ,)
|
||||
BRIDGE_HELPER(void, showContextHelp, , ,)
|
||||
BRIDGE_HELPER(void, setDesktop, int desktop, desktop,)
|
||||
|
||||
void Bridge::setKeepAbove( bool set )
|
||||
{
|
||||
if( c->keepAbove() != set )
|
||||
c->workspace()->performWindowOperation( c, KeepAboveOp );
|
||||
}
|
||||
void Bridge::setKeepAbove(bool set)
|
||||
{
|
||||
if (c->keepAbove() != set)
|
||||
c->workspace()->performWindowOperation(c, KeepAboveOp);
|
||||
}
|
||||
|
||||
void Bridge::setKeepBelow( bool set )
|
||||
{
|
||||
if( c->keepBelow() != set )
|
||||
c->workspace()->performWindowOperation( c, KeepBelowOp );
|
||||
}
|
||||
void Bridge::setKeepBelow(bool set)
|
||||
{
|
||||
if (c->keepBelow() != set)
|
||||
c->workspace()->performWindowOperation(c, KeepBelowOp);
|
||||
}
|
||||
|
||||
NET::WindowType Bridge::windowType( unsigned long supported_types ) const
|
||||
{
|
||||
return c->windowType( false, supported_types );
|
||||
}
|
||||
NET::WindowType Bridge::windowType(unsigned long supported_types) const
|
||||
{
|
||||
return c->windowType(false, supported_types);
|
||||
}
|
||||
|
||||
QIcon Bridge::icon() const
|
||||
{
|
||||
QIcon ret( c->icon());
|
||||
ret.addPixmap( c->miniIcon());
|
||||
{
|
||||
QIcon ret(c->icon());
|
||||
ret.addPixmap(c->miniIcon());
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
bool Bridge::isSetShade() const
|
||||
{
|
||||
{
|
||||
return c->shadeMode() != ShadeNone;
|
||||
}
|
||||
}
|
||||
|
||||
void Bridge::showWindowMenu( const QPoint &p )
|
||||
{
|
||||
c->workspace()->showWindowMenu( p, c );
|
||||
}
|
||||
void Bridge::showWindowMenu(const QPoint &p)
|
||||
{
|
||||
c->workspace()->showWindowMenu(p, c);
|
||||
}
|
||||
|
||||
void Bridge::showWindowMenu( const QRect &p )
|
||||
{
|
||||
c->workspace()->showWindowMenu( p, c );
|
||||
}
|
||||
void Bridge::showWindowMenu(const QRect &p)
|
||||
{
|
||||
c->workspace()->showWindowMenu(p, c);
|
||||
}
|
||||
|
||||
void Bridge::performWindowOperation( WindowOperation op )
|
||||
{
|
||||
c->workspace()->performWindowOperation( c, op );
|
||||
}
|
||||
void Bridge::performWindowOperation(WindowOperation op)
|
||||
{
|
||||
c->workspace()->performWindowOperation(c, op);
|
||||
}
|
||||
|
||||
void Bridge::setMask( const QRegion& r, int mode )
|
||||
{
|
||||
c->setMask( r, mode );
|
||||
}
|
||||
void Bridge::setMask(const QRegion& r, int mode)
|
||||
{
|
||||
c->setMask(r, mode);
|
||||
}
|
||||
|
||||
bool Bridge::isPreview() const
|
||||
{
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
QRect Bridge::iconGeometry() const
|
||||
{
|
||||
{
|
||||
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
|
||||
{
|
||||
{
|
||||
return c->window();
|
||||
}
|
||||
}
|
||||
|
||||
void Bridge::titlebarDblClickOperation()
|
||||
{
|
||||
c->workspace()->performWindowOperation( c, options->operationTitlebarDblClick());
|
||||
}
|
||||
{
|
||||
c->workspace()->performWindowOperation(c, options->operationTitlebarDblClick());
|
||||
}
|
||||
|
||||
void Bridge::titlebarMouseWheelOperation( int delta )
|
||||
{
|
||||
c->performMouseCommand( options->operationTitlebarMouseWheel( delta ), cursorPos());
|
||||
}
|
||||
void Bridge::titlebarMouseWheelOperation(int delta)
|
||||
{
|
||||
c->performMouseCommand(options->operationTitlebarMouseWheel(delta), cursorPos());
|
||||
}
|
||||
|
||||
void Bridge::setShade( bool set )
|
||||
{
|
||||
c->setShade( set ? ShadeNormal : ShadeNone );
|
||||
}
|
||||
void Bridge::setShade(bool set)
|
||||
{
|
||||
c->setShade(set ? ShadeNormal : ShadeNone);
|
||||
}
|
||||
|
||||
int Bridge::currentDesktop() const
|
||||
{
|
||||
{
|
||||
return c->workspace()->currentDesktop();
|
||||
}
|
||||
}
|
||||
|
||||
QWidget* Bridge::initialParentWidget() const
|
||||
{
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
Qt::WFlags Bridge::initialWFlags() const
|
||||
{
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
QRegion Bridge::unobscuredRegion( const QRegion& r ) const
|
||||
{
|
||||
QRegion reg( r );
|
||||
QRegion Bridge::unobscuredRegion(const QRegion& r) const
|
||||
{
|
||||
QRegion reg(r);
|
||||
const ClientList stacking_order = c->workspace()->stackingOrder();
|
||||
int pos = stacking_order.indexOf( c );
|
||||
int pos = stacking_order.indexOf(c);
|
||||
++pos;
|
||||
for(; pos < stacking_order.count(); ++pos )
|
||||
{
|
||||
if( !stacking_order[pos]->isShown( true ))
|
||||
for (; pos < stacking_order.count(); ++pos) {
|
||||
if (!stacking_order[pos]->isShown(true))
|
||||
continue; // these don't obscure the window
|
||||
if( c->isOnAllDesktops())
|
||||
{
|
||||
if( !stacking_order[ pos ]->isOnCurrentDesktop())
|
||||
if (c->isOnAllDesktops()) {
|
||||
if (!stacking_order[ pos ]->isOnCurrentDesktop())
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !stacking_order[ pos ]->isOnDesktop( c->desktop()))
|
||||
} else {
|
||||
if (!stacking_order[ pos ]->isOnDesktop(c->desktop()))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
/* the clients all have their mask-regions in local coords
|
||||
so we have to translate them to a shared coord system
|
||||
we choose ours */
|
||||
|
@ -186,121 +182,119 @@ QRegion Bridge::unobscuredRegion( const QRegion& r ) const
|
|||
QRegion creg = stacking_order[ pos ]->mask();
|
||||
creg.translate(dx, dy);
|
||||
reg -= creg;
|
||||
if (reg.isEmpty())
|
||||
{
|
||||
if (reg.isEmpty()) {
|
||||
// early out, we are completely obscured
|
||||
break;
|
||||
}
|
||||
}
|
||||
return reg;
|
||||
}
|
||||
return reg;
|
||||
}
|
||||
|
||||
void Bridge::grabXServer( bool grab )
|
||||
{
|
||||
if( grab )
|
||||
void Bridge::grabXServer(bool grab)
|
||||
{
|
||||
if (grab)
|
||||
KWin::grabXServer();
|
||||
else
|
||||
KWin::ungrabXServer();
|
||||
}
|
||||
}
|
||||
|
||||
bool Bridge::compositingActive() const
|
||||
{
|
||||
{
|
||||
return c->workspace()->compositingActive();
|
||||
}
|
||||
}
|
||||
|
||||
QRect Bridge::transparentRect() const
|
||||
{
|
||||
{
|
||||
return c->transparentRect().translated(-c->decorationRect().topLeft());
|
||||
}
|
||||
}
|
||||
|
||||
bool Bridge::isClientGroupActive()
|
||||
{
|
||||
if( c->clientGroup() )
|
||||
{
|
||||
if (c->clientGroup())
|
||||
return c->clientGroup()->containsActiveClient();
|
||||
return isActive();
|
||||
}
|
||||
}
|
||||
|
||||
QList< ClientGroupItem > Bridge::clientGroupItems() const
|
||||
{
|
||||
if( c->clientGroup() )
|
||||
{
|
||||
if (c->clientGroup())
|
||||
return c->clientGroup()->items();
|
||||
QList< ClientGroupItem > items;
|
||||
QIcon icon( c->icon() );
|
||||
icon.addPixmap( c->miniIcon() );
|
||||
items.append( ClientGroupItem( c->caption(), icon ));
|
||||
QIcon icon(c->icon());
|
||||
icon.addPixmap(c->miniIcon());
|
||||
items.append(ClientGroupItem(c->caption(), icon));
|
||||
return items;
|
||||
}
|
||||
}
|
||||
|
||||
long Bridge::itemId( int index )
|
||||
{
|
||||
if( !c->clientGroup() )
|
||||
long Bridge::itemId(int index)
|
||||
{
|
||||
if (!c->clientGroup())
|
||||
return 0;
|
||||
const ClientList list = c->clientGroup()->clients();
|
||||
return reinterpret_cast<long>( list.at( index ));
|
||||
}
|
||||
return reinterpret_cast<long>(list.at(index));
|
||||
}
|
||||
|
||||
int Bridge::visibleClientGroupItem()
|
||||
{
|
||||
if( c->clientGroup() )
|
||||
{
|
||||
if (c->clientGroup())
|
||||
return c->clientGroup()->indexOfVisibleClient();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void Bridge::setVisibleClientGroupItem( int index )
|
||||
{
|
||||
if( c->clientGroup() )
|
||||
c->clientGroup()->setVisible( index );
|
||||
}
|
||||
void Bridge::setVisibleClientGroupItem(int index)
|
||||
{
|
||||
if (c->clientGroup())
|
||||
c->clientGroup()->setVisible(index);
|
||||
}
|
||||
|
||||
void Bridge::moveItemInClientGroup( int index, int before )
|
||||
{
|
||||
if( c->clientGroup() )
|
||||
c->clientGroup()->move( index, before );
|
||||
}
|
||||
void Bridge::moveItemInClientGroup(int index, int before)
|
||||
{
|
||||
if (c->clientGroup())
|
||||
c->clientGroup()->move(index, before);
|
||||
}
|
||||
|
||||
void Bridge::moveItemToClientGroup( long itemId, int before )
|
||||
{
|
||||
Client* item = reinterpret_cast<Client*>( itemId );
|
||||
if( !c->workspace()->hasClient( item ))
|
||||
{
|
||||
void Bridge::moveItemToClientGroup(long itemId, int before)
|
||||
{
|
||||
Client* item = reinterpret_cast<Client*>(itemId);
|
||||
if (!c->workspace()->hasClient(item)) {
|
||||
kWarning(1212) << "****** ARBITRARY CODE EXECUTION ATTEMPT DETECTED ******";
|
||||
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 )
|
||||
{
|
||||
if( c->clientGroup() )
|
||||
c->clientGroup()->remove( index, newGeom );
|
||||
}
|
||||
void Bridge::removeFromClientGroup(int index, const QRect& newGeom)
|
||||
{
|
||||
if (c->clientGroup())
|
||||
c->clientGroup()->remove(index, newGeom);
|
||||
}
|
||||
|
||||
void Bridge::closeClientGroupItem( int index )
|
||||
{
|
||||
if( !c->clientGroup() )
|
||||
void Bridge::closeClientGroupItem(int index)
|
||||
{
|
||||
if (!c->clientGroup())
|
||||
return;
|
||||
const ClientList list = c->clientGroup()->clients();
|
||||
if( index >= 0 || index <= list.count() )
|
||||
list.at( index )->closeWindow();
|
||||
}
|
||||
if (index >= 0 || index <= list.count())
|
||||
list.at(index)->closeWindow();
|
||||
}
|
||||
|
||||
void Bridge::closeAllInClientGroup()
|
||||
{
|
||||
if( c->clientGroup() )
|
||||
{
|
||||
if (c->clientGroup())
|
||||
c->clientGroup()->closeAll();
|
||||
}
|
||||
}
|
||||
|
||||
void Bridge::displayClientMenu( int index, const QPoint& pos )
|
||||
{
|
||||
if( c->clientGroup() )
|
||||
c->clientGroup()->displayClientMenu( index, pos );
|
||||
}
|
||||
void Bridge::displayClientMenu(int index, const QPoint& pos)
|
||||
{
|
||||
if (c->clientGroup())
|
||||
c->clientGroup()->displayClientMenu(index, pos);
|
||||
}
|
||||
|
||||
KDecoration::WindowOperation Bridge::buttonToWindowOperation( Qt::MouseButtons button )
|
||||
{
|
||||
return c->mouseButtonToWindowOperation( button );
|
||||
}
|
||||
KDecoration::WindowOperation Bridge::buttonToWindowOperation(Qt::MouseButtons button)
|
||||
{
|
||||
return c->mouseButtonToWindowOperation(button);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
126
bridge.h
126
bridge.h
|
@ -29,72 +29,72 @@ namespace KWin
|
|||
class Client;
|
||||
|
||||
class Bridge : public KDecorationBridgeUnstable
|
||||
{
|
||||
public:
|
||||
Bridge( Client* cl );
|
||||
virtual bool isActive() const;
|
||||
virtual bool isCloseable() const;
|
||||
virtual bool isMaximizable() const;
|
||||
virtual MaximizeMode maximizeMode() const;
|
||||
virtual bool isMinimizable() const;
|
||||
virtual bool providesContextHelp() const;
|
||||
virtual int desktop() const;
|
||||
virtual bool isModal() const;
|
||||
virtual bool isShadeable() const;
|
||||
virtual bool isShade() const;
|
||||
virtual bool isSetShade() const;
|
||||
virtual bool keepAbove() const;
|
||||
virtual bool keepBelow() const;
|
||||
virtual bool isMovable() const;
|
||||
virtual bool isResizable() const;
|
||||
virtual NET::WindowType windowType( unsigned long supported_types ) const;
|
||||
virtual QIcon icon() const;
|
||||
virtual QString caption() const;
|
||||
virtual void processMousePressEvent( QMouseEvent* );
|
||||
virtual void showWindowMenu( const QPoint & );
|
||||
virtual void showWindowMenu( const QRect & );
|
||||
virtual void performWindowOperation( WindowOperation );
|
||||
virtual void setMask( const QRegion&, int );
|
||||
virtual bool isPreview() const;
|
||||
virtual QRect geometry() const;
|
||||
virtual QRect iconGeometry() const;
|
||||
virtual QRegion unobscuredRegion( const QRegion& r ) const;
|
||||
virtual WId windowId() const;
|
||||
virtual void closeWindow();
|
||||
virtual void maximize( MaximizeMode mode );
|
||||
virtual void minimize();
|
||||
virtual void showContextHelp();
|
||||
virtual void setDesktop( int desktop );
|
||||
virtual void titlebarDblClickOperation();
|
||||
virtual void titlebarMouseWheelOperation( int delta );
|
||||
virtual void setShade( bool set );
|
||||
virtual void setKeepAbove( bool );
|
||||
virtual void setKeepBelow( bool );
|
||||
virtual int currentDesktop() const;
|
||||
virtual QWidget* initialParentWidget() const;
|
||||
virtual Qt::WFlags initialWFlags() const;
|
||||
virtual void grabXServer( bool grab );
|
||||
{
|
||||
public:
|
||||
Bridge(Client* cl);
|
||||
virtual bool isActive() const;
|
||||
virtual bool isCloseable() const;
|
||||
virtual bool isMaximizable() const;
|
||||
virtual MaximizeMode maximizeMode() const;
|
||||
virtual bool isMinimizable() const;
|
||||
virtual bool providesContextHelp() const;
|
||||
virtual int desktop() const;
|
||||
virtual bool isModal() const;
|
||||
virtual bool isShadeable() const;
|
||||
virtual bool isShade() const;
|
||||
virtual bool isSetShade() const;
|
||||
virtual bool keepAbove() const;
|
||||
virtual bool keepBelow() const;
|
||||
virtual bool isMovable() const;
|
||||
virtual bool isResizable() const;
|
||||
virtual NET::WindowType windowType(unsigned long supported_types) const;
|
||||
virtual QIcon icon() const;
|
||||
virtual QString caption() const;
|
||||
virtual void processMousePressEvent(QMouseEvent*);
|
||||
virtual void showWindowMenu(const QPoint &);
|
||||
virtual void showWindowMenu(const QRect &);
|
||||
virtual void performWindowOperation(WindowOperation);
|
||||
virtual void setMask(const QRegion&, int);
|
||||
virtual bool isPreview() const;
|
||||
virtual QRect geometry() const;
|
||||
virtual QRect iconGeometry() const;
|
||||
virtual QRegion unobscuredRegion(const QRegion& r) const;
|
||||
virtual WId windowId() const;
|
||||
virtual void closeWindow();
|
||||
virtual void maximize(MaximizeMode mode);
|
||||
virtual void minimize();
|
||||
virtual void showContextHelp();
|
||||
virtual void setDesktop(int desktop);
|
||||
virtual void titlebarDblClickOperation();
|
||||
virtual void titlebarMouseWheelOperation(int delta);
|
||||
virtual void setShade(bool set);
|
||||
virtual void setKeepAbove(bool);
|
||||
virtual void setKeepBelow(bool);
|
||||
virtual int currentDesktop() const;
|
||||
virtual QWidget* initialParentWidget() const;
|
||||
virtual Qt::WFlags initialWFlags() const;
|
||||
virtual void grabXServer(bool grab);
|
||||
|
||||
virtual bool compositingActive() const;
|
||||
virtual QRect transparentRect() const;
|
||||
virtual bool compositingActive() const;
|
||||
virtual QRect transparentRect() const;
|
||||
|
||||
// Window tabbing
|
||||
virtual bool isClientGroupActive();
|
||||
virtual QList< ClientGroupItem > clientGroupItems() const;
|
||||
virtual long itemId( int index );
|
||||
virtual int visibleClientGroupItem();
|
||||
virtual void setVisibleClientGroupItem( int index );
|
||||
virtual void moveItemInClientGroup( int index, int before );
|
||||
virtual void moveItemToClientGroup( long itemId, int before );
|
||||
virtual void removeFromClientGroup( int index, const QRect& newGeom );
|
||||
virtual void closeClientGroupItem( int index );
|
||||
virtual void closeAllInClientGroup();
|
||||
virtual void displayClientMenu( int index, const QPoint& pos );
|
||||
virtual WindowOperation buttonToWindowOperation( Qt::MouseButtons button );
|
||||
// Window tabbing
|
||||
virtual bool isClientGroupActive();
|
||||
virtual QList< ClientGroupItem > clientGroupItems() const;
|
||||
virtual long itemId(int index);
|
||||
virtual int visibleClientGroupItem();
|
||||
virtual void setVisibleClientGroupItem(int index);
|
||||
virtual void moveItemInClientGroup(int index, int before);
|
||||
virtual void moveItemToClientGroup(long itemId, int before);
|
||||
virtual void removeFromClientGroup(int index, const QRect& newGeom);
|
||||
virtual void closeClientGroupItem(int index);
|
||||
virtual void closeAllInClientGroup();
|
||||
virtual void displayClientMenu(int index, const QPoint& pos);
|
||||
virtual WindowOperation buttonToWindowOperation(Qt::MouseButtons button);
|
||||
|
||||
private:
|
||||
Client* c;
|
||||
};
|
||||
private:
|
||||
Client* c;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
2230
client.cpp
2230
client.cpp
File diff suppressed because it is too large
Load Diff
410
clientgroup.cpp
410
clientgroup.cpp
|
@ -27,337 +27,323 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
ClientGroup::ClientGroup( Client *c )
|
||||
ClientGroup::ClientGroup(Client *c)
|
||||
: clients_()
|
||||
, items_()
|
||||
, visible_( 0 )
|
||||
, minSize_( 0, 0 )
|
||||
, maxSize_( INT_MAX, INT_MAX )
|
||||
{
|
||||
clients_.append( c );
|
||||
, visible_(0)
|
||||
, minSize_(0, 0)
|
||||
, maxSize_(INT_MAX, INT_MAX)
|
||||
{
|
||||
clients_.append(c);
|
||||
updateItems();
|
||||
updateMinMaxSize();
|
||||
Workspace::self()->addClientGroup( this );
|
||||
c->setClientShown( true ); // Ensure the client is visible
|
||||
Workspace::self()->addClientGroup(this);
|
||||
c->setClientShown(true); // Ensure the client is visible
|
||||
c->triggerDecorationRepaint(); // TODO: Required? Maybe for creating new group?
|
||||
}
|
||||
}
|
||||
|
||||
ClientGroup::~ClientGroup()
|
||||
{
|
||||
Workspace::self()->removeClientGroup( this );
|
||||
}
|
||||
{
|
||||
Workspace::self()->removeClientGroup(this);
|
||||
}
|
||||
|
||||
void ClientGroup::add( Client* c, int before, bool becomeVisible )
|
||||
{
|
||||
if( contains( c ) || !c->workspace()->decorationSupportsClientGrouping() )
|
||||
void ClientGroup::add(Client* c, int before, bool becomeVisible)
|
||||
{
|
||||
if (contains(c) || !c->workspace()->decorationSupportsClientGrouping())
|
||||
return;
|
||||
|
||||
// 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 REMOVE them from the actual group until we are certain that the client will be moved.
|
||||
ClientGroup* oldGroup = NULL;
|
||||
if( c->clientGroup() )
|
||||
{
|
||||
if (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
|
||||
// We do this here as the ungroup code in updateStates() cannot be called until add() completes
|
||||
ShadeMode oldShadeMode = c->shadeMode();
|
||||
if( c->shadeMode() != clients_[visible_]->shadeMode() )
|
||||
c->setShade( clients_[visible_]->shadeMode() );
|
||||
if( c->shadeMode() != clients_[visible_]->shadeMode() )
|
||||
{
|
||||
if( oldGroup ) // Re-add to old group if required
|
||||
c->setClientGroup( oldGroup );
|
||||
// One need to trigger decoration repaint on the group to
|
||||
if (c->shadeMode() != clients_[visible_]->shadeMode())
|
||||
c->setShade(clients_[visible_]->shadeMode());
|
||||
if (c->shadeMode() != clients_[visible_]->shadeMode()) {
|
||||
if (oldGroup) // Re-add to old group if required
|
||||
c->setClientGroup(oldGroup);
|
||||
// One need to trigger decoration repaint on the group to
|
||||
// make sure hover animations are properly reset.
|
||||
clients_[visible_]->triggerDecorationRepaint();
|
||||
return;
|
||||
}
|
||||
}
|
||||
QRect oldGeom = c->geometry();
|
||||
if( c->geometry() != clients_[visible_]->geometry() )
|
||||
c->setGeometry( clients_[visible_]->geometry() );
|
||||
if( c->geometry() != clients_[visible_]->geometry() )
|
||||
{
|
||||
if( c->shadeMode() != oldShadeMode )
|
||||
c->setShade( oldShadeMode ); // Restore old shade mode
|
||||
if( oldGroup ) // Re-add to old group if required
|
||||
c->setClientGroup( oldGroup );
|
||||
if (c->geometry() != clients_[visible_]->geometry())
|
||||
c->setGeometry(clients_[visible_]->geometry());
|
||||
if (c->geometry() != clients_[visible_]->geometry()) {
|
||||
if (c->shadeMode() != oldShadeMode)
|
||||
c->setShade(oldShadeMode); // Restore old shade mode
|
||||
if (oldGroup) // Re-add to old group if required
|
||||
c->setClientGroup(oldGroup);
|
||||
clients_[visible_]->triggerDecorationRepaint();
|
||||
return;
|
||||
}
|
||||
if( c->desktop() != clients_[visible_]->desktop() )
|
||||
c->setDesktop( clients_[visible_]->desktop() );
|
||||
if( c->desktop() != clients_[visible_]->desktop() )
|
||||
{
|
||||
if( c->geometry() != oldGeom )
|
||||
c->setGeometry( oldGeom ); // Restore old geometry
|
||||
if( c->shadeMode() != oldShadeMode )
|
||||
c->setShade( oldShadeMode ); // Restore old shade mode
|
||||
if( oldGroup ) // Re-add to old group if required
|
||||
c->setClientGroup( oldGroup );
|
||||
}
|
||||
if (c->desktop() != clients_[visible_]->desktop())
|
||||
c->setDesktop(clients_[visible_]->desktop());
|
||||
if (c->desktop() != clients_[visible_]->desktop()) {
|
||||
if (c->geometry() != oldGeom)
|
||||
c->setGeometry(oldGeom); // Restore old geometry
|
||||
if (c->shadeMode() != oldShadeMode)
|
||||
c->setShade(oldShadeMode); // Restore old shade mode
|
||||
if (oldGroup) // Re-add to old group if required
|
||||
c->setClientGroup(oldGroup);
|
||||
clients_[visible_]->triggerDecorationRepaint();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Tabbed windows MUST have a decoration
|
||||
if( c->noBorder() )
|
||||
c->setNoBorder( false );
|
||||
if( clients_[visible_]->noBorder() )
|
||||
clients_[visible_]->setNoBorder( false );
|
||||
if (c->noBorder())
|
||||
c->setNoBorder(false);
|
||||
if (clients_[visible_]->noBorder())
|
||||
clients_[visible_]->setNoBorder(false);
|
||||
|
||||
// Re-add to old group if required for the effect hook
|
||||
if( oldGroup )
|
||||
c->setClientGroup( oldGroup );
|
||||
if (oldGroup)
|
||||
c->setClientGroup(oldGroup);
|
||||
|
||||
// Notify effects of merge
|
||||
if( effects != NULL )
|
||||
if (effects != NULL)
|
||||
static_cast<EffectsHandlerImpl*>(effects)->clientGroupItemAdded(
|
||||
c->effectWindow(), clients_[visible_]->effectWindow() );
|
||||
c->effectWindow(), clients_[visible_]->effectWindow());
|
||||
|
||||
// Actually remove from old group if required and update
|
||||
if( c->clientGroup() )
|
||||
c->clientGroup()->remove( c );
|
||||
c->setClientGroup( this ); // Let the client know which group it belongs to
|
||||
if (c->clientGroup())
|
||||
c->clientGroup()->remove(c);
|
||||
c->setClientGroup(this); // Let the client know which group it belongs to
|
||||
|
||||
// Actually add to new group
|
||||
if( before >= 0 )
|
||||
{
|
||||
if( visible_ >= before )
|
||||
if (before >= 0) {
|
||||
if (visible_ >= before)
|
||||
visible_++;
|
||||
clients_.insert( before, c );
|
||||
}
|
||||
else
|
||||
clients_.append( c );
|
||||
if( !becomeVisible ) // Hide before adding
|
||||
c->setClientShown( false );
|
||||
clients_.insert(before, c);
|
||||
} else
|
||||
clients_.append(c);
|
||||
if (!becomeVisible) // Hide before adding
|
||||
c->setClientShown(false);
|
||||
updateItems();
|
||||
updateMinMaxSize();
|
||||
updateStates( clients_[visible_], c );
|
||||
updateStates(clients_[visible_], c);
|
||||
|
||||
if( becomeVisible ) // Set visible after settings geometry
|
||||
setVisible( c );
|
||||
if (becomeVisible) // Set visible after settings geometry
|
||||
setVisible(c);
|
||||
|
||||
// Activate the new visible window
|
||||
clients_[visible_]->setActive( true );
|
||||
clients_[visible_]->setActive(true);
|
||||
//clients_[visible_]->takeFocus( Allowed );
|
||||
//clients_[visible_]->workspace()->raiseClient( clients_[visible_] );
|
||||
|
||||
clients_[visible_]->triggerDecorationRepaint();
|
||||
}
|
||||
}
|
||||
|
||||
void ClientGroup::remove( int index, const QRect& newGeom, bool toNullGroup )
|
||||
{
|
||||
remove( clients_[index], newGeom, toNullGroup );
|
||||
}
|
||||
void ClientGroup::remove(int index, const QRect& newGeom, bool toNullGroup)
|
||||
{
|
||||
remove(clients_[index], newGeom, toNullGroup);
|
||||
}
|
||||
|
||||
void ClientGroup::remove( Client* c, const QRect& newGeom, bool toNullGroup )
|
||||
{
|
||||
if( !c )
|
||||
void ClientGroup::remove(Client* c, const QRect& newGeom, bool toNullGroup)
|
||||
{
|
||||
if (!c)
|
||||
return;
|
||||
if( clients_.count() < 2 )
|
||||
{
|
||||
c->setClientGroup( NULL );
|
||||
Workspace::self()->removeClientGroup( this ); // Remove immediately
|
||||
if (clients_.count() < 2) {
|
||||
c->setClientGroup(NULL);
|
||||
Workspace::self()->removeClientGroup(this); // Remove immediately
|
||||
delete this;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ClientList::const_iterator i;
|
||||
Client* newVisible = clients_[visible_];
|
||||
if( newVisible == c )
|
||||
newVisible = ( visible_ != clients_.size() - 1 ) ? clients_[visible_ + 1] : clients_[visible_ - 1];
|
||||
if (newVisible == c)
|
||||
newVisible = (visible_ != clients_.size() - 1) ? clients_[visible_ + 1] : clients_[visible_ - 1];
|
||||
|
||||
// Notify effects of removal
|
||||
if( effects )
|
||||
if (effects)
|
||||
static_cast<EffectsHandlerImpl*>(effects)->clientGroupItemRemoved(
|
||||
c->effectWindow(), newVisible->effectWindow() );
|
||||
c->effectWindow(), newVisible->effectWindow());
|
||||
|
||||
setVisible( newVisible ); // Display new window before removing old one
|
||||
clients_.removeAll( c );
|
||||
visible_ = indexOfClient( newVisible ); // Index may have changed
|
||||
setVisible(newVisible); // Display new window before removing old one
|
||||
clients_.removeAll(c);
|
||||
visible_ = indexOfClient(newVisible); // Index may have changed
|
||||
updateItems();
|
||||
updateMinMaxSize();
|
||||
|
||||
c->setClientGroup( toNullGroup ? NULL : new ClientGroup( c ));
|
||||
if( newGeom.isValid() )
|
||||
{
|
||||
c->setClientGroup(toNullGroup ? NULL : new ClientGroup(c));
|
||||
if (newGeom.isValid()) {
|
||||
// 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
|
||||
// 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
|
||||
// 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
|
||||
Client::MaximizeMode groupMaxMode( newVisible->maximizeMode() );
|
||||
if( ( ( groupMaxMode & Client::MaximizeHorizontal ) && newGeom.left() != newVisible->geometry().left() ) ||
|
||||
( ( groupMaxMode & Client::MaximizeVertical ) && newGeom.top() != newVisible->geometry().top() ) )
|
||||
c->maximize( Client::MaximizeRestore );
|
||||
c->setGeometry( newGeom );
|
||||
}
|
||||
newVisible->triggerDecorationRepaint();
|
||||
Client::MaximizeMode groupMaxMode(newVisible->maximizeMode());
|
||||
if (((groupMaxMode & Client::MaximizeHorizontal) && newGeom.left() != newVisible->geometry().left()) ||
|
||||
((groupMaxMode & Client::MaximizeVertical) && newGeom.top() != newVisible->geometry().top()))
|
||||
c->maximize(Client::MaximizeRestore);
|
||||
c->setGeometry(newGeom);
|
||||
}
|
||||
newVisible->triggerDecorationRepaint();
|
||||
}
|
||||
|
||||
void ClientGroup::removeAll()
|
||||
{
|
||||
while( clients_.count() > 1 )
|
||||
remove( clients_.at( 1 ));
|
||||
}
|
||||
{
|
||||
while (clients_.count() > 1)
|
||||
remove(clients_.at(1));
|
||||
}
|
||||
|
||||
void ClientGroup::closeAll()
|
||||
{
|
||||
{
|
||||
Client* front;
|
||||
ClientList list( clients_ );
|
||||
while( !list.isEmpty() )
|
||||
{
|
||||
ClientList list(clients_);
|
||||
while (!list.isEmpty()) {
|
||||
front = list.front();
|
||||
list.pop_front();
|
||||
if( front != clients_[visible_] )
|
||||
if (front != clients_[visible_])
|
||||
front->closeWindow();
|
||||
}
|
||||
}
|
||||
clients_[visible_]->closeWindow();
|
||||
}
|
||||
}
|
||||
|
||||
void ClientGroup::move( int index, int before )
|
||||
{
|
||||
move( clients_[index], ( before >= 0 && before < clients_.size() ) ? clients_[before] : NULL );
|
||||
}
|
||||
void ClientGroup::move(int index, int before)
|
||||
{
|
||||
move(clients_[index], (before >= 0 && before < clients_.size()) ? clients_[before] : NULL);
|
||||
}
|
||||
|
||||
void ClientGroup::move( Client* c, Client* before )
|
||||
{
|
||||
if( c == before ) // Impossible to do
|
||||
void ClientGroup::move(Client* c, Client* before)
|
||||
{
|
||||
if (c == before) // Impossible to do
|
||||
return;
|
||||
|
||||
Client* wasVisible = clients_[visible_];
|
||||
clients_.removeAll( c );
|
||||
clients_.insert( before ? indexOfClient( before ) : clients_.size(), c );
|
||||
visible_ = indexOfClient( wasVisible );
|
||||
clients_.removeAll(c);
|
||||
clients_.insert(before ? indexOfClient(before) : clients_.size(), c);
|
||||
visible_ = indexOfClient(wasVisible);
|
||||
updateItems();
|
||||
|
||||
clients_[visible_]->triggerDecorationRepaint();
|
||||
}
|
||||
}
|
||||
|
||||
void ClientGroup::displayClientMenu( int index, const QPoint& pos )
|
||||
{
|
||||
if( index == -1 )
|
||||
void ClientGroup::displayClientMenu(int index, const QPoint& pos)
|
||||
{
|
||||
if (index == -1)
|
||||
index = visible_;
|
||||
displayClientMenu( clients_[index], pos );
|
||||
}
|
||||
displayClientMenu(clients_[index], pos);
|
||||
}
|
||||
|
||||
void ClientGroup::displayClientMenu( Client* c, const QPoint& pos )
|
||||
{
|
||||
c->workspace()->showWindowMenu( pos, c );
|
||||
}
|
||||
void ClientGroup::displayClientMenu(Client* c, const QPoint& pos)
|
||||
{
|
||||
c->workspace()->showWindowMenu(pos, c);
|
||||
}
|
||||
|
||||
bool ClientGroup::containsActiveClient()
|
||||
{
|
||||
return contains( Workspace::self()->activeClient() );
|
||||
}
|
||||
{
|
||||
return contains(Workspace::self()->activeClient());
|
||||
}
|
||||
|
||||
void ClientGroup::setVisible( int index )
|
||||
{
|
||||
setVisible( clients_[index] );
|
||||
}
|
||||
void ClientGroup::setVisible(int index)
|
||||
{
|
||||
setVisible(clients_[index]);
|
||||
}
|
||||
|
||||
void ClientGroup::setVisible( Client* c )
|
||||
{
|
||||
if( c == clients_[visible_] || !contains( c ))
|
||||
void ClientGroup::setVisible(Client* c)
|
||||
{
|
||||
if (c == clients_[visible_] || !contains(c))
|
||||
return;
|
||||
|
||||
// Notify effects of switch
|
||||
if( effects != NULL )
|
||||
if (effects != NULL)
|
||||
static_cast<EffectsHandlerImpl*>(effects)->clientGroupItemSwitched(
|
||||
clients_[visible_]->effectWindow(), c->effectWindow() );
|
||||
clients_[visible_]->effectWindow(), c->effectWindow());
|
||||
|
||||
visible_ = indexOfClient( c );
|
||||
c->setClientShown( true );
|
||||
for( ClientList::const_iterator i = clients_.constBegin(); i != clients_.constEnd(); ++i )
|
||||
if( (*i) != c )
|
||||
(*i)->setClientShown( false );
|
||||
}
|
||||
visible_ = indexOfClient(c);
|
||||
c->setClientShown(true);
|
||||
for (ClientList::const_iterator i = clients_.constBegin(); i != clients_.constEnd(); ++i)
|
||||
if ((*i) != c)
|
||||
(*i)->setClientShown(false);
|
||||
}
|
||||
|
||||
void ClientGroup::updateStates( Client* main, Client* only )
|
||||
{
|
||||
for( ClientList::const_iterator i = clients_.constBegin(); i != clients_.constEnd(); i++ )
|
||||
if( (*i) != main && ( !only || (*i) == only ))
|
||||
{
|
||||
if( (*i)->isMinimized() != main->isMinimized() )
|
||||
{
|
||||
if( main->isMinimized() )
|
||||
(*i)->minimize( true );
|
||||
void ClientGroup::updateStates(Client* main, Client* only)
|
||||
{
|
||||
for (ClientList::const_iterator i = clients_.constBegin(); i != clients_.constEnd(); i++)
|
||||
if ((*i) != main && (!only || (*i) == only)) {
|
||||
if ((*i)->isMinimized() != main->isMinimized()) {
|
||||
if (main->isMinimized())
|
||||
(*i)->minimize(true);
|
||||
else
|
||||
(*i)->unminimize( true );
|
||||
}
|
||||
if( (*i)->isShade() != main->isShade() )
|
||||
(*i)->setShade( main->isShade() ? ShadeNormal : ShadeNone );
|
||||
if( (*i)->geometry() != main->geometry() )
|
||||
(*i)->setGeometry( main->geometry() );
|
||||
if( (*i)->desktop() != main->desktop() )
|
||||
(*i)->setDesktop( main->desktop() );
|
||||
if( (*i)->isOnAllDesktops() != main->isOnAllDesktops() )
|
||||
(*i)->setOnAllDesktops( main->isOnAllDesktops() );
|
||||
if( (*i)->activities() != main->activities() )
|
||||
(*i)->setOnActivities( main->activities() );
|
||||
if( (*i)->keepAbove() != main->keepAbove() )
|
||||
(*i)->setKeepAbove( main->keepAbove() );
|
||||
if( (*i)->keepBelow() != main->keepBelow() )
|
||||
(*i)->setKeepBelow( main->keepBelow() );
|
||||
(*i)->unminimize(true);
|
||||
}
|
||||
if ((*i)->isShade() != main->isShade())
|
||||
(*i)->setShade(main->isShade() ? ShadeNormal : ShadeNone);
|
||||
if ((*i)->geometry() != main->geometry())
|
||||
(*i)->setGeometry(main->geometry());
|
||||
if ((*i)->desktop() != main->desktop())
|
||||
(*i)->setDesktop(main->desktop());
|
||||
if ((*i)->isOnAllDesktops() != main->isOnAllDesktops())
|
||||
(*i)->setOnAllDesktops(main->isOnAllDesktops());
|
||||
if ((*i)->activities() != main->activities())
|
||||
(*i)->setOnActivities(main->activities());
|
||||
if ((*i)->keepAbove() != main->keepAbove())
|
||||
(*i)->setKeepAbove(main->keepAbove());
|
||||
if ((*i)->keepBelow() != main->keepBelow())
|
||||
(*i)->setKeepBelow(main->keepBelow());
|
||||
|
||||
// If it's not possible to have the same states then ungroup them, TODO: Check all states
|
||||
if( (*i)->geometry() != main->geometry() )
|
||||
remove( *i );
|
||||
if( (*i)->desktop() != main->desktop() )
|
||||
remove( *i );
|
||||
}
|
||||
}
|
||||
if ((*i)->geometry() != main->geometry())
|
||||
remove(*i);
|
||||
if ((*i)->desktop() != main->desktop())
|
||||
remove(*i);
|
||||
}
|
||||
}
|
||||
|
||||
void ClientGroup::updateItems()
|
||||
{
|
||||
{
|
||||
items_.clear();
|
||||
for( ClientList::const_iterator i = clients_.constBegin(); i != clients_.constEnd(); ++i )
|
||||
{
|
||||
QIcon icon( (*i)->icon() );
|
||||
icon.addPixmap( (*i)->miniIcon() );
|
||||
items_.append( ClientGroupItem( (*i)->caption(), icon ));
|
||||
}
|
||||
for (ClientList::const_iterator i = clients_.constBegin(); i != clients_.constEnd(); ++i) {
|
||||
QIcon icon((*i)->icon());
|
||||
icon.addPixmap((*i)->miniIcon());
|
||||
items_.append(ClientGroupItem((*i)->caption(), icon));
|
||||
}
|
||||
}
|
||||
|
||||
void ClientGroup::updateMinMaxSize()
|
||||
{
|
||||
{
|
||||
// Determine entire group's minimum and maximum sizes
|
||||
minSize_ = QSize( 0, 0 );
|
||||
maxSize_ = QSize( INT_MAX, INT_MAX );
|
||||
for( ClientList::const_iterator i = clients_.constBegin(); i != clients_.constEnd(); ++i )
|
||||
{
|
||||
if( (*i)->minSize().width() > minSize_.width() )
|
||||
minSize_.setWidth( (*i)->minSize().width() );
|
||||
if( (*i)->minSize().height() > minSize_.height() )
|
||||
minSize_.setHeight( (*i)->minSize().height() );
|
||||
if( (*i)->maxSize().width() < maxSize_.width() )
|
||||
maxSize_.setWidth( (*i)->maxSize().width() );
|
||||
if( (*i)->maxSize().height() < maxSize_.height() )
|
||||
maxSize_.setHeight( (*i)->maxSize().height() );
|
||||
}
|
||||
if( minSize_.width() > maxSize_.width() ||
|
||||
minSize_.height() > maxSize_.height() )
|
||||
{
|
||||
minSize_ = QSize(0, 0);
|
||||
maxSize_ = QSize(INT_MAX, INT_MAX);
|
||||
for (ClientList::const_iterator i = clients_.constBegin(); i != clients_.constEnd(); ++i) {
|
||||
if ((*i)->minSize().width() > minSize_.width())
|
||||
minSize_.setWidth((*i)->minSize().width());
|
||||
if ((*i)->minSize().height() > minSize_.height())
|
||||
minSize_.setHeight((*i)->minSize().height());
|
||||
if ((*i)->maxSize().width() < maxSize_.width())
|
||||
maxSize_.setWidth((*i)->maxSize().width());
|
||||
if ((*i)->maxSize().height() < maxSize_.height())
|
||||
maxSize_.setHeight((*i)->maxSize().height());
|
||||
}
|
||||
if (minSize_.width() > maxSize_.width() ||
|
||||
minSize_.height() > maxSize_.height()) {
|
||||
//kWarning(1212) << "ClientGroup's min size is greater than its max size. Setting max to min.";
|
||||
maxSize_ = minSize_;
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure all windows are within these sizes
|
||||
const QSize size = clients_[visible_]->clientSize();
|
||||
QSize newSize(
|
||||
qBound( minSize_.width(), size.width(), maxSize_.width() ),
|
||||
qBound( minSize_.height(), size.height(), maxSize_.height() ));
|
||||
if( newSize != size )
|
||||
for( ClientList::const_iterator i = clients_.constBegin(); i != clients_.constEnd(); ++i )
|
||||
qBound(minSize_.width(), size.width(), maxSize_.width()),
|
||||
qBound(minSize_.height(), size.height(), maxSize_.height()));
|
||||
if (newSize != size)
|
||||
for (ClientList::const_iterator i = clients_.constBegin(); i != clients_.constEnd(); ++i)
|
||||
// TODO: Doesn't affect shaded windows?
|
||||
// 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
|
||||
// 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)));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
283
clientgroup.h
283
clientgroup.h
|
@ -43,184 +43,185 @@ class Client;
|
|||
* 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
|
||||
* one client.
|
||||
*
|
||||
*
|
||||
* rohanp: Had to convert this object to a QObject to make it easier for adding
|
||||
* scripting interface to ClientGroup.
|
||||
*
|
||||
* If a group contains multiple clients then only one will ever be mapped at
|
||||
* any given time.
|
||||
*/
|
||||
class ClientGroup : public QObject {
|
||||
class ClientGroup : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* Creates a new group containing \p c.
|
||||
*/
|
||||
ClientGroup( Client* c );
|
||||
~ClientGroup();
|
||||
public:
|
||||
/**
|
||||
* Creates a new group containing \p c.
|
||||
*/
|
||||
ClientGroup(Client* c);
|
||||
~ClientGroup();
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
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
|
||||
* 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
|
||||
* of its own.
|
||||
*/
|
||||
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
|
||||
* 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.
|
||||
*/
|
||||
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
|
||||
to a group of their own.
|
||||
*/
|
||||
void removeAll();
|
||||
/**
|
||||
* Close all clients in this group.
|
||||
*/
|
||||
void closeAll();
|
||||
/**
|
||||
* Move the client at index \p index to the position before the client at index \p before
|
||||
* in the list.
|
||||
*/
|
||||
void move( int index, int before );
|
||||
/**
|
||||
* Move \p c to the position before \p before in the list.
|
||||
*/
|
||||
void move( Client* c, Client* before );
|
||||
/**
|
||||
* Display the right-click client menu belonging to the client at index \p index at the
|
||||
* global coordinates specified by \p pos.
|
||||
*/
|
||||
void displayClientMenu( int index, const QPoint& pos );
|
||||
/**
|
||||
* Display the right-click client menu belonging to \p c at the global coordinates
|
||||
* specified by \p pos.
|
||||
*/
|
||||
void displayClientMenu( Client* c, const QPoint& pos );
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
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
|
||||
* 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
|
||||
* of its own.
|
||||
*/
|
||||
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
|
||||
* 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.
|
||||
*/
|
||||
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
|
||||
to a group of their own.
|
||||
*/
|
||||
void removeAll();
|
||||
/**
|
||||
* Close all clients in this group.
|
||||
*/
|
||||
void closeAll();
|
||||
/**
|
||||
* Move the client at index \p index to the position before the client at index \p before
|
||||
* in the list.
|
||||
*/
|
||||
void move(int index, int before);
|
||||
/**
|
||||
* Move \p c to the position before \p before in the list.
|
||||
*/
|
||||
void move(Client* c, Client* before);
|
||||
/**
|
||||
* Display the right-click client menu belonging to the client at index \p index at the
|
||||
* global coordinates specified by \p pos.
|
||||
*/
|
||||
void displayClientMenu(int index, const QPoint& pos);
|
||||
/**
|
||||
* Display the right-click client menu belonging to \p c at the global coordinates
|
||||
* specified by \p pos.
|
||||
*/
|
||||
void displayClientMenu(Client* c, const QPoint& pos);
|
||||
|
||||
/**
|
||||
* Returns the list index of \p c.
|
||||
*/
|
||||
int indexOfClient( Client* c );
|
||||
/**
|
||||
* Returns the list index of the currently visible client in the group.
|
||||
*/
|
||||
int indexOfVisibleClient();
|
||||
/**
|
||||
* Returns whether or not this group contains \p c.
|
||||
*/
|
||||
bool contains( Client* c );
|
||||
/**
|
||||
* Returns whether or not this group contains the active client.
|
||||
*/
|
||||
bool containsActiveClient();
|
||||
/**
|
||||
* Returns the list index of \p c.
|
||||
*/
|
||||
int indexOfClient(Client* c);
|
||||
/**
|
||||
* Returns the list index of the currently visible client in the group.
|
||||
*/
|
||||
int indexOfVisibleClient();
|
||||
/**
|
||||
* Returns whether or not this group contains \p c.
|
||||
*/
|
||||
bool contains(Client* c);
|
||||
/**
|
||||
* Returns whether or not this group contains the active client.
|
||||
*/
|
||||
bool containsActiveClient();
|
||||
|
||||
/**
|
||||
* Returns the list of all the clients contained in this group in their current order.
|
||||
*/
|
||||
ClientList clients() const;
|
||||
/**
|
||||
* Returns a list of the captions and icons of all the clients contained in this group
|
||||
* in their current order.
|
||||
*/
|
||||
QList< ClientGroupItem > items() const;
|
||||
/**
|
||||
* Returns the list of all the clients contained in this group in their current order.
|
||||
*/
|
||||
ClientList clients() const;
|
||||
/**
|
||||
* Returns a list of the captions and icons of all the clients contained in this group
|
||||
* in their current order.
|
||||
*/
|
||||
QList< ClientGroupItem > items() const;
|
||||
|
||||
/**
|
||||
* Returns the currently visible client.
|
||||
*/
|
||||
Client* visible();
|
||||
/**
|
||||
* Makes the client at index \p index the visible one in the group.
|
||||
*/
|
||||
void setVisible( int index );
|
||||
/**
|
||||
* Makes \p c the visible client in the group.
|
||||
*/
|
||||
void setVisible( Client* c );
|
||||
/**
|
||||
* Returns the currently visible client.
|
||||
*/
|
||||
Client* visible();
|
||||
/**
|
||||
* Makes the client at index \p index the visible one in the group.
|
||||
*/
|
||||
void setVisible(int index);
|
||||
/**
|
||||
* Makes \p c the visible client in the group.
|
||||
*/
|
||||
void setVisible(Client* c);
|
||||
|
||||
/**
|
||||
* Returns combined minimum size of all clients in the group.
|
||||
*/
|
||||
QSize minSize() const;
|
||||
/**
|
||||
* Returns combined maximum size of all clients in the group.
|
||||
*/
|
||||
QSize maxSize() const;
|
||||
/**
|
||||
* Returns combined minimum size of all clients in the group.
|
||||
*/
|
||||
QSize minSize() const;
|
||||
/**
|
||||
* Returns combined maximum size of all clients in the group.
|
||||
*/
|
||||
QSize maxSize() const;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* that client is updated to match \p main.
|
||||
*/
|
||||
void updateStates( Client* main, Client* only = NULL );
|
||||
/**
|
||||
* 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
|
||||
* that client is updated to match \p main.
|
||||
*/
|
||||
void updateStates(Client* main, Client* only = NULL);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Regenerate the list of client captions and icons.
|
||||
*/
|
||||
void updateItems();
|
||||
/**
|
||||
* Determine the combined minimum and maximum sizes of all clients in the group.
|
||||
*/
|
||||
void updateMinMaxSize();
|
||||
private:
|
||||
/**
|
||||
* Regenerate the list of client captions and icons.
|
||||
*/
|
||||
void updateItems();
|
||||
/**
|
||||
* Determine the combined minimum and maximum sizes of all clients in the group.
|
||||
*/
|
||||
void updateMinMaxSize();
|
||||
|
||||
ClientList clients_;
|
||||
QList< ClientGroupItem > items_;
|
||||
int visible_;
|
||||
ClientList clients_;
|
||||
QList< ClientGroupItem > items_;
|
||||
int visible_;
|
||||
|
||||
QSize minSize_;
|
||||
QSize maxSize_;
|
||||
QSize minSize_;
|
||||
QSize maxSize_;
|
||||
|
||||
friend class Client;
|
||||
};
|
||||
friend class Client;
|
||||
};
|
||||
|
||||
inline int ClientGroup::indexOfClient( Client* c )
|
||||
{
|
||||
return clients_.indexOf( c );
|
||||
}
|
||||
inline int ClientGroup::indexOfClient(Client* c)
|
||||
{
|
||||
return clients_.indexOf(c);
|
||||
}
|
||||
|
||||
inline int ClientGroup::indexOfVisibleClient()
|
||||
{
|
||||
{
|
||||
return visible_;
|
||||
}
|
||||
}
|
||||
|
||||
inline bool ClientGroup::contains( Client* c )
|
||||
{
|
||||
return clients_.contains( c );
|
||||
}
|
||||
inline bool ClientGroup::contains(Client* c)
|
||||
{
|
||||
return clients_.contains(c);
|
||||
}
|
||||
|
||||
inline ClientList ClientGroup::clients() const
|
||||
{
|
||||
{
|
||||
return clients_;
|
||||
}
|
||||
}
|
||||
|
||||
inline QList< ClientGroupItem > ClientGroup::items() const
|
||||
{
|
||||
{
|
||||
return items_;
|
||||
}
|
||||
}
|
||||
|
||||
inline Client* ClientGroup::visible()
|
||||
{
|
||||
{
|
||||
return clients_[visible_];
|
||||
}
|
||||
}
|
||||
|
||||
inline QSize ClientGroup::minSize() const
|
||||
{
|
||||
{
|
||||
return minSize_;
|
||||
}
|
||||
}
|
||||
|
||||
inline QSize ClientGroup::maxSize() const
|
||||
{
|
||||
{
|
||||
return maxSize_;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
1083
composite.cpp
1083
composite.cpp
File diff suppressed because it is too large
Load Diff
|
@ -36,89 +36,84 @@ namespace KWin
|
|||
{
|
||||
|
||||
CompositingPrefs::CompositingPrefs()
|
||||
: mRecommendCompositing( false )
|
||||
, mEnableVSync( true )
|
||||
, mEnableDirectRendering( true )
|
||||
, mStrictBinding( true )
|
||||
{
|
||||
}
|
||||
: mRecommendCompositing(false)
|
||||
, mEnableVSync(true)
|
||||
, mEnableDirectRendering(true)
|
||||
, mStrictBinding(true)
|
||||
{
|
||||
}
|
||||
|
||||
CompositingPrefs::~CompositingPrefs()
|
||||
{
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
bool CompositingPrefs::recommendCompositing() const
|
||||
{
|
||||
{
|
||||
return mRecommendCompositing;
|
||||
}
|
||||
}
|
||||
|
||||
bool CompositingPrefs::compositingPossible()
|
||||
{
|
||||
{
|
||||
#ifdef KWIN_HAVE_COMPOSITING
|
||||
Extensions::init();
|
||||
if( !Extensions::compositeAvailable())
|
||||
{
|
||||
kDebug( 1212 ) << "No composite extension available";
|
||||
if (!Extensions::compositeAvailable()) {
|
||||
kDebug(1212) << "No composite extension available";
|
||||
return false;
|
||||
}
|
||||
if( !Extensions::damageAvailable())
|
||||
{
|
||||
kDebug( 1212 ) << "No damage extension available";
|
||||
}
|
||||
if (!Extensions::damageAvailable()) {
|
||||
kDebug(1212) << "No damage extension available";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
|
||||
if( Extensions::glxAvailable())
|
||||
if (Extensions::glxAvailable())
|
||||
return true;
|
||||
#endif
|
||||
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
||||
if( Extensions::renderAvailable() && Extensions::fixesAvailable())
|
||||
if (Extensions::renderAvailable() && Extensions::fixesAvailable())
|
||||
return true;
|
||||
#endif
|
||||
#ifdef KWIN_HAVE_OPENGLES
|
||||
return true;
|
||||
#endif
|
||||
kDebug( 1212 ) << "No OpenGL or XRender/XFixes support";
|
||||
kDebug(1212) << "No OpenGL or XRender/XFixes support";
|
||||
return false;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
QString CompositingPrefs::compositingNotPossibleReason()
|
||||
{
|
||||
{
|
||||
#ifdef KWIN_HAVE_COMPOSITING
|
||||
Extensions::init();
|
||||
if( !Extensions::compositeAvailable() || !Extensions::damageAvailable())
|
||||
{
|
||||
if (!Extensions::compositeAvailable() || !Extensions::damageAvailable()) {
|
||||
return i18n("Required X extensions (XComposite and XDamage) are not available.");
|
||||
}
|
||||
}
|
||||
#if defined( KWIN_HAVE_OPENGL_COMPOSITING ) && !defined( KWIN_HAVE_XRENDER_COMPOSITING )
|
||||
if( !Extensions::glxAvailable())
|
||||
return i18n( "GLX/OpenGL are not available and only OpenGL support is compiled." );
|
||||
if (!Extensions::glxAvailable())
|
||||
return i18n("GLX/OpenGL are not available and only OpenGL support is compiled.");
|
||||
#elif !defined( KWIN_HAVE_OPENGL_COMPOSITING ) && defined( KWIN_HAVE_XRENDER_COMPOSITING )
|
||||
if( !( Extensions::renderAvailable() && Extensions::fixesAvailable()))
|
||||
return i18n( "XRender/XFixes extensions are not available and only XRender support"
|
||||
" is compiled." );
|
||||
if (!(Extensions::renderAvailable() && Extensions::fixesAvailable()))
|
||||
return i18n("XRender/XFixes extensions are not available and only XRender support"
|
||||
" is compiled.");
|
||||
#else
|
||||
if( !( Extensions::glxAvailable()
|
||||
|| ( Extensions::renderAvailable() && Extensions::fixesAvailable())))
|
||||
{
|
||||
return i18n( "GLX/OpenGL and XRender/XFixes are not available." );
|
||||
}
|
||||
if (!(Extensions::glxAvailable()
|
||||
|| (Extensions::renderAvailable() && Extensions::fixesAvailable()))) {
|
||||
return i18n("GLX/OpenGL and XRender/XFixes are not available.");
|
||||
}
|
||||
#endif
|
||||
return QString();
|
||||
#else
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
void CompositingPrefs::detect()
|
||||
{
|
||||
if( !compositingPossible())
|
||||
{
|
||||
{
|
||||
if (!compositingPossible()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
|
||||
#ifdef KWIN_HAVE_OPENGLES
|
||||
|
@ -144,8 +139,7 @@ void CompositingPrefs::detect()
|
|||
}
|
||||
#else
|
||||
// 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
|
||||
// 0 if we can use direct rendering, and 1 otherwise.
|
||||
// The reason we have to use an external program is that after GLX
|
||||
|
@ -153,40 +147,38 @@ void CompositingPrefs::detect()
|
|||
// environment variable.
|
||||
// Direct rendering is preferred, since not all OpenGL extensions are
|
||||
// available with indirect rendering.
|
||||
const QString opengl_test = KStandardDirs::findExe( "kwin_opengl_test" );
|
||||
if ( QProcess::execute( opengl_test ) != 0 )
|
||||
setenv( "LIBGL_ALWAYS_INDIRECT", "1", true );
|
||||
}
|
||||
if( !Extensions::glxAvailable())
|
||||
{
|
||||
kDebug( 1212 ) << "No GLX available";
|
||||
const QString opengl_test = KStandardDirs::findExe("kwin_opengl_test");
|
||||
if (QProcess::execute(opengl_test) != 0)
|
||||
setenv("LIBGL_ALWAYS_INDIRECT", "1", true);
|
||||
}
|
||||
if (!Extensions::glxAvailable()) {
|
||||
kDebug(1212) << "No GLX available";
|
||||
return;
|
||||
}
|
||||
}
|
||||
int glxmajor, glxminor;
|
||||
glXQueryVersion( display(), &glxmajor, &glxminor );
|
||||
kDebug( 1212 ) << "glx version is " << glxmajor << "." << glxminor;
|
||||
bool hasglx13 = ( glxmajor > 1 || ( glxmajor == 1 && glxminor >= 3 ));
|
||||
glXQueryVersion(display(), &glxmajor, &glxminor);
|
||||
kDebug(1212) << "glx version is " << glxmajor << "." << glxminor;
|
||||
bool hasglx13 = (glxmajor > 1 || (glxmajor == 1 && glxminor >= 3));
|
||||
|
||||
// remember and later restore active context
|
||||
GLXContext oldcontext = glXGetCurrentContext();
|
||||
GLXDrawable olddrawable = glXGetCurrentDrawable();
|
||||
GLXDrawable oldreaddrawable = None;
|
||||
if( hasglx13 )
|
||||
if (hasglx13)
|
||||
oldreaddrawable = glXGetCurrentReadDrawable();
|
||||
|
||||
if( initGLXContext() )
|
||||
{
|
||||
if (initGLXContext()) {
|
||||
detectDriverAndVersion();
|
||||
applyDriverSpecificOptions();
|
||||
}
|
||||
if( hasglx13 )
|
||||
glXMakeContextCurrent( display(), olddrawable, oldreaddrawable, oldcontext );
|
||||
}
|
||||
if (hasglx13)
|
||||
glXMakeContextCurrent(display(), olddrawable, oldreaddrawable, oldcontext);
|
||||
else
|
||||
glXMakeCurrent( display(), olddrawable, oldcontext );
|
||||
glXMakeCurrent(display(), olddrawable, oldcontext);
|
||||
deleteGLXContext();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
bool CompositingPrefs::initGLXContext()
|
||||
{
|
||||
|
@ -202,44 +194,41 @@ bool CompositingPrefs::initGLXContext()
|
|||
attribs << GLX_BLUE_SIZE << 1;
|
||||
attribs << None;
|
||||
|
||||
XVisualInfo* visinfo = glXChooseVisual( display(), DefaultScreen( display()), attribs.data() );
|
||||
if( !visinfo )
|
||||
{
|
||||
XVisualInfo* visinfo = glXChooseVisual(display(), DefaultScreen(display()), attribs.data());
|
||||
if (!visinfo) {
|
||||
attribs.last() = GLX_DOUBLEBUFFER;
|
||||
attribs << None;
|
||||
visinfo = glXChooseVisual( display(), DefaultScreen( display()), attribs.data() );
|
||||
if (!visinfo)
|
||||
{
|
||||
kDebug( 1212 ) << "Error: couldn't find RGB GLX visual";
|
||||
visinfo = glXChooseVisual(display(), DefaultScreen(display()), attribs.data());
|
||||
if (!visinfo) {
|
||||
kDebug(1212) << "Error: couldn't find RGB GLX visual";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mGLContext = glXCreateContext( display(), visinfo, NULL, True );
|
||||
if ( !mGLContext )
|
||||
{
|
||||
kDebug( 1212 ) << "glXCreateContext failed";
|
||||
XDestroyWindow( display(), mGLWindow );
|
||||
mGLContext = glXCreateContext(display(), visinfo, NULL, True);
|
||||
if (!mGLContext) {
|
||||
kDebug(1212) << "glXCreateContext failed";
|
||||
XDestroyWindow(display(), mGLWindow);
|
||||
return false;
|
||||
}
|
||||
|
||||
XSetWindowAttributes attr;
|
||||
attr.background_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;
|
||||
unsigned long mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
|
||||
int width = 100, height = 100;
|
||||
mGLWindow = XCreateWindow( display(), rootWindow(), 0, 0, width, height,
|
||||
0, visinfo->depth, InputOutput,
|
||||
visinfo->visual, mask, &attr );
|
||||
mGLWindow = XCreateWindow(display(), rootWindow(), 0, 0, width, height,
|
||||
0, visinfo->depth, InputOutput,
|
||||
visinfo->visual, mask, &attr);
|
||||
|
||||
return glXMakeCurrent( display(), mGLWindow, mGLContext ) && !handler.error( true );
|
||||
return glXMakeCurrent(display(), mGLWindow, mGLContext) && !handler.error(true);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
#else
|
||||
return false;
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -247,10 +236,10 @@ void CompositingPrefs::deleteGLXContext()
|
|||
{
|
||||
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
|
||||
#ifndef KWIN_HAVE_OPENGLES
|
||||
if( mGLContext == NULL )
|
||||
if (mGLContext == NULL)
|
||||
return;
|
||||
glXDestroyContext( display(), mGLContext );
|
||||
XDestroyWindow( display(), mGLWindow );
|
||||
glXDestroyContext(display(), mGLContext);
|
||||
XDestroyWindow(display(), mGLWindow);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
@ -258,14 +247,14 @@ void CompositingPrefs::deleteGLXContext()
|
|||
bool CompositingPrefs::initEGLContext()
|
||||
{
|
||||
#ifdef KWIN_HAVE_OPENGLES
|
||||
mEGLDisplay = eglGetDisplay( display() );
|
||||
mEGLDisplay = eglGetDisplay(display());
|
||||
if (mEGLDisplay == EGL_NO_DISPLAY) {
|
||||
return false;
|
||||
}
|
||||
if (eglInitialize( mEGLDisplay, 0, 0 ) == EGL_FALSE) {
|
||||
if (eglInitialize(mEGLDisplay, 0, 0) == EGL_FALSE) {
|
||||
return false;
|
||||
}
|
||||
eglBindAPI( EGL_OPENGL_ES_API );
|
||||
eglBindAPI(EGL_OPENGL_ES_API);
|
||||
|
||||
const EGLint config_attribs[] = {
|
||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
||||
|
@ -297,26 +286,26 @@ bool CompositingPrefs::initEGLContext()
|
|||
XSetWindowAttributes attr;
|
||||
attr.background_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;
|
||||
unsigned long mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
|
||||
int width = 100, height = 100;
|
||||
mGLWindow = XCreateWindow( display(), rootWindow(), 0, 0, width, height,
|
||||
0, QX11Info::appDepth(), InputOutput,
|
||||
(Visual*)QX11Info::appVisual(), mask, &attr );
|
||||
mGLWindow = XCreateWindow(display(), rootWindow(), 0, 0, width, height,
|
||||
0, QX11Info::appDepth(), InputOutput,
|
||||
(Visual*)QX11Info::appVisual(), mask, &attr);
|
||||
|
||||
mEGLSurface = eglCreateWindowSurface( mEGLDisplay, config, mGLWindow, 0 );
|
||||
mEGLSurface = eglCreateWindowSurface(mEGLDisplay, config, mGLWindow, 0);
|
||||
|
||||
const EGLint context_attribs[] = {
|
||||
EGL_CONTEXT_CLIENT_VERSION, 2,
|
||||
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) {
|
||||
return false;
|
||||
}
|
||||
if (eglMakeCurrent( mEGLDisplay, mEGLSurface, mEGLSurface, mEGLContext ) == EGL_FALSE) {
|
||||
if (eglMakeCurrent(mEGLDisplay, mEGLSurface, mEGLSurface, mEGLContext) == EGL_FALSE) {
|
||||
return false;
|
||||
}
|
||||
EGLint error = eglGetError();
|
||||
|
@ -337,32 +326,32 @@ void CompositingPrefs::deleteEGLContext()
|
|||
eglDestroySurface(mEGLDisplay, mEGLSurface);
|
||||
eglTerminate(mEGLDisplay);
|
||||
eglReleaseThread();
|
||||
XDestroyWindow( display(), mGLWindow );
|
||||
XDestroyWindow(display(), mGLWindow);
|
||||
#endif
|
||||
}
|
||||
|
||||
void CompositingPrefs::detectDriverAndVersion()
|
||||
{
|
||||
{
|
||||
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
|
||||
GLPlatform *gl = GLPlatform::instance();
|
||||
gl->detect();
|
||||
gl->printResults();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// See http://techbase.kde.org/Projects/KWin/HW for a list of some cards that are known to work.
|
||||
void CompositingPrefs::applyDriverSpecificOptions()
|
||||
{
|
||||
{
|
||||
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
|
||||
// Always recommend
|
||||
mRecommendCompositing = true;
|
||||
|
||||
GLPlatform *gl = GLPlatform::instance();
|
||||
mStrictBinding = !gl->supports( LooseBinding );
|
||||
if ( gl->driver() == Driver_Intel )
|
||||
mStrictBinding = !gl->supports(LooseBinding);
|
||||
if (gl->driver() == Driver_Intel)
|
||||
mEnableVSync = false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -40,9 +40,15 @@ public:
|
|||
static bool compositingPossible();
|
||||
static QString compositingNotPossibleReason();
|
||||
bool recommendCompositing() const;
|
||||
bool enableVSync() const { return mEnableVSync; }
|
||||
bool enableDirectRendering() const { return mEnableDirectRendering; }
|
||||
bool strictBinding() const { return mStrictBinding; }
|
||||
bool enableVSync() const {
|
||||
return mEnableVSync;
|
||||
}
|
||||
bool enableDirectRendering() const {
|
||||
return mEnableDirectRendering;
|
||||
}
|
||||
bool strictBinding() const {
|
||||
return mStrictBinding;
|
||||
}
|
||||
|
||||
void detect();
|
||||
|
||||
|
|
112
deleted.cpp
112
deleted.cpp
|
@ -27,61 +27,59 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
Deleted::Deleted( Workspace* ws )
|
||||
: Toplevel( ws )
|
||||
, delete_refcount( 1 )
|
||||
, no_border( true )
|
||||
, padding_left( 0 )
|
||||
, padding_top( 0 )
|
||||
, padding_right( 0 )
|
||||
, padding_bottom( 0 )
|
||||
{
|
||||
}
|
||||
Deleted::Deleted(Workspace* ws)
|
||||
: Toplevel(ws)
|
||||
, delete_refcount(1)
|
||||
, no_border(true)
|
||||
, padding_left(0)
|
||||
, padding_top(0)
|
||||
, padding_right(0)
|
||||
, padding_bottom(0)
|
||||
{
|
||||
}
|
||||
|
||||
Deleted::~Deleted()
|
||||
{
|
||||
if( delete_refcount != 0 )
|
||||
{
|
||||
if (delete_refcount != 0)
|
||||
kError(1212) << "Deleted client has non-zero reference count (" << delete_refcount << ")";
|
||||
assert( delete_refcount == 0 );
|
||||
workspace()->removeDeleted( this, Allowed );
|
||||
assert(delete_refcount == 0);
|
||||
workspace()->removeDeleted(this, Allowed);
|
||||
deleteEffectWindow();
|
||||
}
|
||||
}
|
||||
|
||||
Deleted* Deleted::create( Toplevel* c )
|
||||
{
|
||||
Deleted* d = new Deleted( c->workspace());
|
||||
d->copyToDeleted( c );
|
||||
d->workspace()->addDeleted( d, Allowed );
|
||||
Deleted* Deleted::create(Toplevel* c)
|
||||
{
|
||||
Deleted* d = new Deleted(c->workspace());
|
||||
d->copyToDeleted(c);
|
||||
d->workspace()->addDeleted(d, Allowed);
|
||||
return d;
|
||||
}
|
||||
}
|
||||
|
||||
// to be used only from Workspace::finishCompositing()
|
||||
void Deleted::discard( allowed_t )
|
||||
{
|
||||
void Deleted::discard(allowed_t)
|
||||
{
|
||||
delete_refcount = 0;
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
|
||||
void Deleted::copyToDeleted( Toplevel* c )
|
||||
{
|
||||
assert( dynamic_cast< Deleted* >( c ) == NULL );
|
||||
Toplevel::copyToDeleted( c );
|
||||
void Deleted::copyToDeleted(Toplevel* c)
|
||||
{
|
||||
assert(dynamic_cast< Deleted* >(c) == NULL);
|
||||
Toplevel::copyToDeleted(c);
|
||||
desk = c->desktop();
|
||||
activityList = c->activities();
|
||||
contentsRect = QRect( c->clientPos(), c->clientSize());
|
||||
contentsRect = QRect(c->clientPos(), c->clientSize());
|
||||
transparent_rect = c->transparentRect();
|
||||
if( WinInfo* cinfo = dynamic_cast< WinInfo* >( info ))
|
||||
if (WinInfo* cinfo = dynamic_cast< WinInfo* >(info))
|
||||
cinfo->disable();
|
||||
Client* client = dynamic_cast<Client*>(c);
|
||||
if( client )
|
||||
{
|
||||
if (client) {
|
||||
no_border = client->noBorder();
|
||||
padding_left = client->paddingLeft();
|
||||
padding_right = client->paddingRight();
|
||||
padding_bottom = client->paddingBottom();
|
||||
padding_top = client->paddingTop();
|
||||
if( !no_border )
|
||||
{
|
||||
if (!no_border) {
|
||||
client->layoutDecorationRects(decoration_left,
|
||||
decoration_top,
|
||||
decoration_right,
|
||||
|
@ -91,64 +89,64 @@ void Deleted::copyToDeleted( Toplevel* c )
|
|||
decorationPixmapRight = *client->rightDecoPixmap();
|
||||
decorationPixmapTop = *client->topDecoPixmap();
|
||||
decorationPixmapBottom = *client->bottomDecoPixmap();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Deleted::unrefWindow( bool delay )
|
||||
{
|
||||
if( --delete_refcount > 0 )
|
||||
void Deleted::unrefWindow(bool delay)
|
||||
{
|
||||
if (--delete_refcount > 0)
|
||||
return;
|
||||
// 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
|
||||
if( delay )
|
||||
if (delay)
|
||||
deleteLater();
|
||||
else
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
|
||||
int Deleted::desktop() const
|
||||
{
|
||||
{
|
||||
return desk;
|
||||
}
|
||||
}
|
||||
|
||||
QStringList Deleted::activities() const
|
||||
{
|
||||
{
|
||||
return activityList;
|
||||
}
|
||||
}
|
||||
|
||||
QPoint Deleted::clientPos() const
|
||||
{
|
||||
{
|
||||
return contentsRect.topLeft();
|
||||
}
|
||||
}
|
||||
|
||||
QSize Deleted::clientSize() const
|
||||
{
|
||||
{
|
||||
return contentsRect.size();
|
||||
}
|
||||
}
|
||||
|
||||
void Deleted::debug( QDebug& stream ) const
|
||||
{
|
||||
void Deleted::debug(QDebug& stream) const
|
||||
{
|
||||
stream << "\'ID:" << window() << "\' (deleted)";
|
||||
}
|
||||
}
|
||||
|
||||
void Deleted::layoutDecorationRects(QRect& left, QRect& top, QRect& right, QRect& bottom) const
|
||||
{
|
||||
{
|
||||
left = decoration_left;
|
||||
top = decoration_top;
|
||||
right = decoration_right;
|
||||
bottom = decoration_bottom;
|
||||
}
|
||||
}
|
||||
|
||||
QRect Deleted::decorationRect() const
|
||||
{
|
||||
{
|
||||
return rect().adjusted(-padding_left, -padding_top, padding_top, padding_bottom);
|
||||
}
|
||||
}
|
||||
|
||||
QRect Deleted::transparentRect() const
|
||||
{
|
||||
{
|
||||
return transparent_rect;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
102
deleted.h
102
deleted.h
|
@ -28,57 +28,67 @@ namespace KWin
|
|||
|
||||
class Deleted
|
||||
: public Toplevel
|
||||
{
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static Deleted* create( Toplevel* c );
|
||||
// used by effects to keep the window around for e.g. fadeout effects when it's destroyed
|
||||
void refWindow();
|
||||
void unrefWindow( bool delay = false );
|
||||
void discard( allowed_t );
|
||||
virtual int desktop() const;
|
||||
virtual QStringList activities() const;
|
||||
virtual QPoint clientPos() const;
|
||||
virtual QSize clientSize() const;
|
||||
virtual QRect transparentRect() const;
|
||||
const QPixmap *topDecoPixmap() const { return &decorationPixmapTop; }
|
||||
const QPixmap *leftDecoPixmap() const { return &decorationPixmapLeft; }
|
||||
const QPixmap *bottomDecoPixmap() const { return &decorationPixmapBottom; }
|
||||
const QPixmap *rightDecoPixmap() const { return &decorationPixmapRight; }
|
||||
bool noBorder() const { return no_border; }
|
||||
void layoutDecorationRects(QRect &left, QRect &top, QRect &right, QRect &bottom) const;
|
||||
virtual void addRepaintFull(); // in composite.cpp
|
||||
QRect decorationRect() const;
|
||||
protected:
|
||||
virtual void debug( QDebug& stream ) const;
|
||||
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;
|
||||
public:
|
||||
static Deleted* create(Toplevel* c);
|
||||
// used by effects to keep the window around for e.g. fadeout effects when it's destroyed
|
||||
void refWindow();
|
||||
void unrefWindow(bool delay = false);
|
||||
void discard(allowed_t);
|
||||
virtual int desktop() const;
|
||||
virtual QStringList activities() const;
|
||||
virtual QPoint clientPos() const;
|
||||
virtual QSize clientSize() const;
|
||||
virtual QRect transparentRect() const;
|
||||
const QPixmap *topDecoPixmap() const {
|
||||
return &decorationPixmapTop;
|
||||
}
|
||||
const QPixmap *leftDecoPixmap() const {
|
||||
return &decorationPixmapLeft;
|
||||
}
|
||||
const QPixmap *bottomDecoPixmap() const {
|
||||
return &decorationPixmapBottom;
|
||||
}
|
||||
const QPixmap *rightDecoPixmap() const {
|
||||
return &decorationPixmapRight;
|
||||
}
|
||||
bool noBorder() const {
|
||||
return no_border;
|
||||
}
|
||||
void layoutDecorationRects(QRect &left, QRect &top, QRect &right, QRect &bottom) const;
|
||||
virtual void addRepaintFull(); // in composite.cpp
|
||||
QRect decorationRect() const;
|
||||
protected:
|
||||
virtual void debug(QDebug& stream) const;
|
||||
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 decorationPixmapRight;
|
||||
QPixmap decorationPixmapTop;
|
||||
QPixmap decorationPixmapBottom;
|
||||
bool no_border;
|
||||
QRect decoration_left;
|
||||
QRect decoration_right;
|
||||
QRect decoration_top;
|
||||
QRect decoration_bottom;
|
||||
int padding_left, padding_top, padding_right, padding_bottom;
|
||||
};
|
||||
QPixmap decorationPixmapLeft;
|
||||
QPixmap decorationPixmapRight;
|
||||
QPixmap decorationPixmapTop;
|
||||
QPixmap decorationPixmapBottom;
|
||||
bool no_border;
|
||||
QRect decoration_left;
|
||||
QRect decoration_right;
|
||||
QRect decoration_top;
|
||||
QRect decoration_bottom;
|
||||
int padding_left, padding_top, padding_right, padding_bottom;
|
||||
};
|
||||
|
||||
inline void Deleted::refWindow()
|
||||
{
|
||||
{
|
||||
++delete_refcount;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -38,597 +38,543 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
DesktopChangeOSD::DesktopChangeOSD( Workspace* ws )
|
||||
DesktopChangeOSD::DesktopChangeOSD(Workspace* ws)
|
||||
: QGraphicsView()
|
||||
, m_wspace( ws )
|
||||
, m_scene( 0 )
|
||||
, m_active( false )
|
||||
, m_show( false )
|
||||
, m_delayTime( 0 )
|
||||
, m_textOnly( false )
|
||||
{
|
||||
setWindowFlags( Qt::X11BypassWindowManagerHint );
|
||||
setFrameStyle( QFrame::NoFrame );
|
||||
viewport()->setAutoFillBackground( false );
|
||||
setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
|
||||
setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
|
||||
setAttribute( Qt::WA_TranslucentBackground );
|
||||
m_frame.setImagePath( "dialogs/background" );
|
||||
m_frame.setCacheAllRenderedFrames( true );
|
||||
m_frame.setEnabledBorders( Plasma::FrameSvg::AllBorders );
|
||||
, m_wspace(ws)
|
||||
, m_scene(0)
|
||||
, m_active(false)
|
||||
, m_show(false)
|
||||
, m_delayTime(0)
|
||||
, m_textOnly(false)
|
||||
{
|
||||
setWindowFlags(Qt::X11BypassWindowManagerHint);
|
||||
setFrameStyle(QFrame::NoFrame);
|
||||
viewport()->setAutoFillBackground(false);
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setAttribute(Qt::WA_TranslucentBackground);
|
||||
m_frame.setImagePath("dialogs/background");
|
||||
m_frame.setCacheAllRenderedFrames(true);
|
||||
m_frame.setEnabledBorders(Plasma::FrameSvg::AllBorders);
|
||||
|
||||
m_item_frame.setImagePath( "widgets/pager" );
|
||||
m_item_frame.setCacheAllRenderedFrames( true );
|
||||
m_item_frame.setEnabledBorders( Plasma::FrameSvg::AllBorders );
|
||||
m_item_frame.setImagePath("widgets/pager");
|
||||
m_item_frame.setCacheAllRenderedFrames(true);
|
||||
m_item_frame.setEnabledBorders(Plasma::FrameSvg::AllBorders);
|
||||
|
||||
m_delayedHideTimer.setSingleShot( true );
|
||||
connect( &m_delayedHideTimer, SIGNAL(timeout()), this, SLOT(hide()) );
|
||||
m_delayedHideTimer.setSingleShot(true);
|
||||
connect(&m_delayedHideTimer, SIGNAL(timeout()), this, SLOT(hide()));
|
||||
|
||||
m_scene = new QGraphicsScene( 0 );
|
||||
setScene( m_scene );
|
||||
m_scene = new QGraphicsScene(0);
|
||||
setScene(m_scene);
|
||||
|
||||
reconfigure();
|
||||
|
||||
m_scene->addItem( new DesktopChangeText( m_wspace ) );
|
||||
}
|
||||
m_scene->addItem(new DesktopChangeText(m_wspace));
|
||||
}
|
||||
|
||||
DesktopChangeOSD::~DesktopChangeOSD()
|
||||
{
|
||||
{
|
||||
delete m_scene;
|
||||
}
|
||||
}
|
||||
|
||||
void DesktopChangeOSD::reconfigure()
|
||||
{
|
||||
{
|
||||
KSharedConfigPtr c(KGlobal::config());
|
||||
const KConfigGroup cg = c->group( "PopupInfo" );
|
||||
m_show = cg.readEntry( "ShowPopup", false );
|
||||
m_delayTime = cg.readEntry( "PopupHideDelay", 1000 );
|
||||
m_textOnly = cg.readEntry( "TextOnly", false );
|
||||
const KConfigGroup cg = c->group("PopupInfo");
|
||||
m_show = cg.readEntry("ShowPopup", false);
|
||||
m_delayTime = cg.readEntry("PopupHideDelay", 1000);
|
||||
m_textOnly = cg.readEntry("TextOnly", false);
|
||||
numberDesktopsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void DesktopChangeOSD::desktopChanged( int old )
|
||||
{
|
||||
if( !m_show )
|
||||
void DesktopChangeOSD::desktopChanged(int old)
|
||||
{
|
||||
if (!m_show)
|
||||
return;
|
||||
// we have to stop in case the old desktop does not exist anymore
|
||||
if( old > m_wspace->numberOfDesktops() )
|
||||
if (old > m_wspace->numberOfDesktops())
|
||||
return;
|
||||
// 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>();
|
||||
int desktop = old;
|
||||
int target = m_wspace->currentDesktop();
|
||||
int x = diff.x();
|
||||
int y = diff.y();
|
||||
if( y >= 0 )
|
||||
{
|
||||
if (y >= 0) {
|
||||
// first go in x direction, then in y
|
||||
while( desktop != target )
|
||||
{
|
||||
if( x != 0 )
|
||||
{
|
||||
if( x < 0 )
|
||||
{
|
||||
while (desktop != target) {
|
||||
if (x != 0) {
|
||||
if (x < 0) {
|
||||
x++;
|
||||
hash.insert( desktop, DesktopChangeItem::LEFT );
|
||||
desktop = m_wspace->desktopToLeft( desktop );
|
||||
}
|
||||
else
|
||||
{
|
||||
hash.insert(desktop, DesktopChangeItem::LEFT);
|
||||
desktop = m_wspace->desktopToLeft(desktop);
|
||||
} else {
|
||||
x--;
|
||||
hash.insert( desktop, DesktopChangeItem::RIGHT );
|
||||
desktop = m_wspace->desktopToRight( desktop );
|
||||
}
|
||||
continue;
|
||||
hash.insert(desktop, DesktopChangeItem::RIGHT);
|
||||
desktop = m_wspace->desktopToRight(desktop);
|
||||
}
|
||||
y--;
|
||||
hash.insert( desktop, DesktopChangeItem::DOWN );
|
||||
desktop = m_wspace->desktopBelow( desktop );
|
||||
continue;
|
||||
}
|
||||
y--;
|
||||
hash.insert(desktop, DesktopChangeItem::DOWN);
|
||||
desktop = m_wspace->desktopBelow(desktop);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// first go in y direction, then in x
|
||||
while( target != desktop )
|
||||
{
|
||||
if( y != 0 )
|
||||
{
|
||||
while (target != desktop) {
|
||||
if (y != 0) {
|
||||
// only go upward
|
||||
y++;
|
||||
hash.insert( desktop, DesktopChangeItem::UP );
|
||||
desktop = m_wspace->desktopAbove( desktop );
|
||||
hash.insert(desktop, DesktopChangeItem::UP);
|
||||
desktop = m_wspace->desktopAbove(desktop);
|
||||
continue;
|
||||
}
|
||||
if( x != 0 )
|
||||
{
|
||||
if( x < 0 )
|
||||
{
|
||||
}
|
||||
if (x != 0) {
|
||||
if (x < 0) {
|
||||
x++;
|
||||
hash.insert( desktop, DesktopChangeItem::LEFT );
|
||||
desktop = m_wspace->desktopToLeft( desktop );
|
||||
}
|
||||
else
|
||||
{
|
||||
hash.insert(desktop, DesktopChangeItem::LEFT);
|
||||
desktop = m_wspace->desktopToLeft(desktop);
|
||||
} else {
|
||||
x--;
|
||||
hash.insert( desktop, DesktopChangeItem::RIGHT );
|
||||
desktop = m_wspace->desktopToRight( desktop );
|
||||
}
|
||||
hash.insert(desktop, DesktopChangeItem::RIGHT);
|
||||
desktop = m_wspace->desktopToRight(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() );
|
||||
foreach( QGraphicsItem* it, m_scene->items() )
|
||||
{
|
||||
DesktopChangeItem* item = qgraphicsitem_cast< DesktopChangeItem* >( it );
|
||||
if( item )
|
||||
{
|
||||
if( hash.contains( item->desktop() ) )
|
||||
{
|
||||
QPoint distance = m_wspace->desktopGridCoords( m_wspace->currentDesktop() )
|
||||
- m_wspace->desktopGridCoords( item->desktop() );
|
||||
int desktopDistance = numberOfArrows - ( qAbs( distance.x() ) + qAbs( distance.y() ) );
|
||||
int start = m_delayTime/numberOfArrows * desktopDistance - m_delayTime*0.15f;
|
||||
int stop = m_delayTime/numberOfArrows * (desktopDistance + 1) + m_delayTime*0.15f;
|
||||
start = qMax( start, 0 );
|
||||
item->setArrow( hash[ item->desktop() ], start, stop );
|
||||
}
|
||||
else
|
||||
{
|
||||
item->setArrow( DesktopChangeItem::NONE, 0, 0 );
|
||||
}
|
||||
if( old != m_wspace->currentDesktop() )
|
||||
{
|
||||
if( item->desktop() == m_wspace->currentDesktop() )
|
||||
item->startDesktopHighLightAnimation( m_delayTime * 0.33 );
|
||||
if( m_active && item->desktop() == old )
|
||||
int numberOfArrows = qAbs(diff.x()) + qAbs(diff.y());
|
||||
foreach (QGraphicsItem * it, m_scene->items()) {
|
||||
DesktopChangeItem* item = qgraphicsitem_cast< DesktopChangeItem* >(it);
|
||||
if (item) {
|
||||
if (hash.contains(item->desktop())) {
|
||||
QPoint distance = m_wspace->desktopGridCoords(m_wspace->currentDesktop())
|
||||
- m_wspace->desktopGridCoords(item->desktop());
|
||||
int desktopDistance = numberOfArrows - (qAbs(distance.x()) + qAbs(distance.y()));
|
||||
int start = m_delayTime / numberOfArrows * desktopDistance - m_delayTime * 0.15f;
|
||||
int stop = m_delayTime / numberOfArrows * (desktopDistance + 1) + m_delayTime * 0.15f;
|
||||
start = qMax(start, 0);
|
||||
item->setArrow(hash[ item->desktop()], start, stop);
|
||||
} else {
|
||||
item->setArrow(DesktopChangeItem::NONE, 0, 0);
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
if( m_active )
|
||||
{
|
||||
}
|
||||
if (m_active) {
|
||||
// for text only we need to resize
|
||||
if( m_textOnly )
|
||||
if (m_textOnly)
|
||||
resize();
|
||||
// already active - just update and reset timer
|
||||
update();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
m_active = true;
|
||||
resize();
|
||||
show();
|
||||
raise();
|
||||
}
|
||||
}
|
||||
// Set a zero inputmask, effectively making clicks go "through" the popup
|
||||
// For those who impatiently wait to click on a dialog behind the it
|
||||
XShapeCombineRectangles( display(), winId(), ShapeInput, 0, 0, NULL, 0, ShapeSet, Unsorted );
|
||||
m_delayedHideTimer.start( m_delayTime );
|
||||
}
|
||||
XShapeCombineRectangles(display(), winId(), ShapeInput, 0, 0, NULL, 0, ShapeSet, Unsorted);
|
||||
m_delayedHideTimer.start(m_delayTime);
|
||||
}
|
||||
|
||||
void DesktopChangeOSD::hideEvent( QHideEvent* )
|
||||
{
|
||||
void DesktopChangeOSD::hideEvent(QHideEvent*)
|
||||
{
|
||||
m_delayedHideTimer.stop();
|
||||
m_active = false;
|
||||
}
|
||||
}
|
||||
|
||||
void DesktopChangeOSD::drawBackground( QPainter* painter, const QRectF& rect )
|
||||
{
|
||||
void DesktopChangeOSD::drawBackground(QPainter* painter, const QRectF& rect)
|
||||
{
|
||||
painter->save();
|
||||
painter->setCompositionMode( QPainter::CompositionMode_Source );
|
||||
painter->setCompositionMode(QPainter::CompositionMode_Source);
|
||||
qreal left, top, right, bottom;
|
||||
m_frame.getMargins( left, top, right, bottom );
|
||||
m_frame.paintFrame( painter, rect.adjusted( -left, -top, right, bottom ) );
|
||||
m_frame.getMargins(left, top, right, bottom);
|
||||
m_frame.paintFrame(painter, rect.adjusted(-left, -top, right, bottom));
|
||||
painter->restore();
|
||||
}
|
||||
}
|
||||
|
||||
void DesktopChangeOSD::numberDesktopsChanged()
|
||||
{
|
||||
foreach( QGraphicsItem* it, m_scene->items() )
|
||||
{
|
||||
{
|
||||
foreach (QGraphicsItem * it, m_scene->items()) {
|
||||
DesktopChangeItem* item = qgraphicsitem_cast<DesktopChangeItem*>(it);
|
||||
if( 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 (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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DesktopChangeOSD::resize()
|
||||
{
|
||||
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 screenRect = m_wspace->clientArea(ScreenArea, m_wspace->activeScreen(), m_wspace->currentDesktop());
|
||||
QRect fullRect = m_wspace->clientArea(FullArea, m_wspace->activeScreen(), m_wspace->currentDesktop());
|
||||
qreal left, top, right, bottom;
|
||||
m_frame.getMargins( left, top, right, bottom );
|
||||
m_frame.getMargins(left, top, right, bottom);
|
||||
|
||||
QSize desktopGridSize = m_wspace->desktopGridSize();
|
||||
float itemWidth = fullRect.width()*0.1f;
|
||||
float itemHeight = fullRect.height()*0.1f;
|
||||
float itemWidth = fullRect.width() * 0.1f;
|
||||
float itemHeight = fullRect.height() * 0.1f;
|
||||
// 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 height = (desktopGridSize.height()-1)*2 + top + bottom;
|
||||
float width = (desktopGridSize.width() - 1) * 2 + desktopGridSize.width() * itemWidth + left + right;
|
||||
float height = (desktopGridSize.height() - 1) * 2 + top + bottom;
|
||||
|
||||
// bound width between ten and 33 percent of active screen
|
||||
float tempWidth = qBound( screenRect.width()*0.25f, width, screenRect.width()*0.5f );
|
||||
if( tempWidth != width )
|
||||
{
|
||||
float tempWidth = qBound(screenRect.width() * 0.25f, width, screenRect.width() * 0.5f);
|
||||
if (tempWidth != width) {
|
||||
// have to adjust the height
|
||||
width = tempWidth;
|
||||
itemWidth = (width - (desktopGridSize.width()-1)*2 - left - right)/desktopGridSize.width();
|
||||
itemHeight = itemWidth*(float)((float)fullRect.height()/(float)fullRect.width());
|
||||
}
|
||||
height += itemHeight*desktopGridSize.height();
|
||||
itemWidth = (width - (desktopGridSize.width() - 1) * 2 - left - right) / desktopGridSize.width();
|
||||
itemHeight = itemWidth * (float)((float)fullRect.height() / (float)fullRect.width());
|
||||
}
|
||||
height += itemHeight * desktopGridSize.height();
|
||||
height += fontMetrics().height() + 4;
|
||||
|
||||
// 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;
|
||||
if( tempHeight != height )
|
||||
{
|
||||
if (tempHeight != height) {
|
||||
// have to adjust item width
|
||||
height = tempHeight;
|
||||
itemHeight = (height - (fontMetrics().height() + 4) - top - bottom - (desktopGridSize.height()-1)*2)/
|
||||
desktopGridSize.height();
|
||||
itemHeight = (height - (fontMetrics().height() + 4) - top - bottom - (desktopGridSize.height() - 1) * 2) /
|
||||
desktopGridSize.height();
|
||||
itemOffset = itemWidth;
|
||||
itemWidth = itemHeight*(float)((float)fullRect.width()/(float)fullRect.height());
|
||||
itemWidth = itemHeight * (float)((float)fullRect.width() / (float)fullRect.height());
|
||||
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
|
||||
if( m_textOnly )
|
||||
{
|
||||
if (m_textOnly) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
QRect rect = QRect( screenRect.x() + (screenRect.width()-width)/2,
|
||||
screenRect.y() + (screenRect.height()-height)/2,
|
||||
width,
|
||||
height );
|
||||
setGeometry( rect );
|
||||
m_scene->setSceneRect( 0, 0, width, height );
|
||||
m_frame.resizeFrame( QSize( width, height ) );
|
||||
QRect rect = QRect(screenRect.x() + (screenRect.width() - width) / 2,
|
||||
screenRect.y() + (screenRect.height() - height) / 2,
|
||||
width,
|
||||
height);
|
||||
setGeometry(rect);
|
||||
m_scene->setSceneRect(0, 0, width, height);
|
||||
m_frame.resizeFrame(QSize(width, height));
|
||||
|
||||
if (Plasma::Theme::defaultTheme()->windowTranslucencyEnabled())
|
||||
{
|
||||
if (Plasma::Theme::defaultTheme()->windowTranslucencyEnabled()) {
|
||||
// blur background
|
||||
Plasma::WindowEffects::enableBlurBehind(winId(), true, m_frame.mask());
|
||||
Plasma::WindowEffects::overrideShadow(winId(), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// do not trim to mask with compositing enabled, otherwise shadows are cropped
|
||||
setMask( m_frame.mask() );
|
||||
}
|
||||
setMask(m_frame.mask());
|
||||
}
|
||||
|
||||
// resize item frame
|
||||
m_item_frame.setElementPrefix( "normal" );
|
||||
m_item_frame.resizeFrame( QSize( itemWidth, itemHeight ) );
|
||||
m_item_frame.setElementPrefix( "hover" );
|
||||
m_item_frame.resizeFrame( QSize( itemWidth, itemHeight ) );
|
||||
m_item_frame.setElementPrefix("normal");
|
||||
m_item_frame.resizeFrame(QSize(itemWidth, itemHeight));
|
||||
m_item_frame.setElementPrefix("hover");
|
||||
m_item_frame.resizeFrame(QSize(itemWidth, itemHeight));
|
||||
|
||||
// reset the items
|
||||
foreach( QGraphicsItem* it, m_scene->items() )
|
||||
{
|
||||
foreach (QGraphicsItem * it, m_scene->items()) {
|
||||
DesktopChangeItem* item = qgraphicsitem_cast<DesktopChangeItem*>(it);
|
||||
if( item )
|
||||
{
|
||||
item->setWidth( itemWidth );
|
||||
item->setHeight( itemHeight );
|
||||
QPoint coords = m_wspace->desktopGridCoords( item->desktop() );
|
||||
item->setPos( left + itemOffset + coords.x()*(itemWidth+2),
|
||||
top + fontMetrics().height() + 4 + coords.y()*(itemHeight+4) );
|
||||
}
|
||||
if (item) {
|
||||
item->setWidth(itemWidth);
|
||||
item->setHeight(itemHeight);
|
||||
QPoint coords = m_wspace->desktopGridCoords(item->desktop());
|
||||
item->setPos(left + itemOffset + coords.x()*(itemWidth + 2),
|
||||
top + fontMetrics().height() + 4 + coords.y()*(itemHeight + 4));
|
||||
}
|
||||
DesktopChangeText* text = qgraphicsitem_cast<DesktopChangeText*>(it);
|
||||
if( text )
|
||||
{
|
||||
text->setPos( left, top );
|
||||
text->setWidth( width - left - right );
|
||||
if( m_textOnly )
|
||||
text->setHeight( fontMetrics().height() + 4 );
|
||||
if (text) {
|
||||
text->setPos(left, top);
|
||||
text->setWidth(width - left - right);
|
||||
if (m_textOnly)
|
||||
text->setHeight(fontMetrics().height() + 4);
|
||||
else
|
||||
text->setHeight( fontMetrics().height() );
|
||||
}
|
||||
text->setHeight(fontMetrics().height());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//*******************************
|
||||
// DesktopChangeText
|
||||
//*******************************
|
||||
DesktopChangeText::DesktopChangeText( Workspace* ws )
|
||||
DesktopChangeText::DesktopChangeText(Workspace* ws)
|
||||
: QGraphicsItem()
|
||||
, m_wspace( ws )
|
||||
, m_width( 0.0f )
|
||||
, m_height( 0.0f )
|
||||
{
|
||||
}
|
||||
, m_wspace(ws)
|
||||
, m_width(0.0f)
|
||||
, m_height(0.0f)
|
||||
{
|
||||
}
|
||||
|
||||
DesktopChangeText::~DesktopChangeText()
|
||||
{
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
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* )
|
||||
{
|
||||
painter->setPen( Plasma::Theme::defaultTheme()->color( Plasma::Theme::TextColor ) );
|
||||
painter->drawText( boundingRect(), Qt::AlignCenter | Qt:: AlignVCenter,
|
||||
m_wspace->desktopName( m_wspace->currentDesktop() ) );
|
||||
}
|
||||
void DesktopChangeText::paint(QPainter* painter, const QStyleOptionGraphicsItem* , QWidget*)
|
||||
{
|
||||
painter->setPen(Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor));
|
||||
painter->drawText(boundingRect(), Qt::AlignCenter | Qt:: AlignVCenter,
|
||||
m_wspace->desktopName(m_wspace->currentDesktop()));
|
||||
}
|
||||
|
||||
//*******************************
|
||||
// DesktopChangeItem
|
||||
//*******************************
|
||||
DesktopChangeItem::DesktopChangeItem( Workspace* ws, DesktopChangeOSD* parent, int desktop )
|
||||
DesktopChangeItem::DesktopChangeItem(Workspace* ws, DesktopChangeOSD* parent, int desktop)
|
||||
: QGraphicsItem()
|
||||
, m_wspace( ws )
|
||||
, m_parent( parent )
|
||||
, m_desktop( desktop )
|
||||
, m_width( 0.0f )
|
||||
, m_height( 0.0f )
|
||||
, m_arrow( NONE )
|
||||
, m_arrowShown( false )
|
||||
, m_fadeInArrow( false )
|
||||
, m_fadeInHighLight( false )
|
||||
, m_arrowValue( 0.0 )
|
||||
, m_highLightValue( 0.0 )
|
||||
{
|
||||
m_delayed_show_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_hide_arrow_timer, SIGNAL(timeout()), this, SLOT(hideArrow()));
|
||||
}
|
||||
, m_wspace(ws)
|
||||
, m_parent(parent)
|
||||
, m_desktop(desktop)
|
||||
, m_width(0.0f)
|
||||
, m_height(0.0f)
|
||||
, m_arrow(NONE)
|
||||
, m_arrowShown(false)
|
||||
, m_fadeInArrow(false)
|
||||
, m_fadeInHighLight(false)
|
||||
, m_arrowValue(0.0)
|
||||
, m_highLightValue(0.0)
|
||||
{
|
||||
m_delayed_show_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_hide_arrow_timer, SIGNAL(timeout()), this, SLOT(hideArrow()));
|
||||
}
|
||||
|
||||
DesktopChangeItem::~DesktopChangeItem()
|
||||
{
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
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
|
||||
m_delayed_show_arrow_timer.stop();
|
||||
m_delayed_hide_arrow_timer.stop();
|
||||
|
||||
QPropertyAnimation *arrowAnimation = m_arrowAnimation.data();
|
||||
if( arrowAnimation )
|
||||
{
|
||||
if (arrowAnimation) {
|
||||
arrowAnimation->stop();
|
||||
m_arrowAnimation.clear();
|
||||
}
|
||||
}
|
||||
|
||||
m_arrowShown = false;
|
||||
m_arrow = arrow;
|
||||
if( m_arrow != NONE )
|
||||
{
|
||||
m_delayed_show_arrow_timer.start( start_delay );
|
||||
m_delayed_hide_arrow_timer.start( hide_delay );
|
||||
}
|
||||
if (m_arrow != NONE) {
|
||||
m_delayed_show_arrow_timer.start(start_delay);
|
||||
m_delayed_hide_arrow_timer.start(hide_delay);
|
||||
}
|
||||
}
|
||||
|
||||
qreal DesktopChangeItem::arrowValue() const
|
||||
{
|
||||
{
|
||||
qCritical() << __func__ << m_arrowValue;
|
||||
return m_arrowValue;
|
||||
}
|
||||
}
|
||||
|
||||
qreal DesktopChangeItem::highLightValue() const
|
||||
{
|
||||
{
|
||||
return m_highLightValue;
|
||||
}
|
||||
}
|
||||
|
||||
void DesktopChangeItem::setArrowValue( qreal value )
|
||||
{
|
||||
void DesktopChangeItem::setArrowValue(qreal value)
|
||||
{
|
||||
m_arrowValue = value;
|
||||
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void DesktopChangeItem::setHighLightValue( qreal value )
|
||||
{
|
||||
void DesktopChangeItem::setHighLightValue(qreal value)
|
||||
{
|
||||
m_highLightValue = value;
|
||||
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void DesktopChangeItem::showArrow()
|
||||
{
|
||||
{
|
||||
m_arrowShown = true;
|
||||
|
||||
QPropertyAnimation *arrowAnimation = m_arrowAnimation.data();
|
||||
if( !arrowAnimation )
|
||||
{
|
||||
arrowAnimation = new QPropertyAnimation( this, "arrowValue" );
|
||||
arrowAnimation->setDuration( m_parent->getDelayTime()*0.15f );
|
||||
arrowAnimation->setStartValue( 0.0 );
|
||||
arrowAnimation->setEndValue( 1.0 );
|
||||
if (!arrowAnimation) {
|
||||
arrowAnimation = new QPropertyAnimation(this, "arrowValue");
|
||||
arrowAnimation->setDuration(m_parent->getDelayTime() * 0.15f);
|
||||
arrowAnimation->setStartValue(0.0);
|
||||
arrowAnimation->setEndValue(1.0);
|
||||
|
||||
m_arrowAnimation = arrowAnimation;
|
||||
}
|
||||
}
|
||||
|
||||
m_fadeInArrow = true;
|
||||
|
||||
arrowAnimation->setEasingCurve( QEasingCurve::InQuad );
|
||||
arrowAnimation->setDirection( QAbstractAnimation::Forward );
|
||||
arrowAnimation->setEasingCurve(QEasingCurve::InQuad);
|
||||
arrowAnimation->setDirection(QAbstractAnimation::Forward);
|
||||
arrowAnimation->start();
|
||||
}
|
||||
}
|
||||
|
||||
void DesktopChangeItem::hideArrow()
|
||||
{
|
||||
{
|
||||
m_fadeInArrow = false;
|
||||
|
||||
QPropertyAnimation *arrowAnimation = m_arrowAnimation.data();
|
||||
if( arrowAnimation )
|
||||
{
|
||||
arrowAnimation->setEasingCurve( QEasingCurve::OutQuad );
|
||||
arrowAnimation->setDirection( QAbstractAnimation::Backward );
|
||||
arrowAnimation->start( QAbstractAnimation::DeleteWhenStopped );
|
||||
if (arrowAnimation) {
|
||||
arrowAnimation->setEasingCurve(QEasingCurve::OutQuad);
|
||||
arrowAnimation->setDirection(QAbstractAnimation::Backward);
|
||||
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();
|
||||
if( !highLightAnimation )
|
||||
{
|
||||
highLightAnimation = new QPropertyAnimation( this, "highLightValue" );
|
||||
highLightAnimation->setDuration( time );
|
||||
highLightAnimation->setStartValue( 0.0 );
|
||||
highLightAnimation->setEndValue( 1.0 );
|
||||
if (!highLightAnimation) {
|
||||
highLightAnimation = new QPropertyAnimation(this, "highLightValue");
|
||||
highLightAnimation->setDuration(time);
|
||||
highLightAnimation->setStartValue(0.0);
|
||||
highLightAnimation->setEndValue(1.0);
|
||||
|
||||
m_highLightAnimation = highLightAnimation;
|
||||
}
|
||||
}
|
||||
|
||||
m_fadeInHighLight = true;
|
||||
|
||||
highLightAnimation->setEasingCurve( QEasingCurve::InQuad );
|
||||
highLightAnimation->setDirection( QAbstractAnimation::Forward );
|
||||
highLightAnimation->setEasingCurve(QEasingCurve::InQuad);
|
||||
highLightAnimation->setDirection(QAbstractAnimation::Forward);
|
||||
highLightAnimation->start();
|
||||
}
|
||||
}
|
||||
|
||||
void DesktopChangeItem::stopDesktopHighLightAnimation()
|
||||
{
|
||||
{
|
||||
m_fadeInHighLight = false;
|
||||
|
||||
QPropertyAnimation *highLightAnimation = m_highLightAnimation.data();
|
||||
if(highLightAnimation)
|
||||
{
|
||||
highLightAnimation->setEasingCurve( QEasingCurve::OutQuad );
|
||||
highLightAnimation->setDirection( QAbstractAnimation::Backward );
|
||||
highLightAnimation->start( QAbstractAnimation::DeleteWhenStopped );
|
||||
}
|
||||
if (highLightAnimation) {
|
||||
highLightAnimation->setEasingCurve(QEasingCurve::OutQuad);
|
||||
highLightAnimation->setDirection(QAbstractAnimation::Backward);
|
||||
highLightAnimation->start(QAbstractAnimation::DeleteWhenStopped);
|
||||
}
|
||||
}
|
||||
|
||||
void DesktopChangeItem::arrowAnimationFinished()
|
||||
{
|
||||
if( !m_fadeInArrow )
|
||||
{
|
||||
if (!m_fadeInArrow)
|
||||
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_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 )
|
||||
if (!m_arrowShown)
|
||||
return;
|
||||
// paint the arrow
|
||||
QPixmap icon;
|
||||
int iconWidth = 32;
|
||||
qreal maxsize = qMin( boundingRect().width(), boundingRect().height() );
|
||||
if( maxsize > 128.0 )
|
||||
qreal maxsize = qMin(boundingRect().width(), boundingRect().height());
|
||||
if (maxsize > 128.0)
|
||||
iconWidth = 128;
|
||||
else if( maxsize > 64.0 )
|
||||
else if (maxsize > 64.0)
|
||||
iconWidth = 64.0;
|
||||
else if( maxsize > 32.0 )
|
||||
else if (maxsize > 32.0)
|
||||
iconWidth = 32.0;
|
||||
else
|
||||
iconWidth = 16.0;
|
||||
QRect iconRect = QRect( boundingRect().x() + boundingRect().width()/2 - iconWidth/2,
|
||||
boundingRect().y() + boundingRect().height()/2 - iconWidth/2,
|
||||
iconWidth, iconWidth );
|
||||
switch( m_arrow )
|
||||
{
|
||||
case UP:
|
||||
icon = KIconLoader::global()->loadIcon( "go-up", KIconLoader::Desktop, iconWidth );
|
||||
break;
|
||||
case DOWN:
|
||||
icon = KIconLoader::global()->loadIcon( "go-down", KIconLoader::Desktop, iconWidth );
|
||||
break;
|
||||
case LEFT:
|
||||
icon = KIconLoader::global()->loadIcon( "go-previous", KIconLoader::Desktop, iconWidth );
|
||||
break;
|
||||
case RIGHT:
|
||||
icon = KIconLoader::global()->loadIcon( "go-next", KIconLoader::Desktop, iconWidth );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if( m_arrow != NONE )
|
||||
{
|
||||
if( !m_arrowAnimation.isNull() &&
|
||||
QRect iconRect = QRect(boundingRect().x() + boundingRect().width() / 2 - iconWidth / 2,
|
||||
boundingRect().y() + boundingRect().height() / 2 - iconWidth / 2,
|
||||
iconWidth, iconWidth);
|
||||
switch(m_arrow) {
|
||||
case UP:
|
||||
icon = KIconLoader::global()->loadIcon("go-up", KIconLoader::Desktop, iconWidth);
|
||||
break;
|
||||
case DOWN:
|
||||
icon = KIconLoader::global()->loadIcon("go-down", KIconLoader::Desktop, iconWidth);
|
||||
break;
|
||||
case LEFT:
|
||||
icon = KIconLoader::global()->loadIcon("go-previous", KIconLoader::Desktop, iconWidth);
|
||||
break;
|
||||
case RIGHT:
|
||||
icon = KIconLoader::global()->loadIcon("go-next", KIconLoader::Desktop, iconWidth);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (m_arrow != NONE) {
|
||||
if (!m_arrowAnimation.isNull() &&
|
||||
m_arrowAnimation.data()->state() == QAbstractAnimation::Running &&
|
||||
!qFuzzyCompare(m_arrowValue, qreal(1.0)) )
|
||||
{
|
||||
QPixmap temp( icon.size() );
|
||||
temp.fill( Qt::transparent );
|
||||
!qFuzzyCompare(m_arrowValue, qreal(1.0))) {
|
||||
QPixmap temp(icon.size());
|
||||
temp.fill(Qt::transparent);
|
||||
|
||||
QPainter p( &temp );
|
||||
p.setCompositionMode( QPainter::CompositionMode_Source );
|
||||
p.drawPixmap( 0, 0, icon );
|
||||
p.setCompositionMode( QPainter::CompositionMode_DestinationIn );
|
||||
p.fillRect( temp.rect(), QColor( 0, 0, 0, 255*m_arrowValue ) );
|
||||
QPainter p(&temp);
|
||||
p.setCompositionMode(QPainter::CompositionMode_Source);
|
||||
p.drawPixmap(0, 0, icon);
|
||||
p.setCompositionMode(QPainter::CompositionMode_DestinationIn);
|
||||
p.fillRect(temp.rect(), QColor(0, 0, 0, 255 * m_arrowValue));
|
||||
p.end();
|
||||
|
||||
icon = temp;
|
||||
}
|
||||
painter->drawPixmap( iconRect, icon );
|
||||
}
|
||||
painter->drawPixmap(iconRect, icon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include "desktopchangeosd.moc"
|
||||
|
|
|
@ -37,120 +37,137 @@ namespace KWin
|
|||
class Workspace;
|
||||
|
||||
class DesktopChangeText : public QGraphicsItem
|
||||
{
|
||||
public:
|
||||
DesktopChangeText( Workspace* ws );
|
||||
~DesktopChangeText();
|
||||
{
|
||||
public:
|
||||
DesktopChangeText(Workspace* ws);
|
||||
~DesktopChangeText();
|
||||
|
||||
enum { Type = UserType + 2 };
|
||||
enum { Type = UserType + 2 };
|
||||
|
||||
inline void setWidth( float width ) { m_width = width;};
|
||||
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;
|
||||
inline void setWidth(float width) {
|
||||
m_width = width;
|
||||
};
|
||||
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
|
||||
{
|
||||
public:
|
||||
DesktopChangeOSD( Workspace* ws );
|
||||
~DesktopChangeOSD();
|
||||
{
|
||||
public:
|
||||
DesktopChangeOSD(Workspace* ws);
|
||||
~DesktopChangeOSD();
|
||||
|
||||
void reconfigure();
|
||||
void desktopChanged( int old );
|
||||
void numberDesktopsChanged();
|
||||
void reconfigure();
|
||||
void desktopChanged(int old);
|
||||
void numberDesktopsChanged();
|
||||
|
||||
inline Plasma::FrameSvg* itemFrame() { return &m_item_frame;};
|
||||
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;
|
||||
inline Plasma::FrameSvg* itemFrame() {
|
||||
return &m_item_frame;
|
||||
};
|
||||
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
|
||||
{
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY( qreal arrowValue READ arrowValue WRITE setArrowValue )
|
||||
Q_PROPERTY( qreal highLightValue READ highLightValue WRITE setHighLightValue )
|
||||
Q_PROPERTY(qreal arrowValue READ arrowValue WRITE setArrowValue)
|
||||
Q_PROPERTY(qreal highLightValue READ highLightValue WRITE setHighLightValue)
|
||||
|
||||
Q_INTERFACES(QGraphicsItem)
|
||||
public:
|
||||
DesktopChangeItem( Workspace* ws, DesktopChangeOSD* parent, int desktop );
|
||||
~DesktopChangeItem();
|
||||
enum { Type = UserType + 1 };
|
||||
void startDesktopHighLightAnimation( int time );
|
||||
void stopDesktopHighLightAnimation();
|
||||
public:
|
||||
DesktopChangeItem(Workspace* ws, DesktopChangeOSD* parent, int desktop);
|
||||
~DesktopChangeItem();
|
||||
enum { Type = UserType + 1 };
|
||||
void startDesktopHighLightAnimation(int time);
|
||||
void stopDesktopHighLightAnimation();
|
||||
|
||||
inline void setWidth( float width ) { m_width = width;};
|
||||
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;
|
||||
inline void setWidth(float width) {
|
||||
m_width = width;
|
||||
};
|
||||
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;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -26,169 +26,162 @@ namespace KWin
|
|||
{
|
||||
|
||||
void Workspace::updateDesktopLayout()
|
||||
{
|
||||
{
|
||||
// TODO: Is there a sane way to avoid overriding the existing grid?
|
||||
int width = rootInfo->desktopLayoutColumnsRows().width();
|
||||
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;
|
||||
setNETDesktopLayout(
|
||||
rootInfo->desktopLayoutOrientation() == NET::OrientationHorizontal ? Qt::Horizontal : Qt::Vertical,
|
||||
width, height, 0 //rootInfo->desktopLayoutCorner() // Not really worth implementing right now.
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void Workspace::setNETDesktopLayout( Qt::Orientation orientation, int width, int height,
|
||||
int startingCorner )
|
||||
{
|
||||
Q_UNUSED( startingCorner ); // Not really worth implementing right now.
|
||||
void Workspace::setNETDesktopLayout(Qt::Orientation orientation, int width, int height,
|
||||
int startingCorner)
|
||||
{
|
||||
Q_UNUSED(startingCorner); // Not really worth implementing right now.
|
||||
|
||||
// Calculate valid grid size
|
||||
assert( width > 0 || height > 0 );
|
||||
if(( width <= 0 ) && ( height > 0 ))
|
||||
width = ( desktopCount_ + height - 1 ) / height;
|
||||
else if(( height <= 0 ) && ( width > 0 ))
|
||||
height = ( desktopCount_ + width - 1 ) / width;
|
||||
while( width * height < desktopCount_ )
|
||||
{
|
||||
if( orientation == Qt::Horizontal )
|
||||
assert(width > 0 || height > 0);
|
||||
if ((width <= 0) && (height > 0))
|
||||
width = (desktopCount_ + height - 1) / height;
|
||||
else if ((height <= 0) && (width > 0))
|
||||
height = (desktopCount_ + width - 1) / width;
|
||||
while (width * height < desktopCount_) {
|
||||
if (orientation == Qt::Horizontal)
|
||||
++width;
|
||||
else
|
||||
++height;
|
||||
}
|
||||
}
|
||||
|
||||
// Set private variables
|
||||
delete[] desktopGrid_;
|
||||
desktopGridSize_ = QSize( width, height );
|
||||
desktopGridSize_ = QSize(width, height);
|
||||
int size = width * height;
|
||||
desktopGrid_ = new int[size];
|
||||
|
||||
// Populate grid
|
||||
int desktop = 1;
|
||||
if( orientation == Qt::Horizontal )
|
||||
for( int y = 0; y < height; y++ )
|
||||
for( int x = 0; x < width; x++ )
|
||||
if (orientation == Qt::Horizontal)
|
||||
for (int y = 0; y < height; y++)
|
||||
for (int x = 0; x < width; x++)
|
||||
desktopGrid_[y * width + x] = (desktop <= desktopCount_ ? desktop++ : 0);
|
||||
else
|
||||
for( int x = 0; x < width; x++ )
|
||||
for( int y = 0; y < height; y++ )
|
||||
for (int x = 0; x < width; x++)
|
||||
for (int y = 0; y < height; y++)
|
||||
desktopGrid_[y * width + x] = (desktop <= desktopCount_ ? desktop++ : 0);
|
||||
}
|
||||
}
|
||||
|
||||
QPoint Workspace::desktopGridCoords( int id ) const
|
||||
{
|
||||
for( int y = 0; y < desktopGridSize_.height(); y++ )
|
||||
for( int x = 0; x < desktopGridSize_.width(); x++ )
|
||||
if( desktopGrid_[y * desktopGridSize_.width() + x] == id )
|
||||
return QPoint( x, y );
|
||||
return QPoint( -1, -1 );
|
||||
}
|
||||
QPoint Workspace::desktopGridCoords(int id) const
|
||||
{
|
||||
for (int y = 0; y < desktopGridSize_.height(); y++)
|
||||
for (int x = 0; x < desktopGridSize_.width(); x++)
|
||||
if (desktopGrid_[y * desktopGridSize_.width() + x] == id)
|
||||
return QPoint(x, y);
|
||||
return QPoint(-1, -1);
|
||||
}
|
||||
|
||||
QPoint Workspace::desktopCoords( int id ) const
|
||||
{
|
||||
QPoint coords = desktopGridCoords( id );
|
||||
if( coords.x() == -1 )
|
||||
return QPoint( -1, -1 );
|
||||
return QPoint( coords.x() * displayWidth(), coords.y() * displayHeight() );
|
||||
}
|
||||
QPoint Workspace::desktopCoords(int id) const
|
||||
{
|
||||
QPoint coords = desktopGridCoords(id);
|
||||
if (coords.x() == -1)
|
||||
return QPoint(-1, -1);
|
||||
return QPoint(coords.x() * displayWidth(), coords.y() * displayHeight());
|
||||
}
|
||||
|
||||
int Workspace::desktopAbove( int id, bool wrap ) const
|
||||
{
|
||||
if( id == 0 )
|
||||
int Workspace::desktopAbove(int id, bool wrap) const
|
||||
{
|
||||
if (id == 0)
|
||||
id = currentDesktop();
|
||||
QPoint coords = desktopGridCoords( id );
|
||||
assert( coords.x() >= 0 );
|
||||
for(;;)
|
||||
{
|
||||
QPoint coords = desktopGridCoords(id);
|
||||
assert(coords.x() >= 0);
|
||||
for (;;) {
|
||||
coords.ry()--;
|
||||
if( coords.y() < 0 )
|
||||
{
|
||||
if( wrap )
|
||||
coords.setY( desktopGridSize_.height() - 1 );
|
||||
if (coords.y() < 0) {
|
||||
if (wrap)
|
||||
coords.setY(desktopGridSize_.height() - 1);
|
||||
else
|
||||
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
|
||||
{
|
||||
if( id == 0 )
|
||||
int Workspace::desktopToRight(int id, bool wrap) const
|
||||
{
|
||||
if (id == 0)
|
||||
id = currentDesktop();
|
||||
QPoint coords = desktopGridCoords( id );
|
||||
assert( coords.x() >= 0 );
|
||||
for(;;)
|
||||
{
|
||||
QPoint coords = desktopGridCoords(id);
|
||||
assert(coords.x() >= 0);
|
||||
for (;;) {
|
||||
coords.rx()++;
|
||||
if( coords.x() >= desktopGridSize_.width() )
|
||||
{
|
||||
if( wrap )
|
||||
coords.setX( 0 );
|
||||
if (coords.x() >= desktopGridSize_.width()) {
|
||||
if (wrap)
|
||||
coords.setX(0);
|
||||
else
|
||||
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
|
||||
{
|
||||
if( id == 0 )
|
||||
int Workspace::desktopBelow(int id, bool wrap) const
|
||||
{
|
||||
if (id == 0)
|
||||
id = currentDesktop();
|
||||
QPoint coords = desktopGridCoords( id );
|
||||
assert( coords.x() >= 0 );
|
||||
for(;;)
|
||||
{
|
||||
QPoint coords = desktopGridCoords(id);
|
||||
assert(coords.x() >= 0);
|
||||
for (;;) {
|
||||
coords.ry()++;
|
||||
if( coords.y() >= desktopGridSize_.height() )
|
||||
{
|
||||
if( wrap )
|
||||
coords.setY( 0 );
|
||||
if (coords.y() >= desktopGridSize_.height()) {
|
||||
if (wrap)
|
||||
coords.setY(0);
|
||||
else
|
||||
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
|
||||
{
|
||||
if( id == 0 )
|
||||
int Workspace::desktopToLeft(int id, bool wrap) const
|
||||
{
|
||||
if (id == 0)
|
||||
id = currentDesktop();
|
||||
QPoint coords = desktopGridCoords( id );
|
||||
assert( coords.x() >= 0 );
|
||||
for(;;)
|
||||
{
|
||||
QPoint coords = desktopGridCoords(id);
|
||||
assert(coords.x() >= 0);
|
||||
for (;;) {
|
||||
coords.rx()--;
|
||||
if( coords.x() < 0 )
|
||||
{
|
||||
if( wrap )
|
||||
coords.setX( desktopGridSize_.width() - 1 );
|
||||
if (coords.x() < 0) {
|
||||
if (wrap)
|
||||
coords.setX(desktopGridSize_.width() - 1);
|
||||
else
|
||||
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 )
|
||||
{ // TODO
|
||||
Q_UNUSED( coords );
|
||||
int Workspace::addDesktop(QPoint coords)
|
||||
{
|
||||
// TODO
|
||||
Q_UNUSED(coords);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void Workspace::deleteDesktop( int id )
|
||||
{ // TODO
|
||||
Q_UNUSED( id );
|
||||
}
|
||||
void Workspace::deleteDesktop(int id)
|
||||
{
|
||||
// TODO
|
||||
Q_UNUSED(id);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
2157
effects.cpp
2157
effects.cpp
File diff suppressed because it is too large
Load Diff
647
effects.h
647
effects.h
|
@ -37,406 +37,399 @@ namespace KWin
|
|||
|
||||
class EffectsHandlerImpl : public EffectsHandler
|
||||
{
|
||||
public:
|
||||
EffectsHandlerImpl(CompositingType type);
|
||||
virtual ~EffectsHandlerImpl();
|
||||
virtual void prePaintScreen( ScreenPrePaintData& data, int time );
|
||||
virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data );
|
||||
virtual void postPaintScreen();
|
||||
virtual void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time );
|
||||
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data );
|
||||
virtual void postPaintWindow( EffectWindow* w );
|
||||
virtual void paintEffectFrame( EffectFrame* frame, QRegion region, double opacity, double frameOpacity );
|
||||
public:
|
||||
EffectsHandlerImpl(CompositingType type);
|
||||
virtual ~EffectsHandlerImpl();
|
||||
virtual void prePaintScreen(ScreenPrePaintData& data, int time);
|
||||
virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data);
|
||||
virtual void postPaintScreen();
|
||||
virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time);
|
||||
virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
|
||||
virtual void postPaintWindow(EffectWindow* w);
|
||||
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 EffectWindow* activeWindow() const;
|
||||
virtual void moveWindow( EffectWindow* w, const QPoint& pos, bool snap = false, double snapAdjust = 1.0 );
|
||||
virtual void windowToDesktop( EffectWindow* w, int desktop );
|
||||
virtual void windowToScreen( EffectWindow* w, int screen );
|
||||
virtual void setShowingDesktop( bool showing );
|
||||
virtual void activateWindow(EffectWindow* c);
|
||||
virtual EffectWindow* activeWindow() const;
|
||||
virtual void moveWindow(EffectWindow* w, const QPoint& pos, bool snap = false, double snapAdjust = 1.0);
|
||||
virtual void windowToDesktop(EffectWindow* w, int desktop);
|
||||
virtual void windowToScreen(EffectWindow* w, int screen);
|
||||
virtual void setShowingDesktop(bool showing);
|
||||
|
||||
virtual int currentDesktop() const;
|
||||
virtual int numberOfDesktops() const;
|
||||
virtual void setCurrentDesktop( int desktop );
|
||||
virtual void setNumberOfDesktops( int desktops );
|
||||
virtual QSize desktopGridSize() const;
|
||||
virtual int desktopGridWidth() const;
|
||||
virtual int desktopGridHeight() const;
|
||||
virtual int workspaceWidth() const;
|
||||
virtual int workspaceHeight() const;
|
||||
virtual int desktopAtCoords( QPoint coords ) const;
|
||||
virtual QPoint desktopGridCoords( int id ) const;
|
||||
virtual QPoint desktopCoords( int id ) const;
|
||||
virtual int desktopAbove( 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 desktopToLeft( int desktop = 0, bool wrap = true ) const;
|
||||
virtual bool isDesktopLayoutDynamic() const;
|
||||
virtual int addDesktop( QPoint coords );
|
||||
virtual void deleteDesktop( int id );
|
||||
virtual QString desktopName( int desktop ) const;
|
||||
virtual bool optionRollOverDesktops() const;
|
||||
virtual int currentDesktop() const;
|
||||
virtual int numberOfDesktops() const;
|
||||
virtual void setCurrentDesktop(int desktop);
|
||||
virtual void setNumberOfDesktops(int desktops);
|
||||
virtual QSize desktopGridSize() const;
|
||||
virtual int desktopGridWidth() const;
|
||||
virtual int desktopGridHeight() const;
|
||||
virtual int workspaceWidth() const;
|
||||
virtual int workspaceHeight() const;
|
||||
virtual int desktopAtCoords(QPoint coords) const;
|
||||
virtual QPoint desktopGridCoords(int id) const;
|
||||
virtual QPoint desktopCoords(int id) const;
|
||||
virtual int desktopAbove(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 desktopToLeft(int desktop = 0, bool wrap = true) const;
|
||||
virtual bool isDesktopLayoutDynamic() const;
|
||||
virtual int addDesktop(QPoint coords);
|
||||
virtual void deleteDesktop(int id);
|
||||
virtual QString desktopName(int desktop) const;
|
||||
virtual bool optionRollOverDesktops() const;
|
||||
|
||||
virtual int displayWidth() const;
|
||||
virtual int displayHeight() const;
|
||||
virtual QPoint cursorPos() const;
|
||||
virtual bool grabKeyboard( Effect* effect );
|
||||
virtual void ungrabKeyboard();
|
||||
virtual void* getProxy( QString name );
|
||||
virtual void startMousePolling();
|
||||
virtual void stopMousePolling();
|
||||
virtual EffectWindow* findWindow( WId id ) const;
|
||||
virtual EffectWindowList stackingOrder() const;
|
||||
virtual void setElevatedWindow( EffectWindow* w, bool set );
|
||||
virtual int displayWidth() const;
|
||||
virtual int displayHeight() const;
|
||||
virtual QPoint cursorPos() const;
|
||||
virtual bool grabKeyboard(Effect* effect);
|
||||
virtual void ungrabKeyboard();
|
||||
virtual void* getProxy(QString name);
|
||||
virtual void startMousePolling();
|
||||
virtual void stopMousePolling();
|
||||
virtual EffectWindow* findWindow(WId id) const;
|
||||
virtual EffectWindowList stackingOrder() const;
|
||||
virtual void setElevatedWindow(EffectWindow* w, bool set);
|
||||
|
||||
virtual void setTabBoxWindow(EffectWindow*);
|
||||
virtual void setTabBoxDesktop(int);
|
||||
virtual EffectWindowList currentTabBoxWindowList() const;
|
||||
virtual void refTabBox();
|
||||
virtual void unrefTabBox();
|
||||
virtual void closeTabBox();
|
||||
virtual QList< int > currentTabBoxDesktopList() const;
|
||||
virtual int currentTabBoxDesktop() const;
|
||||
virtual EffectWindow* currentTabBoxWindow() const;
|
||||
virtual void setTabBoxWindow(EffectWindow*);
|
||||
virtual void setTabBoxDesktop(int);
|
||||
virtual EffectWindowList currentTabBoxWindowList() const;
|
||||
virtual void refTabBox();
|
||||
virtual void unrefTabBox();
|
||||
virtual void closeTabBox();
|
||||
virtual QList< int > currentTabBoxDesktopList() const;
|
||||
virtual int currentTabBoxDesktop() const;
|
||||
virtual EffectWindow* currentTabBoxWindow() const;
|
||||
|
||||
virtual void setActiveFullScreenEffect( Effect* e );
|
||||
virtual Effect* activeFullScreenEffect() const;
|
||||
virtual void setActiveFullScreenEffect(Effect* e);
|
||||
virtual Effect* activeFullScreenEffect() const;
|
||||
|
||||
virtual void pushRenderTarget(GLRenderTarget* target);
|
||||
virtual GLRenderTarget* popRenderTarget();
|
||||
virtual bool isRenderTargetBound();
|
||||
virtual void pushRenderTarget(GLRenderTarget* target);
|
||||
virtual GLRenderTarget* popRenderTarget();
|
||||
virtual bool isRenderTargetBound();
|
||||
|
||||
virtual void addRepaintFull();
|
||||
virtual void addRepaint( const QRect& r );
|
||||
virtual void addRepaint( const QRegion& r );
|
||||
virtual void addRepaint( int x, int y, int w, int h );
|
||||
virtual int activeScreen() const;
|
||||
virtual int numScreens() const;
|
||||
virtual int screenNumber( const QPoint& pos ) const;
|
||||
virtual QRect clientArea( clientAreaOption, int screen, int desktop ) const;
|
||||
virtual QRect clientArea( clientAreaOption, const EffectWindow* c ) const;
|
||||
virtual QRect clientArea( clientAreaOption, const QPoint& p, int desktop ) const;
|
||||
virtual double animationTimeFactor() const;
|
||||
virtual WindowQuadType newWindowQuadType();
|
||||
virtual void addRepaintFull();
|
||||
virtual void addRepaint(const QRect& r);
|
||||
virtual void addRepaint(const QRegion& r);
|
||||
virtual void addRepaint(int x, int y, int w, int h);
|
||||
virtual int activeScreen() const;
|
||||
virtual int numScreens() const;
|
||||
virtual int screenNumber(const QPoint& pos) const;
|
||||
virtual QRect clientArea(clientAreaOption, int screen, int desktop) const;
|
||||
virtual QRect clientArea(clientAreaOption, const EffectWindow* c) const;
|
||||
virtual QRect clientArea(clientAreaOption, const QPoint& p, int desktop) const;
|
||||
virtual double animationTimeFactor() const;
|
||||
virtual WindowQuadType newWindowQuadType();
|
||||
|
||||
virtual Window createInputWindow( Effect* e, int x, int y, int w, int h, const QCursor& cursor );
|
||||
using EffectsHandler::createInputWindow;
|
||||
virtual void destroyInputWindow( Window w );
|
||||
virtual bool checkInputWindowEvent( XEvent* e );
|
||||
virtual void checkInputWindowStacking();
|
||||
virtual Window createInputWindow(Effect* e, int x, int y, int w, int h, const QCursor& cursor);
|
||||
using EffectsHandler::createInputWindow;
|
||||
virtual void destroyInputWindow(Window w);
|
||||
virtual bool checkInputWindowEvent(XEvent* e);
|
||||
virtual void checkInputWindowStacking();
|
||||
|
||||
virtual void checkElectricBorder(const QPoint &pos, Time time);
|
||||
virtual void reserveElectricBorder( ElectricBorder border );
|
||||
virtual void unreserveElectricBorder( ElectricBorder border );
|
||||
virtual void reserveElectricBorderSwitching( bool reserve );
|
||||
virtual void checkElectricBorder(const QPoint &pos, Time time);
|
||||
virtual void reserveElectricBorder(ElectricBorder border);
|
||||
virtual void unreserveElectricBorder(ElectricBorder border);
|
||||
virtual void reserveElectricBorderSwitching(bool reserve);
|
||||
|
||||
virtual unsigned long xrenderBufferPicture();
|
||||
virtual void reconfigure();
|
||||
virtual void registerPropertyType( long atom, bool reg );
|
||||
virtual QByteArray readRootProperty( long atom, long type, int format ) const;
|
||||
virtual void deleteRootProperty( long atom ) const;
|
||||
virtual unsigned long xrenderBufferPicture();
|
||||
virtual void reconfigure();
|
||||
virtual void registerPropertyType(long atom, bool reg);
|
||||
virtual QByteArray readRootProperty(long atom, long type, int format) 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)
|
||||
void startPaint();
|
||||
void windowUserMovedResized( EffectWindow* c, bool first, bool last );
|
||||
void windowMoveResizeGeometryUpdate( EffectWindow* c, const QRect& geometry );
|
||||
void windowOpacityChanged( EffectWindow* c, double old_opacity );
|
||||
void windowAdded( EffectWindow* c );
|
||||
void windowClosed( EffectWindow* c );
|
||||
void windowDeleted( EffectWindow* c );
|
||||
void windowActivated( EffectWindow* c );
|
||||
void windowMinimized( EffectWindow* c );
|
||||
void windowUnminimized( EffectWindow* c );
|
||||
void clientGroupItemSwitched( EffectWindow* from, EffectWindow* to );
|
||||
void clientGroupItemAdded( EffectWindow* from, EffectWindow* to );
|
||||
void clientGroupItemRemoved( EffectWindow* c, EffectWindow* group );
|
||||
void desktopChanged( int old );
|
||||
void windowDamaged( EffectWindow* w, const QRect& r );
|
||||
void windowGeometryShapeChanged( EffectWindow* w, const QRect& old );
|
||||
void tabBoxAdded( int mode );
|
||||
void tabBoxClosed();
|
||||
void tabBoxUpdated();
|
||||
void tabBoxKeyEvent( QKeyEvent* event );
|
||||
bool borderActivated( ElectricBorder border );
|
||||
void mouseChanged( const QPoint& pos, const QPoint& oldpos,
|
||||
Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons,
|
||||
Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers );
|
||||
void grabbedKeyboardEvent( QKeyEvent* e );
|
||||
bool hasKeyboardGrab() const;
|
||||
void propertyNotify( EffectWindow* c, long atom );
|
||||
void numberDesktopsChanged( int old );
|
||||
// internal (used by kwin core or compositing code)
|
||||
void startPaint();
|
||||
void windowUserMovedResized(EffectWindow* c, bool first, bool last);
|
||||
void windowMoveResizeGeometryUpdate(EffectWindow* c, const QRect& geometry);
|
||||
void windowOpacityChanged(EffectWindow* c, double old_opacity);
|
||||
void windowAdded(EffectWindow* c);
|
||||
void windowClosed(EffectWindow* c);
|
||||
void windowDeleted(EffectWindow* c);
|
||||
void windowActivated(EffectWindow* c);
|
||||
void windowMinimized(EffectWindow* c);
|
||||
void windowUnminimized(EffectWindow* c);
|
||||
void clientGroupItemSwitched(EffectWindow* from, EffectWindow* to);
|
||||
void clientGroupItemAdded(EffectWindow* from, EffectWindow* to);
|
||||
void clientGroupItemRemoved(EffectWindow* c, EffectWindow* group);
|
||||
void desktopChanged(int old);
|
||||
void windowDamaged(EffectWindow* w, const QRect& r);
|
||||
void windowGeometryShapeChanged(EffectWindow* w, const QRect& old);
|
||||
void tabBoxAdded(int mode);
|
||||
void tabBoxClosed();
|
||||
void tabBoxUpdated();
|
||||
void tabBoxKeyEvent(QKeyEvent* event);
|
||||
bool borderActivated(ElectricBorder border);
|
||||
void mouseChanged(const QPoint& pos, const QPoint& oldpos,
|
||||
Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons,
|
||||
Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers);
|
||||
void grabbedKeyboardEvent(QKeyEvent* e);
|
||||
bool hasKeyboardGrab() const;
|
||||
void propertyNotify(EffectWindow* c, long atom);
|
||||
void numberDesktopsChanged(int old);
|
||||
|
||||
bool loadEffect( const QString& name );
|
||||
void toggleEffect( const QString& name );
|
||||
void unloadEffect( const QString& name );
|
||||
void reconfigureEffect( const QString& name );
|
||||
bool isEffectLoaded( const QString& name );
|
||||
QStringList loadedEffects() const;
|
||||
QStringList listOfEffects() const;
|
||||
bool loadEffect(const QString& name);
|
||||
void toggleEffect(const QString& name);
|
||||
void unloadEffect(const QString& name);
|
||||
void reconfigureEffect(const QString& name);
|
||||
bool isEffectLoaded(const QString& name);
|
||||
QStringList loadedEffects() const;
|
||||
QStringList listOfEffects() const;
|
||||
|
||||
QList<EffectWindow*> elevatedWindows() const;
|
||||
QList<EffectWindow*> elevatedWindows() const;
|
||||
|
||||
protected:
|
||||
KLibrary* findEffectLibrary( KService* service );
|
||||
void effectsChanged();
|
||||
protected:
|
||||
KLibrary* findEffectLibrary(KService* service);
|
||||
void effectsChanged();
|
||||
|
||||
Effect* keyboard_grab_effect;
|
||||
QStack<GLRenderTarget*> render_targets;
|
||||
Effect* fullscreen_effect;
|
||||
QList<EffectWindow*> elevated_windows;
|
||||
QMultiMap< int, EffectPair > effect_order;
|
||||
QHash< long, int > registered_atoms;
|
||||
int next_window_quad_type;
|
||||
int mouse_poll_ref_count;
|
||||
int current_paint_effectframe;
|
||||
Effect* keyboard_grab_effect;
|
||||
QStack<GLRenderTarget*> render_targets;
|
||||
Effect* fullscreen_effect;
|
||||
QList<EffectWindow*> elevated_windows;
|
||||
QMultiMap< int, EffectPair > effect_order;
|
||||
QHash< long, int > registered_atoms;
|
||||
int next_window_quad_type;
|
||||
int mouse_poll_ref_count;
|
||||
int current_paint_effectframe;
|
||||
};
|
||||
|
||||
class EffectWindowImpl : public EffectWindow
|
||||
{
|
||||
public:
|
||||
EffectWindowImpl();
|
||||
virtual ~EffectWindowImpl();
|
||||
public:
|
||||
EffectWindowImpl();
|
||||
virtual ~EffectWindowImpl();
|
||||
|
||||
virtual void enablePainting( int reason );
|
||||
virtual void disablePainting( int reason );
|
||||
virtual bool isPaintingEnabled();
|
||||
virtual void addRepaint( const QRect& r );
|
||||
virtual void addRepaint( int x, int y, int w, int h );
|
||||
virtual void addRepaintFull();
|
||||
virtual void enablePainting(int reason);
|
||||
virtual void disablePainting(int reason);
|
||||
virtual bool isPaintingEnabled();
|
||||
virtual void addRepaint(const QRect& r);
|
||||
virtual void addRepaint(int x, int y, int w, int h);
|
||||
virtual void addRepaintFull();
|
||||
|
||||
virtual void refWindow();
|
||||
virtual void unrefWindow();
|
||||
virtual bool isDeleted() const;
|
||||
virtual void refWindow();
|
||||
virtual void unrefWindow();
|
||||
virtual bool isDeleted() const;
|
||||
|
||||
virtual bool isOnAllDesktops() const;
|
||||
virtual int desktop() const; // prefer isOnXXX()
|
||||
virtual bool isMinimized() const;
|
||||
virtual double opacity() const;
|
||||
virtual bool hasAlpha() const;
|
||||
virtual QString caption() const;
|
||||
virtual QPixmap icon() const;
|
||||
virtual QString windowClass() const;
|
||||
virtual QString windowRole() const;
|
||||
virtual const EffectWindowGroup* group() const;
|
||||
virtual bool isOnAllDesktops() const;
|
||||
virtual int desktop() const; // prefer isOnXXX()
|
||||
virtual bool isMinimized() const;
|
||||
virtual double opacity() const;
|
||||
virtual bool hasAlpha() const;
|
||||
virtual QString caption() const;
|
||||
virtual QPixmap icon() const;
|
||||
virtual QString windowClass() const;
|
||||
virtual QString windowRole() const;
|
||||
virtual const EffectWindowGroup* group() const;
|
||||
|
||||
virtual int x() const;
|
||||
virtual int y() const;
|
||||
virtual int width() const;
|
||||
virtual int height() const;
|
||||
virtual QRect geometry() const;
|
||||
virtual QRegion shape() const;
|
||||
virtual int screen() const;
|
||||
virtual bool hasOwnShape() const;
|
||||
virtual QPoint pos() const;
|
||||
virtual QSize size() const;
|
||||
virtual QRect rect() const;
|
||||
virtual bool isMovable() const;
|
||||
virtual bool isMovableAcrossScreens() const;
|
||||
virtual bool isUserMove() const;
|
||||
virtual bool isUserResize() const;
|
||||
virtual QRect iconGeometry() const;
|
||||
virtual QRect contentsRect() const;
|
||||
virtual QRect decorationInnerRect() const;
|
||||
virtual QByteArray readProperty( long atom, long type, int format ) const;
|
||||
virtual void deleteProperty( long atom ) const;
|
||||
virtual int x() const;
|
||||
virtual int y() const;
|
||||
virtual int width() const;
|
||||
virtual int height() const;
|
||||
virtual QRect geometry() const;
|
||||
virtual QRegion shape() const;
|
||||
virtual int screen() const;
|
||||
virtual bool hasOwnShape() const;
|
||||
virtual QPoint pos() const;
|
||||
virtual QSize size() const;
|
||||
virtual QRect rect() const;
|
||||
virtual bool isMovable() const;
|
||||
virtual bool isMovableAcrossScreens() const;
|
||||
virtual bool isUserMove() const;
|
||||
virtual bool isUserResize() const;
|
||||
virtual QRect iconGeometry() const;
|
||||
virtual QRect contentsRect() const;
|
||||
virtual QRect decorationInnerRect() const;
|
||||
virtual QByteArray readProperty(long atom, long type, int format) const;
|
||||
virtual void deleteProperty(long atom) const;
|
||||
|
||||
virtual bool isDesktop() const;
|
||||
virtual bool isDock() const;
|
||||
virtual bool isToolbar() const;
|
||||
virtual bool isTopMenu() const;
|
||||
virtual bool isMenu() const;
|
||||
virtual bool isNormalWindow() const; // normal as in 'NET::Normal or NET::Unknown non-transient'
|
||||
virtual bool isSpecialWindow() const;
|
||||
virtual bool isDialog() const;
|
||||
virtual bool isSplash() const;
|
||||
virtual bool isUtility() const;
|
||||
virtual bool isDropdownMenu() const;
|
||||
virtual bool isPopupMenu() const; // a context popup, not dropdown, not torn-off
|
||||
virtual bool isTooltip() const;
|
||||
virtual bool isNotification() const;
|
||||
virtual bool isComboBox() const;
|
||||
virtual bool isDNDIcon() const;
|
||||
virtual bool isManaged() const; // managed or override-redirect
|
||||
virtual bool acceptsFocus() const;
|
||||
virtual bool keepAbove() const;
|
||||
virtual bool isDesktop() const;
|
||||
virtual bool isDock() const;
|
||||
virtual bool isToolbar() const;
|
||||
virtual bool isTopMenu() const;
|
||||
virtual bool isMenu() const;
|
||||
virtual bool isNormalWindow() const; // normal as in 'NET::Normal or NET::Unknown non-transient'
|
||||
virtual bool isSpecialWindow() const;
|
||||
virtual bool isDialog() const;
|
||||
virtual bool isSplash() const;
|
||||
virtual bool isUtility() const;
|
||||
virtual bool isDropdownMenu() const;
|
||||
virtual bool isPopupMenu() const; // a context popup, not dropdown, not torn-off
|
||||
virtual bool isTooltip() const;
|
||||
virtual bool isNotification() const;
|
||||
virtual bool isComboBox() const;
|
||||
virtual bool isDNDIcon() const;
|
||||
virtual bool isManaged() const; // managed or override-redirect
|
||||
virtual bool acceptsFocus() const;
|
||||
virtual bool keepAbove() const;
|
||||
|
||||
virtual bool isModal() const;
|
||||
virtual EffectWindow* findModal();
|
||||
virtual EffectWindowList mainWindows() const;
|
||||
virtual bool isModal() const;
|
||||
virtual EffectWindow* findModal();
|
||||
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 unminimize() const;
|
||||
virtual void closeWindow() const;
|
||||
virtual void minimize() const;
|
||||
virtual void unminimize() const;
|
||||
virtual void closeWindow() const;
|
||||
|
||||
virtual bool visibleInClientGroup() const;
|
||||
virtual bool visibleInClientGroup() const;
|
||||
|
||||
const Toplevel* window() const;
|
||||
Toplevel* window();
|
||||
const Toplevel* window() const;
|
||||
Toplevel* window();
|
||||
|
||||
void setWindow( Toplevel* w ); // internal
|
||||
void setSceneWindow( Scene::Window* w ); // internal
|
||||
const Scene::Window* sceneWindow() const; // internal
|
||||
Scene::Window* sceneWindow(); // internal
|
||||
void setWindow(Toplevel* w); // internal
|
||||
void setSceneWindow(Scene::Window* w); // internal
|
||||
const Scene::Window* sceneWindow() const; // internal
|
||||
Scene::Window* sceneWindow(); // internal
|
||||
|
||||
void setData( int role, const QVariant &data );
|
||||
QVariant data( int role ) const;
|
||||
private:
|
||||
Toplevel* toplevel;
|
||||
Scene::Window* sw; // This one is used only during paint pass.
|
||||
QHash<int, QVariant> dataMap;
|
||||
void setData(int role, const QVariant &data);
|
||||
QVariant data(int role) const;
|
||||
private:
|
||||
Toplevel* toplevel;
|
||||
Scene::Window* sw; // This one is used only during paint pass.
|
||||
QHash<int, QVariant> dataMap;
|
||||
};
|
||||
|
||||
class EffectWindowGroupImpl
|
||||
: public EffectWindowGroup
|
||||
{
|
||||
public:
|
||||
EffectWindowGroupImpl( Group* g );
|
||||
virtual EffectWindowList members() const;
|
||||
private:
|
||||
Group* group;
|
||||
};
|
||||
{
|
||||
public:
|
||||
EffectWindowGroupImpl(Group* g);
|
||||
virtual EffectWindowList members() const;
|
||||
private:
|
||||
Group* group;
|
||||
};
|
||||
|
||||
class EffectFrameImpl
|
||||
: public QObject, public EffectFrame
|
||||
{
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit EffectFrameImpl( EffectFrameStyle style, bool staticSize = true, QPoint position = QPoint( -1, -1 ),
|
||||
Qt::Alignment alignment = Qt::AlignCenter );
|
||||
virtual ~EffectFrameImpl();
|
||||
public:
|
||||
explicit EffectFrameImpl(EffectFrameStyle style, bool staticSize = true, QPoint position = QPoint(-1, -1),
|
||||
Qt::Alignment alignment = Qt::AlignCenter);
|
||||
virtual ~EffectFrameImpl();
|
||||
|
||||
virtual void free();
|
||||
virtual void render( QRegion region = infiniteRegion(), double opacity = 1.0, double frameOpacity = 1.0 );
|
||||
virtual Qt::Alignment alignment() const;
|
||||
virtual void setAlignment( Qt::Alignment alignment );
|
||||
virtual const QFont& font() const;
|
||||
virtual void setFont( const QFont& font );
|
||||
virtual const QRect& geometry() const;
|
||||
virtual void setGeometry( const QRect& geometry, bool force = false );
|
||||
virtual const QPixmap& icon() const;
|
||||
virtual void setIcon( const QPixmap& icon );
|
||||
virtual const QSize& iconSize() const;
|
||||
virtual void setIconSize( const QSize& size );
|
||||
virtual void setPosition( const QPoint& point );
|
||||
virtual const QString& text() const;
|
||||
virtual void setText( const QString& text );
|
||||
EffectFrameStyle style() const
|
||||
{
|
||||
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;
|
||||
virtual void free();
|
||||
virtual void render(QRegion region = infiniteRegion(), double opacity = 1.0, double frameOpacity = 1.0);
|
||||
virtual Qt::Alignment alignment() const;
|
||||
virtual void setAlignment(Qt::Alignment alignment);
|
||||
virtual const QFont& font() const;
|
||||
virtual void setFont(const QFont& font);
|
||||
virtual const QRect& geometry() const;
|
||||
virtual void setGeometry(const QRect& geometry, bool force = false);
|
||||
virtual const QPixmap& icon() const;
|
||||
virtual void setIcon(const QPixmap& icon);
|
||||
virtual const QSize& iconSize() const;
|
||||
virtual void setIconSize(const QSize& size);
|
||||
virtual void setPosition(const QPoint& point);
|
||||
virtual const QString& text() const;
|
||||
virtual void setText(const QString& text);
|
||||
EffectFrameStyle style() const {
|
||||
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;
|
||||
};
|
||||
|
||||
inline
|
||||
QList<EffectWindow*> EffectsHandlerImpl::elevatedWindows() const
|
||||
{
|
||||
{
|
||||
return elevated_windows;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
EffectWindowGroupImpl::EffectWindowGroupImpl( Group* g )
|
||||
: group( g )
|
||||
{
|
||||
}
|
||||
EffectWindowGroupImpl::EffectWindowGroupImpl(Group* g)
|
||||
: group(g)
|
||||
{
|
||||
}
|
||||
|
||||
EffectWindow* effectWindow( Toplevel* w );
|
||||
EffectWindow* effectWindow( Scene::Window* w );
|
||||
EffectWindow* effectWindow(Toplevel* w);
|
||||
EffectWindow* effectWindow(Scene::Window* w);
|
||||
|
||||
inline
|
||||
const Scene::Window* EffectWindowImpl::sceneWindow() const
|
||||
{
|
||||
{
|
||||
return sw;
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
Scene::Window* EffectWindowImpl::sceneWindow()
|
||||
{
|
||||
{
|
||||
return sw;
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
const Toplevel* EffectWindowImpl::window() const
|
||||
{
|
||||
{
|
||||
return toplevel;
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
Toplevel* EffectWindowImpl::window()
|
||||
{
|
||||
{
|
||||
return toplevel;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -31,36 +31,35 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
KWIN_EFFECT( demo_liquid, LiquidEffect )
|
||||
KWIN_EFFECT_SUPPORTED( demo_liquid, LiquidEffect::supported() )
|
||||
KWIN_EFFECT(demo_liquid, LiquidEffect)
|
||||
KWIN_EFFECT_SUPPORTED(demo_liquid, LiquidEffect::supported())
|
||||
|
||||
|
||||
LiquidEffect::LiquidEffect() : Effect()
|
||||
{
|
||||
{
|
||||
mTexture = 0;
|
||||
mRenderTarget = 0;
|
||||
mShader = 0;
|
||||
|
||||
mTime = 0.0f;
|
||||
mValid = loadData();
|
||||
}
|
||||
}
|
||||
LiquidEffect::~LiquidEffect()
|
||||
{
|
||||
{
|
||||
delete mTexture;
|
||||
delete mRenderTarget;
|
||||
delete mShader;
|
||||
}
|
||||
}
|
||||
|
||||
bool LiquidEffect::loadData()
|
||||
{
|
||||
{
|
||||
// If NPOT textures are not supported, use nearest power-of-two sized
|
||||
// texture. It wastes memory, but it's possible to support systems without
|
||||
// NPOT textures that way
|
||||
int texw = displayWidth();
|
||||
int texh = displayHeight();
|
||||
if( !GLTexture::NPOTTextureSupported() )
|
||||
{
|
||||
kWarning( 1212 ) << "NPOT textures not supported, wasting some memory" ;
|
||||
if (!GLTexture::NPOTTextureSupported()) {
|
||||
kWarning(1212) << "NPOT textures not supported, wasting some memory" ;
|
||||
texw = nearestPowerOfTwo(texw);
|
||||
texh = nearestPowerOfTwo(texh);
|
||||
}
|
||||
|
@ -70,19 +69,17 @@ bool LiquidEffect::loadData()
|
|||
mTexture->setWrapMode(GL_CLAMP);
|
||||
|
||||
mRenderTarget = new GLRenderTarget(mTexture);
|
||||
if( !mRenderTarget->valid() )
|
||||
if (!mRenderTarget->valid())
|
||||
return false;
|
||||
|
||||
QString fragmentshader = KGlobal::dirs()->findResource("data", "kwin/liquid.frag");
|
||||
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;
|
||||
return false;
|
||||
}
|
||||
mShader = new GLShader(vertexshader, fragmentshader);
|
||||
if(!mShader->isValid())
|
||||
{
|
||||
if (!mShader->isValid()) {
|
||||
kError(1212) << "The shader failed to load!" << endl;
|
||||
return false;
|
||||
}
|
||||
|
@ -93,38 +90,36 @@ bool LiquidEffect::loadData()
|
|||
mShader->unbind();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool LiquidEffect::supported()
|
||||
{
|
||||
{
|
||||
return GLRenderTarget::supported() &&
|
||||
GLShader::fragmentShaderSupported() &&
|
||||
(effects->compositingType() == OpenGLCompositing);
|
||||
}
|
||||
GLShader::fragmentShaderSupported() &&
|
||||
(effects->compositingType() == OpenGLCompositing);
|
||||
}
|
||||
|
||||
|
||||
void LiquidEffect::prePaintScreen( ScreenPrePaintData& data, int time )
|
||||
{
|
||||
void LiquidEffect::prePaintScreen(ScreenPrePaintData& data, int time)
|
||||
{
|
||||
mTime += time / 1000.0f;
|
||||
if(mValid)
|
||||
{
|
||||
if (mValid) {
|
||||
data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
|
||||
// Start rendering to texture
|
||||
effects->pushRenderTarget(mRenderTarget);
|
||||
}
|
||||
|
||||
effects->prePaintScreen(data, time);
|
||||
}
|
||||
|
||||
effects->prePaintScreen(data, time);
|
||||
}
|
||||
|
||||
void LiquidEffect::postPaintScreen()
|
||||
{
|
||||
{
|
||||
// Call the next effect.
|
||||
effects->postPaintScreen();
|
||||
|
||||
if(mValid)
|
||||
{
|
||||
if (mValid) {
|
||||
// Disable render texture
|
||||
assert( effects->popRenderTarget() == mRenderTarget );
|
||||
assert(effects->popRenderTarget() == mRenderTarget);
|
||||
mTexture->bind();
|
||||
|
||||
// Use the shader
|
||||
|
@ -133,10 +128,10 @@ void LiquidEffect::postPaintScreen()
|
|||
|
||||
// Render fullscreen quad with screen contents
|
||||
glBegin(GL_QUADS);
|
||||
glVertex2f(0.0, displayHeight());
|
||||
glVertex2f(displayWidth(), displayHeight());
|
||||
glVertex2f(displayWidth(), 0.0);
|
||||
glVertex2f(0.0, 0.0);
|
||||
glVertex2f(0.0, displayHeight());
|
||||
glVertex2f(displayWidth(), displayHeight());
|
||||
glVertex2f(displayWidth(), 0.0);
|
||||
glVertex2f(0.0, 0.0);
|
||||
glEnd();
|
||||
|
||||
mShader->unbind();
|
||||
|
@ -144,10 +139,10 @@ void LiquidEffect::postPaintScreen()
|
|||
|
||||
// Make sure the animation continues
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -35,27 +35,27 @@ class GLShader;
|
|||
* Turns your desktop into a wavy (liquid) surface
|
||||
**/
|
||||
class LiquidEffect : public Effect
|
||||
{
|
||||
public:
|
||||
LiquidEffect();
|
||||
~LiquidEffect();
|
||||
{
|
||||
public:
|
||||
LiquidEffect();
|
||||
~LiquidEffect();
|
||||
|
||||
virtual void prePaintScreen( ScreenPrePaintData& data, int time );
|
||||
virtual void postPaintScreen();
|
||||
virtual void prePaintScreen(ScreenPrePaintData& data, int time);
|
||||
virtual void postPaintScreen();
|
||||
|
||||
static bool supported();
|
||||
static bool supported();
|
||||
|
||||
protected:
|
||||
bool loadData();
|
||||
protected:
|
||||
bool loadData();
|
||||
|
||||
private:
|
||||
GLTexture* mTexture;
|
||||
GLRenderTarget* mRenderTarget;
|
||||
GLShader* mShader;
|
||||
bool mValid;
|
||||
private:
|
||||
GLTexture* mTexture;
|
||||
GLRenderTarget* mRenderTarget;
|
||||
GLShader* mShader;
|
||||
bool mValid;
|
||||
|
||||
double mTime;
|
||||
};
|
||||
double mTime;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -13,77 +13,73 @@ License. See the file "COPYING" for the exact licensing terms.
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
KWIN_EFFECT( demo_shakymove, ShakyMoveEffect )
|
||||
KWIN_EFFECT(demo_shakymove, 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_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 )
|
||||
{
|
||||
if( !windows.isEmpty())
|
||||
void ShakyMoveEffect::prePaintScreen(ScreenPrePaintData& data, int time)
|
||||
{
|
||||
if (!windows.isEmpty())
|
||||
data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
|
||||
effects->prePaintScreen( data, time );
|
||||
}
|
||||
effects->prePaintScreen(data, time);
|
||||
}
|
||||
|
||||
void ShakyMoveEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time )
|
||||
{
|
||||
if( windows.contains( w ))
|
||||
void ShakyMoveEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
|
||||
{
|
||||
if (windows.contains(w))
|
||||
data.setTransformed();
|
||||
effects->prePaintWindow( w, data, time );
|
||||
}
|
||||
effects->prePaintWindow(w, data, time);
|
||||
}
|
||||
|
||||
void ShakyMoveEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data )
|
||||
{
|
||||
if( windows.contains( w ))
|
||||
void ShakyMoveEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
|
||||
{
|
||||
if (windows.contains(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 )
|
||||
{
|
||||
if( first )
|
||||
{
|
||||
if( windows.isEmpty())
|
||||
timer.start( 50 );
|
||||
void ShakyMoveEffect::windowUserMovedResized(EffectWindow* c, bool first, bool last)
|
||||
{
|
||||
if (first) {
|
||||
if (windows.isEmpty())
|
||||
timer.start(50);
|
||||
windows[ c ] = 0;
|
||||
}
|
||||
else if( last )
|
||||
{
|
||||
windows.remove( c );
|
||||
} else if (last) {
|
||||
windows.remove(c);
|
||||
// just repaint whole screen, transformation is involved
|
||||
effects->addRepaintFull();
|
||||
if( windows.isEmpty())
|
||||
if (windows.isEmpty())
|
||||
timer.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ShakyMoveEffect::windowClosed( EffectWindow* c )
|
||||
{
|
||||
windows.remove( c );
|
||||
if( windows.isEmpty())
|
||||
void ShakyMoveEffect::windowClosed(EffectWindow* c)
|
||||
{
|
||||
windows.remove(c);
|
||||
if (windows.isEmpty())
|
||||
timer.stop();
|
||||
}
|
||||
}
|
||||
|
||||
// TODO use time provided with prePaintWindow() instead
|
||||
void ShakyMoveEffect::tick()
|
||||
{
|
||||
for( QHash< const EffectWindow*, int >::Iterator it = windows.begin();
|
||||
it != windows.end();
|
||||
++it )
|
||||
{
|
||||
if( *it == SHAKY_MAX - 1 )
|
||||
{
|
||||
for (QHash< const EffectWindow*, int >::Iterator it = windows.begin();
|
||||
it != windows.end();
|
||||
++it) {
|
||||
if (*it == SHAKY_MAX - 1)
|
||||
*it = 0;
|
||||
else
|
||||
++(*it);
|
||||
// just repaint whole screen, transformation is involved
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -20,21 +20,21 @@ namespace KWin
|
|||
|
||||
class ShakyMoveEffect
|
||||
: public QObject, public Effect
|
||||
{
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ShakyMoveEffect();
|
||||
virtual void prePaintScreen( ScreenPrePaintData& 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 windowUserMovedResized( EffectWindow* c, bool first, bool last );
|
||||
virtual void windowClosed( EffectWindow* c );
|
||||
private slots:
|
||||
void tick();
|
||||
private:
|
||||
QHash< const EffectWindow*, int > windows;
|
||||
QTimer timer;
|
||||
};
|
||||
public:
|
||||
ShakyMoveEffect();
|
||||
virtual void prePaintScreen(ScreenPrePaintData& 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 windowUserMovedResized(EffectWindow* c, bool first, bool last);
|
||||
virtual void windowClosed(EffectWindow* c);
|
||||
private slots:
|
||||
void tick();
|
||||
private:
|
||||
QHash< const EffectWindow*, int > windows;
|
||||
QTimer timer;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -13,46 +13,46 @@ License. See the file "COPYING" for the exact licensing terms.
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
KWIN_EFFECT( demo_shiftworkspaceup, ShiftWorkspaceUpEffect )
|
||||
KWIN_EFFECT(demo_shiftworkspaceup, ShiftWorkspaceUpEffect)
|
||||
|
||||
ShiftWorkspaceUpEffect::ShiftWorkspaceUpEffect()
|
||||
: up( false )
|
||||
, diff( 0 )
|
||||
{
|
||||
connect( &timer, SIGNAL( timeout()), SLOT( tick()));
|
||||
timer.start( 2000 );
|
||||
}
|
||||
: up(false)
|
||||
, diff(0)
|
||||
{
|
||||
connect(&timer, SIGNAL(timeout()), SLOT(tick()));
|
||||
timer.start(2000);
|
||||
}
|
||||
|
||||
void ShiftWorkspaceUpEffect::prePaintScreen( ScreenPrePaintData& data, int time )
|
||||
{
|
||||
if( up && diff < 1000 )
|
||||
diff = qBound( 0, diff + time, 1000 ); // KDE3: note this differs from KCLAMP
|
||||
if( !up && diff > 0 )
|
||||
diff = qBound( 0, diff - time, 1000 );
|
||||
if( diff != 0 )
|
||||
void ShiftWorkspaceUpEffect::prePaintScreen(ScreenPrePaintData& data, int time)
|
||||
{
|
||||
if (up && diff < 1000)
|
||||
diff = qBound(0, diff + time, 1000); // KDE3: note this differs from KCLAMP
|
||||
if (!up && diff > 0)
|
||||
diff = qBound(0, diff - time, 1000);
|
||||
if (diff != 0)
|
||||
data.mask |= PAINT_SCREEN_TRANSFORMED;
|
||||
effects->prePaintScreen( data, time );
|
||||
}
|
||||
effects->prePaintScreen(data, time);
|
||||
}
|
||||
|
||||
void ShiftWorkspaceUpEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
|
||||
{
|
||||
if( diff != 0 )
|
||||
void ShiftWorkspaceUpEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
|
||||
{
|
||||
if (diff != 0)
|
||||
data.yTranslate -= diff / 100;
|
||||
effects->paintScreen( mask, region, data );
|
||||
}
|
||||
effects->paintScreen(mask, region, data);
|
||||
}
|
||||
|
||||
void ShiftWorkspaceUpEffect::postPaintScreen()
|
||||
{
|
||||
if( up ? diff < 1000 : diff > 0 )
|
||||
{
|
||||
if (up ? diff < 1000 : diff > 0)
|
||||
effects->addRepaintFull(); // trigger next animation repaint
|
||||
effects->postPaintScreen();
|
||||
}
|
||||
}
|
||||
|
||||
void ShiftWorkspaceUpEffect::tick()
|
||||
{
|
||||
{
|
||||
up = !up;
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -20,20 +20,20 @@ namespace KWin
|
|||
|
||||
class ShiftWorkspaceUpEffect
|
||||
: public QObject, public Effect
|
||||
{
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ShiftWorkspaceUpEffect();
|
||||
virtual void prePaintScreen( ScreenPrePaintData& data, int time );
|
||||
virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data );
|
||||
virtual void postPaintScreen();
|
||||
private slots:
|
||||
void tick();
|
||||
private:
|
||||
QTimer timer;
|
||||
bool up;
|
||||
int diff;
|
||||
};
|
||||
public:
|
||||
ShiftWorkspaceUpEffect();
|
||||
virtual void prePaintScreen(ScreenPrePaintData& data, int time);
|
||||
virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data);
|
||||
virtual void postPaintScreen();
|
||||
private slots:
|
||||
void tick();
|
||||
private:
|
||||
QTimer timer;
|
||||
bool up;
|
||||
int diff;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -16,49 +16,47 @@ License. See the file "COPYING" for the exact licensing terms.
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
KWIN_EFFECT( demo_showpicture, ShowPictureEffect )
|
||||
KWIN_EFFECT(demo_showpicture, ShowPictureEffect)
|
||||
|
||||
ShowPictureEffect::ShowPictureEffect()
|
||||
: init( true )
|
||||
, picture( NULL )
|
||||
{
|
||||
}
|
||||
: init(true)
|
||||
, picture(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
ShowPictureEffect::~ShowPictureEffect()
|
||||
{
|
||||
{
|
||||
delete picture;
|
||||
}
|
||||
}
|
||||
|
||||
void ShowPictureEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
|
||||
{
|
||||
effects->paintScreen( mask, region, data );
|
||||
if( init )
|
||||
{
|
||||
void ShowPictureEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
|
||||
{
|
||||
effects->paintScreen(mask, region, data);
|
||||
if (init) {
|
||||
loadPicture();
|
||||
init = false;
|
||||
}
|
||||
if( picture && region.intersects( pictureRect ))
|
||||
{
|
||||
glPushAttrib( GL_CURRENT_BIT | GL_ENABLE_BIT );
|
||||
}
|
||||
if (picture && region.intersects(pictureRect)) {
|
||||
glPushAttrib(GL_CURRENT_BIT | GL_ENABLE_BIT);
|
||||
picture->bind();
|
||||
glEnable( GL_BLEND );
|
||||
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
||||
picture->render( region, pictureRect );
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
picture->render(region, pictureRect);
|
||||
picture->unbind();
|
||||
glPopAttrib();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ShowPictureEffect::loadPicture()
|
||||
{
|
||||
QString file = KGlobal::dirs()->findResource( "appdata", "showpicture.png" );
|
||||
if( file.isEmpty())
|
||||
{
|
||||
QString file = KGlobal::dirs()->findResource("appdata", "showpicture.png");
|
||||
if (file.isEmpty())
|
||||
return;
|
||||
QImage im( file );
|
||||
QRect area = effects->clientArea( PlacementArea, effects->activeScreen(), effects->currentDesktop());
|
||||
picture = new GLTexture( im );
|
||||
pictureRect = QRect( area.x() + ( area.width() - im.width()) / 2,
|
||||
area.y() + ( area.height() - im.height()) / 2, im.width(), im.height());
|
||||
}
|
||||
QImage im(file);
|
||||
QRect area = effects->clientArea(PlacementArea, effects->activeScreen(), effects->currentDesktop());
|
||||
picture = new GLTexture(im);
|
||||
pictureRect = QRect(area.x() + (area.width() - im.width()) / 2,
|
||||
area.y() + (area.height() - im.height()) / 2, im.width(), im.height());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -19,17 +19,17 @@ namespace KWin
|
|||
|
||||
class ShowPictureEffect
|
||||
: public Effect
|
||||
{
|
||||
public:
|
||||
ShowPictureEffect();
|
||||
virtual ~ShowPictureEffect();
|
||||
virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data );
|
||||
private:
|
||||
void loadPicture();
|
||||
bool init;
|
||||
GLTexture* picture;
|
||||
QRect pictureRect;
|
||||
};
|
||||
{
|
||||
public:
|
||||
ShowPictureEffect();
|
||||
virtual ~ShowPictureEffect();
|
||||
virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data);
|
||||
private:
|
||||
void loadPicture();
|
||||
bool init;
|
||||
GLTexture* picture;
|
||||
QRect pictureRect;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -26,16 +26,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
KWIN_EFFECT( demo_wavywindows, WavyWindowsEffect )
|
||||
KWIN_EFFECT(demo_wavywindows, WavyWindowsEffect)
|
||||
|
||||
WavyWindowsEffect::WavyWindowsEffect()
|
||||
{
|
||||
{
|
||||
mTimeElapsed = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void WavyWindowsEffect::prePaintScreen( ScreenPrePaintData& data, int time )
|
||||
{
|
||||
void WavyWindowsEffect::prePaintScreen(ScreenPrePaintData& data, int time)
|
||||
{
|
||||
// Adjust elapsed time
|
||||
mTimeElapsed += (time / 1000.0f);
|
||||
// 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;
|
||||
|
||||
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
|
||||
data.setTransformed();
|
||||
// Check if OpenGL compositing is used
|
||||
// Request the window to be divided into cells which are at most 30x30
|
||||
// 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
|
||||
// special window
|
||||
// TODO if( w->isVisible() && !w->isSpecialWindow() )
|
||||
if( !w->isSpecialWindow() )
|
||||
{
|
||||
// TODO if ( w->isVisible() && !w->isSpecialWindow() )
|
||||
if (!w->isSpecialWindow()) {
|
||||
// We have OpenGL compositing and the window has been subdivided
|
||||
// because of our request (in pre-paint pass)
|
||||
// Transform all the vertices to create wavy effect
|
||||
for( int i = 0;
|
||||
i < data.quads.count();
|
||||
++i )
|
||||
for( int j = 0;
|
||||
j < 4;
|
||||
++j )
|
||||
{
|
||||
for (int i = 0;
|
||||
i < data.quads.count();
|
||||
++i)
|
||||
for (int j = 0;
|
||||
j < 4;
|
||||
++j) {
|
||||
WindowVertex& v = data.quads[ i ][ j ];
|
||||
v.move( v.x() + sin(mTimeElapsed + v.originalY() / 60 + 0.5f) * 10,
|
||||
v.y() + sin(mTimeElapsed + v.originalX() / 80) * 10 );
|
||||
v.move(v.x() + sin(mTimeElapsed + v.originalY() / 60 + 0.5f) * 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()
|
||||
{
|
||||
{
|
||||
// Repaint the workspace so that everything would be repainted next time
|
||||
effects->addRepaintFull();
|
||||
|
||||
// Call the next effect.
|
||||
effects->postPaintScreen();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -32,18 +32,18 @@ namespace KWin
|
|||
**/
|
||||
class WavyWindowsEffect
|
||||
: public Effect
|
||||
{
|
||||
public:
|
||||
WavyWindowsEffect();
|
||||
{
|
||||
public:
|
||||
WavyWindowsEffect();
|
||||
|
||||
virtual void prePaintScreen( ScreenPrePaintData& 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 postPaintScreen();
|
||||
virtual void prePaintScreen(ScreenPrePaintData& 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 postPaintScreen();
|
||||
|
||||
private:
|
||||
double mTimeElapsed;
|
||||
};
|
||||
private:
|
||||
double mTimeElapsed;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -15,63 +15,61 @@ License. See the file "COPYING" for the exact licensing terms.
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
KWIN_EFFECT( drunken, DrunkenEffect )
|
||||
KWIN_EFFECT(drunken, DrunkenEffect)
|
||||
|
||||
void DrunkenEffect::prePaintScreen( ScreenPrePaintData& data, int time )
|
||||
{
|
||||
if( !windows.isEmpty())
|
||||
void DrunkenEffect::prePaintScreen(ScreenPrePaintData& data, int time)
|
||||
{
|
||||
if (!windows.isEmpty())
|
||||
data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
|
||||
effects->prePaintScreen( data, time );
|
||||
}
|
||||
effects->prePaintScreen(data, time);
|
||||
}
|
||||
|
||||
void DrunkenEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time )
|
||||
{
|
||||
if( windows.contains( w ))
|
||||
{
|
||||
void DrunkenEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
|
||||
{
|
||||
if (windows.contains(w)) {
|
||||
windows[ w ] += time / 1000.;
|
||||
if( windows[ w ] < 1 )
|
||||
if (windows[ w ] < 1)
|
||||
data.setTransformed();
|
||||
else
|
||||
windows.remove( w );
|
||||
}
|
||||
effects->prePaintWindow( w, data, time );
|
||||
windows.remove(w);
|
||||
}
|
||||
effects->prePaintWindow(w, data, time);
|
||||
}
|
||||
|
||||
void DrunkenEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data )
|
||||
{
|
||||
if( !windows.contains( w ))
|
||||
{
|
||||
effects->paintWindow( w, mask, region, data );
|
||||
void DrunkenEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
|
||||
{
|
||||
if (!windows.contains(w)) {
|
||||
effects->paintWindow(w, mask, region, data);
|
||||
return;
|
||||
}
|
||||
}
|
||||
WindowPaintData d1 = data;
|
||||
// 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.opacity *= 0.5;
|
||||
effects->paintWindow( w, mask, region, d1 );
|
||||
effects->paintWindow(w, mask, region, d1);
|
||||
WindowPaintData d2 = data;
|
||||
d2.xTranslate += diff;
|
||||
d2.opacity *= 0.5;
|
||||
effects->paintWindow( w, mask, region, d2 );
|
||||
}
|
||||
effects->paintWindow(w, mask, region, d2);
|
||||
}
|
||||
|
||||
void DrunkenEffect::postPaintWindow( EffectWindow* w )
|
||||
{
|
||||
if( windows.contains( w ))
|
||||
void DrunkenEffect::postPaintWindow(EffectWindow* w)
|
||||
{
|
||||
if (windows.contains(w))
|
||||
w->addRepaintFull();
|
||||
effects->postPaintWindow( w );
|
||||
}
|
||||
effects->postPaintWindow(w);
|
||||
}
|
||||
|
||||
void DrunkenEffect::windowAdded( EffectWindow* w )
|
||||
{
|
||||
void DrunkenEffect::windowAdded(EffectWindow* w)
|
||||
{
|
||||
windows[ w ] = 0;
|
||||
w->addRepaintFull();
|
||||
}
|
||||
}
|
||||
|
||||
void DrunkenEffect::windowClosed( EffectWindow* w )
|
||||
{
|
||||
windows.remove( w );
|
||||
}
|
||||
void DrunkenEffect::windowClosed(EffectWindow* w)
|
||||
{
|
||||
windows.remove(w);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -18,17 +18,17 @@ namespace KWin
|
|||
|
||||
class DrunkenEffect
|
||||
: public Effect
|
||||
{
|
||||
public:
|
||||
virtual void prePaintScreen( ScreenPrePaintData& 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 postPaintWindow( EffectWindow* w );
|
||||
virtual void windowAdded( EffectWindow* w );
|
||||
virtual void windowClosed( EffectWindow* w );
|
||||
private:
|
||||
QHash< EffectWindow*, double > windows; // progress
|
||||
};
|
||||
{
|
||||
public:
|
||||
virtual void prePaintScreen(ScreenPrePaintData& 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 postPaintWindow(EffectWindow* w);
|
||||
virtual void windowAdded(EffectWindow* w);
|
||||
virtual void windowClosed(EffectWindow* w);
|
||||
private:
|
||||
QHash< EffectWindow*, double > windows; // progress
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -16,70 +16,64 @@ License. See the file "COPYING" for the exact licensing terms.
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
KWIN_EFFECT( flame, FlameEffect )
|
||||
KWIN_EFFECT(flame, FlameEffect)
|
||||
|
||||
void FlameEffect::prePaintScreen( ScreenPrePaintData& data, int time )
|
||||
{
|
||||
if( !windows.isEmpty())
|
||||
void FlameEffect::prePaintScreen(ScreenPrePaintData& data, int time)
|
||||
{
|
||||
if (!windows.isEmpty())
|
||||
data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
|
||||
effects->prePaintScreen(data, time);
|
||||
}
|
||||
}
|
||||
|
||||
void FlameEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time )
|
||||
{
|
||||
if( windows.contains( w ))
|
||||
{
|
||||
if( windows[ w ] < 1 )
|
||||
{
|
||||
void FlameEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
|
||||
{
|
||||
if (windows.contains(w)) {
|
||||
if (windows[ w ] < 1) {
|
||||
windows[ w ] += time / 500.;
|
||||
data.setTransformed();
|
||||
w->enablePainting( EffectWindow::PAINT_DISABLED_BY_DELETE );
|
||||
data.quads = data.quads.splitAtY( windows[ w ] * w->height());
|
||||
}
|
||||
else
|
||||
{
|
||||
windows.remove( w );
|
||||
w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DELETE);
|
||||
data.quads = data.quads.splitAtY(windows[ w ] * w->height());
|
||||
} else {
|
||||
windows.remove(w);
|
||||
w->unrefWindow();
|
||||
}
|
||||
}
|
||||
effects->prePaintWindow( w, data, time );
|
||||
}
|
||||
effects->prePaintWindow(w, data, time);
|
||||
}
|
||||
|
||||
void FlameEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data )
|
||||
{
|
||||
if( windows.contains( w ))
|
||||
{
|
||||
void FlameEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
|
||||
{
|
||||
if (windows.contains(w)) {
|
||||
WindowQuadList new_quads;
|
||||
double ylimit = windows[ w ] * w->height(); // parts above this are already away
|
||||
foreach( const WindowQuad &quad, data.quads )
|
||||
{
|
||||
if( quad.bottom() <= ylimit )
|
||||
foreach (const WindowQuad & quad, data.quads) {
|
||||
if (quad.bottom() <= ylimit)
|
||||
continue;
|
||||
new_quads.append( quad );
|
||||
}
|
||||
if( new_quads.isEmpty())
|
||||
new_quads.append(quad);
|
||||
}
|
||||
if (new_quads.isEmpty())
|
||||
return; // nothing to paint
|
||||
data.quads = new_quads;
|
||||
}
|
||||
effects->paintWindow( w, mask, region, data );
|
||||
}
|
||||
effects->paintWindow(w, mask, region, data);
|
||||
}
|
||||
|
||||
void FlameEffect::postPaintWindow( EffectWindow* w )
|
||||
{
|
||||
if( windows.contains( w ))
|
||||
effects->addRepaint( w->geometry()); // workspace, since the window under it will need painting too
|
||||
void FlameEffect::postPaintWindow(EffectWindow* w)
|
||||
{
|
||||
if (windows.contains(w))
|
||||
effects->addRepaint(w->geometry()); // workspace, since the window under it will need painting too
|
||||
effects->postPaintScreen();
|
||||
}
|
||||
}
|
||||
|
||||
void FlameEffect::windowClosed( EffectWindow* c )
|
||||
{
|
||||
void FlameEffect::windowClosed(EffectWindow* c)
|
||||
{
|
||||
windows[ c ] = 0;
|
||||
c->refWindow();
|
||||
}
|
||||
}
|
||||
|
||||
void FlameEffect::windowDeleted( EffectWindow* c )
|
||||
{
|
||||
windows.remove( c );
|
||||
}
|
||||
void FlameEffect::windowDeleted(EffectWindow* c)
|
||||
{
|
||||
windows.remove(c);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -18,17 +18,17 @@ namespace KWin
|
|||
|
||||
class FlameEffect
|
||||
: public Effect
|
||||
{
|
||||
public:
|
||||
virtual void prePaintScreen( ScreenPrePaintData& 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 postPaintWindow( EffectWindow* w );
|
||||
virtual void windowClosed( EffectWindow* c );
|
||||
virtual void windowDeleted( EffectWindow* c );
|
||||
private:
|
||||
QHash< const EffectWindow*, double > windows;
|
||||
};
|
||||
{
|
||||
public:
|
||||
virtual void prePaintScreen(ScreenPrePaintData& 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 postPaintWindow(EffectWindow* w);
|
||||
virtual void windowClosed(EffectWindow* c);
|
||||
virtual void windowDeleted(EffectWindow* c);
|
||||
private:
|
||||
QHash< const EffectWindow*, double > windows;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -33,77 +33,74 @@ Which is based on glxgears.c by Brian Paul:
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
KWIN_EFFECT( gears, GearsEffect )
|
||||
KWIN_EFFECT_SUPPORTED( gears, GearsEffect::supported() )
|
||||
KWIN_EFFECT(gears, GearsEffect)
|
||||
KWIN_EFFECT_SUPPORTED(gears, GearsEffect::supported())
|
||||
|
||||
GearsEffect::GearsEffect()
|
||||
: CubeInsideEffect()
|
||||
, m_active( false )
|
||||
, m_contentRotation( 0.0f )
|
||||
, m_angle( 0.0f )
|
||||
{
|
||||
, m_active(false)
|
||||
, m_contentRotation(0.0f)
|
||||
, m_angle(0.0f)
|
||||
{
|
||||
CubeEffectProxy* proxy =
|
||||
static_cast<CubeEffectProxy*>( effects->getProxy( "cube" ) );
|
||||
if( proxy )
|
||||
proxy->registerCubeInsideEffect( this );
|
||||
}
|
||||
static_cast<CubeEffectProxy*>(effects->getProxy("cube"));
|
||||
if (proxy)
|
||||
proxy->registerCubeInsideEffect(this);
|
||||
}
|
||||
|
||||
GearsEffect::~GearsEffect()
|
||||
{
|
||||
{
|
||||
CubeEffectProxy* proxy =
|
||||
static_cast<CubeEffectProxy*>( effects->getProxy( "cube" ) );
|
||||
if( proxy )
|
||||
proxy->unregisterCubeInsideEffect( this );
|
||||
}
|
||||
static_cast<CubeEffectProxy*>(effects->getProxy("cube"));
|
||||
if (proxy)
|
||||
proxy->unregisterCubeInsideEffect(this);
|
||||
}
|
||||
|
||||
bool GearsEffect::supported()
|
||||
{
|
||||
return effects->compositingType() == OpenGLCompositing;
|
||||
}
|
||||
|
||||
void GearsEffect::prePaintScreen( ScreenPrePaintData& data, int time )
|
||||
{
|
||||
if( m_active )
|
||||
{
|
||||
void GearsEffect::prePaintScreen(ScreenPrePaintData& data, int time)
|
||||
{
|
||||
if (m_active) {
|
||||
m_contentRotation += time * 360.0f / 20000.0f;
|
||||
if( m_contentRotation > 360.0f )
|
||||
if (m_contentRotation > 360.0f)
|
||||
m_contentRotation -= 360.0f;
|
||||
m_angle += time * 360.0f / 8000.0f;
|
||||
if( m_angle > 360.0f )
|
||||
if (m_angle > 360.0f)
|
||||
m_angle -= 360.0f;
|
||||
}
|
||||
effects->prePaintScreen( data, time );
|
||||
}
|
||||
effects->prePaintScreen(data, time);
|
||||
}
|
||||
|
||||
void GearsEffect::postPaintScreen()
|
||||
{
|
||||
if( m_active )
|
||||
{
|
||||
{
|
||||
if (m_active) {
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
effects->postPaintScreen();
|
||||
}
|
||||
effects->postPaintScreen();
|
||||
}
|
||||
|
||||
|
||||
void GearsEffect::paint()
|
||||
{
|
||||
if( m_active )
|
||||
{
|
||||
{
|
||||
if (m_active) {
|
||||
paintGears();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GearsEffect::setActive( bool active )
|
||||
{
|
||||
void GearsEffect::setActive(bool active)
|
||||
{
|
||||
m_active = active;
|
||||
if( active )
|
||||
if (active)
|
||||
initGears();
|
||||
else
|
||||
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;
|
||||
GLfloat r0, r1, r2, maxr2, minr2;
|
||||
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;
|
||||
|
||||
glShadeModel( GL_FLAT );
|
||||
glShadeModel(GL_FLAT);
|
||||
|
||||
glNormal3f( 0.0, 0.0, 1.0 );
|
||||
glNormal3f(0.0, 0.0, 1.0);
|
||||
|
||||
/* 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;
|
||||
glVertex3f( r0 * cos( angle ), r0 * 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(r1 * cos(angle), r1 * sin(angle), width * 0.5);
|
||||
|
||||
if( i < teeth )
|
||||
{
|
||||
glVertex3f( r0 * cos( angle ), r0 * sin( angle ), width * 0.5 );
|
||||
glVertex3f( r1 * cos( angle + 3 * da ), r1 * sin( angle + 3 * da ), width * 0.5 );
|
||||
}
|
||||
if (i < teeth) {
|
||||
glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
|
||||
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5);
|
||||
}
|
||||
}
|
||||
|
||||
glEnd();
|
||||
|
||||
/* 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;
|
||||
|
||||
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 + 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), r1 * sin(angle), 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(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5);
|
||||
r2 = minr2;
|
||||
}
|
||||
}
|
||||
|
||||
r2 = maxr2;
|
||||
|
||||
glEnd();
|
||||
|
||||
glNormal3f( 0.0, 0.0, -1.0 );
|
||||
glNormal3f(0.0, 0.0, -1.0);
|
||||
|
||||
/* 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;
|
||||
glVertex3f( r1 * cos( angle ), r1 * 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(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
|
||||
|
||||
if( i < teeth )
|
||||
{
|
||||
glVertex3f( r1 * cos( angle + 3 * da ), r1 * sin( angle + 3 * da ), -width * 0.5 );
|
||||
glVertex3f( r0 * cos( angle ), r0 * sin( angle ), -width * 0.5 );
|
||||
}
|
||||
if (i < teeth) {
|
||||
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5);
|
||||
glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
|
||||
}
|
||||
}
|
||||
|
||||
glEnd();
|
||||
|
||||
/* draw back sides of teeth */
|
||||
glBegin( GL_QUADS );
|
||||
glBegin(GL_QUADS);
|
||||
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;
|
||||
|
||||
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 + da), r2 * sin (angle + da), -width * 0.5 );
|
||||
glVertex3f( r1 * cos (angle), r1 * sin (angle), -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 + da), r2 * sin(angle + da), -width * 0.5);
|
||||
glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
|
||||
r2 = minr2;
|
||||
}
|
||||
}
|
||||
|
||||
r2 = maxr2;
|
||||
|
||||
glEnd();
|
||||
|
||||
/* 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;
|
||||
|
||||
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 );
|
||||
v = r2 * sin( angle + da ) - r1 * sin( angle );
|
||||
len = sqrt( u * u + v * v );
|
||||
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);
|
||||
v = r2 * sin(angle + da) - r1 * sin(angle);
|
||||
len = sqrt(u * u + v * v);
|
||||
u /= len;
|
||||
v /= len;
|
||||
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 );
|
||||
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 );
|
||||
u = r1 * cos( angle + 3 * da ) - r2 * cos( angle + 2 * da );
|
||||
v = r1 * sin( angle + 3 * da ) - r2 * sin( angle + 2 * da );
|
||||
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 );
|
||||
glNormal3f( cos( angle + 3.5 * da ), sin( angle + 3.5 * da ), 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);
|
||||
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);
|
||||
u = r1 * cos(angle + 3 * da) - r2 * cos(angle + 2 * da);
|
||||
v = r1 * sin(angle + 3 * da) - r2 * sin(angle + 2 * da);
|
||||
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);
|
||||
glNormal3f(cos(angle + 3.5 * da), sin(angle + 3.5 * da), 0.0);
|
||||
r2 = minr2;
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
glShadeModel( GL_SMOOTH );
|
||||
glShadeModel(GL_SMOOTH);
|
||||
|
||||
/* 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;
|
||||
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 );
|
||||
}
|
||||
glEnd();
|
||||
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);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
||||
void GearsEffect::paintGears()
|
||||
{
|
||||
{
|
||||
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();
|
||||
// invert scale
|
||||
float fovy = 60.0f;
|
||||
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 xmin = ymin;
|
||||
float xmax = 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 );
|
||||
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);
|
||||
|
||||
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();
|
||||
|
||||
// content rotation requires depth test - so disabled
|
||||
// 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_LIGHTING );
|
||||
glEnable( GL_LIGHT1 );
|
||||
glDisable( GL_COLOR_MATERIAL );
|
||||
glEnable(GL_NORMALIZE);
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_LIGHT1);
|
||||
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();
|
||||
glTranslatef( -3.0, -2.0, 0.0 );
|
||||
glRotatef( m_angle, 0.0, 0.0, 1.0 );
|
||||
glCallList( m_gear1 );
|
||||
glTranslatef(-3.0, -2.0, 0.0);
|
||||
glRotatef(m_angle, 0.0, 0.0, 1.0);
|
||||
glCallList(m_gear1);
|
||||
glPopMatrix();
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef( 3.1, -2.0, 0.0 );
|
||||
glRotatef( -2.0 * m_angle - 9.0, 0.0, 0.0, 1.0 );
|
||||
glCallList( m_gear2 );
|
||||
glTranslatef(3.1, -2.0, 0.0);
|
||||
glRotatef(-2.0 * m_angle - 9.0, 0.0, 0.0, 1.0);
|
||||
glCallList(m_gear2);
|
||||
glPopMatrix();
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef( -3.1, 4.2, 0.0 );
|
||||
glRotatef( -2.0 * m_angle - 25.0, 0.0, 0.0, 1.0 );
|
||||
glCallList( m_gear3 );
|
||||
glTranslatef(-3.1, 4.2, 0.0);
|
||||
glRotatef(-2.0 * m_angle - 25.0, 0.0, 0.0, 1.0);
|
||||
glCallList(m_gear3);
|
||||
glPopMatrix();
|
||||
|
||||
glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, white );
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, white);
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
glDisable( GL_LIGHT1 );
|
||||
glDisable( GL_NORMALIZE );
|
||||
glEnable( GL_COLOR_MATERIAL );
|
||||
glDisable(GL_LIGHT1);
|
||||
glDisable(GL_NORMALIZE);
|
||||
glEnable(GL_COLOR_MATERIAL);
|
||||
|
||||
glDisable( GL_LIGHTING );
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
glPopMatrix();
|
||||
glPopAttrib();
|
||||
}
|
||||
}
|
||||
|
||||
void GearsEffect::initGears()
|
||||
{
|
||||
{
|
||||
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 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 diffuseLight[] = { 0.5f, 0.5f, 0.5f, 0.5f };
|
||||
|
||||
glLightfv( GL_LIGHT1, GL_AMBIENT, ambientLight );
|
||||
glLightfv( GL_LIGHT1, GL_DIFFUSE, diffuseLight );
|
||||
glLightfv( GL_LIGHT1, GL_POSITION, pos );
|
||||
glLightfv(GL_LIGHT1, GL_AMBIENT, ambientLight);
|
||||
glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuseLight);
|
||||
glLightfv(GL_LIGHT1, GL_POSITION, pos);
|
||||
|
||||
m_gear1 = glGenLists( 1 );
|
||||
glNewList( m_gear1, GL_COMPILE );
|
||||
glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red );
|
||||
gear( 1.0f, 4.0f, 1.0f, 20, 0.7f );
|
||||
m_gear1 = glGenLists(1);
|
||||
glNewList(m_gear1, GL_COMPILE);
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
|
||||
gear(1.0f, 4.0f, 1.0f, 20, 0.7f);
|
||||
glEndList();
|
||||
|
||||
m_gear2 = glGenLists( 1 );
|
||||
glNewList( m_gear2, GL_COMPILE );
|
||||
glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green );
|
||||
gear( 0.5f, 2.0f, 2.0f, 10, 0.7f );
|
||||
m_gear2 = glGenLists(1);
|
||||
glNewList(m_gear2, GL_COMPILE);
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);
|
||||
gear(0.5f, 2.0f, 2.0f, 10, 0.7f);
|
||||
glEndList();
|
||||
|
||||
m_gear3 = glGenLists( 1 );
|
||||
glNewList( m_gear3, GL_COMPILE );
|
||||
glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue );
|
||||
gear( 1.3f, 2.0f, 0.5f, 10, 0.7f );
|
||||
m_gear3 = glGenLists(1);
|
||||
glNewList(m_gear3, GL_COMPILE);
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
|
||||
gear(1.3f, 2.0f, 0.5f, 10, 0.7f);
|
||||
glEndList();
|
||||
}
|
||||
}
|
||||
|
||||
void GearsEffect::endGears()
|
||||
{
|
||||
glDeleteLists( m_gear1, 1 );
|
||||
glDeleteLists( m_gear2, 1 );
|
||||
glDeleteLists( m_gear3, 1 );
|
||||
}
|
||||
{
|
||||
glDeleteLists(m_gear1, 1);
|
||||
glDeleteLists(m_gear2, 1);
|
||||
glDeleteLists(m_gear3, 1);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -33,28 +33,28 @@ namespace KWin
|
|||
|
||||
class GearsEffect : public CubeInsideEffect
|
||||
{
|
||||
public:
|
||||
GearsEffect();
|
||||
~GearsEffect();
|
||||
public:
|
||||
GearsEffect();
|
||||
~GearsEffect();
|
||||
|
||||
virtual void paint();
|
||||
virtual void setActive( bool active );
|
||||
virtual void prePaintScreen(ScreenPrePaintData& data, int time);
|
||||
virtual void postPaintScreen();
|
||||
virtual void paint();
|
||||
virtual void setActive(bool active);
|
||||
virtual void prePaintScreen(ScreenPrePaintData& data, int time);
|
||||
virtual void postPaintScreen();
|
||||
|
||||
static bool supported();
|
||||
private:
|
||||
void gear( float inner_radius, float outer_radius, float width, int teeth, float tooth_depth );
|
||||
void paintGears();
|
||||
void initGears();
|
||||
void endGears();
|
||||
static bool supported();
|
||||
private:
|
||||
void gear(float inner_radius, float outer_radius, float width, int teeth, float tooth_depth);
|
||||
void paintGears();
|
||||
void initGears();
|
||||
void endGears();
|
||||
|
||||
bool m_active;
|
||||
GLuint m_gear1;
|
||||
GLuint m_gear2;
|
||||
GLuint m_gear3;
|
||||
float m_contentRotation;
|
||||
float m_angle;
|
||||
bool m_active;
|
||||
GLuint m_gear1;
|
||||
GLuint m_gear2;
|
||||
GLuint m_gear3;
|
||||
float m_contentRotation;
|
||||
float m_angle;
|
||||
};
|
||||
|
||||
} //namespace
|
||||
|
|
|
@ -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.
|
||||
|
||||
Please see file howto.h first.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
// 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.
|
||||
KWIN_EFFECT( howto, HowtoEffect )
|
||||
KWIN_EFFECT(howto, HowtoEffect)
|
||||
|
||||
// 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
|
||||
|
@ -36,33 +36,29 @@ KWIN_EFFECT( howto, HowtoEffect )
|
|||
// region - the region of the screen that needs to be painted, support for modifying it
|
||||
// is not fully implemented yet, do not use
|
||||
// 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?
|
||||
if( w == fade_window )
|
||||
{
|
||||
if (w == fade_window) {
|
||||
// Simply add the time to the total progress. The value of progress will be used
|
||||
// to determine how far in effect is.
|
||||
progress += time;
|
||||
// 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
|
||||
// the flags so that the window will be painted only as translucent.
|
||||
// Use a helper that also takes care of changing the clipping rectangle.
|
||||
data.setTranslucent();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// If progress has reached 1000 (milliseconds), it means the effect is done
|
||||
// and there is no window to fade anymore.
|
||||
fade_window = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 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->prePaintWindow( w, data, time );
|
||||
}
|
||||
effects->prePaintWindow(w, data, time);
|
||||
}
|
||||
|
||||
// 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
|
||||
|
@ -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
|
||||
// everything needs to be painted
|
||||
// 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?
|
||||
if( w == fade_window )
|
||||
{
|
||||
if (w == fade_window) {
|
||||
// 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
|
||||
// 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.
|
||||
// progress == 0 -> opacity *= 1
|
||||
// progress == 500 -> opacity *= 0.5
|
||||
// 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,
|
||||
// for example if another effect always changes opacity of some window types.
|
||||
data.opacity *= 1 - 0.5 * ( progress / 500.0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
data.opacity *= 1 - 0.5 * (progress / 500.0);
|
||||
} else {
|
||||
// For the second 500 milliseconds (progress being 500 to 1000), the window is
|
||||
// faded in again.
|
||||
// progress == 500 -> opacity *= 0.5
|
||||
// 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,
|
||||
// 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?
|
||||
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.
|
||||
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.
|
||||
void HowtoEffect::windowActivated( EffectWindow* c )
|
||||
{
|
||||
void HowtoEffect::windowActivated(EffectWindow* c)
|
||||
{
|
||||
// Set the window to be faded (or NULL if no window is active).
|
||||
fade_window = c;
|
||||
if( fade_window != NULL )
|
||||
{
|
||||
if (fade_window != NULL) {
|
||||
// If there is a window to be faded, reset the progress to zero.
|
||||
progress = 0;
|
||||
// And add repaint to the window so that it needs to be repainted.
|
||||
c->addRepaintFull();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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.
|
||||
// This effect then will do nothing and just call the next effect.
|
||||
if( fade_window == c )
|
||||
if (fade_window == c)
|
||||
fade_window = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// That's all. Now only the matching .desktop file is needed.
|
||||
|
||||
|
|
|
@ -30,39 +30,39 @@ namespace KWin
|
|||
class HowtoEffect
|
||||
// Inherit from the base class for effects.
|
||||
: public Effect
|
||||
{
|
||||
public:
|
||||
// There are two kinds of functions in an effect:
|
||||
|
||||
// Functions related to painting: These allow the effect to affect painting.
|
||||
{
|
||||
public:
|
||||
// There are two kinds of functions in an effect:
|
||||
|
||||
// A pre-paint function. It tells the compositing code how the painting will
|
||||
// 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.
|
||||
// Functions related to painting: These allow the effect to affect painting.
|
||||
|
||||
// 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;
|
||||
};
|
||||
// A pre-paint function. It tells the compositing code how the painting will
|
||||
// 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.
|
||||
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
|
||||
|
||||
|
|
|
@ -29,230 +29,212 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
KWIN_EFFECT( kicker, KickerEffect )
|
||||
KWIN_EFFECT(kicker, KickerEffect)
|
||||
|
||||
KickerEffect::KickerEffect()
|
||||
: m_page( new QWebPage( this ) )
|
||||
, m_timer( new QTimer( this ) )
|
||||
, m_goalTimer( new QTimer( this ) )
|
||||
, m_goalActive( false )
|
||||
, m_ascending( false )
|
||||
{
|
||||
: m_page(new QWebPage(this))
|
||||
, m_timer(new QTimer(this))
|
||||
, m_goalTimer(new QTimer(this))
|
||||
, m_goalActive(false)
|
||||
, m_ascending(false)
|
||||
{
|
||||
connect(m_page, SIGNAL(loadFinished(bool)), this, SLOT(slotLoadFinished(bool)));
|
||||
connect(m_timer, SIGNAL(timeout()), this, SLOT(timeout()));
|
||||
connect(m_goalTimer, SIGNAL(timeout()), this, SLOT(goalTimeout()));
|
||||
|
||||
reconfigure( ReconfigureAll );
|
||||
reconfigure(ReconfigureAll);
|
||||
// reload the webpage each half a minute
|
||||
m_timer->start(30*1000);
|
||||
m_timer->start(30 * 1000);
|
||||
// goal animation should end after seven seconds
|
||||
m_goalTimer->setInterval( 7 * 1000 );
|
||||
m_goalTimer->setSingleShot( true );
|
||||
m_goalTimer->setInterval(7 * 1000);
|
||||
m_goalTimer->setSingleShot(true);
|
||||
// the animations should have a duration of half a second with an
|
||||
// ease in out curve
|
||||
m_timeLine.setCurveShape( TimeLine::EaseInOutCurve );
|
||||
m_timeLine.setDuration( 500 );
|
||||
m_timeLine.setCurveShape(TimeLine::EaseInOutCurve);
|
||||
m_timeLine.setDuration(500);
|
||||
// let's download the webpage immediatelly
|
||||
timeout();
|
||||
}
|
||||
}
|
||||
|
||||
KickerEffect::~KickerEffect()
|
||||
{
|
||||
while( !m_frames.isEmpty() )
|
||||
{
|
||||
{
|
||||
while (!m_frames.isEmpty()) {
|
||||
delete m_frames.first();
|
||||
m_frames.removeFirst();
|
||||
}
|
||||
while( !m_goalFrames.isEmpty() )
|
||||
{
|
||||
}
|
||||
while (!m_goalFrames.isEmpty()) {
|
||||
delete m_goalFrames.first();
|
||||
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
|
||||
// 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
|
||||
// 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
|
||||
// descending (decreasing opacity). In case of ascending we add time
|
||||
// to the timeline till progress reaches 1.0. There we switch direction
|
||||
// to descending. In descending case of course vice versa.
|
||||
if( m_ascending )
|
||||
{
|
||||
m_timeLine.addTime( time );
|
||||
if( m_timeLine.progress() == 1.0 )
|
||||
{
|
||||
if (m_ascending) {
|
||||
m_timeLine.addTime(time);
|
||||
if (m_timeLine.progress() == 1.0) {
|
||||
m_ascending = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_timeLine.removeTime( time );
|
||||
} else {
|
||||
m_timeLine.removeTime(time);
|
||||
// it is possible that this is the last animation. Therefore the
|
||||
// anding with goalActive. If it has been the last animation we
|
||||
// do not need to keep the goal EffectFrame around any more, so
|
||||
// we delete them.
|
||||
if( m_timeLine.progress() == 0.0 && m_goalActive )
|
||||
{
|
||||
if (m_timeLine.progress() == 0.0 && m_goalActive) {
|
||||
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
|
||||
while( !m_goalFrames.isEmpty() )
|
||||
{
|
||||
while (!m_goalFrames.isEmpty()) {
|
||||
delete m_goalFrames.first();
|
||||
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 )
|
||||
{
|
||||
effects->paintScreen( mask, region, data );
|
||||
void KickerEffect::paintScreen(int mask, QRegion region, ScreenPaintData &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
|
||||
// uses Plasma styled textures it's still translucent, but the text
|
||||
// is fully opaque.
|
||||
foreach( EffectFrame* frame, m_frames )
|
||||
frame->render( region, 1.0 );
|
||||
}
|
||||
if( m_goalActive || m_timeLine.progress() != 0.0 )
|
||||
{
|
||||
foreach (EffectFrame * frame, m_frames)
|
||||
frame->render(region, 1.0);
|
||||
}
|
||||
if (m_goalActive || m_timeLine.progress() != 0.0) {
|
||||
// the goal animation changes the opacity. Therefore we modify the
|
||||
// opacity by multiplying with the timeline's progress.
|
||||
// The text should be fully opaque (1.0), while the background should
|
||||
// be translucent (0.75)
|
||||
foreach( EffectFrame* frame, m_goalFrames )
|
||||
frame->render( region, 1.0 * m_timeLine.progress(), 0.75 * m_timeLine.progress() );
|
||||
foreach (EffectFrame * frame, m_goalFrames)
|
||||
frame->render(region, 1.0 * m_timeLine.progress(), 0.75 * m_timeLine.progress());
|
||||
// we are animating: need a new frame
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void KickerEffect::slotLoadFinished( bool ok )
|
||||
{
|
||||
void KickerEffect::slotLoadFinished(bool ok)
|
||||
{
|
||||
// if connection failed let's keep the last score
|
||||
if( !ok )
|
||||
if (!ok)
|
||||
return;
|
||||
|
||||
QWebElement doc = m_page->mainFrame()->documentElement();
|
||||
// CSS selector for the teams
|
||||
QWebElementCollection teams = doc.findAll("td.lttabver h1 a");
|
||||
if( teams.count() != 2 )
|
||||
if (teams.count() != 2)
|
||||
return;
|
||||
QString firstTeam = teams[0].toPlainText();
|
||||
QString secondTeam = teams[1].toPlainText();
|
||||
|
||||
// CSS selector for the current score
|
||||
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
|
||||
bool activate = true;
|
||||
// but not if the web page has been loaded for the first time
|
||||
if( m_score.isNull() )
|
||||
if (m_score.isNull())
|
||||
activate = false;
|
||||
// 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;
|
||||
// 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;
|
||||
// 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;
|
||||
// not if first or second half starts.
|
||||
if( m_score.count( '-' ) > result.count( '-' ) )
|
||||
if (m_score.count('-') > result.count('-'))
|
||||
activate = false;
|
||||
// yeah it's a goal - generate the EffectFrame and start the animation
|
||||
if( activate )
|
||||
{
|
||||
if (activate) {
|
||||
generateGoalImage();
|
||||
m_goalActive = true;
|
||||
m_ascending = true;
|
||||
m_goalTimer->start();
|
||||
}
|
||||
m_score = result;
|
||||
}
|
||||
m_score = result;
|
||||
}
|
||||
|
||||
QString text = firstTeam + ' ' + result + ' ' + secondTeam;
|
||||
QFont font;
|
||||
font.setBold( true );
|
||||
font.setBold(true);
|
||||
QFontMetrics fm(font);
|
||||
m_size = fm.boundingRect(text).adjusted(-10, -10, 10, 10).size();
|
||||
// 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
|
||||
// half a minute and it's easier to code...
|
||||
while( !m_frames.isEmpty() )
|
||||
{
|
||||
while (!m_frames.isEmpty()) {
|
||||
delete m_frames.first();
|
||||
m_frames.removeFirst();
|
||||
}
|
||||
}
|
||||
m_frames.clear();
|
||||
// and properly position the frame on each screen
|
||||
for( int i = 0; i < effects->numScreens(); i++ )
|
||||
{
|
||||
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() );
|
||||
EffectFrame *frame = new EffectFrame( EffectFrame::Styled );
|
||||
frame->setText( text );
|
||||
frame->setFont( font );
|
||||
frame->setGeometry( geometry );
|
||||
for (int i = 0; i < effects->numScreens(); i++) {
|
||||
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());
|
||||
EffectFrame *frame = new EffectFrame(EffectFrame::Styled);
|
||||
frame->setText(text);
|
||||
frame->setFont(font);
|
||||
frame->setGeometry(geometry);
|
||||
m_frames.append(frame);
|
||||
}
|
||||
}
|
||||
// effect frame changed and animation might have started - we need a full repaint
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
}
|
||||
|
||||
void KickerEffect::timeout()
|
||||
{
|
||||
{
|
||||
// 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.
|
||||
m_page->mainFrame()->load(QUrl("http://www.kicker.de/news/fussball/wm/spielplan/weltmeisterschaft/2010/5/833353/livematch_argentinien_deutschland.html"));
|
||||
}
|
||||
}
|
||||
|
||||
void KickerEffect::generateGoalImage()
|
||||
{
|
||||
QFont font( "FreeMono", 172 );
|
||||
QString goal( "GOAL" );
|
||||
QFontMetrics fm( font );
|
||||
QSize size = fm.boundingRect( goal ).adjusted(-10, -10, 10, 10).size();
|
||||
for( int i = 0; i < effects->numScreens(); i++ )
|
||||
{
|
||||
{
|
||||
QFont font("FreeMono", 172);
|
||||
QString goal("GOAL");
|
||||
QFontMetrics fm(font);
|
||||
QSize size = fm.boundingRect(goal).adjusted(-10, -10, 10, 10).size();
|
||||
for (int i = 0; i < effects->numScreens(); i++) {
|
||||
// place one frame on the center of each screen
|
||||
QRect area = effects->clientArea( ScreenArea, i, effects->currentDesktop());
|
||||
QRect geometry = QRect( area.x() + (area.width() - size.width())/2,
|
||||
area.y() + (area.height() - size.height())/2,
|
||||
size.width(), size.height());
|
||||
EffectFrame *frame = new EffectFrame( EffectFrame::Unstyled, false );
|
||||
frame->setText( goal );
|
||||
frame->setFont( font );
|
||||
frame->setGeometry( geometry );
|
||||
QRect area = effects->clientArea(ScreenArea, i, effects->currentDesktop());
|
||||
QRect geometry = QRect(area.x() + (area.width() - size.width()) / 2,
|
||||
area.y() + (area.height() - size.height()) / 2,
|
||||
size.width(), size.height());
|
||||
EffectFrame *frame = new EffectFrame(EffectFrame::Unstyled, false);
|
||||
frame->setText(goal);
|
||||
frame->setFont(font);
|
||||
frame->setGeometry(geometry);
|
||||
m_goalFrames.append(frame);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void KickerEffect::goalTimeout()
|
||||
{
|
||||
{
|
||||
// stop the animation
|
||||
m_goalActive = false;
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -51,33 +51,33 @@ namespace KWin
|
|||
* @author Martin Gräßlin
|
||||
*/
|
||||
class KickerEffect : public QObject, public Effect
|
||||
{
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
KickerEffect();
|
||||
~KickerEffect();
|
||||
virtual void reconfigure( ReconfigureFlags );
|
||||
virtual void prePaintScreen( ScreenPrePaintData& data, int time );
|
||||
virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data );
|
||||
public:
|
||||
KickerEffect();
|
||||
~KickerEffect();
|
||||
virtual void reconfigure(ReconfigureFlags);
|
||||
virtual void prePaintScreen(ScreenPrePaintData& data, int time);
|
||||
virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data);
|
||||
|
||||
private Q_SLOTS:
|
||||
void slotLoadFinished(bool ok);
|
||||
void timeout();
|
||||
void goalTimeout();
|
||||
private Q_SLOTS:
|
||||
void slotLoadFinished(bool ok);
|
||||
void timeout();
|
||||
void goalTimeout();
|
||||
|
||||
private:
|
||||
void generateGoalImage();
|
||||
QWebPage *m_page;
|
||||
QTimer *m_timer;
|
||||
QTimer *m_goalTimer;
|
||||
QSize m_size;
|
||||
QList<EffectFrame*> m_frames;
|
||||
QList<EffectFrame*> m_goalFrames;
|
||||
bool m_goalActive;
|
||||
QString m_score;
|
||||
TimeLine m_timeLine;
|
||||
bool m_ascending;
|
||||
};
|
||||
private:
|
||||
void generateGoalImage();
|
||||
QWebPage *m_page;
|
||||
QTimer *m_timer;
|
||||
QTimer *m_goalTimer;
|
||||
QSize m_size;
|
||||
QList<EffectFrame*> m_frames;
|
||||
QList<EffectFrame*> m_goalFrames;
|
||||
bool m_goalActive;
|
||||
QString m_score;
|
||||
TimeLine m_timeLine;
|
||||
bool m_ascending;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -26,169 +26,160 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
KWIN_EFFECT( slidetabs, SlideTabsEffect )
|
||||
KWIN_EFFECT(slidetabs, SlideTabsEffect)
|
||||
|
||||
SlideTabsEffect::SlideTabsEffect()
|
||||
{
|
||||
reconfigure( ReconfigureAll );
|
||||
}
|
||||
{
|
||||
reconfigure(ReconfigureAll);
|
||||
}
|
||||
|
||||
void SlideTabsEffect::reconfigure( ReconfigureFlags )
|
||||
{
|
||||
void SlideTabsEffect::reconfigure(ReconfigureFlags)
|
||||
{
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("SlideTabs");
|
||||
switching = conf.readEntry("SlideSwitching", true );
|
||||
grouping = conf.readEntry("SlideGrouping", true );
|
||||
totalTime = conf.readEntry("SlideDuration", 500 );
|
||||
}
|
||||
switching = conf.readEntry("SlideSwitching", true);
|
||||
grouping = conf.readEntry("SlideGrouping", true);
|
||||
totalTime = conf.readEntry("SlideDuration", 500);
|
||||
}
|
||||
|
||||
void SlideTabsEffect::prePaintWindow( EffectWindow *w, WindowPrePaintData &data, int time )
|
||||
{
|
||||
if( motionManager.isManaging( w ) )
|
||||
{
|
||||
void SlideTabsEffect::prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time)
|
||||
{
|
||||
if (motionManager.isManaging(w)) {
|
||||
data.setTransformed();
|
||||
w->enablePainting( EffectWindow::PAINT_DISABLED );
|
||||
timeLine.addTime( time );
|
||||
}
|
||||
effects->prePaintWindow( w, data, time );
|
||||
w->enablePainting(EffectWindow::PAINT_DISABLED);
|
||||
timeLine.addTime(time);
|
||||
}
|
||||
effects->prePaintWindow(w, data, time);
|
||||
}
|
||||
|
||||
void SlideTabsEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data )
|
||||
{
|
||||
if( motionManager.isManaging( w ) && w == inMove )
|
||||
motionManager.apply( w, data );
|
||||
effects->paintWindow( w, mask, region, data );
|
||||
}
|
||||
void SlideTabsEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
|
||||
{
|
||||
if (motionManager.isManaging(w) && w == inMove)
|
||||
motionManager.apply(w, data);
|
||||
effects->paintWindow(w, mask, region, data);
|
||||
}
|
||||
|
||||
void SlideTabsEffect::postPaintWindow( EffectWindow* w )
|
||||
{
|
||||
if( motionManager.isManaging( w ) )
|
||||
{
|
||||
if( w == inMove )
|
||||
{
|
||||
void SlideTabsEffect::postPaintWindow(EffectWindow* w)
|
||||
{
|
||||
if (motionManager.isManaging(w)) {
|
||||
if (w == inMove) {
|
||||
QRect moving = calculateNextMove();
|
||||
motionManager.moveWindow( w, moving );
|
||||
if( direction && timeLine.progress() >= 0.5 )
|
||||
{
|
||||
motionManager.moveWindow(w, moving);
|
||||
if (direction && timeLine.progress() >= 0.5) {
|
||||
moving = target;
|
||||
target = source;
|
||||
source = moving;
|
||||
direction = false;
|
||||
effects->setElevatedWindow( notMoving, false );
|
||||
effects->setElevatedWindow( w, true );
|
||||
}
|
||||
else if( timeLine.progress() >= 1.0 )
|
||||
{
|
||||
effects->setElevatedWindow( notMoving, false );
|
||||
effects->setElevatedWindow( inMove, false );
|
||||
motionManager.unmanage( notMoving );
|
||||
motionManager.unmanage( inMove );
|
||||
effects->setElevatedWindow(notMoving, false);
|
||||
effects->setElevatedWindow(w, true);
|
||||
} else if (timeLine.progress() >= 1.0) {
|
||||
effects->setElevatedWindow(notMoving, false);
|
||||
effects->setElevatedWindow(inMove, false);
|
||||
motionManager.unmanage(notMoving);
|
||||
motionManager.unmanage(inMove);
|
||||
notMoving = NULL;
|
||||
inMove = NULL;
|
||||
wasD = false;
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
}
|
||||
else if( w == notMoving && !direction && target != w->geometry() && !wasD )
|
||||
{
|
||||
} else if (w == notMoving && !direction && target != w->geometry() && !wasD) {
|
||||
target = w->geometry();
|
||||
}
|
||||
}
|
||||
w->addRepaintFull();
|
||||
}
|
||||
effects->postPaintWindow( w );
|
||||
}
|
||||
effects->postPaintWindow(w);
|
||||
}
|
||||
|
||||
void SlideTabsEffect::prePaintScreen( ScreenPrePaintData &data, int time )
|
||||
{
|
||||
if( motionManager.managingWindows() )
|
||||
{
|
||||
motionManager.calculate( time );
|
||||
void SlideTabsEffect::prePaintScreen(ScreenPrePaintData &data, int time)
|
||||
{
|
||||
if (motionManager.managingWindows()) {
|
||||
motionManager.calculate(time);
|
||||
data.mask |= Effect::PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
|
||||
}
|
||||
effects->prePaintScreen( data, time );
|
||||
}
|
||||
effects->prePaintScreen(data, time);
|
||||
}
|
||||
|
||||
void SlideTabsEffect::postPaintScreen()
|
||||
{
|
||||
if( motionManager.managingWindows() )
|
||||
{
|
||||
if (motionManager.managingWindows())
|
||||
effects->addRepaintFull();
|
||||
effects->postPaintScreen();
|
||||
}
|
||||
}
|
||||
|
||||
void SlideTabsEffect::clientGroupItemSwitched( EffectWindow* from, EffectWindow* to )
|
||||
{
|
||||
if( !switching )
|
||||
void SlideTabsEffect::clientGroupItemSwitched(EffectWindow* from, EffectWindow* to)
|
||||
{
|
||||
if (!switching)
|
||||
return;
|
||||
inMove = to;
|
||||
notMoving = from;
|
||||
source = notMoving->geometry();
|
||||
QRect window = notMoving->geometry();
|
||||
int leftSpace = window.x(), rightSpace = displayWidth() - ( window.x() + window.width() ),
|
||||
upSpace = window.y(), downSpace = displayHeight() - ( window.y() + window.height() );
|
||||
int leftSpace = window.x(), rightSpace = displayWidth() - (window.x() + window.width()),
|
||||
upSpace = window.y(), downSpace = displayHeight() - (window.y() + window.height());
|
||||
|
||||
if( leftSpace >= rightSpace && leftSpace >= upSpace && leftSpace >= downSpace )
|
||||
target = QRect( source.x() - ( 1.2 * source.width() ), source.y(), source.width(), source.height() );
|
||||
else if( rightSpace >= leftSpace && rightSpace >= upSpace && rightSpace >= downSpace )
|
||||
target = QRect( source.x() + ( 1.2 * source.width() ), source.y(), source.width(), source.height() );
|
||||
else if( upSpace >= leftSpace && upSpace >= rightSpace && upSpace >= downSpace )
|
||||
target = QRect( source.x(), source.y() - ( 1.2 * source.height() ), source.width(), source.height() );
|
||||
if (leftSpace >= rightSpace && leftSpace >= upSpace && leftSpace >= downSpace)
|
||||
target = QRect(source.x() - (1.2 * source.width()), source.y(), source.width(), source.height());
|
||||
else if (rightSpace >= leftSpace && rightSpace >= upSpace && rightSpace >= downSpace)
|
||||
target = QRect(source.x() + (1.2 * source.width()), source.y(), source.width(), source.height());
|
||||
else if (upSpace >= leftSpace && upSpace >= rightSpace && upSpace >= downSpace)
|
||||
target = QRect(source.x(), source.y() - (1.2 * source.height()), source.width(), source.height());
|
||||
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.setDuration( animationTime( totalTime ) );
|
||||
timeLine.setProgress( 0.0f );
|
||||
motionManager.manage( inMove );
|
||||
motionManager.manage( notMoving );
|
||||
distance = sqrt( ( ( source.x()-target.x() ) * ( source.x()-target.x() ) ) + ( ( source.y()-target.y() ) * ( source.y()-target.y() ) ) );
|
||||
effects->setElevatedWindow( notMoving, true );
|
||||
timeLine.setCurveShape(TimeLine::LinearCurve);
|
||||
timeLine.setDuration(animationTime(totalTime));
|
||||
timeLine.setProgress(0.0f);
|
||||
motionManager.manage(inMove);
|
||||
motionManager.manage(notMoving);
|
||||
distance = sqrt(((source.x() - target.x()) * (source.x() - target.x())) + ((source.y() - target.y()) * (source.y() - target.y())));
|
||||
effects->setElevatedWindow(notMoving, true);
|
||||
direction = wasD = true;
|
||||
|
||||
QRect moving = calculateNextMove();
|
||||
motionManager.moveWindow( inMove, moving );
|
||||
}
|
||||
motionManager.moveWindow(inMove, moving);
|
||||
}
|
||||
|
||||
void SlideTabsEffect::clientGroupItemAdded( EffectWindow* from, EffectWindow* to )
|
||||
{
|
||||
if( !grouping || from->desktop() != to->desktop() || from->isMinimized() || to->isMinimized() )
|
||||
void SlideTabsEffect::clientGroupItemAdded(EffectWindow* from, EffectWindow* to)
|
||||
{
|
||||
if (!grouping || from->desktop() != to->desktop() || from->isMinimized() || to->isMinimized())
|
||||
return;
|
||||
timeLine.setCurveShape( TimeLine::LinearCurve );
|
||||
timeLine.setDuration( animationTime( totalTime ) );
|
||||
timeLine.setProgress( 0.0f );
|
||||
timeLine.setCurveShape(TimeLine::LinearCurve);
|
||||
timeLine.setDuration(animationTime(totalTime));
|
||||
timeLine.setProgress(0.0f);
|
||||
inMove = from;
|
||||
notMoving = to;
|
||||
source = inMove->geometry();
|
||||
target = notMoving->geometry();
|
||||
distance = sqrt( ( ( source.x()-target.x() ) * ( source.x()-target.x() ) ) + ( ( source.y()-target.y() ) * ( source.y()-target.y() ) ) );
|
||||
motionManager.manage( inMove );
|
||||
motionManager.manage( notMoving );
|
||||
distance = sqrt(((source.x() - target.x()) * (source.x() - target.x())) + ((source.y() - target.y()) * (source.y() - target.y())));
|
||||
motionManager.manage(inMove);
|
||||
motionManager.manage(notMoving);
|
||||
QRect moving = calculateNextMove();
|
||||
motionManager.moveWindow( inMove, moving );
|
||||
effects->setElevatedWindow( notMoving, true );
|
||||
motionManager.moveWindow(inMove, moving);
|
||||
effects->setElevatedWindow(notMoving, true);
|
||||
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;
|
||||
k = direction? (2.0*timeLine.progress()):(wasD?((timeLine.progress()-0.5)*2):timeLine.progress());
|
||||
dx = fabs( a.x() - b.x() );
|
||||
dy = fabs( a.y() - b.y() );
|
||||
y = k*dy;
|
||||
x = k*dx;
|
||||
if( a.x() > b.x() )
|
||||
k = direction ? (2.0 * timeLine.progress()) : (wasD ? ((timeLine.progress() - 0.5) * 2) : timeLine.progress());
|
||||
dx = fabs(a.x() - b.x());
|
||||
dy = fabs(a.y() - b.y());
|
||||
y = k * dy;
|
||||
x = k * dx;
|
||||
if (a.x() > b.x())
|
||||
x = -x;
|
||||
if( a.y() > b.y() )
|
||||
if (a.y() > b.y())
|
||||
y = -y;
|
||||
return QPoint( a.x() + x, a.y() + y );
|
||||
}
|
||||
return QPoint(a.x() + x, a.y() + y);
|
||||
}
|
||||
|
||||
QRect SlideTabsEffect::calculateNextMove()
|
||||
{
|
||||
{
|
||||
QPoint topLeft, bottomRight;
|
||||
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() ) );
|
||||
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() );
|
||||
}
|
||||
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));
|
||||
return QRect(topLeft.x(), topLeft.y(), bottomRight.x() - topLeft.x(), bottomRight.y() - topLeft.y());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,29 +27,29 @@ namespace KWin
|
|||
{
|
||||
|
||||
class SlideTabsEffect : public Effect
|
||||
{
|
||||
public:
|
||||
SlideTabsEffect();
|
||||
virtual void reconfigure( ReconfigureFlags );
|
||||
virtual void prePaintWindow( EffectWindow *w, WindowPrePaintData &data, int time );
|
||||
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data );
|
||||
virtual void postPaintWindow( EffectWindow* w );
|
||||
virtual void prePaintScreen( ScreenPrePaintData &data, int time );
|
||||
virtual void postPaintScreen();
|
||||
virtual void clientGroupItemSwitched( EffectWindow* from, EffectWindow* to );
|
||||
virtual void clientGroupItemAdded( EffectWindow* from, EffectWindow* to );
|
||||
{
|
||||
public:
|
||||
SlideTabsEffect();
|
||||
virtual void reconfigure(ReconfigureFlags);
|
||||
virtual void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time);
|
||||
virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
|
||||
virtual void postPaintWindow(EffectWindow* w);
|
||||
virtual void prePaintScreen(ScreenPrePaintData &data, int time);
|
||||
virtual void postPaintScreen();
|
||||
virtual void clientGroupItemSwitched(EffectWindow* from, EffectWindow* to);
|
||||
virtual void clientGroupItemAdded(EffectWindow* from, EffectWindow* to);
|
||||
|
||||
private:
|
||||
QRect calculateNextMove();
|
||||
QPoint calculatePointTarget( const QPoint &a, const QPoint &b );
|
||||
WindowMotionManager motionManager;
|
||||
EffectWindow* inMove;
|
||||
EffectWindow* notMoving;
|
||||
TimeLine timeLine;
|
||||
QRect target, source;
|
||||
bool direction, wasD, grouping, switching;
|
||||
int totalTime, distance;
|
||||
};
|
||||
private:
|
||||
QRect calculateNextMove();
|
||||
QPoint calculatePointTarget(const QPoint &a, const QPoint &b);
|
||||
WindowMotionManager motionManager;
|
||||
EffectWindow* inMove;
|
||||
EffectWindow* notMoving;
|
||||
TimeLine timeLine;
|
||||
QRect target, source;
|
||||
bool direction, wasD, grouping, switching;
|
||||
int totalTime, distance;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -32,63 +32,63 @@ namespace KWin
|
|||
|
||||
KWIN_EFFECT_CONFIG_FACTORY
|
||||
|
||||
SlideTabsEffectConfigForm::SlideTabsEffectConfigForm( QWidget* parent ) : QWidget( parent )
|
||||
{
|
||||
setupUi( this );
|
||||
}
|
||||
SlideTabsEffectConfigForm::SlideTabsEffectConfigForm(QWidget* parent) : QWidget(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
}
|
||||
|
||||
SlideTabsEffectConfig::SlideTabsEffectConfig(QWidget* parent, const QVariantList& args)
|
||||
: KCModule( EffectFactory::componentData(), parent, args )
|
||||
{
|
||||
m_ui = new SlideTabsEffectConfigForm( this );
|
||||
: KCModule(EffectFactory::componentData(), parent, args)
|
||||
{
|
||||
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->switching, SIGNAL( toggled( bool )), this, SLOT( changed() ) );
|
||||
connect( m_ui->duration, SIGNAL( valueChanged( int ) ), 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->duration, SIGNAL(valueChanged(int)), this, SLOT(changed()));
|
||||
|
||||
load();
|
||||
}
|
||||
}
|
||||
|
||||
void SlideTabsEffectConfig::save()
|
||||
{
|
||||
KConfigGroup conf = EffectsHandler::effectConfig( "SlideTabs" );
|
||||
{
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("SlideTabs");
|
||||
|
||||
conf.writeEntry( "SlideGrouping", m_ui->grouping->isChecked() );
|
||||
conf.writeEntry( "SlideSwitching", m_ui->switching->isChecked() );
|
||||
conf.writeEntry( "SlideDuration", m_ui->duration->value() );
|
||||
conf.writeEntry("SlideGrouping", m_ui->grouping->isChecked());
|
||||
conf.writeEntry("SlideSwitching", m_ui->switching->isChecked());
|
||||
conf.writeEntry("SlideDuration", m_ui->duration->value());
|
||||
|
||||
conf.sync();
|
||||
|
||||
KCModule::save();
|
||||
emit changed( false );
|
||||
EffectsHandler::sendReloadMessage( "slidetabs" );
|
||||
}
|
||||
emit changed(false);
|
||||
EffectsHandler::sendReloadMessage("slidetabs");
|
||||
}
|
||||
|
||||
void SlideTabsEffectConfig::load()
|
||||
{
|
||||
{
|
||||
KCModule::load();
|
||||
KConfigGroup conf = EffectsHandler::effectConfig( "SlideTabs" );
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("SlideTabs");
|
||||
|
||||
bool switching = conf.readEntry( "SlideSwitching", true );
|
||||
bool grouping = conf.readEntry( "SlideGrouping", true );
|
||||
int duration = conf.readEntry("SlideDuration", 500 );
|
||||
m_ui->switching->setChecked( switching );
|
||||
m_ui->grouping->setChecked( grouping );
|
||||
m_ui->duration->setValue( duration );
|
||||
emit changed( false );
|
||||
}
|
||||
bool switching = conf.readEntry("SlideSwitching", true);
|
||||
bool grouping = conf.readEntry("SlideGrouping", true);
|
||||
int duration = conf.readEntry("SlideDuration", 500);
|
||||
m_ui->switching->setChecked(switching);
|
||||
m_ui->grouping->setChecked(grouping);
|
||||
m_ui->duration->setValue(duration);
|
||||
emit changed(false);
|
||||
}
|
||||
|
||||
void SlideTabsEffectConfig::defaults()
|
||||
{
|
||||
m_ui->grouping->setChecked( true );
|
||||
m_ui->switching->setChecked( true );
|
||||
m_ui->duration->setValue( 500 );
|
||||
emit changed( true );
|
||||
}
|
||||
{
|
||||
m_ui->grouping->setChecked(true);
|
||||
m_ui->switching->setChecked(true);
|
||||
m_ui->duration->setValue(500);
|
||||
emit changed(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,24 +29,24 @@ namespace KWin
|
|||
{
|
||||
|
||||
class SlideTabsEffectConfigForm : public QWidget, public Ui::SlideTabsEffectConfigForm
|
||||
{
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SlideTabsEffectConfigForm( QWidget* parent );
|
||||
};
|
||||
public:
|
||||
explicit SlideTabsEffectConfigForm(QWidget* parent);
|
||||
};
|
||||
|
||||
class SlideTabsEffectConfig : public KCModule
|
||||
{
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SlideTabsEffectConfig( QWidget* parent = 0, const QVariantList& args = QVariantList() );
|
||||
public slots:
|
||||
virtual void save();
|
||||
virtual void load();
|
||||
virtual void defaults();
|
||||
private:
|
||||
SlideTabsEffectConfigForm* m_ui;
|
||||
};
|
||||
public:
|
||||
explicit SlideTabsEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
|
||||
public slots:
|
||||
virtual void save();
|
||||
virtual void load();
|
||||
virtual void defaults();
|
||||
private:
|
||||
SlideTabsEffectConfigForm* m_ui;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -24,134 +24,123 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
KWIN_EFFECT( swiveltabs, SwivelTabsEffect )
|
||||
KWIN_EFFECT_SUPPORTED( swiveltabs, SwivelTabsEffect::supported() )
|
||||
KWIN_EFFECT(swiveltabs, SwivelTabsEffect)
|
||||
KWIN_EFFECT_SUPPORTED(swiveltabs, SwivelTabsEffect::supported())
|
||||
|
||||
SwivelTabsEffect::SwivelTabsEffect()
|
||||
{
|
||||
{
|
||||
isActive = false;
|
||||
PI = 2.0 * acos( 0.0 );
|
||||
reconfigure( ReconfigureAll );
|
||||
}
|
||||
PI = 2.0 * acos(0.0);
|
||||
reconfigure(ReconfigureAll);
|
||||
}
|
||||
|
||||
bool SwivelTabsEffect::supported()
|
||||
{
|
||||
{
|
||||
return effects->compositingType() == OpenGLCompositing;
|
||||
}
|
||||
}
|
||||
|
||||
void SwivelTabsEffect::reconfigure( ReconfigureFlags )
|
||||
{
|
||||
void SwivelTabsEffect::reconfigure(ReconfigureFlags)
|
||||
{
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("SwivelTabs");
|
||||
vertical = conf.readEntry("SwivelVertical", true );
|
||||
horizontal = conf.readEntry("SwivelHorizontal", true );
|
||||
totalTime = conf.readEntry("SwivelDuration", 500 );
|
||||
}
|
||||
vertical = conf.readEntry("SwivelVertical", true);
|
||||
horizontal = conf.readEntry("SwivelHorizontal", true);
|
||||
totalTime = conf.readEntry("SwivelDuration", 500);
|
||||
}
|
||||
|
||||
void SwivelTabsEffect::prePaintScreen( ScreenPrePaintData& data, int time )
|
||||
{
|
||||
if( isActive )
|
||||
void SwivelTabsEffect::prePaintScreen(ScreenPrePaintData& data, int time)
|
||||
{
|
||||
if (isActive)
|
||||
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 )
|
||||
{
|
||||
if( isActive && ( w == windows.show || w == windows.hide ) )
|
||||
{
|
||||
data.quads = data.quads.makeGrid( 40 );
|
||||
void SwivelTabsEffect::prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time)
|
||||
{
|
||||
if (isActive && (w == windows.show || w == windows.hide)) {
|
||||
data.quads = data.quads.makeGrid(40);
|
||||
data.setTransformed();
|
||||
w->enablePainting( EffectWindow::PAINT_DISABLED );
|
||||
windows.time.addTime( time );
|
||||
}
|
||||
effects->prePaintWindow( w, data, time );
|
||||
w->enablePainting(EffectWindow::PAINT_DISABLED);
|
||||
windows.time.addTime(time);
|
||||
}
|
||||
effects->prePaintWindow(w, data, time);
|
||||
}
|
||||
|
||||
void SwivelTabsEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data )
|
||||
{
|
||||
if( isActive && ( w == windows.show || w == windows.hide ) )
|
||||
{
|
||||
for( int i = 0; i < data.quads.count(); ++i )
|
||||
transformQuad( data.quads[i] );
|
||||
}
|
||||
effects->paintWindow( w, mask, region, data );
|
||||
void SwivelTabsEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
|
||||
{
|
||||
if (isActive && (w == windows.show || w == windows.hide)) {
|
||||
for (int i = 0; i < data.quads.count(); ++i)
|
||||
transformQuad(data.quads[i]);
|
||||
}
|
||||
effects->paintWindow(w, mask, region, data);
|
||||
}
|
||||
|
||||
void SwivelTabsEffect::postPaintWindow( EffectWindow* w )
|
||||
{
|
||||
if( isActive && ( w == windows.show || w == windows.hide ) )
|
||||
void SwivelTabsEffect::postPaintWindow(EffectWindow* w)
|
||||
{
|
||||
if (isActive && (w == windows.show || w == windows.hide))
|
||||
w->addRepaintFull();
|
||||
effects->postPaintWindow( w );
|
||||
}
|
||||
effects->postPaintWindow(w);
|
||||
}
|
||||
|
||||
void SwivelTabsEffect::transformQuad( WindowQuad &quad )
|
||||
{
|
||||
void SwivelTabsEffect::transformQuad(WindowQuad &quad)
|
||||
{
|
||||
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 cx = quad[0].x() + ( width/2 );
|
||||
int cy = quad[0].y() + ( height/2 );
|
||||
if( lastF < 0.5 && F > 0.5 )
|
||||
{
|
||||
effects->setElevatedWindow( windows.hide, false );
|
||||
effects->setElevatedWindow( windows.show, true );
|
||||
}
|
||||
int cx = quad[0].x() + (width / 2);
|
||||
int cy = quad[0].y() + (height / 2);
|
||||
if (lastF < 0.5 && F > 0.5) {
|
||||
effects->setElevatedWindow(windows.hide, false);
|
||||
effects->setElevatedWindow(windows.show, true);
|
||||
}
|
||||
lastF = F;
|
||||
if( F >= 1.0 )
|
||||
{
|
||||
if (F >= 1.0) {
|
||||
isActive = false;
|
||||
effects->setElevatedWindow( windows.hide, false );
|
||||
effects->setElevatedWindow( windows.show, false );
|
||||
effects->setElevatedWindow(windows.hide, 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( 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( 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 ) );
|
||||
}
|
||||
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;
|
||||
if( horizontal )
|
||||
{
|
||||
quad[0].setX( cx - ( width * F ) );
|
||||
quad[3].setX( cx - ( width * F ) );
|
||||
quad[1].setX( cx + ( width * F ) );
|
||||
quad[2].setX( cx + ( width * F ) );
|
||||
}
|
||||
if( vertical )
|
||||
{
|
||||
quad[0].setY( cy - ( height * F ) );
|
||||
quad[3].setY( cy + ( height * F ) );
|
||||
quad[1].setY( cy - ( height * F ) );
|
||||
quad[2].setY( cy + ( height * F ) );
|
||||
}
|
||||
if (horizontal) {
|
||||
quad[0].setX(cx - (width * F));
|
||||
quad[3].setX(cx - (width * F));
|
||||
quad[1].setX(cx + (width * F));
|
||||
quad[2].setX(cx + (width * F));
|
||||
}
|
||||
if (vertical) {
|
||||
quad[0].setY(cy - (height * F));
|
||||
quad[3].setY(cy + (height * F));
|
||||
quad[1].setY(cy - (height * F));
|
||||
quad[2].setY(cy + (height * F));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SwivelTabsEffect::clientGroupItemSwitched( EffectWindow* from, EffectWindow* to )
|
||||
{
|
||||
if( isActive || from->isMinimized() )
|
||||
void SwivelTabsEffect::clientGroupItemSwitched(EffectWindow* from, EffectWindow* to)
|
||||
{
|
||||
if (isActive || from->isMinimized())
|
||||
return;
|
||||
windows.show = to;
|
||||
windows.hide = from;
|
||||
windows.time.setCurveShape( TimeLine::LinearCurve );
|
||||
windows.time.setDuration( animationTime( totalTime ) );
|
||||
windows.time.setProgress( 0.0f );
|
||||
windows.time.setCurveShape(TimeLine::LinearCurve);
|
||||
windows.time.setDuration(animationTime(totalTime));
|
||||
windows.time.setProgress(0.0f);
|
||||
lastF = 0.0;
|
||||
isActive = true;
|
||||
effects->setElevatedWindow( to, false );
|
||||
effects->setElevatedWindow( from, true );
|
||||
}
|
||||
effects->setElevatedWindow(to, false);
|
||||
effects->setElevatedWindow(from, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,35 +27,34 @@ namespace KWin
|
|||
{
|
||||
|
||||
class SwivelTabsEffect : public Effect
|
||||
{
|
||||
public:
|
||||
SwivelTabsEffect();
|
||||
virtual void reconfigure( ReconfigureFlags );
|
||||
virtual void prePaintScreen( ScreenPrePaintData& 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 postPaintWindow( EffectWindow* w );
|
||||
virtual void clientGroupItemSwitched( EffectWindow* from, EffectWindow* to );
|
||||
static bool supported();
|
||||
private:
|
||||
struct swivel
|
||||
{
|
||||
EffectWindow* hide;
|
||||
EffectWindow* show;
|
||||
TimeLine time;
|
||||
// The points of the transformed window
|
||||
QPoint topLeft, topRight, bottomLeft, bottomRight;
|
||||
// The size of the transformed window
|
||||
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 );
|
||||
{
|
||||
public:
|
||||
SwivelTabsEffect();
|
||||
virtual void reconfigure(ReconfigureFlags);
|
||||
virtual void prePaintScreen(ScreenPrePaintData& 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 postPaintWindow(EffectWindow* w);
|
||||
virtual void clientGroupItemSwitched(EffectWindow* from, EffectWindow* to);
|
||||
static bool supported();
|
||||
private:
|
||||
struct swivel {
|
||||
EffectWindow* hide;
|
||||
EffectWindow* show;
|
||||
TimeLine time;
|
||||
// The points of the transformed window
|
||||
QPoint topLeft, topRight, bottomLeft, bottomRight;
|
||||
// The size of the transformed window
|
||||
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);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,63 +29,63 @@ namespace KWin
|
|||
|
||||
KWIN_EFFECT_CONFIG_FACTORY
|
||||
|
||||
SwivelTabsEffectConfigForm::SwivelTabsEffectConfigForm( QWidget* parent ) : QWidget( parent )
|
||||
{
|
||||
setupUi( this );
|
||||
}
|
||||
SwivelTabsEffectConfigForm::SwivelTabsEffectConfigForm(QWidget* parent) : QWidget(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
}
|
||||
|
||||
SwivelTabsEffectConfig::SwivelTabsEffectConfig(QWidget* parent, const QVariantList& args)
|
||||
: KCModule( EffectFactory::componentData(), parent, args )
|
||||
{
|
||||
m_ui = new SwivelTabsEffectConfigForm( this );
|
||||
QVBoxLayout* layout = new QVBoxLayout( this );
|
||||
layout->addWidget( m_ui );
|
||||
connect( m_ui->vertical, 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() ) );
|
||||
: KCModule(EffectFactory::componentData(), parent, args)
|
||||
{
|
||||
m_ui = new SwivelTabsEffectConfigForm(this);
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
layout->addWidget(m_ui);
|
||||
connect(m_ui->vertical, 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()));
|
||||
load();
|
||||
}
|
||||
}
|
||||
|
||||
SwivelTabsEffectConfig::~SwivelTabsEffectConfig()
|
||||
{
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
}
|
||||
|
||||
void SwivelTabsEffectConfig::save()
|
||||
{
|
||||
KConfigGroup conf = EffectsHandler::effectConfig( "SwivelTabs" );
|
||||
{
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("SwivelTabs");
|
||||
|
||||
conf.writeEntry( "SwivelVertical", m_ui->vertical->isChecked() );
|
||||
conf.writeEntry( "SwivelHorizontal", m_ui->horizontal->isChecked() );
|
||||
conf.writeEntry( "SwivelDuration", m_ui->duration->value() );
|
||||
conf.writeEntry("SwivelVertical", m_ui->vertical->isChecked());
|
||||
conf.writeEntry("SwivelHorizontal", m_ui->horizontal->isChecked());
|
||||
conf.writeEntry("SwivelDuration", m_ui->duration->value());
|
||||
|
||||
conf.sync();
|
||||
|
||||
KCModule::save();
|
||||
emit changed( false );
|
||||
EffectsHandler::sendReloadMessage( "swiveltabs" );
|
||||
}
|
||||
emit changed(false);
|
||||
EffectsHandler::sendReloadMessage("swiveltabs");
|
||||
}
|
||||
|
||||
void SwivelTabsEffectConfig::load()
|
||||
{
|
||||
{
|
||||
KCModule::load();
|
||||
KConfigGroup conf = EffectsHandler::effectConfig( "SwivelTabs" );
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("SwivelTabs");
|
||||
|
||||
bool vertical = conf.readEntry( "SwivelVertical", true );
|
||||
bool horizontal = conf.readEntry( "SwivelHorizontal", true );
|
||||
int duration = conf.readEntry("SwivelDuration", 500 );
|
||||
m_ui->vertical->setChecked( vertical );
|
||||
m_ui->horizontal->setChecked( horizontal );
|
||||
m_ui->duration->setValue( duration );
|
||||
emit changed( false );
|
||||
}
|
||||
bool vertical = conf.readEntry("SwivelVertical", true);
|
||||
bool horizontal = conf.readEntry("SwivelHorizontal", true);
|
||||
int duration = conf.readEntry("SwivelDuration", 500);
|
||||
m_ui->vertical->setChecked(vertical);
|
||||
m_ui->horizontal->setChecked(horizontal);
|
||||
m_ui->duration->setValue(duration);
|
||||
emit changed(false);
|
||||
}
|
||||
|
||||
void SwivelTabsEffectConfig::defaults()
|
||||
{
|
||||
m_ui->vertical->setChecked( true );
|
||||
m_ui->horizontal->setChecked( true );
|
||||
m_ui->duration->setValue( 500 );
|
||||
emit changed( true );
|
||||
}
|
||||
{
|
||||
m_ui->vertical->setChecked(true);
|
||||
m_ui->horizontal->setChecked(true);
|
||||
m_ui->duration->setValue(500);
|
||||
emit changed(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,25 +28,25 @@ namespace KWin
|
|||
{
|
||||
|
||||
class SwivelTabsEffectConfigForm : public QWidget, public Ui::SwivelTabsEffectConfigForm
|
||||
{
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SwivelTabsEffectConfigForm( QWidget* parent );
|
||||
};
|
||||
public:
|
||||
explicit SwivelTabsEffectConfigForm(QWidget* parent);
|
||||
};
|
||||
|
||||
class SwivelTabsEffectConfig : public KCModule
|
||||
{
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SwivelTabsEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
|
||||
~SwivelTabsEffectConfig();
|
||||
public slots:
|
||||
virtual void save();
|
||||
virtual void load();
|
||||
virtual void defaults();
|
||||
private:
|
||||
SwivelTabsEffectConfigForm *m_ui;
|
||||
};
|
||||
public:
|
||||
explicit SwivelTabsEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
|
||||
~SwivelTabsEffectConfig();
|
||||
public slots:
|
||||
virtual void save();
|
||||
virtual void load();
|
||||
virtual void defaults();
|
||||
private:
|
||||
SwivelTabsEffectConfigForm *m_ui;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -27,12 +27,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
KWIN_EFFECT( test_fbo, TestFBOEffect )
|
||||
KWIN_EFFECT_SUPPORTED( test_fbo, TestFBOEffect::supported() )
|
||||
KWIN_EFFECT(test_fbo, TestFBOEffect)
|
||||
KWIN_EFFECT_SUPPORTED(test_fbo, TestFBOEffect::supported())
|
||||
|
||||
|
||||
TestFBOEffect::TestFBOEffect() : Effect()
|
||||
{
|
||||
{
|
||||
mRot = 0.0f;
|
||||
|
||||
// Create texture and render target
|
||||
|
@ -42,66 +42,64 @@ TestFBOEffect::TestFBOEffect() : Effect()
|
|||
mRenderTarget = new GLRenderTarget(mTexture);
|
||||
|
||||
mValid = mRenderTarget->valid();
|
||||
}
|
||||
}
|
||||
|
||||
TestFBOEffect::~TestFBOEffect()
|
||||
{
|
||||
{
|
||||
delete mTexture;
|
||||
delete mRenderTarget;
|
||||
}
|
||||
}
|
||||
|
||||
bool TestFBOEffect::supported()
|
||||
{
|
||||
{
|
||||
return GLRenderTarget::supported() && GLTexture::NPOTTextureSupported() &&
|
||||
(effects->compositingType() == OpenGLCompositing);
|
||||
}
|
||||
(effects->compositingType() == OpenGLCompositing);
|
||||
}
|
||||
|
||||
|
||||
void TestFBOEffect::prePaintScreen( ScreenPrePaintData& data, int time )
|
||||
{
|
||||
if(mValid)
|
||||
{
|
||||
void TestFBOEffect::prePaintScreen(ScreenPrePaintData& data, int time)
|
||||
{
|
||||
if (mValid) {
|
||||
data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
|
||||
// Start rendering to texture
|
||||
effects->pushRenderTarget(mRenderTarget);
|
||||
}
|
||||
|
||||
effects->prePaintScreen(data, time);
|
||||
}
|
||||
|
||||
effects->prePaintScreen(data, time);
|
||||
}
|
||||
|
||||
void TestFBOEffect::postPaintScreen()
|
||||
{
|
||||
{
|
||||
// Call the next effect.
|
||||
effects->postPaintScreen();
|
||||
|
||||
if(mValid)
|
||||
{
|
||||
if (mValid) {
|
||||
// Disable render texture
|
||||
assert( effects->popRenderTarget() == mRenderTarget );
|
||||
assert(effects->popRenderTarget() == mRenderTarget);
|
||||
mTexture->bind();
|
||||
|
||||
// Render fullscreen quad with screen contents
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0.0, 0.0); glVertex2f(0.0, displayHeight());
|
||||
glTexCoord2f(1.0, 0.0); glVertex2f(displayWidth(), displayHeight());
|
||||
glTexCoord2f(1.0, 1.0); glVertex2f(displayWidth(), 0.0);
|
||||
glTexCoord2f(0.0, 1.0); glVertex2f(0.0, 0.0);
|
||||
glTexCoord2f(0.0, 0.0); glVertex2f(0.0, displayHeight());
|
||||
glTexCoord2f(1.0, 0.0); glVertex2f(displayWidth(), displayHeight());
|
||||
glTexCoord2f(1.0, 1.0); glVertex2f(displayWidth(), 0.0);
|
||||
glTexCoord2f(0.0, 1.0); glVertex2f(0.0, 0.0);
|
||||
glEnd();
|
||||
|
||||
// Render rotated screen thumbnail
|
||||
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);
|
||||
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);
|
||||
glColor4f(1.0, 1.0, 1.0, 0.8);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0.0, 0.0); glVertex2f(0.0, displayHeight());
|
||||
glTexCoord2f(1.0, 0.0); glVertex2f(displayWidth(), displayHeight());
|
||||
glTexCoord2f(1.0, 1.0); glVertex2f(displayWidth(), 0.0);
|
||||
glTexCoord2f(0.0, 1.0); glVertex2f(0.0, 0.0);
|
||||
glTexCoord2f(0.0, 0.0); glVertex2f(0.0, displayHeight());
|
||||
glTexCoord2f(1.0, 0.0); glVertex2f(displayWidth(), displayHeight());
|
||||
glTexCoord2f(1.0, 1.0); glVertex2f(displayWidth(), 0.0);
|
||||
glTexCoord2f(0.0, 1.0); glVertex2f(0.0, 0.0);
|
||||
glEnd();
|
||||
glColor4f(1.0, 1.0, 1.0, 1.0);
|
||||
glDisable(GL_BLEND);
|
||||
|
@ -113,10 +111,10 @@ void TestFBOEffect::postPaintScreen()
|
|||
|
||||
// Make sure the animation continues
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -36,23 +36,23 @@ class GLTexture;
|
|||
* on top of the usual scene.
|
||||
**/
|
||||
class TestFBOEffect : public Effect
|
||||
{
|
||||
public:
|
||||
TestFBOEffect();
|
||||
~TestFBOEffect();
|
||||
{
|
||||
public:
|
||||
TestFBOEffect();
|
||||
~TestFBOEffect();
|
||||
|
||||
virtual void prePaintScreen( ScreenPrePaintData& data, int time );
|
||||
virtual void postPaintScreen();
|
||||
virtual void prePaintScreen(ScreenPrePaintData& data, int time);
|
||||
virtual void postPaintScreen();
|
||||
|
||||
static bool supported();
|
||||
static bool supported();
|
||||
|
||||
private:
|
||||
GLTexture* mTexture;
|
||||
GLRenderTarget* mRenderTarget;
|
||||
bool mValid;
|
||||
private:
|
||||
GLTexture* mTexture;
|
||||
GLRenderTarget* mRenderTarget;
|
||||
bool mValid;
|
||||
|
||||
double mRot;
|
||||
};
|
||||
double mRot;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -29,46 +29,44 @@ License. See the file "COPYING" for the exact licensing terms.
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
KWIN_EFFECT( test_input, TestInputEffect )
|
||||
KWIN_EFFECT(test_input, 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()
|
||||
{
|
||||
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;
|
||||
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;
|
||||
effects->paintScreen( mask, region, data );
|
||||
}
|
||||
effects->paintScreen(mask, region, data);
|
||||
}
|
||||
|
||||
void TestInputEffect::windowInputMouseEvent( Window w, QEvent* e )
|
||||
{
|
||||
assert( w == input );
|
||||
if( e->type() != QEvent::MouseButtonPress )
|
||||
void TestInputEffect::windowInputMouseEvent(Window w, QEvent* e)
|
||||
{
|
||||
assert(w == input);
|
||||
if (e->type() != QEvent::MouseButtonPress)
|
||||
return;
|
||||
QPoint pos = static_cast< QMouseEvent* >( e )->pos();
|
||||
pos -= QPoint( 0, 100 ); // adjust for transformation
|
||||
foreach( EffectWindow* c, effects->stackingOrder())
|
||||
{
|
||||
if( /* TODO c->isShown( true ) && */c->isOnCurrentDesktop()
|
||||
&& c->geometry().contains( pos ))
|
||||
{
|
||||
effects->activateWindow( c );
|
||||
QPoint pos = static_cast< QMouseEvent* >(e)->pos();
|
||||
pos -= QPoint(0, 100); // adjust for transformation
|
||||
foreach (EffectWindow * c, effects->stackingOrder()) {
|
||||
if (/* TODO c->isShown( true ) && */c->isOnCurrentDesktop()
|
||||
&& c->geometry().contains(pos)) {
|
||||
effects->activateWindow(c);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -24,16 +24,16 @@ namespace KWin
|
|||
|
||||
class TestInputEffect
|
||||
: public Effect
|
||||
{
|
||||
public:
|
||||
TestInputEffect();
|
||||
virtual ~TestInputEffect();
|
||||
virtual void prePaintScreen( ScreenPrePaintData& data, int time );
|
||||
virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data );
|
||||
virtual void windowInputMouseEvent( Window w, QEvent* e );
|
||||
private:
|
||||
Window input;
|
||||
};
|
||||
{
|
||||
public:
|
||||
TestInputEffect();
|
||||
virtual ~TestInputEffect();
|
||||
virtual void prePaintScreen(ScreenPrePaintData& data, int time);
|
||||
virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data);
|
||||
virtual void windowInputMouseEvent(Window w, QEvent* e);
|
||||
private:
|
||||
Window input;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -20,58 +20,56 @@ License. See the file "COPYING" for the exact licensing terms.
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
KWIN_EFFECT( test_thumbnail, TestThumbnailEffect )
|
||||
KWIN_EFFECT(test_thumbnail, TestThumbnailEffect)
|
||||
|
||||
TestThumbnailEffect::TestThumbnailEffect()
|
||||
: active_window( NULL )
|
||||
{
|
||||
}
|
||||
: active_window(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
void TestThumbnailEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
|
||||
{
|
||||
effects->paintScreen( mask, region, data );
|
||||
if( active_window != NULL && region.contains( thumbnailRect()))
|
||||
{
|
||||
WindowPaintData data( active_window );
|
||||
void TestThumbnailEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
|
||||
{
|
||||
effects->paintScreen(mask, region, data);
|
||||
if (active_window != NULL && region.contains(thumbnailRect())) {
|
||||
WindowPaintData data(active_window);
|
||||
QRect region;
|
||||
setPositionTransformations( data, region, active_window, thumbnailRect(), Qt::KeepAspectRatio );
|
||||
effects->drawWindow( active_window,
|
||||
PAINT_WINDOW_OPAQUE | PAINT_WINDOW_TRANSLUCENT | PAINT_WINDOW_TRANSFORMED,
|
||||
region, data );
|
||||
}
|
||||
setPositionTransformations(data, region, active_window, thumbnailRect(), Qt::KeepAspectRatio);
|
||||
effects->drawWindow(active_window,
|
||||
PAINT_WINDOW_OPAQUE | PAINT_WINDOW_TRANSLUCENT | PAINT_WINDOW_TRANSFORMED,
|
||||
region, data);
|
||||
}
|
||||
}
|
||||
|
||||
void TestThumbnailEffect::windowActivated( EffectWindow* act )
|
||||
{
|
||||
void TestThumbnailEffect::windowActivated(EffectWindow* act)
|
||||
{
|
||||
active_window = act;
|
||||
effects->addRepaint( thumbnailRect());
|
||||
}
|
||||
effects->addRepaint(thumbnailRect());
|
||||
}
|
||||
|
||||
void TestThumbnailEffect::windowDamaged( EffectWindow* w, const QRect& )
|
||||
{
|
||||
if( w == active_window )
|
||||
effects->addRepaint( thumbnailRect());
|
||||
void TestThumbnailEffect::windowDamaged(EffectWindow* w, const QRect&)
|
||||
{
|
||||
if (w == active_window)
|
||||
effects->addRepaint(thumbnailRect());
|
||||
// TODO maybe just the relevant part of the area should be repainted?
|
||||
}
|
||||
}
|
||||
|
||||
void TestThumbnailEffect::windowGeometryShapeChanged( EffectWindow* w, const QRect& old )
|
||||
{
|
||||
if( w == active_window && w->size() != old.size())
|
||||
effects->addRepaint( thumbnailRect());
|
||||
}
|
||||
void TestThumbnailEffect::windowGeometryShapeChanged(EffectWindow* w, const QRect& old)
|
||||
{
|
||||
if (w == active_window && w->size() != old.size())
|
||||
effects->addRepaint(thumbnailRect());
|
||||
}
|
||||
|
||||
void TestThumbnailEffect::windowClosed( EffectWindow* w )
|
||||
{
|
||||
if( w == active_window )
|
||||
{
|
||||
void TestThumbnailEffect::windowClosed(EffectWindow* w)
|
||||
{
|
||||
if (w == active_window) {
|
||||
active_window = NULL;
|
||||
effects->addRepaint( thumbnailRect());
|
||||
}
|
||||
effects->addRepaint(thumbnailRect());
|
||||
}
|
||||
}
|
||||
|
||||
QRect TestThumbnailEffect::thumbnailRect() const
|
||||
{
|
||||
return QRect( displayWidth() - 100, displayHeight() - 100, 100, 100 );
|
||||
}
|
||||
{
|
||||
return QRect(displayWidth() - 100, displayHeight() - 100, 100, 100);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -24,18 +24,18 @@ namespace KWin
|
|||
|
||||
class TestThumbnailEffect
|
||||
: public Effect
|
||||
{
|
||||
public:
|
||||
TestThumbnailEffect();
|
||||
virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data );
|
||||
virtual void windowActivated( EffectWindow* w );
|
||||
virtual void windowDamaged( EffectWindow* w, const QRect& damage );
|
||||
virtual void windowGeometryShapeChanged( EffectWindow* w, const QRect& old );
|
||||
virtual void windowClosed( EffectWindow* w );
|
||||
private:
|
||||
QRect thumbnailRect() const;
|
||||
EffectWindow* active_window;
|
||||
};
|
||||
{
|
||||
public:
|
||||
TestThumbnailEffect();
|
||||
virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data);
|
||||
virtual void windowActivated(EffectWindow* w);
|
||||
virtual void windowDamaged(EffectWindow* w, const QRect& damage);
|
||||
virtual void windowGeometryShapeChanged(EffectWindow* w, const QRect& old);
|
||||
virtual void windowClosed(EffectWindow* w);
|
||||
private:
|
||||
QRect thumbnailRect() const;
|
||||
EffectWindow* active_window;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -59,59 +59,56 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
KWIN_EFFECT( videorecord, VideoRecordEffect )
|
||||
KWIN_EFFECT(videorecord, VideoRecordEffect)
|
||||
|
||||
VideoRecordEffect::VideoRecordEffect()
|
||||
: client( NULL )
|
||||
{
|
||||
KActionCollection* actionCollection = new KActionCollection( this );
|
||||
KAction* a = static_cast< KAction* >( actionCollection->addAction( "VideoRecord" ));
|
||||
a->setText( i18n("Toggle Video Recording" ));
|
||||
a->setGlobalShortcut( KShortcut( Qt::CTRL + Qt::META + Qt::Key_V ));
|
||||
connect( a, SIGNAL( triggered( bool )), this, SLOT( toggleRecording()));
|
||||
area = QRect( 0, 0, displayWidth(), displayHeight());
|
||||
}
|
||||
: client(NULL)
|
||||
{
|
||||
KActionCollection* actionCollection = new KActionCollection(this);
|
||||
KAction* a = static_cast< KAction* >(actionCollection->addAction("VideoRecord"));
|
||||
a->setText(i18n("Toggle Video Recording"));
|
||||
a->setGlobalShortcut(KShortcut(Qt::CTRL + Qt::META + Qt::Key_V));
|
||||
connect(a, SIGNAL(triggered(bool)), this, SLOT(toggleRecording()));
|
||||
area = QRect(0, 0, displayWidth(), displayHeight());
|
||||
}
|
||||
|
||||
VideoRecordEffect::~VideoRecordEffect()
|
||||
{
|
||||
{
|
||||
stopRecording();
|
||||
}
|
||||
}
|
||||
|
||||
void VideoRecordEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
|
||||
{
|
||||
effects->paintScreen( mask, region, data );
|
||||
if( client != NULL )
|
||||
capture_region = ( mask & ( PAINT_WINDOW_TRANSFORMED | PAINT_SCREEN_TRANSFORMED ))
|
||||
? QRect( 0, 0, displayWidth(), displayHeight()) : region;
|
||||
}
|
||||
void VideoRecordEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
|
||||
{
|
||||
effects->paintScreen(mask, region, data);
|
||||
if (client != NULL)
|
||||
capture_region = (mask & (PAINT_WINDOW_TRANSFORMED | PAINT_SCREEN_TRANSFORMED))
|
||||
? QRect(0, 0, displayWidth(), displayHeight()) : region;
|
||||
}
|
||||
|
||||
void VideoRecordEffect::postPaintScreen()
|
||||
{
|
||||
{
|
||||
effects->postPaintScreen();
|
||||
if( client != NULL )
|
||||
{
|
||||
if (client != NULL) {
|
||||
#if 1
|
||||
if( CapturyProcessRegionStart( client ) == CAPTURY_SUCCESS )
|
||||
{
|
||||
capture_region &= QRect( 0, 0, displayWidth(), displayHeight()); // limit to screen
|
||||
foreach( const QRect &r, capture_region.rects())
|
||||
{
|
||||
if (CapturyProcessRegionStart(client) == CAPTURY_SUCCESS) {
|
||||
capture_region &= QRect(0, 0, displayWidth(), displayHeight()); // limit to screen
|
||||
foreach (const QRect & r, capture_region.rects()) {
|
||||
int gly = displayHeight() - r.y() - r.height(); // opengl coords
|
||||
CapturyProcessRegion( client, r.x(), gly, r.width(), r.height());
|
||||
}
|
||||
CapturyProcessRegionCommit( client );
|
||||
CapturyProcessRegion(client, r.x(), gly, r.width(), r.height());
|
||||
}
|
||||
#else
|
||||
CapturyProcessFrame( client );
|
||||
#endif
|
||||
CapturyProcessRegionCommit(client);
|
||||
}
|
||||
#else
|
||||
CapturyProcessFrame(client);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void VideoRecordEffect::startRecording()
|
||||
{
|
||||
if( client != NULL )
|
||||
{
|
||||
if (client != NULL)
|
||||
stopRecording();
|
||||
bzero( &config, sizeof( config ));
|
||||
bzero(&config, sizeof(config));
|
||||
config.x = area.x();
|
||||
config.y = area.y();
|
||||
config.width = area.width();
|
||||
|
@ -122,58 +119,56 @@ void VideoRecordEffect::startRecording()
|
|||
config.deviceHandle = display();
|
||||
config.windowHandle = rootWindow(); // TODO
|
||||
config.cursor = true;
|
||||
client = CapturyOpen( &config );
|
||||
if( client == NULL )
|
||||
{
|
||||
kDebug( 1212 ) << "Video recording init failed";
|
||||
client = CapturyOpen(&config);
|
||||
if (client == NULL) {
|
||||
kDebug(1212) << "Video recording init failed";
|
||||
return;
|
||||
}
|
||||
}
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("VideoRecord");
|
||||
QString videoPath =conf.readEntry( "videopath", KGlobalSettings::documentPath() );
|
||||
QString videoName(videoPath +"/kwin_video1.cps" );
|
||||
while(QFile::exists( videoName )) {
|
||||
autoincFilename( videoName );
|
||||
QString videoPath = conf.readEntry("videopath", KGlobalSettings::documentPath());
|
||||
QString videoName(videoPath + "/kwin_video1.cps");
|
||||
while (QFile::exists(videoName)) {
|
||||
autoincFilename(videoName);
|
||||
}
|
||||
if( CapturySetOutputFileName( client, QFile::encodeName( videoName ).constData() ) != CAPTURY_SUCCESS )
|
||||
{
|
||||
kDebug( 1212 ) << "Video recording file open failed";
|
||||
if (CapturySetOutputFileName(client, QFile::encodeName(videoName).constData()) != CAPTURY_SUCCESS) {
|
||||
kDebug(1212) << "Video recording file open failed";
|
||||
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)
|
||||
{
|
||||
// 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
|
||||
// Does it have a number?
|
||||
int start = numSearch.lastIndexIn( name );
|
||||
if (start != -1) {
|
||||
// It has a number, increment it
|
||||
start = numSearch.pos( 2 ); // we are only interested in the second group
|
||||
QString numAsStr = numSearch.capturedTexts()[ 2 ];
|
||||
QString number = QString::number( numAsStr.toInt() + 1 );
|
||||
number = number.rightJustified( numAsStr.length(), '0' );
|
||||
name.replace( start, number.length(), number );
|
||||
}
|
||||
{
|
||||
// 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
|
||||
// Does it have a number?
|
||||
int start = numSearch.lastIndexIn(name);
|
||||
if (start != -1) {
|
||||
// It has a number, increment it
|
||||
start = numSearch.pos(2); // we are only interested in the second group
|
||||
QString numAsStr = numSearch.capturedTexts()[ 2 ];
|
||||
QString number = QString::number(numAsStr.toInt() + 1);
|
||||
number = number.rightJustified(numAsStr.length(), '0');
|
||||
name.replace(start, number.length(), number);
|
||||
}
|
||||
}
|
||||
void VideoRecordEffect::stopRecording()
|
||||
{
|
||||
if( client == NULL )
|
||||
{
|
||||
if (client == NULL)
|
||||
return;
|
||||
kDebug( 1212 ) << "Video recording stop";
|
||||
CapturyClose( client );
|
||||
kDebug(1212) << "Video recording stop";
|
||||
CapturyClose(client);
|
||||
client = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void VideoRecordEffect::toggleRecording()
|
||||
{
|
||||
if( client == NULL )
|
||||
{
|
||||
if (client == NULL)
|
||||
startRecording();
|
||||
else
|
||||
stopRecording();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -30,24 +30,24 @@ namespace KWin
|
|||
|
||||
class VideoRecordEffect
|
||||
: public QObject, public Effect
|
||||
{
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VideoRecordEffect();
|
||||
virtual ~VideoRecordEffect();
|
||||
virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data );
|
||||
virtual void postPaintScreen();
|
||||
private slots:
|
||||
void toggleRecording();
|
||||
private:
|
||||
void startRecording();
|
||||
void stopRecording();
|
||||
void autoincFilename(QString & url);
|
||||
captury_config_t config;
|
||||
captury_t* client;
|
||||
QRect area;
|
||||
QRegion capture_region;
|
||||
};
|
||||
public:
|
||||
VideoRecordEffect();
|
||||
virtual ~VideoRecordEffect();
|
||||
virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data);
|
||||
virtual void postPaintScreen();
|
||||
private slots:
|
||||
void toggleRecording();
|
||||
private:
|
||||
void startRecording();
|
||||
void stopRecording();
|
||||
void autoincFilename(QString & url);
|
||||
captury_config_t config;
|
||||
captury_t* client;
|
||||
QRect area;
|
||||
QRegion capture_region;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -38,35 +38,35 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
KWIN_EFFECT_CONFIG_FACTORY
|
||||
#endif
|
||||
K_PLUGIN_FACTORY_DEFINITION(EffectFactory,
|
||||
registerPlugin<KWin::VideoRecordEffectConfig>("videorecord");
|
||||
)
|
||||
registerPlugin<KWin::VideoRecordEffectConfig>("videorecord");
|
||||
)
|
||||
K_EXPORT_PLUGIN(EffectFactory("kwin"))
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
VideoRecordEffectConfig::VideoRecordEffectConfig(QWidget* parent, const QVariantList& args) :
|
||||
KCModule(EffectFactory::componentData(), parent, args)
|
||||
{
|
||||
KCModule(EffectFactory::componentData(), parent, args)
|
||||
{
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
QHBoxLayout* hlayout = new QHBoxLayout( this );
|
||||
QLabel *label = new QLabel( i18n( "Path to save video:" ), this );
|
||||
hlayout->addWidget( label );
|
||||
saveVideo = new KUrlRequester( this );
|
||||
saveVideo->setMode( KFile::Directory | KFile::LocalOnly );
|
||||
hlayout->addWidget( saveVideo );
|
||||
layout->addLayout( hlayout );
|
||||
QHBoxLayout* hlayout = new QHBoxLayout(this);
|
||||
QLabel *label = new QLabel(i18n("Path to save video:"), this);
|
||||
hlayout->addWidget(label);
|
||||
saveVideo = new KUrlRequester(this);
|
||||
saveVideo->setMode(KFile::Directory | KFile::LocalOnly);
|
||||
hlayout->addWidget(saveVideo);
|
||||
layout->addLayout(hlayout);
|
||||
|
||||
// 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" ));
|
||||
a->setText( i18n("Toggle Video Recording" ));
|
||||
KAction* a = static_cast<KAction*>(actionCollection->addAction("VideoRecord"));
|
||||
a->setText(i18n("Toggle Video Recording"));
|
||||
a->setProperty("isConfigurationAction", true);
|
||||
a->setGlobalShortcut(KShortcut(Qt::CTRL + Qt::META + Qt::Key_V));
|
||||
|
||||
mShortcutEditor = new KShortcutsEditor(actionCollection, this,
|
||||
KShortcutsEditor::GlobalAction, KShortcutsEditor::LetterShortcutsDisallowed);
|
||||
KShortcutsEditor::GlobalAction, KShortcutsEditor::LetterShortcutsDisallowed);
|
||||
layout->addWidget(mShortcutEditor);
|
||||
|
||||
connect(saveVideo, SIGNAL(textChanged(const QString&)), this, SLOT(changed()));
|
||||
|
@ -75,48 +75,48 @@ VideoRecordEffectConfig::VideoRecordEffectConfig(QWidget* parent, const QVariant
|
|||
layout->addStretch();
|
||||
|
||||
load();
|
||||
}
|
||||
}
|
||||
|
||||
VideoRecordEffectConfig::~VideoRecordEffectConfig()
|
||||
{
|
||||
{
|
||||
// Undo (only) unsaved changes to global key shortcuts
|
||||
mShortcutEditor->undoChanges();
|
||||
}
|
||||
}
|
||||
|
||||
void VideoRecordEffectConfig::load()
|
||||
{
|
||||
{
|
||||
KCModule::load();
|
||||
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("VideoRecord");
|
||||
saveVideo->setPath( conf.readEntry( "videopath", KGlobalSettings::documentPath() ) );
|
||||
saveVideo->setPath(conf.readEntry("videopath", KGlobalSettings::documentPath()));
|
||||
emit changed(false);
|
||||
}
|
||||
}
|
||||
|
||||
void VideoRecordEffectConfig::save()
|
||||
{
|
||||
{
|
||||
KCModule::save();
|
||||
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("VideoRecord");
|
||||
|
||||
if( saveVideo->url().isEmpty() )
|
||||
conf.writeEntry("videopath", KGlobalSettings::documentPath());
|
||||
if (saveVideo->url().isEmpty())
|
||||
conf.writeEntry("videopath", KGlobalSettings::documentPath());
|
||||
else
|
||||
conf.writeEntry("videopath", saveVideo->url().path());
|
||||
conf.writeEntry("videopath", saveVideo->url().path());
|
||||
|
||||
conf.sync();
|
||||
|
||||
mShortcutEditor->save(); // undo() will restore to this state from now on
|
||||
|
||||
emit changed(false);
|
||||
EffectsHandler::sendReloadMessage( "videorecord" );
|
||||
}
|
||||
EffectsHandler::sendReloadMessage("videorecord");
|
||||
}
|
||||
|
||||
void VideoRecordEffectConfig::defaults()
|
||||
{
|
||||
saveVideo->setPath(KGlobalSettings::documentPath() );
|
||||
{
|
||||
saveVideo->setPath(KGlobalSettings::documentPath());
|
||||
mShortcutEditor->allDefault();
|
||||
emit changed(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -30,21 +30,21 @@ namespace KWin
|
|||
{
|
||||
|
||||
class VideoRecordEffectConfig : public KCModule
|
||||
{
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit VideoRecordEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
|
||||
~VideoRecordEffectConfig();
|
||||
public:
|
||||
explicit VideoRecordEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
|
||||
~VideoRecordEffectConfig();
|
||||
|
||||
public slots:
|
||||
virtual void save();
|
||||
virtual void load();
|
||||
virtual void defaults();
|
||||
public slots:
|
||||
virtual void save();
|
||||
virtual void load();
|
||||
virtual void defaults();
|
||||
|
||||
private:
|
||||
KShortcutsEditor* mShortcutEditor;
|
||||
KUrlRequester *saveVideo;
|
||||
};
|
||||
private:
|
||||
KShortcutsEditor* mShortcutEditor;
|
||||
KUrlRequester *saveVideo;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ void BlurEffect::propertyNotify(EffectWindow *w, long atom)
|
|||
bool BlurEffect::supported()
|
||||
{
|
||||
bool supported = GLRenderTarget::supported() && GLTexture::NPOTTextureSupported() &&
|
||||
(GLSLBlurShader::supported() || ARBBlurShader::supported());
|
||||
(GLSLBlurShader::supported() || ARBBlurShader::supported());
|
||||
|
||||
if (supported) {
|
||||
int maxTexSize;
|
||||
|
@ -131,9 +131,9 @@ bool BlurEffect::supported()
|
|||
|
||||
if (supported) {
|
||||
// check the blacklist
|
||||
KSharedConfigPtr config = KSharedConfig::openConfig( "kwinrc" );
|
||||
KConfigGroup blacklist = config->group( "Blacklist" ).group( "Blur" );
|
||||
if (effects->checkDriverBlacklist( blacklist )) {
|
||||
KSharedConfigPtr config = KSharedConfig::openConfig("kwinrc");
|
||||
KConfigGroup blacklist = config->group("Blacklist").group("Blur");
|
||||
if (effects->checkDriverBlacklist(blacklist)) {
|
||||
kDebug() << "Blur effect disabled by driver blacklist";
|
||||
supported = false;
|
||||
}
|
||||
|
@ -152,8 +152,8 @@ QRegion BlurEffect::expand(const QRegion ®ion) const
|
|||
QRegion expanded;
|
||||
|
||||
if (region.rectCount() < 20) {
|
||||
foreach (const QRect &rect, region.rects())
|
||||
expanded += expand(rect);
|
||||
foreach (const QRect & rect, region.rects())
|
||||
expanded += expand(rect);
|
||||
} else
|
||||
expanded += expand(region.boundingRect());
|
||||
|
||||
|
@ -172,7 +172,7 @@ QRegion BlurEffect::blurRegion(const EffectWindow *w) const
|
|||
region = w->shape();
|
||||
region -= w->decorationInnerRect();
|
||||
region |= appRegion.translated(w->contentsRect().topLeft()) &
|
||||
w->contentsRect();
|
||||
w->contentsRect();
|
||||
} else
|
||||
region = appRegion & w->contentsRect();
|
||||
} else {
|
||||
|
@ -197,7 +197,7 @@ void BlurEffect::drawRegion(const QRegion ®ion)
|
|||
vertices.resize(vertexCount);
|
||||
|
||||
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.y());
|
||||
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();
|
||||
|
||||
QRegion shape;
|
||||
const QVariant forceBlur = w->data( WindowForceBlurRole );
|
||||
if ((!effects->activeFullScreenEffect() || (forceBlur.isValid() && forceBlur.toBool() ))
|
||||
const QVariant forceBlur = w->data(WindowForceBlurRole);
|
||||
if ((!effects->activeFullScreenEffect() || (forceBlur.isValid() && forceBlur.toBool()))
|
||||
&& hasAlpha && !w->isDesktop() && !transformed)
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -248,7 +247,7 @@ void BlurEffect::paintEffectFrame(EffectFrame *frame, QRegion region, double opa
|
|||
{
|
||||
const QRect screen(0, 0, displayWidth(), displayHeight());
|
||||
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())) {
|
||||
doBlur(shape, screen, opacity * frameOpacity);
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
|
||||
#ifndef BLUR_H
|
||||
#define BLUR_H
|
||||
#define BLUR_H
|
||||
|
||||
#include <kwineffects.h>
|
||||
#include <kwinglutils.h>
|
||||
|
|
|
@ -68,7 +68,7 @@ void BlurShader::setDirection(Qt::Orientation direction)
|
|||
float BlurShader::gaussian(float x, float sigma) const
|
||||
{
|
||||
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
|
||||
|
@ -380,11 +380,10 @@ void ARBBlurShader::unbind()
|
|||
#ifndef KWIN_HAVE_OPENGLES
|
||||
int boundObject;
|
||||
glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_BINDING_ARB, &boundObject);
|
||||
if( boundObject == program )
|
||||
{
|
||||
if (boundObject == program) {
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 0);
|
||||
glDisable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -418,7 +417,7 @@ void ARBBlurShader::init()
|
|||
|
||||
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++)
|
||||
stream << "PARAM kernel" << i << " = " << kernel[center + i] << ";\n";
|
||||
|
||||
|
@ -442,14 +441,14 @@ void ARBBlurShader::init()
|
|||
for (int i = 1; i < size; i++)
|
||||
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";
|
||||
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 << "MOV result.color, temp0;\n"; // gl_FragColor = temp0
|
||||
stream << "MOV result.color, temp0;\n"; // gl_FragColor = temp0
|
||||
stream << "END\n";
|
||||
stream.flush();
|
||||
|
||||
|
|
|
@ -35,15 +35,21 @@ public:
|
|||
|
||||
static BlurShader *create();
|
||||
|
||||
bool isValid() const { return mValid; }
|
||||
bool isValid() const {
|
||||
return mValid;
|
||||
}
|
||||
|
||||
// Sets the radius in pixels
|
||||
void setRadius(int radius);
|
||||
int radius() const { return mRadius; }
|
||||
int radius() const {
|
||||
return mRadius;
|
||||
}
|
||||
|
||||
// Sets the blur direction
|
||||
void setDirection(Qt::Orientation direction);
|
||||
Qt::Orientation direction() const { return mDirection; }
|
||||
Qt::Orientation direction() const {
|
||||
return mDirection;
|
||||
}
|
||||
|
||||
// Sets the distance between two pixels
|
||||
virtual void setPixelDistance(float val) = 0;
|
||||
|
@ -55,7 +61,9 @@ public:
|
|||
protected:
|
||||
float gaussian(float x, float sigma) const;
|
||||
QVector<float> gaussianKernel() const;
|
||||
void setIsValid(bool value) { mValid = value; }
|
||||
void setIsValid(bool value) {
|
||||
mValid = value;
|
||||
}
|
||||
virtual void init() = 0;
|
||||
virtual void reset() = 0;
|
||||
virtual int maxKernelSize() const = 0;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -40,103 +40,102 @@ namespace KWin
|
|||
|
||||
class BoxSwitchEffect
|
||||
: public Effect
|
||||
{
|
||||
public:
|
||||
BoxSwitchEffect();
|
||||
~BoxSwitchEffect();
|
||||
virtual void reconfigure( ReconfigureFlags );
|
||||
virtual void prePaintScreen( ScreenPrePaintData &data, int time );
|
||||
virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data );
|
||||
virtual void postPaintScreen();
|
||||
virtual void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time );
|
||||
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data );
|
||||
{
|
||||
public:
|
||||
BoxSwitchEffect();
|
||||
~BoxSwitchEffect();
|
||||
virtual void reconfigure(ReconfigureFlags);
|
||||
virtual void prePaintScreen(ScreenPrePaintData &data, int time);
|
||||
virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data);
|
||||
virtual void postPaintScreen();
|
||||
virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time);
|
||||
virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
|
||||
|
||||
virtual void windowInputMouseEvent( Window w, QEvent* e );
|
||||
virtual void windowDamaged( EffectWindow* w, const QRect& damage );
|
||||
virtual void windowGeometryShapeChanged( EffectWindow* w, const QRect& old );
|
||||
virtual void tabBoxAdded( int mode );
|
||||
virtual void tabBoxClosed();
|
||||
virtual void tabBoxUpdated();
|
||||
virtual void windowClosed( EffectWindow* w );
|
||||
virtual void* proxy();
|
||||
void activateFromProxy( int mode, bool animate, bool showText, float positioningFactor );
|
||||
void paintWindowsBox( const QRegion& region );
|
||||
private:
|
||||
class ItemInfo;
|
||||
void setActive();
|
||||
void setInactive();
|
||||
void moveResizeInputWindow( int x, int y, int width, int height );
|
||||
void calculateFrameSize();
|
||||
void calculateItemSizes();
|
||||
void setSelectedWindow( EffectWindow* w );
|
||||
virtual void windowInputMouseEvent(Window w, QEvent* e);
|
||||
virtual void windowDamaged(EffectWindow* w, const QRect& damage);
|
||||
virtual void windowGeometryShapeChanged(EffectWindow* w, const QRect& old);
|
||||
virtual void tabBoxAdded(int mode);
|
||||
virtual void tabBoxClosed();
|
||||
virtual void tabBoxUpdated();
|
||||
virtual void windowClosed(EffectWindow* w);
|
||||
virtual void* proxy();
|
||||
void activateFromProxy(int mode, bool animate, bool showText, float positioningFactor);
|
||||
void paintWindowsBox(const QRegion& region);
|
||||
private:
|
||||
class ItemInfo;
|
||||
void setActive();
|
||||
void setInactive();
|
||||
void moveResizeInputWindow(int x, int y, int width, int height);
|
||||
void calculateFrameSize();
|
||||
void calculateItemSizes();
|
||||
void setSelectedWindow(EffectWindow* w);
|
||||
|
||||
void paintWindowThumbnail( EffectWindow* w );
|
||||
void paintDesktopThumbnail( int iDesktop );
|
||||
void paintWindowIcon( EffectWindow* w );
|
||||
void paintWindowThumbnail(EffectWindow* w);
|
||||
void paintDesktopThumbnail(int iDesktop);
|
||||
void paintWindowIcon(EffectWindow* w);
|
||||
|
||||
bool mActivated;
|
||||
Window mInput;
|
||||
int mMode;
|
||||
bool mActivated;
|
||||
Window mInput;
|
||||
int mMode;
|
||||
|
||||
EffectFrame* thumbnailFrame;
|
||||
EffectFrame* thumbnailFrame;
|
||||
|
||||
QRect frame_area;
|
||||
int highlight_margin;
|
||||
QSize item_max_size; // maximum item display size (including highlight)
|
||||
QRect text_area;
|
||||
QFont text_font;
|
||||
QColor color_frame;
|
||||
QColor color_highlight;
|
||||
QRect frame_area;
|
||||
int highlight_margin;
|
||||
QSize item_max_size; // maximum item display size (including highlight)
|
||||
QRect text_area;
|
||||
QFont text_font;
|
||||
QColor color_frame;
|
||||
QColor color_highlight;
|
||||
|
||||
float bg_opacity;
|
||||
bool elevate_window;
|
||||
float bg_opacity;
|
||||
bool elevate_window;
|
||||
|
||||
QHash< EffectWindow*, ItemInfo* > windows;
|
||||
EffectWindowList original_windows;
|
||||
EffectWindowList referrencedWindows;
|
||||
EffectWindow* selected_window;
|
||||
QHash< int, ItemInfo* > desktops;
|
||||
QList< int > original_desktops;
|
||||
int selected_desktop;
|
||||
QHash< EffectWindow*, ItemInfo* > windows;
|
||||
EffectWindowList original_windows;
|
||||
EffectWindowList referrencedWindows;
|
||||
EffectWindow* selected_window;
|
||||
QHash< int, ItemInfo* > desktops;
|
||||
QList< int > original_desktops;
|
||||
int selected_desktop;
|
||||
|
||||
int painting_desktop;
|
||||
int painting_desktop;
|
||||
|
||||
bool mAnimateSwitch;
|
||||
TimeLine activeTimeLine;
|
||||
TimeLine timeLine;
|
||||
bool animation;
|
||||
QRect highlight_area;
|
||||
bool highlight_is_set;
|
||||
enum Direction
|
||||
{
|
||||
Left,
|
||||
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;
|
||||
bool mAnimateSwitch;
|
||||
TimeLine activeTimeLine;
|
||||
TimeLine timeLine;
|
||||
bool animation;
|
||||
QRect highlight_area;
|
||||
bool highlight_is_set;
|
||||
enum Direction {
|
||||
Left,
|
||||
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;
|
||||
};
|
||||
|
||||
class BoxSwitchEffect::ItemInfo
|
||||
{
|
||||
public:
|
||||
ItemInfo();
|
||||
~ItemInfo();
|
||||
QRect area; // maximal painting area, including any frames/highlights/etc.
|
||||
QRegion clickable;
|
||||
QRect thumbnail;
|
||||
EffectFrame* iconFrame;
|
||||
};
|
||||
{
|
||||
public:
|
||||
ItemInfo();
|
||||
~ItemInfo();
|
||||
QRect area; // maximal painting area, including any frames/highlights/etc.
|
||||
QRegion clickable;
|
||||
QRect thumbnail;
|
||||
EffectFrame* iconFrame;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -32,72 +32,72 @@ KWIN_EFFECT_CONFIG_FACTORY
|
|||
|
||||
BoxSwitchEffectConfigForm::BoxSwitchEffectConfigForm(QWidget* parent) : QWidget(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
setupUi(this);
|
||||
}
|
||||
|
||||
BoxSwitchEffectConfig::BoxSwitchEffectConfig(QWidget* parent, const QVariantList& args)
|
||||
: KCModule( EffectFactory::componentData(), parent, args )
|
||||
{
|
||||
m_ui = new BoxSwitchEffectConfigForm( this );
|
||||
: KCModule(EffectFactory::componentData(), parent, args)
|
||||
{
|
||||
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->elevateBox, SIGNAL( stateChanged(int) ), this, SLOT( changed() ));
|
||||
connect( m_ui->animateBox, SIGNAL( stateChanged(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->animateBox, SIGNAL(stateChanged(int)), this, SLOT(changed()));
|
||||
|
||||
load();
|
||||
}
|
||||
}
|
||||
|
||||
BoxSwitchEffectConfig::~BoxSwitchEffectConfig()
|
||||
{
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
void BoxSwitchEffectConfig::load()
|
||||
{
|
||||
{
|
||||
KCModule::load();
|
||||
|
||||
KConfigGroup conf = EffectsHandler::effectConfig( "BoxSwitch" );
|
||||
|
||||
int opacity = conf.readEntry( "BackgroundOpacity", 25 );
|
||||
m_ui->opacitySpin->setValue( opacity );
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("BoxSwitch");
|
||||
|
||||
bool elevate = conf.readEntry( "ElevateSelected", true );
|
||||
m_ui->elevateBox->setChecked( elevate );
|
||||
int opacity = conf.readEntry("BackgroundOpacity", 25);
|
||||
m_ui->opacitySpin->setValue(opacity);
|
||||
|
||||
bool animate = conf.readEntry( "AnimateSwitch", false );
|
||||
m_ui->animateBox->setChecked( animate );
|
||||
bool elevate = conf.readEntry("ElevateSelected", true);
|
||||
m_ui->elevateBox->setChecked(elevate);
|
||||
|
||||
bool animate = conf.readEntry("AnimateSwitch", false);
|
||||
m_ui->animateBox->setChecked(animate);
|
||||
|
||||
emit changed(false);
|
||||
}
|
||||
}
|
||||
|
||||
void BoxSwitchEffectConfig::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();
|
||||
|
||||
emit changed(false);
|
||||
EffectsHandler::sendReloadMessage( "boxswitch" );
|
||||
}
|
||||
EffectsHandler::sendReloadMessage("boxswitch");
|
||||
}
|
||||
|
||||
void BoxSwitchEffectConfig::defaults()
|
||||
{
|
||||
m_ui->opacitySpin->setValue( 25 );
|
||||
m_ui->elevateBox->setChecked( true );
|
||||
m_ui->animateBox->setChecked( false );
|
||||
{
|
||||
m_ui->opacitySpin->setValue(25);
|
||||
m_ui->elevateBox->setChecked(true);
|
||||
m_ui->animateBox->setChecked(false);
|
||||
emit changed(true);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -31,25 +31,25 @@ namespace KWin
|
|||
class BoxSwitchEffectConfigForm : public QWidget, public Ui::BoxSwitchEffectConfigForm
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit BoxSwitchEffectConfigForm(QWidget* parent);
|
||||
public:
|
||||
explicit BoxSwitchEffectConfigForm(QWidget* parent);
|
||||
};
|
||||
|
||||
class BoxSwitchEffectConfig : public KCModule
|
||||
{
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit BoxSwitchEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
|
||||
~BoxSwitchEffectConfig();
|
||||
public:
|
||||
explicit BoxSwitchEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
|
||||
~BoxSwitchEffectConfig();
|
||||
|
||||
public slots:
|
||||
virtual void save();
|
||||
virtual void load();
|
||||
virtual void defaults();
|
||||
public slots:
|
||||
virtual void save();
|
||||
virtual void load();
|
||||
virtual void defaults();
|
||||
|
||||
private:
|
||||
BoxSwitchEffectConfigForm* m_ui;
|
||||
};
|
||||
private:
|
||||
BoxSwitchEffectConfigForm* m_ui;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -24,23 +24,23 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
BoxSwitchEffectProxy::BoxSwitchEffectProxy( BoxSwitchEffect* effect )
|
||||
: m_effect( effect )
|
||||
{
|
||||
}
|
||||
BoxSwitchEffectProxy::BoxSwitchEffectProxy(BoxSwitchEffect* effect)
|
||||
: m_effect(effect)
|
||||
{
|
||||
}
|
||||
|
||||
BoxSwitchEffectProxy::~BoxSwitchEffectProxy()
|
||||
{
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
void BoxSwitchEffectProxy::activate( int mode, bool animate, bool showText, float positioningFactor )
|
||||
{
|
||||
m_effect->activateFromProxy( mode, animate, showText, positioningFactor );
|
||||
}
|
||||
void BoxSwitchEffectProxy::activate(int mode, bool animate, bool showText, float positioningFactor)
|
||||
{
|
||||
m_effect->activateFromProxy(mode, animate, showText, positioningFactor);
|
||||
}
|
||||
|
||||
void BoxSwitchEffectProxy::paintWindowsBox( const QRegion& region )
|
||||
{
|
||||
m_effect->paintWindowsBox( region );
|
||||
}
|
||||
void BoxSwitchEffectProxy::paintWindowsBox(const QRegion& region)
|
||||
{
|
||||
m_effect->paintWindowsBox(region);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -30,22 +30,22 @@ class BoxSwitchEffect;
|
|||
|
||||
class BoxSwitchEffectProxy
|
||||
{
|
||||
public:
|
||||
BoxSwitchEffectProxy( BoxSwitchEffect* effect );
|
||||
~BoxSwitchEffectProxy();
|
||||
public:
|
||||
BoxSwitchEffectProxy(BoxSwitchEffect* effect);
|
||||
~BoxSwitchEffectProxy();
|
||||
|
||||
/**
|
||||
* Activates the BoxSwitch Effect. It will get deactivated in tabBoxClosed()
|
||||
* @param mode The TabBoxMode for which it should be activated.
|
||||
* @param animate switch will be animated
|
||||
* @param showText the caption of the window will be shown
|
||||
* @param positioningFactor where to put the frame: 0.0 == top, 1.0 == bottom
|
||||
*/
|
||||
void activate( int mode, bool animate, bool showText, float positioningFactor );
|
||||
void paintWindowsBox( const QRegion& region);
|
||||
/**
|
||||
* Activates the BoxSwitch Effect. It will get deactivated in tabBoxClosed()
|
||||
* @param mode The TabBoxMode for which it should be activated.
|
||||
* @param animate switch will be animated
|
||||
* @param showText the caption of the window will be shown
|
||||
* @param positioningFactor where to put the frame: 0.0 == top, 1.0 == bottom
|
||||
*/
|
||||
void activate(int mode, bool animate, bool showText, float positioningFactor);
|
||||
void paintWindowsBox(const QRegion& region);
|
||||
|
||||
private:
|
||||
BoxSwitchEffect* m_effect;
|
||||
private:
|
||||
BoxSwitchEffect* m_effect;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -56,33 +56,33 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
KWIN_EFFECT_CONFIG_MULTIPLE( builtins,
|
||||
KWIN_EFFECT_CONFIG_SINGLE( boxswitch, BoxSwitchEffectConfig )
|
||||
KWIN_EFFECT_CONFIG_SINGLE( dashboard, DashboardEffectConfig )
|
||||
KWIN_EFFECT_CONFIG_SINGLE( desktopgrid, DesktopGridEffectConfig )
|
||||
KWIN_EFFECT_CONFIG_SINGLE( diminactive, DimInactiveEffectConfig )
|
||||
KWIN_EFFECT_CONFIG_SINGLE( magiclamp, MagicLampEffectConfig )
|
||||
KWIN_EFFECT_CONFIG_SINGLE( presentwindows, PresentWindowsEffectConfig )
|
||||
KWIN_EFFECT_CONFIG_SINGLE( resize, ResizeEffectConfig )
|
||||
KWIN_EFFECT_CONFIG_SINGLE( showfps, ShowFpsEffectConfig )
|
||||
KWIN_EFFECT_CONFIG_SINGLE( translucency, TranslucencyEffectConfig )
|
||||
KWIN_EFFECT_CONFIG_SINGLE( thumbnailaside, ThumbnailAsideEffectConfig )
|
||||
KWIN_EFFECT_CONFIG_SINGLE( zoom, ZoomEffectConfig )
|
||||
KWIN_EFFECT_CONFIG_MULTIPLE(builtins,
|
||||
KWIN_EFFECT_CONFIG_SINGLE(boxswitch, BoxSwitchEffectConfig)
|
||||
KWIN_EFFECT_CONFIG_SINGLE(dashboard, DashboardEffectConfig)
|
||||
KWIN_EFFECT_CONFIG_SINGLE(desktopgrid, DesktopGridEffectConfig)
|
||||
KWIN_EFFECT_CONFIG_SINGLE(diminactive, DimInactiveEffectConfig)
|
||||
KWIN_EFFECT_CONFIG_SINGLE(magiclamp, MagicLampEffectConfig)
|
||||
KWIN_EFFECT_CONFIG_SINGLE(presentwindows, PresentWindowsEffectConfig)
|
||||
KWIN_EFFECT_CONFIG_SINGLE(resize, ResizeEffectConfig)
|
||||
KWIN_EFFECT_CONFIG_SINGLE(showfps, ShowFpsEffectConfig)
|
||||
KWIN_EFFECT_CONFIG_SINGLE(translucency, TranslucencyEffectConfig)
|
||||
KWIN_EFFECT_CONFIG_SINGLE(thumbnailaside, ThumbnailAsideEffectConfig)
|
||||
KWIN_EFFECT_CONFIG_SINGLE(zoom, ZoomEffectConfig)
|
||||
|
||||
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
|
||||
KWIN_EFFECT_CONFIG_SINGLE( blur, BlurEffectConfig )
|
||||
KWIN_EFFECT_CONFIG_SINGLE( coverswitch, CoverSwitchEffectConfig )
|
||||
KWIN_EFFECT_CONFIG_SINGLE( cube, CubeEffectConfig )
|
||||
KWIN_EFFECT_CONFIG_SINGLE( cubeslide, CubeSlideEffectConfig )
|
||||
KWIN_EFFECT_CONFIG_SINGLE( flipswitch, FlipSwitchEffectConfig )
|
||||
KWIN_EFFECT_CONFIG_SINGLE( glide, GlideEffectConfig )
|
||||
KWIN_EFFECT_CONFIG_SINGLE( invert, InvertEffectConfig )
|
||||
KWIN_EFFECT_CONFIG_SINGLE( lookingglass, LookingGlassEffectConfig )
|
||||
KWIN_EFFECT_CONFIG_SINGLE( magnifier, MagnifierEffectConfig )
|
||||
KWIN_EFFECT_CONFIG_SINGLE( mousemark, MouseMarkEffectConfig )
|
||||
KWIN_EFFECT_CONFIG_SINGLE( trackmouse, TrackMouseEffectConfig )
|
||||
KWIN_EFFECT_CONFIG_SINGLE( wobblywindows, WobblyWindowsEffectConfig )
|
||||
KWIN_EFFECT_CONFIG_SINGLE(blur, BlurEffectConfig)
|
||||
KWIN_EFFECT_CONFIG_SINGLE(coverswitch, CoverSwitchEffectConfig)
|
||||
KWIN_EFFECT_CONFIG_SINGLE(cube, CubeEffectConfig)
|
||||
KWIN_EFFECT_CONFIG_SINGLE(cubeslide, CubeSlideEffectConfig)
|
||||
KWIN_EFFECT_CONFIG_SINGLE(flipswitch, FlipSwitchEffectConfig)
|
||||
KWIN_EFFECT_CONFIG_SINGLE(glide, GlideEffectConfig)
|
||||
KWIN_EFFECT_CONFIG_SINGLE(invert, InvertEffectConfig)
|
||||
KWIN_EFFECT_CONFIG_SINGLE(lookingglass, LookingGlassEffectConfig)
|
||||
KWIN_EFFECT_CONFIG_SINGLE(magnifier, MagnifierEffectConfig)
|
||||
KWIN_EFFECT_CONFIG_SINGLE(mousemark, MouseMarkEffectConfig)
|
||||
KWIN_EFFECT_CONFIG_SINGLE(trackmouse, TrackMouseEffectConfig)
|
||||
KWIN_EFFECT_CONFIG_SINGLE(wobblywindows, WobblyWindowsEffectConfig)
|
||||
#endif
|
||||
)
|
||||
)
|
||||
|
||||
} // namespace
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -35,76 +35,75 @@ namespace KWin
|
|||
|
||||
class CoverSwitchEffect
|
||||
: public Effect
|
||||
{
|
||||
public:
|
||||
CoverSwitchEffect();
|
||||
~CoverSwitchEffect();
|
||||
{
|
||||
public:
|
||||
CoverSwitchEffect();
|
||||
~CoverSwitchEffect();
|
||||
|
||||
virtual void reconfigure( ReconfigureFlags );
|
||||
virtual void prePaintScreen( ScreenPrePaintData& data, int time );
|
||||
virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data );
|
||||
virtual void postPaintScreen();
|
||||
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data );
|
||||
virtual void tabBoxAdded( int mode );
|
||||
virtual void tabBoxClosed();
|
||||
virtual void tabBoxUpdated();
|
||||
virtual void windowInputMouseEvent( Window w, QEvent* e );
|
||||
virtual void windowClosed( EffectWindow* c );
|
||||
virtual void reconfigure(ReconfigureFlags);
|
||||
virtual void prePaintScreen(ScreenPrePaintData& data, int time);
|
||||
virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data);
|
||||
virtual void postPaintScreen();
|
||||
virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
|
||||
virtual void tabBoxAdded(int mode);
|
||||
virtual void tabBoxClosed();
|
||||
virtual void tabBoxUpdated();
|
||||
virtual void windowInputMouseEvent(Window w, QEvent* e);
|
||||
virtual void windowClosed(EffectWindow* c);
|
||||
|
||||
static bool supported();
|
||||
private:
|
||||
void paintScene( EffectWindow* frontWindow, const EffectWindowList& leftWindows, const EffectWindowList& rightWindows,
|
||||
bool reflectedWindows = false );
|
||||
void paintWindowCover( EffectWindow* w, bool reflectedWindow, WindowPaintData& data );
|
||||
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 abort();
|
||||
static bool supported();
|
||||
private:
|
||||
void paintScene(EffectWindow* frontWindow, const EffectWindowList& leftWindows, const EffectWindowList& rightWindows,
|
||||
bool reflectedWindows = false);
|
||||
void paintWindowCover(EffectWindow* w, bool reflectedWindow, WindowPaintData& data);
|
||||
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 abort();
|
||||
|
||||
bool mActivated;
|
||||
float angle;
|
||||
bool animateSwitch;
|
||||
bool animateStart;
|
||||
bool animateStop;
|
||||
bool animation;
|
||||
bool start;
|
||||
bool stop;
|
||||
bool reflection;
|
||||
float mirrorColor[2][4];
|
||||
bool windowTitle;
|
||||
int animationDuration;
|
||||
bool stopRequested;
|
||||
bool startRequested;
|
||||
TimeLine timeLine;
|
||||
QRect area;
|
||||
Window input;
|
||||
float zPosition;
|
||||
float scaleFactor;
|
||||
enum Direction
|
||||
{
|
||||
Left,
|
||||
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;
|
||||
bool mActivated;
|
||||
float angle;
|
||||
bool animateSwitch;
|
||||
bool animateStart;
|
||||
bool animateStop;
|
||||
bool animation;
|
||||
bool start;
|
||||
bool stop;
|
||||
bool reflection;
|
||||
float mirrorColor[2][4];
|
||||
bool windowTitle;
|
||||
int animationDuration;
|
||||
bool stopRequested;
|
||||
bool startRequested;
|
||||
TimeLine timeLine;
|
||||
QRect area;
|
||||
Window input;
|
||||
float zPosition;
|
||||
float scaleFactor;
|
||||
enum Direction {
|
||||
Left,
|
||||
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;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -31,12 +31,12 @@ KWIN_EFFECT_CONFIG_FACTORY
|
|||
|
||||
CoverSwitchEffectConfigForm::CoverSwitchEffectConfigForm(QWidget* parent) : QWidget(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
setupUi(this);
|
||||
}
|
||||
|
||||
CoverSwitchEffectConfig::CoverSwitchEffectConfig(QWidget* parent, const QVariantList& args) :
|
||||
KCModule(EffectFactory::componentData(), parent, args)
|
||||
{
|
||||
KCModule(EffectFactory::componentData(), parent, args)
|
||||
{
|
||||
m_ui = new CoverSwitchEffectConfigForm(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()));
|
||||
|
||||
load();
|
||||
}
|
||||
}
|
||||
|
||||
void CoverSwitchEffectConfig::load()
|
||||
{
|
||||
{
|
||||
KCModule::load();
|
||||
|
||||
KConfigGroup conf = EffectsHandler::effectConfig( "CoverSwitch" );
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("CoverSwitch");
|
||||
|
||||
m_ui->spinDuration->setValue( conf.readEntry( "Duration", 0 ) );
|
||||
m_ui->spinDuration->setSuffix( ki18np( " millisecond", " milliseconds" ) );
|
||||
m_ui->checkAnimateSwitch->setChecked( conf.readEntry( "AnimateSwitch", true ));
|
||||
m_ui->checkAnimateStart->setChecked( conf.readEntry( "AnimateStart", true ));
|
||||
m_ui->checkAnimateStop->setChecked( conf.readEntry( "AnimateStop", true ));
|
||||
m_ui->checkReflection->setChecked( conf.readEntry( "Reflection", true ));
|
||||
m_ui->colorFront->setColor( conf.readEntry( "MirrorFrontColor", 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->checkThumbnails->setChecked( conf.readEntry( "Thumbnails", true ));
|
||||
m_ui->checkDynamicThumbnails->setChecked( conf.readEntry( "DynamicThumbnails", true ));
|
||||
m_ui->spinThumbnailWindows->setValue( conf.readEntry( "ThumbnailWindows", 8 ));
|
||||
m_ui->zPositionSlider->setValue( conf.readEntry( "ZPosition", 900 ));
|
||||
m_ui->spinDuration->setValue(conf.readEntry("Duration", 0));
|
||||
m_ui->spinDuration->setSuffix(ki18np(" millisecond", " milliseconds"));
|
||||
m_ui->checkAnimateSwitch->setChecked(conf.readEntry("AnimateSwitch", true));
|
||||
m_ui->checkAnimateStart->setChecked(conf.readEntry("AnimateStart", true));
|
||||
m_ui->checkAnimateStop->setChecked(conf.readEntry("AnimateStop", true));
|
||||
m_ui->checkReflection->setChecked(conf.readEntry("Reflection", true));
|
||||
m_ui->colorFront->setColor(conf.readEntry("MirrorFrontColor", 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->checkThumbnails->setChecked(conf.readEntry("Thumbnails", true));
|
||||
m_ui->checkDynamicThumbnails->setChecked(conf.readEntry("DynamicThumbnails", true));
|
||||
m_ui->spinThumbnailWindows->setValue(conf.readEntry("ThumbnailWindows", 8));
|
||||
m_ui->zPositionSlider->setValue(conf.readEntry("ZPosition", 900));
|
||||
|
||||
thumbnailsChanged();
|
||||
|
||||
emit changed(false);
|
||||
}
|
||||
}
|
||||
|
||||
void CoverSwitchEffectConfig::save()
|
||||
{
|
||||
KConfigGroup conf = EffectsHandler::effectConfig( "CoverSwitch" );
|
||||
{
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("CoverSwitch");
|
||||
|
||||
conf.writeEntry( "Duration", m_ui->spinDuration->value() );
|
||||
conf.writeEntry( "AnimateSwitch", m_ui->checkAnimateSwitch->isChecked() );
|
||||
conf.writeEntry( "AnimateStart", m_ui->checkAnimateStart->isChecked() );
|
||||
conf.writeEntry( "AnimateStop", m_ui->checkAnimateStop->isChecked() );
|
||||
conf.writeEntry( "Reflection", m_ui->checkReflection->isChecked() );
|
||||
conf.writeEntry( "MirrorFrontColor", m_ui->colorFront->color() );
|
||||
conf.writeEntry( "MirrorRearColor", m_ui->colorRear->color() );
|
||||
conf.writeEntry( "WindowTitle", m_ui->checkWindowTitle->isChecked() );
|
||||
conf.writeEntry( "Thumbnails", m_ui->checkThumbnails->isChecked() );
|
||||
conf.writeEntry( "DynamicThumbnails", m_ui->checkDynamicThumbnails->isChecked() );
|
||||
conf.writeEntry( "ThumbnailWindows", m_ui->spinThumbnailWindows->value() );
|
||||
conf.writeEntry( "ZPosition", m_ui->zPositionSlider->value() );
|
||||
conf.writeEntry("Duration", m_ui->spinDuration->value());
|
||||
conf.writeEntry("AnimateSwitch", m_ui->checkAnimateSwitch->isChecked());
|
||||
conf.writeEntry("AnimateStart", m_ui->checkAnimateStart->isChecked());
|
||||
conf.writeEntry("AnimateStop", m_ui->checkAnimateStop->isChecked());
|
||||
conf.writeEntry("Reflection", m_ui->checkReflection->isChecked());
|
||||
conf.writeEntry("MirrorFrontColor", m_ui->colorFront->color());
|
||||
conf.writeEntry("MirrorRearColor", m_ui->colorRear->color());
|
||||
conf.writeEntry("WindowTitle", m_ui->checkWindowTitle->isChecked());
|
||||
conf.writeEntry("Thumbnails", m_ui->checkThumbnails->isChecked());
|
||||
conf.writeEntry("DynamicThumbnails", m_ui->checkDynamicThumbnails->isChecked());
|
||||
conf.writeEntry("ThumbnailWindows", m_ui->spinThumbnailWindows->value());
|
||||
conf.writeEntry("ZPosition", m_ui->zPositionSlider->value());
|
||||
|
||||
conf.sync();
|
||||
|
||||
emit changed(false);
|
||||
EffectsHandler::sendReloadMessage( "coverswitch" );
|
||||
}
|
||||
EffectsHandler::sendReloadMessage("coverswitch");
|
||||
}
|
||||
|
||||
void CoverSwitchEffectConfig::defaults()
|
||||
{
|
||||
m_ui->spinDuration->setValue( 0 );
|
||||
m_ui->checkAnimateSwitch->setCheckState( Qt::Checked );
|
||||
m_ui->checkAnimateStart->setCheckState( Qt::Checked );
|
||||
m_ui->checkAnimateStop->setCheckState( Qt::Checked );
|
||||
m_ui->checkReflection->setCheckState( Qt::Checked );
|
||||
m_ui->colorFront->setColor( QColor(0,0,0) );
|
||||
m_ui->colorRear->setColor( QColor(0,0,0) );
|
||||
m_ui->checkWindowTitle->setCheckState( Qt::Checked );
|
||||
m_ui->checkThumbnails->setCheckState( Qt::Checked );
|
||||
m_ui->checkDynamicThumbnails->setCheckState( Qt::Checked );
|
||||
m_ui->spinThumbnailWindows->setValue( 8 );
|
||||
m_ui->zPositionSlider->setValue( 900 );
|
||||
{
|
||||
m_ui->spinDuration->setValue(0);
|
||||
m_ui->checkAnimateSwitch->setCheckState(Qt::Checked);
|
||||
m_ui->checkAnimateStart->setCheckState(Qt::Checked);
|
||||
m_ui->checkAnimateStop->setCheckState(Qt::Checked);
|
||||
m_ui->checkReflection->setCheckState(Qt::Checked);
|
||||
m_ui->colorFront->setColor(QColor(0, 0, 0));
|
||||
m_ui->colorRear->setColor(QColor(0, 0, 0));
|
||||
m_ui->checkWindowTitle->setCheckState(Qt::Checked);
|
||||
m_ui->checkThumbnails->setCheckState(Qt::Checked);
|
||||
m_ui->checkDynamicThumbnails->setCheckState(Qt::Checked);
|
||||
m_ui->spinThumbnailWindows->setValue(8);
|
||||
m_ui->zPositionSlider->setValue(900);
|
||||
emit changed(true);
|
||||
}
|
||||
}
|
||||
|
||||
void CoverSwitchEffectConfig::thumbnailsChanged()
|
||||
{
|
||||
{
|
||||
bool enabled = m_ui->checkThumbnails->isChecked() && m_ui->checkDynamicThumbnails->isChecked();
|
||||
m_ui->checkDynamicThumbnails->setEnabled( m_ui->checkThumbnails->isChecked() );
|
||||
m_ui->spinThumbnailWindows->setEnabled( enabled );
|
||||
m_ui->labelThumbnailWindows->setEnabled( enabled );
|
||||
}
|
||||
m_ui->checkDynamicThumbnails->setEnabled(m_ui->checkThumbnails->isChecked());
|
||||
m_ui->spinThumbnailWindows->setEnabled(enabled);
|
||||
m_ui->labelThumbnailWindows->setEnabled(enabled);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -32,27 +32,27 @@ namespace KWin
|
|||
class CoverSwitchEffectConfigForm : public QWidget, public Ui::CoverSwitchEffectConfigForm
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CoverSwitchEffectConfigForm(QWidget* parent);
|
||||
public:
|
||||
explicit CoverSwitchEffectConfigForm(QWidget* parent);
|
||||
};
|
||||
|
||||
class CoverSwitchEffectConfig : public KCModule
|
||||
{
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CoverSwitchEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
|
||||
public:
|
||||
explicit CoverSwitchEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
|
||||
|
||||
public slots:
|
||||
virtual void save();
|
||||
virtual void load();
|
||||
virtual void defaults();
|
||||
public slots:
|
||||
virtual void save();
|
||||
virtual void load();
|
||||
virtual void defaults();
|
||||
|
||||
private slots:
|
||||
void thumbnailsChanged();
|
||||
private slots:
|
||||
void thumbnailsChanged();
|
||||
|
||||
private:
|
||||
CoverSwitchEffectConfigForm* m_ui;
|
||||
};
|
||||
private:
|
||||
CoverSwitchEffectConfigForm* m_ui;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -35,150 +35,147 @@ namespace KWin
|
|||
|
||||
class CubeEffect
|
||||
: public QObject, public Effect
|
||||
{
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CubeEffect();
|
||||
~CubeEffect();
|
||||
virtual void reconfigure( ReconfigureFlags );
|
||||
virtual void prePaintScreen( ScreenPrePaintData& data, int time );
|
||||
virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data );
|
||||
virtual void postPaintScreen();
|
||||
virtual void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time );
|
||||
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data );
|
||||
virtual bool borderActivated( ElectricBorder border );
|
||||
virtual void grabbedKeyboardEvent( QKeyEvent* e );
|
||||
virtual void mouseChanged( const QPoint& pos, const QPoint& oldpos, Qt::MouseButtons buttons,
|
||||
Qt::MouseButtons oldbuttons, Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers );
|
||||
virtual void windowInputMouseEvent( Window w, QEvent* e );
|
||||
virtual void tabBoxAdded( int mode );
|
||||
virtual void tabBoxUpdated();
|
||||
virtual void tabBoxClosed();
|
||||
public:
|
||||
CubeEffect();
|
||||
~CubeEffect();
|
||||
virtual void reconfigure(ReconfigureFlags);
|
||||
virtual void prePaintScreen(ScreenPrePaintData& data, int time);
|
||||
virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data);
|
||||
virtual void postPaintScreen();
|
||||
virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time);
|
||||
virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
|
||||
virtual bool borderActivated(ElectricBorder border);
|
||||
virtual void grabbedKeyboardEvent(QKeyEvent* e);
|
||||
virtual void mouseChanged(const QPoint& pos, const QPoint& oldpos, Qt::MouseButtons buttons,
|
||||
Qt::MouseButtons oldbuttons, Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers);
|
||||
virtual void windowInputMouseEvent(Window w, QEvent* e);
|
||||
virtual void tabBoxAdded(int mode);
|
||||
virtual void tabBoxUpdated();
|
||||
virtual void tabBoxClosed();
|
||||
|
||||
// proxy functions
|
||||
virtual void* proxy();
|
||||
void registerCubeInsideEffect( CubeInsideEffect* effect );
|
||||
void unregisterCubeInsideEffect( CubeInsideEffect* effect );
|
||||
// proxy functions
|
||||
virtual void* proxy();
|
||||
void registerCubeInsideEffect(CubeInsideEffect* effect);
|
||||
void unregisterCubeInsideEffect(CubeInsideEffect* effect);
|
||||
|
||||
static bool supported();
|
||||
private slots:
|
||||
void toggleCube();
|
||||
void toggleCylinder();
|
||||
void toggleSphere();
|
||||
// slots for global shortcut changed
|
||||
// needed to toggle the effect
|
||||
void cubeShortcutChanged( const QKeySequence& seq );
|
||||
void cylinderShortcutChanged( const QKeySequence& seq );
|
||||
void sphereShortcutChanged( const QKeySequence& seq );
|
||||
private:
|
||||
enum RotationDirection
|
||||
{
|
||||
Left,
|
||||
Right,
|
||||
Upwards,
|
||||
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;
|
||||
static bool supported();
|
||||
private slots:
|
||||
void toggleCube();
|
||||
void toggleCylinder();
|
||||
void toggleSphere();
|
||||
// slots for global shortcut changed
|
||||
// needed to toggle the effect
|
||||
void cubeShortcutChanged(const QKeySequence& seq);
|
||||
void cylinderShortcutChanged(const QKeySequence& seq);
|
||||
void sphereShortcutChanged(const QKeySequence& seq);
|
||||
private:
|
||||
enum RotationDirection {
|
||||
Left,
|
||||
Right,
|
||||
Upwards,
|
||||
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;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -35,39 +35,39 @@ KWIN_EFFECT_CONFIG_FACTORY
|
|||
|
||||
CubeEffectConfigForm::CubeEffectConfigForm(QWidget* parent) : QWidget(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
setupUi(this);
|
||||
}
|
||||
|
||||
CubeEffectConfig::CubeEffectConfig(QWidget* parent, const QVariantList& args) :
|
||||
KCModule(EffectFactory::componentData(), parent, args)
|
||||
{
|
||||
KCModule(EffectFactory::componentData(), parent, args)
|
||||
{
|
||||
m_ui = new CubeEffectConfigForm(this);
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
|
||||
layout->addWidget(m_ui);
|
||||
|
||||
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(0, i18nc("@title:tab Basic Settings", "Basic"));
|
||||
m_ui->tabWidget->setTabText(1, i18nc("@title:tab Advanced Settings", "Advanced"));
|
||||
|
||||
// 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);
|
||||
|
||||
KAction* cubeAction = (KAction*) m_actionCollection->addAction( "Cube" );
|
||||
cubeAction->setText( i18n("Desktop Cube" ));
|
||||
KAction* cubeAction = (KAction*) m_actionCollection->addAction("Cube");
|
||||
cubeAction->setText(i18n("Desktop Cube"));
|
||||
cubeAction->setProperty("isConfigurationAction", true);
|
||||
cubeAction->setGlobalShortcut( KShortcut( Qt::CTRL + Qt::Key_F11 ));
|
||||
KAction* cylinderAction = (KAction*) m_actionCollection->addAction( "Cylinder" );
|
||||
cylinderAction->setText( i18n("Desktop Cylinder" ));
|
||||
cubeAction->setGlobalShortcut(KShortcut(Qt::CTRL + Qt::Key_F11));
|
||||
KAction* cylinderAction = (KAction*) m_actionCollection->addAction("Cylinder");
|
||||
cylinderAction->setText(i18n("Desktop Cylinder"));
|
||||
cylinderAction->setProperty("isConfigurationAction", true);
|
||||
cylinderAction->setGlobalShortcut( KShortcut(), KAction::ActiveShortcut);
|
||||
KAction* sphereAction = (KAction*) m_actionCollection->addAction( "Sphere" );
|
||||
sphereAction->setText( i18n("Desktop Sphere" ));
|
||||
cylinderAction->setGlobalShortcut(KShortcut(), KAction::ActiveShortcut);
|
||||
KAction* sphereAction = (KAction*) m_actionCollection->addAction("Sphere");
|
||||
sphereAction->setText(i18n("Desktop Sphere"));
|
||||
sphereAction->setProperty("isConfigurationAction", true);
|
||||
sphereAction->setGlobalShortcut( KShortcut(), KAction::ActiveShortcut);
|
||||
sphereAction->setGlobalShortcut(KShortcut(), KAction::ActiveShortcut);
|
||||
|
||||
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()));
|
||||
|
||||
load();
|
||||
}
|
||||
}
|
||||
|
||||
void CubeEffectConfig::load()
|
||||
{
|
||||
{
|
||||
KCModule::load();
|
||||
|
||||
KConfigGroup conf = EffectsHandler::effectConfig( "Cube" );
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("Cube");
|
||||
|
||||
int duration = conf.readEntry( "RotationDuration", 0 );
|
||||
float opacity = conf.readEntry( "Opacity", 80 );
|
||||
bool desktopOpacityOnly = conf.readEntry( "OpacityDesktopOnly", false );
|
||||
bool desktopName = conf.readEntry( "DisplayDesktopName", true );
|
||||
bool reflection = conf.readEntry( "Reflection", true );
|
||||
QColor background = conf.readEntry( "BackgroundColor", QColor( Qt::black ) );
|
||||
QColor capColor = conf.readEntry( "CapColor", KColorScheme( QPalette::Active, KColorScheme::Window ).background().color() );
|
||||
bool texturedCaps = conf.readEntry( "TexturedCaps", true );
|
||||
bool caps = conf.readEntry( "Caps", true );
|
||||
bool closeOnMouseRelease = conf.readEntry( "CloseOnMouseRelease", false );
|
||||
bool walkThroughDesktop = conf.readEntry( "TabBox", false );
|
||||
m_ui->zPositionSlider->setValue( conf.readEntry( "ZPosition", 100 ) );
|
||||
m_ui->wallpaperRequester->setUrl( KUrl( conf.readEntry( "Wallpaper", "" ) ));
|
||||
bool invertKeys = conf.readEntry( "InvertKeys", false );
|
||||
bool invertMouse = conf.readEntry( "InvertMouse", false );
|
||||
m_ui->capDeformationSlider->setValue( conf.readEntry( "CapDeformation", 0 ) );
|
||||
bool zOrdering = conf.readEntry( "ZOrdering", false );
|
||||
int duration = conf.readEntry("RotationDuration", 0);
|
||||
float opacity = conf.readEntry("Opacity", 80);
|
||||
bool desktopOpacityOnly = conf.readEntry("OpacityDesktopOnly", false);
|
||||
bool desktopName = conf.readEntry("DisplayDesktopName", true);
|
||||
bool reflection = conf.readEntry("Reflection", true);
|
||||
QColor background = conf.readEntry("BackgroundColor", QColor(Qt::black));
|
||||
QColor capColor = conf.readEntry("CapColor", KColorScheme(QPalette::Active, KColorScheme::Window).background().color());
|
||||
bool texturedCaps = conf.readEntry("TexturedCaps", true);
|
||||
bool caps = conf.readEntry("Caps", true);
|
||||
bool closeOnMouseRelease = conf.readEntry("CloseOnMouseRelease", false);
|
||||
bool walkThroughDesktop = conf.readEntry("TabBox", false);
|
||||
m_ui->zPositionSlider->setValue(conf.readEntry("ZPosition", 100));
|
||||
m_ui->wallpaperRequester->setUrl(KUrl(conf.readEntry("Wallpaper", "")));
|
||||
bool invertKeys = conf.readEntry("InvertKeys", false);
|
||||
bool invertMouse = conf.readEntry("InvertMouse", false);
|
||||
m_ui->capDeformationSlider->setValue(conf.readEntry("CapDeformation", 0));
|
||||
bool zOrdering = conf.readEntry("ZOrdering", false);
|
||||
|
||||
m_ui->rotationDurationSpin->setValue( duration );
|
||||
m_ui->rotationDurationSpin->setSuffix( ki18np( " millisecond", " milliseconds" ) );
|
||||
m_ui->cubeOpacitySlider->setValue( opacity );
|
||||
m_ui->cubeOpacitySpin->setValue( opacity );
|
||||
m_ui->desktopOpacityOnlyBox->setChecked( desktopOpacityOnly );
|
||||
if( desktopName )
|
||||
{
|
||||
m_ui->displayDesktopNameBox->setCheckState( Qt::Checked );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->displayDesktopNameBox->setCheckState( Qt::Unchecked );
|
||||
}
|
||||
if( reflection )
|
||||
{
|
||||
m_ui->reflectionBox->setCheckState( Qt::Checked );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->reflectionBox->setCheckState( Qt::Unchecked );
|
||||
}
|
||||
if( caps )
|
||||
{
|
||||
m_ui->cubeCapsBox->setCheckState( Qt::Checked );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->cubeCapsBox->setCheckState( Qt::Unchecked );
|
||||
}
|
||||
if( texturedCaps )
|
||||
{
|
||||
m_ui->capsImageBox->setCheckState( Qt::Checked );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->capsImageBox->setCheckState( Qt::Unchecked );
|
||||
}
|
||||
if( closeOnMouseRelease )
|
||||
{
|
||||
m_ui->closeOnMouseReleaseBox->setCheckState( Qt::Checked );
|
||||
}
|
||||
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 );
|
||||
m_ui->rotationDurationSpin->setValue(duration);
|
||||
m_ui->rotationDurationSpin->setSuffix(ki18np(" millisecond", " milliseconds"));
|
||||
m_ui->cubeOpacitySlider->setValue(opacity);
|
||||
m_ui->cubeOpacitySpin->setValue(opacity);
|
||||
m_ui->desktopOpacityOnlyBox->setChecked(desktopOpacityOnly);
|
||||
if (desktopName) {
|
||||
m_ui->displayDesktopNameBox->setCheckState(Qt::Checked);
|
||||
} else {
|
||||
m_ui->displayDesktopNameBox->setCheckState(Qt::Unchecked);
|
||||
}
|
||||
if (reflection) {
|
||||
m_ui->reflectionBox->setCheckState(Qt::Checked);
|
||||
} else {
|
||||
m_ui->reflectionBox->setCheckState(Qt::Unchecked);
|
||||
}
|
||||
if (caps) {
|
||||
m_ui->cubeCapsBox->setCheckState(Qt::Checked);
|
||||
} else {
|
||||
m_ui->cubeCapsBox->setCheckState(Qt::Unchecked);
|
||||
}
|
||||
if (texturedCaps) {
|
||||
m_ui->capsImageBox->setCheckState(Qt::Checked);
|
||||
} else {
|
||||
m_ui->capsImageBox->setCheckState(Qt::Unchecked);
|
||||
}
|
||||
if (closeOnMouseRelease) {
|
||||
m_ui->closeOnMouseReleaseBox->setCheckState(Qt::Checked);
|
||||
} 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();
|
||||
|
||||
emit changed(false);
|
||||
}
|
||||
}
|
||||
|
||||
void CubeEffectConfig::save()
|
||||
{
|
||||
KConfigGroup conf = EffectsHandler::effectConfig( "Cube" );
|
||||
{
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("Cube");
|
||||
|
||||
conf.writeEntry( "RotationDuration", m_ui->rotationDurationSpin->value() );
|
||||
conf.writeEntry( "DisplayDesktopName", m_ui->displayDesktopNameBox->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( "OpacityDesktopOnly", m_ui->desktopOpacityOnlyBox->isChecked() );
|
||||
conf.writeEntry( "BackgroundColor", m_ui->backgroundColorButton->color() );
|
||||
conf.writeEntry( "Caps", m_ui->cubeCapsBox->checkState() == Qt::Checked ? true : false );
|
||||
conf.writeEntry( "CapColor", m_ui->capColorButton->color() );
|
||||
conf.writeEntry( "TexturedCaps", m_ui->capsImageBox->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( "ZPosition", m_ui->zPositionSlider->value() );
|
||||
conf.writeEntry( "TabBox", m_ui->walkThroughDesktopBox->checkState() == Qt::Checked ? true : false );
|
||||
conf.writeEntry( "InvertKeys", m_ui->invertKeysBox->isChecked() );
|
||||
conf.writeEntry( "InvertMouse", m_ui->invertMouseBox->isChecked() );
|
||||
conf.writeEntry( "CapDeformation", m_ui->capDeformationSlider->value() );
|
||||
conf.writeEntry( "ZOrdering", m_ui->zOrderingBox->isChecked() );
|
||||
conf.writeEntry("RotationDuration", m_ui->rotationDurationSpin->value());
|
||||
conf.writeEntry("DisplayDesktopName", m_ui->displayDesktopNameBox->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("OpacityDesktopOnly", m_ui->desktopOpacityOnlyBox->isChecked());
|
||||
conf.writeEntry("BackgroundColor", m_ui->backgroundColorButton->color());
|
||||
conf.writeEntry("Caps", m_ui->cubeCapsBox->checkState() == Qt::Checked ? true : false);
|
||||
conf.writeEntry("CapColor", m_ui->capColorButton->color());
|
||||
conf.writeEntry("TexturedCaps", m_ui->capsImageBox->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("ZPosition", m_ui->zPositionSlider->value());
|
||||
conf.writeEntry("TabBox", m_ui->walkThroughDesktopBox->checkState() == Qt::Checked ? true : false);
|
||||
conf.writeEntry("InvertKeys", m_ui->invertKeysBox->isChecked());
|
||||
conf.writeEntry("InvertMouse", m_ui->invertMouseBox->isChecked());
|
||||
conf.writeEntry("CapDeformation", m_ui->capDeformationSlider->value());
|
||||
conf.writeEntry("ZOrdering", m_ui->zOrderingBox->isChecked());
|
||||
|
||||
m_ui->editor->save();
|
||||
|
||||
conf.sync();
|
||||
|
||||
emit changed(false);
|
||||
EffectsHandler::sendReloadMessage( "cube" );
|
||||
}
|
||||
EffectsHandler::sendReloadMessage("cube");
|
||||
}
|
||||
|
||||
void CubeEffectConfig::defaults()
|
||||
{
|
||||
m_ui->rotationDurationSpin->setValue( 0 );
|
||||
m_ui->displayDesktopNameBox->setCheckState( Qt::Checked );
|
||||
m_ui->reflectionBox->setCheckState( Qt::Checked );
|
||||
m_ui->cubeOpacitySpin->setValue( 80 );
|
||||
m_ui->cubeOpacitySlider->setValue( 80 );
|
||||
m_ui->desktopOpacityOnlyBox->setChecked( false );
|
||||
m_ui->backgroundColorButton->setColor( QColor( Qt::black ) );
|
||||
m_ui->cubeCapsBox->setCheckState( Qt::Checked );
|
||||
m_ui->capColorButton->setColor( KColorScheme( QPalette::Active, KColorScheme::Window ).background().color() );
|
||||
m_ui->capsImageBox->setCheckState( Qt::Checked );
|
||||
m_ui->closeOnMouseReleaseBox->setCheckState( Qt::Unchecked );
|
||||
m_ui->wallpaperRequester->setUrl( KUrl( "" ));
|
||||
m_ui->zPositionSlider->setValue( 100 );
|
||||
m_ui->walkThroughDesktopBox->setCheckState( Qt::Unchecked );
|
||||
m_ui->invertKeysBox->setChecked( false );
|
||||
m_ui->invertMouseBox->setChecked( false );
|
||||
m_ui->capDeformationSlider->setValue( 0 );
|
||||
m_ui->zOrderingBox->setChecked( false );
|
||||
{
|
||||
m_ui->rotationDurationSpin->setValue(0);
|
||||
m_ui->displayDesktopNameBox->setCheckState(Qt::Checked);
|
||||
m_ui->reflectionBox->setCheckState(Qt::Checked);
|
||||
m_ui->cubeOpacitySpin->setValue(80);
|
||||
m_ui->cubeOpacitySlider->setValue(80);
|
||||
m_ui->desktopOpacityOnlyBox->setChecked(false);
|
||||
m_ui->backgroundColorButton->setColor(QColor(Qt::black));
|
||||
m_ui->cubeCapsBox->setCheckState(Qt::Checked);
|
||||
m_ui->capColorButton->setColor(KColorScheme(QPalette::Active, KColorScheme::Window).background().color());
|
||||
m_ui->capsImageBox->setCheckState(Qt::Checked);
|
||||
m_ui->closeOnMouseReleaseBox->setCheckState(Qt::Unchecked);
|
||||
m_ui->wallpaperRequester->setUrl(KUrl(""));
|
||||
m_ui->zPositionSlider->setValue(100);
|
||||
m_ui->walkThroughDesktopBox->setCheckState(Qt::Unchecked);
|
||||
m_ui->invertKeysBox->setChecked(false);
|
||||
m_ui->invertMouseBox->setChecked(false);
|
||||
m_ui->capDeformationSlider->setValue(0);
|
||||
m_ui->zOrderingBox->setChecked(false);
|
||||
m_ui->editor->allDefault();
|
||||
emit changed(true);
|
||||
}
|
||||
}
|
||||
|
||||
void CubeEffectConfig::capsSelectionChanged()
|
||||
{
|
||||
if( m_ui->cubeCapsBox->checkState() == Qt::Checked )
|
||||
{
|
||||
{
|
||||
if (m_ui->cubeCapsBox->checkState() == Qt::Checked) {
|
||||
// activate cap color
|
||||
m_ui->capColorButton->setEnabled( true );
|
||||
m_ui->capColorLabel->setEnabled( true );
|
||||
m_ui->capsImageBox->setEnabled( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->capColorButton->setEnabled(true);
|
||||
m_ui->capColorLabel->setEnabled(true);
|
||||
m_ui->capsImageBox->setEnabled(true);
|
||||
} else {
|
||||
// deactivate cap color
|
||||
m_ui->capColorButton->setEnabled( false );
|
||||
m_ui->capColorLabel->setEnabled( false );
|
||||
m_ui->capsImageBox->setEnabled( false );
|
||||
}
|
||||
}
|
||||
m_ui->capColorButton->setEnabled(false);
|
||||
m_ui->capColorLabel->setEnabled(false);
|
||||
m_ui->capsImageBox->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -32,27 +32,27 @@ namespace KWin
|
|||
class CubeEffectConfigForm : public QWidget, public Ui::CubeEffectConfigForm
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CubeEffectConfigForm(QWidget* parent);
|
||||
public:
|
||||
explicit CubeEffectConfigForm(QWidget* parent);
|
||||
};
|
||||
|
||||
class CubeEffectConfig : public KCModule
|
||||
{
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CubeEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
|
||||
public:
|
||||
explicit CubeEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
|
||||
|
||||
public slots:
|
||||
virtual void save();
|
||||
virtual void load();
|
||||
virtual void defaults();
|
||||
public slots:
|
||||
virtual void save();
|
||||
virtual void load();
|
||||
virtual void defaults();
|
||||
|
||||
private slots:
|
||||
void capsSelectionChanged();
|
||||
private:
|
||||
CubeEffectConfigForm* m_ui;
|
||||
KActionCollection* m_actionCollection;
|
||||
};
|
||||
private slots:
|
||||
void capsSelectionChanged();
|
||||
private:
|
||||
CubeEffectConfigForm* m_ui;
|
||||
KActionCollection* m_actionCollection;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -27,12 +27,12 @@ namespace KWin
|
|||
|
||||
class CubeInsideEffect : public Effect
|
||||
{
|
||||
public:
|
||||
CubeInsideEffect() {}
|
||||
virtual ~CubeInsideEffect() {}
|
||||
public:
|
||||
CubeInsideEffect() {}
|
||||
virtual ~CubeInsideEffect() {}
|
||||
|
||||
virtual void paint() = 0;
|
||||
virtual void setActive( bool active ) = 0;
|
||||
virtual void paint() = 0;
|
||||
virtual void setActive(bool active) = 0;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -25,23 +25,23 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
CubeEffectProxy::CubeEffectProxy( CubeEffect* effect )
|
||||
: m_effect( effect )
|
||||
{
|
||||
}
|
||||
CubeEffectProxy::CubeEffectProxy(CubeEffect* effect)
|
||||
: m_effect(effect)
|
||||
{
|
||||
}
|
||||
|
||||
CubeEffectProxy::~CubeEffectProxy()
|
||||
{
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
void CubeEffectProxy::registerCubeInsideEffect( CubeInsideEffect* effect )
|
||||
{
|
||||
m_effect->registerCubeInsideEffect( effect );
|
||||
}
|
||||
void CubeEffectProxy::registerCubeInsideEffect(CubeInsideEffect* effect)
|
||||
{
|
||||
m_effect->registerCubeInsideEffect(effect);
|
||||
}
|
||||
|
||||
void CubeEffectProxy::unregisterCubeInsideEffect( CubeInsideEffect* effect )
|
||||
{
|
||||
m_effect->unregisterCubeInsideEffect( effect );
|
||||
}
|
||||
void CubeEffectProxy::unregisterCubeInsideEffect(CubeInsideEffect* effect)
|
||||
{
|
||||
m_effect->unregisterCubeInsideEffect(effect);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -29,15 +29,15 @@ class CubeInsideEffect;
|
|||
|
||||
class CubeEffectProxy
|
||||
{
|
||||
public:
|
||||
CubeEffectProxy( CubeEffect* effect );
|
||||
~CubeEffectProxy();
|
||||
public:
|
||||
CubeEffectProxy(CubeEffect* effect);
|
||||
~CubeEffectProxy();
|
||||
|
||||
void registerCubeInsideEffect( CubeInsideEffect* effect );
|
||||
void unregisterCubeInsideEffect( CubeInsideEffect* effect );
|
||||
void registerCubeInsideEffect(CubeInsideEffect* effect);
|
||||
void unregisterCubeInsideEffect(CubeInsideEffect* effect);
|
||||
|
||||
private:
|
||||
CubeEffect* m_effect;
|
||||
private:
|
||||
CubeEffect* m_effect;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -30,48 +30,47 @@ namespace KWin
|
|||
{
|
||||
class CubeSlideEffect
|
||||
: public Effect
|
||||
{
|
||||
public:
|
||||
CubeSlideEffect();
|
||||
~CubeSlideEffect();
|
||||
virtual void reconfigure( ReconfigureFlags );
|
||||
virtual void prePaintScreen( ScreenPrePaintData& data, int time );
|
||||
virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data );
|
||||
virtual void postPaintScreen();
|
||||
virtual void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time );
|
||||
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data );
|
||||
virtual void desktopChanged( int old );
|
||||
virtual void windowUserMovedResized( EffectWindow* c, bool first, bool last );
|
||||
{
|
||||
public:
|
||||
CubeSlideEffect();
|
||||
~CubeSlideEffect();
|
||||
virtual void reconfigure(ReconfigureFlags);
|
||||
virtual void prePaintScreen(ScreenPrePaintData& data, int time);
|
||||
virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data);
|
||||
virtual void postPaintScreen();
|
||||
virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time);
|
||||
virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
|
||||
virtual void desktopChanged(int old);
|
||||
virtual void windowUserMovedResized(EffectWindow* c, bool first, bool last);
|
||||
|
||||
static bool supported();
|
||||
private:
|
||||
enum RotationDirection
|
||||
{
|
||||
Left,
|
||||
Right,
|
||||
Upwards,
|
||||
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;
|
||||
static bool supported();
|
||||
private:
|
||||
enum RotationDirection {
|
||||
Left,
|
||||
Right,
|
||||
Upwards,
|
||||
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;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -30,12 +30,12 @@ KWIN_EFFECT_CONFIG_FACTORY
|
|||
|
||||
CubeSlideEffectConfigForm::CubeSlideEffectConfigForm(QWidget* parent) : QWidget(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
setupUi(this);
|
||||
}
|
||||
|
||||
CubeSlideEffectConfig::CubeSlideEffectConfig(QWidget* parent, const QVariantList& args) :
|
||||
KCModule(EffectFactory::componentData(), parent, args)
|
||||
{
|
||||
KCModule(EffectFactory::componentData(), parent, args)
|
||||
{
|
||||
m_ui = new CubeSlideEffectConfigForm(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()));
|
||||
|
||||
load();
|
||||
}
|
||||
}
|
||||
|
||||
void CubeSlideEffectConfig::load()
|
||||
{
|
||||
{
|
||||
KCModule::load();
|
||||
|
||||
KConfigGroup conf = EffectsHandler::effectConfig( "CubeSlide" );
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("CubeSlide");
|
||||
|
||||
int duration = conf.readEntry( "RotationDuration", 0 );
|
||||
bool dontSlidePanels = conf.readEntry( "DontSlidePanels", true );
|
||||
bool dontSlideStickyWindows = conf.readEntry( "DontSlideStickyWindows", false );
|
||||
bool usePager = conf.readEntry( "UsePagerLayout", true );
|
||||
int duration = conf.readEntry("RotationDuration", 0);
|
||||
bool dontSlidePanels = conf.readEntry("DontSlidePanels", true);
|
||||
bool dontSlideStickyWindows = conf.readEntry("DontSlideStickyWindows", false);
|
||||
bool usePager = conf.readEntry("UsePagerLayout", true);
|
||||
|
||||
m_ui->rotationDurationSpin->setValue( duration );
|
||||
m_ui->dontSlidePanelsBox->setChecked( dontSlidePanels );
|
||||
m_ui->dontSlideStickyWindowsBox->setChecked( dontSlideStickyWindows );
|
||||
m_ui->usePagerBox->setChecked( usePager );
|
||||
m_ui->windowsMovingBox->setChecked( conf.readEntry( "UseWindowMoving", false ) );
|
||||
m_ui->rotationDurationSpin->setValue(duration);
|
||||
m_ui->dontSlidePanelsBox->setChecked(dontSlidePanels);
|
||||
m_ui->dontSlideStickyWindowsBox->setChecked(dontSlideStickyWindows);
|
||||
m_ui->usePagerBox->setChecked(usePager);
|
||||
m_ui->windowsMovingBox->setChecked(conf.readEntry("UseWindowMoving", false));
|
||||
|
||||
emit changed(false);
|
||||
}
|
||||
}
|
||||
|
||||
void CubeSlideEffectConfig::save()
|
||||
{
|
||||
KConfigGroup conf = EffectsHandler::effectConfig( "CubeSlide" );
|
||||
{
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("CubeSlide");
|
||||
|
||||
conf.writeEntry( "RotationDuration", m_ui->rotationDurationSpin->value() );
|
||||
conf.writeEntry( "DontSlidePanels", m_ui->dontSlidePanelsBox->isChecked() );
|
||||
conf.writeEntry( "DontSlideStickyWindows", m_ui->dontSlideStickyWindowsBox->isChecked() );
|
||||
conf.writeEntry( "UsePagerLayout", m_ui->usePagerBox->isChecked() );
|
||||
conf.writeEntry( "UseWindowMoving", m_ui->windowsMovingBox->isChecked() );
|
||||
conf.writeEntry("RotationDuration", m_ui->rotationDurationSpin->value());
|
||||
conf.writeEntry("DontSlidePanels", m_ui->dontSlidePanelsBox->isChecked());
|
||||
conf.writeEntry("DontSlideStickyWindows", m_ui->dontSlideStickyWindowsBox->isChecked());
|
||||
conf.writeEntry("UsePagerLayout", m_ui->usePagerBox->isChecked());
|
||||
conf.writeEntry("UseWindowMoving", m_ui->windowsMovingBox->isChecked());
|
||||
|
||||
conf.sync();
|
||||
|
||||
emit changed(false);
|
||||
EffectsHandler::sendReloadMessage( "cubeslide" );
|
||||
}
|
||||
EffectsHandler::sendReloadMessage("cubeslide");
|
||||
}
|
||||
|
||||
void CubeSlideEffectConfig::defaults()
|
||||
{
|
||||
m_ui->rotationDurationSpin->setValue( 0 );
|
||||
m_ui->dontSlidePanelsBox->setChecked( true );
|
||||
m_ui->dontSlideStickyWindowsBox->setChecked( false );
|
||||
m_ui->usePagerBox->setChecked( true );
|
||||
m_ui->windowsMovingBox->setChecked( false );
|
||||
{
|
||||
m_ui->rotationDurationSpin->setValue(0);
|
||||
m_ui->dontSlidePanelsBox->setChecked(true);
|
||||
m_ui->dontSlideStickyWindowsBox->setChecked(false);
|
||||
m_ui->usePagerBox->setChecked(true);
|
||||
m_ui->windowsMovingBox->setChecked(false);
|
||||
emit changed(true);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -32,23 +32,23 @@ namespace KWin
|
|||
class CubeSlideEffectConfigForm : public QWidget, public Ui::CubeSlideEffectConfigForm
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CubeSlideEffectConfigForm(QWidget* parent);
|
||||
public:
|
||||
explicit CubeSlideEffectConfigForm(QWidget* parent);
|
||||
};
|
||||
|
||||
class CubeSlideEffectConfig : public KCModule
|
||||
{
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CubeSlideEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
|
||||
public:
|
||||
explicit CubeSlideEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
|
||||
|
||||
public slots:
|
||||
virtual void save();
|
||||
virtual void load();
|
||||
virtual void defaults();
|
||||
private:
|
||||
CubeSlideEffectConfigForm* m_ui;
|
||||
};
|
||||
public slots:
|
||||
virtual void save();
|
||||
virtual void load();
|
||||
virtual void defaults();
|
||||
private:
|
||||
CubeSlideEffectConfigForm* m_ui;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -25,41 +25,41 @@ namespace KWin
|
|||
KWIN_EFFECT(dashboard, DashboardEffect)
|
||||
|
||||
DashboardEffect::DashboardEffect()
|
||||
: transformWindow( false )
|
||||
, activateAnimation( false )
|
||||
, deactivateAnimation( false )
|
||||
{
|
||||
: transformWindow(false)
|
||||
, activateAnimation(false)
|
||||
, deactivateAnimation(false)
|
||||
{
|
||||
// propagate that the effect is loaded
|
||||
propagate();
|
||||
|
||||
// read settings
|
||||
reconfigure(ReconfigureAll);
|
||||
}
|
||||
}
|
||||
|
||||
DashboardEffect::~DashboardEffect()
|
||||
{
|
||||
{
|
||||
unpropagate();
|
||||
}
|
||||
}
|
||||
|
||||
void DashboardEffect::propagate()
|
||||
{
|
||||
{
|
||||
// TODO: better namespacing for atoms
|
||||
atom = XInternAtom( display(), "_WM_EFFECT_KDE_DASHBOARD", false );
|
||||
effects->registerPropertyType( atom, true );
|
||||
atom = XInternAtom(display(), "_WM_EFFECT_KDE_DASHBOARD", false);
|
||||
effects->registerPropertyType(atom, true);
|
||||
|
||||
// TODO: maybe not the best way to propagate the loaded effect
|
||||
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()
|
||||
{
|
||||
{
|
||||
effects->registerPropertyType(atom, false);
|
||||
XDeleteProperty(display(), rootWindow(), atom);
|
||||
}
|
||||
}
|
||||
|
||||
void DashboardEffect::reconfigure( ReconfigureFlags )
|
||||
{
|
||||
void DashboardEffect::reconfigure(ReconfigureFlags)
|
||||
{
|
||||
// read settings again
|
||||
KConfigGroup config = EffectsHandler::effectConfig("Dashboard");
|
||||
|
||||
|
@ -69,153 +69,132 @@ void DashboardEffect::reconfigure( ReconfigureFlags )
|
|||
|
||||
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 )
|
||||
{
|
||||
if( transformWindow && ( w != window ) && w->isManaged() && !isDashboard( w ) )
|
||||
{
|
||||
void DashboardEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
|
||||
{
|
||||
if (transformWindow && (w != window) && w->isManaged() && !isDashboard(w)) {
|
||||
brightnessDelta = (1 - (brightness.toDouble() / 100));
|
||||
saturationDelta = (1 - (saturation.toDouble() / 100));
|
||||
|
||||
// dashboard active, transform other windows
|
||||
data.brightness *= (1 - (brightnessDelta * timeline.value()));
|
||||
data.saturation *= (1 - (saturationDelta * timeline.value()));
|
||||
}
|
||||
}
|
||||
|
||||
else if( transformWindow && ( w == window ) && w->isManaged() )
|
||||
{
|
||||
else if (transformWindow && (w == window) && w->isManaged()) {
|
||||
// transform dashboard
|
||||
if ((timeline.value() * 2) <= 1)
|
||||
{
|
||||
if ((timeline.value() * 2) <= 1) {
|
||||
data.opacity *= timeline.value() * 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
data.opacity *= 1;
|
||||
}
|
||||
}
|
||||
|
||||
effects->paintWindow( w, mask, region, data );
|
||||
}
|
||||
|
||||
void DashboardEffect::prePaintScreen( ScreenPrePaintData& data, int time )
|
||||
{
|
||||
if( transformWindow )
|
||||
{
|
||||
if( activateAnimation )
|
||||
timeline.addTime( time );
|
||||
if( deactivateAnimation )
|
||||
timeline.removeTime( time );
|
||||
}
|
||||
effects->paintWindow(w, mask, region, data);
|
||||
}
|
||||
|
||||
void DashboardEffect::prePaintScreen(ScreenPrePaintData& data, int time)
|
||||
{
|
||||
if (transformWindow) {
|
||||
if (activateAnimation)
|
||||
timeline.addTime(time);
|
||||
if (deactivateAnimation)
|
||||
timeline.removeTime(time);
|
||||
}
|
||||
effects->prePaintScreen(data, time);
|
||||
}
|
||||
}
|
||||
|
||||
void DashboardEffect::postPaintScreen()
|
||||
{
|
||||
if( transformWindow )
|
||||
{
|
||||
if( retransformWindow )
|
||||
{
|
||||
{
|
||||
if (transformWindow) {
|
||||
if (retransformWindow) {
|
||||
retransformWindow = false;
|
||||
transformWindow = false;
|
||||
effects->addRepaintFull();
|
||||
effects->setActiveFullScreenEffect( 0 );
|
||||
}
|
||||
effects->setActiveFullScreenEffect(0);
|
||||
}
|
||||
|
||||
if( activateAnimation )
|
||||
{
|
||||
if( timeline.value() == 1.0 )
|
||||
if (activateAnimation) {
|
||||
if (timeline.value() == 1.0)
|
||||
activateAnimation = false;
|
||||
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
}
|
||||
|
||||
if( deactivateAnimation )
|
||||
{
|
||||
if( timeline.value() == 0.0 )
|
||||
{
|
||||
if (deactivateAnimation) {
|
||||
if (timeline.value() == 0.0) {
|
||||
deactivateAnimation = false;
|
||||
transformWindow = false;
|
||||
effects->setActiveFullScreenEffect( 0 );
|
||||
}
|
||||
effects->setActiveFullScreenEffect(0);
|
||||
}
|
||||
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
effects->postPaintScreen();
|
||||
}
|
||||
}
|
||||
|
||||
bool DashboardEffect::isDashboard ( EffectWindow *w )
|
||||
{
|
||||
if( w->windowClass() == "dashboard dashboard")
|
||||
{
|
||||
bool DashboardEffect::isDashboard(EffectWindow *w)
|
||||
{
|
||||
if (w->windowClass() == "dashboard dashboard") {
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DashboardEffect::windowActivated( EffectWindow *w )
|
||||
{
|
||||
if( !w )
|
||||
void DashboardEffect::windowActivated(EffectWindow *w)
|
||||
{
|
||||
if (!w)
|
||||
return;
|
||||
|
||||
// apply effect on dashboard activation
|
||||
if( isDashboard( w ) )
|
||||
{
|
||||
effects->setActiveFullScreenEffect( this );
|
||||
if (isDashboard(w)) {
|
||||
effects->setActiveFullScreenEffect(this);
|
||||
transformWindow = true;
|
||||
window = w;
|
||||
|
||||
if ( blur )
|
||||
{
|
||||
w->setData( WindowBlurBehindRole, w->geometry() );
|
||||
}
|
||||
if (blur) {
|
||||
w->setData(WindowBlurBehindRole, w->geometry());
|
||||
}
|
||||
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
else
|
||||
{
|
||||
if( transformWindow)
|
||||
{
|
||||
} else {
|
||||
if (transformWindow) {
|
||||
retransformWindow = true;
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DashboardEffect::windowAdded( EffectWindow* w )
|
||||
{
|
||||
propertyNotify( w, atom );
|
||||
void DashboardEffect::windowAdded(EffectWindow* w)
|
||||
{
|
||||
propertyNotify(w, atom);
|
||||
|
||||
if( isDashboard( w ) )
|
||||
{
|
||||
if (isDashboard(w)) {
|
||||
// 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;
|
||||
deactivateAnimation = false;
|
||||
timeline.setProgress( 0.0 );
|
||||
timeline.setProgress(0.0);
|
||||
|
||||
w->addRepaintFull();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DashboardEffect::windowClosed( EffectWindow* w )
|
||||
{
|
||||
propertyNotify( w, atom );
|
||||
void DashboardEffect::windowClosed(EffectWindow* w)
|
||||
{
|
||||
propertyNotify(w, atom);
|
||||
|
||||
if( isDashboard( w ) )
|
||||
{
|
||||
if (isDashboard(w)) {
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -31,35 +31,35 @@ namespace KWin
|
|||
|
||||
|
||||
class DashboardEffect : public KWin::Effect
|
||||
{
|
||||
public:
|
||||
DashboardEffect();
|
||||
~DashboardEffect();
|
||||
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data );
|
||||
virtual void prePaintScreen( ScreenPrePaintData& data, int time );
|
||||
virtual void postPaintScreen();
|
||||
virtual void propagate();
|
||||
virtual void reconfigure( ReconfigureFlags );
|
||||
virtual void unpropagate();
|
||||
virtual void windowActivated( EffectWindow *w );
|
||||
virtual void windowAdded( EffectWindow* c );
|
||||
virtual void windowClosed( EffectWindow* c );
|
||||
private:
|
||||
bool blur;
|
||||
bool isDashboard( EffectWindow* w );
|
||||
bool transformWindow;
|
||||
bool retransformWindow;
|
||||
bool activateAnimation;
|
||||
bool deactivateAnimation;
|
||||
TimeLine timeline;
|
||||
long atom;
|
||||
QString brightness;
|
||||
double brightnessDelta;
|
||||
QString saturation;
|
||||
double saturationDelta;
|
||||
QString duration;
|
||||
EffectWindow* window;
|
||||
};
|
||||
{
|
||||
public:
|
||||
DashboardEffect();
|
||||
~DashboardEffect();
|
||||
virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
|
||||
virtual void prePaintScreen(ScreenPrePaintData& data, int time);
|
||||
virtual void postPaintScreen();
|
||||
virtual void propagate();
|
||||
virtual void reconfigure(ReconfigureFlags);
|
||||
virtual void unpropagate();
|
||||
virtual void windowActivated(EffectWindow *w);
|
||||
virtual void windowAdded(EffectWindow* c);
|
||||
virtual void windowClosed(EffectWindow* c);
|
||||
private:
|
||||
bool blur;
|
||||
bool isDashboard(EffectWindow* w);
|
||||
bool transformWindow;
|
||||
bool retransformWindow;
|
||||
bool activateAnimation;
|
||||
bool deactivateAnimation;
|
||||
TimeLine timeline;
|
||||
long atom;
|
||||
QString brightness;
|
||||
double brightnessDelta;
|
||||
QString saturation;
|
||||
double saturationDelta;
|
||||
QString duration;
|
||||
EffectWindow* window;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
void defaults();
|
||||
|
||||
private:
|
||||
bool isBlurEffectAvailable ();
|
||||
bool isBlurEffectAvailable();
|
||||
long net_wm_dashboard;
|
||||
::Ui::DashboardEffectConfig ui;
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -38,122 +38,122 @@ namespace KWin
|
|||
class PresentWindowsEffectProxy;
|
||||
|
||||
class DesktopButtonsView : public QGraphicsView
|
||||
{
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DesktopButtonsView( QWidget* parent = 0 );
|
||||
void windowInputMouseEvent( QMouseEvent* e );
|
||||
void setAddDesktopEnabled( bool enable );
|
||||
void setRemoveDesktopEnabled( bool enable );
|
||||
virtual void drawBackground( QPainter* painter, const QRectF& rect );
|
||||
public:
|
||||
DesktopButtonsView(QWidget* parent = 0);
|
||||
void windowInputMouseEvent(QMouseEvent* e);
|
||||
void setAddDesktopEnabled(bool enable);
|
||||
void setRemoveDesktopEnabled(bool enable);
|
||||
virtual void drawBackground(QPainter* painter, const QRectF& rect);
|
||||
|
||||
Q_SIGNALS:
|
||||
void addDesktop();
|
||||
void removeDesktop();
|
||||
Q_SIGNALS:
|
||||
void addDesktop();
|
||||
void removeDesktop();
|
||||
|
||||
private:
|
||||
Plasma::PushButton* m_addDesktopButton;
|
||||
Plasma::PushButton* m_removeDesktopButton;
|
||||
Plasma::FrameSvg* m_frame;
|
||||
};
|
||||
private:
|
||||
Plasma::PushButton* m_addDesktopButton;
|
||||
Plasma::PushButton* m_removeDesktopButton;
|
||||
Plasma::FrameSvg* m_frame;
|
||||
};
|
||||
|
||||
class DesktopGridEffect
|
||||
: public QObject, public Effect
|
||||
{
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DesktopGridEffect();
|
||||
~DesktopGridEffect();
|
||||
virtual void reconfigure( ReconfigureFlags );
|
||||
virtual void prePaintScreen( ScreenPrePaintData& data, int time );
|
||||
virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data );
|
||||
virtual void postPaintScreen();
|
||||
virtual void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time );
|
||||
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data );
|
||||
virtual void windowClosed( EffectWindow* w );
|
||||
virtual void windowDeleted( EffectWindow* w );
|
||||
virtual void windowAdded( EffectWindow* w );
|
||||
virtual void windowGeometryShapeChanged( EffectWindow* w, const QRect& old );
|
||||
virtual void windowInputMouseEvent( Window w, QEvent* e );
|
||||
virtual void grabbedKeyboardEvent( QKeyEvent* e );
|
||||
virtual bool borderActivated( ElectricBorder border );
|
||||
virtual void numberDesktopsChanged( int old );
|
||||
public:
|
||||
DesktopGridEffect();
|
||||
~DesktopGridEffect();
|
||||
virtual void reconfigure(ReconfigureFlags);
|
||||
virtual void prePaintScreen(ScreenPrePaintData& data, int time);
|
||||
virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data);
|
||||
virtual void postPaintScreen();
|
||||
virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time);
|
||||
virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
|
||||
virtual void windowClosed(EffectWindow* w);
|
||||
virtual void windowDeleted(EffectWindow* w);
|
||||
virtual void windowAdded(EffectWindow* w);
|
||||
virtual void windowGeometryShapeChanged(EffectWindow* w, const QRect& old);
|
||||
virtual void windowInputMouseEvent(Window w, QEvent* e);
|
||||
virtual void grabbedKeyboardEvent(QKeyEvent* e);
|
||||
virtual bool borderActivated(ElectricBorder border);
|
||||
virtual void numberDesktopsChanged(int old);
|
||||
|
||||
enum { LayoutPager, LayoutAutomatic, LayoutCustom }; // Layout modes
|
||||
enum { LayoutPager, LayoutAutomatic, LayoutCustom }; // Layout modes
|
||||
|
||||
private slots:
|
||||
void toggle();
|
||||
// slots for global shortcut changed
|
||||
// needed to toggle the effect
|
||||
void globalShortcutChanged( const QKeySequence& seq );
|
||||
void slotAddDesktop();
|
||||
void slotRemoveDesktop();
|
||||
private slots:
|
||||
void toggle();
|
||||
// slots for global shortcut changed
|
||||
// needed to toggle the effect
|
||||
void globalShortcutChanged(const QKeySequence& seq);
|
||||
void slotAddDesktop();
|
||||
void slotRemoveDesktop();
|
||||
|
||||
private:
|
||||
QPointF scalePos( const QPoint& pos, int desktop, int screen = -1 ) const;
|
||||
QPoint unscalePos( const QPoint& pos, int* desktop = NULL ) const;
|
||||
int posToDesktop( const QPoint& pos ) const;
|
||||
EffectWindow* windowAt( QPoint pos ) const;
|
||||
void setCurrentDesktop( int desktop );
|
||||
void setHighlightedDesktop( int desktop );
|
||||
int desktopToRight( int desktop, bool wrap = true ) const;
|
||||
int desktopToLeft( int desktop, bool wrap = true ) const;
|
||||
int desktopUp( int desktop, bool wrap = true ) const;
|
||||
int desktopDown( int desktop, bool wrap = true ) const;
|
||||
void setActive( bool active );
|
||||
void setup();
|
||||
void setupGrid();
|
||||
void finish();
|
||||
bool isMotionManagerMovingWindows();
|
||||
bool isUsingPresentWindows() const;
|
||||
QRectF moveGeometryToDesktop( int desktop ) const;
|
||||
void desktopsAdded( 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;
|
||||
private:
|
||||
QPointF scalePos(const QPoint& pos, int desktop, int screen = -1) const;
|
||||
QPoint unscalePos(const QPoint& pos, int* desktop = NULL) const;
|
||||
int posToDesktop(const QPoint& pos) const;
|
||||
EffectWindow* windowAt(QPoint pos) const;
|
||||
void setCurrentDesktop(int desktop);
|
||||
void setHighlightedDesktop(int desktop);
|
||||
int desktopToRight(int desktop, bool wrap = true) const;
|
||||
int desktopToLeft(int desktop, bool wrap = true) const;
|
||||
int desktopUp(int desktop, bool wrap = true) const;
|
||||
int desktopDown(int desktop, bool wrap = true) const;
|
||||
void setActive(bool active);
|
||||
void setup();
|
||||
void setupGrid();
|
||||
void finish();
|
||||
bool isMotionManagerMovingWindows();
|
||||
bool isUsingPresentWindows() const;
|
||||
QRectF moveGeometryToDesktop(int desktop) const;
|
||||
void desktopsAdded(int old);
|
||||
void desktopsRemoved(int old);
|
||||
|
||||
QList< EffectFrame* > desktopNames;
|
||||
QList<ElectricBorder> borderActivate;
|
||||
int zoomDuration;
|
||||
int border;
|
||||
Qt::Alignment desktopNameAlignment;
|
||||
int layoutMode;
|
||||
int customLayoutRows;
|
||||
|
||||
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;
|
||||
bool activated;
|
||||
TimeLine timeline;
|
||||
int paintingDesktop;
|
||||
int highlightedDesktop;
|
||||
Window input;
|
||||
bool keyboardGrab;
|
||||
bool wasWindowMove, wasDesktopMove;
|
||||
EffectWindow* windowMove;
|
||||
QPoint windowMoveDiff;
|
||||
QPoint dragStartPos;
|
||||
|
||||
// Shortcut - needed to toggle the effect
|
||||
KShortcut shortcut;
|
||||
// Soft highlighting
|
||||
QList<TimeLine> hoverTimeline;
|
||||
|
||||
PresentWindowsEffectProxy* m_proxy;
|
||||
QList<WindowMotionManager> m_managers;
|
||||
bool m_usePresentWindows;
|
||||
QRect m_windowMoveGeometry;
|
||||
QPoint m_windowMoveStartPoint;
|
||||
QList< EffectFrame* > desktopNames;
|
||||
|
||||
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
|
||||
|
||||
|
|
|
@ -35,149 +35,146 @@ KWIN_EFFECT_CONFIG_FACTORY
|
|||
|
||||
DesktopGridEffectConfigForm::DesktopGridEffectConfigForm(QWidget* parent) : QWidget(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
setupUi(this);
|
||||
}
|
||||
|
||||
DesktopGridEffectConfig::DesktopGridEffectConfig(QWidget* parent, const QVariantList& args)
|
||||
: KCModule( EffectFactory::componentData(), parent, args )
|
||||
{
|
||||
m_ui = new DesktopGridEffectConfigForm( this );
|
||||
: KCModule(EffectFactory::componentData(), parent, args)
|
||||
{
|
||||
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"!
|
||||
m_actionCollection = new KActionCollection( this, KComponentData("kwin") );
|
||||
m_actionCollection = new KActionCollection(this, KComponentData("kwin"));
|
||||
|
||||
m_actionCollection->setConfigGroup( "DesktopGrid" );
|
||||
m_actionCollection->setConfigGlobal( true );
|
||||
m_actionCollection->setConfigGroup("DesktopGrid");
|
||||
m_actionCollection->setConfigGlobal(true);
|
||||
|
||||
KAction* a = (KAction*) m_actionCollection->addAction( "ShowDesktopGrid" );
|
||||
a->setText( i18n( "Show Desktop Grid" ));
|
||||
a->setProperty( "isConfigurationAction", true );
|
||||
a->setGlobalShortcut( KShortcut( Qt::CTRL + Qt::Key_F8 ));
|
||||
KAction* a = (KAction*) m_actionCollection->addAction("ShowDesktopGrid");
|
||||
a->setText(i18n("Show Desktop Grid"));
|
||||
a->setProperty("isConfigurationAction", true);
|
||||
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_ui->desktopNameAlignmentCombo->addItem( i18nc( "Desktop name alignment:", "Disabled" ));
|
||||
m_alignmentItems.append( Qt::AlignHCenter | Qt::AlignTop );
|
||||
m_ui->desktopNameAlignmentCombo->addItem( i18n( "Top" ));
|
||||
m_alignmentItems.append( Qt::AlignRight | Qt::AlignTop );
|
||||
m_ui->desktopNameAlignmentCombo->addItem( i18n( "Top-Right" ));
|
||||
m_alignmentItems.append( Qt::AlignRight | Qt::AlignVCenter );
|
||||
m_ui->desktopNameAlignmentCombo->addItem( i18n( "Right" ));
|
||||
m_alignmentItems.append( Qt::AlignRight | Qt::AlignBottom );
|
||||
m_ui->desktopNameAlignmentCombo->addItem( i18n( "Bottom-Right" ));
|
||||
m_alignmentItems.append( Qt::AlignHCenter | Qt::AlignBottom );
|
||||
m_ui->desktopNameAlignmentCombo->addItem( i18n( "Bottom" ));
|
||||
m_alignmentItems.append( Qt::AlignLeft | Qt::AlignBottom );
|
||||
m_ui->desktopNameAlignmentCombo->addItem( i18n( "Bottom-Left" ));
|
||||
m_alignmentItems.append( Qt::AlignLeft | Qt::AlignVCenter );
|
||||
m_ui->desktopNameAlignmentCombo->addItem( i18n( "Left" ));
|
||||
m_alignmentItems.append( Qt::AlignLeft | Qt::AlignTop );
|
||||
m_ui->desktopNameAlignmentCombo->addItem( i18n( "Top-Left" ));
|
||||
m_alignmentItems.append( Qt::AlignCenter );
|
||||
m_ui->desktopNameAlignmentCombo->addItem( i18n( "Center" ));
|
||||
m_alignmentItems.append(Qt::Alignment(0));
|
||||
m_ui->desktopNameAlignmentCombo->addItem(i18nc("Desktop name alignment:", "Disabled"));
|
||||
m_alignmentItems.append(Qt::AlignHCenter | Qt::AlignTop);
|
||||
m_ui->desktopNameAlignmentCombo->addItem(i18n("Top"));
|
||||
m_alignmentItems.append(Qt::AlignRight | Qt::AlignTop);
|
||||
m_ui->desktopNameAlignmentCombo->addItem(i18n("Top-Right"));
|
||||
m_alignmentItems.append(Qt::AlignRight | Qt::AlignVCenter);
|
||||
m_ui->desktopNameAlignmentCombo->addItem(i18n("Right"));
|
||||
m_alignmentItems.append(Qt::AlignRight | Qt::AlignBottom);
|
||||
m_ui->desktopNameAlignmentCombo->addItem(i18n("Bottom-Right"));
|
||||
m_alignmentItems.append(Qt::AlignHCenter | Qt::AlignBottom);
|
||||
m_ui->desktopNameAlignmentCombo->addItem(i18n("Bottom"));
|
||||
m_alignmentItems.append(Qt::AlignLeft | Qt::AlignBottom);
|
||||
m_ui->desktopNameAlignmentCombo->addItem(i18n("Bottom-Left"));
|
||||
m_alignmentItems.append(Qt::AlignLeft | Qt::AlignVCenter);
|
||||
m_ui->desktopNameAlignmentCombo->addItem(i18n("Left"));
|
||||
m_alignmentItems.append(Qt::AlignLeft | Qt::AlignTop);
|
||||
m_ui->desktopNameAlignmentCombo->addItem(i18n("Top-Left"));
|
||||
m_alignmentItems.append(Qt::AlignCenter);
|
||||
m_ui->desktopNameAlignmentCombo->addItem(i18n("Center"));
|
||||
|
||||
connect( m_ui->zoomDurationSpin, 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->layoutCombo, SIGNAL( currentIndexChanged( int )), this, SLOT( changed() ));
|
||||
connect( m_ui->layoutCombo, SIGNAL( currentIndexChanged( int )), this, SLOT( layoutSelectionChanged() ));
|
||||
connect( m_ui->layoutRowsSpin, SIGNAL( valueChanged( int )), 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->zoomDurationSpin, 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->layoutCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
|
||||
connect(m_ui->layoutCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(layoutSelectionChanged()));
|
||||
connect(m_ui->layoutRowsSpin, SIGNAL(valueChanged(int)), this, SLOT(changed()));
|
||||
connect(m_ui->shortcutEditor, SIGNAL(keyChange()), this, SLOT(changed()));
|
||||
connect(m_ui->presentWindowsCheckBox, SIGNAL(stateChanged(int)), this, SLOT(changed()));
|
||||
|
||||
load();
|
||||
}
|
||||
}
|
||||
|
||||
DesktopGridEffectConfig::~DesktopGridEffectConfig()
|
||||
{
|
||||
{
|
||||
// If save() is called undoChanges() has no effect
|
||||
m_ui->shortcutEditor->undoChanges();
|
||||
}
|
||||
}
|
||||
|
||||
void DesktopGridEffectConfig::load()
|
||||
{
|
||||
{
|
||||
KCModule::load();
|
||||
|
||||
KConfigGroup conf = EffectsHandler::effectConfig( "DesktopGrid" );
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("DesktopGrid");
|
||||
|
||||
m_ui->zoomDurationSpin->setValue( conf.readEntry( "ZoomDuration", 0 ));
|
||||
m_ui->zoomDurationSpin->setSuffix( ki18np( " millisecond", " milliseconds"));
|
||||
m_ui->borderWidthSpin->setValue( conf.readEntry( "BorderWidth", 10 ));
|
||||
m_ui->borderWidthSpin->setSuffix( ki18np( " pixel", " pixels"));
|
||||
m_ui->zoomDurationSpin->setValue(conf.readEntry("ZoomDuration", 0));
|
||||
m_ui->zoomDurationSpin->setSuffix(ki18np(" millisecond", " milliseconds"));
|
||||
m_ui->borderWidthSpin->setValue(conf.readEntry("BorderWidth", 10));
|
||||
m_ui->borderWidthSpin->setSuffix(ki18np(" pixel", " pixels"));
|
||||
|
||||
Qt::Alignment alignment = Qt::Alignment( conf.readEntry( "DesktopNameAlignment", 0 ));
|
||||
m_ui->desktopNameAlignmentCombo->setCurrentIndex( m_alignmentItems.indexOf( alignment ));
|
||||
Qt::Alignment alignment = Qt::Alignment(conf.readEntry("DesktopNameAlignment", 0));
|
||||
m_ui->desktopNameAlignmentCombo->setCurrentIndex(m_alignmentItems.indexOf(alignment));
|
||||
|
||||
int layoutMode = conf.readEntry( "LayoutMode", int( DesktopGridEffect::LayoutPager ));
|
||||
m_ui->layoutCombo->setCurrentIndex( layoutMode );
|
||||
int layoutMode = conf.readEntry("LayoutMode", int(DesktopGridEffect::LayoutPager));
|
||||
m_ui->layoutCombo->setCurrentIndex(layoutMode);
|
||||
layoutSelectionChanged();
|
||||
|
||||
m_ui->layoutRowsSpin->setValue( conf.readEntry( "CustomLayoutRows", 2 ));
|
||||
m_ui->layoutRowsSpin->setSuffix( ki18np( " row", " rows"));
|
||||
m_ui->layoutRowsSpin->setValue(conf.readEntry("CustomLayoutRows", 2));
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
void DesktopGridEffectConfig::save()
|
||||
{
|
||||
{
|
||||
KCModule::save();
|
||||
|
||||
KConfigGroup conf = EffectsHandler::effectConfig( "DesktopGrid" );
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("DesktopGrid");
|
||||
|
||||
conf.writeEntry( "ZoomDuration", m_ui->zoomDurationSpin->value() );
|
||||
conf.writeEntry( "BorderWidth", m_ui->borderWidthSpin->value() );
|
||||
conf.writeEntry("ZoomDuration", m_ui->zoomDurationSpin->value());
|
||||
conf.writeEntry("BorderWidth", m_ui->borderWidthSpin->value());
|
||||
|
||||
int alignment = m_ui->desktopNameAlignmentCombo->currentIndex();
|
||||
alignment = int( m_alignmentItems[alignment] );
|
||||
conf.writeEntry( "DesktopNameAlignment", alignment );
|
||||
alignment = int(m_alignmentItems[alignment]);
|
||||
conf.writeEntry("DesktopNameAlignment", alignment);
|
||||
|
||||
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();
|
||||
|
||||
conf.sync();
|
||||
|
||||
emit changed(false);
|
||||
EffectsHandler::sendReloadMessage( "desktopgrid" );
|
||||
}
|
||||
EffectsHandler::sendReloadMessage("desktopgrid");
|
||||
}
|
||||
|
||||
void DesktopGridEffectConfig::defaults()
|
||||
{
|
||||
m_ui->zoomDurationSpin->setValue( 0 );
|
||||
m_ui->borderWidthSpin->setValue( 10 );
|
||||
m_ui->desktopNameAlignmentCombo->setCurrentIndex( 0 );
|
||||
m_ui->layoutCombo->setCurrentIndex( int( DesktopGridEffect::LayoutPager ));
|
||||
m_ui->layoutRowsSpin->setValue( 2 );
|
||||
{
|
||||
m_ui->zoomDurationSpin->setValue(0);
|
||||
m_ui->borderWidthSpin->setValue(10);
|
||||
m_ui->desktopNameAlignmentCombo->setCurrentIndex(0);
|
||||
m_ui->layoutCombo->setCurrentIndex(int(DesktopGridEffect::LayoutPager));
|
||||
m_ui->layoutRowsSpin->setValue(2);
|
||||
m_ui->shortcutEditor->allDefault();
|
||||
m_ui->presentWindowsCheckBox->setChecked( true );
|
||||
m_ui->presentWindowsCheckBox->setChecked(true);
|
||||
emit changed(true);
|
||||
}
|
||||
}
|
||||
|
||||
void DesktopGridEffectConfig::layoutSelectionChanged()
|
||||
{
|
||||
if( m_ui->layoutCombo->currentIndex() == DesktopGridEffect::LayoutCustom )
|
||||
{
|
||||
m_ui->layoutRowsLabel->setEnabled( true );
|
||||
m_ui->layoutRowsSpin->setEnabled( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->layoutRowsLabel->setEnabled( false );
|
||||
m_ui->layoutRowsSpin->setEnabled( false );
|
||||
}
|
||||
{
|
||||
if (m_ui->layoutCombo->currentIndex() == DesktopGridEffect::LayoutCustom) {
|
||||
m_ui->layoutRowsLabel->setEnabled(true);
|
||||
m_ui->layoutRowsSpin->setEnabled(true);
|
||||
} else {
|
||||
m_ui->layoutRowsLabel->setEnabled(false);
|
||||
m_ui->layoutRowsSpin->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -33,30 +33,30 @@ namespace KWin
|
|||
class DesktopGridEffectConfigForm : public QWidget, public Ui::DesktopGridEffectConfigForm
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DesktopGridEffectConfigForm(QWidget* parent);
|
||||
public:
|
||||
explicit DesktopGridEffectConfigForm(QWidget* parent);
|
||||
};
|
||||
|
||||
class DesktopGridEffectConfig : public KCModule
|
||||
{
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DesktopGridEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
|
||||
~DesktopGridEffectConfig();
|
||||
public:
|
||||
explicit DesktopGridEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
|
||||
~DesktopGridEffectConfig();
|
||||
|
||||
public slots:
|
||||
virtual void save();
|
||||
virtual void load();
|
||||
virtual void defaults();
|
||||
public slots:
|
||||
virtual void save();
|
||||
virtual void load();
|
||||
virtual void defaults();
|
||||
|
||||
private slots:
|
||||
void layoutSelectionChanged();
|
||||
private slots:
|
||||
void layoutSelectionChanged();
|
||||
|
||||
private:
|
||||
DesktopGridEffectConfigForm* m_ui;
|
||||
KActionCollection* m_actionCollection;
|
||||
QList<Qt::Alignment> m_alignmentItems;
|
||||
};
|
||||
private:
|
||||
DesktopGridEffectConfigForm* m_ui;
|
||||
KActionCollection* m_actionCollection;
|
||||
QList<Qt::Alignment> m_alignmentItems;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -23,92 +23,86 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
KWIN_EFFECT( dialogparent, DialogParentEffect )
|
||||
KWIN_EFFECT(dialogparent, 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)
|
||||
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
|
||||
// effect's strength accordingly
|
||||
bool hasDialog = w->findModal() != NULL;
|
||||
if( hasDialog )
|
||||
{
|
||||
if (hasDialog) {
|
||||
// Increase effect strength of this window
|
||||
effectStrength[w] = qMin(1.0, effectStrength[w] + time/changeTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
effectStrength[w] = qMax(0.0, effectStrength[w] - time/changeTime);
|
||||
}
|
||||
|
||||
// Call the next effect
|
||||
effects->prePaintWindow( w, data, time );
|
||||
effectStrength[w] = qMin(1.0, effectStrength[w] + time / changeTime);
|
||||
} else {
|
||||
effectStrength[w] = qMax(0.0, effectStrength[w] - time / changeTime);
|
||||
}
|
||||
|
||||
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];
|
||||
if(s > 0.0f)
|
||||
{
|
||||
if (s > 0.0f) {
|
||||
// Brightness will be within [1.0; 0.6]
|
||||
data.brightness *= (1.0 - s * 0.4);
|
||||
// Saturation within [1.0; 0.4]
|
||||
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];
|
||||
|
||||
// If strength is between 0 and 1, the effect is still in progress and the
|
||||
// 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
|
||||
|
||||
// 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
|
||||
// that the effect could be run for it
|
||||
// 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
|
||||
EffectWindowList mainwindows = w->mainWindows();
|
||||
foreach( EffectWindow* parent, mainwindows )
|
||||
parent->addRepaintFull();
|
||||
}
|
||||
foreach (EffectWindow * parent, mainwindows)
|
||||
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
|
||||
// that the effect could be run for it
|
||||
// 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
|
||||
EffectWindowList mainwindows = w->mainWindows();
|
||||
foreach( EffectWindow* parent, mainwindows )
|
||||
parent->addRepaintFull();
|
||||
}
|
||||
foreach (EffectWindow * parent, mainwindows)
|
||||
parent->addRepaintFull();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -36,25 +36,25 @@ namespace KWin
|
|||
**/
|
||||
class DialogParentEffect
|
||||
: public Effect
|
||||
{
|
||||
public:
|
||||
DialogParentEffect();
|
||||
virtual void reconfigure( ReconfigureFlags );
|
||||
{
|
||||
public:
|
||||
DialogParentEffect();
|
||||
virtual void reconfigure(ReconfigureFlags);
|
||||
|
||||
virtual void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time );
|
||||
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data );
|
||||
virtual void postPaintWindow( EffectWindow* w );
|
||||
virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time);
|
||||
virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
|
||||
virtual void postPaintWindow(EffectWindow* w);
|
||||
|
||||
virtual void windowClosed( EffectWindow* c );
|
||||
virtual void windowActivated( EffectWindow* c );
|
||||
virtual void windowClosed(EffectWindow* c);
|
||||
virtual void windowActivated(EffectWindow* c);
|
||||
|
||||
protected:
|
||||
bool hasModalWindow( EffectWindow* t );
|
||||
private:
|
||||
// The progress of the fading.
|
||||
QHash<EffectWindow*, double> effectStrength;
|
||||
double changeTime;
|
||||
};
|
||||
protected:
|
||||
bool hasModalWindow(EffectWindow* t);
|
||||
private:
|
||||
// The progress of the fading.
|
||||
QHash<EffectWindow*, double> effectStrength;
|
||||
double changeTime;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -26,120 +26,113 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
KWIN_EFFECT( diminactive, DimInactiveEffect )
|
||||
KWIN_EFFECT(diminactive, DimInactiveEffect)
|
||||
|
||||
DimInactiveEffect::DimInactiveEffect()
|
||||
{
|
||||
reconfigure( ReconfigureAll );
|
||||
timeline.setDuration( animationTime( 250 ));
|
||||
previousActiveTimeline.setDuration( animationTime( 250 ));
|
||||
{
|
||||
reconfigure(ReconfigureAll);
|
||||
timeline.setDuration(animationTime(250));
|
||||
previousActiveTimeline.setDuration(animationTime(250));
|
||||
active = effects->activeWindow();
|
||||
previousActive = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void DimInactiveEffect::reconfigure( ReconfigureFlags )
|
||||
{
|
||||
void DimInactiveEffect::reconfigure(ReconfigureFlags)
|
||||
{
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("DimInactive");
|
||||
dim_panels = conf.readEntry("DimPanels", false);
|
||||
dim_desktop = conf.readEntry("DimDesktop", false);
|
||||
dim_keepabove = conf.readEntry("DimKeepAbove", false);
|
||||
dim_by_group = conf.readEntry("DimByGroup", true);
|
||||
dim_strength = conf.readEntry("Strength", 25);
|
||||
}
|
||||
}
|
||||
|
||||
void DimInactiveEffect::prePaintScreen( ScreenPrePaintData& data, int time )
|
||||
{
|
||||
void DimInactiveEffect::prePaintScreen(ScreenPrePaintData& data, int time)
|
||||
{
|
||||
double oldValue = timeline.value();
|
||||
if( effects->activeFullScreenEffect() )
|
||||
timeline.removeTime( time );
|
||||
if (effects->activeFullScreenEffect())
|
||||
timeline.removeTime(time);
|
||||
else
|
||||
timeline.addTime( time );
|
||||
if( oldValue != timeline.value() )
|
||||
timeline.addTime(time);
|
||||
if (oldValue != timeline.value())
|
||||
effects->addRepaintFull();
|
||||
if( previousActive )
|
||||
{ // We are fading out the previous window
|
||||
if (previousActive) {
|
||||
// We are fading out the previous window
|
||||
previousActive->addRepaintFull();
|
||||
previousActiveTimeline.addTime( time );
|
||||
}
|
||||
effects->prePaintScreen( data, time );
|
||||
previousActiveTimeline.addTime(time);
|
||||
}
|
||||
effects->prePaintScreen(data, time);
|
||||
}
|
||||
|
||||
void DimInactiveEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data )
|
||||
{
|
||||
if( dimWindow( w ) || w == previousActive )
|
||||
{
|
||||
void DimInactiveEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
|
||||
{
|
||||
if (dimWindow(w) || w == previousActive) {
|
||||
double previous = 1.0;
|
||||
if( w == previousActive )
|
||||
if (w == previousActive)
|
||||
previous = previousActiveTimeline.value();
|
||||
if( previousActiveTimeline.value() == 1.0 )
|
||||
if (previousActiveTimeline.value() == 1.0)
|
||||
previousActive = NULL;
|
||||
data.brightness *= (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 );
|
||||
data.brightness *= (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);
|
||||
}
|
||||
|
||||
bool DimInactiveEffect::dimWindow( const EffectWindow* w ) const
|
||||
{
|
||||
if( effects->activeWindow() == w )
|
||||
bool DimInactiveEffect::dimWindow(const EffectWindow* w) const
|
||||
{
|
||||
if (effects->activeWindow() == w)
|
||||
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
|
||||
if( w->isDock() && !dim_panels )
|
||||
if (w->isDock() && !dim_panels)
|
||||
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
|
||||
if( w->keepAbove() && !dim_keepabove )
|
||||
if (w->keepAbove() && !dim_keepabove)
|
||||
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
|
||||
// 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)
|
||||
if( !w->isManaged())
|
||||
if (!w->isManaged())
|
||||
return false;
|
||||
return true; // dim the rest
|
||||
}
|
||||
}
|
||||
|
||||
void DimInactiveEffect::windowDeleted( EffectWindow* w )
|
||||
{
|
||||
if( w == previousActive )
|
||||
void DimInactiveEffect::windowDeleted(EffectWindow* w)
|
||||
{
|
||||
if (w == previousActive)
|
||||
previousActive = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void DimInactiveEffect::windowActivated( EffectWindow* w )
|
||||
{
|
||||
if( active != NULL )
|
||||
{
|
||||
void DimInactiveEffect::windowActivated(EffectWindow* w)
|
||||
{
|
||||
if (active != NULL) {
|
||||
previousActive = active;
|
||||
previousActiveTimeline.setProgress( 0.0 );
|
||||
if( !dimWindow( previousActive ) )
|
||||
previousActiveTimeline.setProgress(0.0);
|
||||
if (!dimWindow(previousActive))
|
||||
previousActive = NULL;
|
||||
|
||||
if( dim_by_group )
|
||||
{
|
||||
if(( w == NULL || w->group() != active->group()) && active->group() != NULL )
|
||||
{ // repaint windows that are no longer in the active group
|
||||
foreach( EffectWindow* tmp, active->group()->members())
|
||||
tmp->addRepaintFull();
|
||||
}
|
||||
if (dim_by_group) {
|
||||
if ((w == NULL || w->group() != active->group()) && active->group() != NULL) {
|
||||
// repaint windows that are no longer in the active group
|
||||
foreach (EffectWindow * tmp, active->group()->members())
|
||||
tmp->addRepaintFull();
|
||||
}
|
||||
else
|
||||
} 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();
|
||||
}
|
||||
}
|
||||
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
|
||||
|
|
|
@ -31,26 +31,26 @@ namespace KWin
|
|||
|
||||
class DimInactiveEffect
|
||||
: public Effect
|
||||
{
|
||||
public:
|
||||
DimInactiveEffect();
|
||||
virtual void reconfigure( ReconfigureFlags );
|
||||
virtual void prePaintScreen( ScreenPrePaintData& data, int time );
|
||||
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data );
|
||||
virtual void windowDeleted( EffectWindow* w );
|
||||
virtual void windowActivated( EffectWindow* c );
|
||||
private:
|
||||
bool dimWindow( const EffectWindow* w ) const;
|
||||
TimeLine timeline;
|
||||
EffectWindow* active;
|
||||
EffectWindow* previousActive;
|
||||
TimeLine previousActiveTimeline;
|
||||
int dim_strength; // reduce saturation and brightness by this percentage
|
||||
bool dim_panels; // do/don't dim also all panels
|
||||
bool dim_desktop; // do/don't dim the desktop
|
||||
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
|
||||
};
|
||||
{
|
||||
public:
|
||||
DimInactiveEffect();
|
||||
virtual void reconfigure(ReconfigureFlags);
|
||||
virtual void prePaintScreen(ScreenPrePaintData& data, int time);
|
||||
virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
|
||||
virtual void windowDeleted(EffectWindow* w);
|
||||
virtual void windowActivated(EffectWindow* c);
|
||||
private:
|
||||
bool dimWindow(const EffectWindow* w) const;
|
||||
TimeLine timeline;
|
||||
EffectWindow* active;
|
||||
EffectWindow* previousActive;
|
||||
TimeLine previousActiveTimeline;
|
||||
int dim_strength; // reduce saturation and brightness by this percentage
|
||||
bool dim_panels; // do/don't dim also all panels
|
||||
bool dim_desktop; // do/don't dim the desktop
|
||||
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
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -38,12 +38,12 @@ KWIN_EFFECT_CONFIG_FACTORY
|
|||
|
||||
DimInactiveEffectConfigForm::DimInactiveEffectConfigForm(QWidget* parent) : QWidget(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
setupUi(this);
|
||||
}
|
||||
|
||||
DimInactiveEffectConfig::DimInactiveEffectConfig(QWidget* parent, const QVariantList& args) :
|
||||
KCModule(EffectFactory::componentData(), parent, args)
|
||||
{
|
||||
KCModule(EffectFactory::componentData(), parent, args)
|
||||
{
|
||||
m_ui = new DimInactiveEffectConfigForm(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()));
|
||||
|
||||
load();
|
||||
}
|
||||
}
|
||||
|
||||
void DimInactiveEffectConfig::load()
|
||||
{
|
||||
{
|
||||
KCModule::load();
|
||||
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("DimInactive");
|
||||
|
@ -77,10 +77,10 @@ void DimInactiveEffectConfig::load()
|
|||
m_ui->checkGroup->setChecked(group);
|
||||
|
||||
emit changed(false);
|
||||
}
|
||||
}
|
||||
|
||||
void DimInactiveEffectConfig::save()
|
||||
{
|
||||
{
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("DimInactive");
|
||||
|
||||
conf.writeEntry("Strength", m_ui->spinStrength->value());
|
||||
|
@ -93,18 +93,18 @@ void DimInactiveEffectConfig::save()
|
|||
|
||||
KCModule::save();
|
||||
emit changed(false);
|
||||
EffectsHandler::sendReloadMessage( "diminactive" );
|
||||
}
|
||||
EffectsHandler::sendReloadMessage("diminactive");
|
||||
}
|
||||
|
||||
void DimInactiveEffectConfig::defaults()
|
||||
{
|
||||
{
|
||||
m_ui->spinStrength->setValue(25);
|
||||
m_ui->checkPanel->setChecked(false);
|
||||
m_ui->checkDesktop->setChecked(false);
|
||||
m_ui->checkKeepAbove->setChecked(false);
|
||||
m_ui->checkGroup->setChecked(true);
|
||||
emit changed(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -31,23 +31,23 @@ namespace KWin
|
|||
class DimInactiveEffectConfigForm : public QWidget, public Ui::DimInactiveEffectConfigForm
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DimInactiveEffectConfigForm(QWidget* parent);
|
||||
public:
|
||||
explicit DimInactiveEffectConfigForm(QWidget* parent);
|
||||
};
|
||||
|
||||
class DimInactiveEffectConfig : public KCModule
|
||||
{
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DimInactiveEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
|
||||
public:
|
||||
explicit DimInactiveEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
|
||||
|
||||
virtual void save();
|
||||
virtual void load();
|
||||
virtual void defaults();
|
||||
virtual void save();
|
||||
virtual void load();
|
||||
virtual void defaults();
|
||||
|
||||
private:
|
||||
DimInactiveEffectConfigForm* m_ui;
|
||||
};
|
||||
private:
|
||||
DimInactiveEffectConfigForm* m_ui;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -24,95 +24,87 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
KWIN_EFFECT( dimscreen, DimScreenEffect )
|
||||
KWIN_EFFECT(dimscreen, DimScreenEffect)
|
||||
|
||||
DimScreenEffect::DimScreenEffect()
|
||||
: mActivated( false )
|
||||
, activateAnimation( false )
|
||||
, deactivateAnimation( false )
|
||||
{
|
||||
reconfigure( ReconfigureAll );
|
||||
}
|
||||
: mActivated(false)
|
||||
, activateAnimation(false)
|
||||
, deactivateAnimation(false)
|
||||
{
|
||||
reconfigure(ReconfigureAll);
|
||||
}
|
||||
|
||||
DimScreenEffect::~DimScreenEffect()
|
||||
{
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
void DimScreenEffect::reconfigure( ReconfigureFlags )
|
||||
{
|
||||
timeline.setDuration( animationTime( 250 ));
|
||||
}
|
||||
void DimScreenEffect::reconfigure(ReconfigureFlags)
|
||||
{
|
||||
timeline.setDuration(animationTime(250));
|
||||
}
|
||||
|
||||
void DimScreenEffect::prePaintScreen( ScreenPrePaintData& data, int time )
|
||||
{
|
||||
if( mActivated && activateAnimation && !effects->activeFullScreenEffect() )
|
||||
timeline.addTime( time );
|
||||
if( mActivated && deactivateAnimation )
|
||||
timeline.removeTime( time );
|
||||
if( mActivated && effects->activeFullScreenEffect() )
|
||||
timeline.removeTime( time );
|
||||
if( mActivated && !activateAnimation && !deactivateAnimation && !effects->activeFullScreenEffect() && timeline.value() != 1.0 )
|
||||
timeline.addTime( time );
|
||||
effects->prePaintScreen( data, time );
|
||||
}
|
||||
void DimScreenEffect::prePaintScreen(ScreenPrePaintData& data, int time)
|
||||
{
|
||||
if (mActivated && activateAnimation && !effects->activeFullScreenEffect())
|
||||
timeline.addTime(time);
|
||||
if (mActivated && deactivateAnimation)
|
||||
timeline.removeTime(time);
|
||||
if (mActivated && effects->activeFullScreenEffect())
|
||||
timeline.removeTime(time);
|
||||
if (mActivated && !activateAnimation && !deactivateAnimation && !effects->activeFullScreenEffect() && timeline.value() != 1.0)
|
||||
timeline.addTime(time);
|
||||
effects->prePaintScreen(data, time);
|
||||
}
|
||||
|
||||
void DimScreenEffect::postPaintScreen()
|
||||
{
|
||||
if( mActivated )
|
||||
{
|
||||
if( activateAnimation && timeline.value() == 1.0 )
|
||||
{
|
||||
{
|
||||
if (mActivated) {
|
||||
if (activateAnimation && timeline.value() == 1.0) {
|
||||
activateAnimation = false;
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
if( deactivateAnimation && timeline.value() == 0.0 )
|
||||
{
|
||||
}
|
||||
if (deactivateAnimation && timeline.value() == 0.0) {
|
||||
deactivateAnimation = false;
|
||||
mActivated = false;
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
}
|
||||
// still animating
|
||||
if( timeline.value() > 0.0 && timeline.value() < 1.0 )
|
||||
if (timeline.value() > 0.0 && timeline.value() < 1.0)
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
}
|
||||
effects->postPaintScreen();
|
||||
}
|
||||
}
|
||||
|
||||
void DimScreenEffect::paintWindow( EffectWindow *w, int mask, QRegion region, WindowPaintData &data )
|
||||
{
|
||||
if( mActivated && ( w != window ) && w->isManaged() )
|
||||
{
|
||||
data.brightness *= (1.0 - 0.33 * timeline.value() );
|
||||
data.saturation *= (1.0 - 0.33 * timeline.value() );
|
||||
}
|
||||
effects->paintWindow( w, mask, region, data );
|
||||
void DimScreenEffect::paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data)
|
||||
{
|
||||
if (mActivated && (w != window) && w->isManaged()) {
|
||||
data.brightness *= (1.0 - 0.33 * timeline.value());
|
||||
data.saturation *= (1.0 - 0.33 * timeline.value());
|
||||
}
|
||||
effects->paintWindow(w, mask, region, data);
|
||||
}
|
||||
|
||||
void DimScreenEffect::windowActivated( EffectWindow *w )
|
||||
{
|
||||
if( !w ) return;
|
||||
void DimScreenEffect::windowActivated(EffectWindow *w)
|
||||
{
|
||||
if (!w) return;
|
||||
QStringList check;
|
||||
check << "kdesu kdesu";
|
||||
check << "kdesudo kdesudo";
|
||||
check << "polkit-kde-manager polkit-kde-manager";
|
||||
check << "polkit-kde-authentication-agent-1 polkit-kde-authentication-agent-1";
|
||||
check << "pinentry pinentry";
|
||||
if( check.contains( w->windowClass() ) )
|
||||
{
|
||||
if (check.contains(w->windowClass())) {
|
||||
mActivated = true;
|
||||
activateAnimation = true;
|
||||
deactivateAnimation = false;
|
||||
window = w;
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
else
|
||||
{
|
||||
if( mActivated)
|
||||
{
|
||||
} else {
|
||||
if (mActivated) {
|
||||
activateAnimation = false;
|
||||
deactivateAnimation = true;
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
|
|
@ -28,24 +28,24 @@ namespace KWin
|
|||
|
||||
class DimScreenEffect
|
||||
: public Effect
|
||||
{
|
||||
public:
|
||||
DimScreenEffect();
|
||||
~DimScreenEffect();
|
||||
{
|
||||
public:
|
||||
DimScreenEffect();
|
||||
~DimScreenEffect();
|
||||
|
||||
virtual void reconfigure( ReconfigureFlags );
|
||||
virtual void prePaintScreen( ScreenPrePaintData& data, int time );
|
||||
virtual void postPaintScreen();
|
||||
virtual void paintWindow( EffectWindow *w, int mask, QRegion region, WindowPaintData &data );
|
||||
virtual void windowActivated( EffectWindow *w );
|
||||
virtual void reconfigure(ReconfigureFlags);
|
||||
virtual void prePaintScreen(ScreenPrePaintData& data, int time);
|
||||
virtual void postPaintScreen();
|
||||
virtual void paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data);
|
||||
virtual void windowActivated(EffectWindow *w);
|
||||
|
||||
private:
|
||||
bool mActivated;
|
||||
bool activateAnimation;
|
||||
bool deactivateAnimation;
|
||||
TimeLine timeline;
|
||||
EffectWindow* window;
|
||||
};
|
||||
private:
|
||||
bool mActivated;
|
||||
bool activateAnimation;
|
||||
bool deactivateAnimation;
|
||||
TimeLine timeline;
|
||||
EffectWindow* window;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -33,11 +33,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
KWIN_EFFECT( explosion, ExplosionEffect )
|
||||
KWIN_EFFECT_SUPPORTED( explosion, ExplosionEffect::supported() )
|
||||
KWIN_EFFECT(explosion, ExplosionEffect)
|
||||
KWIN_EFFECT_SUPPORTED(explosion, ExplosionEffect::supported())
|
||||
|
||||
ExplosionEffect::ExplosionEffect() : Effect()
|
||||
{
|
||||
{
|
||||
mShader = 0;
|
||||
mStartOffsetTex = 0;
|
||||
mEndOffsetTex = 0;
|
||||
|
@ -45,20 +45,20 @@ ExplosionEffect::ExplosionEffect() : Effect()
|
|||
mActiveAnimations = 0;
|
||||
mValid = true;
|
||||
mInited = false;
|
||||
}
|
||||
}
|
||||
|
||||
ExplosionEffect::~ExplosionEffect()
|
||||
{
|
||||
{
|
||||
delete mShader;
|
||||
delete mStartOffsetTex;
|
||||
delete mEndOffsetTex;
|
||||
}
|
||||
}
|
||||
|
||||
bool ExplosionEffect::supported()
|
||||
{
|
||||
{
|
||||
return GLShader::fragmentShaderSupported() &&
|
||||
(effects->compositingType() == OpenGLCompositing);
|
||||
}
|
||||
(effects->compositingType() == OpenGLCompositing);
|
||||
}
|
||||
|
||||
bool ExplosionEffect::loadData()
|
||||
{
|
||||
|
@ -67,20 +67,16 @@ bool ExplosionEffect::loadData()
|
|||
const QString fragmentshader = KGlobal::dirs()->findResource("data", "kwin/explosion.frag");
|
||||
QString starttexture = KGlobal::dirs()->findResource("data", "kwin/explosion-start.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;
|
||||
return false;
|
||||
}
|
||||
|
||||
mShader = ShaderManager::instance()->loadFragmentShader(ShaderManager::GenericShader, fragmentshader);
|
||||
if(!mShader->isValid())
|
||||
{
|
||||
if (!mShader->isValid()) {
|
||||
kError(1212) << "The shader failed to load!" << endl;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
ShaderManager::instance()->pushShader(mShader);
|
||||
mShader->setUniform("startOffsetTexture", 4);
|
||||
mShader->setUniform("endOffsetTexture", 5);
|
||||
|
@ -89,70 +85,61 @@ bool ExplosionEffect::loadData()
|
|||
|
||||
mStartOffsetTex = new GLTexture(starttexture);
|
||||
mEndOffsetTex = new GLTexture(endtexture);
|
||||
if(mStartOffsetTex->isNull() || mEndOffsetTex->isNull())
|
||||
{
|
||||
if (mStartOffsetTex->isNull() || mEndOffsetTex->isNull()) {
|
||||
kError(1212) << "The textures failed to load!" << endl;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
mStartOffsetTex->setFilter( GL_LINEAR );
|
||||
mEndOffsetTex->setFilter( GL_LINEAR );
|
||||
} else {
|
||||
mStartOffsetTex->setFilter(GL_LINEAR);
|
||||
mEndOffsetTex->setFilter(GL_LINEAR);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void ExplosionEffect::prePaintScreen( ScreenPrePaintData& data, int time )
|
||||
{
|
||||
if( mActiveAnimations > 0 )
|
||||
void ExplosionEffect::prePaintScreen(ScreenPrePaintData& data, int time)
|
||||
{
|
||||
if (mActiveAnimations > 0)
|
||||
// We need to mark the screen as transformed. Otherwise the whole screen
|
||||
// won't be repainted, resulting in artefacts
|
||||
data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
|
||||
|
||||
effects->prePaintScreen(data, time);
|
||||
}
|
||||
}
|
||||
|
||||
void ExplosionEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time )
|
||||
{
|
||||
if( mWindows.contains( w ))
|
||||
{
|
||||
if( mValid && !mInited )
|
||||
void ExplosionEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
|
||||
{
|
||||
if (mWindows.contains(w)) {
|
||||
if (mValid && !mInited)
|
||||
mValid = loadData();
|
||||
if( mValid )
|
||||
{
|
||||
mWindows[ w ] += time / animationTime( 700.0 ); // complete change in 700ms
|
||||
if( mWindows[ w ] < 1 )
|
||||
{
|
||||
if (mValid) {
|
||||
mWindows[ w ] += time / animationTime(700.0); // complete change in 700ms
|
||||
if (mWindows[ w ] < 1) {
|
||||
data.setTranslucent();
|
||||
data.setTransformed();
|
||||
w->enablePainting( EffectWindow::PAINT_DISABLED_BY_DELETE );
|
||||
}
|
||||
else
|
||||
{
|
||||
mWindows.remove( w );
|
||||
w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DELETE);
|
||||
} else {
|
||||
mWindows.remove(w);
|
||||
w->unrefWindow();
|
||||
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
|
||||
// special window
|
||||
bool useshader = ( mValid && mWindows.contains( w ) );
|
||||
if( useshader )
|
||||
{
|
||||
bool useshader = (mValid && mWindows.contains(w));
|
||||
if (useshader) {
|
||||
double maxscaleadd = 1.5f;
|
||||
double scale = 1 + maxscaleadd*mWindows[w];
|
||||
double scale = 1 + maxscaleadd * mWindows[w];
|
||||
data.xScale = scale;
|
||||
data.yScale = scale;
|
||||
data.xTranslate += int( w->width() / 2 * ( 1 - scale ));
|
||||
data.yTranslate += int( w->height() / 2 * ( 1 - scale ));
|
||||
data.xTranslate += int(w->width() / 2 * (1 - scale));
|
||||
data.yTranslate += int(w->height() / 2 * (1 - scale));
|
||||
data.opacity *= 0.99; // Force blending
|
||||
ShaderManager *manager = ShaderManager::instance();
|
||||
GLShader *shader = manager->pushShader(ShaderManager::GenericShader);
|
||||
|
@ -168,49 +155,47 @@ void ExplosionEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Wi
|
|||
mEndOffsetTex->bind();
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
data.shader = mShader;
|
||||
}
|
||||
}
|
||||
|
||||
// Call the next effect.
|
||||
effects->paintWindow( w, mask, region, data );
|
||||
effects->paintWindow(w, mask, region, data);
|
||||
|
||||
if( useshader )
|
||||
{
|
||||
if (useshader) {
|
||||
ShaderManager::instance()->popShader();
|
||||
glActiveTexture(GL_TEXTURE4);
|
||||
mStartOffsetTex->unbind();
|
||||
glActiveTexture(GL_TEXTURE5);
|
||||
mEndOffsetTex->unbind();
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ExplosionEffect::postPaintScreen()
|
||||
{
|
||||
if( mActiveAnimations > 0 )
|
||||
{
|
||||
if (mActiveAnimations > 0)
|
||||
effects->addRepaintFull();
|
||||
|
||||
// Call the next effect.
|
||||
effects->postPaintScreen();
|
||||
}
|
||||
}
|
||||
|
||||
void ExplosionEffect::windowClosed( EffectWindow* c )
|
||||
{
|
||||
const void* e = c->data( WindowClosedGrabRole ).value<void*>();
|
||||
if( e && e != this )
|
||||
void ExplosionEffect::windowClosed(EffectWindow* c)
|
||||
{
|
||||
const void* e = c->data(WindowClosedGrabRole).value<void*>();
|
||||
if (e && e != this)
|
||||
return;
|
||||
if( c->isOnCurrentDesktop() && !c->isMinimized())
|
||||
{
|
||||
if (c->isOnCurrentDesktop() && !c->isMinimized()) {
|
||||
mWindows[ c ] = 0; // count up to 1
|
||||
c->addRepaintFull();
|
||||
c->refWindow();
|
||||
mActiveAnimations++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ExplosionEffect::windowDeleted( EffectWindow* c )
|
||||
{
|
||||
mWindows.remove( c );
|
||||
}
|
||||
void ExplosionEffect::windowDeleted(EffectWindow* c)
|
||||
{
|
||||
mWindows.remove(c);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -37,34 +37,34 @@ class GLTexture;
|
|||
**/
|
||||
class ExplosionEffect
|
||||
: public Effect
|
||||
{
|
||||
public:
|
||||
ExplosionEffect();
|
||||
~ExplosionEffect();
|
||||
{
|
||||
public:
|
||||
ExplosionEffect();
|
||||
~ExplosionEffect();
|
||||
|
||||
virtual void prePaintScreen( ScreenPrePaintData& 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 postPaintScreen();
|
||||
virtual void prePaintScreen(ScreenPrePaintData& 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 postPaintScreen();
|
||||
|
||||
virtual void windowClosed( EffectWindow* c );
|
||||
virtual void windowDeleted( EffectWindow* c );
|
||||
virtual void windowClosed(EffectWindow* c);
|
||||
virtual void windowDeleted(EffectWindow* c);
|
||||
|
||||
static bool supported();
|
||||
static bool supported();
|
||||
|
||||
|
||||
protected:
|
||||
bool loadData();
|
||||
protected:
|
||||
bool loadData();
|
||||
|
||||
private:
|
||||
GLShader* mShader;
|
||||
GLTexture* mStartOffsetTex;
|
||||
GLTexture* mEndOffsetTex;
|
||||
QMap< const EffectWindow*, double > mWindows;
|
||||
int mActiveAnimations;
|
||||
bool mValid;
|
||||
bool mInited;
|
||||
};
|
||||
private:
|
||||
GLShader* mShader;
|
||||
GLTexture* mStartOffsetTex;
|
||||
GLTexture* mEndOffsetTex;
|
||||
QMap< const EffectWindow*, double > mWindows;
|
||||
int mActiveAnimations;
|
||||
bool mValid;
|
||||
bool mInited;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue