KWin uses kdelibs coding style.

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

View File

@ -239,16 +239,15 @@ void Workspace::setActiveClient( Client* c, allowed_t )
StackingUpdatesBlocker blocker(this);
++set_active_client_recursion;
updateFocusMousePosition(cursorPos());
if( active_client != NULL )
{ // note that this may call setActiveClient( NULL ), therefore the recursion counter
if (active_client != NULL) {
// note that this may call setActiveClient( NULL ), therefore the recursion counter
active_client->setActive(false);
}
active_client = c;
Q_ASSERT(c == NULL || c->isActive());
if (active_client != NULL)
last_active_client = active_client;
if ( active_client )
{
if (active_client) {
updateFocusChains(active_client, FocusChainMakeFirst);
active_client->demandAttention(false);
}
@ -286,21 +285,18 @@ void Workspace::setActiveClient( Client* c, allowed_t )
*/
void Workspace::activateClient(Client* c, bool force)
{
if( c == NULL )
{
if (c == NULL) {
focusToNull();
setActiveClient(NULL, Allowed);
return;
}
raiseClient(c);
if (!c->isOnCurrentDesktop() )
{
if (!c->isOnCurrentDesktop()) {
++block_focus;
setCurrentDesktop(c->desktop());
--block_focus;
}
if (!c->isOnCurrentActivity() )
{
if (!c->isOnCurrentActivity()) {
++block_focus;
//DBUS!
activityController_.setCurrentActivity(c->activities().first()); //first isn't necessarily best, but it's easiest
@ -342,19 +338,15 @@ void Workspace::takeActivity( Client* c, int flags, bool handled )
if (!focusChangeEnabled() && (c != active_client))
flags &= ~ActivityFocus;
if ( !c )
{
if (!c) {
focusToNull();
return;
}
if( flags & ActivityFocus )
{
if (flags & ActivityFocus) {
Client* modal = c->findModal();
if( modal != NULL && modal != c )
{
if( !modal->isOnDesktop( c->desktop()))
{
if (modal != NULL && modal != c) {
if (!modal->isOnDesktop(c->desktop())) {
modal->setDesktop(c->desktop());
if (modal->desktop() != c->desktop()) // forced desktop
activateClient(modal);
@ -372,10 +364,8 @@ void Workspace::takeActivity( Client* c, int flags, bool handled )
}
if (!(flags & ActivityFocusForce) && (c->isTopMenu() || c->isDock() || c->isSplash()))
flags &= ~ActivityFocus; // toplevel menus and dock windows don't take focus if not forced
if( c->isShade())
{
if( c->wantsInput() && ( flags & ActivityFocus ))
{
if (c->isShade()) {
if (c->wantsInput() && (flags & ActivityFocus)) {
// client cannot accept focus, but at least the window should be active (window menu, et. al. )
c->setActive(true);
focusToNull();
@ -385,8 +375,7 @@ void Workspace::takeActivity( Client* c, int flags, bool handled )
}
if (c->clientGroup() && c->clientGroup()->visible() != c)
c->clientGroup()->setVisible(c);
if( !c->isShown( true )) // shouldn't happen, call activateClient() if needed
{
if (!c->isShown(true)) { // shouldn't happen, call activateClient() if needed
kWarning(1212) << "takeActivity: not shown" ;
return;
}
@ -434,32 +423,25 @@ bool Workspace::activateNextClient( Client* c )
|| (should_get_focus.count() > 0 && c == should_get_focus.last())))
return false;
closeActivePopup();
if( c != NULL )
{
if (c != NULL) {
if (c == active_client)
setActiveClient(NULL, Allowed);
should_get_focus.removeAll(c);
}
if( focusChangeEnabled())
{
if ( options->focusPolicyIsReasonable())
{ // search the focus_chain for a client to transfer focus to,
if (focusChangeEnabled()) {
if (options->focusPolicyIsReasonable()) {
// search the focus_chain for a client to transfer focus to,
Client* get_focus = NULL;
// first try to pass the focus to the (former) active clients leader
if (c && (get_focus = c->transientFor()) &&
isUsableFocusCandidate( get_focus, c, options->separateScreenFocus ))
{
isUsableFocusCandidate(get_focus, c, options->separateScreenFocus)) {
raiseClient(get_focus); // also raise - we don't know where it came from
}
else // nope, ask the focus chain for the next candidate
{
} else { // nope, ask the focus chain for the next candidate
get_focus = NULL; // reset
for ( int i = focus_chain[ currentDesktop() ].size() - 1; i >= 0; --i )
{
for (int i = focus_chain[ currentDesktop()].size() - 1; i >= 0; --i) {
Client* ci = focus_chain[ currentDesktop()].at(i);
if ( isUsableFocusCandidate( ci, c, options->separateScreenFocus ))
{
if (isUsableFocusCandidate(ci, c, options->separateScreenFocus)) {
get_focus = ci;
break; // we're done
}
@ -473,11 +455,9 @@ bool Workspace::activateNextClient( Client* c )
requestFocus(get_focus);
else
focusToNull();
}
else
} else
return false;
}
else
} else
// if blocking focus, move focus to the desktop later if needed
// in order to avoid flickering
focusToNull();
@ -494,8 +474,7 @@ void Workspace::setCurrentScreen( int new_screen )
Client* get_focus = NULL;
for (int i = focus_chain[ currentDesktop()].count() - 1;
i >= 0;
--i )
{
--i) {
Client* ci = focus_chain[ currentDesktop()].at(i);
if (!ci->isShown(false) || !ci->isOnCurrentDesktop() || !ci->isOnCurrentActivity())
continue;
@ -513,8 +492,8 @@ void Workspace::setCurrentScreen( int new_screen )
void Workspace::gotFocusIn(const Client* c)
{
if( should_get_focus.contains( const_cast< Client* >( c )))
{ // remove also all sooner elements that should have got FocusIn,
if (should_get_focus.contains(const_cast< Client* >(c))) {
// remove also all sooner elements that should have got FocusIn,
// but didn't for some reason (and also won't anymore, because they were sooner)
while (should_get_focus.first() != c)
should_get_focus.pop_front();
@ -544,13 +523,11 @@ bool Workspace::allowClientActivation( const Client* c, Time time, bool focus_in
if (time == -1U)
time = c->userTime();
int level = c->rules()->checkFSP(options->focusStealingPreventionLevel);
if( session_saving && level <= 2 ) // <= normal
{
if (session_saving && level <= 2) { // <= normal
return true;
}
Client* ac = mostRecentlyActivatedClient();
if( focus_in )
{
if (focus_in) {
if (should_get_focus.contains(const_cast< Client* >(c)))
return true; // FocusIn was result of KWin's action
// Before getting FocusIn, the active Client already
@ -567,21 +544,18 @@ bool Workspace::allowClientActivation( const Client* c, Time time, bool focus_in
return false; // allow only with level == 0
if (c->ignoreFocusStealing())
return true;
if( ac == NULL || ac->isDesktop())
{
if (ac == NULL || ac->isDesktop()) {
kDebug(1212) << "Activation: No client active, allowing";
return true; // no active client -> always allow
}
// TODO window urgency -> return true?
if( Client::belongToSameApplication( c, ac, true ))
{
if (Client::belongToSameApplication(c, ac, true)) {
kDebug(1212) << "Activation: Belongs to active application";
return true;
}
if (level == 3) // high
return false;
if( time == -1U ) // no time known
{
if (time == -1U) { // no time known
kDebug(1212) << "Activation: No timestamp at all";
if (level == 1) // low
return true;
@ -604,8 +578,7 @@ bool Workspace::allowClientActivation( const Client* c, Time time, bool focus_in
bool Workspace::allowFullClientRaising(const Client* c, Time time)
{
int level = c->rules()->checkFSP(options->focusStealingPreventionLevel);
if( session_saving && level <= 2 ) // <= normal
{
if (session_saving && level <= 2) { // <= normal
return true;
}
Client* ac = mostRecentlyActivatedClient();
@ -613,16 +586,14 @@ bool Workspace::allowFullClientRaising( const Client* c, Time time )
return true;
if (level == 4) // extreme
return false;
if( ac == NULL || ac->isDesktop())
{
if (ac == NULL || ac->isDesktop()) {
kDebug(1212) << "Raising: No client active, allowing";
return true; // no active client -> always allow
}
if (c->ignoreFocusStealing())
return true;
// TODO window urgency -> return true?
if( Client::belongToSameApplication( c, ac, true ))
{
if (Client::belongToSameApplication(c, ac, true)) {
kDebug(1212) << "Raising: Belongs to active application";
return true;
}
@ -651,12 +622,10 @@ void Workspace::restoreFocus()
void Workspace::clientAttentionChanged(Client* c, bool set)
{
if( set )
{
if (set) {
attention_chain.removeAll(c);
attention_chain.prepend(c);
}
else
} else
attention_chain.removeAll(c);
}
@ -665,8 +634,7 @@ void Workspace::clientAttentionChanged( Client* c, bool set )
// Used only in special cases, e.g. for MouseActivateRaiseandMove with transparent windows,
bool Workspace::fakeRequestedActivity(Client* c)
{
if( should_get_focus.count() > 0 && should_get_focus.last() == c )
{
if (should_get_focus.count() > 0 && should_get_focus.last() == c) {
if (c->isActive())
return false;
c->setActive(true);
@ -677,8 +645,8 @@ bool Workspace::fakeRequestedActivity( Client* c )
void Workspace::unfakeActivity(Client* c)
{
if( should_get_focus.count() > 0 && should_get_focus.last() == c )
{ // TODO this will cause flicker, and probably is not needed
if (should_get_focus.count() > 0 && should_get_focus.last() == c) {
// TODO this will cause flicker, and probably is not needed
if (last_active_client != NULL)
last_active_client->setActive(true);
else
@ -698,7 +666,8 @@ void Workspace::unfakeActivity( Client* c )
externally, etc.).
*/
void Client::updateUserTime(Time time)
{ // copied in Group::updateUserTime
{
// copied in Group::updateUserTime
if (time == CurrentTime)
time = xTime();
if (time != -1U
@ -720,8 +689,7 @@ Time Client::readUserCreationTime() const
status = XGetWindowProperty(display(), window(),
atoms->kde_net_wm_user_creation_time, 0, 10000, false, XA_CARDINAL,
&type, &format, &nitems, &extra, &data);
if (status == Success )
{
if (status == Success) {
if (data && nitems > 0)
result = *((long*) data);
XFree(data);
@ -736,8 +704,7 @@ void Client::demandAttention( bool set )
if (demands_attention == set)
return;
demands_attention = set;
if( demands_attention )
{
if (demands_attention) {
// Demand attention flag is often set right from manage(), when focus stealing prevention
// steps in. At that time the window has no taskbar entry yet, so KNotify cannot place
// e.g. the passive popup next to it. So wait up to 1 second for the icon geometry
@ -750,15 +717,13 @@ void Client::demandAttention( bool set )
info->setState(set ? NET::DemandsAttention : 0, NET::DemandsAttention);
if( demandAttentionKNotifyTimer == NULL )
{
if (demandAttentionKNotifyTimer == NULL) {
demandAttentionKNotifyTimer = new QTimer(this);
demandAttentionKNotifyTimer->setSingleShot(true);
connect(demandAttentionKNotifyTimer, SIGNAL(timeout()), SLOT(demandAttentionKNotify()));
}
demandAttentionKNotifyTimer->start(1000);
}
else
} else
info->setState(set ? NET::DemandsAttention : 0, NET::DemandsAttention);
workspace()->clientAttentionChanged(this, set);
}
@ -788,23 +753,19 @@ Time Client::readUserTimeMapTimestamp( const KStartupInfoId* asn_id, const KStar
// newer ASN timestamp always replaces user timestamp, unless user timestamp is 0
// helps e.g. with konqy reusing
if( asn_data != NULL && time != 0 )
{
if (asn_data != NULL && time != 0) {
// prefer timestamp from ASN id (timestamp from data is obsolete way)
if (asn_id->timestamp() != 0
&& ( time == -1U || timestampCompare( asn_id->timestamp(), time ) > 0 ))
{
&& (time == -1U || timestampCompare(asn_id->timestamp(), time) > 0)) {
time = asn_id->timestamp();
}
else if( asn_data->timestamp() != -1U
&& ( time == -1U || timestampCompare( asn_data->timestamp(), time ) > 0 ))
{
} else if (asn_data->timestamp() != -1U
&& (time == -1U || timestampCompare(asn_data->timestamp(), time) > 0)) {
time = asn_data->timestamp();
}
}
kDebug(1212) << "User timestamp, ASN:" << time;
if( time == -1U )
{ // The window doesn't have any timestamp.
if (time == -1U) {
// The window doesn't have any timestamp.
// If it's the first window for its application
// (i.e. there's no other window from the same app),
// use the _KDE_NET_WM_USER_CREATION_TIME trick.
@ -812,11 +773,9 @@ Time Client::readUserTimeMapTimestamp( const KStartupInfoId* asn_id, const KStar
// from already running application if this application
// is not the active one (unless focus stealing prevention is turned off).
Client* act = workspace()->mostRecentlyActivatedClient();
if( act != NULL && !belongToSameApplication( act, this, true ))
{
if (act != NULL && !belongToSameApplication(act, this, true)) {
bool first_window = true;
if( isTransient())
{
if (isTransient()) {
if (act->hasTransient(this, true))
; // is transient for currently active window, even though it's not
// the same app (e.g. kcookiejar dialog) -> allow activation
@ -825,15 +784,12 @@ Time Client::readUserTimeMapTimestamp( const KStartupInfoId* asn_id, const KStar
; // standalone transient
else
first_window = false;
}
else
{
} else {
if (workspace()->findClient(SameApplicationActiveHackPredicate(this)))
first_window = false;
}
// don't refuse if focus stealing prevention is turned off
if( !first_window && rules()->checkFSP( options->focusStealingPreventionLevel ) > 0 )
{
if (!first_window && rules()->checkFSP(options->focusStealingPreventionLevel) > 0) {
kDebug(1212) << "User timestamp, already exists:" << 0;
return 0; // refuse activation
}
@ -937,8 +893,7 @@ void Client::startupIdChanged()
Time timestamp = asn_id.timestamp();
if (timestamp == 0 && asn_data.timestamp() != -1U)
timestamp = asn_data.timestamp();
if( timestamp != 0 )
{
if (timestamp != 0) {
bool activate = workspace()->allowClientActivation(this, timestamp);
if (asn_data.desktop() != 0 && !isOnCurrentDesktop())
activate = false; // it was started on different desktop than current one
@ -972,19 +927,17 @@ void Group::startupIdChanged()
if (!asn_valid)
return;
if (asn_id.timestamp() != 0 && user_time != -1U
&& timestampCompare( asn_id.timestamp(), user_time ) > 0 )
{
&& timestampCompare(asn_id.timestamp(), user_time) > 0) {
user_time = asn_id.timestamp();
}
else if( asn_data.timestamp() != -1U && user_time != -1U
&& timestampCompare( asn_data.timestamp(), user_time ) > 0 )
{
} else if (asn_data.timestamp() != -1U && user_time != -1U
&& timestampCompare(asn_data.timestamp(), user_time) > 0) {
user_time = asn_data.timestamp();
}
}
void Group::updateUserTime(Time time)
{ // copy of Client::updateUserTime
{
// copy of Client::updateUserTime
if (time == CurrentTime)
time = xTime();
if (time != -1U

View File

@ -164,17 +164,13 @@ QRegion Bridge::unobscuredRegion( const QRegion& r ) const
const ClientList stacking_order = c->workspace()->stackingOrder();
int pos = stacking_order.indexOf(c);
++pos;
for(; pos < stacking_order.count(); ++pos )
{
for (; pos < stacking_order.count(); ++pos) {
if (!stacking_order[pos]->isShown(true))
continue; // these don't obscure the window
if( c->isOnAllDesktops())
{
if (c->isOnAllDesktops()) {
if (!stacking_order[ pos ]->isOnCurrentDesktop())
continue;
}
else
{
} else {
if (!stacking_order[ pos ]->isOnDesktop(c->desktop()))
continue;
}
@ -186,8 +182,7 @@ 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;
}
@ -261,8 +256,7 @@ void Bridge::moveItemInClientGroup( int index, int before )
void Bridge::moveItemToClientGroup(long itemId, int before)
{
Client* item = reinterpret_cast<Client*>(itemId);
if( !c->workspace()->hasClient( item ))
{
if (!c->workspace()->hasClient(item)) {
kWarning(1212) << "****** ARBITRARY CODE EXECUTION ATTEMPT DETECTED ******";
return;
}

View File

@ -130,7 +130,8 @@ Client::Client( Workspace* ws )
, electricMaximizing(false)
, activitiesDefined(false)
, needsSessionInteract(false)
{ // TODO: Do all as initialization
{
// TODO: Do all as initialization
scriptCache = new QHash<QScriptEngine*, ClientResolution>();
@ -233,8 +234,7 @@ void Client::releaseWindow( bool on_shutdown )
assert(!deleting);
deleting = true;
Deleted* del = Deleted::create(this);
if( effects )
{
if (effects) {
static_cast<EffectsHandlerImpl*>(effects)->windowClosed(effectWindow());
scene->windowClosed(this, del);
}
@ -260,8 +260,7 @@ void Client::releaseWindow( bool on_shutdown )
cleanGrouping();
if (clientGroup())
clientGroup()->remove(this, QRect(), true);
if( !on_shutdown )
{
if (!on_shutdown) {
workspace()->removeClient(this, Allowed);
// Only when the window is being unmapped, not when closing down KWin (NETWM sections 5.5,5.7)
info->setDesktop(0);
@ -303,8 +302,7 @@ void Client::destroyClient()
assert(!deleting);
deleting = true;
Deleted* del = Deleted::create(this);
if( effects )
{
if (effects) {
static_cast<EffectsHandlerImpl*>(effects)->windowClosed(effectWindow());
scene->windowClosed(this, del);
}
@ -346,8 +344,7 @@ void Client::updateDecoration( bool check_workspace_pos, bool force )
blockGeometryUpdates(true);
if (force)
destroyDecoration();
if( !noBorder() )
{
if (!noBorder()) {
setMask(QRegion()); // Reset shape mask
decoration = workspace()->createDecoration(bridge);
// TODO: Check decoration's minimum size?
@ -371,8 +368,7 @@ void Client::updateDecoration( bool check_workspace_pos, bool force )
scene->windowGeometryShapeChanged(this);
if (effects != NULL)
static_cast<EffectsHandlerImpl*>(effects)->windowGeometryShapeChanged(effectWindow(), oldgeom);
}
else
} else
destroyDecoration();
if (check_workspace_pos)
checkWorkspacePosition();
@ -385,8 +381,7 @@ void Client::updateDecoration( bool check_workspace_pos, bool force )
void Client::destroyDecoration()
{
QRect oldgeom = geometry();
if( decoration != NULL )
{
if (decoration != NULL) {
delete decoration;
decoration = NULL;
QPoint grav = calculateGravitation(true);
@ -424,8 +419,7 @@ bool Client::checkBorderSizes( bool also_resize )
if (new_left == border_left && new_right == border_right &&
new_top == border_top && new_bottom == border_bottom)
return false;
if( !also_resize )
{
if (!also_resize) {
border_left = new_left;
border_right = new_right;
border_top = new_top;
@ -461,8 +455,7 @@ void Client::layoutDecorationRects(QRect &left, QRect &top, QRect &right, QRect
// Ignore the overlap strut when compositing is disabled
if (!compositing() || !Workspace::self()->decorationSupportsFrameOverlap())
strut.left = strut.top = strut.right = strut.bottom = 0;
else if (strut.left == -1 && strut.top == -1 && strut.right == -1 && strut.bottom == -1)
{
else if (strut.left == -1 && strut.top == -1 && strut.right == -1 && strut.bottom == -1) {
top = QRect(r.x(), r.y(), r.width(), r.height() / 3);
left = QRect(r.x(), r.y() + top.height(), width() / 2, r.height() / 3);
right = QRect(r.x() + left.width(), r.y() + top.height(), r.width() - left.width(), left.height());
@ -488,15 +481,13 @@ QRegion Client::decorationPendingRegion() const
void Client::repaintDecorationPending()
{
if (compositing())
{
if (compositing()) {
// The scene will update the decoration pixmaps in the next painting pass
// if it has not been already repainted before
const QRegion r = paintRedirector->scheduledRepaintRegion();
if (!r.isEmpty())
Workspace::self()->addRepaint(r.translated(x() - padding_left, y() - padding_top));
}
else
} else
ensureDecorationPixmapsPainted();
}
@ -527,13 +518,11 @@ void Client::ensureDecorationPixmapsPainted()
repaintDecorationPixmap(decorationPixmapTop, tr, p, r);
repaintDecorationPixmap(decorationPixmapBottom, br, p, r);
if (!compositing())
{
if (!compositing()) {
// Blit the pixmaps to the frame window
layoutDecorationRects(lr, tr, rr, br, WindowRelative);
#ifdef HAVE_XRENDER
if (Extensions::renderAvailable())
{
if (Extensions::renderAvailable()) {
XRenderPictFormat* format = XRenderFindVisualFormat(display(), visual());
XRenderPictureAttributes pa;
pa.subwindow_mode = IncludeInferiors;
@ -547,8 +536,7 @@ void Client::ensureDecorationPixmapsPainted()
XRenderComposite(display(), PictOpSrc, decorationPixmapBottom.x11PictureHandle(), None, pic,
0, 0, 0, 0, br.x(), br.y(), br.width(), br.height());
XRenderFreePicture(display(), pic); // TODO don't recreate pictures all the time?
}
else
} else
#endif
{
XGCValues values;
@ -564,8 +552,7 @@ void Client::ensureDecorationPixmapsPainted()
br.width(), br.height(), br.x(), br.y());
XFreeGC(display(), gc);
}
}
else
} else
XSync(display(), false);
}
@ -636,14 +623,12 @@ QRect Client::transparentRect() const
void Client::detectNoBorder()
{
if( shape())
{
if (shape()) {
noborder = true;
app_noborder = true;
return;
}
switch( windowType())
{
switch(windowType()) {
case NET::Desktop :
case NET::Dock :
case NET::TopMenu :
@ -665,8 +650,7 @@ void Client::detectNoBorder()
// NET::Override is some strange beast without clear definition, usually
// just meaning "noborder", so let's treat it only as such flag, and ignore it as
// a window type otherwise (SUPPORTED_WINDOW_TYPES_MASK doesn't include it)
if( info->windowType( SUPPORTED_MANAGED_WINDOW_TYPES_MASK | NET::OverrideMask ) == NET::Override )
{
if (info->windowType(SUPPORTED_MANAGED_WINDOW_TYPES_MASK | NET::OverrideMask) == NET::Override) {
noborder = true;
app_noborder = true;
}
@ -696,13 +680,10 @@ void Client::resizeDecoration( const QSize& s )
QSize newSize = s + QSize(padding_left + padding_right, padding_top + padding_bottom);
QSize oldSize = decoration->widget()->size();
decoration->resize(newSize);
if( oldSize == newSize )
{
if (oldSize == newSize) {
QResizeEvent e(newSize, oldSize);
QApplication::sendEvent(decoration->widget(), &e);
}
else // oldSize != newSize
{
} else { // oldSize != newSize
resizeDecorationPixmaps();
}
}
@ -736,10 +717,10 @@ void Client::checkNoBorder()
void Client::updateShape()
{
if( shape() )
{ // Workaround for #19644 - Shaped windows shouldn't have decoration
if( !app_noborder )
{ // Only when shape is detected for the first time, still let the user to override
if (shape()) {
// Workaround for #19644 - Shaped windows shouldn't have decoration
if (!app_noborder) {
// Only when shape is detected for the first time, still let the user to override
app_noborder = true;
noborder = true;
updateDecoration(true);
@ -752,8 +733,7 @@ void Client::updateShape()
// Decoration mask (i.e. 'else' here) setting is done in setMask()
// when the decoration calls it or when the decoration is created/destroyed
updateInputShape();
if( compositing())
{
if (compositing()) {
addRepaintFull();
addWorkspaceRepaint(visibleRect()); // In case shape change removes part of this window
}
@ -769,8 +749,8 @@ void Client::updateInputShape()
{
if (hiddenPreview()) // Sets it to none, don't change
return;
if( Extensions::shapeInputAvailable())
{ // There appears to be no way to find out if a window has input
if (Extensions::shapeInputAvailable()) {
// There appears to be no way to find out if a window has input
// shape set or not, so always propagate the input shape
// (it's the same like the bounding shape by default).
// Also, build the shape using a helper window, not directly
@ -802,8 +782,8 @@ void Client::setMask( const QRegion& reg, int mode )
return;
_mask = r;
Window shape_window = frameId();
if( shape() )
{ // The same way of applying a shape without strange intermediate states like above
if (shape()) {
// The same way of applying a shape without strange intermediate states like above
if (shape_helper_window == None)
shape_helper_window = XCreateSimpleWindow(display(), rootWindow(),
0, 0, 1, 1, 0, 0, 0);
@ -813,12 +793,10 @@ void Client::setMask( const QRegion& reg, int mode )
XShapeCombineMask(display(), shape_window, ShapeBounding, 0, 0, None, ShapeSet);
else if (mode == X::Unsorted)
XShapeCombineRegion(display(), shape_window, ShapeBounding, 0, 0, _mask.handle(), ShapeSet);
else
{
else {
QVector< QRect > rects = _mask.rects();
XRectangle* xrects = new XRectangle[rects.count()];
for( int i = 0; i < rects.count(); ++i )
{
for (int i = 0; i < rects.count(); ++i) {
xrects[i].x = rects[i].x();
xrects[i].y = rects[i].y();
xrects[i].width = rects[i].width();
@ -828,8 +806,8 @@ void Client::setMask( const QRegion& reg, int mode )
xrects, rects.count(), ShapeSet, mode);
delete[] xrects;
}
if( shape() )
{ // The rest of the applyign using a temporary window
if (shape()) {
// The rest of the applyign using a temporary window
XRectangle rec = { 0, 0, clientSize().width(), clientSize().height() };
XShapeCombineRectangles(display(), shape_helper_window, ShapeBounding,
clientPos().x(), clientPos().y(), &rec, 1, ShapeSubtract, Unsorted);
@ -867,8 +845,8 @@ bool Client::isMinimizable() const
{
if (isSpecialWindow())
return false;
if( isTransient() )
{ // #66868 - Let other xmms windows be minimized when the mainwindow is minimized
if (isTransient()) {
// #66868 - Let other xmms windows be minimized when the mainwindow is minimized
bool shown_mainwindow = false;
ClientList mainclients = mainClients();
for (ClientList::ConstIterator it = mainclients.constBegin();
@ -967,10 +945,9 @@ QRect Client::iconGeometry() const
QRect geom(r.pos.x, r.pos.y, r.size.width, r.size.height);
if (geom.isValid())
return geom;
else
{ // Check all mainwindows of this window (recursively)
foreach( Client* mainwin, mainClients() )
{
else {
// Check all mainwindows of this window (recursively)
foreach (Client * mainwin, mainClients()) {
geom = mainwin->iconGeometry();
if (geom.isValid())
return geom;
@ -995,20 +972,16 @@ void Client::setShade( ShadeMode mode )
bool was_shade = isShade();
ShadeMode was_shade_mode = shade_mode;
shade_mode = mode;
if( was_shade == isShade())
{
if (was_shade == isShade()) {
if (decoration != NULL) // Decoration may want to update after e.g. hover-shade changes
decoration->shadeChange();
return; // No real change in shaded state
}
if( shade_mode == ShadeNormal )
{
if (shade_mode == ShadeNormal) {
if (isShown(true) && isOnCurrentDesktop())
Notify::raise(Notify::ShadeUp);
}
else if( shade_mode == ShadeNone )
{
} else if (shade_mode == ShadeNone) {
if (isShown(true) && isOnCurrentDesktop())
Notify::raise(Notify::ShadeDown);
}
@ -1020,8 +993,8 @@ void Client::setShade( ShadeMode mode )
decoration->borders(border_left, border_right, border_top, border_bottom);
// TODO: All this unmapping, resizing etc. feels too much duplicated from elsewhere
if ( isShade())
{ // shade_mode == ShadeNormal
if (isShade()) {
// shade_mode == ShadeNormal
addWorkspaceRepaint(visibleRect());
// Shade
shade_geometry_change = true;
@ -1033,16 +1006,13 @@ void Client::setShade( ShadeMode mode )
XSelectInput(display(), wrapper, ClientWinMask | SubstructureNotifyMask);
plainResize(s);
shade_geometry_change = false;
if( isActive())
{
if (isActive()) {
if (was_shade_mode == ShadeHover)
workspace()->activateNextClient(this);
else
workspace()->focusToNull();
}
}
else
{
} else {
shade_geometry_change = true;
QSize s(sizeForClientSize(clientSize()));
shade_geometry_change = false;
@ -1088,7 +1058,8 @@ void Client::cancelShadeHoverTimer()
}
void Client::toggleShade()
{ // If the mode is ShadeHover or ShadeActive, cancel shade too
{
// If the mode is ShadeHover or ShadeActive, cancel shade too
setShade(shade_mode == ShadeNone ? ShadeNormal : ShadeNone);
}
@ -1096,8 +1067,7 @@ void Client::updateVisibility()
{
if (deleting)
return;
if( hidden && ( clientGroup() == NULL || clientGroup()->visible() == this ))
{
if (hidden && (clientGroup() == NULL || clientGroup()->visible() == this)) {
info->setState(NET::Hidden, NET::Hidden);
setSkipTaskbar(true, false); // Also hide from taskbar
if (compositing() && options->hiddenPreviews == HiddenPreviewsAlways)
@ -1108,8 +1078,7 @@ void Client::updateVisibility()
}
if (clientGroup() == NULL || clientGroup()->visible() == this)
setSkipTaskbar(original_skip_taskbar, false); // Reset from 'hidden'
if( minimized )
{
if (minimized) {
info->setState(NET::Hidden, NET::Hidden);
if (compositing() && options->hiddenPreviews == HiddenPreviewsAlways)
internalKeep(Allowed);
@ -1118,16 +1087,14 @@ void Client::updateVisibility()
return;
}
info->setState(0, NET::Hidden);
if( !isOnCurrentDesktop())
{
if (!isOnCurrentDesktop()) {
if (compositing() && options->hiddenPreviews != HiddenPreviewsNever)
internalKeep(Allowed);
else
internalHide(Allowed);
return;
}
if( !isOnCurrentActivity())
{
if (!isOnCurrentActivity()) {
if (compositing() && options->hiddenPreviews != HiddenPreviewsNever)
internalKeep(Allowed);
else
@ -1138,8 +1105,7 @@ void Client::updateVisibility()
for (ClientList::ConstIterator it = group()->members().constBegin();
it != group()->members().constEnd();
++it)
if( (*it)->isDesktop() )
{
if ((*it)->isDesktop()) {
belongs_to_desktop = true;
break;
}
@ -1156,8 +1122,7 @@ void Client::exportMappingState( int s )
{
assert(client != None);
assert(!deleting || s == WithdrawnState);
if( s == WithdrawnState )
{
if (s == WithdrawnState) {
XDeleteProperty(display(), window(), atoms->wm_state);
return;
}
@ -1228,13 +1193,11 @@ void Client::map( allowed_t )
if (decoration != NULL)
decoration->widget()->show(); // Not really necessary, but let it know the state
XMapWindow(display(), frameId());
if( !isShade())
{
if (!isShade()) {
XMapWindow(display(), wrapper);
XMapWindow(display(), client);
exportMappingState(NormalState);
}
else
} else
exportMappingState(IconicState);
}
@ -1272,14 +1235,11 @@ void Client::unmap( allowed_t )
*/
void Client::updateHiddenPreview()
{
if( hiddenPreview() )
{
if (hiddenPreview()) {
workspace()->forceRestacking();
if (Extensions::shapeInputAvailable())
XShapeCombineRectangles(display(), frameId(), ShapeInput, 0, 0, NULL, 0, ShapeSet, Unsorted);
}
else
{
} else {
workspace()->forceRestacking();
updateInputShape();
}
@ -1325,13 +1285,11 @@ void Client::closeWindow()
// Update user time, because the window may create a confirming dialog.
updateUserTime();
if ( Pdeletewindow )
{
if (Pdeletewindow) {
Notify::raise(Notify::Close);
sendClientMessage(window(), atoms->wm_protocols, atoms->wm_delete_window);
pingWindow();
}
else // Client will not react on wm_delete_window. We have not choice
} else // Client will not react on wm_delete_window. We have not choice
// but destroy his connection to the XServer.
killWindow();
}
@ -1384,8 +1342,7 @@ void Client::gotPing( Time timestamp )
return;
delete ping_timer;
ping_timer = NULL;
if( process_killer != NULL )
{
if (process_killer != NULL) {
process_killer->kill();
// Recycle when the process manager has noticed that the process exited
// a delete process_killer here sometimes causes a hang in waitForFinished
@ -1413,19 +1370,14 @@ void Client::killProcess( bool ask, Time timestamp )
if (pid <= 0 || machine.isEmpty()) // Needed properties missing
return;
kDebug(1212) << "Kill process:" << pid << "(" << machine << ")";
if( !ask )
{
if( machine != "localhost" )
{
if (!ask) {
if (machine != "localhost") {
QStringList lst;
lst << machine << "kill" << QString::number(pid);
QProcess::startDetached("xon", lst);
}
else
} else
::kill(pid, SIGTERM);
}
else
{
} else {
process_killer = new QProcess(this);
connect(process_killer, SIGNAL(error(QProcess::ProcessError)), SLOT(processKillerExited()));
connect(process_killer, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(processKillerExited()));
@ -1448,8 +1400,7 @@ void Client::processKillerExited()
void Client::setSkipTaskbar(bool b, bool from_outside)
{
int was_wants_tab_focus = wantsTabFocus();
if( from_outside )
{
if (from_outside) {
b = rules()->checkSkipTaskbar(b);
original_skip_taskbar = b;
}
@ -1483,7 +1434,8 @@ void Client::setSkipSwitcher( bool set )
}
void Client::setModal(bool m)
{ // Qt-3.2 can have even modal normal windows :(
{
// Qt-3.2 can have even modal normal windows :(
if (modal == m)
return;
modal = m;
@ -1504,8 +1456,8 @@ void Client::setDesktop( int desktop )
int was_desk = desk;
desk = desktop;
info->setDesktop(desktop);
if(( was_desk == NET::OnAllDesktops ) != ( desktop == NET::OnAllDesktops ))
{ // onAllDesktops changed
if ((was_desk == NET::OnAllDesktops) != (desktop == NET::OnAllDesktops)) {
// onAllDesktops changed
if (isShown(true))
Notify::raise(isOnAllDesktops() ? Notify::OnAllDesktops : Notify::NotOnAllDesktops);
workspace()->updateOnAllDesktopsOfTransients(this);
@ -1548,14 +1500,12 @@ void Client::setOnActivity( const QString &activity, bool enable )
QStringList newActivitiesList = activities();
if (newActivitiesList.contains(activity) == enable) //nothing to do
return;
if (enable)
{
if (enable) {
QStringList allActivities = workspace()->activityList();
if (!allActivities.contains(activity)) //bogus ID
return;
newActivitiesList.append(activity);
}
else
} else
newActivitiesList.removeOne(activity);
setOnActivities(newActivitiesList);
}
@ -1566,8 +1516,7 @@ void Client::setOnActivity( const QString &activity, bool enable )
void Client::setOnActivities(QStringList newActivitiesList)
{
QStringList allActivities = workspace()->activityList();
if( newActivitiesList.size() == allActivities.size() || newActivitiesList.isEmpty() )
{
if (newActivitiesList.size() == allActivities.size() || newActivitiesList.isEmpty()) {
setOnAllActivities(true);
return;
}
@ -1651,15 +1600,12 @@ void Client::setOnAllActivities( bool on )
{
if (on == isOnAllActivities())
return;
if( on )
{
if (on) {
activityList.clear();
XChangeProperty(display(), window(), atoms->activities, XA_STRING, 8,
PropModeReplace, (const unsigned char *)"ALL", 3);
updateActivities(true);
}
else
{
} else {
setOnActivity(Workspace::self()->currentActivity(), true);
workspace()->updateOnAllActivitiesOfTransients(this);
}
@ -1670,8 +1616,7 @@ void Client::setOnAllActivities( bool on )
*/
void Client::takeActivity(int flags, bool handled, allowed_t)
{
if( !handled || !Ptakeactivity )
{
if (!handled || !Ptakeactivity) {
if (flags & ActivityFocus)
takeFocus(Allowed);
if (flags & ActivityRaise)
@ -1741,8 +1686,7 @@ bool Client::providesContextHelp() const
*/
void Client::showContextHelp()
{
if( Pcontexthelp )
{
if (Pcontexthelp) {
sendClientMessage(window(), atoms->wm_protocols, atoms->net_wm_context_help);
QWhatsThis::enterWhatsThisMode(); // SELI TODO: ?
}
@ -1779,8 +1723,7 @@ QChar PDF(0x202C);
void Client::setCaption(const QString& _s, bool force)
{
QString s = _s;
if( s != cap_normal || force )
{
if (s != cap_normal || force) {
bool reset_name = force;
for (int i = 0; i < s.length(); ++i)
if (!s[i].isPrint())
@ -1792,28 +1735,24 @@ void Client::setCaption( const QString& _s, bool force )
machine_suffix = QString(" <@") + wmClientMachine(true) + '>' + LRM;
QString shortcut_suffix = !shortcut().isEmpty() ? (" {" + shortcut().toString() + '}') : QString();
cap_suffix = machine_suffix + shortcut_suffix;
if(( !isSpecialWindow() || isToolbar() ) && workspace()->findClient( FetchNameInternalPredicate( this )))
{
if ((!isSpecialWindow() || isToolbar()) && workspace()->findClient(FetchNameInternalPredicate(this))) {
int i = 2;
do
{
do {
cap_suffix = machine_suffix + " <" + QString::number(i) + '>' + LRM + shortcut_suffix;
i++;
} while (workspace()->findClient(FetchNameInternalPredicate(this)));
info->setVisibleName(caption().toUtf8());
reset_name = false;
}
if(( was_suffix && cap_suffix.isEmpty() ) || reset_name )
{ // If it was new window, it may have old value still set, if the window is reused
if ((was_suffix && cap_suffix.isEmpty()) || reset_name) {
// If it was new window, it may have old value still set, if the window is reused
info->setVisibleName("");
info->setVisibleIconName("");
}
else if( !cap_suffix.isEmpty() && !cap_iconic.isEmpty())
} else if (!cap_suffix.isEmpty() && !cap_iconic.isEmpty())
// Keep the same suffix in iconic name if it's set
info->setVisibleIconName((cap_iconic + cap_suffix).toUtf8());
if( isManaged() && decoration != NULL )
{
if (isManaged() && decoration != NULL) {
if (client_group)
client_group->updateItems();
decoration->captionChange();
@ -1833,12 +1772,10 @@ void Client::fetchIconicName()
s = QString::fromUtf8(info->iconName());
else
s = KWindowSystem::readNameProperty(window(), XA_WM_ICON_NAME);
if( s != cap_iconic )
{
if (s != cap_iconic) {
bool was_set = !cap_iconic.isEmpty();
cap_iconic = s;
if( !cap_suffix.isEmpty())
{
if (!cap_suffix.isEmpty()) {
if (!cap_iconic.isEmpty()) // Keep the same suffix in iconic name if it's set
info->setVisibleIconName((s + cap_suffix).toUtf8());
else if (was_set)
@ -1867,8 +1804,7 @@ void Client::setClientShown( bool shown )
{
if (deleting)
return; // Don't change shown status if this client is being deleted
if( shown && hidden )
{
if (shown && hidden) {
map(Allowed);
hidden = false;
//updateVisibility();
@ -1879,8 +1815,7 @@ void Client::setClientShown( bool shown )
autoRaise();
workspace()->updateFocusChains(this, Workspace::FocusChainMakeFirst);
}
if( !shown && !hidden )
{
if (!shown && !hidden) {
unmap(Allowed);
hidden = true;
//updateVisibility();
@ -1900,8 +1835,7 @@ void Client::getWMHints()
input = true;
window_group = None;
urgency = false;
if( hints )
{
if (hints) {
if (hints->flags & InputHint)
input = hints->input;
if (hints->flags & WindowGroupHint)
@ -1914,7 +1848,8 @@ void Client::getWMHints()
updateAllowedActions(); // Group affects isMinimizable()
}
void Client::sl_activated() {
void Client::sl_activated()
{
emit s_activated();
}
@ -1922,8 +1857,7 @@ void Client::getMotifHints()
{
bool mgot_noborder, mnoborder, mresize, mmove, mminimize, mmaximize, mclose;
Motif::readFlags(client, mgot_noborder, mnoborder, mresize, mmove, mminimize, mmaximize, mclose);
if( mgot_noborder )
{
if (mgot_noborder) {
motif_noborder = mnoborder;
// If we just got a hint telling us to hide decorations, we do so.
if (motif_noborder)
@ -1933,12 +1867,11 @@ void Client::getMotifHints()
else if (!motif_noborder && !app_noborder)
noborder = false;
}
if( !hasNETSupport() )
{ // NETWM apps should set type and size constraints
if (!hasNETSupport()) {
// NETWM apps should set type and size constraints
motif_may_resize = mresize; // This should be set using minsize==maxsize, but oh well
motif_may_move = mmove;
}
else
} else
motif_may_resize = motif_may_move = true;
// mminimize; - Ignore, bogus - E.g. shading or sending to another desktop is "minimizing" too
@ -1953,22 +1886,19 @@ void Client::readIcons( Window win, QPixmap* icon, QPixmap* miniicon, QPixmap* b
// Get the icons, allow scaling
if (icon != NULL)
*icon = KWindowSystem::icon(win, 32, 32, true, KWindowSystem::NETWM | KWindowSystem::WMHints);
if( miniicon != NULL )
{
if (miniicon != NULL) {
if (icon == NULL || !icon->isNull())
*miniicon = KWindowSystem::icon(win, 16, 16, true, KWindowSystem::NETWM | KWindowSystem::WMHints);
else
*miniicon = QPixmap();
}
if( bigicon != NULL )
{
if (bigicon != NULL) {
if (icon == NULL || !icon->isNull())
*bigicon = KWindowSystem::icon(win, 64, 64, false, KWindowSystem::NETWM | KWindowSystem::WMHints);
else
*bigicon = QPixmap();
}
if( hugeicon != NULL )
{
if (hugeicon != NULL) {
if (icon == NULL || !icon->isNull())
*hugeicon = KWindowSystem::icon(win, 128, 128, false, KWindowSystem::NETWM | KWindowSystem::WMHints);
else
@ -1980,28 +1910,27 @@ void Client::getIcons()
{
// First read icons from the window itself
readIcons(window(), &icon_pix, &miniicon_pix, &bigicon_pix, &hugeicon_pix);
if( icon_pix.isNull() )
{ // Then try window group
if (icon_pix.isNull()) {
// Then try window group
icon_pix = group()->icon();
miniicon_pix = group()->miniIcon();
bigicon_pix = group()->bigIcon();
hugeicon_pix = group()->hugeIcon();
}
if( icon_pix.isNull() && isTransient() )
{ // Then mainclients
if (icon_pix.isNull() && isTransient()) {
// Then mainclients
ClientList mainclients = mainClients();
for (ClientList::ConstIterator it = mainclients.constBegin();
it != mainclients.constEnd() && icon_pix.isNull();
++it )
{
++it) {
icon_pix = (*it)->icon();
miniicon_pix = (*it)->miniIcon();
bigicon_pix = (*it)->bigIcon();
hugeicon_pix = (*it)->hugeIcon();
}
}
if( icon_pix.isNull())
{ // And if nothing else, load icon from classhint or xapp icon
if (icon_pix.isNull()) {
// And if nothing else, load icon from classhint or xapp icon
icon_pix = KWindowSystem::icon(window(), 32, 32, true, KWindowSystem::ClassHint | KWindowSystem::XApp);
miniicon_pix = KWindowSystem::icon(window(), 16, 16, true, KWindowSystem::ClassHint | KWindowSystem::XApp);
bigicon_pix = KWindowSystem::icon(window(), 64, 64, false, KWindowSystem::ClassHint | KWindowSystem::XApp);
@ -2035,10 +1964,8 @@ void Client::getWindowProtocols()
Pcontexthelp = 0;
Pping = 0;
if( XGetWMProtocols( display(), window(), &p, &n ))
{
for( i = 0; i < n; ++i )
{
if (XGetWMProtocols(display(), window(), &p, &n)) {
for (i = 0; i < n; ++i) {
if (p[i] == atoms->wm_delete_window)
Pdeletewindow = 1;
else if (p[i] == atoms->wm_take_focus)
@ -2069,15 +1996,13 @@ void Client::getSyncCounter()
int ret = XGetWindowProperty(display(), window(), atoms->net_wm_sync_request_counter,
0, 1, false, XA_CARDINAL, &retType, &formatRet, &nItemRet, &byteRet, &propRet);
if( ret == Success && formatRet == 32 )
{
if (ret == Success && formatRet == 32) {
sync_counter = *(long*)(propRet);
XSyncIntToValue(&sync_counter_value, 0);
XSyncValue zero;
XSyncIntToValue(&zero, 0);
XSyncSetCounter(display(), sync_counter, zero);
if( sync_alarm == None )
{
if (sync_alarm == None) {
XSyncAlarmAttributes attrs;
attrs.trigger.counter = sync_counter;
attrs.trigger.value_type = XSyncRelative;
@ -2140,7 +2065,8 @@ bool Client::wantsInput() const
}
bool Client::isSpecialWindow() const
{ // TODO
{
// TODO
return isDesktop() || isDock() || isSplash() || isTopMenu() || isToolbar();
}
@ -2153,8 +2079,7 @@ void Client::updateCursor()
if (!isResizable() || isShade())
m = PositionCenter;
QCursor c;
switch( m )
{
switch(m) {
case PositionTopLeft:
case PositionBottomRight:
c = Qt::SizeFDiagCursor;
@ -2280,16 +2205,13 @@ void Client::checkActivities()
//otherwise, somebody else changed it. we need to validate before reacting
QStringList allActivities = workspace()->activityList();
if (allActivities.isEmpty())
{
if (allActivities.isEmpty()) {
kDebug() << "no activities!?!?";
//don't touch anything, there's probably something bad going on and we don't wanna make it worse
return;
}
for ( int i = 0; i < newActivitiesList.size(); ++i )
{
if ( ! allActivities.contains( newActivitiesList.at(i) ) )
{
for (int i = 0; i < newActivitiesList.size(); ++i) {
if (! allActivities.contains(newActivitiesList.at(i))) {
kDebug() << "invalid:" << newActivitiesList.at(i);
newActivitiesList.removeAt(i--);
}

View File

@ -56,7 +56,8 @@ class QProcess;
class QTimer;
class KStartupInfoData;
namespace SWrapper {
namespace SWrapper
{
class Client;
}
@ -64,7 +65,8 @@ typedef QPair<SWrapper::Client*, QScriptValue> ClientResolution;
namespace KWin
{
namespace TabBox {
namespace TabBox
{
class TabBoxClientImpl;
}
@ -139,8 +141,7 @@ class Client
void destroyClient();
/// How to resize the window in order to obey constains (mainly aspect ratios)
enum Sizemode
{
enum Sizemode {
SizemodeAny,
SizemodeFixedW, ///< Try not to affect width
SizemodeFixedH, ///< Try not to affect height
@ -191,8 +192,12 @@ class Client
bool isFullScreenable(bool fullscreen_hack = false) const;
bool isActiveFullScreen() const;
bool userCanSetFullScreen() const;
QRect geometryFSRestore() const { return geom_fs_restore; } // Only for session saving
int fullScreenMode() const { return fullscreen_mode; } // only for session saving
QRect geometryFSRestore() const {
return geom_fs_restore; // Only for session saving
}
int fullScreenMode() const {
return fullscreen_mode; // only for session saving
}
bool noBorder() const;
void setNoBorder(bool set);
@ -358,25 +363,39 @@ class Client
*/
bool hasOffscreenXineramaStrut() const;
bool isMove() const
{
bool isMove() const {
return moveResizeMode && mode == PositionCenter;
}
bool isResize() const
{
bool isResize() const {
return moveResizeMode && mode != PositionCenter;
}
// Decorations <-> Effects
const QPixmap *topDecoPixmap() const { return &decorationPixmapTop; }
const QPixmap *leftDecoPixmap() const { return &decorationPixmapLeft; }
const QPixmap *bottomDecoPixmap() const { return &decorationPixmapBottom; }
const QPixmap *rightDecoPixmap() const { return &decorationPixmapRight; }
const QPixmap *topDecoPixmap() const {
return &decorationPixmapTop;
}
const QPixmap *leftDecoPixmap() const {
return &decorationPixmapLeft;
}
const QPixmap *bottomDecoPixmap() const {
return &decorationPixmapBottom;
}
const QPixmap *rightDecoPixmap() const {
return &decorationPixmapRight;
}
int paddingLeft() const { return padding_left; }
int paddingRight() const { return padding_right; }
int paddingTop() const { return padding_top; }
int paddingBottom() const { return padding_bottom; }
int paddingLeft() const {
return padding_left;
}
int paddingRight() const {
return padding_right;
}
int paddingTop() const {
return padding_top;
}
int paddingBottom() const {
return padding_bottom;
}
bool decorationPixmapRequiresRepaint();
void ensureDecorationPixmapsPainted();
@ -398,7 +417,9 @@ class Client
void layoutDecorationRects(QRect &left, QRect &top, QRect &right, QRect &bottom, CoordinateMode mode) const;
virtual void addRepaintFull();
TabBox::TabBoxClientImpl* tabBoxClient() const { return m_tabBoxClient; }
TabBox::TabBoxClientImpl* tabBoxClient() const {
return m_tabBoxClient;
}
//sets whether the client should be treated as a SessionInteract window
void setSessionInteract(bool needed);
@ -568,8 +589,7 @@ class Client
QRect initialMoveResizeGeom;
XSizeHints xSizeHint;
void sendSyntheticConfigureNotify();
enum MappingState
{
enum MappingState {
Withdrawn, ///< Not handled, as per ICCCM WithdrawnState
Mapped, ///< The frame is mapped
Unmapped, ///< The frame is not mapped
@ -631,8 +651,7 @@ class Client
QPixmap hugeicon_pix;
QCursor cursor;
// DON'T reorder - Saved to config files !!!
enum FullScreenMode
{
enum FullScreenMode {
FullScreenNone,
FullScreenNormal,
FullScreenHack ///< Non-NETWM fullscreen (noborder and size of desktop)
@ -658,8 +677,7 @@ class Client
unsigned long allowed_actions;
QSize client_size;
int block_geometry_updates; // > 0 = New geometry is remembered, but not actually set
enum PendingGeometry_t
{
enum PendingGeometry_t {
PendingGeometryNone,
PendingGeometryNormal,
PendingGeometryForced
@ -709,9 +727,12 @@ class GeometryUpdatesBlocker
{
public:
GeometryUpdatesBlocker(Client* c)
: cl( c ) { cl->blockGeometryUpdates( true ); }
~GeometryUpdatesBlocker()
{ cl->blockGeometryUpdates( false ); }
: cl(c) {
cl->blockGeometryUpdates(true);
}
~GeometryUpdatesBlocker() {
cl->blockGeometryUpdates(false);
}
private:
Client* cl;

View File

@ -56,8 +56,7 @@ void ClientGroup::add( Client* c, int before, bool becomeVisible )
// 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);
}
@ -67,8 +66,7 @@ void ClientGroup::add( Client* c, int before, bool becomeVisible )
ShadeMode oldShadeMode = c->shadeMode();
if (c->shadeMode() != clients_[visible_]->shadeMode())
c->setShade(clients_[visible_]->shadeMode());
if( c->shadeMode() != clients_[visible_]->shadeMode() )
{
if (c->shadeMode() != clients_[visible_]->shadeMode()) {
if (oldGroup) // Re-add to old group if required
c->setClientGroup(oldGroup);
// One need to trigger decoration repaint on the group to
@ -79,8 +77,7 @@ void ClientGroup::add( Client* c, int before, bool becomeVisible )
QRect oldGeom = c->geometry();
if (c->geometry() != clients_[visible_]->geometry())
c->setGeometry(clients_[visible_]->geometry());
if( c->geometry() != 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
@ -90,8 +87,7 @@ void ClientGroup::add( Client* c, int before, bool becomeVisible )
}
if (c->desktop() != clients_[visible_]->desktop())
c->setDesktop(clients_[visible_]->desktop());
if( c->desktop() != clients_[visible_]->desktop() )
{
if (c->desktop() != clients_[visible_]->desktop()) {
if (c->geometry() != oldGeom)
c->setGeometry(oldGeom); // Restore old geometry
if (c->shadeMode() != oldShadeMode)
@ -123,13 +119,11 @@ void ClientGroup::add( Client* c, int before, bool becomeVisible )
c->setClientGroup(this); // Let the client know which group it belongs to
// Actually add to new group
if( before >= 0 )
{
if (before >= 0) {
if (visible_ >= before)
visible_++;
clients_.insert(before, c);
}
else
} else
clients_.append(c);
if (!becomeVisible) // Hide before adding
c->setClientShown(false);
@ -157,8 +151,7 @@ void ClientGroup::remove( Client* c, const QRect& newGeom, bool toNullGroup )
{
if (!c)
return;
if( clients_.count() < 2 )
{
if (clients_.count() < 2) {
c->setClientGroup(NULL);
Workspace::self()->removeClientGroup(this); // Remove immediately
delete this;
@ -182,8 +175,7 @@ void ClientGroup::remove( Client* c, const QRect& newGeom, bool toNullGroup )
updateMinMaxSize();
c->setClientGroup(toNullGroup ? NULL : new ClientGroup(c));
if( newGeom.isValid() )
{
if (newGeom.isValid()) {
// HACK: if the group was maximized, one needs to make some checks on the future client maximize mode
// because the transition from maximized to MaximizeRestore is not handled properly in setGeometry when
// the new geometry size is unchanged.
@ -209,8 +201,7 @@ void ClientGroup::closeAll()
{
Client* front;
ClientList list(clients_);
while( !list.isEmpty() )
{
while (!list.isEmpty()) {
front = list.front();
list.pop_front();
if (front != clients_[visible_])
@ -280,10 +271,8 @@ void ClientGroup::setVisible( Client* c )
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 ((*i) != main && (!only || (*i) == only)) {
if ((*i)->isMinimized() != main->isMinimized()) {
if (main->isMinimized())
(*i)->minimize(true);
else
@ -315,8 +304,7 @@ void ClientGroup::updateStates( Client* main, Client* only )
void ClientGroup::updateItems()
{
items_.clear();
for( ClientList::const_iterator i = clients_.constBegin(); i != clients_.constEnd(); ++i )
{
for (ClientList::const_iterator i = clients_.constBegin(); i != clients_.constEnd(); ++i) {
QIcon icon((*i)->icon());
icon.addPixmap((*i)->miniIcon());
items_.append(ClientGroupItem((*i)->caption(), icon));
@ -328,8 +316,7 @@ 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 )
{
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())
@ -340,8 +327,7 @@ void ClientGroup::updateMinMaxSize()
maxSize_.setHeight((*i)->maxSize().height());
}
if (minSize_.width() > maxSize_.width() ||
minSize_.height() > maxSize_.height() )
{
minSize_.height() > maxSize_.height()) {
//kWarning(1212) << "ClientGroup's min size is greater than its max size. Setting max to min.";
maxSize_ = minSize_;
}

View File

@ -50,7 +50,8 @@ class Client;
* 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:
/**

View File

@ -89,27 +89,20 @@ void Workspace::setupCompositing()
#ifdef KWIN_HAVE_COMPOSITING
if (scene != NULL)
return;
if( !options->useCompositing && getenv( "KWIN_COMPOSE") == NULL )
{
if (!options->useCompositing && getenv("KWIN_COMPOSE") == NULL) {
kDebug(1212) << "Compositing is turned off in options or disabled";
return;
}
else if( compositingSuspended )
{
} else if (compositingSuspended) {
kDebug(1212) << "Compositing is suspended";
return;
}
else if( !CompositingPrefs::compositingPossible() )
{
} else if (!CompositingPrefs::compositingPossible()) {
kError(1212) << "Compositing is not possible";
return;
}
CompositingType type = options->compositingMode;
if( getenv( "KWIN_COMPOSE" ))
{
if (getenv("KWIN_COMPOSE")) {
char c = getenv("KWIN_COMPOSE")[ 0 ];
switch( c )
{
switch(c) {
case 'O':
kDebug(1212) << "Compositing forced to OpenGL mode by environment variable";
type = OpenGLCompositing;
@ -136,15 +129,13 @@ void Workspace::setupCompositing()
connect(cm_selection, SIGNAL(lostOwnership()), SLOT(lostCMSelection()));
cm_selection->claim(true); // force claiming
switch( type )
{
switch(type) {
/*case 'B':
kDebug( 1212 ) << "X compositing";
scene = new SceneBasic( this );
break; // don't fall through (this is a testing one) */
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
case OpenGLCompositing:
{
case OpenGLCompositing: {
kDebug(1212) << "Initializing OpenGL compositing";
// Some broken drivers crash on glXQuery() so to prevent constant KWin crashes:
@ -153,8 +144,7 @@ void Workspace::setupCompositing()
if (unsafeConfig.readEntry("OpenGLIsUnsafe", false))
kWarning(1212) << "KWin has detected that your OpenGL library is unsafe to use, "
"falling back to XRender.";
else
{
else {
unsafeConfig.writeEntry("OpenGLIsUnsafe", true);
unsafeConfig.sync();
@ -189,8 +179,7 @@ void Workspace::setupCompositing()
delete cm_selection;
return;
}
if( scene == NULL || scene->initFailed())
{
if (scene == NULL || scene->initFailed()) {
kError(1212) << "Failed to initialize compositing, compositing disabled";
kError(1212) << "Consult http://techbase.kde.org/Projects/KWin/4.0-release-notes#Setting_up";
delete scene;
@ -200,13 +189,11 @@ void Workspace::setupCompositing()
}
xrrRefreshRate = KWin::currentRefreshRate();
fpsInterval = (options->maxFpsInterval << 10);
if ( scene->waitSyncAvailable() ) // if we do vsync, set the fps to the next multiple of the vblank rate
{
if (scene->waitSyncAvailable()) { // if we do vsync, set the fps to the next multiple of the vblank rate
vBlankInterval = (1000 << 10) / xrrRefreshRate;
fpsInterval -= (fpsInterval % vBlankInterval);
fpsInterval = qMax(fpsInterval, vBlankInterval);
}
else
} else
vBlankInterval = 1 << 10; // no sync - DO NOT set "0", would cause div-by-zero segfaults.
vBlankPadding = 3; // vblank rounding errors... :-(
nextPaintReference = QTime::currentTime();
@ -267,10 +254,9 @@ void Workspace::finishCompositing()
repaints_region = QRegion();
for (ClientList::ConstIterator it = clients.constBegin();
it != clients.constEnd();
++it )
{ // forward all opacity values to the frame in case there'll be other CM running
if( (*it)->opacity() != 1.0 )
{
++it) {
// forward all opacity values to the frame in case there'll be other CM running
if ((*it)->opacity() != 1.0) {
NETWinInfo2 i(display(), (*it)->frameId(), rootWindow(), 0);
i.setOpacity(static_cast< unsigned long >((*it)->opacity() * 0xffffffff));
}
@ -306,14 +292,12 @@ void Workspace::slotToggleCompositing()
void Workspace::toggleCompositing()
{
slotToggleCompositing();
if( compositingSuspended )
{
if (compositingSuspended) {
// when disabled show a shortcut how the user can get back compositing
QString shortcut, message;
if (KAction* action = qobject_cast<KAction*>(keys->action("Suspend Compositing")))
shortcut = action->globalShortcut().primary().toString(QKeySequence::NativeText);
if( !shortcut.isEmpty() && options->useCompositing )
{
if (!shortcut.isEmpty() && options->useCompositing) {
// display notification only if there is the shortcut
message = i18n("Desktop effects have been suspended by another application.<br/>"
"You can resume using the '%1' shortcut.", shortcut);
@ -340,8 +324,7 @@ void Workspace::suspendCompositing( bool suspend )
void Workspace::resetCompositing()
{
if( compositing())
{
if (compositing()) {
finishCompositing();
QTimer::singleShot(0, this, SLOT(setupCompositing()));
}
@ -381,13 +364,11 @@ void Workspace::addRepaintFull()
void Workspace::timerEvent(QTimerEvent *te)
{
if ( te->timerId() == compositeTimer )
{
if (te->timerId() == compositeTimer) {
killTimer(compositeTimer);
compositeTimer = 0;
performCompositing();
}
else
} else
QObject::timerEvent(te);
}
@ -395,8 +376,7 @@ void Workspace::performCompositing()
{
#ifdef KWIN_HAVE_COMPOSITING
if (((repaints_region.isEmpty() && !windowRepaintsPending()) // no damage
|| !overlay_visible )) // nothing is visible anyway
{
|| !overlay_visible)) { // nothing is visible anyway
vBlankPadding += 3;
scene->idle();
// Note: It would seem here we should undo suspended unredirect, but when scenes need
@ -407,8 +387,7 @@ void Workspace::performCompositing()
}
// create a list of all windows in the stacking order
ToplevelList windows = xStackingOrder();
foreach( EffectWindow* c, static_cast< EffectsHandlerImpl* >( effects )->elevatedWindows())
{
foreach (EffectWindow * c, static_cast< EffectsHandlerImpl* >(effects)->elevatedWindows()) {
Toplevel* t = static_cast< EffectWindowImpl* >(c)->window();
windows.removeAll(t);
windows.append(t);
@ -424,8 +403,8 @@ void Workspace::performCompositing()
if (c->readyForPainting())
windows.append(c);
#endif
foreach( Toplevel* c, windows )
{ // This could be possibly optimized WRT obscuring, but that'd need being already
foreach (Toplevel * c, windows) {
// This could be possibly optimized WRT obscuring, but that'd need being already
// past prePaint() phase - probably not worth it.
// TODO I think effects->transformWindowDamage() doesn't need to be called here,
// pre-paint will extend painted window areas as necessary.
@ -437,13 +416,12 @@ void Workspace::performCompositing()
// clear all repaints, so that post-pass can add repaints for the next repaint
repaints_region = QRegion();
QTime t = QTime::currentTime();
if ( scene->waitSyncAvailable() )
{ // vsync: paint the scene, than rebase the timer and use the duration for next timeout estimation
if (scene->waitSyncAvailable()) {
// vsync: paint the scene, than rebase the timer and use the duration for next timeout estimation
scene->paint(repaints, windows);
nextPaintReference = QTime::currentTime();
}
else
{ // no vsyc -> inversion: reset the timer, then paint the scene, this way we can provide a constant framerate
} else {
// no vsyc -> inversion: reset the timer, then paint the scene, this way we can provide a constant framerate
nextPaintReference = QTime::currentTime();
scene->paint(repaints, windows);
}
@ -491,16 +469,13 @@ void Workspace::setCompositeTimer()
// interval - "time since last paint completion" - "time we need to paint"
uint passed = nextPaintReference.msecsTo(QTime::currentTime()) << 10;
uint delay = fpsInterval;
if ( scene->waitSyncAvailable() )
{
if ( passed > fpsInterval )
{
if (scene->waitSyncAvailable()) {
if (passed > fpsInterval) {
delay = vBlankInterval;
passed %= vBlankInterval;
}
delay -= ((passed + ((scene->estimatedRenderTime() + vBlankPadding) << 10)) % vBlankInterval);
}
else
} else
delay = qBound(0, int(delay - passed), 250 << 10);
compositeTimer = startTimer(delay >> 10);
}
@ -551,8 +526,7 @@ void Workspace::checkCompositePaintTime( int msec )
// with high system load.
const int MAX_LONG_PAINT = 1000;
if (composite_paint_times.count() >= 3 && composite_paint_times[ 0 ] > MAX_LONG_PAINT
&& composite_paint_times[ 1 ] > MAX_LONG_PAINT && composite_paint_times[ 2 ] > MAX_LONG_PAINT )
{
&& composite_paint_times[ 1 ] > MAX_LONG_PAINT && composite_paint_times[ 2 ] > MAX_LONG_PAINT) {
kDebug(1212) << "Too long paint times, suspending";
tooslow = true;
}
@ -562,13 +536,11 @@ void Workspace::checkCompositePaintTime( int msec )
const int MAX_SHORT_PAINT = 100;
const int SHORT_TIME = 15000; // 15 sec
int time = 0;
foreach( int t, composite_paint_times )
{
foreach (int t, composite_paint_times) {
if (t < MAX_SHORT_PAINT)
break;
time += t;
if( time > SHORT_TIME ) // all paints in the given time were long
{
if (time > SHORT_TIME) { // all paints in the given time were long
kDebug(1212) << "Long paint times for long time, suspending";
tooslow = true;
break;
@ -576,8 +548,7 @@ void Workspace::checkCompositePaintTime( int msec )
}
if (composite_paint_times.count() > 1000)
composite_paint_times.removeLast();
if( tooslow )
{
if (tooslow) {
QTimer::singleShot(0, this, SLOT(suspendCompositing()));
QString shortcut, message;
if (KAction* action = qobject_cast<KAction*>(keys->action("Suspend Compositing")))
@ -603,8 +574,7 @@ void Workspace::setupOverlay( Window w )
XSetWindowBackgroundPixmap(display(), overlay, None);
overlay_shape = QRegion();
setOverlayShape(QRect(0, 0, displayWidth(), displayHeight()));
if( w != None )
{
if (w != None) {
XSetWindowBackgroundPixmap(display(), w, None);
XShapeCombineRectangles(display(), w, ShapeInput, 0, 0, NULL, 0, ShapeSet, Unsorted);
}
@ -639,8 +609,7 @@ void Workspace::setOverlayShape( const QRegion& reg )
XRectangle* xrects = new XRectangle[ rects.count()];
for (int i = 0;
i < rects.count();
++i )
{
++i) {
xrects[ i ].x = rects[ i ].x();
xrects[ i ].y = rects[ i ].y();
xrects[ i ].width = rects[ i ].width();
@ -694,8 +663,7 @@ void Workspace::delayedCheckUnredirect()
list.append(c);
foreach (Unmanaged * c, unmanaged)
list.append(c);
foreach( Toplevel* c, list )
{
foreach (Toplevel * c, list) {
if (c->updateUnredirectedState())
changed = true;
}
@ -706,8 +674,7 @@ void Workspace::delayedCheckUnredirect()
// Cut out parts from the overlay window where unredirected windows are,
// so that they are actually visible.
QRegion reg(0, 0, displayWidth(), displayHeight());
foreach( Toplevel* c, list )
{
foreach (Toplevel * c, list) {
if (c->unredirected())
reg -= c->geometry();
}
@ -740,8 +707,7 @@ void Toplevel::finishCompositing()
if (damage_handle == None)
return;
workspace()->checkUnredirect(true);
if( effect_window->window() == this ) // otherwise it's already passed to Deleted, don't free data
{
if (effect_window->window() == this) { // otherwise it's already passed to Deleted, don't free data
discardWindowPixmap();
delete effect_window;
}
@ -778,8 +744,7 @@ Pixmap Toplevel::createWindowPixmap()
XWindowAttributes attrs;
if (!XGetWindowAttributes(display(), frameId(), &attrs)
|| err.error(false)
|| attrs.width != width() || attrs.height != height() || attrs.map_state != IsViewable )
{
|| attrs.width != width() || attrs.height != height() || attrs.map_state != IsViewable) {
kDebug(1212) << "Creating window pixmap failed: " << this;
XFreePixmap(display(), pix);
pix = None;
@ -794,22 +759,22 @@ Pixmap Toplevel::createWindowPixmap()
#ifdef HAVE_XDAMAGE
// We must specify that the two events are a union so the compiler doesn't
// complain about strict aliasing rules.
typedef union { XEvent e; XDamageNotifyEvent de; } EventUnion;
typedef union {
XEvent e;
XDamageNotifyEvent de;
} EventUnion;
void Toplevel::damageNotifyEvent(XDamageNotifyEvent* e)
{
QRegion damage(e->area.x, e->area.y, e->area.width, e->area.height);
// compress
int cnt = 1;
while( XPending( display()))
{
while (XPending(display())) {
EventUnion e2;
if (XPeekEvent(display(), &e2.e) && e2.e.type == Extensions::damageNotifyEvent()
&& e2.e.xany.window == frameId())
{
&& e2.e.xany.window == frameId()) {
XNextEvent(display(), &e2.e);
if( cnt > 200 )
{
if (cnt > 200) {
// If there are way too many damage events in the queue, just discard them
// and damage the whole window. Otherwise the X server can just overload
// us with a flood of damage events. Should be probably optimized
@ -824,8 +789,7 @@ void Toplevel::damageNotifyEvent( XDamageNotifyEvent* e )
// slow with many rectangles, and there is little to gain by using
// many small rectangles (rather the opposite, several large should
// be often faster).
if( cnt > 50 )
{
if (cnt > 50) {
r.setLeft(r.left() / 100 * 100);
r.setRight((r.right() + 99) / 100 * 100);
r.setTop(r.top() / 100 * 100);
@ -869,11 +833,9 @@ void Toplevel::addDamage( int x, int y, int w, int h )
repaints_region += r;
static_cast<EffectsHandlerImpl*>(effects)->windowDamaged(effectWindow(), r);
// discard lanczos texture
if( effect_window )
{
if (effect_window) {
QVariant cachedTextureVariant = effect_window->data(LanczosCacheRole);
if( cachedTextureVariant.isValid() )
{
if (cachedTextureVariant.isValid()) {
GLTexture *cachedTexture = static_cast< GLTexture*>(cachedTextureVariant.value<void*>());
delete cachedTexture;
cachedTexture = 0;
@ -891,11 +853,9 @@ void Toplevel::addDamageFull()
repaints_region = rect();
static_cast<EffectsHandlerImpl*>(effects)->windowDamaged(effectWindow(), rect());
// discard lanczos texture
if( effect_window )
{
if (effect_window) {
QVariant cachedTextureVariant = effect_window->data(LanczosCacheRole);
if( cachedTextureVariant.isValid() )
{
if (cachedTextureVariant.isValid()) {
GLTexture *cachedTexture = static_cast< GLTexture*>(cachedTextureVariant.value<void*>());
delete cachedTexture;
cachedTexture = 0;
@ -956,17 +916,14 @@ bool Toplevel::updateUnredirectedState()
assert(compositing());
bool should = shouldUnredirect() && !unredirectSuspend && !shape() && !hasAlpha() && opacity() == 1.0 &&
!static_cast<EffectsHandlerImpl*>(effects)->activeFullScreenEffect();
if( should && !unredirect )
{
if (should && !unredirect) {
unredirect = true;
kDebug(1212) << "Unredirecting:" << this;
#ifdef HAVE_XCOMPOSITE
XCompositeUnredirectWindow(display(), frameId(), CompositeRedirectManual);
#endif
return true;
}
else if( !should && unredirect )
{
} else if (!should && unredirect) {
unredirect = false;
kDebug(1212) << "Redirecting:" << this;
#ifdef HAVE_XCOMPOSITE
@ -1005,13 +962,11 @@ void Client::finishCompositing()
bool Client::shouldUnredirect() const
{
if( isActiveFullScreen())
{
if (isActiveFullScreen()) {
ToplevelList stacking = workspace()->xStackingOrder();
for (int pos = stacking.count() - 1;
pos >= 0;
--pos )
{
--pos) {
Toplevel* c = stacking.at(pos);
if (c == this) // is not covered by any other window, ok to unredirect
return true;
@ -1041,13 +996,11 @@ bool Unmanaged::shouldUnredirect() const
return false;
// it must cover whole display or one xinerama screen, and be the topmost there
if (geometry() == workspace()->clientArea(FullArea, geometry().center(), workspace()->currentDesktop())
|| geometry() == workspace()->clientArea( ScreenArea, geometry().center(), workspace()->currentDesktop()))
{
|| geometry() == workspace()->clientArea(ScreenArea, geometry().center(), workspace()->currentDesktop())) {
ToplevelList stacking = workspace()->xStackingOrder();
for (int pos = stacking.count() - 1;
pos >= 0;
--pos )
{
--pos) {
Toplevel* c = stacking.at(pos);
if (c == this) // is not covered by any other window, ok to unredirect
return true;

View File

@ -56,13 +56,11 @@ bool CompositingPrefs::compositingPossible()
{
#ifdef KWIN_HAVE_COMPOSITING
Extensions::init();
if( !Extensions::compositeAvailable())
{
if (!Extensions::compositeAvailable()) {
kDebug(1212) << "No composite extension available";
return false;
}
if( !Extensions::damageAvailable())
{
if (!Extensions::damageAvailable()) {
kDebug(1212) << "No damage extension available";
return false;
}
@ -88,8 +86,7 @@ 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 )
@ -101,8 +98,7 @@ QString CompositingPrefs::compositingNotPossibleReason()
" is compiled.");
#else
if (!(Extensions::glxAvailable()
|| ( Extensions::renderAvailable() && Extensions::fixesAvailable())))
{
|| (Extensions::renderAvailable() && Extensions::fixesAvailable()))) {
return i18n("GLX/OpenGL and XRender/XFixes are not available.");
}
#endif
@ -115,8 +111,7 @@ QString CompositingPrefs::compositingNotPossibleReason()
void CompositingPrefs::detect()
{
if( !compositingPossible())
{
if (!compositingPossible()) {
return;
}
@ -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
@ -157,8 +151,7 @@ void CompositingPrefs::detect()
if (QProcess::execute(opengl_test) != 0)
setenv("LIBGL_ALWAYS_INDIRECT", "1", true);
}
if( !Extensions::glxAvailable())
{
if (!Extensions::glxAvailable()) {
kDebug(1212) << "No GLX available";
return;
}
@ -174,8 +167,7 @@ void CompositingPrefs::detect()
if (hasglx13)
oldreaddrawable = glXGetCurrentReadDrawable();
if( initGLXContext() )
{
if (initGLXContext()) {
detectDriverAndVersion();
applyDriverSpecificOptions();
}
@ -203,21 +195,18 @@ bool CompositingPrefs::initGLXContext()
attribs << None;
XVisualInfo* visinfo = glXChooseVisual(display(), DefaultScreen(display()), attribs.data());
if( !visinfo )
{
if (!visinfo) {
attribs.last() = GLX_DOUBLEBUFFER;
attribs << None;
visinfo = glXChooseVisual(display(), DefaultScreen(display()), attribs.data());
if (!visinfo)
{
if (!visinfo) {
kDebug(1212) << "Error: couldn't find RGB GLX visual";
return false;
}
}
mGLContext = glXCreateContext(display(), visinfo, NULL, True);
if ( !mGLContext )
{
if (!mGLContext) {
kDebug(1212) << "glXCreateContext failed";
XDestroyWindow(display(), mGLWindow);
return false;

View File

@ -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();

View File

@ -73,15 +73,13 @@ void Deleted::copyToDeleted( Toplevel* c )
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,

View File

@ -41,11 +41,21 @@ class Deleted
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; }
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;

View File

@ -101,21 +101,15 @@ void DesktopChangeOSD::desktopChanged( int 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
{
} else {
x--;
hash.insert(desktop, DesktopChangeItem::RIGHT);
desktop = m_wspace->desktopToRight(desktop);
@ -126,30 +120,22 @@ void DesktopChangeOSD::desktopChanged( int old )
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);
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
{
} else {
x--;
hash.insert(desktop, DesktopChangeItem::RIGHT);
desktop = m_wspace->desktopToRight(desktop);
@ -159,13 +145,10 @@ void DesktopChangeOSD::desktopChanged( int old )
}
// 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() )
{
foreach (QGraphicsItem * it, m_scene->items()) {
DesktopChangeItem* item = qgraphicsitem_cast< DesktopChangeItem* >(it);
if( item )
{
if( hash.contains( item->desktop() ) )
{
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()));
@ -173,13 +156,10 @@ void DesktopChangeOSD::desktopChanged( int old )
int stop = m_delayTime / numberOfArrows * (desktopDistance + 1) + m_delayTime * 0.15f;
start = qMax(start, 0);
item->setArrow(hash[ item->desktop()], start, stop);
}
else
{
} else {
item->setArrow(DesktopChangeItem::NONE, 0, 0);
}
if( old != m_wspace->currentDesktop() )
{
if (old != m_wspace->currentDesktop()) {
if (item->desktop() == m_wspace->currentDesktop())
item->startDesktopHighLightAnimation(m_delayTime * 0.33);
if (m_active && item->desktop() == old)
@ -187,16 +167,13 @@ void DesktopChangeOSD::desktopChanged( int old )
}
}
}
if( m_active )
{
if (m_active) {
// for text only we need to resize
if (m_textOnly)
resize();
// already active - just update and reset timer
update();
}
else
{
} else {
m_active = true;
resize();
show();
@ -226,19 +203,15 @@ void DesktopChangeOSD::drawBackground( QPainter* painter, const QRectF& rect )
void DesktopChangeOSD::numberDesktopsChanged()
{
foreach( QGraphicsItem* it, m_scene->items() )
{
foreach (QGraphicsItem * it, m_scene->items()) {
DesktopChangeItem* item = qgraphicsitem_cast<DesktopChangeItem*>(it);
if( item )
{
if (item) {
m_scene->removeItem(item);
}
}
if( !m_textOnly )
{
for( int i=1; i<=m_wspace->numberOfDesktops(); i++ )
{
if (!m_textOnly) {
for (int i = 1; i <= m_wspace->numberOfDesktops(); i++) {
DesktopChangeItem* item = new DesktopChangeItem(m_wspace, this, i);
m_scene->addItem(item);
}
@ -261,8 +234,7 @@ void DesktopChangeOSD::resize()
// 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 )
{
if (tempWidth != width) {
// have to adjust the height
width = tempWidth;
itemWidth = (width - (desktopGridSize.width() - 1) * 2 - left - right) / desktopGridSize.width();
@ -274,8 +246,7 @@ void DesktopChangeOSD::resize()
// we do not increase height, but it's bound to a third of screen height
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) /
@ -287,8 +258,7 @@ void DesktopChangeOSD::resize()
}
// 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() +
4 + left + right;
@ -302,14 +272,11 @@ void DesktopChangeOSD::resize()
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());
}
@ -321,11 +288,9 @@ void DesktopChangeOSD::resize()
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 )
{
if (item) {
item->setWidth(itemWidth);
item->setHeight(itemHeight);
QPoint coords = m_wspace->desktopGridCoords(item->desktop());
@ -333,8 +298,7 @@ void DesktopChangeOSD::resize()
top + fontMetrics().height() + 4 + coords.y()*(itemHeight + 4));
}
DesktopChangeText* text = qgraphicsitem_cast<DesktopChangeText*>(it);
if( text )
{
if (text) {
text->setPos(left, top);
text->setWidth(width - left - right);
if (m_textOnly)
@ -411,16 +375,14 @@ void DesktopChangeItem::setArrow( Arrow arrow, int start_delay, int hide_delay )
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 )
{
if (m_arrow != NONE) {
m_delayed_show_arrow_timer.start(start_delay);
m_delayed_hide_arrow_timer.start(hide_delay);
}
@ -456,8 +418,7 @@ void DesktopChangeItem::showArrow()
m_arrowShown = true;
QPropertyAnimation *arrowAnimation = m_arrowAnimation.data();
if( !arrowAnimation )
{
if (!arrowAnimation) {
arrowAnimation = new QPropertyAnimation(this, "arrowValue");
arrowAnimation->setDuration(m_parent->getDelayTime() * 0.15f);
arrowAnimation->setStartValue(0.0);
@ -478,8 +439,7 @@ void DesktopChangeItem::hideArrow()
m_fadeInArrow = false;
QPropertyAnimation *arrowAnimation = m_arrowAnimation.data();
if( arrowAnimation )
{
if (arrowAnimation) {
arrowAnimation->setEasingCurve(QEasingCurve::OutQuad);
arrowAnimation->setDirection(QAbstractAnimation::Backward);
arrowAnimation->start(QAbstractAnimation::DeleteWhenStopped);
@ -491,8 +451,7 @@ void DesktopChangeItem::hideArrow()
void DesktopChangeItem::startDesktopHighLightAnimation(int time)
{
QPropertyAnimation *highLightAnimation = m_highLightAnimation.data();
if( !highLightAnimation )
{
if (!highLightAnimation) {
highLightAnimation = new QPropertyAnimation(this, "highLightValue");
highLightAnimation->setDuration(time);
highLightAnimation->setStartValue(0.0);
@ -513,8 +472,7 @@ void DesktopChangeItem::stopDesktopHighLightAnimation()
m_fadeInHighLight = false;
QPropertyAnimation *highLightAnimation = m_highLightAnimation.data();
if(highLightAnimation)
{
if (highLightAnimation) {
highLightAnimation->setEasingCurve(QEasingCurve::OutQuad);
highLightAnimation->setDirection(QAbstractAnimation::Backward);
highLightAnimation->start(QAbstractAnimation::DeleteWhenStopped);
@ -530,25 +488,20 @@ void DesktopChangeItem::arrowAnimationFinished()
void DesktopChangeItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* , QWidget*)
{
if (m_wspace->currentDesktop() == m_desktop || (!m_highLightAnimation.isNull() &&
m_highLightAnimation.data()->state() == QAbstractAnimation::Running) )
{
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 )
{
m_highLightAnimation.data()->state() == QAbstractAnimation::Running) {
// there is an animation - so we use transition from normal to active or vice versa
if( m_fadeInHighLight )
{
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
{
} else {
m_parent->itemFrame()->setElementPrefix("hover");
QPixmap normal = m_parent->itemFrame()->framePixmap();
m_parent->itemFrame()->setElementPrefix("normal");
@ -556,9 +509,7 @@ void DesktopChangeItem::paint( QPainter* painter, const QStyleOptionGraphicsItem
m_parent->itemFrame()->framePixmap(), 1.0 - m_highLightValue);
painter->drawPixmap(boundingRect().toRect(), result);
}
}
else
{
} else {
// no animation - just render the active frame
m_parent->itemFrame()->setElementPrefix("hover");
m_parent->itemFrame()->paintFrame(painter, boundingRect());
@ -567,9 +518,7 @@ void DesktopChangeItem::paint( QPainter* painter, const QStyleOptionGraphicsItem
rectColor.setAlphaF(0.6 * m_highLightValue);
QBrush rectBrush = QBrush(rectColor);
painter->fillRect(boundingRect().adjusted(left, top, -right, -bottom), rectBrush);
}
else
{
} else {
m_parent->itemFrame()->setElementPrefix("normal");
m_parent->itemFrame()->paintFrame(painter, boundingRect());
}
@ -591,8 +540,7 @@ void DesktopChangeItem::paint( QPainter* painter, const QStyleOptionGraphicsItem
QRect iconRect = QRect(boundingRect().x() + boundingRect().width() / 2 - iconWidth / 2,
boundingRect().y() + boundingRect().height() / 2 - iconWidth / 2,
iconWidth, iconWidth);
switch( m_arrow )
{
switch(m_arrow) {
case UP:
icon = KIconLoader::global()->loadIcon("go-up", KIconLoader::Desktop, iconWidth);
break;
@ -608,12 +556,10 @@ void DesktopChangeItem::paint( QPainter* painter, const QStyleOptionGraphicsItem
default:
break;
}
if( m_arrow != NONE )
{
if (m_arrow != NONE) {
if (!m_arrowAnimation.isNull() &&
m_arrowAnimation.data()->state() == QAbstractAnimation::Running &&
!qFuzzyCompare(m_arrowValue, qreal(1.0)) )
{
!qFuzzyCompare(m_arrowValue, qreal(1.0))) {
QPixmap temp(icon.size());
temp.fill(Qt::transparent);

View File

@ -44,12 +44,18 @@ class DesktopChangeText : public QGraphicsItem
enum { Type = UserType + 2 };
inline void setWidth( float width ) { m_width = width;};
inline void setHeight( float height ) { m_height = 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; };
inline virtual int type() const {
return Type;
};
private:
Workspace* m_wspace;
@ -67,8 +73,12 @@ class DesktopChangeOSD : public QGraphicsView
void desktopChanged(int old);
void numberDesktopsChanged();
inline Plasma::FrameSvg* itemFrame() { return &m_item_frame;};
inline int& getDelayTime() { return m_delayTime; };
inline Plasma::FrameSvg* itemFrame() {
return &m_item_frame;
};
inline int& getDelayTime() {
return m_delayTime;
};
protected:
virtual void hideEvent(QHideEvent*);
@ -101,16 +111,23 @@ class DesktopChangeItem : public QObject, public QGraphicsItem
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; };
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; };
inline virtual int type() const {
return Type;
};
enum Arrow
{
enum Arrow {
NONE,
LEFT,
RIGHT,

View File

@ -49,8 +49,7 @@ void Workspace::setNETDesktopLayout( Qt::Orientation orientation, int width, int
width = (desktopCount_ + height - 1) / height;
else if ((height <= 0) && (width > 0))
height = (desktopCount_ + width - 1) / width;
while( width * height < desktopCount_ )
{
while (width * height < desktopCount_) {
if (orientation == Qt::Horizontal)
++width;
else
@ -98,11 +97,9 @@ int Workspace::desktopAbove( int id, bool wrap ) const
id = currentDesktop();
QPoint coords = desktopGridCoords(id);
assert(coords.x() >= 0);
for(;;)
{
for (;;) {
coords.ry()--;
if( coords.y() < 0 )
{
if (coords.y() < 0) {
if (wrap)
coords.setY(desktopGridSize_.height() - 1);
else
@ -120,11 +117,9 @@ int Workspace::desktopToRight( int id, bool wrap ) const
id = currentDesktop();
QPoint coords = desktopGridCoords(id);
assert(coords.x() >= 0);
for(;;)
{
for (;;) {
coords.rx()++;
if( coords.x() >= desktopGridSize_.width() )
{
if (coords.x() >= desktopGridSize_.width()) {
if (wrap)
coords.setX(0);
else
@ -142,11 +137,9 @@ int Workspace::desktopBelow( int id, bool wrap ) const
id = currentDesktop();
QPoint coords = desktopGridCoords(id);
assert(coords.x() >= 0);
for(;;)
{
for (;;) {
coords.ry()++;
if( coords.y() >= desktopGridSize_.height() )
{
if (coords.y() >= desktopGridSize_.height()) {
if (wrap)
coords.setY(0);
else
@ -164,11 +157,9 @@ int Workspace::desktopToLeft( int id, bool wrap ) const
id = currentDesktop();
QPoint coords = desktopGridCoords(id);
assert(coords.x() >= 0);
for(;;)
{
for (;;) {
coords.rx()--;
if( coords.x() < 0 )
{
if (coords.x() < 0) {
if (wrap)
coords.setX(desktopGridSize_.width() - 1);
else
@ -181,13 +172,15 @@ int Workspace::desktopToLeft( int id, bool wrap ) const
}
int Workspace::addDesktop(QPoint coords)
{ // TODO
{
// TODO
Q_UNUSED(coords);
return 0;
}
void Workspace::deleteDesktop(int id)
{ // TODO
{
// TODO
Q_UNUSED(id);
}

View File

@ -52,36 +52,29 @@ namespace KWin
static QByteArray readWindowProperty(Window win, long atom, long type, int format)
{
int len = 32768;
for(;;)
{
for (;;) {
unsigned char* data;
Atom rtype;
int rformat;
unsigned long nitems, after;
if (XGetWindowProperty(QX11Info::display(), win,
atom, 0, len, False, AnyPropertyType,
&rtype, &rformat, &nitems, &after, &data ) == Success )
{
if( after > 0 )
{
&rtype, &rformat, &nitems, &after, &data) == Success) {
if (after > 0) {
XFree(data);
len *= 2;
continue;
}
if( long( rtype ) == type && rformat == format )
{
if (long(rtype) == type && rformat == format) {
int bytelen = format == 8 ? nitems : format == 16 ? nitems * sizeof(short) : nitems * sizeof(long);
QByteArray ret(reinterpret_cast< const char* >(data), bytelen);
XFree(data);
return ret;
}
else // wrong format, type or something
{
} else { // wrong format, type or something
XFree(data);
return QByteArray();
}
}
else // XGetWindowProperty() failed
} else // XGetWindowProperty() failed
return QByteArray();
}
}
@ -122,8 +115,7 @@ void EffectsHandlerImpl::reconfigure()
KService::List offers = KServiceTypeTrader::self()->query("KWin/Effect");
QStringList effectsToBeLoaded;
// First unload necessary effects
foreach( const KService::Ptr &service, offers )
{
foreach (const KService::Ptr & service, offers) {
KPluginInfo plugininfo(service);
plugininfo.load(conf);
@ -136,16 +128,13 @@ void EffectsHandlerImpl::reconfigure()
}
QStringList newLoaded;
// Then load those that should be loaded
foreach( const QString &effectName, effectsToBeLoaded )
{
if( !isEffectLoaded( effectName ))
{
foreach (const QString & effectName, effectsToBeLoaded) {
if (!isEffectLoaded(effectName)) {
loadEffect(effectName);
newLoaded.append(effectName);
}
}
foreach( const EffectPair &ep, loaded_effects )
{
foreach (const EffectPair & ep, loaded_effects) {
if (!newLoaded.contains(ep.first)) // don't reconfigure newly loaded effects
ep.second->reconfigure(Effect::ReconfigureAll);
}
@ -154,8 +143,7 @@ void EffectsHandlerImpl::reconfigure()
// the idea is that effects call this function again which calls the next one
void EffectsHandlerImpl::prePaintScreen(ScreenPrePaintData& data, int time)
{
if( current_paint_screen < loaded_effects.size())
{
if (current_paint_screen < loaded_effects.size()) {
loaded_effects[current_paint_screen++].second->prePaintScreen(data, time);
--current_paint_screen;
}
@ -164,19 +152,16 @@ void EffectsHandlerImpl::prePaintScreen( ScreenPrePaintData& data, int time )
void EffectsHandlerImpl::paintScreen(int mask, QRegion region, ScreenPaintData& data)
{
if( current_paint_screen < loaded_effects.size())
{
if (current_paint_screen < loaded_effects.size()) {
loaded_effects[current_paint_screen++].second->paintScreen(mask, region, data);
--current_paint_screen;
}
else
} else
scene->finalPaintScreen(mask, region, data);
}
void EffectsHandlerImpl::postPaintScreen()
{
if( current_paint_screen < loaded_effects.size())
{
if (current_paint_screen < loaded_effects.size()) {
loaded_effects[current_paint_screen++].second->postPaintScreen();
--current_paint_screen;
}
@ -185,8 +170,7 @@ void EffectsHandlerImpl::postPaintScreen()
void EffectsHandlerImpl::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
{
if( current_paint_window < loaded_effects.size())
{
if (current_paint_window < loaded_effects.size()) {
loaded_effects[current_paint_window++].second->prePaintWindow(w, data, time);
--current_paint_window;
}
@ -195,24 +179,19 @@ void EffectsHandlerImpl::prePaintWindow( EffectWindow* w, WindowPrePaintData& da
void EffectsHandlerImpl::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{
if( current_paint_window < loaded_effects.size())
{
if (current_paint_window < loaded_effects.size()) {
loaded_effects[current_paint_window++].second->paintWindow(w, mask, region, data);
--current_paint_window;
}
else
} else
scene->finalPaintWindow(static_cast<EffectWindowImpl*>(w), mask, region, data);
}
void EffectsHandlerImpl::paintEffectFrame(EffectFrame* frame, QRegion region, double opacity, double frameOpacity)
{
if( current_paint_effectframe < loaded_effects.size())
{
if (current_paint_effectframe < loaded_effects.size()) {
loaded_effects[current_paint_effectframe++].second->paintEffectFrame(frame, region, opacity, frameOpacity);
--current_paint_effectframe;
}
else
{
} else {
const EffectFrameImpl* frameImpl = static_cast<const EffectFrameImpl*>(frame);
frameImpl->finalRender(region, opacity, frameOpacity);
}
@ -220,8 +199,7 @@ void EffectsHandlerImpl::paintEffectFrame( EffectFrame* frame, QRegion region, d
void EffectsHandlerImpl::postPaintWindow(EffectWindow* w)
{
if( current_paint_window < loaded_effects.size())
{
if (current_paint_window < loaded_effects.size()) {
loaded_effects[current_paint_window++].second->postPaintWindow(w);
--current_paint_window;
}
@ -238,19 +216,16 @@ bool EffectsHandlerImpl::provides( Effect::Feature ef )
void EffectsHandlerImpl::drawWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{
if( current_draw_window < loaded_effects.size())
{
if (current_draw_window < loaded_effects.size()) {
loaded_effects[current_draw_window++].second->drawWindow(w, mask, region, data);
--current_draw_window;
}
else
} else
scene->finalDrawWindow(static_cast<EffectWindowImpl*>(w), mask, region, data);
}
void EffectsHandlerImpl::buildQuads(EffectWindow* w, WindowQuadList& quadList)
{
if( current_build_quads < loaded_effects.size())
{
if (current_build_quads < loaded_effects.size()) {
loaded_effects[current_build_quads++].second->buildQuads(w, quadList);
--current_build_quads;
}
@ -506,8 +481,7 @@ void EffectsHandlerImpl::registerPropertyType( long atom, bool reg )
{
if (reg)
++registered_atoms[ atom ]; // initialized to 0 if not present yet
else
{
else {
if (--registered_atoms[ atom ] == 0)
registered_atoms.remove(atom);
}
@ -874,10 +848,8 @@ Window EffectsHandlerImpl::createInputWindow( Effect* e, int x, int y, int w, in
void EffectsHandlerImpl::destroyInputWindow(Window w)
{
foreach( const InputWindowPair &pos, input_windows )
{
if( pos.second == w )
{
foreach (const InputWindowPair & pos, input_windows) {
if (pos.second == w) {
input_windows.removeAll(pos);
XDestroyWindow(display(), w);
return;
@ -890,14 +862,10 @@ bool EffectsHandlerImpl::checkInputWindowEvent( XEvent* e )
{
if (e->type != ButtonPress && e->type != ButtonRelease && e->type != MotionNotify)
return false;
foreach( const InputWindowPair &pos, input_windows )
{
if( pos.second == e->xany.window )
{
switch( e->type )
{
case ButtonPress:
{
foreach (const InputWindowPair & pos, input_windows) {
if (pos.second == e->xany.window) {
switch(e->type) {
case ButtonPress: {
XButtonEvent* e2 = &e->xbutton;
Qt::MouseButton button = x11ToQtMouseButton(e2->button);
Qt::MouseButtons buttons = x11ToQtMouseButtons(e2->state) | button;
@ -907,8 +875,7 @@ bool EffectsHandlerImpl::checkInputWindowEvent( XEvent* e )
pos.first->windowInputMouseEvent(pos.second, &ev);
break; // --->
}
case ButtonRelease:
{
case ButtonRelease: {
XButtonEvent* e2 = &e->xbutton;
Qt::MouseButton button = x11ToQtMouseButton(e2->button);
Qt::MouseButtons buttons = x11ToQtMouseButtons(e2->state) & ~button;
@ -918,8 +885,7 @@ bool EffectsHandlerImpl::checkInputWindowEvent( XEvent* e )
pos.first->windowInputMouseEvent(pos.second, &ev);
break; // --->
}
case MotionNotify:
{
case MotionNotify: {
XMotionEvent* e2 = &e->xmotion;
QMouseEvent ev(QEvent::MouseMove, QPoint(e2->x, e2->y), QPoint(e2->x_root, e2->y_root),
Qt::NoButton, x11ToQtMouseButtons(e2->state), x11ToQtKeyboardModifiers(e2->state));
@ -987,8 +953,7 @@ KLibrary* EffectsHandlerImpl::findEffectLibrary( KService* service )
{
QString libname = service->library();
KLibrary* library = new KLibrary(libname);
if( !library )
{
if (!library) {
kError(1212) << "couldn't open library for effect '" <<
service->name() << "'" << endl;
return 0;
@ -1008,8 +973,7 @@ void EffectsHandlerImpl::toggleEffect( const QString& name )
QStringList EffectsHandlerImpl::loadedEffects() const
{
QStringList listModules;
for(QVector< EffectPair >::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it)
{
for (QVector< EffectPair >::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) {
listModules << (*it).first;
}
return listModules;
@ -1020,8 +984,7 @@ QStringList EffectsHandlerImpl::listOfEffects() const
KService::List offers = KServiceTypeTrader::self()->query("KWin/Effect");
QStringList listOfModules;
// First unload necessary effects
foreach( const KService::Ptr &service, offers )
{
foreach (const KService::Ptr & service, offers) {
KPluginInfo plugininfo(service);
listOfModules << plugininfo.pluginName();
}
@ -1041,10 +1004,8 @@ bool EffectsHandlerImpl::loadEffect( const QString& name )
kWarning(1212) << "Effect names usually have kwin4_effect_ prefix" ;
// Make sure a single effect won't be loaded multiple times
for(QVector< EffectPair >::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it)
{
if( (*it).first == name )
{
for (QVector< EffectPair >::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) {
if ((*it).first == name) {
kDebug(1212) << "EffectsHandler::loadEffect : Effect already loaded : " << name;
return true;
}
@ -1056,23 +1017,20 @@ bool EffectsHandlerImpl::loadEffect( const QString& name )
QString constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg(internalname);
KService::List offers = KServiceTypeTrader::self()->query("KWin/Effect", constraint);
if(offers.isEmpty())
{
if (offers.isEmpty()) {
kError(1212) << "Couldn't find effect " << name << endl;
return false;
}
KService::Ptr service = offers.first();
KLibrary* library = findEffectLibrary(service.data());
if( !library )
{
if (!library) {
return false;
}
QString version_symbol = "effect_version_" + name;
KLibrary::void_function_ptr version_func = library->resolveFunction(version_symbol.toAscii());
if( version_func == NULL )
{
if (version_func == NULL) {
kWarning(1212) << "Effect " << name << " does not provide required API version, ignoring.";
return false;
}
@ -1082,8 +1040,7 @@ bool EffectsHandlerImpl::loadEffect( const QString& name )
// With major 0 minor must match exactly.
if (version > KWIN_EFFECT_API_VERSION
|| (version >> 8) != KWIN_EFFECT_API_VERSION_MAJOR
|| ( KWIN_EFFECT_API_VERSION_MAJOR == 0 && version != KWIN_EFFECT_API_VERSION ))
{
|| (KWIN_EFFECT_API_VERSION_MAJOR == 0 && version != KWIN_EFFECT_API_VERSION)) {
kWarning(1212) << "Effect " << name << " requires unsupported API version " << version;
return false;
}
@ -1091,19 +1048,16 @@ bool EffectsHandlerImpl::loadEffect( const QString& name )
KLibrary::void_function_ptr supported_func = library->resolveFunction(supported_symbol.toAscii().data());
QString create_symbol = "effect_create_" + name;
KLibrary::void_function_ptr create_func = library->resolveFunction(create_symbol.toAscii().data());
if( supported_func )
{
if (supported_func) {
typedef bool (*t_supportedfunc)();
t_supportedfunc supported = reinterpret_cast<t_supportedfunc>(supported_func);
if(!supported())
{
if (!supported()) {
kWarning(1212) << "EffectsHandler::loadEffect : Effect " << name << " is not supported" ;
library->unload();
return false;
}
}
if(!create_func)
{
if (!create_func) {
kError(1212) << "EffectsHandler::loadEffect : effect_create function not found" << endl;
library->unload();
return false;
@ -1115,10 +1069,8 @@ bool EffectsHandlerImpl::loadEffect( const QString& name )
// TODO: detect circular deps
KPluginInfo plugininfo(service);
QStringList dependencies = plugininfo.dependencies();
foreach( const QString &depName, dependencies )
{
if( !loadEffect(depName))
{
foreach (const QString & depName, dependencies) {
if (!loadEffect(depName)) {
kError(1212) << "EffectsHandler::loadEffect : Couldn't load dependencies for effect " << name << endl;
library->unload();
return false;
@ -1143,13 +1095,10 @@ void EffectsHandlerImpl::unloadEffect( const QString& name )
assert(current_build_quads == 0);
assert(current_transform == 0);
for( QMap< int, EffectPair >::iterator it = effect_order.begin(); it != effect_order.end(); ++it)
{
if ( it.value().first == name )
{
for (QMap< int, EffectPair >::iterator it = effect_order.begin(); it != effect_order.end(); ++it) {
if (it.value().first == name) {
kDebug(1212) << "EffectsHandler::unloadEffect : Unloading Effect : " << name;
if( activeFullScreenEffect() == it.value().second )
{
if (activeFullScreenEffect() == it.value().second) {
setActiveFullScreenEffect(0);
}
delete it.value().second;
@ -1166,8 +1115,7 @@ void EffectsHandlerImpl::unloadEffect( const QString& name )
void EffectsHandlerImpl::reconfigureEffect(const QString& name)
{
for (QVector< EffectPair >::iterator it = loaded_effects.begin(); it != loaded_effects.end(); ++it)
if ( (*it).first == name )
{
if ((*it).first == name) {
(*it).second->reconfigure(Effect::ReconfigureAll);
return;
}
@ -1186,8 +1134,7 @@ void EffectsHandlerImpl::effectsChanged()
{
loaded_effects.clear();
// kDebug(1212) << "Recreating effects' list:";
foreach( const EffectPair &effect, effect_order )
{
foreach (const EffectPair & effect, effect_order) {
// kDebug(1212) << effect.first;
loaded_effects.append(effect);
}
@ -1211,8 +1158,7 @@ EffectWindowImpl::EffectWindowImpl() : EffectWindow()
EffectWindowImpl::~EffectWindowImpl()
{
QVariant cachedTextureVariant = data(LanczosCacheRole);
if( cachedTextureVariant.isValid() )
{
if (cachedTextureVariant.isValid()) {
GLTexture *cachedTexture = static_cast< GLTexture*>(cachedTextureVariant.value<void*>());
delete cachedTexture;
}
@ -1562,8 +1508,7 @@ bool EffectWindowImpl::isModal() const
EffectWindow* EffectWindowImpl::findModal()
{
if( Client* c = dynamic_cast< Client* >( toplevel ))
{
if (Client* c = dynamic_cast< Client* >(toplevel)) {
if (Client* c2 = c->findModal())
return c2->effectWindow();
}
@ -1572,8 +1517,7 @@ EffectWindow* EffectWindowImpl::findModal()
EffectWindowList EffectWindowImpl::mainWindows() const
{
if( Client* c = dynamic_cast< Client* >( toplevel ))
{
if (Client* c = dynamic_cast< Client* >(toplevel)) {
EffectWindowList ret;
ClientList mainclients = c->mainClients();
foreach (Client * tmp, mainclients)
@ -1597,32 +1541,28 @@ WindowQuadList EffectWindowImpl::buildQuads( bool force ) const
void EffectWindowImpl::minimize() const
{
if( Client* c = dynamic_cast< Client* >( toplevel ))
{
if (Client* c = dynamic_cast< Client* >(toplevel)) {
c->minimize();
}
}
void EffectWindowImpl::unminimize() const
{
if( Client* c = dynamic_cast< Client* >( toplevel ))
{
if (Client* c = dynamic_cast< Client* >(toplevel)) {
c->unminimize();
}
}
void EffectWindowImpl::closeWindow() const
{
if( Client* c = dynamic_cast< Client* >( toplevel ))
{
if (Client* c = dynamic_cast< Client* >(toplevel)) {
c->closeWindow();
}
}
bool EffectWindowImpl::visibleInClientGroup() const
{
if( Client* c = dynamic_cast< Client* >( toplevel ))
{
if (Client* c = dynamic_cast< Client* >(toplevel)) {
if (!c->clientGroup())
return true;
return c == c->clientGroup()->visible();
@ -1684,8 +1624,7 @@ EffectFrameImpl::EffectFrameImpl( EffectFrameStyle style, bool staticSize, QPoin
, m_alignment(alignment)
, m_shader(NULL)
{
if( m_style == EffectFrameStyled )
{
if (m_style == EffectFrameStyled) {
m_frame.setImagePath("widgets/background");
m_frame.setCacheAllRenderedFrames(true);
m_selection.setImagePath("widgets/viewitem");
@ -1695,18 +1634,13 @@ EffectFrameImpl::EffectFrameImpl( EffectFrameStyle style, bool staticSize, QPoin
connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), this, SLOT(plasmaThemeChanged()));
}
if( effects->compositingType() == OpenGLCompositing )
{
if (effects->compositingType() == OpenGLCompositing) {
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
m_sceneFrame = new SceneOpenGL::EffectFrame(this);
#endif
}
else if( effects->compositingType() == XRenderCompositing )
{
} else if (effects->compositingType() == XRenderCompositing) {
m_sceneFrame = new SceneXrender::EffectFrame(this);
}
else
{
} else {
// that should not happen and will definitely crash!
m_sceneFrame = NULL;
}
@ -1724,18 +1658,16 @@ const QFont& EffectFrameImpl::font() const
void EffectFrameImpl::setFont(const QFont& font)
{
if (m_font == font)
{
if (m_font == font) {
return;
}
m_font = font;
QRect oldGeom = m_geometry;
if( !m_text.isEmpty() )
{
if (!m_text.isEmpty()) {
autoResize();
}
if( oldGeom == m_geometry )
{ // Wasn't updated in autoResize()
if (oldGeom == m_geometry) {
// Wasn't updated in autoResize()
m_sceneFrame->freeTextFrame();
}
}
@ -1754,19 +1686,16 @@ void EffectFrameImpl::setGeometry( const QRect& geometry, bool force )
{
QRect oldGeom = m_geometry;
m_geometry = geometry;
if( m_geometry == oldGeom && !force )
{
if (m_geometry == oldGeom && !force) {
return;
}
effects->addRepaint(oldGeom);
effects->addRepaint(m_geometry);
if( m_geometry.size() == oldGeom.size() && !force )
{
if (m_geometry.size() == oldGeom.size() && !force) {
return;
}
if( m_style == EffectFrameStyled )
{
if (m_style == EffectFrameStyled) {
qreal left, top, right, bottom;
m_frame.getMargins(left, top, right, bottom); // m_geometry is the inner geometry
m_frame.resizeFrame(m_geometry.adjusted(-left, -top, right, bottom).size());
@ -1783,12 +1712,10 @@ const QPixmap& EffectFrameImpl::icon() const
void EffectFrameImpl::setIcon(const QPixmap& icon)
{
m_icon = icon;
if( isCrossFade() )
{
if (isCrossFade()) {
m_sceneFrame->crossFadeIcon();
}
if( m_iconSize.isEmpty() ) // Set a size if we don't already have one
{
if (m_iconSize.isEmpty()) { // Set a size if we don't already have one
setIconSize(m_icon.size());
}
m_sceneFrame->freeIconFrame();
@ -1801,8 +1728,7 @@ const QSize& EffectFrameImpl::iconSize() const
void EffectFrameImpl::setIconSize(const QSize& size)
{
if( m_iconSize == size )
{
if (m_iconSize == size) {
return;
}
m_iconSize = size;
@ -1817,8 +1743,7 @@ void EffectFrameImpl::plasmaThemeChanged()
void EffectFrameImpl::render(QRegion region, double opacity, double frameOpacity)
{
if( m_geometry.isEmpty() )
{
if (m_geometry.isEmpty()) {
return; // Nothing to display
}
m_shader = NULL;
@ -1878,32 +1803,28 @@ const QString& EffectFrameImpl::text() const
void EffectFrameImpl::setText(const QString& text)
{
if( m_text == text )
{
if (m_text == text) {
return;
}
if( isCrossFade() )
{
if (isCrossFade()) {
m_sceneFrame->crossFadeText();
}
m_text = text;
QRect oldGeom = m_geometry;
autoResize();
if( oldGeom == m_geometry )
{ // Wasn't updated in autoResize()
if (oldGeom == m_geometry) {
// Wasn't updated in autoResize()
m_sceneFrame->freeTextFrame();
}
}
void EffectFrameImpl::setSelection(const QRect& selection)
{
if( selection == m_selectionGeometry )
{
if (selection == m_selectionGeometry) {
return;
}
m_selectionGeometry = selection;
if( m_selectionGeometry.size() != m_selection.frameSize().toSize() )
{
if (m_selectionGeometry.size() != m_selection.frameSize().toSize()) {
m_selection.resizeFrame(m_selectionGeometry.size());
}
// TODO; optimize to only recreate when resizing
@ -1917,13 +1838,11 @@ void EffectFrameImpl::autoResize()
QRect geometry;
// Set size
if( !m_text.isEmpty() )
{
if (!m_text.isEmpty()) {
QFontMetrics metrics(m_font);
geometry.setSize(metrics.size(0, m_text));
}
if( !m_icon.isNull() && !m_iconSize.isEmpty() )
{
if (!m_icon.isNull() && !m_iconSize.isEmpty()) {
geometry.setLeft(-m_iconSize.width());
if (m_iconSize.height() > geometry.height())
geometry.setHeight(m_iconSize.height());

View File

@ -338,34 +338,27 @@ class EffectFrameImpl
virtual void setPosition(const QPoint& point);
virtual const QString& text() const;
virtual void setText(const QString& text);
EffectFrameStyle style() const
{
EffectFrameStyle style() const {
return m_style;
};
Plasma::FrameSvg& frame()
{
Plasma::FrameSvg& frame() {
return m_frame;
}
bool isStatic() const
{
bool isStatic() const {
return m_static;
};
void finalRender(QRegion region, double opacity, double frameOpacity) const;
virtual void setShader( GLShader* shader )
{
virtual void setShader(GLShader* shader) {
m_shader = shader;
}
virtual GLShader* shader() const
{
virtual GLShader* shader() const {
return m_shader;
}
virtual void setSelection(const QRect& selection);
const QRect& selection() const
{
const QRect& selection() const {
return m_selectionGeometry;
}
Plasma::FrameSvg& selectionFrame()
{
Plasma::FrameSvg& selectionFrame() {
return m_selection;
}

View File

@ -58,8 +58,7 @@ bool LiquidEffect::loadData()
// NPOT textures that way
int texw = displayWidth();
int texh = displayHeight();
if( !GLTexture::NPOTTextureSupported() )
{
if (!GLTexture::NPOTTextureSupported()) {
kWarning(1212) << "NPOT textures not supported, wasting some memory" ;
texw = nearestPowerOfTwo(texw);
texh = nearestPowerOfTwo(texh);
@ -75,14 +74,12 @@ bool LiquidEffect::loadData()
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;
}
@ -106,8 +103,7 @@ bool LiquidEffect::supported()
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);
@ -121,8 +117,7 @@ void LiquidEffect::postPaintScreen()
// Call the next effect.
effects->postPaintScreen();
if(mValid)
{
if (mValid) {
// Disable render texture
assert(effects->popRenderTarget() == mRenderTarget);
mTexture->bind();

View File

@ -46,14 +46,11 @@ void ShakyMoveEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Wi
void ShakyMoveEffect::windowUserMovedResized(EffectWindow* c, bool first, bool last)
{
if( first )
{
if (first) {
if (windows.isEmpty())
timer.start(50);
windows[ c ] = 0;
}
else if( last )
{
} else if (last) {
windows.remove(c);
// just repaint whole screen, transformation is involved
effects->addRepaintFull();
@ -74,8 +71,7 @@ void ShakyMoveEffect::tick()
{
for (QHash< const EffectWindow*, int >::Iterator it = windows.begin();
it != windows.end();
++it )
{
++it) {
if (*it == SHAKY_MAX - 1)
*it = 0;
else

View File

@ -32,13 +32,11 @@ ShowPictureEffect::~ShowPictureEffect()
void ShowPictureEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
{
effects->paintScreen(mask, region, data);
if( init )
{
if (init) {
loadPicture();
init = false;
}
if( picture && region.intersects( pictureRect ))
{
if (picture && region.intersects(pictureRect)) {
glPushAttrib(GL_CURRENT_BIT | GL_ENABLE_BIT);
picture->bind();
glEnable(GL_BLEND);

View File

@ -62,8 +62,7 @@ void WavyWindowsEffect::paintWindow( EffectWindow* w, int mask, QRegion region,
// 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() )
{
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
@ -72,8 +71,7 @@ void WavyWindowsEffect::paintWindow( EffectWindow* w, int mask, QRegion region,
++i)
for (int j = 0;
j < 4;
++j )
{
++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);

View File

@ -26,8 +26,7 @@ void DrunkenEffect::prePaintScreen( ScreenPrePaintData& data, int time )
void DrunkenEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
{
if( windows.contains( w ))
{
if (windows.contains(w)) {
windows[ w ] += time / 1000.;
if (windows[ w ] < 1)
data.setTransformed();
@ -39,8 +38,7 @@ void DrunkenEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, i
void DrunkenEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{
if( !windows.contains( w ))
{
if (!windows.contains(w)) {
effects->paintWindow(w, mask, region, data);
return;
}

View File

@ -27,17 +27,13 @@ void FlameEffect::prePaintScreen( ScreenPrePaintData& data, int time )
void FlameEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
{
if( windows.contains( w ))
{
if( windows[ w ] < 1 )
{
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
{
} else {
windows.remove(w);
w->unrefWindow();
}
@ -47,12 +43,10 @@ void FlameEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int
void FlameEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{
if( windows.contains( w ))
{
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 )
{
foreach (const WindowQuad & quad, data.quads) {
if (quad.bottom() <= ylimit)
continue;
new_quads.append(quad);

View File

@ -63,8 +63,7 @@ bool GearsEffect::supported()
void GearsEffect::prePaintScreen(ScreenPrePaintData& data, int time)
{
if( m_active )
{
if (m_active) {
m_contentRotation += time * 360.0f / 20000.0f;
if (m_contentRotation > 360.0f)
m_contentRotation -= 360.0f;
@ -77,8 +76,7 @@ void GearsEffect::prePaintScreen( ScreenPrePaintData& data, int time )
void GearsEffect::postPaintScreen()
{
if( m_active )
{
if (m_active) {
effects->addRepaintFull();
}
effects->postPaintScreen();
@ -87,8 +85,7 @@ void GearsEffect::postPaintScreen()
void GearsEffect::paint()
{
if( m_active )
{
if (m_active) {
paintGears();
}
}
@ -123,14 +120,12 @@ void GearsEffect::gear( float inner_radius, float outer_radius, float width, int
/* draw front face */
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);
if( i < teeth )
{
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);
}
@ -141,8 +136,7 @@ void GearsEffect::gear( float inner_radius, float outer_radius, float width, int
/* draw front sides of teeth */
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);
@ -161,14 +155,12 @@ void GearsEffect::gear( float inner_radius, float outer_radius, float width, int
/* draw back face */
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);
if( i < teeth )
{
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);
}
@ -180,8 +172,7 @@ void GearsEffect::gear( float inner_radius, float outer_radius, float width, int
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);
@ -198,8 +189,7 @@ void GearsEffect::gear( float inner_radius, float outer_radius, float width, int
/* draw outward faces of teeth */
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);
@ -236,8 +226,7 @@ void GearsEffect::gear( float inner_radius, float outer_radius, float width, int
/* draw inside radius cylinder */
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);

View File

@ -39,21 +39,17 @@ KWIN_EFFECT( howto, HowtoEffect )
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;
@ -77,13 +73,11 @@ void HowtoEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int
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
@ -91,9 +85,7 @@ void HowtoEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Window
// 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
{
} else {
// For the second 500 milliseconds (progress being 500 to 1000), the window is
// faded in again.
// progress == 500 -> opacity *= 0.5
@ -110,8 +102,7 @@ void HowtoEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Window
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
}
@ -124,8 +115,7 @@ 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.

View File

@ -58,13 +58,11 @@ KickerEffect::KickerEffect()
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();
}
@ -80,36 +78,27 @@ void KickerEffect::prePaintScreen( ScreenPrePaintData& data, int time )
// 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 )
{
if (m_ascending) {
m_timeLine.addTime(time);
if( m_timeLine.progress() == 1.0 )
{
if (m_timeLine.progress() == 1.0) {
m_ascending = false;
}
}
else
{
} 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();
}
@ -124,16 +113,14 @@ 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 )
{
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
@ -161,8 +148,7 @@ void KickerEffect::slotLoadFinished( bool ok )
// 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
@ -181,8 +167,7 @@ void KickerEffect::slotLoadFinished( bool ok )
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;
@ -199,15 +184,13 @@ void KickerEffect::slotLoadFinished( bool ok )
// 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++ )
{
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);
@ -233,8 +216,7 @@ void KickerEffect::generateGoalImage()
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++ )
{
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,

View File

@ -43,8 +43,7 @@ void SlideTabsEffect::reconfigure( ReconfigureFlags )
void SlideTabsEffect::prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time)
{
if( motionManager.isManaging( w ) )
{
if (motionManager.isManaging(w)) {
data.setTransformed();
w->enablePainting(EffectWindow::PAINT_DISABLED);
timeLine.addTime(time);
@ -61,23 +60,18 @@ void SlideTabsEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Wi
void SlideTabsEffect::postPaintWindow(EffectWindow* w)
{
if( motionManager.isManaging( w ) )
{
if( w == inMove )
{
if (motionManager.isManaging(w)) {
if (w == inMove) {
QRect moving = calculateNextMove();
motionManager.moveWindow(w, moving);
if( direction && timeLine.progress() >= 0.5 )
{
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 )
{
} else if (timeLine.progress() >= 1.0) {
effects->setElevatedWindow(notMoving, false);
effects->setElevatedWindow(inMove, false);
motionManager.unmanage(notMoving);
@ -87,9 +81,7 @@ void SlideTabsEffect::postPaintWindow( EffectWindow* w )
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();
@ -99,8 +91,7 @@ void SlideTabsEffect::postPaintWindow( EffectWindow* w )
void SlideTabsEffect::prePaintScreen(ScreenPrePaintData &data, int time)
{
if( motionManager.managingWindows() )
{
if (motionManager.managingWindows()) {
motionManager.calculate(time);
data.mask |= Effect::PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
}

View File

@ -56,8 +56,7 @@ void SwivelTabsEffect::prePaintScreen( ScreenPrePaintData& data, int time )
void SwivelTabsEffect::prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time)
{
if( isActive && ( w == windows.show || w == windows.hide ) )
{
if (isActive && (w == windows.show || w == windows.hide)) {
data.quads = data.quads.makeGrid(40);
data.setTransformed();
w->enablePainting(EffectWindow::PAINT_DISABLED);
@ -68,8 +67,7 @@ void SwivelTabsEffect::prePaintWindow( EffectWindow *w, WindowPrePaintData &data
void SwivelTabsEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{
if( isActive && ( w == windows.show || w == windows.hide ) )
{
if (isActive && (w == windows.show || w == windows.hide)) {
for (int i = 0; i < data.quads.count(); ++i)
transformQuad(data.quads[i]);
}
@ -90,47 +88,38 @@ void SwivelTabsEffect::transformQuad( WindowQuad &quad )
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 )
{
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);
}
if( F < 0.5 )
{
if( horizontal )
{
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 )
{
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 )
{
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 )
{
if (vertical) {
quad[0].setY(cy - (height * F));
quad[3].setY(cy + (height * F));
quad[1].setY(cy - (height * F));

View File

@ -38,8 +38,7 @@ class SwivelTabsEffect : public Effect
virtual void clientGroupItemSwitched(EffectWindow* from, EffectWindow* to);
static bool supported();
private:
struct swivel
{
struct swivel {
EffectWindow* hide;
EffectWindow* show;
TimeLine time;

View File

@ -59,8 +59,7 @@ bool TestFBOEffect::supported()
void TestFBOEffect::prePaintScreen(ScreenPrePaintData& data, int time)
{
if(mValid)
{
if (mValid) {
data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
// Start rendering to texture
effects->pushRenderTarget(mRenderTarget);
@ -74,8 +73,7 @@ void TestFBOEffect::postPaintScreen()
// Call the next effect.
effects->postPaintScreen();
if(mValid)
{
if (mValid) {
// Disable render texture
assert(effects->popRenderTarget() == mRenderTarget);
mTexture->bind();

View File

@ -60,11 +60,9 @@ void TestInputEffect::windowInputMouseEvent( Window w, QEvent* e )
return;
QPoint pos = static_cast< QMouseEvent* >(e)->pos();
pos -= QPoint(0, 100); // adjust for transformation
foreach( EffectWindow* c, effects->stackingOrder())
{
foreach (EffectWindow * c, effects->stackingOrder()) {
if (/* TODO c->isShown( true ) && */c->isOnCurrentDesktop()
&& c->geometry().contains( pos ))
{
&& c->geometry().contains(pos)) {
effects->activateWindow(c);
return;
}

View File

@ -30,8 +30,7 @@ TestThumbnailEffect::TestThumbnailEffect()
void TestThumbnailEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
{
effects->paintScreen(mask, region, data);
if( active_window != NULL && region.contains( thumbnailRect()))
{
if (active_window != NULL && region.contains(thumbnailRect())) {
WindowPaintData data(active_window);
QRect region;
setPositionTransformations(data, region, active_window, thumbnailRect(), Qt::KeepAspectRatio);
@ -62,8 +61,7 @@ void TestThumbnailEffect::windowGeometryShapeChanged( EffectWindow* w, const QRe
void TestThumbnailEffect::windowClosed(EffectWindow* w)
{
if( w == active_window )
{
if (w == active_window) {
active_window = NULL;
effects->addRepaint(thumbnailRect());
}

View File

@ -88,14 +88,11 @@ void VideoRecordEffect::paintScreen( int mask, QRegion region, ScreenPaintData&
void VideoRecordEffect::postPaintScreen()
{
effects->postPaintScreen();
if( client != NULL )
{
if (client != NULL) {
#if 1
if( CapturyProcessRegionStart( client ) == CAPTURY_SUCCESS )
{
if (CapturyProcessRegionStart(client) == CAPTURY_SUCCESS) {
capture_region &= QRect(0, 0, displayWidth(), displayHeight()); // limit to screen
foreach( const QRect &r, capture_region.rects())
{
foreach (const QRect & r, capture_region.rects()) {
int gly = displayHeight() - r.y() - r.height(); // opengl coords
CapturyProcessRegion(client, r.x(), gly, r.width(), r.height());
}
@ -123,8 +120,7 @@ void VideoRecordEffect::startRecording()
config.windowHandle = rootWindow(); // TODO
config.cursor = true;
client = CapturyOpen(&config);
if( client == NULL )
{
if (client == NULL) {
kDebug(1212) << "Video recording init failed";
return;
}
@ -134,8 +130,7 @@ void VideoRecordEffect::startRecording()
while (QFile::exists(videoName)) {
autoincFilename(videoName);
}
if( CapturySetOutputFileName( client, QFile::encodeName( videoName ).constData() ) != CAPTURY_SUCCESS )
{
if (CapturySetOutputFileName(client, QFile::encodeName(videoName).constData()) != CAPTURY_SUCCESS) {
kDebug(1212) << "Video recording file open failed";
return;
}

View File

@ -235,8 +235,7 @@ void BlurEffect::drawWindow(EffectWindow *w, int mask, QRegion region, WindowPai
&& 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);
}

View File

@ -380,8 +380,7 @@ 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);
}

View File

@ -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;

View File

@ -86,23 +86,17 @@ void BoxSwitchEffect::reconfigure( ReconfigureFlags )
void BoxSwitchEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
{
if( activeTimeLine.value() != 0.0 && !mProxyActivated )
{
if( mMode == TabBoxWindowsMode || mMode == TabBoxWindowsAlternativeMode )
{
if( windows.contains( w ))
{
if (activeTimeLine.value() != 0.0 && !mProxyActivated) {
if (mMode == TabBoxWindowsMode || mMode == TabBoxWindowsAlternativeMode) {
if (windows.contains(w)) {
if (w == selected_window)
w->enablePainting(EffectWindow::PAINT_DISABLED_BY_CLIENT_GROUP);
else
data.setTranslucent();
w->enablePainting(EffectWindow::PAINT_DISABLED_BY_MINIMIZE | EffectWindow::PAINT_DISABLED_BY_DESKTOP);
}
}
else
{
if( painting_desktop )
{
} else {
if (painting_desktop) {
if (w->isOnDesktop(painting_desktop))
w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DESKTOP);
else
@ -117,17 +111,15 @@ void BoxSwitchEffect::prePaintScreen( ScreenPrePaintData& data, int time )
{
if (mActivated)
activeTimeLine.addTime(time);
else
{
else {
activeTimeLine.removeTime(time);
if( activeTimeLine.value() == 0.0 )
{ // No longer need the window data
if (activeTimeLine.value() == 0.0) {
// No longer need the window data
qDeleteAll(windows);
windows.clear();
}
}
if( mActivated && animation )
{
if (mActivated && animation) {
timeLine.addTime(time);
calculateItemSizes();
}
@ -137,22 +129,16 @@ void BoxSwitchEffect::prePaintScreen( ScreenPrePaintData& data, int time )
void BoxSwitchEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
{
effects->paintScreen(mask, region, data);
if( mActivated && !mProxyActivated )
{
if( mMode == TabBoxWindowsMode || mMode == TabBoxWindowsAlternativeMode )
{
if (mActivated && !mProxyActivated) {
if (mMode == TabBoxWindowsMode || mMode == TabBoxWindowsAlternativeMode) {
paintWindowsBox(region);
}
else
{
if( !painting_desktop )
{
} else {
if (!painting_desktop) {
thumbnailFrame->setSelection(desktops[ selected_desktop ]->area);
thumbnailFrame->render(region);
QHash< int, ItemInfo* >::const_iterator i;
for( i = desktops.constBegin(); i != desktops.constEnd(); ++i )
{
for (i = desktops.constBegin(); i != desktops.constEnd(); ++i) {
painting_desktop = i.key();
paintDesktopThumbnail(painting_desktop);
}
@ -170,23 +156,18 @@ void BoxSwitchEffect::paintWindowsBox(const QRegion& region)
thumbnailFrame->setSelection(windows[ selected_window ]->area);
thumbnailFrame->render(region);
if( (mAnimateSwitch && !mProxyActivated) || (mProxyActivated && mProxyAnimateSwitch) )
{
if ((mAnimateSwitch && !mProxyActivated) || (mProxyActivated && mProxyAnimateSwitch)) {
// HACK: PaintClipper is used because window split is somehow wrong if the height is greater than width
PaintClipper::push(frame_area);
QHash< EffectWindow*, ItemInfo* >::const_iterator i;
for( i = windows.constBegin(); i != windows.constEnd(); ++i )
{
for (i = windows.constBegin(); i != windows.constEnd(); ++i) {
paintWindowThumbnail(i.key());
paintWindowIcon(i.key());
}
PaintClipper::pop(frame_area);
}
else
{
} else {
QHash< EffectWindow*, ItemInfo* >::const_iterator i;
for( i = windows.constBegin(); i != windows.constEnd(); ++i )
{
for (i = windows.constBegin(); i != windows.constEnd(); ++i) {
paintWindowThumbnail(i.key());
paintWindowIcon(i.key());
}
@ -199,14 +180,11 @@ void BoxSwitchEffect::postPaintScreen()
effects->addRepaintFull();
if (!mActivated && activeTimeLine.value() != 0.0)
effects->addRepaintFull();
if( mActivated && animation )
{
if( timeLine.value() == 1.0 )
{
if (mActivated && animation) {
if (timeLine.value() == 1.0) {
timeLine.setProgress(0.0);
animation = false;
if( !scheduled_directions.isEmpty() )
{
if (!scheduled_directions.isEmpty()) {
direction = scheduled_directions.dequeue();
animation = true;
}
@ -223,10 +201,8 @@ void BoxSwitchEffect::postPaintScreen()
void BoxSwitchEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{
if (((mActivated && (mMode == TabBoxWindowsMode || mMode == TabBoxWindowsAlternativeMode))
|| ( !mActivated && activeTimeLine.value() != 0.0 )) && !mProxyActivated)
{
if( windows.contains( w ) && w != selected_window )
{
|| (!mActivated && activeTimeLine.value() != 0.0)) && !mProxyActivated) {
if (windows.contains(w) && w != selected_window) {
if (w->isMinimized() || !w->isOnCurrentDesktop())
// TODO: When deactivating minimized windows are not painted at all
data.opacity *= activeTimeLine.value() * bg_opacity;
@ -247,33 +223,25 @@ void BoxSwitchEffect::windowInputMouseEvent( Window w, QEvent* e )
pos += frame_area.topLeft();
// determine which item was clicked
if( mMode == TabBoxWindowsMode || mMode == TabBoxWindowsAlternativeMode )
{
if (mMode == TabBoxWindowsMode || mMode == TabBoxWindowsAlternativeMode) {
QHash< EffectWindow*, ItemInfo* >::const_iterator i;
for( i = windows.constBegin(); i != windows.constEnd(); ++i )
{
if( i.value()->clickable.contains( pos ))
{
for (i = windows.constBegin(); i != windows.constEnd(); ++i) {
if (i.value()->clickable.contains(pos)) {
effects->setTabBoxWindow(i.key());
break;
}
}
// special handling for second half of window in case of animation and even number of windows
if( mAnimateSwitch && ( windows.size() % 2 == 0 ) )
{
if (mAnimateSwitch && (windows.size() % 2 == 0)) {
QRect additionalRect = QRect(frame_area.x(), frame_area.y(),
item_max_size.width() * 0.5, item_max_size.height());
if( additionalRect.contains( pos ))
{
if (additionalRect.contains(pos)) {
effects->setTabBoxWindow(right_window);
}
}
}
else
{
} else {
QHash< int, ItemInfo* >::const_iterator i;
for( i = desktops.constBegin(); i != desktops.constEnd(); ++i )
{
for (i = desktops.constBegin(); i != desktops.constEnd(); ++i) {
if (i.value()->clickable.contains(pos))
effects->setTabBoxDesktop(i.key());
}
@ -283,24 +251,16 @@ void BoxSwitchEffect::windowInputMouseEvent( Window w, QEvent* e )
void BoxSwitchEffect::windowDamaged(EffectWindow* w, const QRect& damage)
{
Q_UNUSED(damage);
if( mActivated )
{
if( mMode == TabBoxWindowsMode || mMode == TabBoxWindowsAlternativeMode )
{
if( windows.contains( w ))
{
if (mActivated) {
if (mMode == TabBoxWindowsMode || mMode == TabBoxWindowsAlternativeMode) {
if (windows.contains(w)) {
effects->addRepaint(frame_area);
}
}
else
{
if( w->isOnAllDesktops())
{
} else {
if (w->isOnAllDesktops()) {
foreach (ItemInfo * info, desktops)
effects->addRepaint(info->area);
}
else
{
} else {
effects->addRepaint(desktops[ w->desktop()]->area);
}
}
@ -309,24 +269,16 @@ void BoxSwitchEffect::windowDamaged( EffectWindow* w, const QRect& damage )
void BoxSwitchEffect::windowGeometryShapeChanged(EffectWindow* w, const QRect& old)
{
if( mActivated )
{
if( mMode == TabBoxWindowsMode || mMode == TabBoxWindowsAlternativeMode )
{
if( windows.contains( w ) && w->size() != old.size())
{
if (mActivated) {
if (mMode == TabBoxWindowsMode || mMode == TabBoxWindowsAlternativeMode) {
if (windows.contains(w) && w->size() != old.size()) {
effects->addRepaint(windows[ w ]->area);
}
}
else
{
if( w->isOnAllDesktops())
{
} else {
if (w->isOnAllDesktops()) {
foreach (ItemInfo * info, desktops)
effects->addRepaint(info->area);
}
else
{
} else {
effects->addRepaint(desktops[ w->desktop()]->area);
}
}
@ -335,13 +287,10 @@ void BoxSwitchEffect::windowGeometryShapeChanged( EffectWindow* w, const QRect&
void BoxSwitchEffect::tabBoxAdded(int mode)
{
if( !mActivated )
{
if (!mActivated) {
if ((mode == TabBoxWindowsMode && primaryTabBox) ||
( mode == TabBoxWindowsAlternativeMode && secondaryTabBox) )
{
if( effects->currentTabBoxWindowList().count() > 0 )
{
(mode == TabBoxWindowsAlternativeMode && secondaryTabBox)) {
if (effects->currentTabBoxWindowList().count() > 0) {
mMode = mode;
effects->refTabBox();
highlight_is_set = false;
@ -350,11 +299,9 @@ void BoxSwitchEffect::tabBoxAdded( int mode )
right_window = 0;
setActive();
}
}
else if( mode == TabBoxDesktopListMode || mode == TabBoxDesktopMode )
{ // DesktopMode
if( effects->currentTabBoxDesktopList().count() > 0 )
{
} else if (mode == TabBoxDesktopListMode || mode == TabBoxDesktopMode) {
// DesktopMode
if (effects->currentTabBoxDesktopList().count() > 0) {
mMode = mode;
painting_desktop = 0;
effects->refTabBox();
@ -372,15 +319,11 @@ void BoxSwitchEffect::tabBoxClosed()
void BoxSwitchEffect::tabBoxUpdated()
{
if( mActivated )
{
if (mActivated) {
if ((mMode == TabBoxWindowsMode || mMode == TabBoxWindowsAlternativeMode)
&& selected_window != effects->currentTabBoxWindow() )
{
if( selected_window != NULL )
{
if( (mAnimateSwitch && !mProxyActivated) || (mProxyActivated && mProxyAnimateSwitch) )
{
&& selected_window != effects->currentTabBoxWindow()) {
if (selected_window != NULL) {
if ((mAnimateSwitch && !mProxyActivated) || (mProxyActivated && mProxyAnimateSwitch)) {
int old_index = effects->currentTabBoxWindowList().indexOf(selected_window);
int new_index = effects->currentTabBoxWindowList().indexOf(effects->currentTabBoxWindow());
Direction new_direction;
@ -389,26 +332,22 @@ void BoxSwitchEffect::tabBoxUpdated()
new_direction = Left;
if (distance < 0)
new_direction = Right;
if( distance != 0 )
{
if (distance != 0) {
distance = abs(distance);
int tempDistance = effects->currentTabBoxWindowList().count() - distance;
if( tempDistance < abs( distance ) )
{
if (tempDistance < abs(distance)) {
distance = tempDistance;
if (new_direction == Left)
new_direction = Right;
else
new_direction = Left;
}
if( !animation )
{
if (!animation) {
animation = true;
direction = new_direction;
distance--;
}
for( int i=0; i<distance; i++ )
{
for (int i = 0; i < distance; i++) {
if (!scheduled_directions.isEmpty() && scheduled_directions.last() != new_direction)
scheduled_directions.pop_back();
else
@ -427,9 +366,8 @@ void BoxSwitchEffect::tabBoxUpdated()
effects->addRepaint(windows.value(selected_window)->area);
selected_window->addRepaintFull();
effects->addRepaint(text_area);
}
else if( mMode != TabBoxWindowsMode && mMode != TabBoxWindowsAlternativeMode )
{ // DesktopMode
} else if (mMode != TabBoxWindowsMode && mMode != TabBoxWindowsAlternativeMode) {
// DesktopMode
if (desktops.contains(selected_desktop))
effects->addRepaint(desktops.value(selected_desktop)->area);
selected_desktop = effects->currentTabBoxDesktop();
@ -460,13 +398,10 @@ void BoxSwitchEffect::setActive()
qDeleteAll(windows);
windows.clear();
if( mMode == TabBoxWindowsMode || mMode == TabBoxWindowsAlternativeMode )
{
if (mMode == TabBoxWindowsMode || mMode == TabBoxWindowsAlternativeMode) {
original_windows = effects->currentTabBoxWindowList();
setSelectedWindow(effects->currentTabBoxWindow());
}
else
{
} else {
original_desktops = effects->currentTabBoxDesktopList();
selected_desktop = effects->currentTabBoxDesktop();
if (!mProxyActivated || mProxyShowText)
@ -474,18 +409,15 @@ void BoxSwitchEffect::setActive()
}
calculateFrameSize();
calculateItemSizes();
if( !mProxyActivated )
{
if (!mProxyActivated) {
// only create the input window when effect is not activated via the proxy
mInput = effects->createInputWindow(this, frame_area.x(), frame_area.y(),
frame_area.width(), frame_area.height(), Qt::ArrowCursor);
}
effects->addRepaint(frame_area);
if( mMode == TabBoxWindowsMode || mMode == TabBoxWindowsAlternativeMode )
{
if (mMode == TabBoxWindowsMode || mMode == TabBoxWindowsAlternativeMode) {
QHash< EffectWindow*, ItemInfo* >::const_iterator i;
for( i = windows.constBegin(); i != windows.constEnd(); ++i )
{
for (i = windows.constBegin(); i != windows.constEnd(); ++i) {
i.key()->addRepaintFull();
}
}
@ -495,18 +427,15 @@ void BoxSwitchEffect::setInactive()
{
mActivated = false;
effects->unrefTabBox();
if( !mProxyActivated && mInput != None )
{
if (!mProxyActivated && mInput != None) {
effects->destroyInputWindow(mInput);
mInput = None;
}
mProxyActivated = false;
mPositioningFactor = 0.5f;
if( mMode == TabBoxWindowsMode || mMode == TabBoxWindowsAlternativeMode )
{
if (mMode == TabBoxWindowsMode || mMode == TabBoxWindowsAlternativeMode) {
QHash< EffectWindow*, ItemInfo* >::const_iterator i;
for( i = windows.constBegin(); i != windows.constEnd(); ++i )
{
for (i = windows.constBegin(); i != windows.constEnd(); ++i) {
if (i.key() != selected_window)
i.key()->addRepaintFull();
}
@ -515,14 +444,12 @@ void BoxSwitchEffect::setInactive()
if (elevate_window && selected_window)
effects->setElevatedWindow(selected_window, false);
foreach( EffectWindow* w, referrencedWindows )
{
foreach (EffectWindow * w, referrencedWindows) {
w->unrefWindow();
}
referrencedWindows.clear();
}
else
{ // DesktopMode
} else {
// DesktopMode
qDeleteAll(windows);
desktops.clear();
}
@ -533,27 +460,23 @@ void BoxSwitchEffect::setInactive()
void BoxSwitchEffect::setSelectedWindow(EffectWindow* w)
{
if( elevate_window && selected_window )
{
if (elevate_window && selected_window) {
effects->setElevatedWindow(selected_window, false);
}
selected_window = w;
if (selected_window && (!mProxyActivated || mProxyShowText))
thumbnailFrame->setText(selected_window->caption());
if( elevate_window && w )
{
if (elevate_window && w) {
effects->setElevatedWindow(selected_window, true);
}
}
void BoxSwitchEffect::windowClosed(EffectWindow* w)
{
if( w == selected_window )
{
if (w == selected_window) {
setSelectedWindow(0);
}
if( windows.contains( w ) )
{
if (windows.contains(w)) {
w->refWindow();
referrencedWindows.append(w);
original_windows.removeAll(w);
@ -573,14 +496,11 @@ void BoxSwitchEffect::calculateFrameSize()
{
int itemcount;
if( mMode == TabBoxWindowsMode || mMode == TabBoxWindowsAlternativeMode )
{
if (mMode == TabBoxWindowsMode || mMode == TabBoxWindowsAlternativeMode) {
itemcount = original_windows.count();
item_max_size.setWidth(200);
item_max_size.setHeight(200);
}
else
{
} else {
itemcount = original_desktops.count();
item_max_size.setWidth(200);
item_max_size.setHeight(200);
@ -592,8 +512,7 @@ void BoxSwitchEffect::calculateFrameSize()
// Shrink the size until all windows/desktops can fit onscreen
frame_area.setWidth(itemcount * item_max_size.width());
QRect screenr = effects->clientArea(PlacementArea, effects->activeScreen(), effects->currentDesktop());
while( frame_area.width() > screenr.width())
{
while (frame_area.width() > screenr.width()) {
item_max_size /= 2;
frame_area.setWidth(itemcount * item_max_size.width());
}
@ -613,12 +532,10 @@ void BoxSwitchEffect::calculateFrameSize()
void BoxSwitchEffect::calculateItemSizes()
{
if( mMode == TabBoxWindowsMode || mMode == TabBoxWindowsAlternativeMode )
{
if (mMode == TabBoxWindowsMode || mMode == TabBoxWindowsAlternativeMode) {
qDeleteAll(windows);
windows.clear();
if( (mAnimateSwitch && !mProxyActivated) || (mProxyActivated && mProxyAnimateSwitch) )
{
if ((mAnimateSwitch && !mProxyActivated) || (mProxyActivated && mProxyAnimateSwitch)) {
int index = original_windows.indexOf(effects->currentTabBoxWindow());
int leftIndex = index;
int rightIndex = index + 1;
@ -630,65 +547,51 @@ void BoxSwitchEffect::calculateItemSizes()
int rightWindowCount = leftWindowCount;
if (original_windows.count() % 2 == 1)
leftWindowCount++;
for( int i=0; i < leftWindowCount; i++ )
{
for (int i = 0; i < leftWindowCount; i++) {
int tempIndex = (leftIndex - i);
if (tempIndex < 0)
tempIndex = original_windows.count() + tempIndex;
ordered_windows.prepend(original_windows[ tempIndex ]);
}
for( int i=0; i < rightWindowCount; i++ )
{
for (int i = 0; i < rightWindowCount; i++) {
int tempIndex = (rightIndex + i) % original_windows.count();
ordered_windows.append(original_windows[ tempIndex ]);
}
// move items cause of schedule
for( int i=0; i < scheduled_directions.count(); i++ )
{
for (int i = 0; i < scheduled_directions.count(); i++) {
Direction actual = scheduled_directions[ i ];
if( actual == Left )
{
if (actual == Left) {
EffectWindow* w = ordered_windows.takeLast();
ordered_windows.prepend(w);
}
else
{
} else {
EffectWindow* w = ordered_windows.takeFirst();
ordered_windows.append(w);
}
}
if( animation && timeLine.value() < 0.5 )
{
if( direction == Left )
{
if (animation && timeLine.value() < 0.5) {
if (direction == Left) {
EffectWindow* w = ordered_windows.takeLast();
edge_window = w;
ordered_windows.prepend(w);
}
else
{
} else {
EffectWindow* w = ordered_windows.takeFirst();
edge_window = w;
ordered_windows.append(w);
}
}
else if( animation && timeLine.value() >= 0.5 )
{
} else if (animation && timeLine.value() >= 0.5) {
if (animation && direction == Left)
edge_window = ordered_windows.last();
if (animation && direction == Right)
edge_window = ordered_windows.first();
}
int offset = 0;
if( animation )
{
if (animation) {
if (direction == Left)
offset = (float)item_max_size.width() * (1.0 - timeLine.value());
else
offset = -(float)item_max_size.width() * (1.0 - timeLine.value());
}
for( int i = 0; i < ordered_windows.count(); i++ )
{
for (int i = 0; i < ordered_windows.count(); i++) {
if (!ordered_windows.at(i))
continue;
EffectWindow* w = ordered_windows.at(i);
@ -699,8 +602,7 @@ void BoxSwitchEffect::calculateItemSizes()
windows[ w ]->iconFrame->setIcon(w->icon());
float moveIndex = i;
if( animation && timeLine.value() < 0.5 )
{
if (animation && timeLine.value() < 0.5) {
if (direction == Left)
moveIndex--;
else
@ -713,20 +615,15 @@ void BoxSwitchEffect::calculateItemSizes()
item_max_size.width(), item_max_size.height());
windows[ w ]->clickable = windows[ w ]->area;
}
if( ordered_windows.count()%2 == 0 )
{
if (ordered_windows.count() % 2 == 0) {
right_window = ordered_windows.last();
}
if( !highlight_is_set )
{
if (!highlight_is_set) {
highlight_area = windows[ selected_window ]->area;
highlight_is_set = true;
}
}
else
{
for( int i = 0; i < original_windows.count(); i++ )
{
} else {
for (int i = 0; i < original_windows.count(); i++) {
if (!original_windows.at(i))
continue;
EffectWindow* w = original_windows.at(i);
@ -742,12 +639,9 @@ void BoxSwitchEffect::calculateItemSizes()
windows[ w ]->clickable = windows[ w ]->area;
}
}
}
else
{
} else {
desktops.clear();
for( int i = 0; i < original_desktops.count(); i++ )
{
for (int i = 0; i < original_desktops.count(); i++) {
int it = original_desktops.at(i);
desktops[ it ] = new ItemInfo();
@ -770,39 +664,31 @@ void BoxSwitchEffect::paintWindowThumbnail( EffectWindow* w )
windows[ w ]->area.adjusted(highlight_margin, highlight_margin, -highlight_margin, -highlight_margin),
Qt::KeepAspectRatio);
if( animation && ( w == edge_window ) && ( windows.size() % 2 == 1 ) )
{
if (animation && (w == edge_window) && (windows.size() % 2 == 1)) {
// in case of animation:
// the window which has to change the side will be split and painted on both sides of the edge
double splitPoint = 0.0;
if( direction == Left )
{
if (direction == Left) {
splitPoint = w->geometry().width() * timeLine.value();
}
else
{
} else {
splitPoint = w->geometry().width() - w->geometry().width() * timeLine.value();
}
data.quads = data.quads.splitAtX(splitPoint);
WindowQuadList left_quads;
WindowQuadList right_quads;
foreach( const WindowQuad &quad, data.quads )
{
foreach (const WindowQuad & quad, data.quads) {
if (quad.left() >= splitPoint)
left_quads << quad;
if (quad.right() <= splitPoint)
right_quads << quad;
}
// the base position of the window is changed after half of the animation
if( timeLine.value() < 0.5 )
{
if (timeLine.value() < 0.5) {
if (direction == Left)
data.quads = left_quads;
else
data.quads = right_quads;
}
else
{
} else {
if (direction == Left)
data.quads = right_quads;
else
@ -818,17 +704,13 @@ void BoxSwitchEffect::paintWindowThumbnail( EffectWindow* w )
// paint the second part of the thumbnail:
// the other window quads are needed and a new rect for transformation has to be calculated
if( direction == Left )
{
if( timeLine.value() < 0.5 )
{
if (direction == Left) {
if (timeLine.value() < 0.5) {
data.quads = right_quads;
secondThumbnail = QRect(frame_area.x() + frame_area.width() -
(float)item_max_size.width() * timeLine.value(),
frame_area.y(), item_max_size.width(), item_max_size.height());
}
else
{
} else {
data.quads = left_quads;
secondThumbnail = QRect(frame_area.x() - (float)item_max_size.width() * timeLine.value(),
frame_area.y(), item_max_size.width(), item_max_size.height());
@ -837,18 +719,13 @@ void BoxSwitchEffect::paintWindowThumbnail( EffectWindow* w )
(float)item_max_size.width() * (timeLine.value() - 0.5),
frame_area.y(), item_max_size.width(), item_max_size.height());
}
}
else
{
if( timeLine.value() < 0.5 )
{
} else {
if (timeLine.value() < 0.5) {
data.quads = left_quads;
secondThumbnail = QRect(frame_area.x() -
(float)item_max_size.width() * (1.0 - timeLine.value()),
frame_area.y(), item_max_size.width(), item_max_size.height());
}
else
{
} else {
data.quads = right_quads;
secondThumbnail = QRect(frame_area.x() + frame_area.width() -
(float)item_max_size.width() * (1.0 - timeLine.value()),
@ -862,38 +739,28 @@ void BoxSwitchEffect::paintWindowThumbnail( EffectWindow* w )
effects->paintWindow(w,
PAINT_WINDOW_OPAQUE | PAINT_WINDOW_TRANSFORMED | PAINT_WINDOW_LANCZOS,
windows[ w ]->thumbnail, data);
}
else if( ( windows.size() % 2 == 0 ) && ( w == right_window ) )
{
} else if ((windows.size() % 2 == 0) && (w == right_window)) {
// in case of even number of thumbnails:
// the window on the right is painted one half on left and on half on the right side
float animationOffset = 0.0f;
double splitPoint = w->geometry().width() * 0.5;
if( animation && timeLine.value() <= 0.5 )
{
if (animation && timeLine.value() <= 0.5) {
// in case of animation the right window has only to be split during first half of animation
if( direction == Left )
{
if (direction == Left) {
splitPoint += w->geometry().width() * timeLine.value();
animationOffset = -(float)item_max_size.width() * timeLine.value();
}
else
{
} else {
splitPoint -= w->geometry().width() * timeLine.value();
animationOffset = (float)item_max_size.width() * timeLine.value();
}
}
if( animation && timeLine.value() > 0.5 )
{
if (animation && timeLine.value() > 0.5) {
// at half of animation a different window has become the right window
// we have to adjust the splitting again
if( direction == Left )
{
if (direction == Left) {
splitPoint -= w->geometry().width() * (1.0 - timeLine.value());
animationOffset = (float)item_max_size.width() * (1.0 - timeLine.value());
}
else
{
} else {
splitPoint += w->geometry().width() * (1.0 - timeLine.value());
animationOffset = -(float)item_max_size.width() * (1.0 - timeLine.value());
}
@ -901,8 +768,7 @@ void BoxSwitchEffect::paintWindowThumbnail( EffectWindow* w )
data.quads = data.quads.splitAtX(splitPoint);
WindowQuadList rightQuads;
WindowQuadList leftQuads;
foreach( const WindowQuad &quad, data.quads )
{
foreach (const WindowQuad & quad, data.quads) {
if (quad.right() <= splitPoint)
leftQuads << quad;
else
@ -928,9 +794,7 @@ void BoxSwitchEffect::paintWindowThumbnail( EffectWindow* w )
effects->drawWindow(w,
PAINT_WINDOW_OPAQUE | PAINT_WINDOW_TRANSFORMED | PAINT_WINDOW_LANCZOS,
windows[ w ]->thumbnail, data);
}
else
{
} else {
effects->drawWindow(w,
PAINT_WINDOW_OPAQUE | PAINT_WINDOW_TRANSFORMED | PAINT_WINDOW_LANCZOS,
windows[ w ]->thumbnail, data);
@ -968,8 +832,7 @@ void BoxSwitchEffect::paintWindowIcon( EffectWindow* w )
if (!windows.contains(w))
return;
// Don't render null icons
if( w->icon().isNull() )
{
if (w->icon().isNull()) {
return;
}
@ -977,51 +840,36 @@ void BoxSwitchEffect::paintWindowIcon( EffectWindow* w )
int height = w->icon().height();
int x = windows[ w ]->area.x() + windows[ w ]->area.width() - width - highlight_margin;
int y = windows[ w ]->area.y() + windows[ w ]->area.height() - height - highlight_margin;
if( ( windows.size() % 2 == 0 ) )
{
if( w == right_window )
{
if ((windows.size() % 2 == 0)) {
if (w == right_window) {
// in case of right window the icon has to be painted on the left side of the frame
x = frame_area.x() + windows[ w ]->area.width() * 0.5 - width - highlight_margin;
if( animation )
{
if( timeLine.value() <= 0.5 )
{
if( direction == Left )
{
if (animation) {
if (timeLine.value() <= 0.5) {
if (direction == Left) {
x -= windows[ w ]->area.width() * timeLine.value();
x = qMax(x, frame_area.x());
}
else
} else
x += windows[ w ]->area.width() * timeLine.value();
}
else
{
} else {
if (direction == Left)
x += windows[ w ]->area.width() * (1.0 - timeLine.value());
else
{
else {
x -= windows[ w ]->area.width() * (1.0 - timeLine.value());
x = qMax(x, frame_area.x());
}
}
}
}
}
else
{
} else {
// during animation the icon of the edge window has to change position
if( animation && w == edge_window )
{
if( timeLine.value() < 0.5 )
{
if (animation && w == edge_window) {
if (timeLine.value() < 0.5) {
if (direction == Left)
x += windows[ w ]->area.width() * timeLine.value();
else
x -= windows[ w ]->area.width() * timeLine.value();
}
else
{
} else {
if (direction == Left)
x -= windows[ w ]->area.width() * (1.0 - timeLine.value());
else
@ -1041,17 +889,14 @@ void* BoxSwitchEffect::proxy()
void BoxSwitchEffect::activateFromProxy(int mode, bool animate, bool showText, float positioningFactor)
{
if( !mActivated )
{
if (!mActivated) {
mProxyActivated = true;
mProxyAnimateSwitch = animate;
mProxyShowText = showText;
mPositioningFactor = positioningFactor;
thumbnailFrame->setText(" ");
if( ( mode == TabBoxWindowsMode ) || ( mode == TabBoxWindowsAlternativeMode ) )
{
if( effects->currentTabBoxWindowList().count() > 0 )
{
if ((mode == TabBoxWindowsMode) || (mode == TabBoxWindowsAlternativeMode)) {
if (effects->currentTabBoxWindowList().count() > 0) {
mMode = mode;
effects->refTabBox();
highlight_is_set = false;
@ -1060,11 +905,9 @@ void BoxSwitchEffect::activateFromProxy( int mode, bool animate, bool showText,
right_window = 0;
setActive();
}
}
else if( mode == TabBoxDesktopListMode || mode == TabBoxDesktopMode )
{ // DesktopMode
if( effects->currentTabBoxDesktopList().count() > 0 )
{
} else if (mode == TabBoxDesktopListMode || mode == TabBoxDesktopMode) {
// DesktopMode
if (effects->currentTabBoxDesktopList().count() > 0) {
mMode = mode;
painting_desktop = 0;
effects->refTabBox();

View File

@ -107,8 +107,7 @@ class BoxSwitchEffect
bool animation;
QRect highlight_area;
bool highlight_is_set;
enum Direction
{
enum Direction {
Left,
Right
};

View File

@ -115,11 +115,9 @@ void CoverSwitchEffect::reconfigure( ReconfigureFlags )
void CoverSwitchEffect::prePaintScreen(ScreenPrePaintData& data, int time)
{
if( mActivated || stop || stopRequested )
{
if (mActivated || stop || stopRequested) {
data.mask |= Effect::PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
if( animation || start || stop )
{
if (animation || start || stop) {
timeLine.addTime((double)time);
}
if (selected_window == NULL)
@ -132,13 +130,11 @@ void CoverSwitchEffect::paintScreen( int mask, QRegion region, ScreenPaintData&
{
effects->paintScreen(mask, region, data);
if( mActivated || stop || stopRequested )
{
if (mActivated || stop || stopRequested) {
QMatrix4x4 origProjection;
QMatrix4x4 origModelview;
ShaderManager *shaderManager = ShaderManager::instance();
if( effects->numScreens() > 1 )
{
if (effects->numScreens() > 1) {
// unfortunatelly we have to change the projection matrix in dual screen mode
QRect fullRect = effects->clientArea(FullArea, activeScreen, effects->currentDesktop());
float fovy = 60.0f;
@ -155,29 +151,25 @@ void CoverSwitchEffect::paintScreen( int mask, QRegion region, ScreenPaintData&
float xmaxFactor = 1.0;
float yminFactor = 1.0;
float ymaxFactor = 1.0;
if( area.x() == 0 && area.width() != fullRect.width() )
{
if (area.x() == 0 && area.width() != fullRect.width()) {
// horizontal layout: left screen
xminFactor = (float)area.width() / (float)fullRect.width();
xmaxFactor = ((float)fullRect.width() - (float)area.width() * 0.5f) / ((float)fullRect.width() * 0.5f);
xTranslate = (float)fullRect.width() * 0.5f - (float)area.width() * 0.5f;
}
if( area.x() != 0 && area.width() != fullRect.width() )
{
if (area.x() != 0 && area.width() != fullRect.width()) {
// horizontal layout: right screen
xminFactor = ((float)fullRect.width() - (float)area.width() * 0.5f) / ((float)fullRect.width() * 0.5f);
xmaxFactor = (float)area.width() / (float)fullRect.width();
xTranslate = (float)fullRect.width() * 0.5f - (float)area.width() * 0.5f;
}
if( area.y() == 0 && area.height() != fullRect.height() )
{
if (area.y() == 0 && area.height() != fullRect.height()) {
// vertical layout: top screen
yminFactor = ((float)fullRect.height() - (float)area.height() * 0.5f) / ((float)fullRect.height() * 0.5f);
ymaxFactor = (float)area.height() / (float)fullRect.height();
yTranslate = (float)fullRect.height() * 0.5f - (float)area.height() * 0.5f;
}
if( area.y() != 0 && area.height() != fullRect.height() )
{
if (area.y() != 0 && area.height() != fullRect.height()) {
// vertical layout: bottom screen
yminFactor = (float)area.height() / (float)fullRect.height();
ymaxFactor = ((float)fullRect.height() - (float)area.height() * 0.5f) / ((float)fullRect.height() * 0.5f);
@ -207,10 +199,8 @@ void CoverSwitchEffect::paintScreen( int mask, QRegion region, ScreenPaintData&
QList< EffectWindow* > tempList = currentWindowList;
int index = tempList.indexOf(selected_window);
if( animation || start || stop )
{
if( !start && !stop )
{
if (animation || start || stop) {
if (!start && !stop) {
if (direction == Right)
index++;
else
@ -220,8 +210,7 @@ void CoverSwitchEffect::paintScreen( int mask, QRegion region, ScreenPaintData&
if (index >= tempList.count())
index = index % tempList.count();
}
foreach( Direction direction, scheduled_directions )
{
foreach (Direction direction, scheduled_directions) {
if (direction == Right)
index++;
else
@ -249,8 +238,7 @@ void CoverSwitchEffect::paintScreen( int mask, QRegion region, ScreenPaintData&
leftWindowCount = tempList.count() / 2 - 1;
else
leftWindowCount = (tempList.count() - 1) / 2;
for( int i=0; i < leftWindowCount; i++ )
{
for (int i = 0; i < leftWindowCount; i++) {
int tempIndex = (leftIndex - i);
if (tempIndex < 0)
tempIndex = tempList.count() + tempIndex;
@ -261,14 +249,12 @@ void CoverSwitchEffect::paintScreen( int mask, QRegion region, ScreenPaintData&
rightWindowCount = tempList.count() / 2;
else
rightWindowCount = (tempList.count() - 1) / 2;
for( int i=0; i < rightWindowCount; i++ )
{
for (int i = 0; i < rightWindowCount; i++) {
int tempIndex = (rightIndex + i) % tempList.count();
rightWindows.prepend(tempList[ tempIndex ]);
}
if( reflection )
{
if (reflection) {
// restrict painting the reflections to the current screen
QRegion clip = QRegion(area);
PaintClipper::push(clip);
@ -290,7 +276,8 @@ void CoverSwitchEffect::paintScreen( int mask, QRegion region, ScreenPaintData&
-area.width() * 0.5f, area.height(), 0.0,
area.width() * 0.5f, area.height(), 0.0,
(float)area.width()*reflectionScaleFactor, area.height(), -5000,
-(float)area.width()*reflectionScaleFactor, area.height(), -5000 };
-(float)area.width()*reflectionScaleFactor, area.height(), -5000
};
// foreground
if (start) {
mirrorColor[0][3] = timeLine.value();
@ -303,11 +290,9 @@ void CoverSwitchEffect::paintScreen( int mask, QRegion region, ScreenPaintData&
int y = 0;
// have to adjust the y values to fit OpenGL
// in OpenGL y==0 is at bottom, in Qt at top
if( effects->numScreens() > 1 )
{
if (effects->numScreens() > 1) {
QRect fullArea = effects->clientArea(FullArea, 0, 1);
if( fullArea.height() != area.height() )
{
if (fullArea.height() != area.height()) {
if (area.y() == 0)
y = fullArea.height() - area.height();
else
@ -351,8 +336,7 @@ void CoverSwitchEffect::paintScreen( int mask, QRegion region, ScreenPaintData&
} else {
#ifndef KWIN_HAVE_OPENGLES
glPushMatrix();
if( effects->numScreens() > 1 && area.x() != fullRect.x() )
{
if (effects->numScreens() > 1 && area.x() != fullRect.x()) {
// have to change the reflection area in horizontal layout and right screen
glTranslatef(-area.x(), 0.0, 0.0);
}
@ -375,8 +359,7 @@ void CoverSwitchEffect::paintScreen( int mask, QRegion region, ScreenPaintData&
}
paintScene(frontWindow, leftWindows, rightWindows);
if( effects->numScreens() > 1 )
{
if (effects->numScreens() > 1) {
if (shaderManager->isShaderBound()) {
GLShader *shader = shaderManager->pushShader(ShaderManager::GenericShader);
shader->setUniform("projection", origProjection);
@ -394,8 +377,7 @@ void CoverSwitchEffect::paintScreen( int mask, QRegion region, ScreenPaintData&
}
// Render the caption frame
if (windowTitle)
{
if (windowTitle) {
double opacity = 1.0;
if (start)
opacity = timeLine.value();
@ -408,8 +390,7 @@ void CoverSwitchEffect::paintScreen( int mask, QRegion region, ScreenPaintData&
if ((thumbnails && (!dynamicThumbnails ||
(dynamicThumbnails && currentWindowList.size() >= thumbnailWindows)))
&& !( start || stop ) )
{
&& !(start || stop)) {
BoxSwitchEffectProxy *proxy =
static_cast<BoxSwitchEffectProxy*>(effects->getProxy("boxswitch"));
if (proxy)
@ -420,48 +401,36 @@ void CoverSwitchEffect::paintScreen( int mask, QRegion region, ScreenPaintData&
void CoverSwitchEffect::postPaintScreen()
{
if( ( mActivated && ( animation || start ) ) || stop || stopRequested )
{
if( timeLine.value() == 1.0 )
{
if ((mActivated && (animation || start)) || stop || stopRequested) {
if (timeLine.value() == 1.0) {
timeLine.setProgress(0.0);
if( stop )
{
if (stop) {
stop = false;
effects->setActiveFullScreenEffect(0);
foreach( EffectWindow* window, referrencedWindows )
{
foreach (EffectWindow * window, referrencedWindows) {
window->unrefWindow();
}
referrencedWindows.clear();
currentWindowList.clear();
if( startRequested )
{
if (startRequested) {
startRequested = false;
mActivated = true;
effects->refTabBox();
currentWindowList = effects->currentTabBoxWindowList();
if( animateStart )
{
if (animateStart) {
start = true;
}
}
}
else if( !scheduled_directions.isEmpty() )
{
} else if (!scheduled_directions.isEmpty()) {
direction = scheduled_directions.dequeue();
if( start )
{
if (start) {
animation = true;
start = false;
}
}
else
{
} else {
animation = false;
start = false;
if( stopRequested )
{
if (stopRequested) {
stopRequested = false;
stop = true;
}
@ -502,47 +471,33 @@ void CoverSwitchEffect::paintScene( EffectWindow* frontWindow, const EffectWindo
// paint sequence no animation: left, right, front
// paint sequence forward animation: right, front, left
if( !animation )
{
if (!animation) {
paintWindows(leftWindows, true, reflectedWindows);
paintWindows(rightWindows, false, reflectedWindows);
paintFrontWindow(frontWindow, width, leftWindowCount, rightWindowCount, reflectedWindows);
}
else
{
if( direction == Right )
{
if( timeLine.value() < 0.5 )
{
} else {
if (direction == Right) {
if (timeLine.value() < 0.5) {
// paint in normal way
paintWindows(leftWindows, true, reflectedWindows);
paintWindows(rightWindows, false, reflectedWindows);
paintFrontWindow(frontWindow, width, leftWindowCount, rightWindowCount, reflectedWindows);
}
else
{
} else {
paintWindows(rightWindows, false, reflectedWindows);
paintFrontWindow(frontWindow, width, leftWindowCount, rightWindowCount, reflectedWindows);
paintWindows(leftWindows, true, reflectedWindows, rightWindows.at(0));
}
}
else
{
} else {
paintWindows(leftWindows, true, reflectedWindows);
if( timeLine.value() < 0.5 )
{
if (timeLine.value() < 0.5) {
paintWindows(rightWindows, false, reflectedWindows);
paintFrontWindow(frontWindow, width, leftWindowCount, rightWindowCount, reflectedWindows);
}
else
{
} else {
EffectWindow* leftWindow;
if( leftWindowCount > 0)
{
if (leftWindowCount > 0) {
leftWindow = leftWindows.at(0);
paintFrontWindow(frontWindow, width, leftWindowCount, rightWindowCount, reflectedWindows);
}
else
} else
leftWindow = frontWindow;
paintWindows(rightWindows, false, reflectedWindows, leftWindow);
}
@ -552,22 +507,17 @@ void CoverSwitchEffect::paintScene( EffectWindow* frontWindow, const EffectWindo
void CoverSwitchEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{
if( mActivated || stop || stopRequested )
{
if( !( mask & PAINT_WINDOW_TRANSFORMED ) && !w->isDesktop() )
{
if( ( start || stop ) && w->isDock() )
{
if (mActivated || stop || stopRequested) {
if (!(mask & PAINT_WINDOW_TRANSFORMED) && !w->isDesktop()) {
if ((start || stop) && w->isDock()) {
data.opacity = 1.0 - timeLine.value();
if (stop)
data.opacity = timeLine.value();
}
else
} else
return;
}
}
if ( ( start || stop ) && (!w->isOnCurrentDesktop() || w->isMinimized() ) )
{
if ((start || stop) && (!w->isOnCurrentDesktop() || w->isMinimized())) {
if (stop) // Fade out windows not on the current desktop
data.opacity = (1.0 - timeLine.value());
else // Fade in Windows from other desktops when animation is started
@ -580,21 +530,18 @@ void CoverSwitchEffect::tabBoxAdded( int mode )
{
if (effects->activeFullScreenEffect() && effects->activeFullScreenEffect() != this)
return;
if( !mActivated )
{
if (!mActivated) {
// only for windows mode
if (((mode == TabBoxWindowsMode && primaryTabBox) ||
(mode == TabBoxWindowsAlternativeMode && secondaryTabBox))
&& effects->currentTabBoxWindowList().count() > 0 )
{
&& effects->currentTabBoxWindowList().count() > 0) {
input = effects->createFullScreenInputWindow(this, Qt::ArrowCursor);
activeScreen = effects->activeScreen();
BoxSwitchEffectProxy *proxy =
static_cast<BoxSwitchEffectProxy*>(effects->getProxy("boxswitch"));
if (proxy)
proxy->activate(mode, true, false, 0.05f);
if( !stop && !stopRequested )
{
if (!stop && !stopRequested) {
effects->refTabBox();
effects->setActiveFullScreenEffect(this);
scheduled_directions.clear();
@ -602,21 +549,18 @@ void CoverSwitchEffect::tabBoxAdded( int mode )
currentWindowList = effects->currentTabBoxWindowList();
direction = Left;
mActivated = true;
if( animateStart )
{
if (animateStart) {
start = true;
}
// Calculation of correct area
area = effects->clientArea(FullScreenArea, activeScreen, effects->currentDesktop());
scaleFactor = (zPosition + 1100) * 2.0 * tan(60.0 * M_PI / 360.0f) / displayWidth();
if( displayWidth()-area.width() != 0 )
{
if (displayWidth() - area.width() != 0) {
// one of the screens is smaller than the other (horizontal)
if (area.width() < displayWidth() - area.width())
scaleFactor *= (float)area.width() / (float)(displayWidth() - area.width());
else if( area.width() != displayWidth() - area.width() )
{
else if (area.width() != displayWidth() - area.width()) {
// vertical layout with different width
// but we don't want to catch screens with same width and different height
if (displayHeight() != area.height())
@ -625,8 +569,7 @@ void CoverSwitchEffect::tabBoxAdded( int mode )
}
// Setup caption frame geometry
if (windowTitle)
{
if (windowTitle) {
QRect frameRect = QRect(area.width() * 0.25f + area.x(),
area.height() * 0.9f + area.y(),
area.width() * 0.5f,
@ -639,9 +582,7 @@ void CoverSwitchEffect::tabBoxAdded( int mode )
}
effects->addRepaintFull();
}
else
{
} else {
startRequested = true;
}
}
@ -650,26 +591,18 @@ void CoverSwitchEffect::tabBoxAdded( int mode )
void CoverSwitchEffect::tabBoxClosed()
{
if( mActivated )
{
if( animateStop )
{
if( !animation && !start )
{
if (mActivated) {
if (animateStop) {
if (!animation && !start) {
stop = true;
}
else if( start && scheduled_directions.isEmpty() )
{
} else if (start && scheduled_directions.isEmpty()) {
start = false;
stop = true;
timeLine.setProgress(1.0 - timeLine.value());
}
else
{
} else {
stopRequested = true;
}
}
else
} else
effects->setActiveFullScreenEffect(0);
mActivated = false;
effects->unrefTabBox();
@ -680,15 +613,11 @@ void CoverSwitchEffect::tabBoxClosed()
void CoverSwitchEffect::tabBoxUpdated()
{
if( mActivated )
{
if( animateSwitch && currentWindowList.count() > 1)
{
if (mActivated) {
if (animateSwitch && currentWindowList.count() > 1) {
// determine the switch direction
if( selected_window != effects->currentTabBoxWindow() )
{
if( selected_window != NULL )
{
if (selected_window != effects->currentTabBoxWindow()) {
if (selected_window != NULL) {
int old_index = currentWindowList.indexOf(selected_window);
int new_index = effects->currentTabBoxWindowList().indexOf(effects->currentTabBoxWindow());
Direction new_direction;
@ -697,31 +626,26 @@ void CoverSwitchEffect::tabBoxUpdated()
new_direction = Left;
if (distance < 0)
new_direction = Right;
if( effects->currentTabBoxWindowList().count() == 2 )
{
if (effects->currentTabBoxWindowList().count() == 2) {
new_direction = Left;
distance = 1;
}
if( distance != 0 )
{
if (distance != 0) {
distance = abs(distance);
int tempDistance = effects->currentTabBoxWindowList().count() - distance;
if( tempDistance < abs( distance ) )
{
if (tempDistance < abs(distance)) {
distance = tempDistance;
if (new_direction == Left)
new_direction = Right;
else
new_direction = Left;
}
if( !animation && !start )
{
if (!animation && !start) {
animation = true;
direction = new_direction;
distance--;
}
for( int i=0; i<distance; i++ )
{
for (int i = 0; i < distance; i++) {
if (!scheduled_directions.isEmpty() && scheduled_directions.last() != new_direction)
scheduled_directions.pop_back();
else
@ -746,39 +670,27 @@ void CoverSwitchEffect::paintWindowCover( EffectWindow* w, bool reflectedWindow,
QRect windowRect = w->geometry();
data.yTranslate = area.height() - windowRect.y() - windowRect.height();
data.zTranslate = -zPosition;
if( start )
{
if( w->isMinimized() )
{
if (start) {
if (w->isMinimized()) {
data.opacity *= timeLine.value();
}
else
{
} else {
data.xTranslate *= timeLine.value();
data.yTranslate *= timeLine.value();
if( effects->numScreens() > 1)
{
if (effects->numScreens() > 1) {
QRect clientRect = effects->clientArea(FullScreenArea, w->screen(), effects->currentDesktop());
QRect fullRect = effects->clientArea(FullArea, activeScreen, effects->currentDesktop());
if( w->screen() == activeScreen )
{
if( clientRect.width() != fullRect.width() && clientRect.x() != fullRect.x() )
{
if (w->screen() == activeScreen) {
if (clientRect.width() != fullRect.width() && clientRect.x() != fullRect.x()) {
data.xTranslate -= clientRect.x() * (1.0f - timeLine.value());
}
if( clientRect.height() != fullRect.height() && clientRect.y() != fullRect.y() )
{
if (clientRect.height() != fullRect.height() && clientRect.y() != fullRect.y()) {
data.yTranslate -= clientRect.y() * (1.0f - timeLine.value());
}
}
else
{
if( clientRect.width() != fullRect.width() && clientRect.x() < area.x())
{
} else {
if (clientRect.width() != fullRect.width() && clientRect.x() < area.x()) {
data.xTranslate -= clientRect.width() * (1.0f - timeLine.value());
}
if( clientRect.height() != fullRect.height() && clientRect.y() < area.y() )
{
if (clientRect.height() != fullRect.height() && clientRect.y() < area.y()) {
data.yTranslate -= clientRect.height() * (1.0f - timeLine.value());
}
}
@ -788,40 +700,28 @@ void CoverSwitchEffect::paintWindowCover( EffectWindow* w, bool reflectedWindow,
data.rotation->angle *= timeLine.value();
}
}
if( stop )
{
if( w->isMinimized() && w != effects->activeWindow() )
{
if (stop) {
if (w->isMinimized() && w != effects->activeWindow()) {
data.opacity *= (1.0 - timeLine.value());
}
else
{
} else {
data.xTranslate *= (1.0 - timeLine.value());
data.yTranslate *= (1.0 - timeLine.value());
if( effects->numScreens() > 1)
{
if (effects->numScreens() > 1) {
QRect clientRect = effects->clientArea(FullScreenArea, w->screen(), effects->currentDesktop());
QRect rect = effects->clientArea(FullScreenArea, activeScreen, effects->currentDesktop());
QRect fullRect = effects->clientArea(FullArea, activeScreen, effects->currentDesktop());
if( w->screen() == activeScreen )
{
if( clientRect.width() != fullRect.width() && clientRect.x() != fullRect.x() )
{
if (w->screen() == activeScreen) {
if (clientRect.width() != fullRect.width() && clientRect.x() != fullRect.x()) {
data.xTranslate -= clientRect.x() * timeLine.value();
}
if( clientRect.height() != fullRect.height() && clientRect.y() != fullRect.y() )
{
if (clientRect.height() != fullRect.height() && clientRect.y() != fullRect.y()) {
data.yTranslate -= clientRect.y() * timeLine.value();
}
}
else
{
if( clientRect.width() != fullRect.width() && clientRect.x() < rect.x())
{
} else {
if (clientRect.width() != fullRect.width() && clientRect.x() < rect.x()) {
data.xTranslate -= clientRect.width() * timeLine.value();
}
if( clientRect.height() != fullRect.height() && clientRect.y() < area.y() )
{
if (clientRect.height() != fullRect.height() && clientRect.y() < area.y()) {
data.yTranslate -= clientRect.height() * timeLine.value();
}
}
@ -834,8 +734,7 @@ void CoverSwitchEffect::paintWindowCover( EffectWindow* w, bool reflectedWindow,
QRect thumbnail = infiniteRegion();
if( reflectedWindow )
{
if (reflectedWindow) {
if (ShaderManager::instance()->isValid()) {
GLShader *shader = ShaderManager::instance()->pushShader(ShaderManager::GenericShader);
QMatrix4x4 origMatrix = shader->getUniformMatrix4x4("screenTransformation");
@ -864,9 +763,7 @@ void CoverSwitchEffect::paintWindowCover( EffectWindow* w, bool reflectedWindow,
glPopMatrix();
#endif
}
}
else
{
} else {
effects->paintWindow(w,
PAINT_WINDOW_TRANSFORMED,
infiniteRegion(), data);
@ -881,20 +778,16 @@ void CoverSwitchEffect::paintFrontWindow( EffectWindow* frontWindow, int width,
bool specialHandlingForward = false;
WindowPaintData data(frontWindow);
data.xTranslate = area.width() * 0.5 - frontWindow->geometry().x() - frontWindow->geometry().width() * 0.5;
if( leftWindows == 0 )
{
if (leftWindows == 0) {
leftWindows = 1;
if (!start && !stop)
specialHandlingForward = true;
}
if( rightWindows == 0 )
{
if (rightWindows == 0) {
rightWindows = 1;
}
if( animation )
{
if( direction == Right )
{
if (animation) {
if (direction == Right) {
// move to right
distance = -frontWindow->geometry().width() * 0.5f + area.width() * 0.5f +
(((float)displayWidth() * 0.5 * scaleFactor) - (float)area.width() * 0.5f) / rightWindows;
@ -904,9 +797,7 @@ void CoverSwitchEffect::paintFrontWindow( EffectWindow* frontWindow, int width,
rot.angle = -angle * timeLine.value();
rot.xRotationPoint = frontWindow->geometry().width();
data.rotation = &rot;
}
else
{
} else {
// move to left
distance = frontWindow->geometry().width() * 0.5f - area.width() * 0.5f +
((float)width * 0.5f - ((float)displayWidth() * 0.5 * scaleFactor)) / leftWindows;
@ -920,12 +811,10 @@ void CoverSwitchEffect::paintFrontWindow( EffectWindow* frontWindow, int width,
data.rotation = &rot;
}
}
if( specialHandlingForward )
{
if (specialHandlingForward) {
data.opacity *= (1.0 - timeLine.value() * 2.0);
paintWindowCover(frontWindow, reflectedWindow, data);
}
else
} else
paintWindowCover(frontWindow, reflectedWindow, data);
}
@ -936,8 +825,7 @@ void CoverSwitchEffect::paintWindows( const EffectWindowList& windows, bool left
EffectWindow* window;
int rotateFactor = 1;
if( !left )
{
if (!left) {
rotateFactor = -1;
}
@ -946,8 +834,7 @@ void CoverSwitchEffect::paintWindows( const EffectWindowList& windows, bool left
xTranslate = ((float)displayWidth() * 0.5 * scaleFactor) - (float)width * 0.5f;
// handling for additional window from other side
// has to appear on this side after half of the time
if( animation && timeLine.value() >= 0.5 && additionalWindow != NULL )
{
if (animation && timeLine.value() >= 0.5 && additionalWindow != NULL) {
RotationData rot;
rot.axis = RotationData::YAxis;
rot.angle = angle;
@ -955,8 +842,7 @@ void CoverSwitchEffect::paintWindows( const EffectWindowList& windows, bool left
WindowPaintData data(additionalWindow);
if (left)
data.xTranslate += -xTranslate - additionalWindow->geometry().x();
else
{
else {
data.xTranslate += xTranslate + area.width() -
additionalWindow->geometry().x() - additionalWindow->geometry().width();
rot.xRotationPoint = additionalWindow->geometry().width();
@ -968,11 +854,9 @@ void CoverSwitchEffect::paintWindows( const EffectWindowList& windows, bool left
RotationData rot;
rot.axis = RotationData::YAxis;
// normal behaviour
for( int i=0; i < windows.count(); i++)
{
for (int i = 0; i < windows.count(); i++) {
window = windows.at(i);
if( window == NULL || window->isDeleted() )
{
if (window == NULL || window->isDeleted()) {
continue;
}
WindowPaintData data(window);
@ -981,12 +865,9 @@ void CoverSwitchEffect::paintWindows( const EffectWindowList& windows, bool left
data.xTranslate += -xTranslate + xTranslate * i / windowCount - window->geometry().x();
else
data.xTranslate += xTranslate + width - xTranslate * i / windowCount - window->geometry().x() - window->geometry().width();
if( animation )
{
if( direction == Right )
{
if( ( i == windowCount - 1 ) && left )
{
if (animation) {
if (direction == Right) {
if ((i == windowCount - 1) && left) {
// right most window on left side -> move to front
// have to move one window distance plus half the difference between the window and the desktop size
data.xTranslate += (xTranslate / windowCount + (width - window->geometry().width()) * 0.5f) * timeLine.value();
@ -994,24 +875,19 @@ void CoverSwitchEffect::paintWindows( const EffectWindowList& windows, bool left
}
// right most window does not have to be moved
else if (!left && (i == 0)); // do nothing
else
{
else {
// all other windows - move to next position
data.xTranslate += xTranslate / windowCount * timeLine.value();
}
}
else
{
if( ( i == windowCount - 1 ) && !left )
{
} else {
if ((i == windowCount - 1) && !left) {
// left most window on right side -> move to front
data.xTranslate -= (xTranslate / windowCount + (width - window->geometry().width()) * 0.5f) * timeLine.value();
rot.angle = (angle - angle * timeLine.value());
}
// left most window does not have to be moved
else if (i == 0 && left); // do nothing
else
{
else {
// all other windows - move to next position
data.xTranslate -= xTranslate / windowCount * timeLine.value();
}
@ -1024,17 +900,13 @@ void CoverSwitchEffect::paintWindows( const EffectWindowList& windows, bool left
rot.angle *= rotateFactor;
data.rotation = &rot;
// make window most to edge transparent if animation
if( animation && i == 0 && ( ( direction == Left && left ) || ( direction == Right && !left ) ) )
{
if (animation && i == 0 && ((direction == Left && left) || (direction == Right && !left))) {
// only for the first half of the animation
if( timeLine.value() < 0.5 )
{
if (timeLine.value() < 0.5) {
data.opacity *= (1.0 - timeLine.value() * 2.0);
paintWindowCover(window, reflectedWindows, data);
}
}
else
{
} else {
paintWindowCover(window, reflectedWindows, data);
}
}
@ -1060,16 +932,13 @@ void CoverSwitchEffect::windowInputMouseEvent( Window w, QEvent* e )
if (!selected_window)
return;
if( pos.x() < (area.width()*scaleFactor - selected_window->width())*0.5f*(1.0f/scaleFactor) )
{
if (pos.x() < (area.width()*scaleFactor - selected_window->width()) * 0.5f *(1.0f / scaleFactor)) {
float availableSize = (area.width() * scaleFactor - area.width()) * 0.5f * (1.0f / scaleFactor);
for( int i=0;i<leftWindows.count();i++ )
{
for (int i = 0; i < leftWindows.count(); i++) {
int windowPos = availableSize / leftWindows.count() * i;
if (pos.x() < windowPos)
continue;
if( i+1 < leftWindows.count() )
{
if (i + 1 < leftWindows.count()) {
if (pos.x() > availableSize / leftWindows.count()*(i + 1))
continue;
}
@ -1079,16 +948,13 @@ void CoverSwitchEffect::windowInputMouseEvent( Window w, QEvent* e )
}
}
if( pos.x() > area.width() - (area.width()*scaleFactor - selected_window->width())*0.5f*(1.0f/scaleFactor) )
{
if (pos.x() > area.width() - (area.width()*scaleFactor - selected_window->width()) * 0.5f *(1.0f / scaleFactor)) {
float availableSize = (area.width() * scaleFactor - area.width()) * 0.5f * (1.0f / scaleFactor);
for( int i=0;i<rightWindows.count();i++ )
{
for (int i = 0; i < rightWindows.count(); i++) {
int windowPos = area.width() - availableSize / rightWindows.count() * i;
if (pos.x() > windowPos)
continue;
if( i+1 < rightWindows.count() )
{
if (i + 1 < rightWindows.count()) {
if (pos.x() < area.width() - availableSize / rightWindows.count()*(i + 1))
continue;
}
@ -1103,8 +969,7 @@ void CoverSwitchEffect::abort()
{
// it's possible that abort is called after tabbox has been closed
// in this case the cleanup is already done (see bug 207554)
if( mActivated )
{
if (mActivated) {
effects->unrefTabBox();
effects->destroyInputWindow(input);
}
@ -1119,8 +984,7 @@ void CoverSwitchEffect::abort()
void CoverSwitchEffect::windowClosed(EffectWindow* c)
{
// if the list is not empty, the effect is active
if( !currentWindowList.isEmpty() )
{
if (!currentWindowList.isEmpty()) {
c->refWindow();
referrencedWindows.append(c);
currentWindowList.removeAll(c);

View File

@ -79,8 +79,7 @@ class CoverSwitchEffect
Window input;
float zPosition;
float scaleFactor;
enum Direction
{
enum Direction {
Left,
Right
};

File diff suppressed because it is too large Load Diff

View File

@ -71,21 +71,18 @@ class CubeEffect
void cylinderShortcutChanged(const QKeySequence& seq);
void sphereShortcutChanged(const QKeySequence& seq);
private:
enum RotationDirection
{
enum RotationDirection {
Left,
Right,
Upwards,
Downwards
};
enum VerticalRotationPosition
{
enum VerticalRotationPosition {
Up,
Normal,
Down
};
enum CubeMode
{
enum CubeMode {
Cube,
Cylinder,
Sphere

View File

@ -125,52 +125,34 @@ void CubeEffectConfig::load()
m_ui->cubeOpacitySlider->setValue(opacity);
m_ui->cubeOpacitySpin->setValue(opacity);
m_ui->desktopOpacityOnlyBox->setChecked(desktopOpacityOnly);
if( desktopName )
{
if (desktopName) {
m_ui->displayDesktopNameBox->setCheckState(Qt::Checked);
}
else
{
} else {
m_ui->displayDesktopNameBox->setCheckState(Qt::Unchecked);
}
if( reflection )
{
if (reflection) {
m_ui->reflectionBox->setCheckState(Qt::Checked);
}
else
{
} else {
m_ui->reflectionBox->setCheckState(Qt::Unchecked);
}
if( caps )
{
if (caps) {
m_ui->cubeCapsBox->setCheckState(Qt::Checked);
}
else
{
} else {
m_ui->cubeCapsBox->setCheckState(Qt::Unchecked);
}
if( texturedCaps )
{
if (texturedCaps) {
m_ui->capsImageBox->setCheckState(Qt::Checked);
}
else
{
} else {
m_ui->capsImageBox->setCheckState(Qt::Unchecked);
}
if( closeOnMouseRelease )
{
if (closeOnMouseRelease) {
m_ui->closeOnMouseReleaseBox->setCheckState(Qt::Checked);
}
else
{
} else {
m_ui->closeOnMouseReleaseBox->setCheckState(Qt::Unchecked);
}
if( walkThroughDesktop )
{
if (walkThroughDesktop) {
m_ui->walkThroughDesktopBox->setCheckState(Qt::Checked);
}
else
{
} else {
m_ui->walkThroughDesktopBox->setCheckState(Qt::Unchecked);
}
m_ui->backgroundColorButton->setColor(background);
@ -239,15 +221,12 @@ void CubeEffectConfig::defaults()
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
{
} else {
// deactivate cap color
m_ui->capColorButton->setEnabled(false);
m_ui->capColorLabel->setEnabled(false);

View File

@ -64,8 +64,7 @@ void CubeSlideEffect::reconfigure( ReconfigureFlags )
void CubeSlideEffect::prePaintScreen(ScreenPrePaintData& data, int time)
{
if( !slideRotations.empty() )
{
if (!slideRotations.empty()) {
data.mask |= PAINT_SCREEN_TRANSFORMED | Effect::PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS | PAINT_SCREEN_BACKGROUND_FIRST;
timeLine.addTime(time);
if (windowMoving && timeLine.progress() > progressRestriction)
@ -79,8 +78,7 @@ void CubeSlideEffect::prePaintScreen( ScreenPrePaintData& data, int time)
void CubeSlideEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
{
if( !slideRotations.empty() )
{
if (!slideRotations.empty()) {
#ifdef KWIN_HAVE_OPENGLES
glEnable(GL_CULL_FACE);
glCullFace(GL_FRONT);
@ -102,21 +100,17 @@ void CubeSlideEffect::paintScreen( int mask, QRegion region, ScreenPaintData& da
glDisable(GL_CULL_FACE);
glPopAttrib();
#endif
if( dontSlidePanels )
{
foreach( EffectWindow* w, panels )
{
if (dontSlidePanels) {
foreach (EffectWindow * w, panels) {
WindowPaintData wData(w);
effects->paintWindow(w, 0, QRegion(w->x(), w->y(), w->width(), w->height()), wData);
}
}
foreach( EffectWindow* w, stickyWindows )
{
foreach (EffectWindow * w, stickyWindows) {
WindowPaintData wData(w);
effects->paintWindow(w, 0, QRegion(w->x(), w->y(), w->width(), w->height()), wData);
}
}
else
} else
effects->paintScreen(mask, region, data);
}
@ -135,15 +129,13 @@ void CubeSlideEffect::paintSlideCube(int mask, QRegion region, ScreenPaintData&
RotationData secondFaceRot = RotationData();
RotationDirection direction = slideRotations.head();
int secondDesktop;
switch ( direction )
{
switch(direction) {
case Left:
firstFaceRot.axis = RotationData::YAxis;
secondFaceRot.axis = RotationData::YAxis;
if (usePagerLayout)
secondDesktop = effects->desktopToLeft(front_desktop, true);
else
{
else {
secondDesktop = front_desktop - 1;
if (secondDesktop == 0)
secondDesktop = effects->numberOfDesktops();
@ -156,8 +148,7 @@ void CubeSlideEffect::paintSlideCube(int mask, QRegion region, ScreenPaintData&
secondFaceRot.axis = RotationData::YAxis;
if (usePagerLayout)
secondDesktop = effects->desktopToRight(front_desktop, true);
else
{
else {
secondDesktop = front_desktop + 1;
if (secondDesktop > effects->numberOfDesktops())
secondDesktop = 1;
@ -208,83 +199,64 @@ void CubeSlideEffect::paintSlideCube(int mask, QRegion region, ScreenPaintData&
void CubeSlideEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
{
if( !slideRotations.empty() && cube_painting )
{
if (!slideRotations.empty() && cube_painting) {
QRect rect = effects->clientArea(FullArea, effects->activeScreen(), painting_desktop);
if( dontSlidePanels && w->isDock())
{
if (dontSlidePanels && w->isDock()) {
w->setData(WindowForceBlurRole, QVariant(true));
panels.insert(w);
}
if( !w->isManaged() )
{
if (!w->isManaged()) {
w->setData(WindowForceBlurRole, QVariant(true));
stickyWindows.insert(w);
} else if (dontSlideStickyWindows && !w->isDock() &&
!w->isDesktop() && w->isOnAllDesktops()) {
w->setData(WindowForceBlurRole, QVariant(true));
stickyWindows.insert(w);
}
else if( dontSlideStickyWindows && !w->isDock() &&
!w->isDesktop() && w->isOnAllDesktops())
{
w->setData( WindowForceBlurRole, QVariant( true ) );
stickyWindows.insert( w );
}
if( w->isOnDesktop( painting_desktop ) )
{
if( w->x() < rect.x() )
{
if (w->isOnDesktop(painting_desktop)) {
if (w->x() < rect.x()) {
data.quads = data.quads.splitAtX(-w->x());
}
if( w->x() + w->width() > rect.x() + rect.width() )
{
if (w->x() + w->width() > rect.x() + rect.width()) {
data.quads = data.quads.splitAtX(rect.width() - w->x());
}
if( w->y() < rect.y() )
{
if (w->y() < rect.y()) {
data.quads = data.quads.splitAtY(-w->y());
}
if( w->y() + w->height() > rect.y() + rect.height() )
{
if (w->y() + w->height() > rect.y() + rect.height()) {
data.quads = data.quads.splitAtY(rect.height() - w->y());
}
w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DESKTOP);
}
else if( w->isOnDesktop( other_desktop ) )
{
} else if (w->isOnDesktop(other_desktop)) {
RotationDirection direction = slideRotations.head();
bool enable = false;
if (w->x() < rect.x() &&
( direction == Left || direction == Right ) )
{
(direction == Left || direction == Right)) {
data.quads = data.quads.splitAtX(-w->x());
enable = true;
}
if (w->x() + w->width() > rect.x() + rect.width() &&
( direction == Left || direction == Right ) )
{
(direction == Left || direction == Right)) {
data.quads = data.quads.splitAtX(rect.width() - w->x());
enable = true;
}
if (w->y() < rect.y() &&
( direction == Upwards || direction == Downwards ) )
{
(direction == Upwards || direction == Downwards)) {
data.quads = data.quads.splitAtY(-w->y());
enable = true;
}
if (w->y() + w->height() > rect.y() + rect.height() &&
( direction == Upwards || direction == Downwards ) )
{
(direction == Upwards || direction == Downwards)) {
data.quads = data.quads.splitAtY(rect.height() - w->y());
enable = true;
}
if( enable )
{
if (enable) {
data.setTransformed();
data.setTranslucent();
w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DESKTOP);
}
else
} else
w->disablePainting(EffectWindow::PAINT_DISABLED_BY_DESKTOP);
}
else
} else
w->disablePainting(EffectWindow::PAINT_DISABLED_BY_DESKTOP);
}
effects->prePaintWindow(w, data, time);
@ -292,8 +264,7 @@ void CubeSlideEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data
void CubeSlideEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{
if( !slideRotations.empty() && cube_painting )
{
if (!slideRotations.empty() && cube_painting) {
if (dontSlidePanels && w->isDock())
return;
if (stickyWindows.contains(w))
@ -301,51 +272,38 @@ void CubeSlideEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Wi
// filter out quads overlapping the edges
QRect rect = effects->clientArea(FullArea, effects->activeScreen(), painting_desktop);
if( w->isOnDesktop( painting_desktop ) )
{
if( w->x() < rect.x() )
{
if (w->isOnDesktop(painting_desktop)) {
if (w->x() < rect.x()) {
WindowQuadList new_quads;
foreach( const WindowQuad &quad, data.quads )
{
if( quad.right() > -w->x() )
{
foreach (const WindowQuad & quad, data.quads) {
if (quad.right() > -w->x()) {
new_quads.append(quad);
}
}
data.quads = new_quads;
}
if( w->x() + w->width() > rect.x() + rect.width() )
{
if (w->x() + w->width() > rect.x() + rect.width()) {
WindowQuadList new_quads;
foreach( const WindowQuad &quad, data.quads )
{
if( quad.right() <= rect.width() - w->x() )
{
foreach (const WindowQuad & quad, data.quads) {
if (quad.right() <= rect.width() - w->x()) {
new_quads.append(quad);
}
}
data.quads = new_quads;
}
if( w->y() < rect.y() )
{
if (w->y() < rect.y()) {
WindowQuadList new_quads;
foreach( const WindowQuad &quad, data.quads )
{
if( quad.bottom() > -w->y() )
{
foreach (const WindowQuad & quad, data.quads) {
if (quad.bottom() > -w->y()) {
new_quads.append(quad);
}
}
data.quads = new_quads;
}
if( w->y() + w->height() > rect.y() + rect.height() )
{
if (w->y() + w->height() > rect.y() + rect.height()) {
WindowQuadList new_quads;
foreach( const WindowQuad &quad, data.quads )
{
if( quad.bottom() <= rect.height() - w->y() )
{
foreach (const WindowQuad & quad, data.quads) {
if (quad.bottom() <= rect.height() - w->y()) {
new_quads.append(quad);
}
}
@ -353,60 +311,47 @@ void CubeSlideEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Wi
}
}
// paint windows overlapping edges from other desktop
if( w->isOnDesktop( other_desktop ) && ( mask & PAINT_WINDOW_TRANSFORMED ) )
{
if (w->isOnDesktop(other_desktop) && (mask & PAINT_WINDOW_TRANSFORMED)) {
RotationDirection direction = slideRotations.head();
if (w->x() < rect.x() &&
( direction == Left || direction == Right ) )
{
(direction == Left || direction == Right)) {
WindowQuadList new_quads;
data.xTranslate = rect.width();
foreach( const WindowQuad &quad, data.quads )
{
if( quad.right() <= -w->x() )
{
foreach (const WindowQuad & quad, data.quads) {
if (quad.right() <= -w->x()) {
new_quads.append(quad);
}
}
data.quads = new_quads;
}
if (w->x() + w->width() > rect.x() + rect.width() &&
( direction == Left || direction == Right ) )
{
(direction == Left || direction == Right)) {
WindowQuadList new_quads;
data.xTranslate = -rect.width();
foreach( const WindowQuad &quad, data.quads )
{
if( quad.right() > rect.width() - w->x() )
{
foreach (const WindowQuad & quad, data.quads) {
if (quad.right() > rect.width() - w->x()) {
new_quads.append(quad);
}
}
data.quads = new_quads;
}
if (w->y() < rect.y() &&
( direction == Upwards || direction == Downwards ) )
{
(direction == Upwards || direction == Downwards)) {
WindowQuadList new_quads;
data.yTranslate = rect.height();
foreach( const WindowQuad &quad, data.quads )
{
if( quad.bottom() <= -w->y() )
{
foreach (const WindowQuad & quad, data.quads) {
if (quad.bottom() <= -w->y()) {
new_quads.append(quad);
}
}
data.quads = new_quads;
}
if (w->y() + w->height() > rect.y() + rect.height() &&
( direction == Upwards || direction == Downwards ) )
{
(direction == Upwards || direction == Downwards)) {
WindowQuadList new_quads;
data.yTranslate = -rect.height();
foreach( const WindowQuad &quad, data.quads )
{
if( quad.bottom() > rect.height() - w->y() )
{
foreach (const WindowQuad & quad, data.quads) {
if (quad.bottom() > rect.height() - w->y()) {
new_quads.append(quad);
}
}
@ -424,18 +369,14 @@ void CubeSlideEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Wi
void CubeSlideEffect::postPaintScreen()
{
effects->postPaintScreen();
if( !slideRotations.empty() )
{
if( timeLine.value() == 1.0 )
{
if (!slideRotations.empty()) {
if (timeLine.value() == 1.0) {
RotationDirection direction = slideRotations.dequeue();
switch (direction)
{
switch(direction) {
case Left:
if (usePagerLayout)
front_desktop = effects->desktopToLeft(front_desktop, true);
else
{
else {
front_desktop--;
if (front_desktop == 0)
front_desktop = effects->numberOfDesktops();
@ -444,8 +385,7 @@ void CubeSlideEffect::postPaintScreen()
case Right:
if (usePagerLayout)
front_desktop = effects->desktopToRight(front_desktop, true);
else
{
else {
front_desktop++;
if (front_desktop > effects->numberOfDesktops())
front_desktop = 1;
@ -463,8 +403,7 @@ void CubeSlideEffect::postPaintScreen()
timeLine.setCurveShape(TimeLine::EaseOutCurve);
else
timeLine.setCurveShape(TimeLine::LinearCurve);
if( slideRotations.empty() )
{
if (slideRotations.empty()) {
foreach (EffectWindow * w, panels)
w->setData(WindowForceBlurRole, QVariant(false));
foreach (EffectWindow * w, stickyWindows)
@ -482,33 +421,28 @@ void CubeSlideEffect::desktopChanged( int old )
{
if (effects->activeFullScreenEffect() && effects->activeFullScreenEffect() != this)
return;
if( old > effects->numberOfDesktops() )
{
if (old > effects->numberOfDesktops()) {
// number of desktops has been reduced -> no animation
return;
}
if( windowMoving )
{
if (windowMoving) {
desktopChangedWhileMoving = true;
progressRestriction = 1.0 - progressRestriction;
effects->addRepaintFull();
return;
}
bool activate = true;
if( !slideRotations.empty() )
{
if (!slideRotations.empty()) {
// last slide still in progress
activate = false;
RotationDirection direction = slideRotations.dequeue();
slideRotations.clear();
slideRotations.enqueue(direction);
switch (direction)
{
switch(direction) {
case Left:
if (usePagerLayout)
old = effects->desktopToLeft(front_desktop, true);
else
{
else {
old = front_desktop - 1;
if (old == 0)
old = effects->numberOfDesktops();
@ -517,8 +451,7 @@ void CubeSlideEffect::desktopChanged( int old )
case Right:
if (usePagerLayout)
old = effects->desktopToRight(front_desktop, true);
else
{
else {
old = front_desktop + 1;
if (old > effects->numberOfDesktops())
old = 1;
@ -532,53 +465,39 @@ void CubeSlideEffect::desktopChanged( int old )
break;
}
}
if( usePagerLayout )
{
if (usePagerLayout) {
// calculate distance in respect to pager
QPoint diff = effects->desktopGridCoords(effects->currentDesktop()) - effects->desktopGridCoords(old);
if( qAbs( diff.x() ) > effects->desktopGridWidth()/2 )
{
if (qAbs(diff.x()) > effects->desktopGridWidth() / 2) {
int sign = -1 * (diff.x() / qAbs(diff.x()));
diff.setX(sign *(effects->desktopGridWidth() - qAbs(diff.x())));
}
if( diff.x() > 0 )
{
for( int i=0; i<diff.x(); i++ )
{
if (diff.x() > 0) {
for (int i = 0; i < diff.x(); i++) {
slideRotations.enqueue(Right);
}
}
else if( diff.x() < 0 )
{
} else if (diff.x() < 0) {
diff.setX(-diff.x());
for( int i=0; i<diff.x(); i++ )
{
for (int i = 0; i < diff.x(); i++) {
slideRotations.enqueue(Left);
}
}
if( qAbs( diff.y() ) > effects->desktopGridHeight()/2 )
{
if (qAbs(diff.y()) > effects->desktopGridHeight() / 2) {
int sign = -1 * (diff.y() / qAbs(diff.y()));
diff.setY(sign *(effects->desktopGridHeight() - qAbs(diff.y())));
}
if( diff.y() > 0 )
{
for( int i=0; i<diff.y(); i++ )
{
if (diff.y() > 0) {
for (int i = 0; i < diff.y(); i++) {
slideRotations.enqueue(Downwards);
}
}
if( diff.y() < 0 )
{
if (diff.y() < 0) {
diff.setY(-diff.y());
for( int i=0; i<diff.y(); i++ )
{
for (int i = 0; i < diff.y(); i++) {
slideRotations.enqueue(Upwards);
}
}
}
else
{
} else {
// ignore pager layout
int left = old - effects->currentDesktop();
if (left < 0)
@ -586,24 +505,18 @@ void CubeSlideEffect::desktopChanged( int old )
int right = effects->currentDesktop() - old;
if (right < 0)
right = effects->numberOfDesktops() + right;
if( left < right )
{
for( int i=0; i<left; i++ )
{
if (left < right) {
for (int i = 0; i < left; i++) {
slideRotations.enqueue(Left);
}
}
else
{
for( int i=0; i<right; i++ )
{
} else {
for (int i = 0; i < right; i++) {
slideRotations.enqueue(Right);
}
}
}
timeLine.setDuration((float)rotationDuration / (float)slideRotations.count());
if( activate )
{
if (activate) {
if (slideRotations.count() == 1)
timeLine.setCurveShape(TimeLine::EaseInOutCurve);
else
@ -621,15 +534,12 @@ void CubeSlideEffect::windowUserMovedResized( EffectWindow* c, bool first, bool
return;
if ((first && last) || c->isUserResize())
return;
if( last )
{
if( !desktopChangedWhileMoving )
{
if (last) {
if (!desktopChangedWhileMoving) {
if (slideRotations.isEmpty())
return;
const RotationDirection direction = slideRotations.dequeue();
switch( direction )
{
switch(direction) {
case Left:
slideRotations.enqueue(Right);
break;
@ -659,28 +569,19 @@ void CubeSlideEffect::windowUserMovedResized( EffectWindow* c, bool first, bool
const QRect rightRect(displayWidth() - horizontal, displayHeight() * 0.1, horizontal, displayHeight() * 0.8);
const QRect topRect(horizontal, 0, displayWidth() * 0.8, vertical);
const QRect bottomRect(horizontal, displayHeight() - vertical, displayWidth() - horizontal * 2, vertical);
if( leftRect.contains( cursor ) )
{
if (leftRect.contains(cursor)) {
if (effects->desktopToLeft(effects->currentDesktop()) != effects->currentDesktop())
windowMovingChanged(0.3 *(float)(horizontal - cursor.x()) / (float)horizontal, Left);
}
else if( rightRect.contains( cursor ) )
{
} else if (rightRect.contains(cursor)) {
if (effects->desktopToRight(effects->currentDesktop()) != effects->currentDesktop())
windowMovingChanged(0.3 *(float)(cursor.x() - displayWidth() + horizontal) / (float)horizontal, Right);
}
else if( topRect.contains( cursor ) )
{
} else if (topRect.contains(cursor)) {
if (effects->desktopAbove(effects->currentDesktop()) != effects->currentDesktop())
windowMovingChanged(0.3 *(float)(vertical - cursor.y()) / (float)vertical, Upwards);
}
else if( bottomRect.contains( cursor ) )
{
} else if (bottomRect.contains(cursor)) {
if (effects->desktopBelow(effects->currentDesktop()) != effects->currentDesktop())
windowMovingChanged(0.3 *(float)(cursor.y() - displayHeight() + vertical) / (float)vertical, Downwards);
}
else
{
} else {
// not in one of the areas
windowMoving = false;
desktopChangedWhileMoving = false;
@ -699,8 +600,7 @@ void CubeSlideEffect::windowMovingChanged( float progress, RotationDirection dir
else
progressRestriction = progress;
front_desktop = effects->currentDesktop();
if( slideRotations.isEmpty() )
{
if (slideRotations.isEmpty()) {
slideRotations.enqueue(direction);
timeLine.setCurveShape(TimeLine::EaseInOutCurve);
windowMoving = true;

View File

@ -45,8 +45,7 @@ class CubeSlideEffect
static bool supported();
private:
enum RotationDirection
{
enum RotationDirection {
Left,
Right,
Upwards,

View File

@ -74,8 +74,7 @@ void DashboardEffect::reconfigure( ReconfigureFlags )
void DashboardEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{
if( transformWindow && ( w != window ) && w->isManaged() && !isDashboard( w ) )
{
if (transformWindow && (w != window) && w->isManaged() && !isDashboard(w)) {
brightnessDelta = (1 - (brightness.toDouble() / 100));
saturationDelta = (1 - (saturation.toDouble() / 100));
@ -84,15 +83,11 @@ void DashboardEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Wi
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;
}
}
@ -102,8 +97,7 @@ void DashboardEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Wi
void DashboardEffect::prePaintScreen(ScreenPrePaintData& data, int time)
{
if( transformWindow )
{
if (transformWindow) {
if (activateAnimation)
timeline.addTime(time);
if (deactivateAnimation)
@ -114,28 +108,23 @@ void DashboardEffect::prePaintScreen( ScreenPrePaintData& data, int time )
void DashboardEffect::postPaintScreen()
{
if( transformWindow )
{
if( retransformWindow )
{
if (transformWindow) {
if (retransformWindow) {
retransformWindow = false;
transformWindow = false;
effects->addRepaintFull();
effects->setActiveFullScreenEffect(0);
}
if( activateAnimation )
{
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);
@ -150,12 +139,9 @@ void DashboardEffect::postPaintScreen()
bool DashboardEffect::isDashboard(EffectWindow *w)
{
if( w->windowClass() == "dashboard dashboard")
{
if (w->windowClass() == "dashboard dashboard") {
return true;
}
else
{
} else {
return false;
}
}
@ -166,23 +152,18 @@ void DashboardEffect::windowActivated( EffectWindow *w )
return;
// apply effect on dashboard activation
if( isDashboard( w ) )
{
if (isDashboard(w)) {
effects->setActiveFullScreenEffect(this);
transformWindow = true;
window = w;
if ( blur )
{
if (blur) {
w->setData(WindowBlurBehindRole, w->geometry());
}
effects->addRepaintFull();
}
else
{
if( transformWindow)
{
} else {
if (transformWindow) {
retransformWindow = true;
effects->addRepaintFull();
}
@ -193,8 +174,7 @@ 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)));
@ -210,8 +190,7 @@ 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->addRepaintFull();

File diff suppressed because it is too large Load Diff

View File

@ -167,13 +167,10 @@ void DesktopGridEffectConfig::defaults()
void DesktopGridEffectConfig::layoutSelectionChanged()
{
if( m_ui->layoutCombo->currentIndex() == DesktopGridEffect::LayoutCustom )
{
if (m_ui->layoutCombo->currentIndex() == DesktopGridEffect::LayoutCustom) {
m_ui->layoutRowsLabel->setEnabled(true);
m_ui->layoutRowsSpin->setEnabled(true);
}
else
{
} else {
m_ui->layoutRowsLabel->setEnabled(false);
m_ui->layoutRowsSpin->setEnabled(false);
}

View File

@ -41,13 +41,10 @@ void DialogParentEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& da
// 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
{
} else {
effectStrength[w] = qMax(0.0, effectStrength[w] - time / changeTime);
}
@ -58,8 +55,7 @@ void DialogParentEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& da
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]
@ -88,8 +84,7 @@ 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)
@ -102,8 +97,7 @@ 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)

View File

@ -56,8 +56,8 @@ void DimInactiveEffect::prePaintScreen( ScreenPrePaintData& data, int time )
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);
}
@ -66,8 +66,7 @@ void DimInactiveEffect::prePaintScreen( ScreenPrePaintData& data, int time )
void DimInactiveEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{
if( dimWindow( w ) || w == previousActive )
{
if (dimWindow(w) || w == previousActive) {
double previous = 1.0;
if (w == previousActive)
previous = previousActiveTimeline.value();
@ -108,36 +107,30 @@ void DimInactiveEffect::windowDeleted( EffectWindow* w )
void DimInactiveEffect::windowActivated(EffectWindow* w)
{
if( active != NULL )
{
if (active != NULL) {
previousActive = active;
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
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
if (active != NULL) {
if (dim_by_group) {
if (active->group() != NULL) {
// repaint newly active windows
foreach (EffectWindow * tmp, active->group()->members())
tmp->addRepaintFull();
}
}
else
} else
active->addRepaintFull();
}
}

View File

@ -58,15 +58,12 @@ void DimScreenEffect::prePaintScreen( ScreenPrePaintData& data, int 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();
@ -80,8 +77,7 @@ void DimScreenEffect::postPaintScreen()
void DimScreenEffect::paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data)
{
if( mActivated && ( w != window ) && w->isManaged() )
{
if (mActivated && (w != window) && w->isManaged()) {
data.brightness *= (1.0 - 0.33 * timeline.value());
data.saturation *= (1.0 - 0.33 * timeline.value());
}
@ -97,18 +93,14 @@ void DimScreenEffect::windowActivated( EffectWindow *w )
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();

View File

@ -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,13 +85,10 @@ 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
{
} else {
mStartOffsetTex->setFilter(GL_LINEAR);
mEndOffsetTex->setFilter(GL_LINEAR);
}
@ -115,21 +108,16 @@ void ExplosionEffect::prePaintScreen( ScreenPrePaintData& data, int time )
void ExplosionEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
{
if( mWindows.contains( w ))
{
if (mWindows.contains(w)) {
if (mValid && !mInited)
mValid = loadData();
if( mValid )
{
if (mValid) {
mWindows[ w ] += time / animationTime(700.0); // complete change in 700ms
if( mWindows[ w ] < 1 )
{
if (mWindows[ w ] < 1) {
data.setTranslucent();
data.setTransformed();
w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DELETE);
}
else
{
} else {
mWindows.remove(w);
w->unrefWindow();
mActiveAnimations--;
@ -145,8 +133,7 @@ void ExplosionEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Wi
// Make sure we have OpenGL compositing and the window is vidible and not a
// special window
bool useshader = (mValid && mWindows.contains(w));
if( useshader )
{
if (useshader) {
double maxscaleadd = 1.5f;
double scale = 1 + maxscaleadd * mWindows[w];
data.xScale = scale;
@ -173,8 +160,7 @@ void ExplosionEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Wi
// Call the next effect.
effects->paintWindow(w, mask, region, data);
if( useshader )
{
if (useshader) {
ShaderManager::instance()->popShader();
glActiveTexture(GL_TEXTURE4);
mStartOffsetTex->unbind();
@ -198,8 +184,7 @@ 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();

View File

@ -51,8 +51,7 @@ void FadeEffect::reconfigure( ReconfigureFlags )
void FadeEffect::prePaintScreen(ScreenPrePaintData& data, int time)
{
if( !windows.isEmpty())
{
if (!windows.isEmpty()) {
fadeInStep = time / double(fadeInTime);
fadeOutStep = time / double(fadeOutTime);
}
@ -61,30 +60,26 @@ void FadeEffect::prePaintScreen( ScreenPrePaintData& data, int time )
void FadeEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
{
if( windows.contains( w ))
{
if (windows.contains(w)) {
windows[ w ].fadeInStep += fadeInStep;
windows[ w ].fadeOutStep += fadeOutStep;
if (windows[ w ].opacity < 1.0)
data.setTranslucent();
if( windows[ w ].deleted )
{
if( windows[ w ].opacity <= 0.0 )
{
if (windows[ w ].deleted) {
if (windows[ w ].opacity <= 0.0) {
windows.remove(w);
w->unrefWindow();
}
else
} else
w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DELETE);
}
}
effects->prePaintWindow(w, data, time);
if( windows.contains( w ) && !w->isPaintingEnabled() && !effects->activeFullScreenEffect() )
{ // if the window isn't to be painted, then let's make sure
if (windows.contains(w) && !w->isPaintingEnabled() && !effects->activeFullScreenEffect()) {
// if the window isn't to be painted, then let's make sure
// to track its progress
if (windows[ w ].fadeInStep < 1.0
|| windows[ w ].fadeOutStep < 1.0 )
{ // but only if the total change is less than the
|| windows[ w ].fadeOutStep < 1.0) {
// but only if the total change is less than the
// maximum possible change
w->addRepaintFull();
}
@ -93,47 +88,36 @@ void FadeEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int
void FadeEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{
if( windows.contains( w ))
{
if (windows.contains(w)) {
if (windows[ w ].deleted
|| windows[ w ].opacity != data.opacity
|| windows[ w ].saturation != data.saturation
|| windows[ w ].brightness != data.brightness )
{
|| windows[ w ].brightness != data.brightness) {
WindowPaintData new_data = data;
if (windows[ w ].deleted)
new_data.opacity = 0.0;
if( new_data.opacity > windows[ w ].opacity )
{
if (new_data.opacity > windows[ w ].opacity) {
windows[ w ].opacity = qMin(new_data.opacity,
windows[ w ].opacity + windows[ w ].fadeInStep);
}
else if( new_data.opacity < windows[ w ].opacity )
{
} else if (new_data.opacity < windows[ w ].opacity) {
windows[ w ].opacity = qMax(new_data.opacity,
windows[ w ].opacity - windows[ w ].fadeOutStep);
}
if( new_data.saturation > windows[ w ].saturation )
{
if (new_data.saturation > windows[ w ].saturation) {
windows[ w ].saturation = qMin(new_data.saturation,
windows[ w ].saturation + windows[ w ].fadeInStep);
}
else if( new_data.saturation < windows[ w ].saturation )
{
} else if (new_data.saturation < windows[ w ].saturation) {
windows[ w ].saturation = qMax(new_data.saturation,
windows[ w ].saturation - windows[ w ].fadeOutStep);
}
if( new_data.brightness > windows[ w ].brightness )
{
if (new_data.brightness > windows[ w ].brightness) {
windows[ w ].brightness = qMin(new_data.brightness,
windows[ w ].brightness + windows[ w ].fadeInStep);
}
else if( new_data.brightness < windows[ w ].brightness )
{
} else if (new_data.brightness < windows[ w ].brightness) {
windows[ w ].brightness = qMax(new_data.brightness,
windows[ w ].brightness - windows[ w ].fadeOutStep);
}
@ -204,8 +188,8 @@ bool FadeEffect::isFadeWindow( EffectWindow* w )
e = w->data(WindowAddedGrabRole).value<void*>();
if (w->windowClass() == "ksplashx ksplashx"
|| w->windowClass() == "ksplashsimple ksplashsimple"
|| ( e && e != this ))
{ // see login effect
|| (e && e != this)) {
// see login effect
return false;
}
return (!w->isDesktop() && !w->isUtility());

View File

@ -41,20 +41,17 @@ void FadeDesktopEffect::reconfigure( ReconfigureFlags )
void FadeDesktopEffect::prePaintScreen(ScreenPrePaintData &data, int time)
{
if( m_fading )
{
if (m_fading) {
m_timeline.addTime(time);
// PAINT_SCREEN_BACKGROUND_FIRST is needed because screen will be actually painted more than once,
// so with normal screen painting second screen paint would erase parts of the first paint
if (m_timeline.value() != 1.0)
data.mask |= PAINT_SCREEN_TRANSFORMED | PAINT_SCREEN_BACKGROUND_FIRST;
else
{
else {
m_fading = false;
m_timeline.setProgress(0.0);
foreach( EffectWindow* w, effects->stackingOrder() )
{
foreach (EffectWindow * w, effects->stackingOrder()) {
w->setData(WindowForceBlurRole, QVariant(false));
}
effects->setActiveFullScreenEffect(NULL);
@ -72,8 +69,7 @@ void FadeDesktopEffect::postPaintScreen()
void FadeDesktopEffect::prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time)
{
if( m_fading )
{
if (m_fading) {
if (w->isOnDesktop(m_oldDesktop))
w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DESKTOP);
data.setTranslucent();
@ -83,8 +79,7 @@ void FadeDesktopEffect::prePaintWindow( EffectWindow *w, WindowPrePaintData &dat
void FadeDesktopEffect::paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data)
{
if( m_fading && !( w->isOnCurrentDesktop() && w->isOnDesktop( m_oldDesktop )))
{
if (m_fading && !(w->isOnCurrentDesktop() && w->isOnDesktop(m_oldDesktop))) {
if (w->isOnDesktop(m_oldDesktop))
data.opacity *= 1 - m_timeline.value();
else
@ -104,8 +99,7 @@ void FadeDesktopEffect::desktopChanged( int old )
m_fading = true;
m_timeline.setProgress(0);
m_oldDesktop = old;
foreach( EffectWindow* w, effects->stackingOrder() )
{
foreach (EffectWindow * w, effects->stackingOrder()) {
w->setData(WindowForceBlurRole, QVariant(true));
}

View File

@ -48,18 +48,14 @@ void FallApartEffect::prePaintScreen( ScreenPrePaintData& data, int time )
void FallApartEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
{
if( windows.contains( w ) && isRealWindow( w ))
{
if( windows[ w ] < 1 )
{
if (windows.contains(w) && isRealWindow(w)) {
if (windows[ w ] < 1) {
windows[ w ] += time / animationTime(1000.);
data.setTransformed();
w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DELETE);
// Request the window to be divided into cells
data.quads = data.quads.makeGrid(blockSize);
}
else
{
} else {
windows.remove(w);
w->unrefWindow();
}
@ -69,12 +65,10 @@ void FallApartEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data,
void FallApartEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{
if( windows.contains( w ) && isRealWindow( w ) )
{
if (windows.contains(w) && isRealWindow(w)) {
WindowQuadList new_quads;
int cnt = 0;
foreach( WindowQuad quad, data.quads ) // krazy:exclude=foreach
{
foreach (WindowQuad quad, data.quads) { // krazy:exclude=foreach
// make fragments move in various directions, based on where
// they are (left pieces generally move to the left, etc.)
QPointF p1(quad[ 0 ].x(), quad[ 0 ].y());
@ -94,8 +88,7 @@ void FallApartEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Wi
ydiff += (rand() % 21 - 10);
for (int j = 0;
j < 4;
++j )
{
++j) {
quad[ j ].move(quad[ j ].x() + xdiff * modif, quad[ j ].y() + ydiff * modif);
}
// also make the fragments rotate around their center
@ -104,8 +97,7 @@ void FallApartEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Wi
double adiff = (rand() % 720 - 360) / 360. * 2 * M_PI; // spin randomly
for (int j = 0;
j < 4;
++j )
{
++j) {
double x = quad[ j ].x() - center.x();
double y = quad[ j ].y() - center.y();
double angle = atan2(y, x);

View File

@ -72,12 +72,10 @@ FlipSwitchEffect::FlipSwitchEffect()
FlipSwitchEffect::~FlipSwitchEffect()
{
foreach( ElectricBorder border, m_borderActivate )
{
foreach (ElectricBorder border, m_borderActivate) {
effects->unreserveElectricBorder(border);
}
foreach( ElectricBorder border, m_borderActivateAll )
{
foreach (ElectricBorder border, m_borderActivateAll) {
effects->unreserveElectricBorder(border);
}
delete m_captionFrame;
@ -91,12 +89,10 @@ bool FlipSwitchEffect::supported()
void FlipSwitchEffect::reconfigure(ReconfigureFlags)
{
KConfigGroup conf = effects->effectConfig("FlipSwitch");
foreach( ElectricBorder border, m_borderActivate )
{
foreach (ElectricBorder border, m_borderActivate) {
effects->unreserveElectricBorder(border);
}
foreach( ElectricBorder border, m_borderActivateAll )
{
foreach (ElectricBorder border, m_borderActivateAll) {
effects->unreserveElectricBorder(border);
}
m_borderActivate.clear();
@ -104,16 +100,14 @@ void FlipSwitchEffect::reconfigure( ReconfigureFlags )
QList<int> borderList = QList<int>();
borderList.append(int(ElectricNone));
borderList = conf.readEntry("BorderActivate", borderList);
foreach( int i, borderList )
{
foreach (int i, borderList) {
m_borderActivate.append(ElectricBorder(i));
effects->reserveElectricBorder(ElectricBorder(i));
}
borderList.clear();
borderList.append(int(ElectricNone));
borderList = conf.readEntry("BorderActivateAll", borderList);
foreach( int i, borderList )
{
foreach (int i, borderList) {
m_borderActivateAll.append(ElectricBorder(i));
effects->reserveElectricBorder(ElectricBorder(i));
}
@ -131,8 +125,7 @@ void FlipSwitchEffect::reconfigure( ReconfigureFlags )
void FlipSwitchEffect::prePaintScreen(ScreenPrePaintData& data, int time)
{
if( m_active )
{
if (m_active) {
data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
if (m_start)
m_startStopTimeLine.addTime(time);
@ -147,19 +140,16 @@ void FlipSwitchEffect::prePaintScreen( ScreenPrePaintData& data, int time )
void FlipSwitchEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
{
effects->paintScreen(mask, region, data);
if( m_active )
{
if (m_active) {
EffectWindowList tempList;
if (m_mode == TabboxMode)
tempList = effects->currentTabBoxWindowList();
else
{
else {
// we have to setup the list
// using stacking order directly is not possible
// as not each window in stacking order is shown
// TODO: store list instead of calculating in each frame?
foreach( EffectWindow* w, effects->stackingOrder() )
{
foreach (EffectWindow * w, effects->stackingOrder()) {
if (m_windows.contains(w))
tempList.append(w);
}
@ -168,10 +158,8 @@ void FlipSwitchEffect::paintScreen( int mask, QRegion region, ScreenPaintData& d
int index = tempList.indexOf(m_selectedWindow);
int tabIndex = index;
if( m_mode == TabboxMode )
{
foreach( SwitchingDirection direction, m_scheduledDirections ) // krazy:exclude=foreach
{
if (m_mode == TabboxMode) {
foreach (SwitchingDirection direction, m_scheduledDirections) { // krazy:exclude=foreach
if (direction == DirectionBackward)
index++;
else
@ -183,8 +171,7 @@ void FlipSwitchEffect::paintScreen( int mask, QRegion region, ScreenPaintData& d
}
tabIndex = index;
EffectWindow* w = NULL;
if( !m_scheduledDirections.isEmpty() && m_scheduledDirections.head() == DirectionBackward )
{
if (!m_scheduledDirections.isEmpty() && m_scheduledDirections.head() == DirectionBackward) {
index--;
if (index < 0)
index = tempList.count() + index;
@ -194,16 +181,12 @@ void FlipSwitchEffect::paintScreen( int mask, QRegion region, ScreenPaintData& d
m_flipOrderedWindows.append(tempList.at(i));
for (int i = effects->currentTabBoxWindowList().count() - 1; i >= index; i--)
m_flipOrderedWindows.append(tempList.at(i));
if( w )
{
if (w) {
m_flipOrderedWindows.removeAll(w);
m_flipOrderedWindows.append(w);
}
}
else
{
foreach( SwitchingDirection direction, m_scheduledDirections ) // krazy:exclude=foreach
{
} else {
foreach (SwitchingDirection direction, m_scheduledDirections) { // krazy:exclude=foreach
if (direction == DirectionForward)
index++;
else
@ -215,8 +198,7 @@ void FlipSwitchEffect::paintScreen( int mask, QRegion region, ScreenPaintData& d
}
tabIndex = index;
EffectWindow* w = NULL;
if( !m_scheduledDirections.isEmpty() && m_scheduledDirections.head() == DirectionBackward )
{
if (!m_scheduledDirections.isEmpty() && m_scheduledDirections.head() == DirectionBackward) {
index++;
if (index >= tempList.count())
index = 0;
@ -226,8 +208,7 @@ void FlipSwitchEffect::paintScreen( int mask, QRegion region, ScreenPaintData& d
m_flipOrderedWindows.append(tempList.at(i));
for (int i = 0; i <= index; i++)
m_flipOrderedWindows.append(tempList.at(i));
if( w )
{
if (w) {
m_flipOrderedWindows.removeAll(w);
m_flipOrderedWindows.append(w);
}
@ -238,8 +219,7 @@ void FlipSwitchEffect::paintScreen( int mask, QRegion region, ScreenPaintData& d
QMatrix4x4 origProjection;
QMatrix4x4 origModelview;
ShaderManager *shaderManager = ShaderManager::instance();
if( effects->numScreens() > 1 )
{
if (effects->numScreens() > 1) {
// unfortunatelly we have to change the projection matrix in dual screen mode
QRect fullRect = effects->clientArea(FullArea, effects->activeScreen(), effects->currentDesktop());
float fovy = 60.0f;
@ -256,29 +236,25 @@ void FlipSwitchEffect::paintScreen( int mask, QRegion region, ScreenPaintData& d
float xmaxFactor = 1.0;
float yminFactor = 1.0;
float ymaxFactor = 1.0;
if( m_screenArea.x() == 0 && m_screenArea.width() != fullRect.width() )
{
if (m_screenArea.x() == 0 && m_screenArea.width() != fullRect.width()) {
// horizontal layout: left screen
xminFactor = (float)m_screenArea.width() / (float)fullRect.width();
xmaxFactor = ((float)fullRect.width() - (float)m_screenArea.width() * 0.5f) / ((float)fullRect.width() * 0.5f);
xTranslate = (float)fullRect.width() * 0.5f - (float)m_screenArea.width() * 0.5f;
}
if( m_screenArea.x() != 0 && m_screenArea.width() != fullRect.width() )
{
if (m_screenArea.x() != 0 && m_screenArea.width() != fullRect.width()) {
// horizontal layout: right screen
xminFactor = ((float)fullRect.width() - (float)m_screenArea.width() * 0.5f) / ((float)fullRect.width() * 0.5f);
xmaxFactor = (float)m_screenArea.width() / (float)fullRect.width();
xTranslate = (float)fullRect.width() * 0.5f - (float)m_screenArea.width() * 0.5f;
}
if( m_screenArea.y() == 0 && m_screenArea.height() != fullRect.height() )
{
if (m_screenArea.y() == 0 && m_screenArea.height() != fullRect.height()) {
// vertical layout: top screen
yminFactor = ((float)fullRect.height() - (float)m_screenArea.height() * 0.5f) / ((float)fullRect.height() * 0.5f);
ymaxFactor = (float)m_screenArea.height() / (float)fullRect.height();
yTranslate = (float)fullRect.height() * 0.5f - (float)m_screenArea.height() * 0.5f;
}
if( m_screenArea.y() != 0 && m_screenArea.height() != fullRect.height() )
{
if (m_screenArea.y() != 0 && m_screenArea.height() != fullRect.height()) {
// vertical layout: bottom screen
yminFactor = (float)m_screenArea.height() / (float)fullRect.height();
ymaxFactor = ((float)fullRect.height() - (float)m_screenArea.height() * 0.5f) / ((float)fullRect.height() * 0.5f);
@ -311,11 +287,9 @@ void FlipSwitchEffect::paintScreen( int mask, QRegion region, ScreenPaintData& d
rot.axis = RotationData::YAxis;
rot.angle = m_angle * m_startStopTimeLine.value();
// fade in/out one window at the end of the stack during animation
if( m_animation && !m_scheduledDirections.isEmpty() )
{
if (m_animation && !m_scheduledDirections.isEmpty()) {
EffectWindow* w = m_flipOrderedWindows.last();
if( m_windows.contains( w ) )
{
if (m_windows.contains(w)) {
WindowPaintData data(w);
data.opacity = m_windows[ w ]->opacity;
data.brightness = m_windows[ w ]->brightness;
@ -334,8 +308,7 @@ void FlipSwitchEffect::paintScreen( int mask, QRegion region, ScreenPaintData& d
else
data.opacity *= 0.8 * (1.0 - m_timeLine.value());
if( effects->numScreens() > 1)
{
if (effects->numScreens() > 1) {
adjustWindowMultiScreen(w, data);
}
data.rotation = &rot;
@ -343,8 +316,7 @@ void FlipSwitchEffect::paintScreen( int mask, QRegion region, ScreenPaintData& d
}
}
foreach( EffectWindow* w, m_flipOrderedWindows )
{
foreach (EffectWindow * w, m_flipOrderedWindows) {
if (!m_windows.contains(w))
continue;
WindowPaintData data(w);
@ -353,28 +325,22 @@ void FlipSwitchEffect::paintScreen( int mask, QRegion region, ScreenPaintData& d
data.saturation = m_windows[ w ]->saturation;
int windowIndex = tempList.indexOf(w);
int distance;
if( m_mode == TabboxMode )
{
if (m_mode == TabboxMode) {
if (windowIndex < tabIndex)
distance = tempList.count() - (tabIndex - windowIndex);
else if (windowIndex > tabIndex)
distance = windowIndex - tabIndex;
else
distance = 0;
}
else
{
} else {
distance = m_flipOrderedWindows.count() - m_flipOrderedWindows.indexOf(w) - 1;
if( !m_scheduledDirections.isEmpty() && m_scheduledDirections.head() == DirectionBackward )
{
if (!m_scheduledDirections.isEmpty() && m_scheduledDirections.head() == DirectionBackward) {
distance--;
}
}
if( !m_scheduledDirections.isEmpty() && m_scheduledDirections.head() == DirectionBackward )
{
if( w == m_flipOrderedWindows.last() )
{
if (!m_scheduledDirections.isEmpty() && m_scheduledDirections.head() == DirectionBackward) {
if (w == m_flipOrderedWindows.last()) {
distance = -1;
data.opacity *= m_timeLine.value();
}
@ -387,26 +353,21 @@ void FlipSwitchEffect::paintScreen( int mask, QRegion region, ScreenPaintData& d
data.xTranslate -= (m_screenArea.width() * 0.25f) * distance * m_startStopTimeLine.value();
data.yTranslate -= (m_screenArea.height() * 0.10f) * distance * m_startStopTimeLine.value();
data.zTranslate -= (zDistance * distance) * m_startStopTimeLine.value();
if( m_animation && !m_scheduledDirections.isEmpty() )
{
if( m_scheduledDirections.head() == DirectionForward )
{
if (m_animation && !m_scheduledDirections.isEmpty()) {
if (m_scheduledDirections.head() == DirectionForward) {
data.xTranslate += (m_screenArea.width() * 0.25f) * m_timeLine.value();
data.yTranslate += (m_screenArea.height() * 0.10f) * m_timeLine.value();
data.zTranslate += zDistance * m_timeLine.value();
if (distance == 0)
data.opacity *= (1.0 - m_timeLine.value());
}
else
{
} else {
data.xTranslate -= (m_screenArea.width() * 0.25f) * m_timeLine.value();
data.yTranslate -= (m_screenArea.height() * 0.10f) * m_timeLine.value();
data.zTranslate -= zDistance * m_timeLine.value();
}
}
data.opacity *= (0.8 + 0.2 * (1.0 - m_startStopTimeLine.value()));
if( effects->numScreens() > 1)
{
if (effects->numScreens() > 1) {
adjustWindowMultiScreen(w, data);
}
@ -414,8 +375,7 @@ void FlipSwitchEffect::paintScreen( int mask, QRegion region, ScreenPaintData& d
effects->drawWindow(w, winMask, infiniteRegion(), data);
}
if( effects->numScreens() > 1 )
{
if (effects->numScreens() > 1) {
if (shaderManager->isShaderBound()) {
GLShader *shader = shaderManager->pushShader(ShaderManager::GenericShader);
shader->setUniform("projection", origProjection);
@ -432,11 +392,9 @@ void FlipSwitchEffect::paintScreen( int mask, QRegion region, ScreenPaintData& d
}
}
if( m_windowTitle )
{
if (m_windowTitle) {
// Render the caption frame
if( m_animation )
{
if (m_animation) {
m_captionFrame->setCrossFadeProgress(m_timeLine.value());
}
m_captionFrame->render(region, m_startStopTimeLine.value());
@ -446,30 +404,23 @@ void FlipSwitchEffect::paintScreen( int mask, QRegion region, ScreenPaintData& d
void FlipSwitchEffect::postPaintScreen()
{
if( m_active )
{
if( m_start && m_startStopTimeLine.value() == 1.0f )
{
if (m_active) {
if (m_start && m_startStopTimeLine.value() == 1.0f) {
m_start = false;
if( !m_scheduledDirections.isEmpty() )
{
if (!m_scheduledDirections.isEmpty()) {
m_animation = true;
m_timeLine.setProgress(0.0f);
if( m_scheduledDirections.count() == 1 )
{
if (m_scheduledDirections.count() == 1) {
m_currentAnimationShape = TimeLine::EaseOutCurve;
m_timeLine.setCurveShape(m_currentAnimationShape);
}
else
{
} else {
m_currentAnimationShape = TimeLine::LinearCurve;
m_timeLine.setCurveShape(m_currentAnimationShape);
}
}
effects->addRepaintFull();
}
if( m_stop && m_startStopTimeLine.value() == 0.0f )
{
if (m_stop && m_startStopTimeLine.value() == 0.0f) {
m_stop = false;
m_active = false;
m_captionFrame->free();
@ -478,26 +429,19 @@ void FlipSwitchEffect::postPaintScreen()
qDeleteAll(m_windows);
m_windows.clear();
}
if( m_animation && m_timeLine.value() == 1.0f )
{
if (m_animation && m_timeLine.value() == 1.0f) {
m_timeLine.setProgress(0.0f);
m_scheduledDirections.dequeue();
if( m_scheduledDirections.isEmpty() )
{
if (m_scheduledDirections.isEmpty()) {
m_animation = false;
effects->addRepaintFull();
}
else
{
if( m_scheduledDirections.count() == 1 )
{
} else {
if (m_scheduledDirections.count() == 1) {
if (m_stop)
m_currentAnimationShape = TimeLine::LinearCurve;
else
m_currentAnimationShape = TimeLine::EaseOutCurve;
}
else
{
} else {
m_currentAnimationShape = TimeLine::LinearCurve;
}
m_timeLine.setCurveShape(m_currentAnimationShape);
@ -511,10 +455,8 @@ void FlipSwitchEffect::postPaintScreen()
void FlipSwitchEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
{
if( m_active )
{
if( m_windows.contains( w ) )
{
if (m_active) {
if (m_windows.contains(w)) {
data.setTransformed();
data.setTranslucent();
if (!w->isOnCurrentDesktop())
@ -523,9 +465,7 @@ void FlipSwitchEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data
w->enablePainting(EffectWindow::PAINT_DISABLED_BY_MINIMIZE);
if (!w->visibleInClientGroup())
w->enablePainting(EffectWindow::PAINT_DISABLED_BY_CLIENT_GROUP);
}
else
{
} else {
if ((m_start || m_stop) && !w->isDesktop() && w->isOnCurrentDesktop())
data.setTranslucent();
else if (!w->isDesktop())
@ -537,13 +477,10 @@ void FlipSwitchEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data
void FlipSwitchEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{
if( m_active )
{
if( w->isDesktop() )
{
if (m_active) {
if (w->isDesktop()) {
// desktop is painted in normal way
if( m_windows.contains( w ) )
{
if (m_windows.contains(w)) {
m_windows[ w ]->opacity = data.opacity;
m_windows[ w ]->brightness = data.brightness;
m_windows[ w ]->saturation = data.saturation;
@ -551,8 +488,7 @@ void FlipSwitchEffect::paintWindow( EffectWindow* w, int mask, QRegion region, W
effects->paintWindow(w, mask, region, data);
return;
}
if( ( m_start || m_stop ) && !m_windows.contains( w ) )
{
if ((m_start || m_stop) && !m_windows.contains(w)) {
// fade out all windows not in window list
data.opacity *= (1.0 - m_startStopTimeLine.value());
effects->paintWindow(w, mask, region, data);
@ -563,9 +499,7 @@ void FlipSwitchEffect::paintWindow( EffectWindow* w, int mask, QRegion region, W
m_windows[ w ]->saturation = data.saturation;
// it's not nice but it removes flickering
return;
}
else
{
} else {
effects->paintWindow(w, mask, region, data);
}
}
@ -581,8 +515,7 @@ void FlipSwitchEffect::tabBoxAdded( int mode )
if (((mode == TabBoxWindowsMode && m_tabbox) ||
(mode == TabBoxWindowsAlternativeMode && m_tabboxAlternative))
&& (!m_active || (m_active && m_stop))
&& !effects->currentTabBoxWindowList().isEmpty() )
{
&& !effects->currentTabBoxWindowList().isEmpty()) {
setActive(true, TabboxMode);
if (m_active)
effects->refTabBox();
@ -591,8 +524,7 @@ void FlipSwitchEffect::tabBoxAdded( int mode )
void FlipSwitchEffect::tabBoxClosed()
{
if( m_active )
{
if (m_active) {
setActive(false, TabboxMode);
effects->unrefTabBox();
}
@ -600,15 +532,11 @@ void FlipSwitchEffect::tabBoxClosed()
void FlipSwitchEffect::tabBoxUpdated()
{
if( m_active && !m_stop )
{
if( !effects->currentTabBoxWindowList().isEmpty() )
{
if (m_active && !m_stop) {
if (!effects->currentTabBoxWindowList().isEmpty()) {
// determine the switch direction
if( m_selectedWindow != effects->currentTabBoxWindow() )
{
if( m_selectedWindow != NULL )
{
if (m_selectedWindow != effects->currentTabBoxWindow()) {
if (m_selectedWindow != NULL) {
int old_index = effects->currentTabBoxWindowList().indexOf(m_selectedWindow);
int new_index = effects->currentTabBoxWindowList().indexOf(effects->currentTabBoxWindow());
SwitchingDirection new_direction;
@ -617,17 +545,14 @@ void FlipSwitchEffect::tabBoxUpdated()
new_direction = DirectionForward;
if (distance < 0)
new_direction = DirectionBackward;
if( effects->currentTabBoxWindowList().count() == 2 )
{
if (effects->currentTabBoxWindowList().count() == 2) {
new_direction = DirectionForward;
distance = 1;
}
if( distance != 0 )
{
if (distance != 0) {
distance = abs(distance);
int tempDistance = effects->currentTabBoxWindowList().count() - distance;
if( tempDistance < abs( distance ) )
{
if (tempDistance < abs(distance)) {
distance = tempDistance;
if (new_direction == DirectionForward)
new_direction = DirectionBackward;
@ -652,16 +577,14 @@ void FlipSwitchEffect::tabBoxUpdated()
void FlipSwitchEffect::windowAdded(EffectWindow* w)
{
if( m_active && isSelectableWindow( w ) )
{
if (m_active && isSelectableWindow(w)) {
m_windows[ w ] = new ItemInfo();
}
}
void FlipSwitchEffect::windowClosed(EffectWindow* w)
{
if( m_active && m_windows.contains( w ) )
{
if (m_active && m_windows.contains(w)) {
m_windows.remove(w);
}
}
@ -672,29 +595,22 @@ void FlipSwitchEffect::windowClosed( EffectWindow* w )
void FlipSwitchEffect::setActive(bool activate, FlipSwitchMode mode)
{
if( activate )
{
if (activate) {
// effect already active, do some sanity checks
if( m_active )
{
if( m_stop )
{
if( mode != m_mode )
{
if (m_active) {
if (m_stop) {
if (mode != m_mode) {
// only the same mode may reactivate the effect
return;
}
}
else
{
} else {
// active, but not scheduled for closing -> abort
return;
}
}
m_mode = mode;
foreach( EffectWindow* w, effects->stackingOrder() )
{
foreach (EffectWindow * w, effects->stackingOrder()) {
if (isSelectableWindow(w) && !m_windows.contains(w))
m_windows[ w ] = new ItemInfo();
}
@ -708,19 +624,15 @@ void FlipSwitchEffect::setActive( bool activate, FlipSwitchMode mode )
m_activeScreen = effects->activeScreen();
m_screenArea = effects->clientArea(ScreenArea, m_activeScreen, effects->currentDesktop());
if( m_stop )
{
if (m_stop) {
// effect is still closing from last usage
m_stop = false;
}
else
{
} else {
// things to do only when there is no closing animation
m_scheduledDirections.clear();
}
switch( m_mode )
{
switch(m_mode) {
case TabboxMode:
m_selectedWindow = effects->currentTabBoxWindow();
break;
@ -746,35 +658,28 @@ void FlipSwitchEffect::setActive( bool activate, FlipSwitchMode mode )
m_captionFrame->setText(m_selectedWindow->caption());
m_captionFrame->setIcon(m_selectedWindow->icon());
effects->addRepaintFull();
}
else
{
} else {
// only deactivate if mode is current mode
if (mode != m_mode)
return;
if( m_start && m_scheduledDirections.isEmpty() )
{
if (m_start && m_scheduledDirections.isEmpty()) {
m_start = false;
}
m_stop = true;
if( m_animation )
{
if (m_animation) {
m_startStopTimeLine.setCurveShape(TimeLine::EaseOutCurve);
if( m_scheduledDirections.count() == 1 )
{
if (m_scheduledDirections.count() == 1) {
if (m_currentAnimationShape == TimeLine::EaseInOutCurve)
m_currentAnimationShape = TimeLine::EaseInCurve;
else if (m_currentAnimationShape == TimeLine::EaseOutCurve)
m_currentAnimationShape = TimeLine::LinearCurve;
m_timeLine.setCurveShape(m_currentAnimationShape);
}
}
else
} else
m_startStopTimeLine.setCurveShape(TimeLine::EaseInOutCurve);
if (mode != TabboxMode)
effects->destroyInputWindow(m_input);
if( m_hasKeyboardGrab )
{
if (m_hasKeyboardGrab) {
effects->ungrabKeyboard();
m_hasKeyboardGrab = false;
}
@ -784,42 +689,30 @@ void FlipSwitchEffect::setActive( bool activate, FlipSwitchMode mode )
void FlipSwitchEffect::toggleActiveAllDesktops()
{
if( m_active )
{
if( m_stop )
{
if (m_active) {
if (m_stop) {
// reactivate if stopping
setActive(true, AllDesktopsMode);
}
else
{
} else {
// deactivate if not stopping
setActive(false, AllDesktopsMode);
}
}
else
{
} else {
setActive(true, AllDesktopsMode);
}
}
void FlipSwitchEffect::toggleActiveCurrent()
{
if( m_active )
{
if( m_stop )
{
if (m_active) {
if (m_stop) {
// reactivate if stopping
setActive(true, CurrentDesktopMode);
}
else
{
} else {
// deactivate if not stopping
setActive(false, CurrentDesktopMode);
}
}
else
{
} else {
setActive(true, CurrentDesktopMode);
}
}
@ -852,8 +745,7 @@ bool FlipSwitchEffect::isSelectableWindow( EffectWindow* w ) const
return false;
if (!w->acceptsFocus())
return false;
switch( m_mode )
{
switch(m_mode) {
case TabboxMode:
return effects->currentTabBoxWindowList().contains(w);
case CurrentDesktopMode:
@ -867,13 +759,11 @@ bool FlipSwitchEffect::isSelectableWindow( EffectWindow* w ) const
void FlipSwitchEffect::scheduleAnimation(const SwitchingDirection& direction, int distance)
{
if( m_start )
{
if (m_start) {
// start is still active so change the shape to have a nice transition
m_startStopTimeLine.setCurveShape(TimeLine::EaseInCurve);
}
if( !m_animation && !m_start )
{
if (!m_animation && !m_start) {
m_animation = true;
m_scheduledDirections.enqueue(direction);
distance--;
@ -881,24 +771,20 @@ void FlipSwitchEffect::scheduleAnimation( const SwitchingDirection& direction, i
m_currentAnimationShape = TimeLine::EaseInOutCurve;
m_timeLine.setCurveShape(m_currentAnimationShape);
}
for( int i=0; i<distance; i++ )
{
for (int i = 0; i < distance; i++) {
if (m_scheduledDirections.count() > 1 && m_scheduledDirections.last() != direction)
m_scheduledDirections.pop_back();
else
m_scheduledDirections.enqueue(direction);
if( m_scheduledDirections.count() == m_windows.count() + 1 )
{
if (m_scheduledDirections.count() == m_windows.count() + 1) {
SwitchingDirection temp = m_scheduledDirections.dequeue();
m_scheduledDirections.clear();
m_scheduledDirections.enqueue(temp);
}
}
if( m_scheduledDirections.count() > 1 )
{
if (m_scheduledDirections.count() > 1) {
TimeLine::CurveShape newShape = TimeLine::EaseInOutCurve;
switch( m_currentAnimationShape )
{
switch(m_currentAnimationShape) {
case TimeLine::EaseInOutCurve:
newShape = TimeLine::EaseInCurve;
break;
@ -908,8 +794,7 @@ void FlipSwitchEffect::scheduleAnimation( const SwitchingDirection& direction, i
default:
newShape = m_currentAnimationShape;
}
if( newShape != m_currentAnimationShape )
{
if (newShape != m_currentAnimationShape) {
m_currentAnimationShape = newShape;
m_timeLine.setCurveShape(m_currentAnimationShape);
}
@ -923,25 +808,18 @@ void FlipSwitchEffect::adjustWindowMultiScreen( const KWin::EffectWindow* w, Win
QRect clientRect = effects->clientArea(FullScreenArea, w->screen(), effects->currentDesktop());
QRect rect = effects->clientArea(ScreenArea, m_activeScreen, effects->currentDesktop());
QRect fullRect = effects->clientArea(FullArea, m_activeScreen, effects->currentDesktop());
if( w->screen() == m_activeScreen )
{
if( clientRect.width() != fullRect.width() && clientRect.x() != fullRect.x() )
{
if (w->screen() == m_activeScreen) {
if (clientRect.width() != fullRect.width() && clientRect.x() != fullRect.x()) {
data.xTranslate -= clientRect.x();
}
if( clientRect.height() != fullRect.height() && clientRect.y() != fullRect.y() )
{
if (clientRect.height() != fullRect.height() && clientRect.y() != fullRect.y()) {
data.yTranslate -= clientRect.y();
}
}
else
{
if( clientRect.width() != fullRect.width() && clientRect.x() < rect.x())
{
} else {
if (clientRect.width() != fullRect.width() && clientRect.x() < rect.x()) {
data.xTranslate -= clientRect.width();
}
if( clientRect.height() != fullRect.height() && clientRect.y() < m_screenArea.y() )
{
if (clientRect.height() != fullRect.height() && clientRect.y() < m_screenArea.y()) {
data.yTranslate -= clientRect.height();
}
}
@ -963,90 +841,72 @@ void FlipSwitchEffect::globalShortcutChangedCurrent(QKeySequence shortcut)
void FlipSwitchEffect::grabbedKeyboardEvent(QKeyEvent* e)
{
if( e->type() == QEvent::KeyPress )
{
if (e->type() == QEvent::KeyPress) {
// check for global shortcuts
// HACK: keyboard grab disables the global shortcuts so we have to check for global shortcut (bug 156155)
if( m_mode == CurrentDesktopMode && m_shortcutCurrent.contains( e->key() + e->modifiers() ) )
{
if (m_mode == CurrentDesktopMode && m_shortcutCurrent.contains(e->key() + e->modifiers())) {
toggleActiveCurrent();
return;
}
if( m_mode == AllDesktopsMode && m_shortcutAll.contains( e->key() + e->modifiers() ) )
{
if (m_mode == AllDesktopsMode && m_shortcutAll.contains(e->key() + e->modifiers())) {
toggleActiveAllDesktops();
return;
}
switch( e->key() )
{
switch(e->key()) {
case Qt::Key_Escape:
setActive(false, m_mode);
return;
case Qt::Key_Tab:
{
case Qt::Key_Tab: {
// find next window
if (m_windows.isEmpty())
return; // sanity check
bool found = false;
for( int i=effects->stackingOrder().indexOf( m_selectedWindow)-1; i>=0; i-- )
{
if( isSelectableWindow( effects->stackingOrder().at( i )) )
{
for (int i = effects->stackingOrder().indexOf(m_selectedWindow) - 1; i >= 0; i--) {
if (isSelectableWindow(effects->stackingOrder().at(i))) {
m_selectedWindow = effects->stackingOrder().at(i);
found = true;
break;
}
}
if( !found )
{
for( int i=effects->stackingOrder().count()-1; i>effects->stackingOrder().indexOf( m_selectedWindow); i-- )
{
if( isSelectableWindow( effects->stackingOrder().at( i )) )
{
if (!found) {
for (int i = effects->stackingOrder().count() - 1; i > effects->stackingOrder().indexOf(m_selectedWindow); i--) {
if (isSelectableWindow(effects->stackingOrder().at(i))) {
m_selectedWindow = effects->stackingOrder().at(i);
found = true;
break;
}
}
}
if( found )
{
if (found) {
m_captionFrame->setText(m_selectedWindow->caption());
m_captionFrame->setIcon(m_selectedWindow->icon());
scheduleAnimation(DirectionForward);
}
break;
}
case Qt::Key_Backtab:
{
case Qt::Key_Backtab: {
// find previous window
if (m_windows.isEmpty())
return; // sanity check
bool found = false;
for( int i=effects->stackingOrder().indexOf( m_selectedWindow)+1; i<effects->stackingOrder().count(); i++ )
{
if( isSelectableWindow( effects->stackingOrder().at( i )) )
{
for (int i = effects->stackingOrder().indexOf(m_selectedWindow) + 1; i < effects->stackingOrder().count(); i++) {
if (isSelectableWindow(effects->stackingOrder().at(i))) {
m_selectedWindow = effects->stackingOrder().at(i);
found = true;
break;
}
}
if( !found )
{
for( int i=0; i<effects->stackingOrder().indexOf( m_selectedWindow); i++ )
{
if( isSelectableWindow( effects->stackingOrder().at( i )) )
{
if (!found) {
for (int i = 0; i < effects->stackingOrder().indexOf(m_selectedWindow); i++) {
if (isSelectableWindow(effects->stackingOrder().at(i))) {
m_selectedWindow = effects->stackingOrder().at(i);
found = true;
break;
}
}
}
if( found )
{
if (found) {
m_captionFrame->setText(m_selectedWindow->caption());
m_captionFrame->setIcon(m_selectedWindow->icon());
scheduleAnimation(DirectionBackward);

View File

@ -61,13 +61,11 @@ class FlipSwitchEffect
private:
class ItemInfo;
enum SwitchingDirection
{
enum SwitchingDirection {
DirectionForward,
DirectionBackward
};
enum FlipSwitchMode
{
enum FlipSwitchMode {
TabboxMode,
CurrentDesktopMode,
AllDesktopsMode

View File

@ -62,13 +62,11 @@ void GlideEffect::prePaintScreen( ScreenPrePaintData& data, int time )
void GlideEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
{
InfoHash::iterator info = windows.find(w);
if( info != windows.end() )
{
if (info != windows.end()) {
data.setTransformed();
if (info->added)
info->timeLine.addTime(time);
else if( info->closed )
{
else if (info->closed) {
info->timeLine.removeTime(time);
if (info->deleted)
w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DELETE);
@ -86,16 +84,14 @@ void GlideEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int
void GlideEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{
InfoHash::const_iterator info = windows.constFind(w);
if( info != windows.constEnd() )
{
if (info != windows.constEnd()) {
const double progress = info->timeLine.value();
RotationData rot;
rot.axis = RotationData::XAxis;
rot.angle = angle * (1 - progress);
data.rotation = &rot;
data.opacity *= progress;
switch ( effect )
{
switch(effect) {
default:
case GlideInOut:
if (info->added)
@ -145,18 +141,13 @@ void GlideEffect::glideOut(EffectWindow* w, WindowPaintData& data )
void GlideEffect::postPaintWindow(EffectWindow* w)
{
InfoHash::iterator info = windows.find(w);
if( info != windows.end() )
{
if( info->added && info->timeLine.value() == 1.0 )
{
if (info != windows.end()) {
if (info->added && info->timeLine.value() == 1.0) {
windows.remove(w);
effects->addRepaintFull();
}
else if( info->closed && info->timeLine.value() == 0.0 )
{
} else if (info->closed && info->timeLine.value() == 0.0) {
info->closed = false;
if( info->deleted )
{
if (info->deleted) {
windows.remove(w);
w->unrefWindow();
}

View File

@ -53,8 +53,7 @@ class GlideEffect
InfoHash windows;
float duration;
int angle;
enum EffectStyle
{
enum EffectStyle {
GlideIn = 0,
GlideInOut = 1,
GlideOutIn = 2,
@ -70,8 +69,7 @@ class GlideEffect::WindowInfo
: deleted(false)
, added(false)
, closed(false) { }
~WindowInfo()
{
~WindowInfo() {
}
bool deleted;
bool added;

View File

@ -47,15 +47,16 @@ HighlightWindowEffect::~HighlightWindowEffect()
}
static bool isInitiallyHidden(EffectWindow* w)
{ // Is the window initially hidden until it is highlighted?
{
// Is the window initially hidden until it is highlighted?
return !w->visibleInClientGroup() || !w->isOnCurrentDesktop();
}
void HighlightWindowEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
{
// Calculate window opacities
if( !m_highlightedWindows.isEmpty() )
{ // Initial fade out and changing highlight animation
if (!m_highlightedWindows.isEmpty()) {
// Initial fade out and changing highlight animation
double oldOpacity = m_windowOpacity[w];
if (m_highlightedWindows.contains(w))
m_windowOpacity[w] = qMin(1.0, m_windowOpacity[w] + time / m_fadeDuration);
@ -67,9 +68,8 @@ void HighlightWindowEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData&
data.setTranslucent();
if (oldOpacity != m_windowOpacity[w])
w->addRepaintFull();
}
else if( m_finishing && m_windowOpacity.contains( w ))
{ // Final fading back in animation
} else if (m_finishing && m_windowOpacity.contains(w)) {
// Final fading back in animation
double oldOpacity = m_windowOpacity[w];
if (isInitiallyHidden(w))
m_windowOpacity[w] = qMax(0.0, m_windowOpacity[w] - time / m_fadeDuration);
@ -86,8 +86,7 @@ void HighlightWindowEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData&
}
// Show tabbed windows and windows on other desktops if highlighted
if( m_windowOpacity.contains( w ) && m_windowOpacity[w] != 0.0 )
{
if (m_windowOpacity.contains(w) && m_windowOpacity[w] != 0.0) {
if (!w->visibleInClientGroup())
w->enablePainting(EffectWindow::PAINT_DISABLED_BY_CLIENT_GROUP);
if (!w->isOnCurrentDesktop())
@ -106,8 +105,8 @@ void HighlightWindowEffect::paintWindow( EffectWindow* w, int mask, QRegion regi
void HighlightWindowEffect::windowAdded(EffectWindow* w)
{
if( !m_highlightedWindows.isEmpty() )
{ // The effect is activated thus we need to add it to the opacity hash
if (!m_highlightedWindows.isEmpty()) {
// The effect is activated thus we need to add it to the opacity hash
if (w->isNormalWindow() || w->isDialog()) // Only fade out windows
m_windowOpacity[w] = isInitiallyHidden(w) ? 0.0 : 0.15;
else
@ -135,15 +134,15 @@ void HighlightWindowEffect::propertyNotify( EffectWindow* w, long a )
// if the window is null, the property was set on the root window - see events.cpp
QByteArray byteData = w ? w->readProperty(m_atom, m_atom, 32) :
effects->readRootProperty(m_atom, m_atom, 32);
if( byteData.length() < 1 )
{ // Property was removed, clearing highlight
if (byteData.length() < 1) {
// Property was removed, clearing highlight
finishHighlighting();
return;
}
long* data = reinterpret_cast<long*>(byteData.data());
if( !data[0] )
{ // Purposely clearing highlight by issuing a NULL target
if (!data[0]) {
// Purposely clearing highlight by issuing a NULL target
finishHighlighting();
return;
}
@ -153,16 +152,13 @@ void HighlightWindowEffect::propertyNotify( EffectWindow* w, long a )
//foreach ( EffectWindow* e, m_highlightedWindows )
// effects->setElevatedWindow( e, false );
m_highlightedWindows.clear();
for( int i=0; i<length; i++ )
{
for (int i = 0; i < length; i++) {
EffectWindow* foundWin = effects->findWindow(data[i]);
if( !foundWin )
{
if (!foundWin) {
kDebug(1212) << "Invalid window targetted for highlight. Requested:" << data[i];
continue;
}
if( !foundWin->isMinimized() )
{
if (!foundWin->isMinimized()) {
m_highlightedWindows.append(foundWin);
// TODO: We cannot just simply elevate the window as this will elevate it over
// Plasma tooltips and other such windows as well
@ -170,8 +166,7 @@ void HighlightWindowEffect::propertyNotify( EffectWindow* w, long a )
}
found = true;
}
if( !found )
{
if (!found) {
finishHighlighting();
return;
}

View File

@ -78,8 +78,7 @@ bool InvertEffect::loadData()
const QString fragmentshader = KGlobal::dirs()->findResource("data", "kwin/invert.frag");
m_shader = ShaderManager::instance()->loadFragmentShader(ShaderManager::GenericShader, fragmentshader);
if( !m_shader->isValid() )
{
if (!m_shader->isValid()) {
kError(1212) << "The shader failed to load!" << endl;
return false;
}
@ -130,17 +129,14 @@ void InvertEffect::drawWindow( EffectWindow* w, int mask, QRegion region, Window
void InvertEffect::paintEffectFrame(KWin::EffectFrame* frame, QRegion region, double opacity, double frameOpacity)
{
if( m_valid && m_allWindows )
{
if (m_valid && m_allWindows) {
frame->setShader(m_shader);
ShaderManager::instance()->pushShader(m_shader);
m_shader->setUniform("screenTransformation", QMatrix4x4());
m_shader->setUniform("windowTransformation", QMatrix4x4());
effects->paintEffectFrame(frame, region, opacity, frameOpacity);
ShaderManager::instance()->popShader();
}
else
{
} else {
effects->paintEffectFrame(frame, region, opacity, frameOpacity);
}
}

View File

@ -35,13 +35,10 @@ LoginEffect::LoginEffect()
void LoginEffect::prePaintScreen(ScreenPrePaintData& data, int time)
{
if( login_window != NULL )
{
if( progress != 1.0 )
{
if (login_window != NULL) {
if (progress != 1.0) {
progress = qBound(0.0, progress + time / animationTime(2000), 1.0);
if( progress == 1.0 )
{
if (progress == 1.0) {
login_window->unrefWindow();
login_window = NULL;
effects->prePaintScreen(data, time);
@ -54,8 +51,7 @@ void LoginEffect::prePaintScreen( ScreenPrePaintData& data, int time )
void LoginEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
{
if( progress != 1.0 && w == login_window )
{
if (progress != 1.0 && w == login_window) {
w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DELETE);
data.setTranslucent();
}
@ -78,8 +74,7 @@ void LoginEffect::postPaintScreen()
void LoginEffect::windowClosed(EffectWindow* w)
{
if( isLoginSplash( w ))
{
if (isLoginSplash(w)) {
if (login_window)
return; // We already have a window... should never happen.
login_window = w;
@ -90,11 +85,11 @@ void LoginEffect::windowClosed( EffectWindow* w )
}
bool LoginEffect::isLoginSplash(EffectWindow* w)
{ // TODO there should be probably a better way (window type?)
{
// TODO there should be probably a better way (window type?)
// see also fade effect and composite.cpp
if (w->windowClass() == "ksplashx ksplashx"
|| w->windowClass() == "ksplashsimple ksplashsimple" )
{
|| w->windowClass() == "ksplashsimple ksplashsimple") {
return true;
}
return false;

View File

@ -87,23 +87,19 @@ void LogoutEffect::reconfigure( ReconfigureFlags )
void LogoutEffect::prePaintScreen(ScreenPrePaintData& data, int time)
{
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
if( !displayEffect && progress == 0.0 )
{
if( blurTexture )
{
if (!displayEffect && progress == 0.0) {
if (blurTexture) {
delete blurTexture;
blurTexture = NULL;
delete blurTarget;
blurTarget = NULL;
blurSupported = false;
}
}
else if( !blurTexture )
{
} else if (!blurTexture) {
blurSupported = false;
delete blurTarget; // catch as we just tested the texture ;-P
if( effects->compositingType() == OpenGLCompositing && GLTexture::NPOTTextureSupported() && useBlur )
{ // TODO: It seems that it is not possible to create a GLRenderTarget that has
if (effects->compositingType() == OpenGLCompositing && GLTexture::NPOTTextureSupported() && useBlur) {
// TODO: It seems that it is not possible to create a GLRenderTarget that has
// a different size than the display right now. Most likely a KWin core bug.
// Create texture and render target
blurTexture = new GLTexture(displayWidth(), displayHeight());
@ -133,8 +129,7 @@ void LogoutEffect::prePaintScreen( ScreenPrePaintData& data, int time )
}
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
if( blurSupported && progress > 0.0 )
{
if (blurSupported && progress > 0.0) {
data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
}
#endif
@ -144,33 +139,28 @@ void LogoutEffect::prePaintScreen( ScreenPrePaintData& data, int time )
void LogoutEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{
if( progress > 0.0 )
{
if (progress > 0.0) {
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
if( effects->compositingType() == KWin::OpenGLCompositing )
{ // In OpenGL mode we add vignetting and, if supported, a slight blur
if( blurSupported )
{ // When using blur we render everything to an FBO and as such don't do the vignetting
if (effects->compositingType() == KWin::OpenGLCompositing) {
// In OpenGL mode we add vignetting and, if supported, a slight blur
if (blurSupported) {
// When using blur we render everything to an FBO and as such don't do the vignetting
// until after we render the FBO to the screen.
if( w == logoutWindow )
{ // Window is rendered after the FBO
if (w == logoutWindow) {
// Window is rendered after the FBO
windowOpacity = data.opacity;
data.opacity = 0.0; // Cheat, we need the opacity for later but don't want to blur it
}
else
{
if( logoutWindowPassed || ignoredWindows.contains( w ))
{ // Window is rendered after the FBO
} else {
if (logoutWindowPassed || ignoredWindows.contains(w)) {
// Window is rendered after the FBO
windows.append(w);
windowsOpacities[ w ] = data.opacity;
data.opacity = 0.0;
}
else // Window is added to the FBO
} else // Window is added to the FBO
data.saturation *= (1.0 - progress * 0.2);
}
}
else
{ // If we are not blurring then we are not rendering to an FBO
} else {
// If we are not blurring then we are not rendering to an FBO
if (w == logoutWindow)
// This is the logout window don't alter it but render our vignetting now
renderVignetting();
@ -181,10 +171,9 @@ void LogoutEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Windo
}
}
#endif
if( effects->compositingType() == KWin::XRenderCompositing )
{ // Since we can't do vignetting in XRender just do a stronger desaturation and darken
if( w != logoutWindow && !logoutWindowPassed && !ignoredWindows.contains( w ))
{
if (effects->compositingType() == KWin::XRenderCompositing) {
// Since we can't do vignetting in XRender just do a stronger desaturation and darken
if (w != logoutWindow && !logoutWindowPassed && !ignoredWindows.contains(w)) {
data.saturation *= (1.0 - progress * 0.8);
data.brightness *= (1.0 - progress * 0.3);
}
@ -207,18 +196,14 @@ void LogoutEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data
effects->paintScreen(mask, region, data);
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
if( effects->compositingType() == KWin::OpenGLCompositing && progress > 0.0 )
{
if( !blurSupported )
{
if (effects->compositingType() == KWin::OpenGLCompositing && progress > 0.0) {
if (!blurSupported) {
if (!logoutWindowPassed)
// The logout window has been deleted but we still want to fade out the vignetting, thus
// render it on the top of everything if still animating. We don't check if logoutWindow
// is set as it may still be even if it wasn't rendered.
renderVignetting();
}
else
{
} else {
GLRenderTarget* target = effects->popRenderTarget();
assert(target == blurTarget);
Q_UNUSED(target);
@ -270,8 +255,7 @@ void LogoutEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data
//--------------------------
// Render the logout window
if( logoutWindow )
{
if (logoutWindow) {
int winMask = logoutWindow->hasAlpha() ? PAINT_WINDOW_TRANSLUCENT : PAINT_WINDOW_OPAQUE;
WindowPaintData winData(logoutWindow);
winData.opacity = windowOpacity;
@ -279,8 +263,7 @@ void LogoutEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data
}
// Render all windows on top of logout window
foreach( EffectWindow* w, windows )
{
foreach (EffectWindow * w, windows) {
int winMask = w->hasAlpha() ? PAINT_WINDOW_TRANSLUCENT : PAINT_WINDOW_OPAQUE;
WindowPaintData winData(w);
winData.opacity = windowsOpacities[ w ];
@ -311,24 +294,21 @@ void LogoutEffect::postPaintScreen()
void LogoutEffect::windowAdded(EffectWindow* w)
{
if( isLogoutDialog( w ))
{
if (isLogoutDialog(w)) {
logoutWindow = w;
logoutWindowClosed = false; // So we don't blur the window on close
progress = 0.0;
displayEffect = true;
ignoredWindows.clear();
effects->addRepaintFull();
}
else if( canDoPersistent )
} else if (canDoPersistent)
// TODO: Add parent
ignoredWindows.append(w);
}
void LogoutEffect::windowClosed(EffectWindow* w)
{
if( w == logoutWindow )
{
if (w == logoutWindow) {
logoutWindowClosed = true;
if (!canDoPersistent)
displayEffect = false; // Fade back to normal
@ -344,10 +324,10 @@ void LogoutEffect::windowDeleted( EffectWindow* w )
}
bool LogoutEffect::isLogoutDialog(EffectWindow* w)
{ // TODO there should be probably a better way (window type?)
if( w->windowClass() == "ksmserver ksmserver"
&& ( w->windowRole() == "logoutdialog" || w->windowRole() == "logouteffect" ))
{
// TODO there should be probably a better way (window type?)
if (w->windowClass() == "ksmserver ksmserver"
&& (w->windowRole() == "logoutdialog" || w->windowRole() == "logouteffect")) {
return true;
}
return false;
@ -359,8 +339,7 @@ void LogoutEffect::renderVignetting()
glPushAttrib(GL_CURRENT_BIT | GL_ENABLE_BIT | GL_TEXTURE_BIT);
glEnable(GL_BLEND); // If not already (Such as when rendered straight to the screen)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
for( int screen = 0; screen < effects->numScreens(); screen++ )
{
for (int screen = 0; screen < effects->numScreens(); screen++) {
QRect screenGeom = effects->clientArea(ScreenArea, screen, 0);
glScissor(screenGeom.x(), displayHeight() - screenGeom.y() - screenGeom.height(),
screenGeom.width(), screenGeom.height()); // GL coords are flipped
@ -389,8 +368,8 @@ void LogoutEffect::propertyNotify( EffectWindow* w, long a )
return; // Not our atom
QByteArray byteData = effects->readRootProperty(logoutAtom, logoutAtom, 8);
if( byteData.length() < 1 )
{ // Property was deleted
if (byteData.length() < 1) {
// Property was deleted
displayEffect = false;
return;
}

View File

@ -146,21 +146,16 @@ bool LookingGlassEffect::loadData()
void LookingGlassEffect::toggle()
{
if( target_zoom == 1.0f )
{
if (target_zoom == 1.0f) {
target_zoom = 2.0f;
if( !polling )
{
if (!polling) {
polling = true;
effects->startMousePolling();
}
m_enabled = true;
}
else
{
} else {
target_zoom = 1.0f;
if( polling )
{
if (polling) {
polling = false;
effects->stopMousePolling();
}
@ -172,8 +167,7 @@ void LookingGlassEffect::zoomIn()
{
target_zoom = qMin(7.0, target_zoom + 0.5);
m_enabled = true;
if( !polling )
{
if (!polling) {
polling = true;
effects->startMousePolling();
}
@ -183,12 +177,10 @@ void LookingGlassEffect::zoomIn()
void LookingGlassEffect::zoomOut()
{
target_zoom -= 0.5;
if( target_zoom < 1 )
{
if (target_zoom < 1) {
target_zoom = 1;
m_enabled = false;
if( polling )
{
if (polling) {
polling = false;
effects->stopMousePolling();
}
@ -198,8 +190,7 @@ void LookingGlassEffect::zoomOut()
void LookingGlassEffect::prePaintScreen(ScreenPrePaintData& data, int time)
{
if( zoom != target_zoom )
{
if (zoom != target_zoom) {
double diff = time / animationTime(500.0);
if (target_zoom > zoom)
zoom = qMin(zoom * qMax(1.0 + diff, 1.2), target_zoom);
@ -226,8 +217,7 @@ void LookingGlassEffect::prePaintScreen( ScreenPrePaintData& data, int time )
void LookingGlassEffect::mouseChanged(const QPoint& pos, const QPoint& old, Qt::MouseButtons,
Qt::MouseButtons, Qt::KeyboardModifiers, Qt::KeyboardModifiers)
{
if( pos != old && m_enabled )
{
if (pos != old && m_enabled) {
effects->addRepaint(pos.x() - radius, pos.y() - radius, 2 * radius, 2 * radius);
effects->addRepaint(old.x() - radius, old.y() - radius, 2 * radius, 2 * radius);
}

View File

@ -63,16 +63,12 @@ void MagicLampEffect::prePaintScreen( ScreenPrePaintData& data, int time )
QHash< EffectWindow*, TimeLine >::iterator entry = mTimeLineWindows.begin();
bool erase = false;
while( entry != mTimeLineWindows.end() )
{
while (entry != mTimeLineWindows.end()) {
TimeLine &timeline = entry.value();
if( entry.key()->isMinimized() )
{
if (entry.key()->isMinimized()) {
timeline.addTime(time);
erase = (timeline.progress() >= 1.0f);
}
else
{
} else {
timeline.removeTime(time);
erase = (timeline.progress() <= 0.0f);
}
@ -95,8 +91,7 @@ void MagicLampEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data,
{
// Schedule window for transformation if the animation is still in
// progress
if( mTimeLineWindows.contains( w ))
{
if (mTimeLineWindows.contains(w)) {
// We'll transform this window
data.setTransformed();
data.quads = data.quads.makeGrid(40);
@ -108,8 +103,7 @@ void MagicLampEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data,
void MagicLampEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{
if( mTimeLineWindows.contains( w ))
{
if (mTimeLineWindows.contains(w)) {
// 0 = not minimized, 1 = fully minimized
float progress = mTimeLineWindows[w].value();
@ -118,39 +112,33 @@ void MagicLampEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Wi
QRect area = effects->clientArea(ScreenArea, w);
IconPosition position = Top;
// If there's no icon geometry, minimize to the center of the screen
if( !icon.isValid() )
{
if (!icon.isValid()) {
QRect extG = geo.adjusted(mShadowOffset[0], mShadowOffset[1], mShadowOffset[2], mShadowOffset[3]);
QPoint pt = QCursor::pos();
// focussing inside the window is no good, leads to ugly artefacts, find nearest border
if (extG.contains(pt))
{
if (extG.contains(pt)) {
const int d[2][2] = { {pt.x() - extG.x(), extG.right() - pt.x()},
{pt.y() - extG.y(), extG.bottom() - pt.y()} };
{pt.y() - extG.y(), extG.bottom() - pt.y()}
};
int di = d[1][0];
position = Top;
if (d[0][0] < di)
{
if (d[0][0] < di) {
di = d[0][0];
position = Left;
}
if (d[1][1] < di)
{
if (d[1][1] < di) {
di = d[1][1];
position = Bottom;
}
if (d[0][1] < di)
position = Right;
switch (position)
{
switch(position) {
case Top: pt.setY(extG.y()); break;
case Left: pt.setX(extG.x()); break;
case Bottom: pt.setY(extG.bottom()); break;
case Right: pt.setX(extG.right()); break;
}
}
else
{
} else {
if (pt.y() < geo.y())
position = Top;
else if (pt.x() < geo.x())
@ -161,47 +149,37 @@ void MagicLampEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Wi
position = Right;
}
icon = QRect(pt, QSize(0, 0));
}
else
{
} else {
// Assumption: there is a panel containing the icon position
EffectWindow* panel = NULL;
foreach( EffectWindow* window, effects->stackingOrder() )
{
foreach (EffectWindow * window, effects->stackingOrder()) {
if (!window->isDock())
continue;
// we have to use intersects as there seems to be a Plasma bug
// the published icon geometry might be bigger than the panel
if( window->geometry().intersects( icon ) )
{
if (window->geometry().intersects(icon)) {
panel = window;
break;
}
}
if( panel )
{
if (panel) {
// Assumption: width of horizonal panel is greater than its height and vice versa
// The panel has to border one screen edge, so get it's screen area
QRect panelScreen = effects->clientArea(ScreenArea, panel);
if( panel->width() >= panel->height() )
{
if (panel->width() >= panel->height()) {
// horizontal panel
if (panel->y() == panelScreen.y())
position = Top;
else
position = Bottom;
}
else
{
} else {
// vertical panel
if (panel->x() == panelScreen.x())
position = Left;
else
position = Right;
}
}
else
{
} else {
// we did not find a panel, so it might be autohidden
QRect iconScreen = effects->clientArea(ScreenArea, icon.topLeft(), effects->currentDesktop());
// as the icon geometry could be overlap a screen edge we use an intersection
@ -210,30 +188,21 @@ void MagicLampEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Wi
// this assumption might be wrong for e.g. task applet being the only applet in panel
// in this case the icon borders two screen edges
// there might be a wrong animation, but not distorted
if( rect.x() == iconScreen.x() )
{
if (rect.x() == iconScreen.x()) {
position = Left;
}
else if( rect.x() + rect.width() == iconScreen.x() + iconScreen.width() )
{
} else if (rect.x() + rect.width() == iconScreen.x() + iconScreen.width()) {
position = Right;
}
else if( rect.y() == iconScreen.y() )
{
} else if (rect.y() == iconScreen.y()) {
position = Top;
}
else
{
} else {
position = Bottom;
}
}
}
WindowQuadList newQuads;
foreach( WindowQuad quad, data.quads ) // krazy:exclude=foreach
{
if( position == Top || position == Bottom )
{
foreach (WindowQuad quad, data.quads) { // krazy:exclude=foreach
if (position == Top || position == Bottom) {
// quadFactor defines how fast a quad is vertically moved: y coordinates near to window top are slowed down
// it is used as quadFactor^3/windowHeight^3
// quadFactor is the y position of the quad but is changed towards becomming the window height
@ -246,8 +215,7 @@ void MagicLampEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Wi
// factor is the current moved y value diveded by the distance between icon and window
float topProgress;
float bottomProgress;
if( position == Bottom )
{
if (position == Bottom) {
quadFactor = quad[0].y() + (geo.height() - quad[0].y()) * progress;
yOffsetTop = (icon.y() + quad[0].y() - geo.y()) * progress *
((quadFactor * quadFactor * quadFactor) / (geo.height() * geo.height() * geo.height()));
@ -256,9 +224,7 @@ void MagicLampEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Wi
((quadFactor * quadFactor * quadFactor) / (geo.height() * geo.height() * geo.height()));
topProgress = qMin(yOffsetTop / (icon.y() + icon.height() - geo.y() - (float)(quad[0].y() / geo.height() * geo.height())), 1.0f);
bottomProgress = qMin(yOffsetBottom / (icon.y() + icon.height() - geo.y() - (float)(quad[2].y() / geo.height() * geo.height())), 1.0f);
}
else
{
} else {
quadFactor = geo.height() - quad[0].y() + (quad[0].y()) * progress;
yOffsetTop = (geo.y() - icon.height() + geo.height() + quad[0].y() - icon.y()) * progress *
((quadFactor * quadFactor * quadFactor) / (geo.height() * geo.height() * geo.height()));
@ -270,8 +236,7 @@ void MagicLampEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Wi
bottomProgress = qMin(yOffsetBottom / (geo.y() - icon.height() + geo.height() - icon.y() -
(float)((geo.height() - quad[2].y()) / geo.height() * geo.height())), 1.0f);
}
if( position == Top )
{
if (position == Top) {
yOffsetTop *= -1;
yOffsetBottom *= -1;
}
@ -290,16 +255,13 @@ void MagicLampEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Wi
quad[1].setY(quad[1].y() + yOffsetTop);
quad[2].setY(quad[2].y() + yOffsetBottom);
quad[3].setY(quad[3].y() + yOffsetBottom);
}
else
{
} else {
float quadFactor;
float xOffsetLeft;
float xOffsetRight;
float leftProgress;
float rightProgress;
if( position == Right )
{
if (position == Right) {
quadFactor = quad[0].x() + (geo.width() - quad[0].x()) * progress;
xOffsetLeft = (icon.x() + quad[0].x() - geo.x()) * progress *
((quadFactor * quadFactor * quadFactor) / (geo.width() * geo.width() * geo.width()));
@ -308,9 +270,7 @@ void MagicLampEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Wi
((quadFactor * quadFactor * quadFactor) / (geo.width() * geo.width() * geo.width()));
leftProgress = qMin(xOffsetLeft / (icon.x() + icon.width() - geo.x() - (float)(quad[0].x() / geo.width() * geo.width())), 1.0f);
rightProgress = qMin(xOffsetRight / (icon.x() + icon.width() - geo.x() - (float)(quad[1].x() / geo.width() * geo.width())), 1.0f);
}
else
{
} else {
quadFactor = geo.width() - quad[0].x() + (quad[0].x()) * progress;
xOffsetLeft = (geo.x() - icon.width() + geo.width() + quad[0].x() - icon.x()) * progress *
((quadFactor * quadFactor * quadFactor) / (geo.width() * geo.width() * geo.width()));
@ -322,8 +282,7 @@ void MagicLampEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Wi
rightProgress = qMin(xOffsetRight / (geo.x() - icon.width() + geo.width() - icon.x() -
(float)((geo.width() - quad[1].x()) / geo.width() * geo.width())), 1.0f);
}
if( position == Left )
{
if (position == Left) {
xOffsetLeft *= -1;
xOffsetRight *= -1;
}

View File

@ -50,8 +50,7 @@ class MagicLampEffect
int mAnimationDuration;
int mShadowOffset[4];
enum IconPosition
{
enum IconPosition {
Top,
Bottom,
Left,

View File

@ -64,8 +64,7 @@ void MagnifierEffect::reconfigure( ReconfigureFlags )
void MagnifierEffect::prePaintScreen(ScreenPrePaintData& data, int time)
{
if( zoom != target_zoom )
{
if (zoom != target_zoom) {
double diff = time / animationTime(500.0);
if (target_zoom > zoom)
zoom = qMin(zoom * qMax(1 + diff, 1.2), target_zoom);
@ -81,8 +80,8 @@ void MagnifierEffect::paintScreen( int mask, QRegion region, ScreenPaintData& da
{
ScreenPaintData data2 = data;
effects->paintScreen(mask, region, data); // paint normal screen
if( zoom != 1.0 )
{ // paint magnifier
if (zoom != 1.0) {
// paint magnifier
QRect area = magnifierArea();
PaintClipper::push(area); // don't allow any painting outside of the area
mask |= PAINT_SCREEN_TRANSFORMED;
@ -139,8 +138,7 @@ void MagnifierEffect::paintScreen( int mask, QRegion region, ScreenPaintData& da
void MagnifierEffect::postPaintScreen()
{
if( zoom != target_zoom )
{
if (zoom != target_zoom) {
QRect framedarea = magnifierArea().adjusted(-FRAME_WIDTH, -FRAME_WIDTH, FRAME_WIDTH, FRAME_WIDTH);
effects->addRepaint(framedarea);
}
@ -156,8 +154,7 @@ QRect MagnifierEffect::magnifierArea( QPoint pos ) const
void MagnifierEffect::zoomIn()
{
target_zoom *= 1.2;
if( !polling )
{
if (!polling) {
polling = true;
effects->startMousePolling();
}
@ -167,11 +164,9 @@ void MagnifierEffect::zoomIn()
void MagnifierEffect::zoomOut()
{
target_zoom /= 1.2;
if( target_zoom < 1 )
{
if (target_zoom < 1) {
target_zoom = 1;
if( polling )
{
if (polling) {
polling = false;
effects->stopMousePolling();
}
@ -181,20 +176,15 @@ void MagnifierEffect::zoomOut()
void MagnifierEffect::toggle()
{
if( target_zoom == 1.0 )
{
if (target_zoom == 1.0) {
target_zoom = 2;
if( !polling )
{
if (!polling) {
polling = true;
effects->startMousePolling();
}
}
else
{
} else {
target_zoom = 1;
if( polling )
{
if (polling) {
polling = false;
effects->stopMousePolling();
}

View File

@ -36,16 +36,12 @@ void MinimizeAnimationEffect::prePaintScreen( ScreenPrePaintData& data, int time
QHash< EffectWindow*, TimeLine >::iterator entry = mTimeLineWindows.begin();
bool erase = false;
while( entry != mTimeLineWindows.end() )
{
while (entry != mTimeLineWindows.end()) {
TimeLine &timeline = entry.value();
if( entry.key()->isMinimized() )
{
if (entry.key()->isMinimized()) {
timeline.addTime(time);
erase = (timeline.progress() >= 1.0f);
}
else
{
} else {
timeline.removeTime(time);
erase = (timeline.progress() <= 0.0f);
}
@ -68,8 +64,7 @@ void MinimizeAnimationEffect::prePaintWindow( EffectWindow* w, WindowPrePaintDat
{
// Schedule window for transformation if the animation is still in
// progress
if( mTimeLineWindows.contains( w ) )
{
if (mTimeLineWindows.contains(w)) {
// We'll transform this window
data.setTransformed();
w->enablePainting(EffectWindow::PAINT_DISABLED_BY_MINIMIZE);
@ -81,8 +76,7 @@ void MinimizeAnimationEffect::prePaintWindow( EffectWindow* w, WindowPrePaintDat
void MinimizeAnimationEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{
QHash< EffectWindow*, TimeLine >::const_iterator entry = mTimeLineWindows.constFind(w);
if( entry != mTimeLineWindows.constEnd() )
{
if (entry != mTimeLineWindows.constEnd()) {
// 0 = not minimized, 1 = fully minimized
double progress = entry->value();

View File

@ -121,23 +121,19 @@ void MouseMarkEffect::mouseChanged( const QPoint& pos, const QPoint&,
Qt::MouseButtons, Qt::MouseButtons,
Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers)
{
if( modifiers == ( Qt::META | Qt::SHIFT | Qt::CTRL )) // start/finish arrow
{
if( arrow_start != NULL_POINT )
{
if (modifiers == (Qt::META | Qt::SHIFT | Qt::CTRL)) { // start/finish arrow
if (arrow_start != NULL_POINT) {
marks.append(createArrow(arrow_start, pos));
arrow_start = NULL_POINT;
effects->addRepaintFull();
return;
}
else
} else
arrow_start = pos;
}
if (arrow_start != NULL_POINT)
return;
// TODO the shortcuts now trigger this right before they're activated
if( modifiers == ( Qt::META | Qt::SHIFT )) // activated
{
if (modifiers == (Qt::META | Qt::SHIFT)) { // activated
if (drawing.isEmpty())
drawing.append(pos);
if (drawing.last() == pos)
@ -148,9 +144,7 @@ void MouseMarkEffect::mouseChanged( const QPoint& pos, const QPoint&,
qMax(pos.x(), pos2.x()), qMax(pos.y(), pos2.y()));
repaint.adjust(-width, -width, width, width);
effects->addRepaint(repaint);
}
else if( !drawing.isEmpty())
{
} else if (!drawing.isEmpty()) {
marks.append(drawing);
drawing.clear();
}
@ -165,17 +159,12 @@ void MouseMarkEffect::clear()
void MouseMarkEffect::clearLast()
{
if( arrow_start != NULL_POINT )
{
if (arrow_start != NULL_POINT) {
arrow_start = NULL_POINT;
}
else if( !drawing.isEmpty())
{
} else if (!drawing.isEmpty()) {
drawing.clear();
effects->addRepaintFull();
}
else if( !marks.isEmpty())
{
} else if (!marks.isEmpty()) {
marks.pop_back();
effects->addRepaintFull();
}

File diff suppressed because it is too large Load Diff

View File

@ -67,8 +67,7 @@ class PresentWindowsEffect
Q_OBJECT
private:
// Structures
struct WindowData
{
struct WindowData {
bool visible;
bool deleted;
bool referenced;
@ -80,8 +79,7 @@ class PresentWindowsEffect
EffectFrame* iconFrame;
};
typedef QHash<EffectWindow*, WindowData> DataHash;
struct GridSize
{
struct GridSize {
int columns;
int rows;
};
@ -121,16 +119,14 @@ class PresentWindowsEffect
virtual void propertyNotify(EffectWindow* w, long atom);
enum { LayoutNatural, LayoutRegularGrid, LayoutFlexibleGrid }; // Layout modes
enum PresentWindowsMode
{
enum PresentWindowsMode {
ModeAllDesktops, // Shows windows of all desktops
ModeCurrentDesktop, // Shows windows on current desktop
ModeSelectedDesktop, // Shows windows of selected desktop via property (m_desktop)
ModeWindowGroup, // Shows windows selected via property
ModeWindowClass // Shows all windows of same class as selected class
};
enum WindowMouseAction
{
enum WindowMouseAction {
WindowNoAction = 0, // Nothing
WindowActivateAction = 1, // Activates the window and deactivates the effect
WindowExitAction = 2, // Deactivates the effect without activating new window
@ -139,8 +135,7 @@ class PresentWindowsEffect
WindowMinimizeAction = 5, // Minimize the window
WindowCloseAction = 6 // Closes the window
};
enum DesktopMouseAction
{
enum DesktopMouseAction {
DesktopNoAction = 0, // nothing
DesktopActivateAction = 1, // Activates the window and deactivates the effect
DesktopExitAction = 2, // Deactivates the effect without activating new window
@ -149,8 +144,14 @@ class PresentWindowsEffect
public slots:
void setActive(bool active, bool closingTab = false); // HACK: closingTab shouldn't be needed
void toggleActive() { m_mode = ModeCurrentDesktop; setActive( !m_activated ); }
void toggleActiveAllDesktops() { m_mode = ModeAllDesktops; setActive( !m_activated ); }
void toggleActive() {
m_mode = ModeCurrentDesktop;
setActive(!m_activated);
}
void toggleActiveAllDesktops() {
m_mode = ModeAllDesktops;
setActive(!m_activated);
}
void toggleActiveClass();
// slots for global shortcut changed
@ -175,12 +176,15 @@ class PresentWindowsEffect
WindowMotionManager& motionManager);
// Helper functions for window rearranging
inline double aspectRatio( EffectWindow *w )
{ return w->width() / double( w->height() ); }
inline int widthForHeight( EffectWindow *w, int height )
{ return int(( height / double( w->height() )) * w->width() ); }
inline int heightForWidth( EffectWindow *w, int width )
{ return int(( width / double( w->width() )) * w->height() ); }
inline double aspectRatio(EffectWindow *w) {
return w->width() / double(w->height());
}
inline int widthForHeight(EffectWindow *w, int height) {
return int((height / double(w->height())) * w->width());
}
inline int heightForWidth(EffectWindow *w, int width) {
return int((width / double(w->width())) * w->height());
}
void assignSlots(EffectWindowList windowlist, const QRect &area, int columns, int rows);
void getBestAssignments(EffectWindowList windowlist);
bool isOverlappingAny(EffectWindow *w, const QHash<EffectWindow*, QRect> &targets, const QRegion &border);

View File

@ -48,8 +48,7 @@ ResizeEffect::~ResizeEffect()
void ResizeEffect::prePaintScreen(ScreenPrePaintData& data, int time)
{
if( m_active )
{
if (m_active) {
data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
}
effects->prePaintScreen(data, time);
@ -64,10 +63,8 @@ void ResizeEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, in
void ResizeEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{
if( m_active && w == m_resizeWindow )
{
if( m_features & TextureScale )
{
if (m_active && w == m_resizeWindow) {
if (m_features & TextureScale) {
data.xTranslate += m_currentGeometry.x() - m_originalGeometry.x();
data.xScale *= m_currentGeometry.width();
data.xScale /= m_originalGeometry.width();
@ -77,8 +74,7 @@ void ResizeEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Windo
}
effects->paintWindow(w, mask, region, data);
if( m_features & Outline )
{
if (m_features & Outline) {
QRegion intersection = m_originalGeometry.intersected(m_currentGeometry);
QRegion paintRegion = QRegion(m_originalGeometry).united(m_currentGeometry).subtracted(intersection);
float alpha = 0.8f;
@ -122,8 +118,7 @@ void ResizeEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Windo
#endif
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
if( effects->compositingType() == XRenderCompositing)
{
if (effects->compositingType() == XRenderCompositing) {
XRenderColor col;
col.alpha = int(alpha * 0xffff);
col.red = int(alpha * 0xffff * color.red() / 255);
@ -135,8 +130,7 @@ void ResizeEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Windo
}
#endif
}
}
else
} else
effects->paintWindow(w, mask, region, data);
}
@ -152,21 +146,18 @@ void ResizeEffect::reconfigure( ReconfigureFlags )
void ResizeEffect::windowUserMovedResized(EffectWindow* w, bool first, bool last)
{
if( first && last )
{
if (first && last) {
// not interested in maximized
return;
}
if( first && w->isUserResize() && !w->isUserMove() )
{
if (first && w->isUserResize() && !w->isUserMove()) {
m_active = true;
m_resizeWindow = w;
m_originalGeometry = w->geometry();
m_currentGeometry = w->geometry();
w->addRepaintFull();
}
if( m_active && w == m_resizeWindow && last )
{
if (m_active && w == m_resizeWindow && last) {
m_active = false;
m_resizeWindow = NULL;
effects->addRepaintFull();
@ -175,8 +166,7 @@ void ResizeEffect::windowUserMovedResized( EffectWindow* w, bool first, bool las
void ResizeEffect::windowMoveResizeGeometryUpdate(EffectWindow* c, const QRect& geometry)
{
if( m_active && c == m_resizeWindow )
{
if (m_active && c == m_resizeWindow) {
m_currentGeometry = geometry;
effects->addRepaintFull();
}

View File

@ -32,7 +32,9 @@ class ResizeEffect
public:
ResizeEffect();
~ResizeEffect();
virtual inline bool provides( Effect::Feature ef ) { return ef == Effect::Resize; }
virtual inline bool provides(Effect::Feature ef) {
return ef == Effect::Resize;
}
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);

View File

@ -34,8 +34,7 @@ void ScaleInEffect::prePaintScreen( ScreenPrePaintData& data, int time )
void ScaleInEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
{
if( mTimeLineWindows.contains( w ) )
{
if (mTimeLineWindows.contains(w)) {
mTimeLineWindows[ w ].setCurveShape(TimeLine::EaseOutCurve);
mTimeLineWindows[ w ].addTime(time);
if (mTimeLineWindows[ w ].value() < 1)
@ -48,8 +47,7 @@ void ScaleInEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, i
void ScaleInEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{
if( mTimeLineWindows.contains( w ) && isScaleWindow( w ) )
{
if (mTimeLineWindows.contains(w) && isScaleWindow(w)) {
data.opacity *= mTimeLineWindows[ w ].value();
data.xScale *= mTimeLineWindows[ w ].value();
data.yScale *= mTimeLineWindows[ w ].value();
@ -77,8 +75,7 @@ void ScaleInEffect::postPaintWindow( EffectWindow* w )
void ScaleInEffect::windowAdded(EffectWindow* c)
{
if( c->isOnCurrentDesktop())
{
if (c->isOnCurrentDesktop()) {
mTimeLineWindows[ c ].setDuration(animationTime(250));
mTimeLineWindows[ c ].setProgress(0.0);
c->addRepaintFull();

View File

@ -54,12 +54,10 @@ ScreenShotEffect::~ScreenShotEffect()
void ScreenShotEffect::postPaintScreen()
{
effects->postPaintScreen();
if( m_scheduledScreenshot )
{
if (m_scheduledScreenshot) {
int w = displayWidth();
int h = displayHeight();
if( !GLTexture::NPOTTextureSupported() )
{
if (!GLTexture::NPOTTextureSupported()) {
w = nearestPowerOfTwo(w);
h = nearestPowerOfTwo(h);
}
@ -67,35 +65,28 @@ void ScreenShotEffect::postPaintScreen()
offscreenTexture->setFilter(GL_LINEAR);
offscreenTexture->setWrapMode(GL_CLAMP_TO_EDGE);
GLRenderTarget* target = new GLRenderTarget(offscreenTexture);
if( target->valid() )
{
if (target->valid()) {
WindowPaintData d(m_scheduledScreenshot);
double left = 0;
double top = 0;
double right = m_scheduledScreenshot->width();
double bottom = m_scheduledScreenshot->height();
if( m_scheduledScreenshot->hasDecoration() && m_type & INCLUDE_DECORATION )
{
foreach( const WindowQuad& quad, d.quads )
{
if (m_scheduledScreenshot->hasDecoration() && m_type & INCLUDE_DECORATION) {
foreach (const WindowQuad & quad, d.quads) {
// we need this loop to include the decoration padding
left = qMin(left, quad.left());
top = qMin(top, quad.top());
right = qMax(right, quad.right());
bottom = qMax(bottom, quad.bottom());
}
}
else if( m_scheduledScreenshot->hasDecoration() )
{
} else if (m_scheduledScreenshot->hasDecoration()) {
WindowQuadList newQuads;
left = m_scheduledScreenshot->width();
top = m_scheduledScreenshot->height();
right = 0;
bottom = 0;
foreach( const WindowQuad& quad, d.quads )
{
if( quad.type() == WindowQuadContents )
{
foreach (const WindowQuad & quad, d.quads) {
if (quad.type() == WindowQuadContents) {
newQuads << quad;
left = qMin(left, quad.left());
top = qMin(top, quad.top());
@ -121,8 +112,7 @@ void ScreenShotEffect::postPaintScreen()
glReadPixels(0, offscreenTexture->height() - height, width, height, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)img.bits());
effects->popRenderTarget();
ScreenShotEffect::convertFromGLImage(img, width, height);
if( m_type & INCLUDE_CURSOR )
{
if (m_type & INCLUDE_CURSOR) {
grabPointerImage(img, m_scheduledScreenshot->x() + left, m_scheduledScreenshot->y() + top);
}
m_lastScreenshot = QPixmap::fromImage(img);
@ -138,15 +128,12 @@ void ScreenShotEffect::screenshotWindowUnderCursor(int mask)
{
m_type = (ScreenShotType)mask;
const QPoint cursor = effects->cursorPos();
foreach( EffectWindow* w, effects->stackingOrder() )
{
if( w->geometry().contains( cursor ) && w->isOnCurrentDesktop() && !w->isMinimized() )
{
foreach (EffectWindow * w, effects->stackingOrder()) {
if (w->geometry().contains(cursor) && w->isOnCurrentDesktop() && !w->isMinimized()) {
m_scheduledScreenshot = w;
}
}
if( m_scheduledScreenshot )
{
if (m_scheduledScreenshot) {
m_scheduledScreenshot->addRepaintFull();
}
}

View File

@ -33,8 +33,7 @@ class ScreenShotEffect : public QObject, public Effect
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.kwin.Screenshot")
public:
enum ScreenShotType
{
enum ScreenShotType {
INCLUDE_DECORATION = 1 << 0,
INCLUDE_CURSOR = 1 << 1
};

View File

@ -51,8 +51,7 @@ void SheetEffect::reconfigure( ReconfigureFlags )
void SheetEffect::prePaintScreen(ScreenPrePaintData& data, int time)
{
if( !windows.isEmpty() )
{
if (!windows.isEmpty()) {
data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
screenTime = time;
}
@ -62,13 +61,11 @@ void SheetEffect::prePaintScreen( ScreenPrePaintData& data, int time )
void SheetEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
{
InfoMap::iterator info = windows.find(w);
if( info != windows.end() )
{
if (info != windows.end()) {
data.setTransformed();
if (info->added)
info->timeLine.addTime(screenTime);
else if( info->closed )
{
else if (info->closed) {
info->timeLine.removeTime(screenTime);
if (info->deleted)
w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DELETE);
@ -86,8 +83,7 @@ void SheetEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int
void SheetEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{
InfoMap::const_iterator info = windows.constFind(w);
if( info != windows.constEnd() )
{
if (info != windows.constEnd()) {
const double progress = info->timeLine.value();
RotationData rot;
rot.axis = RotationData::XAxis;
@ -103,18 +99,13 @@ void SheetEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Window
void SheetEffect::postPaintWindow(EffectWindow* w)
{
InfoMap::iterator info = windows.find(w);
if( info != windows.end() )
{
if( info->added && info->timeLine.value() == 1.0 )
{
if (info != windows.end()) {
if (info->added && info->timeLine.value() == 1.0) {
windows.remove(w);
effects->addRepaintFull();
}
else if( info->closed && info->timeLine.value() == 0.0 )
{
} else if (info->closed && info->timeLine.value() == 0.0) {
info->closed = false;
if( info->deleted )
{
if (info->deleted) {
windows.remove(w);
w->unrefWindow();
}
@ -140,10 +131,8 @@ void SheetEffect::windowAdded( EffectWindow* w )
info->timeLine.setDuration(duration);
const EffectWindowList stack = effects->stackingOrder();
// find parent
foreach( EffectWindow* window, stack )
{
if( window->findModal() == w )
{
foreach (EffectWindow * window, stack) {
if (window->findModal() == w) {
info->parentY = window->y();
break;
}
@ -169,10 +158,8 @@ void SheetEffect::windowClosed( EffectWindow* w )
bool found = false;
// find parent
const EffectWindowList stack = effects->stackingOrder();
foreach( EffectWindow* window, stack )
{
if( window->findModal() == w )
{
foreach (EffectWindow * window, stack) {
if (window->findModal() == w) {
info->parentY = window->y();
found = true;
break;

View File

@ -59,8 +59,7 @@ class SheetEffect::WindowInfo
: deleted(false)
, added(false)
, closed(false)
, parentY( 0 )
{
, parentY(0) {
}
bool deleted;
bool added;

View File

@ -57,8 +57,7 @@ ShowFpsEffect::ShowFpsEffect()
{
for (int i = 0;
i < NUM_PAINTS;
++i )
{
++i) {
paints[ i ] = 0;
paint_size[ i ] = 0;
}
@ -95,8 +94,7 @@ void ShowFpsEffect::reconfigure( ReconfigureFlags )
textColor = QPalette().color(QPalette::Active, QPalette::WindowText);
textColor.setAlphaF(textAlpha);
switch(textPosition)
{
switch(textPosition) {
case TOP_LEFT:
fpsTextRect = QRect(0, 0, 100, 100);
textAlign = Qt::AlignTop | Qt::AlignLeft;
@ -165,15 +163,13 @@ void ShowFpsEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data
if (fps > MAX_TIME)
fps = MAX_TIME; // keep it the same height
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
if( effects->compositingType() == OpenGLCompositing)
{
if (effects->compositingType() == OpenGLCompositing) {
paintGL(fps);
glFinish(); // make sure all rendering is done
}
#endif
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
if( effects->compositingType() == XRenderCompositing)
{
if (effects->compositingType() == XRenderCompositing) {
paintXrender(fps);
XSync(display(), False); // make sure all rendering is done
}
@ -230,8 +226,7 @@ void ShowFpsEffect::paintGL( int fps )
QVector<float> vertices;
for (int i = 10;
i < MAX_TIME;
i += 10 )
{
i += 10) {
vertices << x << y - i;
vertices << x + FPS_WIDTH << y - i;
}
@ -286,8 +281,7 @@ void ShowFpsEffect::paintXrender( int fps )
col.blue = 0;
for (int i = 10;
i < MAX_TIME;
i += 10 )
{
i += 10) {
XRenderFillRectangle(display(), PictOpSrc, p, &col, 0, MAX_TIME - i, FPS_WIDTH, 1);
}
XRenderComposite(display(), alpha != 1.0 ? PictOpOver : PictOpSrc, p, None,
@ -309,8 +303,7 @@ void ShowFpsEffect::paintFPSGraph(int x, int y)
QList<int> values;
for (int i = 0;
i < NUM_PAINTS;
++i )
{
++i) {
values.append(paints[(i + paints_pos) % NUM_PAINTS ]);
}
paintGraph(x, y, values, lines, true);
@ -336,12 +329,10 @@ void ShowFpsEffect::paintDrawSizeGraph(int x, int y)
QList<int> drawvalues;
for (int i = 0;
i < NUM_PAINTS;
++i )
{
++i) {
int value = paint_size[(i + paints_pos) % NUM_PAINTS ];
int h = 0;
if( value > 0)
{
if (value > 0) {
h = (int)((log10((double)value) - min_pixels_log) * drawscale);
h = qMin(qMax(0, h) + minh, MAX_TIME);
}
@ -353,8 +344,7 @@ void ShowFpsEffect::paintDrawSizeGraph(int x, int y)
void ShowFpsEffect::paintGraph(int x, int y, QList<int> values, QList<int> lines, bool colorize)
{
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
if( effects->compositingType() == OpenGLCompositing)
{
if (effects->compositingType() == OpenGLCompositing) {
QColor color(0, 0, 0);
color.setAlphaF(alpha);
GLVertexBuffer *vbo = GLVertexBuffer::streamingBuffer();
@ -362,8 +352,7 @@ void ShowFpsEffect::paintGraph( int x, int y, QList<int> values, QList<int> line
vbo->setColor(color);
QVector<float> verts;
// First draw the lines
foreach( int h, lines)
{
foreach (int h, lines) {
verts << x << y - h;
verts << x + values.count() << y - h;
}
@ -402,8 +391,7 @@ void ShowFpsEffect::paintGraph( int x, int y, QList<int> values, QList<int> line
}
#endif
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
if( effects->compositingType() == XRenderCompositing)
{
if (effects->compositingType() == XRenderCompositing) {
Pixmap pixmap = XCreatePixmap(display(), rootWindow(), values.count(), MAX_TIME, 32);
XRenderPicture p(pixmap, 32);
XFreePixmap(display(), pixmap);
@ -416,31 +404,26 @@ void ShowFpsEffect::paintGraph( int x, int y, QList<int> values, QList<int> line
// Then the values
col.red = col.green = col.blue = int(alpha * 0x8000); // grey
for( int i = 0; i < values.count(); i++ )
{
for (int i = 0; i < values.count(); i++) {
int value = values[ i ];
if( colorize )
{
if( value <= 10 )
{ // green
if (colorize) {
if (value <= 10) {
// green
col.red = 0;
col.green = int(alpha * 0xffff);
col.blue = 0;
}
else if( value <= 20 )
{ // yellow
} else if (value <= 20) {
// yellow
col.red = int(alpha * 0xffff);
col.green = int(alpha * 0xffff);
col.blue = 0;
}
else if( value <= 50 )
{ // red
} else if (value <= 50) {
// red
col.red = int(alpha * 0xffff);
col.green = 0;
col.blue = 0;
}
else
{ // black
} else {
// black
col.red = 0;
col.green = 0;
col.blue = 0;

View File

@ -41,7 +41,8 @@ namespace KWin
KWIN_EFFECT(showpaint, ShowPaintEffect)
static QColor colors[] = { Qt::red, Qt::green, Qt::blue, Qt::cyan, Qt::magenta,
Qt::yellow, Qt::gray };
Qt::yellow, Qt::gray
};
ShowPaintEffect::ShowPaintEffect()
: color_index(0)

View File

@ -42,16 +42,14 @@ void SlideEffect::reconfigure( ReconfigureFlags )
void SlideEffect::prePaintScreen(ScreenPrePaintData& data, int time)
{
if( slide )
{
if (slide) {
mTimeLine.addTime(time);
// PAINT_SCREEN_BACKGROUND_FIRST is needed because screen will be actually painted more than once,
// so with normal screen painting second screen paint would erase parts of the first paint
if (mTimeLine.value() != 1)
data.mask |= PAINT_SCREEN_TRANSFORMED | PAINT_SCREEN_BACKGROUND_FIRST;
else
{
else {
slide = false;
mTimeLine.setProgress(0);
effects->setActiveFullScreenEffect(NULL);
@ -62,16 +60,13 @@ void SlideEffect::prePaintScreen( ScreenPrePaintData& data, int time )
void SlideEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
{
if( slide )
{
if( w->isOnAllDesktops())
{
if (slide) {
if (w->isOnAllDesktops()) {
if (slide_painting_sticky)
data.setTransformed();
else
w->disablePainting(EffectWindow::PAINT_DISABLED_BY_DESKTOP);
}
else if( w->isOnDesktop( painting_desktop ))
} else if (w->isOnDesktop(painting_desktop))
w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DESKTOP);
else
w->disablePainting(EffectWindow::PAINT_DISABLED_BY_DESKTOP);
@ -81,8 +76,7 @@ void SlideEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int
void SlideEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
{
if( mTimeLine.value() == 0 )
{
if (mTimeLine.value() == 0) {
effects->paintScreen(mask, region, data);
return;
}
@ -96,8 +90,7 @@ void SlideEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
QPoint diffPos = destPos - slide_start_pos;
int w = 0;
int h = 0;
if( effects->optionRollOverDesktops())
{
if (effects->optionRollOverDesktops()) {
w = effects->workspaceWidth();
h = effects->workspaceHeight();
// wrap around if shorter
@ -113,8 +106,7 @@ void SlideEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
QPoint currentPos = slide_start_pos + mTimeLine.value() * diffPos;
QSize displaySize(displayWidth(), displayHeight());
QRegion currentRegion = QRect(currentPos, displaySize);
if( effects->optionRollOverDesktops())
{
if (effects->optionRollOverDesktops()) {
currentRegion |= (currentRegion & QRect(-w, 0, w, h)).translated(w, 0);
currentRegion |= (currentRegion & QRect(0, -h, w, h)).translated(0, h);
currentRegion |= (currentRegion & QRect(w, 0, w, h)).translated(-w, 0);
@ -123,16 +115,13 @@ void SlideEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
bool do_sticky = true;
for (int desktop = 1;
desktop <= effects->numberOfDesktops();
++desktop )
{
++desktop) {
QRect rect = desktopRect(desktop);
if( currentRegion.contains( rect )) // part of the desktop needs painting
{
if (currentRegion.contains(rect)) { // part of the desktop needs painting
painting_desktop = desktop;
slide_painting_sticky = do_sticky;
slide_painting_diff = rect.topLeft() - currentPos;
if( effects->optionRollOverDesktops())
{
if (effects->optionRollOverDesktops()) {
if (slide_painting_diff.x() > displayWidth())
slide_painting_diff.setX(slide_painting_diff.x() - w);
if (slide_painting_diff.x() < -displayWidth())
@ -154,10 +143,9 @@ void SlideEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
void SlideEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{
if( slide )
{ // don't move windows on all desktops (compensate screen transformation)
if( w->isOnAllDesktops()) // TODO also fix 'Workspace::movingClient'
{
if (slide) {
// don't move windows on all desktops (compensate screen transformation)
if (w->isOnAllDesktops()) { // TODO also fix 'Workspace::movingClient'
data.xTranslate -= slide_painting_diff.x();
data.yTranslate -= slide_painting_diff.y();
}
@ -185,13 +173,11 @@ void SlideEffect::desktopChanged( int old )
if (effects->activeFullScreenEffect() && effects->activeFullScreenEffect() != this)
return;
if( slide ) // old slide still in progress
{
if (slide) { // old slide still in progress
QPoint diffPos = desktopRect(old).topLeft() - slide_start_pos;
int w = 0;
int h = 0;
if( effects->optionRollOverDesktops())
{
if (effects->optionRollOverDesktops()) {
w = effects->workspaceWidth();
h = effects->workspaceHeight();
// wrap around if shorter
@ -206,39 +192,33 @@ void SlideEffect::desktopChanged( int old )
}
QPoint currentPos = slide_start_pos + mTimeLine.value() * diffPos;
QRegion currentRegion = QRect(currentPos, QSize(displayWidth(), displayHeight()));
if( effects->optionRollOverDesktops())
{
if (effects->optionRollOverDesktops()) {
currentRegion |= (currentRegion & QRect(-w, 0, w, h)).translated(w, 0);
currentRegion |= (currentRegion & QRect(0, -h, w, h)).translated(0, h);
currentRegion |= (currentRegion & QRect(w, 0, w, h)).translated(-w, 0);
currentRegion |= (currentRegion & QRect(0, h, w, h)).translated(0, -h);
}
QRect rect = desktopRect(effects->currentDesktop());
if( currentRegion.contains( rect ))
{ // current position is in new current desktop (e.g. quickly changing back),
if (currentRegion.contains(rect)) {
// current position is in new current desktop (e.g. quickly changing back),
// don't do full progress
if (abs(currentPos.x() - rect.x()) > abs(currentPos.y() - rect.y()))
mTimeLine.setProgress(1 - abs(currentPos.x() - rect.x()) / double(displayWidth()));
else
mTimeLine.setProgress(1 - abs(currentPos.y() - rect.y()) / double(displayHeight()));
}
else // current position is not on current desktop, do full progress
} else // current position is not on current desktop, do full progress
mTimeLine.setProgress(0);
diffPos = rect.topLeft() - currentPos;
if( mTimeLine.value() <= 0 )
{
if (mTimeLine.value() <= 0) {
// Compute starting point for this new move (given current and end positions)
slide_start_pos = rect.topLeft() - diffPos * 1 / (1 - mTimeLine.value());
}
else
{ // at the end, stop
} else {
// at the end, stop
slide = false;
mTimeLine.setProgress(0);
effects->setActiveFullScreenEffect(NULL);
}
}
else
{
} else {
if (effects->activeFullScreenEffect() && effects->activeFullScreenEffect() != this)
return;
mTimeLine.setProgress(0);

View File

@ -42,20 +42,17 @@ static inline bool windowsShareDesktop( EffectWindow *w1, EffectWindow *w2 )
void SlideBackEffect::windowActivated(EffectWindow* w)
{
if( w == NULL || w->keepAbove()) // plasma popups, yakuake etc...
{
if (w == NULL || w->keepAbove()) { // plasma popups, yakuake etc...
return;
}
if( disabled || effects->activeFullScreenEffect() ) // TabBox or PresentWindows/Cube in progress
{
if (disabled || effects->activeFullScreenEffect()) { // TabBox or PresentWindows/Cube in progress
updateStackingOrder();
disabled = false;
return;
}
if( !isWindowUsable( w ) || !stackingOrderChanged() || !isWindowOnTop( w ) ) // Focus changed but stacking still the same
{
if (!isWindowUsable(w) || !stackingOrderChanged() || !isWindowOnTop(w)) { // Focus changed but stacking still the same
updateStackingOrder();
return;
}
@ -66,36 +63,27 @@ void SlideBackEffect::windowActivated( EffectWindow* w )
return;
}
if( clientItemShown == w )
{
if (clientItemShown == w) {
clientItemShown = NULL;
updateStackingOrder();
return;
}
if( clientItemHidden == w )
{
if (clientItemHidden == w) {
clientItemHidden = NULL;
updateStackingOrder();
return;
}
// Determine all windows on top of the activated one
bool currentFound = false;
foreach( EffectWindow *tmp, oldStackingOrder )
{
if( !currentFound )
{
if( tmp == w )
{
foreach (EffectWindow * tmp, oldStackingOrder) {
if (!currentFound) {
if (tmp == w) {
currentFound = true;
}
}
else
{
if( isWindowUsable( tmp ) && windowsShareDesktop( tmp, w ) )
{
} else {
if (isWindowUsable(tmp) && windowsShareDesktop(tmp, w)) {
// Do we have to move it?
if( intersects( w, tmp->geometry() ) )
{
if (intersects(w, tmp->geometry())) {
QRect slideRect;
slideRect = getSlideDestination(getModalGroupGeometry(w), tmp->geometry());
effects->setElevatedWindow(tmp, true);
@ -104,14 +92,10 @@ void SlideBackEffect::windowActivated( EffectWindow* w )
motionManager.moveWindow(tmp, slideRect);
destinationList.insert(tmp, slideRect);
coveringWindows.append(tmp);
}
else
{
} else {
//Does it intersect with a moved (elevated) window and do we have to elevate it too?
foreach( EffectWindow *elevatedWindow, elevatedList )
{
if( tmp->geometry().intersects( elevatedWindow->geometry() ) )
{
foreach (EffectWindow * elevatedWindow, elevatedList) {
if (tmp->geometry().intersects(elevatedWindow->geometry())) {
effects->setElevatedWindow(tmp, true);
elevatedList.append(tmp);
break;
@ -120,8 +104,7 @@ void SlideBackEffect::windowActivated( EffectWindow* w )
}
}
if( tmp->isDock() || tmp->keepAbove() )
{
if (tmp->isDock() || tmp->keepAbove()) {
effects->setElevatedWindow(tmp, true);
elevatedList.append(tmp);
}
@ -129,10 +112,8 @@ void SlideBackEffect::windowActivated( EffectWindow* w )
}
// If a window is minimized it could happen that the panels stay elevated without any windows sliding.
// clear all elevation settings
if( !motionManager.managingWindows() )
{
foreach( EffectWindow* tmp, elevatedList )
{
if (!motionManager.managingWindows()) {
foreach (EffectWindow * tmp, elevatedList) {
effects->setElevatedWindow(tmp, false);
}
}
@ -148,23 +129,18 @@ QRect SlideBackEffect::getSlideDestination( const QRect &windowUnderGeometry, co
int downSlide = windowUnderGeometry.bottom() - windowOverGeometry.top() + 20;
int horizSlide = leftSlide;
if( qAbs( horizSlide ) > qAbs( rightSlide ) )
{
if (qAbs(horizSlide) > qAbs(rightSlide)) {
horizSlide = rightSlide;
}
int vertSlide = upSlide;
if( qAbs( vertSlide ) > qAbs( downSlide ) )
{
if (qAbs(vertSlide) > qAbs(downSlide)) {
vertSlide = downSlide;
}
QRect slideRect = windowOverGeometry;
if( qAbs( horizSlide ) < qAbs( vertSlide ) )
{
if (qAbs(horizSlide) < qAbs(vertSlide)) {
slideRect.moveLeft(slideRect.x() + horizSlide);
}
else
{
} else {
slideRect.moveTop(slideRect.y() + vertSlide);
}
return slideRect;
@ -178,8 +154,7 @@ void SlideBackEffect::updateStackingOrder()
void SlideBackEffect::prePaintScreen(ScreenPrePaintData &data, int time)
{
if( motionManager.managingWindows() )
{
if (motionManager.managingWindows()) {
motionManager.calculate(time);
data.mask |= Effect::PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
}
@ -188,8 +163,7 @@ void SlideBackEffect::prePaintScreen( ScreenPrePaintData &data, int time )
void SlideBackEffect::postPaintScreen()
{
if( motionManager.areWindowsMoving() )
{
if (motionManager.areWindowsMoving()) {
effects->addRepaintFull();
}
effects->postPaintScreen();
@ -197,8 +171,7 @@ void SlideBackEffect::postPaintScreen()
void SlideBackEffect::prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time)
{
if( motionManager.isManaging( w ) )
{
if (motionManager.isManaging(w)) {
data.setTransformed();
}
@ -207,15 +180,12 @@ void SlideBackEffect::prePaintWindow( EffectWindow *w, WindowPrePaintData &data,
void SlideBackEffect::paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data)
{
if( stackingOrderChanged() && ( w == newTopWindow() ) && !disabled )
{
if (stackingOrderChanged() && (w == newTopWindow()) && !disabled) {
/* This can happen because of two reasons:
- a window has received the focus earlier without being raised and is raised now. -> call windowActivated() now
- paintWindow() is called with a new stackingOrder before activateWindow(). Bug? -> don't draw the overlapping content;*/
foreach( EffectWindow *tmp, oldStackingOrder )
{
if( oldStackingOrder.lastIndexOf( tmp ) > oldStackingOrder.lastIndexOf( w ) && isWindowUsable( tmp ) && windowsShareDesktop( tmp, w ) )
{
foreach (EffectWindow * tmp, oldStackingOrder) {
if (oldStackingOrder.lastIndexOf(tmp) > oldStackingOrder.lastIndexOf(w) && isWindowUsable(tmp) && windowsShareDesktop(tmp, w)) {
kDebug(1212) << "screw detected. region:" << region << "clipping:" << tmp->geometry() ;
clippedRegions << region.subtracted(tmp->geometry());
PaintClipper::push(clippedRegions.last());
@ -225,8 +195,7 @@ void SlideBackEffect::paintWindow( EffectWindow *w, int mask, QRegion region, Wi
// Finally call windowActivated in case a already active window is raised.
windowActivated(w);
}
if( motionManager.isManaging( w ) )
{
if (motionManager.isManaging(w)) {
motionManager.apply(w, data);
}
effects->paintWindow(w, mask, region, data);
@ -237,51 +206,37 @@ void SlideBackEffect::paintWindow( EffectWindow *w, int mask, QRegion region, Wi
void SlideBackEffect::postPaintWindow(EffectWindow* w)
{
if( motionManager.isManaging( w ) )
{
if( destinationList.contains( w ) )
{
if (motionManager.isManaging(w)) {
if (destinationList.contains(w)) {
// has window reched its destination?
if ((qAbs(motionManager.transformedGeometry(w).x() - destinationList[w].x()) < 1) &&
( qAbs( motionManager.transformedGeometry( w ).y() - destinationList[w].y() ) < 1 ) )
{
(qAbs(motionManager.transformedGeometry(w).y() - destinationList[w].y()) < 1)) {
// If we are still intersecting with the activeWindow it is moving. slide to somewhere else
// restore the stacking order of all windows not intersecting any more except panels
if( coveringWindows.contains( w ) )
{
if (coveringWindows.contains(w)) {
EffectWindowList tmpList;
foreach( EffectWindow *tmp, elevatedList )
{
foreach (EffectWindow * tmp, elevatedList) {
QRect elevatedGeometry = tmp->geometry();
if( motionManager.isManaging( tmp ) )
{
if (motionManager.isManaging(tmp)) {
elevatedGeometry = motionManager.transformedGeometry(tmp).toAlignedRect();
}
if( effects->activeWindow() && !tmp->isDock() && !tmp->keepAbove() && effects->activeWindow()->geometry().intersects( elevatedGeometry ) )
{
if (effects->activeWindow() && !tmp->isDock() && !tmp->keepAbove() && effects->activeWindow()->geometry().intersects(elevatedGeometry)) {
QRect newDestination;
newDestination = getSlideDestination(getModalGroupGeometry(effects->activeWindow()), elevatedGeometry);
if( !motionManager.isManaging( tmp ) )
{
if (!motionManager.isManaging(tmp)) {
motionManager.manage(tmp);
}
motionManager.moveWindow(tmp, newDestination);
destinationList[tmp] = newDestination;
}
else
{
if( !tmp->isDock() )
{
} else {
if (!tmp->isDock()) {
bool keepElevated = false;
foreach( EffectWindow *elevatedWindow, tmpList)
{
if( tmp->geometry().intersects( elevatedWindow->geometry() ) )
{
foreach (EffectWindow * elevatedWindow, tmpList) {
if (tmp->geometry().intersects(elevatedWindow->geometry())) {
keepElevated = true;
}
}
if( !keepElevated )
{
if (!keepElevated) {
effects->setElevatedWindow(tmp, false);
elevatedList.removeAll(tmp);
}
@ -289,37 +244,28 @@ void SlideBackEffect::postPaintWindow( EffectWindow* w )
}
tmpList.append(tmp);
}
}
else
{
} else {
// Move the window back where it belongs
motionManager.moveWindow(w, w->geometry());
destinationList.remove(w);
}
}
}
else
{
} else {
// is window back at its original position?
if ((qAbs(motionManager.transformedGeometry(w).x() - w->geometry().x()) < 1) &&
( qAbs( motionManager.transformedGeometry( w ).y() - w->geometry().y() ) < 1 ) )
{
(qAbs(motionManager.transformedGeometry(w).y() - w->geometry().y()) < 1)) {
motionManager.unmanage(w);
effects->addRepaintFull();
}
}
if( coveringWindows.contains( w ) )
{
if (coveringWindows.contains(w)) {
// It could happen that there is no aciveWindow() here if the user clicks the close-button on an inactive window.
// Just skip... the window will be removed in windowDeleted() later
if( effects->activeWindow() && !intersects( effects->activeWindow(), motionManager.transformedGeometry( w ).toAlignedRect() ) )
{
if (effects->activeWindow() && !intersects(effects->activeWindow(), motionManager.transformedGeometry(w).toAlignedRect())) {
coveringWindows.removeAll(w);
if( coveringWindows.isEmpty() )
{
if (coveringWindows.isEmpty()) {
// Restore correct stacking order
foreach( EffectWindow *tmp, elevatedList )
{
foreach (EffectWindow * tmp, elevatedList) {
effects->setElevatedWindow(tmp, false);
}
elevatedList.clear();
@ -336,8 +282,7 @@ void SlideBackEffect::windowDeleted( EffectWindow* w )
oldStackingOrder.removeAll(w);
coveringWindows.removeAll(w);
elevatedList.removeAll(w);
if( motionManager.isManaging( w ) )
{
if (motionManager.isManaging(w)) {
motionManager.unmanage(w);
}
}
@ -353,12 +298,9 @@ void SlideBackEffect::windowUnminimized( EffectWindow* w)
// SlideBack should not be triggered on an unminimized window. For this we need to store the last unminimized window.
// If a window is unminimized but not on top we need to clear the memory because the windowUnminimized() is not
// followed by a windowActivated().
if( isWindowOnTop( w ) )
{
if (isWindowOnTop(w)) {
unminimizedWindow = w;
}
else
{
} else {
unminimizedWindow = NULL;
}
}
@ -377,8 +319,7 @@ void SlideBackEffect::tabBoxClosed()
bool SlideBackEffect::isWindowOnTop(EffectWindow* w)
{
EffectWindowList openWindows = usableWindows(effects->stackingOrder());
if( !openWindows.isEmpty() && ( openWindows.last() == w ) )
{
if (!openWindows.isEmpty() && (openWindows.last() == w)) {
return true;
}
return false;
@ -399,10 +340,8 @@ bool SlideBackEffect::intersects( EffectWindow* windowUnder, const QRect &window
EffectWindowList SlideBackEffect::usableWindows(const EffectWindowList & allWindows)
{
EffectWindowList retList;
foreach( EffectWindow *tmp, allWindows )
{
if( isWindowUsable( tmp ) )
{
foreach (EffectWindow * tmp, allWindows) {
if (isWindowUsable(tmp)) {
retList.append(tmp);
}
}
@ -423,10 +362,8 @@ EffectWindow* SlideBackEffect::newTopWindow()
QRect SlideBackEffect::getModalGroupGeometry(EffectWindow *w)
{
QRect modalGroupGeometry = w->geometry();
if( w->isModal() )
{
foreach( EffectWindow *modalWindow, w->mainWindows() )
{
if (w->isModal()) {
foreach (EffectWindow * modalWindow, w->mainWindows()) {
modalGroupGeometry = modalGroupGeometry.united(getModalGroupGeometry(modalWindow));
}
}

View File

@ -54,16 +54,13 @@ void SlidingPopupsEffect::prePaintScreen( ScreenPrePaintData& data, int time )
void SlidingPopupsEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
{
if( mAppearingWindows.contains( w ) )
{
if (mAppearingWindows.contains(w)) {
mAppearingWindows[ w ].addTime(time);
if (mAppearingWindows[ w ].value() < 1)
data.setTransformed();
else
mAppearingWindows.remove(w);
}
else if( mDisappearingWindows.contains( w ) )
{
} else if (mDisappearingWindows.contains(w)) {
data.setTransformed();
w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DELETE);
@ -78,24 +75,19 @@ void SlidingPopupsEffect::paintWindow( EffectWindow* w, int mask, QRegion region
bool appearing = false;
QRegion clippedRegion = region;
if( mAppearingWindows.contains( w ) )
{
if (mAppearingWindows.contains(w)) {
appearing = true;
animating = true;
}
else if( mDisappearingWindows.contains( w ) && w->isDeleted() )
{
} else if (mDisappearingWindows.contains(w) && w->isDeleted()) {
appearing = false;
animating = true;
}
if( animating )
{
if (animating) {
qreal progress;
if (appearing)
progress = 1.0 - mAppearingWindows[ w ].value();
else
{
else {
if (mDisappearingWindows.contains(w))
progress = mDisappearingWindows[ w ].value();
else
@ -103,8 +95,7 @@ void SlidingPopupsEffect::paintWindow( EffectWindow* w, int mask, QRegion region
}
const int start = mWindowsData[ w ].start;
switch (mWindowsData[ w ].from)
{
switch(mWindowsData[ w ].from) {
case West:
data.xTranslate += (start - w->width()) * progress;
clippedRegion = clippedRegion.subtracted(QRegion(start - w->width(), w->y(), w->width(), w->height()));
@ -132,8 +123,7 @@ void SlidingPopupsEffect::postPaintWindow( EffectWindow* w )
if (mAppearingWindows.contains(w) || mDisappearingWindows.contains(w))
w->addRepaintFull(); // trigger next animation repaint
effects->postPaintWindow(w);
if( mDisappearingWindows.contains( w ) && mDisappearingWindows[ w ].value() >= 1 )
{
if (mDisappearingWindows.contains(w) && mDisappearingWindows[ w ].value() >= 1) {
mDisappearingWindows.remove(w);
w->unrefWindow();
effects->addRepaint(w->geometry());
@ -143,8 +133,7 @@ void SlidingPopupsEffect::postPaintWindow( EffectWindow* w )
void SlidingPopupsEffect::windowAdded(EffectWindow* w)
{
propertyNotify(w, mAtom);
if( w->isOnCurrentDesktop() && mWindowsData.contains( w ) )
{
if (w->isOnCurrentDesktop() && mWindowsData.contains(w)) {
mAppearingWindows[ w ].setDuration(mWindowsData[ w ].fadeInDuration);
mAppearingWindows[ w ].setProgress(0.0);
mAppearingWindows[ w ].setCurveShape(TimeLine::EaseOutCurve);
@ -159,8 +148,7 @@ void SlidingPopupsEffect::windowAdded( EffectWindow* w )
void SlidingPopupsEffect::windowClosed(EffectWindow* w)
{
propertyNotify(w, mAtom);
if( w->isOnCurrentDesktop() && !w->isMinimized() && mWindowsData.contains( w ) )
{
if (w->isOnCurrentDesktop() && !w->isMinimized() && mWindowsData.contains(w)) {
w->refWindow();
mAppearingWindows.remove(w);
mDisappearingWindows[ w ].setDuration(mWindowsData[ w ].fadeOutDuration);
@ -189,8 +177,7 @@ void SlidingPopupsEffect::propertyNotify( EffectWindow* w, long a )
QByteArray data = w->readProperty(mAtom, mAtom, 32);
if( data.length() < 1 )
{
if (data.length() < 1) {
// Property was removed, thus also remove the effect for window
mAppearingWindows.remove(w);
mDisappearingWindows.remove(w);
@ -202,16 +189,13 @@ void SlidingPopupsEffect::propertyNotify( EffectWindow* w, long a )
Data animData;
animData.start = d[ 0 ];
animData.from = (Position)d[ 1 ];
if( data.length() >= (int)(sizeof( long ) * 3) )
{
if (data.length() >= (int)(sizeof(long) * 3)) {
animData.fadeInDuration = d[2];
if (data.length() >= (int)(sizeof(long) * 4))
animData.fadeOutDuration = d[3];
else
animData.fadeOutDuration = d[2];
}
else
{
} else {
animData.fadeInDuration = animationTime(mFadeInTime);
animData.fadeOutDuration = animationTime(mFadeOutTime);
}

View File

@ -43,15 +43,13 @@ class SlidingPopupsEffect
virtual void windowDeleted(EffectWindow* c);
virtual void propertyNotify(EffectWindow* w, long a);
private:
enum Position
{
enum Position {
West = 0,
North = 1,
East = 2,
South = 3
};
struct Data
{
struct Data {
int start; //point in screen coordinates where the window starts
//to animate, from decides if this point is an x or an y
Position from;

View File

@ -76,10 +76,9 @@ void SnapHelperEffect::prePaintScreen( ScreenPrePaintData &data, int time )
void SnapHelperEffect::postPaintScreen()
{
effects->postPaintScreen();
if( m_timeline.value() != 0.0 )
{ // Display the guide
if( effects->compositingType() == OpenGLCompositing )
{
if (m_timeline.value() != 0.0) {
// Display the guide
if (effects->compositingType() == OpenGLCompositing) {
#ifndef KWIN_HAVE_OPENGLES
glPushAttrib(GL_CURRENT_BIT | GL_ENABLE_BIT);
#endif
@ -181,9 +180,7 @@ void SnapHelperEffect::postPaintScreen()
XDrawSegments( display(), effects->xrenderBufferPicture(), m_gc, segments, 6 );
}
}*/
}
else if( m_window )
{
} else if (m_window) {
if (m_window->isDeleted())
m_window->unrefWindow();
m_window = NULL;
@ -192,8 +189,7 @@ void SnapHelperEffect::postPaintScreen()
void SnapHelperEffect::windowClosed(EffectWindow* w)
{
if( m_window == w )
{
if (m_window == w) {
m_window->refWindow();
m_active = false;
}
@ -201,13 +197,11 @@ void SnapHelperEffect::windowClosed( EffectWindow* w )
void SnapHelperEffect::windowUserMovedResized(EffectWindow* w, bool first, bool last)
{
if( first && !last && w->isMovable() )
{
if (first && !last && w->isMovable()) {
m_active = true;
m_window = w;
effects->addRepaintFull();
}
else if( last )
} else if (last)
m_active = false;
}

View File

@ -54,24 +54,19 @@ static const int BLINKING_FRAME_DURATION = 100;
// duration of one blinking animation
static const int BLINKING_DURATION = BLINKING_FRAME_DURATION * BLINKING_FRAMES;
//const int color_to_pixmap[] = { 0, 1, 2, 3, 2, 1 };
static const int FRAME_TO_BOUNCE_YOFFSET[] =
{
static const int FRAME_TO_BOUNCE_YOFFSET[] = {
-5, -1, 2, 5, 8, 10, 12, 13, 15, 15, 15, 15, 14, 12, 10, 8, 5, 2, -1, -5
};
static const QSize BOUNCE_SIZES[] =
{
static const QSize BOUNCE_SIZES[] = {
QSize(16, 16), QSize(14, 18), QSize(12, 20), QSize(18, 14), QSize(20, 12)
};
static const int FRAME_TO_BOUNCE_TEXTURE[] =
{
static const int FRAME_TO_BOUNCE_TEXTURE[] = {
0, 0, 0, 1, 2, 2, 1, 0, 3, 4, 4, 3, 0, 1, 2, 2, 1, 0, 0, 0
};
static const int FRAME_TO_BLINKING_COLOR[] =
{
static const int FRAME_TO_BLINKING_COLOR[] = {
0, 1, 2, 3, 2, 1
};
static const QColor BLINKING_COLORS[] =
{
static const QColor BLINKING_COLORS[] = {
Qt::black, Qt::darkGray, Qt::lightGray, Qt::white, Qt::white
};
@ -85,8 +80,7 @@ StartupFeedbackEffect::StartupFeedbackEffect()
, m_type(BouncingFeedback)
, m_blinkingShader(0)
{
for( int i=0; i<5; ++i )
{
for (int i = 0; i < 5; ++i) {
m_bouncingTextures[i] = 0;
}
m_selection->claim(true);
@ -98,12 +92,10 @@ StartupFeedbackEffect::StartupFeedbackEffect()
StartupFeedbackEffect::~StartupFeedbackEffect()
{
if( m_active )
{
if (m_active) {
effects->stopMousePolling();
}
for( int i=0; i<5; ++i )
{
for (int i = 0; i < 5; ++i) {
delete m_bouncingTextures[i];
}
delete m_texture;
@ -143,11 +135,9 @@ void StartupFeedbackEffect::reconfigure( Effect::ReconfigureFlags flags )
kDebug(1212) << "Blinking Shader is not valid";
}
}
}
else
} else
m_type = PassiveFeedback;
if( m_active )
{
if (m_active) {
stop();
start(m_startups[ m_currentStartup ]);
}
@ -155,11 +145,9 @@ void StartupFeedbackEffect::reconfigure( Effect::ReconfigureFlags flags )
void StartupFeedbackEffect::prePaintScreen(ScreenPrePaintData& data, int time)
{
if( m_active )
{
if (m_active) {
// need the unclipped version
switch( m_type )
{
switch(m_type) {
case BouncingFeedback:
m_progress = (m_progress + time) % BOUNCE_DURATION;
m_frame = qRound((qreal)m_progress / (qreal)BOUNCE_FRAME_DURATION);
@ -180,11 +168,9 @@ void StartupFeedbackEffect::prePaintScreen( ScreenPrePaintData& data, int time )
void StartupFeedbackEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
{
effects->paintScreen(mask, region, data);
if( m_active )
{
if (m_active) {
GLTexture* texture;
switch( m_type )
{
switch(m_type) {
case BouncingFeedback:
texture = m_bouncingTextures[ FRAME_TO_BOUNCE_TEXTURE[ m_frame ]];
break;
@ -234,8 +220,7 @@ void StartupFeedbackEffect::paintScreen( int mask, QRegion region, ScreenPaintDa
if (useShader) {
ShaderManager::instance()->popShader();
}
if( m_type == BlinkingFeedback && !useShader )
{
if (m_type == BlinkingFeedback && !useShader) {
#ifndef KWIN_HAVE_OPENGLES
// resture states
glActiveTexture(GL_TEXTURE1);
@ -255,10 +240,8 @@ void StartupFeedbackEffect::paintScreen( int mask, QRegion region, ScreenPaintDa
void StartupFeedbackEffect::postPaintScreen()
{
if( m_active )
{
switch( m_type )
{
if (m_active) {
switch(m_type) {
case BouncingFeedback: // fall through
case BlinkingFeedback:
// repaint the icon
@ -282,8 +265,7 @@ void StartupFeedbackEffect::mouseChanged(const QPoint& pos, const QPoint& oldpos
Q_UNUSED(oldbuttons)
Q_UNUSED(modifiers)
Q_UNUSED(oldmodifiers)
if( m_active )
{
if (m_active) {
effects->addRepaint(m_currentGeometry);
effects->addRepaint(feedbackRect());
}
@ -300,8 +282,7 @@ void StartupFeedbackEffect::gotNewStartup( const KStartupInfoId& id, const KStar
void StartupFeedbackEffect::gotRemoveStartup(const KStartupInfoId& id, const KStartupInfoData& data)
{
m_startups.remove(id);
if( m_startups.count() == 0 )
{
if (m_startups.count() == 0) {
m_currentStartup = KStartupInfoId(); // null
stop();
return;
@ -312,11 +293,9 @@ void StartupFeedbackEffect::gotRemoveStartup( const KStartupInfoId& id, const KS
void StartupFeedbackEffect::gotStartupChange(const KStartupInfoId& id, const KStartupInfoData& data)
{
if( m_currentStartup == id )
{
if (m_currentStartup == id) {
const QString& icon = data.findIcon();
if( !icon.isEmpty() && icon != m_startups[ m_currentStartup ] )
{
if (!icon.isEmpty() && icon != m_startups[ m_currentStartup ]) {
m_startups[ id ] = icon;
start(icon);
}
@ -343,11 +322,9 @@ void StartupFeedbackEffect::stop()
if (m_active)
effects->stopMousePolling();
m_active = false;
switch( m_type )
{
switch(m_type) {
case BouncingFeedback:
for( int i=0; i<5; ++i )
{
for (int i = 0; i < 5; ++i) {
delete m_bouncingTextures[i];
m_bouncingTextures[i] = 0;
}
@ -367,11 +344,9 @@ void StartupFeedbackEffect::stop()
void StartupFeedbackEffect::prepareTextures(const QPixmap& pix)
{
switch( m_type )
{
switch(m_type) {
case BouncingFeedback:
for( int i=0; i<5; ++i )
{
for (int i = 0; i < 5; ++i) {
delete m_bouncingTextures[i];
m_bouncingTextures[i] = new GLTexture(scalePixmap(pix, BOUNCE_SIZES[i]));
}
@ -417,8 +392,7 @@ QRect StartupFeedbackEffect::feedbackRect() const
int yDiff = xDiff;
GLTexture* texture;
int yOffset = 0;
switch( m_type )
{
switch(m_type) {
case BouncingFeedback:
texture = m_bouncingTextures[ FRAME_TO_BOUNCE_TEXTURE[ m_frame ]];
yOffset = FRAME_TO_BOUNCE_YOFFSET[ m_frame ];

View File

@ -51,8 +51,7 @@ class StartupFeedbackEffect
void gotStartupChange(const KStartupInfoId& id, const KStartupInfoData& data);
private:
enum FeedbackType
{
enum FeedbackType {
NoFeedback,
BouncingFeedback,
BlinkingFeedback,

View File

@ -68,16 +68,15 @@ void TaskbarThumbnailEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData
void TaskbarThumbnailEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{
effects->paintWindow(w, mask, region, data); // paint window first
if( thumbnails.contains( w ))
{ // paint thumbnails on it
if (thumbnails.contains(w)) {
// paint thumbnails on it
int mask = PAINT_WINDOW_TRANSFORMED;
if (data.opacity == 1.0)
mask |= PAINT_WINDOW_OPAQUE;
else
mask |= PAINT_WINDOW_TRANSLUCENT;
mask |= PAINT_WINDOW_LANCZOS;
foreach( const Data &thumb, thumbnails.values( w ))
{
foreach (const Data & thumb, thumbnails.values(w)) {
EffectWindow* thumbw = effects->findWindow(thumb.window);
if (thumbw == NULL)
continue;
@ -86,15 +85,12 @@ void TaskbarThumbnailEffect::paintWindow( EffectWindow* w, int mask, QRegion reg
QRect r;
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
if( effects->compositingType() == KWin::OpenGLCompositing )
{
if ( data.shader )
{
if (effects->compositingType() == KWin::OpenGLCompositing) {
if (data.shader) {
// there is a shader - update texture width and height
int texw = thumbw->width();
int texh = thumbw->height();
if( !GLTexture::NPOTTextureSupported() )
{
if (!GLTexture::NPOTTextureSupported()) {
kWarning(1212) << "NPOT textures not supported, wasting some memory" ;
texw = nearestPowerOfTwo(texw);
texh = nearestPowerOfTwo(texh);
@ -147,8 +143,7 @@ void TaskbarThumbnailEffect::propertyNotify( EffectWindow* w, long a )
++pos;
for (int i = 0;
i < cnt;
++i )
{
++i) {
int size = d[ pos ];
if (len - pos < size)
return; // format error

View File

@ -42,8 +42,7 @@ class TaskbarThumbnailEffect
virtual void windowDeleted(EffectWindow* w);
virtual void propertyNotify(EffectWindow* w, long atom);
private:
struct Data
{
struct Data {
Window window; // thumbnail of this window
QRect rect;
};

View File

@ -54,10 +54,8 @@ void ThumbnailAsideEffect::reconfigure( ReconfigureFlags )
void ThumbnailAsideEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
{
effects->paintScreen(mask, region, data);
foreach( const Data& d, windows )
{
if( region.contains( d.rect ))
{
foreach (const Data & d, windows) {
if (region.contains(d.rect)) {
WindowPaintData data(d.window);
data.opacity = opacity;
QRect region;
@ -70,8 +68,7 @@ void ThumbnailAsideEffect::paintScreen( int mask, QRegion region, ScreenPaintDat
void ThumbnailAsideEffect::windowDamaged(EffectWindow* w, const QRect&)
{
foreach( const Data& d, windows )
{
foreach (const Data & d, windows) {
if (d.window == w)
effects->addRepaint(d.rect);
}
@ -79,10 +76,8 @@ void ThumbnailAsideEffect::windowDamaged( EffectWindow* w, const QRect& )
void ThumbnailAsideEffect::windowGeometryShapeChanged(EffectWindow* w, const QRect& old)
{
foreach( const Data& d, windows )
{
if( d.window == w )
{
foreach (const Data & d, windows) {
if (d.window == w) {
if (w->size() == old.size())
effects->addRepaint(d.rect);
else
@ -127,8 +122,7 @@ void ThumbnailAsideEffect::removeThumbnail( EffectWindow* w )
windows.remove(w);
for (QHash< EffectWindow*, Data >::Iterator it = windows.begin();
it != windows.end();
++it )
{
++it) {
Data& d = *it;
if (d.index > index)
--d.index;
@ -143,8 +137,7 @@ void ThumbnailAsideEffect::arrange()
int height = 0;
QVector< int > pos(windows.size());
int mwidth = 0;
foreach( const Data& d, windows )
{
foreach (const Data & d, windows) {
height += d.window->height();
mwidth = qMax(mwidth, d.window->width());
pos[ d.index ] = d.window->height();
@ -155,16 +148,14 @@ void ThumbnailAsideEffect::arrange()
int add = 0;
for (int i = 0;
i < windows.size();
++i )
{
++i) {
pos[ i ] = int(pos[ i ] * scale);
pos[ i ] += spacing + add; // compute offset of each item
add = pos[ i ];
}
for (QHash< EffectWindow*, Data >::Iterator it = windows.begin();
it != windows.end();
++it )
{
++it) {
Data& d = *it;
int width = int(d.window->width() * scale);
d.rect = QRect(area.right() - width, area.bottom() - pos[ d.index ], width, int(d.window->height() * scale));

View File

@ -54,8 +54,7 @@ class ThumbnailAsideEffect
void removeThumbnail(EffectWindow* w);
void arrange();
void repaintAll();
struct Data
{
struct Data {
EffectWindow* window; // the same like the key in the hash (makes code simpler)
int index;
QRect rect;

View File

@ -83,14 +83,11 @@ void TrackMouseEffect::reconfigure( ReconfigureFlags )
modifier |= Qt::AltModifier;
if (shift)
modifier |= Qt::ShiftModifier;
if( modifier != 0 && action != NULL )
{
if (modifier != 0 && action != NULL) {
if (!mousePolling)
effects->startMousePolling();
mousePolling = true;
}
else if( action != NULL )
{
} else if (action != NULL) {
if (mousePolling)
effects->stopMousePolling();
mousePolling = false;
@ -112,8 +109,7 @@ void TrackMouseEffect::paintScreen( int mask, QRegion region, ScreenPaintData& d
if (!active)
return;
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
if( texture )
{
if (texture) {
#ifndef KWIN_HAVE_OPENGLES
glPushAttrib(GL_CURRENT_BIT | GL_ENABLE_BIT);
#endif
@ -127,8 +123,7 @@ void TrackMouseEffect::paintScreen( int mask, QRegion region, ScreenPaintData& d
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
for (int i = 0;
i < STARS;
++i )
{
++i) {
QRect r = starRect(i);
texture->render(region, r);
}
@ -146,8 +141,7 @@ void TrackMouseEffect::paintScreen( int mask, QRegion region, ScreenPaintData& d
void TrackMouseEffect::postPaintScreen()
{
if( active )
{
if (active) {
for (int i = 0;
i < STARS;
++i)
@ -160,16 +154,14 @@ void TrackMouseEffect::toggle()
{
if (mousePolling)
return;
if( !active )
{
if (!active) {
if (texture == NULL)
loadTexture();
if (texture == NULL)
return;
active = true;
angle = 0;
}
else
} else
active = false;
for (int i = 0; i < STARS; ++i)
effects->addRepaint(starRect(i));
@ -178,10 +170,8 @@ void TrackMouseEffect::toggle()
void TrackMouseEffect::mouseChanged(const QPoint&, const QPoint&, Qt::MouseButtons,
Qt::MouseButtons, Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers)
{
if( modifier != 0 && modifiers == modifier )
{
if( !active )
{
if (modifier != 0 && modifiers == modifier) {
if (!active) {
if (texture == NULL)
loadTexture();
if (texture == NULL)
@ -191,9 +181,7 @@ void TrackMouseEffect::mouseChanged( const QPoint&, const QPoint&, Qt::MouseButt
}
for (int i = 0; i < STARS; ++i)
effects->addRepaint(starRect(i));
}
else if( active )
{
} else if (active) {
for (int i = 0; i < STARS; ++i)
effects->addRepaint(starRect(i));
active = false;

View File

@ -113,13 +113,10 @@ void TrackMouseEffectConfig::defaults()
void TrackMouseEffectConfig::enableEditor(bool enabled)
{
if( !enabled && !m_ui->alt->isChecked() && !m_ui->shift->isChecked() && !m_ui->meta->isChecked() && !m_ui->control->isChecked() )
{
if (!enabled && !m_ui->alt->isChecked() && !m_ui->shift->isChecked() && !m_ui->meta->isChecked() && !m_ui->control->isChecked()) {
m_ui->editor->setEnabled(true);
emit changed(true);
}
else if( enabled && ( m_ui->alt->isChecked() || m_ui->shift->isChecked() || m_ui->meta->isChecked() || m_ui->control->isChecked() ) )
{
} else if (enabled && (m_ui->alt->isChecked() || m_ui->shift->isChecked() || m_ui->meta->isChecked() || m_ui->control->isChecked())) {
m_ui->editor->setEnabled(false);
action->setGlobalShortcut(KShortcut(), KAction::ShortcutTypes(KAction::ActiveShortcut | KAction::DefaultShortcut), KAction::NoAutoloading);
emit changed(true);

View File

@ -46,14 +46,11 @@ void TranslucencyEffect::reconfigure( ReconfigureFlags )
comboboxpopups = conf.readEntry("ComboboxPopups", 1.0);
menus = conf.readEntry("Menus", 1.0);
individualmenuconfig = conf.readEntry("IndividualMenuConfig", false);
if( individualmenuconfig )
{
if (individualmenuconfig) {
dropdownmenus = conf.readEntry("DropdownMenus", 1.0);
popupmenus = conf.readEntry("PopupMenus", 1.0);
tornoffmenus = conf.readEntry("TornOffMenus", 1.0);
}
else
{
} else {
dropdownmenus = menus;
popupmenus = menus;
tornoffmenus = menus;
@ -72,8 +69,7 @@ void TranslucencyEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& da
moveresize_timeline.addTime(time);
activeinactive_timeline.addTime(time);
if( decoration != 1.0 && w->hasDecoration())
{
if (decoration != 1.0 && w->hasDecoration()) {
data.mask |= PAINT_WINDOW_TRANSLUCENT;
// don't clear PAINT_WINDOW_OPAQUE, contents are not affected
data.clip &= w->contentsRect().translated(w->pos()); // decoration cannot clip
@ -81,15 +77,13 @@ void TranslucencyEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& da
if (inactive != 1.0 && isInactive(w))
data.setTranslucent();
if ((moveresize != 1.0 && (w->isUserMove() || w->isUserResize()))
|| ( dialogs != 1.0 && w->isDialog()))
{
|| (dialogs != 1.0 && w->isDialog())) {
data.setTranslucent();
}
if ((dropdownmenus != 1.0 && w->isDropdownMenu())
|| (popupmenus != 1.0 && w->isPopupMenu())
|| (tornoffmenus != 1.0 && w->isMenu())
|| ( comboboxpopups != 1.0 && w->isComboBox() ) )
{
|| (comboboxpopups != 1.0 && w->isComboBox())) {
data.setTranslucent();
}
@ -100,34 +94,27 @@ void TranslucencyEffect::paintWindow( EffectWindow* w, int mask, QRegion region,
{
// We keep track of the windows that was last active so we know
// which one to fade out and which ones to paint as fully inactive
if ( w == active && w != current )
{
if (w == active && w != current) {
previous = current;
current = w;
}
if ( w->isDesktop() || w->isDock() )
{
if (w->isDesktop() || w->isDock()) {
effects->paintWindow(w, mask, region, data);
return;
}
// Handling active and inactive windows
if( inactive != 1.0 && isInactive(w) )
{
if (inactive != 1.0 && isInactive(w)) {
data.opacity *= inactive;
if ( w == previous )
{
if (w == previous) {
data.opacity *= (inactive + ((1.0 - inactive) * (1.0 - activeinactive_timeline.value())));
if (activeinactive_timeline.value() < 1.0)
w->addRepaintFull();
}
}
else
{
} else {
// Fading in
if ( !isInactive(w) && !w->isDesktop() )
{
if (!isInactive(w) && !w->isDesktop()) {
data.opacity *= (inactive + ((1.0 - inactive) * activeinactive_timeline.value()));
if (activeinactive_timeline.value() < 1.0)
w->addRepaintFull();
@ -139,23 +126,19 @@ void TranslucencyEffect::paintWindow( EffectWindow* w, int mask, QRegion region,
data.opacity *= dialogs;
// Handling moving and resizing
if( moveresize != 1.0 && !w->isDesktop() && !w->isDock())
{
if (moveresize != 1.0 && !w->isDesktop() && !w->isDock()) {
double progress = moveresize_timeline.value();
if ( w->isUserMove() || w->isUserResize() )
{ // Fading to translucent
if (w->isUserMove() || w->isUserResize()) {
// Fading to translucent
data.opacity *= (moveresize + ((1.0 - moveresize) * (1.0 - progress)));
if (progress < 1.0 && progress > 0.0)
{
if (progress < 1.0 && progress > 0.0) {
w->addRepaintFull();
if (fadeout != w)
fadeout = w;
}
}
else
{ // Fading back to more opaque
if( w == fadeout && !w->isUserMove() && !w->isUserResize() )
{
} else {
// Fading back to more opaque
if (w == fadeout && !w->isUserMove() && !w->isUserResize()) {
data.opacity *= (moveresize + ((1.0 - moveresize) * (progress)));
if (progress == 1.0 || progress == 0.0)
fadeout = NULL;
@ -194,8 +177,7 @@ bool TranslucencyEffect::isInactive( const EffectWindow* w ) const
void TranslucencyEffect::windowUserMovedResized(EffectWindow* w, bool first, bool last)
{
if( moveresize != 1.0 && ( first || last ))
{
if (moveresize != 1.0 && (first || last)) {
moveresize_timeline.setProgress(0.0);
w->addRepaintFull();
}
@ -203,31 +185,24 @@ void TranslucencyEffect::windowUserMovedResized( EffectWindow* w, bool first, bo
void TranslucencyEffect::windowActivated(EffectWindow* w)
{
if( inactive != 1.0 )
{
if (inactive != 1.0) {
activeinactive_timeline.setProgress(0.0);
if( NULL != active && active != w )
{
if (NULL != active && active != w) {
if ((NULL == w || w->group() != active->group()) &&
NULL != active->group() )
{
NULL != active->group()) {
// Active group has changed. so repaint old group
foreach (EffectWindow * tmp, active->group()->members())
tmp->addRepaintFull();
}
else
} else
active->addRepaintFull();
}
if( NULL != w )
{
if (NULL != w->group() )
{
if (NULL != w) {
if (NULL != w->group()) {
// Repaint windows in new group
foreach (EffectWindow * tmp, w->group()->members())
tmp->addRepaintFull();
}
else
} else
w->addRepaintFull();
}
}

View File

@ -46,8 +46,7 @@ WindowGeometry::WindowGeometry()
"X: %1 (%3)\nY: %2 (%4)");
reconfigure(ReconfigureAll);
QFont fnt; fnt.setBold(true); fnt.setPointSize(12);
for ( int i = 0; i < 3; ++i )
{
for (int i = 0; i < 3; ++i) {
myMeasure[i] = effects->effectFrame(EffectFrameUnstyled, false);
myMeasure[i]->setFont(fnt);
}
@ -78,8 +77,7 @@ void WindowGeometry::reconfigure( ReconfigureFlags )
void WindowGeometry::paintScreen(int mask, QRegion region, ScreenPaintData &data)
{
effects->paintScreen(mask, region, data);
if ( iAmActivated && iAmActive )
{
if (iAmActivated && iAmActive) {
for (int i = 0; i < 3; ++i)
myMeasure[i]->render(infiniteRegion(), 1.0, .66);
}
@ -95,8 +93,7 @@ void WindowGeometry::windowUserMovedResized( EffectWindow* w, bool first, bool l
if (first && last) // "maximized"
return;
if ( first )
{
if (first) {
if (!iAmActivated)
return;
if (w->isUserResize() && !iHandleResizes)
@ -111,8 +108,7 @@ void WindowGeometry::windowUserMovedResized( EffectWindow* w, bool first, bool l
effects->addRepaint(myCurrentGeometry.adjusted(-20, -20, 20, 20));
}
if ( iAmActive && w == myResizeWindow && last )
{
if (iAmActive && w == myResizeWindow && last) {
iAmActive = false;
myResizeWindow = 0L;
effects->addRepaint(myCurrentGeometry.adjusted(-20, -20, 20, 20));
@ -129,8 +125,7 @@ static inline QString number(int n)
void WindowGeometry::windowMoveResizeGeometryUpdate(EffectWindow* w, const QRect& geometry)
{
if ( iAmActivated && iAmActive && w == myResizeWindow )
{
if (iAmActivated && iAmActive && w == myResizeWindow) {
myCurrentGeometry = geometry;
const QRect &r = geometry;
const QRect &r2 = myOriginalGeometry;
@ -147,8 +142,7 @@ void WindowGeometry::windowMoveResizeGeometryUpdate( EffectWindow* w, const QRec
myMeasure[0]->setPosition(geometry.topLeft());
// center ----------------------
if ( w->isUserResize() )
{
if (w->isUserResize()) {
// calc width for center element, otherwise the current dx/dx remains right
dx = r.width() - r2.width();
dy = r.height() - r2.height();
@ -160,8 +154,7 @@ void WindowGeometry::windowMoveResizeGeometryUpdate( EffectWindow* w, const QRec
// calc width for bottomright element, superfluous otherwise
dx = r.right() - r2.right();
dy = r.bottom() - r2.bottom();
}
else
} else
myMeasure[1]->setText(myCoordString[0].arg(number(dx)).arg(number(dy)));
myMeasure[1]->setPosition(geometry.center());

View File

@ -33,7 +33,9 @@ public:
WindowGeometry();
~WindowGeometry();
inline bool provides( Effect::Feature ef ) { return ef == Effect::GeometryTip; }
inline bool provides(Effect::Feature ef) {
return ef == Effect::GeometryTip;
}
void reconfigure(ReconfigureFlags);
void paintScreen(int mask, QRegion region, ScreenPaintData &data);
void windowUserMovedResized(EffectWindow* w, bool first, bool last);

View File

@ -52,8 +52,7 @@ static const qreal MINACCELERATION = 0.0;
static const qreal MAXACCELERATION = 1000.0;
static const qreal STOPACCELERATION = 5.0;
struct ParameterSet
{
struct ParameterSet {
qreal stiffness;
qreal drag;
qreal move_factor;
@ -73,8 +72,7 @@ struct ParameterSet
bool closeEffectEnabled;
};
static const ParameterSet set_0 =
{
static const ParameterSet set_0 = {
0.15,
0.80,
0.10,
@ -91,8 +89,7 @@ static const ParameterSet set_0 =
false
};
static const ParameterSet set_1 =
{
static const ParameterSet set_1 = {
0.10,
0.85,
0.10,
@ -109,8 +106,7 @@ static const ParameterSet set_1 =
false
};
static const ParameterSet set_2 =
{
static const ParameterSet set_2 = {
0.06,
0.90,
0.10,
@ -127,8 +123,7 @@ static const ParameterSet set_2 =
false
};
static const ParameterSet set_3 =
{
static const ParameterSet set_3 = {
0.03,
0.92,
0.20,
@ -145,8 +140,7 @@ static const ParameterSet set_3 =
false
};
static const ParameterSet set_4 =
{
static const ParameterSet set_4 = {
0.01,
0.97,
0.25,
@ -175,14 +169,12 @@ WobblyWindowsEffect::WobblyWindowsEffect()
WobblyWindowsEffect::~WobblyWindowsEffect()
{
if (!windows.empty())
{
if (!windows.empty()) {
// we should be empty at this point...
// emit a warning and clean the list.
kDebug(1212) << "Windows list not empty. Left items : " << windows.count();
QHash< const EffectWindow*, WindowWobblyInfos >::iterator i;
for (i = windows.begin(); i != windows.end(); ++i)
{
for (i = windows.begin(); i != windows.end(); ++i) {
freeWobblyInfo(i.value());
}
}
@ -194,25 +186,20 @@ void WobblyWindowsEffect::reconfigure( ReconfigureFlags )
QString settingsMode = conf.readEntry("Settings", "Auto");
if (settingsMode != "Custom")
{
if (settingsMode != "Custom") {
unsigned int wobblynessLevel = conf.readEntry("WobblynessLevel", 0);
if (wobblynessLevel > 4)
{
if (wobblynessLevel > 4) {
kDebug(1212) << "Wrong value for \"WobblynessLevel\" : " << wobblynessLevel;
wobblynessLevel = 4;
}
setParameterSet(pset[wobblynessLevel]);
if (conf.readEntry("AdvancedMode", false))
{
if (conf.readEntry("AdvancedMode", false)) {
m_stiffness = conf.readEntry("Stiffness", STIFFNESS * 100.0) / 100.0;
m_drag = conf.readEntry("Drag", DRAG * 100.0) / 100.0;
m_move_factor = conf.readEntry("MoveFactor", MOVEFACTOR * 100.0) / 100.0;
}
}
else // Custom method, read all values from config file.
{
} else { // Custom method, read all values from config file.
m_stiffness = conf.readEntry("Stiffness", STIFFNESS);
m_drag = conf.readEntry("Drag", DRAG);
m_move_factor = conf.readEntry("MoveFactor", MOVEFACTOR);
@ -297,8 +284,7 @@ void WobblyWindowsEffect::prePaintScreen(ScreenPrePaintData& data, int time)
// We need to mark the screen windows as transformed. Otherwise the whole
// screen won't be repainted, resulting in artefacts.
// Could we just set a subset of the screen to be repainted ?
if (windows.count() != 0)
{
if (windows.count() != 0) {
data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_WITHOUT_FULL_REPAINTS;
m_updateRegion = QRegion();
@ -309,23 +295,20 @@ void WobblyWindowsEffect::prePaintScreen(ScreenPrePaintData& data, int time)
const qreal maxTime = 10.0;
void WobblyWindowsEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
{
if (windows.contains(w))
{
if (windows.contains(w)) {
data.setTransformed();
data.quads = data.quads.makeRegularGrid(m_xTesselation, m_yTesselation);
bool stop = false;
qreal updateTime = time;
while (!stop && (updateTime > maxTime))
{
while (!stop && (updateTime > maxTime)) {
#if defined VERBOSE_MODE
kDebug(1212) << "loop time " << updateTime << " / " << time;
#endif
stop = !updateWindowWobblyDatas(w, maxTime);
updateTime -= maxTime;
}
if (!stop && updateTime > 0)
{
if (!stop && updateTime > 0) {
updateWindowWobblyDatas(w, updateTime);
}
}
@ -335,8 +318,7 @@ void WobblyWindowsEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& da
void WobblyWindowsEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{
if(windows.contains(w))
{
if (windows.contains(w)) {
WindowWobblyInfos& wwi = windows[w];
int tx = w->geometry().x();
int ty = w->geometry().y();
@ -344,10 +326,8 @@ void WobblyWindowsEffect::paintWindow(EffectWindow* w, int mask, QRegion region,
double top = 0.0;
double right = w->width();
double bottom = w->height();
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];
Pair oldPos = {tx + v.x(), ty + v.y()};
Pair newPos = computeBezierPoint(wwi, oldPos);
@ -368,8 +348,7 @@ void WobblyWindowsEffect::paintWindow(EffectWindow* w, int mask, QRegion region,
void WobblyWindowsEffect::postPaintScreen()
{
if (!windows.isEmpty())
{
if (!windows.isEmpty()) {
effects->addRepaint(m_updateRegion);
}
@ -382,30 +361,23 @@ void WobblyWindowsEffect::windowUserMovedResized(EffectWindow* w, bool first, bo
if (!m_moveEffectEnabled || w->isSpecialWindow())
return;
if (first)
{
if(last && m_moveWobble && m_resizeWobble)
{
if (first) {
if (last && m_moveWobble && m_resizeWobble) {
// both first and last - a step change like Maximize
stepMovedResized(w);
}
else if ((w->isUserMove() && m_moveWobble) || (w->isUserResize() && m_resizeWobble))
{
} else if ((w->isUserMove() && m_moveWobble) || (w->isUserResize() && m_resizeWobble)) {
startMovedResized(w);
}
}
if (last)
{
if (windows.contains(w))
{
if (last) {
if (windows.contains(w)) {
WindowWobblyInfos& wwi = windows[w];
wwi.status = Free;
}
}
if (windows.contains(w))
{
if (windows.contains(w)) {
WindowWobblyInfos& wwi = windows[w];
QRect rect = w->geometry();
if (rect.y() != wwi.resize_original_rect.y()) wwi.can_wobble_top = true;
@ -418,8 +390,7 @@ void WobblyWindowsEffect::windowUserMovedResized(EffectWindow* w, bool first, bo
void WobblyWindowsEffect::startMovedResized(EffectWindow* w)
{
if (!windows.contains(w))
{
if (!windows.contains(w)) {
WindowWobblyInfos new_wwi;
initWobblyInfo(new_wwi, w->geometry());
windows[w] = new_wwi;
@ -436,13 +407,10 @@ void WobblyWindowsEffect::startMovedResized(EffectWindow* w)
int indx = (picked.x - rect.x()) / x_increment + 0.5;
int indy = (picked.y - rect.y()) / y_increment + 0.5;
int pickedPointIndex = indy * wwi.width + indx;
if (pickedPointIndex < 0)
{
if (pickedPointIndex < 0) {
kDebug(1212) << "Picked index == " << pickedPointIndex << " with (" << cursorPos().x() << "," << cursorPos().y() << ")";
pickedPointIndex = 0;
}
else if (static_cast<unsigned int>(pickedPointIndex) > wwi.count - 1)
{
} else if (static_cast<unsigned int>(pickedPointIndex) > wwi.count - 1) {
kDebug(1212) << "Picked index == " << pickedPointIndex << " with (" << cursorPos().x() << "," << cursorPos().y() << ")";
pickedPointIndex = wwi.count - 1;
}
@ -451,15 +419,12 @@ void WobblyWindowsEffect::startMovedResized(EffectWindow* w)
#endif
wwi.constraint[pickedPointIndex] = true;
if (w->isUserResize())
{
if (w->isUserResize()) {
// on a resize, do not allow any edges to wobble until it has been moved from
// its original location
wwi.can_wobble_top = wwi.can_wobble_left = wwi.can_wobble_right = wwi.can_wobble_bottom = false;
wwi.resize_original_rect = w->geometry();
}
else
{
} else {
wwi.can_wobble_top = wwi.can_wobble_left = wwi.can_wobble_right = wwi.can_wobble_bottom = true;
}
}
@ -467,8 +432,7 @@ void WobblyWindowsEffect::startMovedResized(EffectWindow* w)
void WobblyWindowsEffect::stepMovedResized(EffectWindow* w)
{
QRect new_geometry = w->geometry();
if (!windows.contains(w))
{
if (!windows.contains(w)) {
WindowWobblyInfos new_wwi;
initWobblyInfo(new_wwi, new_geometry);
windows[w] = new_wwi;
@ -481,20 +445,16 @@ void WobblyWindowsEffect::stepMovedResized(EffectWindow* w)
bool throb_direction_out = (new_geometry.top() == maximized_area.top() && new_geometry.bottom() == maximized_area.bottom()) ||
(new_geometry.left() == maximized_area.left() && new_geometry.right() == maximized_area.right());
qreal magnitude = throb_direction_out ? 10 : -30; // a small throb out when maximized, a larger throb inwards when restored
for (unsigned int j=0; j<wwi.height; ++j)
{
for (unsigned int i=0; i<wwi.width; ++i)
{
for (unsigned int j = 0; j < wwi.height; ++j) {
for (unsigned int i = 0; i < wwi.width; ++i) {
Pair v = { magnitude*(i / qreal(wwi.width - 1) - 0.5), magnitude*(j / qreal(wwi.height - 1) - 0.5) };
wwi.velocity[j*wwi.width+i] = v;
}
}
// constrain the middle of the window, so that any asymetry wont cause it to drift off-center
for (unsigned int j=1; j<wwi.height-1; ++j)
{
for (unsigned int i=1; i<wwi.width-1; ++i)
{
for (unsigned int j = 1; j < wwi.height - 1; ++j) {
for (unsigned int i = 1; i < wwi.width - 1; ++i) {
wwi.constraint[j*wwi.width+i] = true;
}
}
@ -502,16 +462,12 @@ void WobblyWindowsEffect::stepMovedResized(EffectWindow* w)
void WobblyWindowsEffect::windowAdded(EffectWindow* w)
{
if (m_openEffectEnabled && w->data( WindowAddedGrabRole ).value<void*>() != this)
{
if(windows.contains(w))
{
if (m_openEffectEnabled && w->data(WindowAddedGrabRole).value<void*>() != this) {
if (windows.contains(w)) {
// could this happen ??
WindowWobblyInfos& wwi = windows[w];
wobblyOpenInit(wwi);
}
else
{
} else {
WindowWobblyInfos new_wwi;
initWobblyInfo(new_wwi, w->geometry());
wobblyOpenInit(new_wwi);
@ -522,24 +478,18 @@ void WobblyWindowsEffect::windowAdded(EffectWindow* w)
void WobblyWindowsEffect::windowClosed(EffectWindow* w)
{
if(windows.contains(w))
{
if (windows.contains(w)) {
WindowWobblyInfos& wwi = windows[w];
if (m_closeEffectEnabled)
{
if (m_closeEffectEnabled) {
wobblyCloseInit(wwi, w);
w->refWindow();
}
else
{
} else {
freeWobblyInfo(wwi);
windows.remove(w);
if (windows.isEmpty())
effects->addRepaintFull();
}
}
else if (m_closeEffectEnabled && w->data( WindowAddedGrabRole ).value<void*>() != this)
{
} else if (m_closeEffectEnabled && w->data(WindowAddedGrabRole).value<void*>() != this) {
WindowWobblyInfos new_wwi;
initWobblyInfo(new_wwi, w->geometry());
wobblyCloseInit(new_wwi, w);
@ -552,10 +502,8 @@ void WobblyWindowsEffect::wobblyOpenInit(WindowWobblyInfos& wwi) const
{
Pair middle = { (wwi.origin[0].x + wwi.origin[15].x) / 2, (wwi.origin[0].y + wwi.origin[15].y) / 2 };
for (unsigned int j=0; j<4; ++j)
{
for (unsigned int i=0; i<4; ++i)
{
for (unsigned int j = 0; j < 4; ++j) {
for (unsigned int i = 0; i < 4; ++i) {
unsigned int idx = j * 4 + i;
wwi.constraint[idx] = false;
wwi.position[idx].x = (wwi.position[idx].x + 3 * middle.x) / 4;
@ -577,10 +525,8 @@ void WobblyWindowsEffect::wobblyCloseInit(WindowWobblyInfos& wwi, EffectWindow*
wwi.closeRect.setCoords(x1, y1, x2, y2);
// for closing, not yet used...
for (unsigned int j=0; j<4; ++j)
{
for (unsigned int i=0; i<4; ++i)
{
for (unsigned int j = 0; j < 4; ++j) {
for (unsigned int i = 0; i < 4; ++i) {
unsigned int idx = j * 4 + i;
wwi.constraint[idx] = false;
}
@ -618,33 +564,25 @@ void WobblyWindowsEffect::initWobblyInfo(WindowWobblyInfos& wwi, QRect geometry)
qreal x_increment = width / (wwi.width - 1.0);
qreal y_increment = height / (wwi.height - 1.0);
for (unsigned int j=0; j<4; ++j)
{
for (unsigned int i=0; i<4; ++i)
{
for (unsigned int j = 0; j < 4; ++j) {
for (unsigned int i = 0; i < 4; ++i) {
unsigned int idx = j * 4 + i;
wwi.origin[idx] = initValue;
wwi.position[idx] = initValue;
wwi.velocity[idx] = nullPair;
wwi.constraint[idx] = false;
if (i != 4-2) // x grid count - 2, i.e. not the last point
{
if (i != 4 - 2) { // x grid count - 2, i.e. not the last point
initValue.x += x_increment;
}
else
{
} else {
initValue.x = width + x;
}
initValue.x = initValue.x;
}
initValue.x = x;
initValue.x = initValue.x;
if (j != 4-2) // y grid count - 2, i.e. not the last point
{
if (j != 4 - 2) { // y grid count - 2, i.e. not the last point
initValue.y += y_increment;
}
else
{
} else {
initValue.y = height + y;
}
initValue.y = initValue.y;
@ -698,10 +636,8 @@ WobblyWindowsEffect::Pair WobblyWindowsEffect::computeBezierPoint(const WindowWo
Pair res = {0.0, 0.0};
for (unsigned int j = 0; j < 4; ++j)
{
for (unsigned int i = 0; i < 4; ++i)
{
for (unsigned int j = 0; j < 4; ++j) {
for (unsigned int i = 0; i < 4; ++i) {
// this assume the grid is 4*4
res.x += px[i] * py[j] * wwi.position[i + j * wwi.width].x;
res.y += px[i] * py[j] * wwi.position[i + j * wwi.width].y;
@ -716,34 +652,22 @@ namespace
static inline void fixVectorBounds(WobblyWindowsEffect::Pair& vec, qreal min, qreal max)
{
if (fabs(vec.x) < min)
{
if (fabs(vec.x) < min) {
vec.x = 0.0;
}
else if (fabs(vec.x) > max)
{
if (vec.x > 0.0)
{
} else if (fabs(vec.x) > max) {
if (vec.x > 0.0) {
vec.x = max;
}
else
{
} else {
vec.x = -max;
}
}
if (fabs(vec.y) < min)
{
if (fabs(vec.y) < min) {
vec.y = 0.0;
}
else if (fabs(vec.y) > max)
{
if (vec.y > 0.0)
{
} else if (fabs(vec.y) > max) {
if (vec.y > 0.0) {
vec.y = max;
}
else
{
} else {
vec.y = -max;
}
}
@ -751,20 +675,14 @@ static inline void fixVectorBounds(WobblyWindowsEffect::Pair& vec, qreal min, qr
static inline void computeVectorBounds(WobblyWindowsEffect::Pair& vec, WobblyWindowsEffect::Pair& bound)
{
if (fabs(vec.x) < bound.x)
{
if (fabs(vec.x) < bound.x) {
bound.x = fabs(vec.x);
}
else if (fabs(vec.x) > bound.y)
{
} else if (fabs(vec.x) > bound.y) {
bound.y = fabs(vec.x);
}
if (fabs(vec.y) < bound.x)
{
if (fabs(vec.y) < bound.x) {
bound.x = fabs(vec.y);
}
else if (fabs(vec.y) > bound.y)
{
} else if (fabs(vec.y) > bound.y) {
bound.y = fabs(vec.y);
}
}
@ -776,8 +694,7 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time)
QRectF rect = w->geometry();
WindowWobblyInfos& wwi = windows[w];
if (wwi.status == Closing)
{
if (wwi.status == Closing) {
rect = wwi.closeRect;
}
@ -791,27 +708,19 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time)
Pair origine = {rect.x(), rect.y()};
for (unsigned int j=0; j<wwi.height; ++j)
{
for (unsigned int i=0; i<wwi.width; ++i)
{
for (unsigned int j = 0; j < wwi.height; ++j) {
for (unsigned int i = 0; i < wwi.width; ++i) {
wwi.origin[wwi.width*j + i] = origine;
if (i != wwi.width-2)
{
if (i != wwi.width - 2) {
origine.x += x_length;
}
else
{
} else {
origine.x = rect.width() + rect.x();
}
}
origine.x = rect.x();
if (j != wwi.height-2)
{
if (j != wwi.height - 2) {
origine.y += y_length;
}
else
{
} else {
origine.y = rect.height() + rect.y();
}
}
@ -828,16 +737,13 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time)
// top-left
if (wwi.constraint[0])
{
if (wwi.constraint[0]) {
Pair window_pos = wwi.origin[0];
Pair current_pos = wwi.position[0];
Pair move = {window_pos.x - current_pos.x, window_pos.y - current_pos.y};
Pair accel = {move.x*m_stiffness, move.y*m_stiffness};
wwi.acceleration[0] = accel;
}
else
{
} else {
Pair& pos = wwi.position[0];
neibourgs[0] = wwi.position[1];
neibourgs[1] = wwi.position[wwi.width];
@ -853,16 +759,13 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time)
// top-right
if (wwi.constraint[wwi.width-1])
{
if (wwi.constraint[wwi.width-1]) {
Pair window_pos = wwi.origin[wwi.width-1];
Pair current_pos = wwi.position[wwi.width-1];
Pair move = {window_pos.x - current_pos.x, window_pos.y - current_pos.y};
Pair accel = {move.x*m_stiffness, move.y*m_stiffness};
wwi.acceleration[wwi.width-1] = accel;
}
else
{
} else {
Pair& pos = wwi.position[wwi.width-1];
neibourgs[0] = wwi.position[wwi.width-2];
neibourgs[1] = wwi.position[2*wwi.width-1];
@ -878,16 +781,13 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time)
// bottom-left
if (wwi.constraint[wwi.width*(wwi.height-1)])
{
if (wwi.constraint[wwi.width*(wwi.height-1)]) {
Pair window_pos = wwi.origin[wwi.width*(wwi.height-1)];
Pair current_pos = wwi.position[wwi.width*(wwi.height-1)];
Pair move = {window_pos.x - current_pos.x, window_pos.y - current_pos.y};
Pair accel = {move.x*m_stiffness, move.y*m_stiffness};
wwi.acceleration[wwi.width*(wwi.height-1)] = accel;
}
else
{
} else {
Pair& pos = wwi.position[wwi.width*(wwi.height-1)];
neibourgs[0] = wwi.position[wwi.width*(wwi.height-1)+1];
neibourgs[1] = wwi.position[wwi.width*(wwi.height-2)];
@ -903,16 +803,13 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time)
// bottom-right
if (wwi.constraint[wwi.count-1])
{
if (wwi.constraint[wwi.count-1]) {
Pair window_pos = wwi.origin[wwi.count-1];
Pair current_pos = wwi.position[wwi.count-1];
Pair move = {window_pos.x - current_pos.x, window_pos.y - current_pos.y};
Pair accel = {move.x*m_stiffness, move.y*m_stiffness};
wwi.acceleration[wwi.count-1] = accel;
}
else
{
} else {
Pair& pos = wwi.position[wwi.count-1];
neibourgs[0] = wwi.position[wwi.count-2];
neibourgs[1] = wwi.position[wwi.width*(wwi.height-1)-1];
@ -930,18 +827,14 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time)
// for borders
// top border
for (unsigned int i=1; i<wwi.width-1; ++i)
{
if (wwi.constraint[i])
{
for (unsigned int i = 1; i < wwi.width - 1; ++i) {
if (wwi.constraint[i]) {
Pair window_pos = wwi.origin[i];
Pair current_pos = wwi.position[i];
Pair move = {window_pos.x - current_pos.x, window_pos.y - current_pos.y};
Pair accel = {move.x*m_stiffness, move.y*m_stiffness};
wwi.acceleration[i] = accel;
}
else
{
} else {
Pair& pos = wwi.position[i];
neibourgs[0] = wwi.position[i-1];
neibourgs[1] = wwi.position[i+1];
@ -958,18 +851,14 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time)
}
// bottom border
for (unsigned int i=wwi.width*(wwi.height-1)+1; i<wwi.count-1; ++i)
{
if (wwi.constraint[i])
{
for (unsigned int i = wwi.width * (wwi.height - 1) + 1; i < wwi.count - 1; ++i) {
if (wwi.constraint[i]) {
Pair window_pos = wwi.origin[i];
Pair current_pos = wwi.position[i];
Pair move = {window_pos.x - current_pos.x, window_pos.y - current_pos.y};
Pair accel = {move.x*m_stiffness, move.y*m_stiffness};
wwi.acceleration[i] = accel;
}
else
{
} else {
Pair& pos = wwi.position[i];
neibourgs[0] = wwi.position[i-1];
neibourgs[1] = wwi.position[i+1];
@ -986,18 +875,14 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time)
}
// left border
for (unsigned int i=wwi.width; i<wwi.width*(wwi.height-1); i+=wwi.width)
{
if (wwi.constraint[i])
{
for (unsigned int i = wwi.width; i < wwi.width*(wwi.height - 1); i += wwi.width) {
if (wwi.constraint[i]) {
Pair window_pos = wwi.origin[i];
Pair current_pos = wwi.position[i];
Pair move = {window_pos.x - current_pos.x, window_pos.y - current_pos.y};
Pair accel = {move.x*m_stiffness, move.y*m_stiffness};
wwi.acceleration[i] = accel;
}
else
{
} else {
Pair& pos = wwi.position[i];
neibourgs[0] = wwi.position[i+1];
neibourgs[1] = wwi.position[i-wwi.width];
@ -1014,18 +899,14 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time)
}
// right border
for (unsigned int i=2*wwi.width-1; i<wwi.count-1; i+=wwi.width)
{
if (wwi.constraint[i])
{
for (unsigned int i = 2 * wwi.width - 1; i < wwi.count - 1; i += wwi.width) {
if (wwi.constraint[i]) {
Pair window_pos = wwi.origin[i];
Pair current_pos = wwi.position[i];
Pair move = {window_pos.x - current_pos.x, window_pos.y - current_pos.y};
Pair accel = {move.x*m_stiffness, move.y*m_stiffness};
wwi.acceleration[i] = accel;
}
else
{
} else {
Pair& pos = wwi.position[i];
neibourgs[0] = wwi.position[i-1];
neibourgs[1] = wwi.position[i-wwi.width];
@ -1042,22 +923,17 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time)
}
// for the inner points
for (unsigned int j=1; j<wwi.height-1; ++j)
{
for (unsigned int i=1; i<wwi.width-1; ++i)
{
for (unsigned int j = 1; j < wwi.height - 1; ++j) {
for (unsigned int i = 1; i < wwi.width - 1; ++i) {
unsigned int index = i + j * wwi.width;
if (wwi.constraint[index])
{
if (wwi.constraint[index]) {
Pair window_pos = wwi.origin[index];
Pair current_pos = wwi.position[index];
Pair move = {window_pos.x - current_pos.x, window_pos.y - current_pos.y};
Pair accel = {move.x*m_stiffness, move.y*m_stiffness};
wwi.acceleration[index] = accel;
}
else
{
} else {
Pair& pos = wwi.position[index];
neibourgs[0] = wwi.position[index-1];
neibourgs[1] = wwi.position[index+1];
@ -1089,8 +965,7 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time)
#endif
// compute the new velocity of each vertex.
for (unsigned int i = 0; i < wwi.count; ++i)
{
for (unsigned int i = 0; i < wwi.count; ++i) {
Pair acc = wwi.acceleration[i];
fixVectorBounds(acc, m_minAcceleration, m_maxAcceleration);
@ -1108,8 +983,7 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time)
heightRingLinearMean(&wwi.velocity, wwi);
// compute the new pos of each vertex.
for (unsigned int i = 0; i < wwi.count; ++i)
{
for (unsigned int i = 0; i < wwi.count; ++i) {
Pair& pos = wwi.position[i];
Pair& vel = wwi.velocity[i];
@ -1124,33 +998,28 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time)
vel_sum += fabs(vel.x) + fabs(vel.y);
#if defined VERBOSE_MODE
if (wwi.constraint[i])
{
if (wwi.constraint[i]) {
kDebug(1212) << "Constraint point ** vel : " << vel.x << "," << vel.y << " ** move : " << vel.x*time << "," << vel.y*time;
}
#endif
}
if(!wwi.can_wobble_top)
{
if (!wwi.can_wobble_top) {
for (unsigned int i = 0; i < wwi.width; ++i)
for (unsigned j = 0; j < wwi.width - 1; ++j)
wwi.position[i+wwi.width*j].y = wwi.origin[i+wwi.width*j].y;
}
if(!wwi.can_wobble_bottom)
{
if (!wwi.can_wobble_bottom) {
for (unsigned int i = wwi.width * (wwi.height - 1); i < wwi.count; ++i)
for (unsigned j = 0; j < wwi.width - 1; ++j)
wwi.position[i-wwi.width*j].y = wwi.origin[i-wwi.width*j].y;
}
if(!wwi.can_wobble_left)
{
if (!wwi.can_wobble_left) {
for (unsigned int i = 0; i < wwi.count; i += wwi.width)
for (unsigned j = 0; j < wwi.width - 1; ++j)
wwi.position[i+j].x = wwi.origin[i+j].x;
}
if(!wwi.can_wobble_right)
{
if (!wwi.can_wobble_right) {
for (unsigned int i = wwi.width - 1; i < wwi.count; i += wwi.width)
for (unsigned j = 0; j < wwi.width - 1; ++j)
wwi.position[i-j].x = wwi.origin[i-j].x;
@ -1164,10 +1033,8 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time)
kDebug(1212) << "sum_acc : " << acc_sum << " *** sum_vel :" << vel_sum;
#endif
if (wwi.status != Moving && acc_sum < m_stopAcceleration && vel_sum < m_stopVelocity)
{
if (wwi.status == Closing)
{
if (wwi.status != Moving && acc_sum < m_stopAcceleration && vel_sum < m_stopVelocity) {
if (wwi.status == Closing) {
w->unrefWindow();
}
freeWobblyInfo(wwi);
@ -1242,8 +1109,7 @@ void WobblyWindowsEffect::heightRingLinearMean(Pair** data_pointer, WindowWobbly
// for borders
// top border
for (unsigned int i=1; i<wwi.width-1; ++i)
{
for (unsigned int i = 1; i < wwi.width - 1; ++i) {
Pair& res = wwi.buffer[i];
Pair vit = data[i];
neibourgs[0] = data[i-1];
@ -1257,8 +1123,7 @@ void WobblyWindowsEffect::heightRingLinearMean(Pair** data_pointer, WindowWobbly
}
// bottom border
for (unsigned int i=wwi.width*(wwi.height-1)+1; i<wwi.count-1; ++i)
{
for (unsigned int i = wwi.width * (wwi.height - 1) + 1; i < wwi.count - 1; ++i) {
Pair& res = wwi.buffer[i];
Pair vit = data[i];
neibourgs[0] = data[i-1];
@ -1272,8 +1137,7 @@ void WobblyWindowsEffect::heightRingLinearMean(Pair** data_pointer, WindowWobbly
}
// left border
for (unsigned int i=wwi.width; i<wwi.width*(wwi.height-1); i+=wwi.width)
{
for (unsigned int i = wwi.width; i < wwi.width*(wwi.height - 1); i += wwi.width) {
Pair& res = wwi.buffer[i];
Pair vit = data[i];
neibourgs[0] = data[i+1];
@ -1287,8 +1151,7 @@ void WobblyWindowsEffect::heightRingLinearMean(Pair** data_pointer, WindowWobbly
}
// right border
for (unsigned int i=2*wwi.width-1; i<wwi.count-1; i+=wwi.width)
{
for (unsigned int i = 2 * wwi.width - 1; i < wwi.count - 1; i += wwi.width) {
Pair& res = wwi.buffer[i];
Pair vit = data[i];
neibourgs[0] = data[i-1];
@ -1302,10 +1165,8 @@ void WobblyWindowsEffect::heightRingLinearMean(Pair** data_pointer, WindowWobbly
}
// for the inner points
for (unsigned int j=1; j<wwi.height-1; ++j)
{
for (unsigned int i=1; i<wwi.width-1; ++i)
{
for (unsigned int j = 1; j < wwi.height - 1; ++j) {
for (unsigned int i = 1; i < wwi.width - 1; ++i) {
unsigned int index = i + j * wwi.width;
Pair& res = wwi.buffer[index];

View File

@ -44,14 +44,12 @@ class WobblyWindowsEffect : public Effect
void setVelocityThreshold(qreal velocityThreshold);
void setMoveFactor(qreal factor);
struct Pair
{
struct Pair {
qreal x;
qreal y;
};
enum WindowStatus
{
enum WindowStatus {
Free,
Moving,
Openning,
@ -66,8 +64,7 @@ class WobblyWindowsEffect : public Effect
void stepMovedResized(EffectWindow* w);
bool updateWindowWobblyDatas(EffectWindow* w, qreal time);
struct WindowWobblyInfos
{
struct WindowWobblyInfos {
Pair* origin;
Pair* position;
Pair* velocity;

View File

@ -36,43 +36,37 @@ KWIN_EFFECT_CONFIG_FACTORY
//-----------------------------------------------------------------------------
// WARNING: This is (kinda) copied from wobblywindows.cpp
struct ParameterSet
{
struct ParameterSet {
int stiffness;
int drag;
int move_factor;
};
ParameterSet set_0 =
{
ParameterSet set_0 = {
15,
80,
10
};
ParameterSet set_1 =
{
ParameterSet set_1 = {
10,
85,
10
};
ParameterSet set_2 =
{
ParameterSet set_2 = {
6,
90,
10
};
ParameterSet set_3 =
{
ParameterSet set_3 = {
3,
92,
20
};
ParameterSet set_4 =
{
ParameterSet set_4 = {
1,
97,
25
@ -113,13 +107,11 @@ void WobblyWindowsEffectConfig::load()
unsigned int wobblynessLevel = 0;
QString settingsMode = conf.readEntry("Settings", "Auto");
if (settingsMode != "Custom")
{
if (settingsMode != "Custom") {
wobblynessLevel = conf.readEntry("WobblynessLevel", 0);
change = false;
}
if (wobblynessLevel > 4)
{
if (wobblynessLevel > 4) {
wobblynessLevel = 4;
change = true;
}

View File

@ -43,8 +43,7 @@ namespace KWin
static int nominalCursorSize(int iconSize)
{
for(int i = 512; i > 8; i /= 2)
{
for (int i = 512; i > 8; i /= 2) {
if (i < iconSize)
return i;
if ((i * .75) < iconSize)
@ -131,8 +130,7 @@ ZoomEffect::~ZoomEffect()
void ZoomEffect::showCursor()
{
#if defined(KWIN_HAVE_OPENGL_COMPOSITING) || defined(KWIN_HAVE_XRENDER_COMPOSITING)
if( isMouseHidden )
{
if (isMouseHidden) {
// show the previously hidden mouse-pointer again and free the loaded texture/picture.
Display* display = QX11Info::display();
XFixesShowCursor(display, DefaultRootWindow(display));
@ -148,12 +146,10 @@ void ZoomEffect::showCursor()
void ZoomEffect::hideCursor()
{
#if defined(KWIN_HAVE_OPENGL_COMPOSITING) || defined(KWIN_HAVE_XRENDER_COMPOSITING)
if( !isMouseHidden )
{
if (!isMouseHidden) {
// try to load the cursor-theme into a OpenGL texture and if successful then hide the mouse-pointer
recreateTexture();
if( texture || xrenderPicture )
{
if (texture || xrenderPicture) {
Display* display = QX11Info::display();
XFixesHideCursor(display, DefaultRootWindow(display));
isMouseHidden = true;
@ -171,12 +167,10 @@ void ZoomEffect::recreateTexture()
// try to find the to the theme-name matching cursor-directory.
QByteArray themePath;
foreach (const QString &baseDir, QString(XcursorLibraryPath()).split(':', QString::SkipEmptyParts))
{
foreach (const QString & baseDir, QString(XcursorLibraryPath()).split(':', QString::SkipEmptyParts)) {
QDir dir(baseDir);
if (!dir.exists()) continue;
if(!theme.isEmpty() && dir.cd(theme))
{
if (!theme.isEmpty() && dir.cd(theme)) {
themePath = QFile::encodeName(dir.absolutePath());
break; // theme found, job is done and we can abort the search now
}
@ -192,8 +186,7 @@ void ZoomEffect::recreateTexture()
// load the cursor-theme image from the Xcursor-library
XcursorImage *ximg = XcursorLibraryLoadImage("left_ptr", themePath, nominalCursorSize(iconSize));
if (ximg)
{
if (ximg) {
// turn the XcursorImage into a QImage that will be used to create the GLTexture/XRenderPicture.
imageWidth = ximg->width;
imageHeight = ximg->height;
@ -221,11 +214,9 @@ void ZoomEffect::reconfigure( ReconfigureFlags )
mouseTracking = MouseTrackingType(conf.readEntry("MouseTracking", int(mouseTracking)));
// Enable tracking of the focused location.
bool _enableFocusTracking = conf.readEntry("EnableFocusTracking", enableFocusTracking);
if(enableFocusTracking != _enableFocusTracking)
{
if (enableFocusTracking != _enableFocusTracking) {
enableFocusTracking = _enableFocusTracking;
if(QDBusConnection::sessionBus().isConnected())
{
if (QDBusConnection::sessionBus().isConnected()) {
if (enableFocusTracking)
QDBusConnection::sessionBus().connect("org.kde.kaccessibleapp", "/Adaptor", "org.kde.kaccessibleapp.Adaptor", "focusChanged", this, SLOT(focusChanged(int, int, int, int, int, int)));
else
@ -242,8 +233,7 @@ void ZoomEffect::reconfigure( ReconfigureFlags )
void ZoomEffect::prePaintScreen(ScreenPrePaintData& data, int time)
{
if( zoom != target_zoom )
{
if (zoom != target_zoom) {
double diff = time / animationTime(500.0);
if (target_zoom > zoom)
zoom = qMin(zoom * qMax(1 + diff, 1.2), target_zoom);
@ -251,12 +241,9 @@ void ZoomEffect::prePaintScreen( ScreenPrePaintData& data, int time )
zoom = qMax(zoom * qMin(1 - diff, 0.8), target_zoom);
}
if( zoom == 1.0 )
{
if (zoom == 1.0) {
showCursor();
}
else
{
} else {
hideCursor();
data.mask |= PAINT_SCREEN_TRANSFORMED;
}
@ -266,14 +253,12 @@ void ZoomEffect::prePaintScreen( ScreenPrePaintData& data, int time )
void ZoomEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
{
if( zoom != 1.0 )
{
if (zoom != 1.0) {
data.xScale *= zoom;
data.yScale *= zoom;
// mouse-tracking allows navigation of the zoom-area using the mouse.
switch( mouseTracking )
{
switch(mouseTracking) {
case MouseTrackingProportional:
data.xTranslate = - int(cursorPoint.x() * (zoom - 1.0));
data.yTranslate = - int(cursorPoint.y() * (zoom - 1.0));
@ -285,8 +270,7 @@ void ZoomEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
prevPoint = cursorPoint;
break;
case MouseTrackingPush:
if( timeline.state() != QTimeLine::Running )
{
if (timeline.state() != QTimeLine::Running) {
// touching an edge of the screen moves the zoom-area in that direction.
int x = cursorPoint.x() * zoom - prevPoint.x() * (zoom - 1.0);
int y = cursorPoint.y() * zoom - prevPoint.y() * (zoom - 1.0);
@ -300,8 +284,7 @@ void ZoomEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
yMove = - qMax(1.0, displayHeight() / zoom / moveFactor);
else if (y + threshold > displayHeight())
yMove = qMax(1.0, displayHeight() / zoom / moveFactor);
if( xMove != 0 || yMove != 0 )
{
if (xMove != 0 || yMove != 0) {
prevPoint.setX(qMax(0, qMin(displayWidth(), prevPoint.x() + xMove)));
prevPoint.setY(qMax(0, qMin(displayHeight(), prevPoint.y() + yMove)));
timeline.start();
@ -315,18 +298,15 @@ void ZoomEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
}
// use the focusPoint if focus tracking is enabled
if(enableFocusTracking && followFocus)
{
if (enableFocusTracking && followFocus) {
bool acceptFocus = true;
if(mouseTracking != MouseTrackingDisabled && focusDelay > 0)
{
if (mouseTracking != MouseTrackingDisabled && focusDelay > 0) {
// Wait some time for the mouse before doing the switch. This serves as threshold
// to prevent the focus from jumping around to much while working with the mouse.
const int msecs = lastMouseEvent.msecsTo(lastFocusEvent);
acceptFocus = msecs > focusDelay;
}
if(acceptFocus)
{
if (acceptFocus) {
data.xTranslate = - int(focusPoint.x() * (zoom - 1.0));
data.yTranslate = - int(focusPoint.y() * (zoom - 1.0));
prevPoint = focusPoint;
@ -336,14 +316,12 @@ void ZoomEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
effects->paintScreen(mask, region, data);
if( zoom != 1.0 && mousePointer != MousePointerHide )
{
if (zoom != 1.0 && mousePointer != MousePointerHide) {
// Draw the mouse-texture at the position matching to zoomed-in image of the desktop. Hiding the
// previous mouse-cursor and drawing our own fake mouse-cursor is needed to be able to scale the
// mouse-cursor up and to re-position those mouse-cursor to match to the chosen zoom-level.
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
if( texture )
{
if (texture) {
#ifndef KWIN_HAVE_OPENGLES
glPushAttrib(GL_CURRENT_BIT | GL_ENABLE_BIT);
#endif
@ -352,8 +330,7 @@ void ZoomEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
int w = imageWidth;
int h = imageHeight;
if( mousePointer == MousePointerScale )
{
if (mousePointer == MousePointerScale) {
w *= zoom;
h *= zoom;
}
@ -368,8 +345,7 @@ void ZoomEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
}
#endif
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
if( xrenderPicture )
{
if (xrenderPicture) {
QPoint p = QCursor::pos();
QRect rect(p.x() * zoom + data.xTranslate, p.y() * zoom + data.yTranslate, imageWidth, imageHeight);
XRenderComposite(display(), PictOpOver, *xrenderPicture, None, effects->xrenderBufferPicture(), 0, 0, 0, 0, rect.x(), rect.y(), rect.width(), rect.height());
@ -388,8 +364,7 @@ void ZoomEffect::postPaintScreen()
void ZoomEffect::zoomIn()
{
target_zoom *= zoomFactor;
if( !polling )
{
if (!polling) {
polling = true;
effects->startMousePolling();
}
@ -399,11 +374,9 @@ void ZoomEffect::zoomIn()
void ZoomEffect::zoomOut()
{
target_zoom /= zoomFactor;
if( target_zoom < 1 )
{
if (target_zoom < 1) {
target_zoom = 1;
if( polling )
{
if (polling) {
polling = false;
effects->stopMousePolling();
}
@ -414,8 +387,7 @@ void ZoomEffect::zoomOut()
void ZoomEffect::actualSize()
{
target_zoom = 1;
if( polling )
{
if (polling) {
polling = false;
effects->stopMousePolling();
}
@ -490,8 +462,7 @@ void ZoomEffect::mouseChanged( const QPoint& pos, const QPoint& old, Qt::MouseBu
if (zoom == 1.0)
return;
cursorPoint = pos;
if( pos != old )
{
if (pos != old) {
lastMouseEvent = QTime::currentTime();
effects->addRepaintFull();
}
@ -502,8 +473,7 @@ void ZoomEffect::focusChanged(int px, int py, int rx, int ry, int rwidth, int rh
if (zoom == 1.0)
return;
focusPoint = (px >= 0 && py >= 0) ? QPoint(px, py) : QPoint(rx + qMax(0, (qMin(displayWidth(), rwidth) / 2) - 60), ry + qMax(0, (qMin(displayHeight(), rheight) / 2) - 60));
if( enableFocusTracking )
{
if (enableFocusTracking) {
lastFocusEvent = QTime::currentTime();
effects->addRepaintFull();
}

File diff suppressed because it is too large Load Diff

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