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

View File

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

View File

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

View File

@ -56,7 +56,8 @@ class QProcess;
class QTimer; class QTimer;
class KStartupInfoData; class KStartupInfoData;
namespace SWrapper { namespace SWrapper
{
class Client; class Client;
} }
@ -64,7 +65,8 @@ typedef QPair<SWrapper::Client*, QScriptValue> ClientResolution;
namespace KWin namespace KWin
{ {
namespace TabBox { namespace TabBox
{
class TabBoxClientImpl; class TabBoxClientImpl;
} }
@ -139,8 +141,7 @@ class Client
void destroyClient(); void destroyClient();
/// How to resize the window in order to obey constains (mainly aspect ratios) /// How to resize the window in order to obey constains (mainly aspect ratios)
enum Sizemode enum Sizemode {
{
SizemodeAny, SizemodeAny,
SizemodeFixedW, ///< Try not to affect width SizemodeFixedW, ///< Try not to affect width
SizemodeFixedH, ///< Try not to affect height SizemodeFixedH, ///< Try not to affect height
@ -191,8 +192,12 @@ class Client
bool isFullScreenable(bool fullscreen_hack = false) const; bool isFullScreenable(bool fullscreen_hack = false) const;
bool isActiveFullScreen() const; bool isActiveFullScreen() const;
bool userCanSetFullScreen() const; bool userCanSetFullScreen() const;
QRect geometryFSRestore() const { return geom_fs_restore; } // Only for session saving QRect geometryFSRestore() const {
int fullScreenMode() const { return fullscreen_mode; } // only for session saving return geom_fs_restore; // Only for session saving
}
int fullScreenMode() const {
return fullscreen_mode; // only for session saving
}
bool noBorder() const; bool noBorder() const;
void setNoBorder(bool set); void setNoBorder(bool set);
@ -358,25 +363,39 @@ class Client
*/ */
bool hasOffscreenXineramaStrut() const; bool hasOffscreenXineramaStrut() const;
bool isMove() const bool isMove() const {
{
return moveResizeMode && mode == PositionCenter; return moveResizeMode && mode == PositionCenter;
} }
bool isResize() const bool isResize() const {
{
return moveResizeMode && mode != PositionCenter; return moveResizeMode && mode != PositionCenter;
} }
// Decorations <-> Effects // Decorations <-> Effects
const QPixmap *topDecoPixmap() const { return &decorationPixmapTop; } const QPixmap *topDecoPixmap() const {
const QPixmap *leftDecoPixmap() const { return &decorationPixmapLeft; } return &decorationPixmapTop;
const QPixmap *bottomDecoPixmap() const { return &decorationPixmapBottom; } }
const QPixmap *rightDecoPixmap() const { return &decorationPixmapRight; } const QPixmap *leftDecoPixmap() const {
return &decorationPixmapLeft;
}
const QPixmap *bottomDecoPixmap() const {
return &decorationPixmapBottom;
}
const QPixmap *rightDecoPixmap() const {
return &decorationPixmapRight;
}
int paddingLeft() const { return padding_left; } int paddingLeft() const {
int paddingRight() const { return padding_right; } return padding_left;
int paddingTop() const { return padding_top; } }
int paddingBottom() const { return padding_bottom; } int paddingRight() const {
return padding_right;
}
int paddingTop() const {
return padding_top;
}
int paddingBottom() const {
return padding_bottom;
}
bool decorationPixmapRequiresRepaint(); bool decorationPixmapRequiresRepaint();
void ensureDecorationPixmapsPainted(); void ensureDecorationPixmapsPainted();
@ -398,7 +417,9 @@ class Client
void layoutDecorationRects(QRect &left, QRect &top, QRect &right, QRect &bottom, CoordinateMode mode) const; void layoutDecorationRects(QRect &left, QRect &top, QRect &right, QRect &bottom, CoordinateMode mode) const;
virtual void addRepaintFull(); 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 //sets whether the client should be treated as a SessionInteract window
void setSessionInteract(bool needed); void setSessionInteract(bool needed);
@ -568,8 +589,7 @@ class Client
QRect initialMoveResizeGeom; QRect initialMoveResizeGeom;
XSizeHints xSizeHint; XSizeHints xSizeHint;
void sendSyntheticConfigureNotify(); void sendSyntheticConfigureNotify();
enum MappingState enum MappingState {
{
Withdrawn, ///< Not handled, as per ICCCM WithdrawnState Withdrawn, ///< Not handled, as per ICCCM WithdrawnState
Mapped, ///< The frame is mapped Mapped, ///< The frame is mapped
Unmapped, ///< The frame is not mapped Unmapped, ///< The frame is not mapped
@ -631,8 +651,7 @@ class Client
QPixmap hugeicon_pix; QPixmap hugeicon_pix;
QCursor cursor; QCursor cursor;
// DON'T reorder - Saved to config files !!! // DON'T reorder - Saved to config files !!!
enum FullScreenMode enum FullScreenMode {
{
FullScreenNone, FullScreenNone,
FullScreenNormal, FullScreenNormal,
FullScreenHack ///< Non-NETWM fullscreen (noborder and size of desktop) FullScreenHack ///< Non-NETWM fullscreen (noborder and size of desktop)
@ -658,8 +677,7 @@ class Client
unsigned long allowed_actions; unsigned long allowed_actions;
QSize client_size; QSize client_size;
int block_geometry_updates; // > 0 = New geometry is remembered, but not actually set int block_geometry_updates; // > 0 = New geometry is remembered, but not actually set
enum PendingGeometry_t enum PendingGeometry_t {
{
PendingGeometryNone, PendingGeometryNone,
PendingGeometryNormal, PendingGeometryNormal,
PendingGeometryForced PendingGeometryForced
@ -709,9 +727,12 @@ class GeometryUpdatesBlocker
{ {
public: public:
GeometryUpdatesBlocker(Client* c) GeometryUpdatesBlocker(Client* c)
: cl( c ) { cl->blockGeometryUpdates( true ); } : cl(c) {
~GeometryUpdatesBlocker() cl->blockGeometryUpdates(true);
{ cl->blockGeometryUpdates( false ); } }
~GeometryUpdatesBlocker() {
cl->blockGeometryUpdates(false);
}
private: private:
Client* cl; 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 change the geometry of other clients in their current group by accident. However
// don't REMOVE them from the actual group until we are certain that the client will be moved. // don't REMOVE them from the actual group until we are certain that the client will be moved.
ClientGroup* oldGroup = NULL; ClientGroup* oldGroup = NULL;
if( c->clientGroup() ) if (c->clientGroup()) {
{
oldGroup = c->clientGroup(); oldGroup = c->clientGroup();
c->setClientGroup(NULL); c->setClientGroup(NULL);
} }
@ -67,8 +66,7 @@ void ClientGroup::add( Client* c, int before, bool becomeVisible )
ShadeMode oldShadeMode = c->shadeMode(); ShadeMode oldShadeMode = c->shadeMode();
if (c->shadeMode() != clients_[visible_]->shadeMode()) if (c->shadeMode() != clients_[visible_]->shadeMode())
c->setShade(clients_[visible_]->shadeMode()); c->setShade(clients_[visible_]->shadeMode());
if( c->shadeMode() != clients_[visible_]->shadeMode() ) if (c->shadeMode() != clients_[visible_]->shadeMode()) {
{
if (oldGroup) // Re-add to old group if required if (oldGroup) // Re-add to old group if required
c->setClientGroup(oldGroup); c->setClientGroup(oldGroup);
// One need to trigger decoration repaint on the group to // One need to trigger decoration repaint on the group to
@ -79,8 +77,7 @@ void ClientGroup::add( Client* c, int before, bool becomeVisible )
QRect oldGeom = c->geometry(); QRect oldGeom = c->geometry();
if (c->geometry() != clients_[visible_]->geometry()) if (c->geometry() != clients_[visible_]->geometry())
c->setGeometry(clients_[visible_]->geometry()); c->setGeometry(clients_[visible_]->geometry());
if( c->geometry() != clients_[visible_]->geometry() ) if (c->geometry() != clients_[visible_]->geometry()) {
{
if (c->shadeMode() != oldShadeMode) if (c->shadeMode() != oldShadeMode)
c->setShade(oldShadeMode); // Restore old shade mode c->setShade(oldShadeMode); // Restore old shade mode
if (oldGroup) // Re-add to old group if required if (oldGroup) // Re-add to old group if required
@ -90,8 +87,7 @@ void ClientGroup::add( Client* c, int before, bool becomeVisible )
} }
if (c->desktop() != clients_[visible_]->desktop()) if (c->desktop() != clients_[visible_]->desktop())
c->setDesktop(clients_[visible_]->desktop()); c->setDesktop(clients_[visible_]->desktop());
if( c->desktop() != clients_[visible_]->desktop() ) if (c->desktop() != clients_[visible_]->desktop()) {
{
if (c->geometry() != oldGeom) if (c->geometry() != oldGeom)
c->setGeometry(oldGeom); // Restore old geometry c->setGeometry(oldGeom); // Restore old geometry
if (c->shadeMode() != oldShadeMode) if (c->shadeMode() != oldShadeMode)
@ -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 c->setClientGroup(this); // Let the client know which group it belongs to
// Actually add to new group // Actually add to new group
if( before >= 0 ) if (before >= 0) {
{
if (visible_ >= before) if (visible_ >= before)
visible_++; visible_++;
clients_.insert(before, c); clients_.insert(before, c);
} } else
else
clients_.append(c); clients_.append(c);
if (!becomeVisible) // Hide before adding if (!becomeVisible) // Hide before adding
c->setClientShown(false); c->setClientShown(false);
@ -157,8 +151,7 @@ void ClientGroup::remove( Client* c, const QRect& newGeom, bool toNullGroup )
{ {
if (!c) if (!c)
return; return;
if( clients_.count() < 2 ) if (clients_.count() < 2) {
{
c->setClientGroup(NULL); c->setClientGroup(NULL);
Workspace::self()->removeClientGroup(this); // Remove immediately Workspace::self()->removeClientGroup(this); // Remove immediately
delete this; delete this;
@ -182,8 +175,7 @@ void ClientGroup::remove( Client* c, const QRect& newGeom, bool toNullGroup )
updateMinMaxSize(); updateMinMaxSize();
c->setClientGroup(toNullGroup ? NULL : new ClientGroup(c)); c->setClientGroup(toNullGroup ? NULL : new ClientGroup(c));
if( newGeom.isValid() ) if (newGeom.isValid()) {
{
// HACK: if the group was maximized, one needs to make some checks on the future client maximize mode // HACK: if the group was maximized, one needs to make some checks on the future client maximize mode
// because the transition from maximized to MaximizeRestore is not handled properly in setGeometry when // because the transition from maximized to MaximizeRestore is not handled properly in setGeometry when
// the new geometry size is unchanged. // the new geometry size is unchanged.
@ -209,8 +201,7 @@ void ClientGroup::closeAll()
{ {
Client* front; Client* front;
ClientList list(clients_); ClientList list(clients_);
while( !list.isEmpty() ) while (!list.isEmpty()) {
{
front = list.front(); front = list.front();
list.pop_front(); list.pop_front();
if (front != clients_[visible_]) if (front != clients_[visible_])
@ -280,10 +271,8 @@ void ClientGroup::setVisible( Client* c )
void ClientGroup::updateStates(Client* main, Client* only) void ClientGroup::updateStates(Client* main, Client* only)
{ {
for (ClientList::const_iterator i = clients_.constBegin(); i != clients_.constEnd(); i++) for (ClientList::const_iterator i = clients_.constBegin(); i != clients_.constEnd(); i++)
if( (*i) != main && ( !only || (*i) == only )) if ((*i) != main && (!only || (*i) == only)) {
{ if ((*i)->isMinimized() != main->isMinimized()) {
if( (*i)->isMinimized() != main->isMinimized() )
{
if (main->isMinimized()) if (main->isMinimized())
(*i)->minimize(true); (*i)->minimize(true);
else else
@ -315,8 +304,7 @@ void ClientGroup::updateStates( Client* main, Client* only )
void ClientGroup::updateItems() void ClientGroup::updateItems()
{ {
items_.clear(); items_.clear();
for( ClientList::const_iterator i = clients_.constBegin(); i != clients_.constEnd(); ++i ) for (ClientList::const_iterator i = clients_.constBegin(); i != clients_.constEnd(); ++i) {
{
QIcon icon((*i)->icon()); QIcon icon((*i)->icon());
icon.addPixmap((*i)->miniIcon()); icon.addPixmap((*i)->miniIcon());
items_.append(ClientGroupItem((*i)->caption(), icon)); items_.append(ClientGroupItem((*i)->caption(), icon));
@ -328,8 +316,7 @@ void ClientGroup::updateMinMaxSize()
// Determine entire group's minimum and maximum sizes // Determine entire group's minimum and maximum sizes
minSize_ = QSize(0, 0); minSize_ = QSize(0, 0);
maxSize_ = QSize(INT_MAX, INT_MAX); maxSize_ = QSize(INT_MAX, INT_MAX);
for( ClientList::const_iterator i = clients_.constBegin(); i != clients_.constEnd(); ++i ) for (ClientList::const_iterator i = clients_.constBegin(); i != clients_.constEnd(); ++i) {
{
if ((*i)->minSize().width() > minSize_.width()) if ((*i)->minSize().width() > minSize_.width())
minSize_.setWidth((*i)->minSize().width()); minSize_.setWidth((*i)->minSize().width());
if ((*i)->minSize().height() > minSize_.height()) if ((*i)->minSize().height() > minSize_.height())
@ -340,8 +327,7 @@ void ClientGroup::updateMinMaxSize()
maxSize_.setHeight((*i)->maxSize().height()); maxSize_.setHeight((*i)->maxSize().height());
} }
if (minSize_.width() > maxSize_.width() || if (minSize_.width() > maxSize_.width() ||
minSize_.height() > maxSize_.height() ) minSize_.height() > maxSize_.height()) {
{
//kWarning(1212) << "ClientGroup's min size is greater than its max size. Setting max to min."; //kWarning(1212) << "ClientGroup's min size is greater than its max size. Setting max to min.";
maxSize_ = minSize_; maxSize_ = minSize_;
} }

View File

@ -50,7 +50,8 @@ class Client;
* If a group contains multiple clients then only one will ever be mapped at * If a group contains multiple clients then only one will ever be mapped at
* any given time. * any given time.
*/ */
class ClientGroup : public QObject { class ClientGroup : public QObject
{
Q_OBJECT Q_OBJECT
public: public:
/** /**

View File

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

View File

@ -56,13 +56,11 @@ bool CompositingPrefs::compositingPossible()
{ {
#ifdef KWIN_HAVE_COMPOSITING #ifdef KWIN_HAVE_COMPOSITING
Extensions::init(); Extensions::init();
if( !Extensions::compositeAvailable()) if (!Extensions::compositeAvailable()) {
{
kDebug(1212) << "No composite extension available"; kDebug(1212) << "No composite extension available";
return false; return false;
} }
if( !Extensions::damageAvailable()) if (!Extensions::damageAvailable()) {
{
kDebug(1212) << "No damage extension available"; kDebug(1212) << "No damage extension available";
return false; return false;
} }
@ -88,8 +86,7 @@ QString CompositingPrefs::compositingNotPossibleReason()
{ {
#ifdef KWIN_HAVE_COMPOSITING #ifdef KWIN_HAVE_COMPOSITING
Extensions::init(); Extensions::init();
if( !Extensions::compositeAvailable() || !Extensions::damageAvailable()) if (!Extensions::compositeAvailable() || !Extensions::damageAvailable()) {
{
return i18n("Required X extensions (XComposite and XDamage) are not available."); return i18n("Required X extensions (XComposite and XDamage) are not available.");
} }
#if defined( KWIN_HAVE_OPENGL_COMPOSITING ) && !defined( KWIN_HAVE_XRENDER_COMPOSITING ) #if defined( KWIN_HAVE_OPENGL_COMPOSITING ) && !defined( KWIN_HAVE_XRENDER_COMPOSITING )
@ -101,8 +98,7 @@ QString CompositingPrefs::compositingNotPossibleReason()
" is compiled."); " is compiled.");
#else #else
if (!(Extensions::glxAvailable() if (!(Extensions::glxAvailable()
|| ( Extensions::renderAvailable() && Extensions::fixesAvailable()))) || (Extensions::renderAvailable() && Extensions::fixesAvailable()))) {
{
return i18n("GLX/OpenGL and XRender/XFixes are not available."); return i18n("GLX/OpenGL and XRender/XFixes are not available.");
} }
#endif #endif
@ -115,8 +111,7 @@ QString CompositingPrefs::compositingNotPossibleReason()
void CompositingPrefs::detect() void CompositingPrefs::detect()
{ {
if( !compositingPossible()) if (!compositingPossible()) {
{
return; return;
} }
@ -144,8 +139,7 @@ void CompositingPrefs::detect()
} }
#else #else
// HACK: This is needed for AIGLX // HACK: This is needed for AIGLX
if( qstrcmp( qgetenv( "KWIN_DIRECT_GL" ), "1" ) != 0 ) if (qstrcmp(qgetenv("KWIN_DIRECT_GL"), "1") != 0) {
{
// Start an external helper program that initializes GLX and returns // Start an external helper program that initializes GLX and returns
// 0 if we can use direct rendering, and 1 otherwise. // 0 if we can use direct rendering, and 1 otherwise.
// The reason we have to use an external program is that after GLX // The reason we have to use an external program is that after GLX
@ -157,8 +151,7 @@ void CompositingPrefs::detect()
if (QProcess::execute(opengl_test) != 0) if (QProcess::execute(opengl_test) != 0)
setenv("LIBGL_ALWAYS_INDIRECT", "1", true); setenv("LIBGL_ALWAYS_INDIRECT", "1", true);
} }
if( !Extensions::glxAvailable()) if (!Extensions::glxAvailable()) {
{
kDebug(1212) << "No GLX available"; kDebug(1212) << "No GLX available";
return; return;
} }
@ -174,8 +167,7 @@ void CompositingPrefs::detect()
if (hasglx13) if (hasglx13)
oldreaddrawable = glXGetCurrentReadDrawable(); oldreaddrawable = glXGetCurrentReadDrawable();
if( initGLXContext() ) if (initGLXContext()) {
{
detectDriverAndVersion(); detectDriverAndVersion();
applyDriverSpecificOptions(); applyDriverSpecificOptions();
} }
@ -203,21 +195,18 @@ bool CompositingPrefs::initGLXContext()
attribs << None; attribs << None;
XVisualInfo* visinfo = glXChooseVisual(display(), DefaultScreen(display()), attribs.data()); XVisualInfo* visinfo = glXChooseVisual(display(), DefaultScreen(display()), attribs.data());
if( !visinfo ) if (!visinfo) {
{
attribs.last() = GLX_DOUBLEBUFFER; attribs.last() = GLX_DOUBLEBUFFER;
attribs << None; attribs << None;
visinfo = glXChooseVisual(display(), DefaultScreen(display()), attribs.data()); visinfo = glXChooseVisual(display(), DefaultScreen(display()), attribs.data());
if (!visinfo) if (!visinfo) {
{
kDebug(1212) << "Error: couldn't find RGB GLX visual"; kDebug(1212) << "Error: couldn't find RGB GLX visual";
return false; return false;
} }
} }
mGLContext = glXCreateContext(display(), visinfo, NULL, True); mGLContext = glXCreateContext(display(), visinfo, NULL, True);
if ( !mGLContext ) if (!mGLContext) {
{
kDebug(1212) << "glXCreateContext failed"; kDebug(1212) << "glXCreateContext failed";
XDestroyWindow(display(), mGLWindow); XDestroyWindow(display(), mGLWindow);
return false; return false;

View File

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

View File

@ -73,15 +73,13 @@ void Deleted::copyToDeleted( Toplevel* c )
if (WinInfo* cinfo = dynamic_cast< WinInfo* >(info)) if (WinInfo* cinfo = dynamic_cast< WinInfo* >(info))
cinfo->disable(); cinfo->disable();
Client* client = dynamic_cast<Client*>(c); Client* client = dynamic_cast<Client*>(c);
if( client ) if (client) {
{
no_border = client->noBorder(); no_border = client->noBorder();
padding_left = client->paddingLeft(); padding_left = client->paddingLeft();
padding_right = client->paddingRight(); padding_right = client->paddingRight();
padding_bottom = client->paddingBottom(); padding_bottom = client->paddingBottom();
padding_top = client->paddingTop(); padding_top = client->paddingTop();
if( !no_border ) if (!no_border) {
{
client->layoutDecorationRects(decoration_left, client->layoutDecorationRects(decoration_left,
decoration_top, decoration_top,
decoration_right, decoration_right,

View File

@ -41,11 +41,21 @@ class Deleted
virtual QPoint clientPos() const; virtual QPoint clientPos() const;
virtual QSize clientSize() const; virtual QSize clientSize() const;
virtual QRect transparentRect() const; virtual QRect transparentRect() const;
const QPixmap *topDecoPixmap() const { return &decorationPixmapTop; } const QPixmap *topDecoPixmap() const {
const QPixmap *leftDecoPixmap() const { return &decorationPixmapLeft; } return &decorationPixmapTop;
const QPixmap *bottomDecoPixmap() const { return &decorationPixmapBottom; } }
const QPixmap *rightDecoPixmap() const { return &decorationPixmapRight; } const QPixmap *leftDecoPixmap() const {
bool noBorder() const { return no_border; } return &decorationPixmapLeft;
}
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; void layoutDecorationRects(QRect &left, QRect &top, QRect &right, QRect &bottom) const;
virtual void addRepaintFull(); // in composite.cpp virtual void addRepaintFull(); // in composite.cpp
QRect decorationRect() const; QRect decorationRect() const;

View File

@ -101,21 +101,15 @@ void DesktopChangeOSD::desktopChanged( int old )
int target = m_wspace->currentDesktop(); int target = m_wspace->currentDesktop();
int x = diff.x(); int x = diff.x();
int y = diff.y(); int y = diff.y();
if( y >= 0 ) if (y >= 0) {
{
// first go in x direction, then in y // first go in x direction, then in y
while( desktop != target ) while (desktop != target) {
{ if (x != 0) {
if( x != 0 ) if (x < 0) {
{
if( x < 0 )
{
x++; x++;
hash.insert(desktop, DesktopChangeItem::LEFT); hash.insert(desktop, DesktopChangeItem::LEFT);
desktop = m_wspace->desktopToLeft(desktop); desktop = m_wspace->desktopToLeft(desktop);
} } else {
else
{
x--; x--;
hash.insert(desktop, DesktopChangeItem::RIGHT); hash.insert(desktop, DesktopChangeItem::RIGHT);
desktop = m_wspace->desktopToRight(desktop); desktop = m_wspace->desktopToRight(desktop);
@ -126,30 +120,22 @@ void DesktopChangeOSD::desktopChanged( int old )
hash.insert(desktop, DesktopChangeItem::DOWN); hash.insert(desktop, DesktopChangeItem::DOWN);
desktop = m_wspace->desktopBelow(desktop); desktop = m_wspace->desktopBelow(desktop);
} }
} } else {
else
{
// first go in y direction, then in x // first go in y direction, then in x
while( target != desktop ) while (target != desktop) {
{ if (y != 0) {
if( y != 0 )
{
// only go upward // only go upward
y++; y++;
hash.insert(desktop, DesktopChangeItem::UP); hash.insert(desktop, DesktopChangeItem::UP);
desktop = m_wspace->desktopAbove(desktop); desktop = m_wspace->desktopAbove(desktop);
continue; continue;
} }
if( x != 0 ) if (x != 0) {
{ if (x < 0) {
if( x < 0 )
{
x++; x++;
hash.insert(desktop, DesktopChangeItem::LEFT); hash.insert(desktop, DesktopChangeItem::LEFT);
desktop = m_wspace->desktopToLeft(desktop); desktop = m_wspace->desktopToLeft(desktop);
} } else {
else
{
x--; x--;
hash.insert(desktop, DesktopChangeItem::RIGHT); hash.insert(desktop, DesktopChangeItem::RIGHT);
desktop = m_wspace->desktopToRight(desktop); desktop = m_wspace->desktopToRight(desktop);
@ -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 // now we know which desktop has to show an arrow -> set the arrow for each desktop
int numberOfArrows = qAbs(diff.x()) + qAbs(diff.y()); int numberOfArrows = qAbs(diff.x()) + qAbs(diff.y());
foreach( QGraphicsItem* it, m_scene->items() ) foreach (QGraphicsItem * it, m_scene->items()) {
{
DesktopChangeItem* item = qgraphicsitem_cast< DesktopChangeItem* >(it); DesktopChangeItem* item = qgraphicsitem_cast< DesktopChangeItem* >(it);
if( item ) if (item) {
{ if (hash.contains(item->desktop())) {
if( hash.contains( item->desktop() ) )
{
QPoint distance = m_wspace->desktopGridCoords(m_wspace->currentDesktop()) QPoint distance = m_wspace->desktopGridCoords(m_wspace->currentDesktop())
- m_wspace->desktopGridCoords(item->desktop()); - m_wspace->desktopGridCoords(item->desktop());
int desktopDistance = numberOfArrows - (qAbs(distance.x()) + qAbs(distance.y())); 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; int stop = m_delayTime / numberOfArrows * (desktopDistance + 1) + m_delayTime * 0.15f;
start = qMax(start, 0); start = qMax(start, 0);
item->setArrow(hash[ item->desktop()], start, stop); item->setArrow(hash[ item->desktop()], start, stop);
} } else {
else
{
item->setArrow(DesktopChangeItem::NONE, 0, 0); item->setArrow(DesktopChangeItem::NONE, 0, 0);
} }
if( old != m_wspace->currentDesktop() ) if (old != m_wspace->currentDesktop()) {
{
if (item->desktop() == m_wspace->currentDesktop()) if (item->desktop() == m_wspace->currentDesktop())
item->startDesktopHighLightAnimation(m_delayTime * 0.33); item->startDesktopHighLightAnimation(m_delayTime * 0.33);
if (m_active && item->desktop() == old) 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 // for text only we need to resize
if (m_textOnly) if (m_textOnly)
resize(); resize();
// already active - just update and reset timer // already active - just update and reset timer
update(); update();
} } else {
else
{
m_active = true; m_active = true;
resize(); resize();
show(); show();
@ -226,19 +203,15 @@ void DesktopChangeOSD::drawBackground( QPainter* painter, const QRectF& rect )
void DesktopChangeOSD::numberDesktopsChanged() void DesktopChangeOSD::numberDesktopsChanged()
{ {
foreach( QGraphicsItem* it, m_scene->items() ) foreach (QGraphicsItem * it, m_scene->items()) {
{
DesktopChangeItem* item = qgraphicsitem_cast<DesktopChangeItem*>(it); DesktopChangeItem* item = qgraphicsitem_cast<DesktopChangeItem*>(it);
if( item ) if (item) {
{
m_scene->removeItem(item); m_scene->removeItem(item);
} }
} }
if( !m_textOnly ) if (!m_textOnly) {
{ for (int i = 1; i <= m_wspace->numberOfDesktops(); i++) {
for( int i=1; i<=m_wspace->numberOfDesktops(); i++ )
{
DesktopChangeItem* item = new DesktopChangeItem(m_wspace, this, i); DesktopChangeItem* item = new DesktopChangeItem(m_wspace, this, i);
m_scene->addItem(item); m_scene->addItem(item);
} }
@ -261,8 +234,7 @@ void DesktopChangeOSD::resize()
// bound width between ten and 33 percent of active screen // bound width between ten and 33 percent of active screen
float tempWidth = qBound(screenRect.width() * 0.25f, width, screenRect.width() * 0.5f); float tempWidth = qBound(screenRect.width() * 0.25f, width, screenRect.width() * 0.5f);
if( tempWidth != width ) if (tempWidth != width) {
{
// have to adjust the height // have to adjust the height
width = tempWidth; width = tempWidth;
itemWidth = (width - (desktopGridSize.width() - 1) * 2 - left - right) / desktopGridSize.width(); itemWidth = (width - (desktopGridSize.width() - 1) * 2 - left - right) / desktopGridSize.width();
@ -274,8 +246,7 @@ void DesktopChangeOSD::resize()
// we do not increase height, but it's bound to a third of screen height // we do not increase height, but it's bound to a third of screen height
float tempHeight = qMin(height, screenRect.height() * 0.5f); float tempHeight = qMin(height, screenRect.height() * 0.5f);
float itemOffset = 0.0f; float itemOffset = 0.0f;
if( tempHeight != height ) if (tempHeight != height) {
{
// have to adjust item width // have to adjust item width
height = tempHeight; height = tempHeight;
itemHeight = (height - (fontMetrics().height() + 4) - top - bottom - (desktopGridSize.height() - 1) * 2) / itemHeight = (height - (fontMetrics().height() + 4) - top - bottom - (desktopGridSize.height() - 1) * 2) /
@ -287,8 +258,7 @@ void DesktopChangeOSD::resize()
} }
// set size to the desktop name if the "pager" is not shown // set size to the desktop name if the "pager" is not shown
if( m_textOnly ) if (m_textOnly) {
{
height = fontMetrics().height() + 4 + top + bottom; height = fontMetrics().height() + 4 + top + bottom;
width = fontMetrics().boundingRect(m_wspace->desktopName(m_wspace->currentDesktop())).width() + width = fontMetrics().boundingRect(m_wspace->desktopName(m_wspace->currentDesktop())).width() +
4 + left + right; 4 + left + right;
@ -302,14 +272,11 @@ void DesktopChangeOSD::resize()
m_scene->setSceneRect(0, 0, width, height); m_scene->setSceneRect(0, 0, width, height);
m_frame.resizeFrame(QSize(width, height)); m_frame.resizeFrame(QSize(width, height));
if (Plasma::Theme::defaultTheme()->windowTranslucencyEnabled()) if (Plasma::Theme::defaultTheme()->windowTranslucencyEnabled()) {
{
// blur background // blur background
Plasma::WindowEffects::enableBlurBehind(winId(), true, m_frame.mask()); Plasma::WindowEffects::enableBlurBehind(winId(), true, m_frame.mask());
Plasma::WindowEffects::overrideShadow(winId(), true); Plasma::WindowEffects::overrideShadow(winId(), true);
} } else {
else
{
// do not trim to mask with compositing enabled, otherwise shadows are cropped // do not trim to mask with compositing enabled, otherwise shadows are cropped
setMask(m_frame.mask()); setMask(m_frame.mask());
} }
@ -321,11 +288,9 @@ void DesktopChangeOSD::resize()
m_item_frame.resizeFrame(QSize(itemWidth, itemHeight)); m_item_frame.resizeFrame(QSize(itemWidth, itemHeight));
// reset the items // reset the items
foreach( QGraphicsItem* it, m_scene->items() ) foreach (QGraphicsItem * it, m_scene->items()) {
{
DesktopChangeItem* item = qgraphicsitem_cast<DesktopChangeItem*>(it); DesktopChangeItem* item = qgraphicsitem_cast<DesktopChangeItem*>(it);
if( item ) if (item) {
{
item->setWidth(itemWidth); item->setWidth(itemWidth);
item->setHeight(itemHeight); item->setHeight(itemHeight);
QPoint coords = m_wspace->desktopGridCoords(item->desktop()); QPoint coords = m_wspace->desktopGridCoords(item->desktop());
@ -333,8 +298,7 @@ void DesktopChangeOSD::resize()
top + fontMetrics().height() + 4 + coords.y()*(itemHeight + 4)); top + fontMetrics().height() + 4 + coords.y()*(itemHeight + 4));
} }
DesktopChangeText* text = qgraphicsitem_cast<DesktopChangeText*>(it); DesktopChangeText* text = qgraphicsitem_cast<DesktopChangeText*>(it);
if( text ) if (text) {
{
text->setPos(left, top); text->setPos(left, top);
text->setWidth(width - left - right); text->setWidth(width - left - right);
if (m_textOnly) if (m_textOnly)
@ -411,16 +375,14 @@ void DesktopChangeItem::setArrow( Arrow arrow, int start_delay, int hide_delay )
m_delayed_hide_arrow_timer.stop(); m_delayed_hide_arrow_timer.stop();
QPropertyAnimation *arrowAnimation = m_arrowAnimation.data(); QPropertyAnimation *arrowAnimation = m_arrowAnimation.data();
if( arrowAnimation ) if (arrowAnimation) {
{
arrowAnimation->stop(); arrowAnimation->stop();
m_arrowAnimation.clear(); m_arrowAnimation.clear();
} }
m_arrowShown = false; m_arrowShown = false;
m_arrow = arrow; m_arrow = arrow;
if( m_arrow != NONE ) if (m_arrow != NONE) {
{
m_delayed_show_arrow_timer.start(start_delay); m_delayed_show_arrow_timer.start(start_delay);
m_delayed_hide_arrow_timer.start(hide_delay); m_delayed_hide_arrow_timer.start(hide_delay);
} }
@ -456,8 +418,7 @@ void DesktopChangeItem::showArrow()
m_arrowShown = true; m_arrowShown = true;
QPropertyAnimation *arrowAnimation = m_arrowAnimation.data(); QPropertyAnimation *arrowAnimation = m_arrowAnimation.data();
if( !arrowAnimation ) if (!arrowAnimation) {
{
arrowAnimation = new QPropertyAnimation(this, "arrowValue"); arrowAnimation = new QPropertyAnimation(this, "arrowValue");
arrowAnimation->setDuration(m_parent->getDelayTime() * 0.15f); arrowAnimation->setDuration(m_parent->getDelayTime() * 0.15f);
arrowAnimation->setStartValue(0.0); arrowAnimation->setStartValue(0.0);
@ -478,8 +439,7 @@ void DesktopChangeItem::hideArrow()
m_fadeInArrow = false; m_fadeInArrow = false;
QPropertyAnimation *arrowAnimation = m_arrowAnimation.data(); QPropertyAnimation *arrowAnimation = m_arrowAnimation.data();
if( arrowAnimation ) if (arrowAnimation) {
{
arrowAnimation->setEasingCurve(QEasingCurve::OutQuad); arrowAnimation->setEasingCurve(QEasingCurve::OutQuad);
arrowAnimation->setDirection(QAbstractAnimation::Backward); arrowAnimation->setDirection(QAbstractAnimation::Backward);
arrowAnimation->start(QAbstractAnimation::DeleteWhenStopped); arrowAnimation->start(QAbstractAnimation::DeleteWhenStopped);
@ -491,8 +451,7 @@ void DesktopChangeItem::hideArrow()
void DesktopChangeItem::startDesktopHighLightAnimation(int time) void DesktopChangeItem::startDesktopHighLightAnimation(int time)
{ {
QPropertyAnimation *highLightAnimation = m_highLightAnimation.data(); QPropertyAnimation *highLightAnimation = m_highLightAnimation.data();
if( !highLightAnimation ) if (!highLightAnimation) {
{
highLightAnimation = new QPropertyAnimation(this, "highLightValue"); highLightAnimation = new QPropertyAnimation(this, "highLightValue");
highLightAnimation->setDuration(time); highLightAnimation->setDuration(time);
highLightAnimation->setStartValue(0.0); highLightAnimation->setStartValue(0.0);
@ -513,8 +472,7 @@ void DesktopChangeItem::stopDesktopHighLightAnimation()
m_fadeInHighLight = false; m_fadeInHighLight = false;
QPropertyAnimation *highLightAnimation = m_highLightAnimation.data(); QPropertyAnimation *highLightAnimation = m_highLightAnimation.data();
if(highLightAnimation) if (highLightAnimation) {
{
highLightAnimation->setEasingCurve(QEasingCurve::OutQuad); highLightAnimation->setEasingCurve(QEasingCurve::OutQuad);
highLightAnimation->setDirection(QAbstractAnimation::Backward); highLightAnimation->setDirection(QAbstractAnimation::Backward);
highLightAnimation->start(QAbstractAnimation::DeleteWhenStopped); highLightAnimation->start(QAbstractAnimation::DeleteWhenStopped);
@ -530,25 +488,20 @@ void DesktopChangeItem::arrowAnimationFinished()
void DesktopChangeItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* , QWidget*) void DesktopChangeItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* , QWidget*)
{ {
if (m_wspace->currentDesktop() == m_desktop || (!m_highLightAnimation.isNull() && 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; qreal left, top, right, bottom;
m_parent->itemFrame()->getMargins(left, top, right, bottom); m_parent->itemFrame()->getMargins(left, top, right, bottom);
if (!m_highLightAnimation.isNull() && 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 // 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"); m_parent->itemFrame()->setElementPrefix("normal");
QPixmap normal = m_parent->itemFrame()->framePixmap(); QPixmap normal = m_parent->itemFrame()->framePixmap();
m_parent->itemFrame()->setElementPrefix("hover"); m_parent->itemFrame()->setElementPrefix("hover");
QPixmap result = Plasma::PaintUtils::transition(normal, QPixmap result = Plasma::PaintUtils::transition(normal,
m_parent->itemFrame()->framePixmap(), m_highLightValue); m_parent->itemFrame()->framePixmap(), m_highLightValue);
painter->drawPixmap(boundingRect().toRect(), result); painter->drawPixmap(boundingRect().toRect(), result);
} } else {
else
{
m_parent->itemFrame()->setElementPrefix("hover"); m_parent->itemFrame()->setElementPrefix("hover");
QPixmap normal = m_parent->itemFrame()->framePixmap(); QPixmap normal = m_parent->itemFrame()->framePixmap();
m_parent->itemFrame()->setElementPrefix("normal"); m_parent->itemFrame()->setElementPrefix("normal");
@ -556,9 +509,7 @@ void DesktopChangeItem::paint( QPainter* painter, const QStyleOptionGraphicsItem
m_parent->itemFrame()->framePixmap(), 1.0 - m_highLightValue); m_parent->itemFrame()->framePixmap(), 1.0 - m_highLightValue);
painter->drawPixmap(boundingRect().toRect(), result); painter->drawPixmap(boundingRect().toRect(), result);
} }
} } else {
else
{
// no animation - just render the active frame // no animation - just render the active frame
m_parent->itemFrame()->setElementPrefix("hover"); m_parent->itemFrame()->setElementPrefix("hover");
m_parent->itemFrame()->paintFrame(painter, boundingRect()); m_parent->itemFrame()->paintFrame(painter, boundingRect());
@ -567,9 +518,7 @@ void DesktopChangeItem::paint( QPainter* painter, const QStyleOptionGraphicsItem
rectColor.setAlphaF(0.6 * m_highLightValue); rectColor.setAlphaF(0.6 * m_highLightValue);
QBrush rectBrush = QBrush(rectColor); QBrush rectBrush = QBrush(rectColor);
painter->fillRect(boundingRect().adjusted(left, top, -right, -bottom), rectBrush); painter->fillRect(boundingRect().adjusted(left, top, -right, -bottom), rectBrush);
} } else {
else
{
m_parent->itemFrame()->setElementPrefix("normal"); m_parent->itemFrame()->setElementPrefix("normal");
m_parent->itemFrame()->paintFrame(painter, boundingRect()); 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, QRect iconRect = QRect(boundingRect().x() + boundingRect().width() / 2 - iconWidth / 2,
boundingRect().y() + boundingRect().height() / 2 - iconWidth / 2, boundingRect().y() + boundingRect().height() / 2 - iconWidth / 2,
iconWidth, iconWidth); iconWidth, iconWidth);
switch( m_arrow ) switch(m_arrow) {
{
case UP: case UP:
icon = KIconLoader::global()->loadIcon("go-up", KIconLoader::Desktop, iconWidth); icon = KIconLoader::global()->loadIcon("go-up", KIconLoader::Desktop, iconWidth);
break; break;
@ -608,12 +556,10 @@ void DesktopChangeItem::paint( QPainter* painter, const QStyleOptionGraphicsItem
default: default:
break; break;
} }
if( m_arrow != NONE ) if (m_arrow != NONE) {
{
if (!m_arrowAnimation.isNull() && if (!m_arrowAnimation.isNull() &&
m_arrowAnimation.data()->state() == QAbstractAnimation::Running && m_arrowAnimation.data()->state() == QAbstractAnimation::Running &&
!qFuzzyCompare(m_arrowValue, qreal(1.0)) ) !qFuzzyCompare(m_arrowValue, qreal(1.0))) {
{
QPixmap temp(icon.size()); QPixmap temp(icon.size());
temp.fill(Qt::transparent); temp.fill(Qt::transparent);

View File

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

View File

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

View File

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

View File

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

View File

@ -58,8 +58,7 @@ bool LiquidEffect::loadData()
// NPOT textures that way // NPOT textures that way
int texw = displayWidth(); int texw = displayWidth();
int texh = displayHeight(); int texh = displayHeight();
if( !GLTexture::NPOTTextureSupported() ) if (!GLTexture::NPOTTextureSupported()) {
{
kWarning(1212) << "NPOT textures not supported, wasting some memory" ; kWarning(1212) << "NPOT textures not supported, wasting some memory" ;
texw = nearestPowerOfTwo(texw); texw = nearestPowerOfTwo(texw);
texh = nearestPowerOfTwo(texh); texh = nearestPowerOfTwo(texh);
@ -75,14 +74,12 @@ bool LiquidEffect::loadData()
QString fragmentshader = KGlobal::dirs()->findResource("data", "kwin/liquid.frag"); QString fragmentshader = KGlobal::dirs()->findResource("data", "kwin/liquid.frag");
QString vertexshader = KGlobal::dirs()->findResource("data", "kwin/liquid.vert"); QString vertexshader = KGlobal::dirs()->findResource("data", "kwin/liquid.vert");
if(fragmentshader.isEmpty() || vertexshader.isEmpty()) if (fragmentshader.isEmpty() || vertexshader.isEmpty()) {
{
kError(1212) << "Couldn't locate shader files" << endl; kError(1212) << "Couldn't locate shader files" << endl;
return false; return false;
} }
mShader = new GLShader(vertexshader, fragmentshader); mShader = new GLShader(vertexshader, fragmentshader);
if(!mShader->isValid()) if (!mShader->isValid()) {
{
kError(1212) << "The shader failed to load!" << endl; kError(1212) << "The shader failed to load!" << endl;
return false; return false;
} }
@ -106,8 +103,7 @@ bool LiquidEffect::supported()
void LiquidEffect::prePaintScreen(ScreenPrePaintData& data, int time) void LiquidEffect::prePaintScreen(ScreenPrePaintData& data, int time)
{ {
mTime += time / 1000.0f; mTime += time / 1000.0f;
if(mValid) if (mValid) {
{
data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS; data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
// Start rendering to texture // Start rendering to texture
effects->pushRenderTarget(mRenderTarget); effects->pushRenderTarget(mRenderTarget);
@ -121,8 +117,7 @@ void LiquidEffect::postPaintScreen()
// Call the next effect. // Call the next effect.
effects->postPaintScreen(); effects->postPaintScreen();
if(mValid) if (mValid) {
{
// Disable render texture // Disable render texture
assert(effects->popRenderTarget() == mRenderTarget); assert(effects->popRenderTarget() == mRenderTarget);
mTexture->bind(); mTexture->bind();

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

View File

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

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 // Make sure we have OpenGL compositing and the window is vidible and not a
// special window // special window
// TODO if ( w->isVisible() && !w->isSpecialWindow() ) // TODO if ( w->isVisible() && !w->isSpecialWindow() )
if( !w->isSpecialWindow() ) if (!w->isSpecialWindow()) {
{
// We have OpenGL compositing and the window has been subdivided // We have OpenGL compositing and the window has been subdivided
// because of our request (in pre-paint pass) // because of our request (in pre-paint pass)
// Transform all the vertices to create wavy effect // Transform all the vertices to create wavy effect
@ -72,8 +71,7 @@ void WavyWindowsEffect::paintWindow( EffectWindow* w, int mask, QRegion region,
++i) ++i)
for (int j = 0; for (int j = 0;
j < 4; j < 4;
++j ) ++j) {
{
WindowVertex& v = data.quads[ i ][ j ]; WindowVertex& v = data.quads[ i ][ j ];
v.move(v.x() + sin(mTimeElapsed + v.originalY() / 60 + 0.5f) * 10, v.move(v.x() + sin(mTimeElapsed + v.originalY() / 60 + 0.5f) * 10,
v.y() + sin(mTimeElapsed + v.originalX() / 80) * 10); v.y() + sin(mTimeElapsed + v.originalX() / 80) * 10);

View File

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

View File

@ -27,17 +27,13 @@ void FlameEffect::prePaintScreen( ScreenPrePaintData& data, int time )
void FlameEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time) void FlameEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
{ {
if( windows.contains( w )) if (windows.contains(w)) {
{ if (windows[ w ] < 1) {
if( windows[ w ] < 1 )
{
windows[ w ] += time / 500.; windows[ w ] += time / 500.;
data.setTransformed(); data.setTransformed();
w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DELETE); w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DELETE);
data.quads = data.quads.splitAtY(windows[ w ] * w->height()); data.quads = data.quads.splitAtY(windows[ w ] * w->height());
} } else {
else
{
windows.remove(w); windows.remove(w);
w->unrefWindow(); w->unrefWindow();
} }
@ -47,12 +43,10 @@ void FlameEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int
void FlameEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) void FlameEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{ {
if( windows.contains( w )) if (windows.contains(w)) {
{
WindowQuadList new_quads; WindowQuadList new_quads;
double ylimit = windows[ w ] * w->height(); // parts above this are already away double ylimit = windows[ w ] * w->height(); // parts above this are already away
foreach( const WindowQuad &quad, data.quads ) foreach (const WindowQuad & quad, data.quads) {
{
if (quad.bottom() <= ylimit) if (quad.bottom() <= ylimit)
continue; continue;
new_quads.append(quad); new_quads.append(quad);

View File

@ -63,8 +63,7 @@ bool GearsEffect::supported()
void GearsEffect::prePaintScreen(ScreenPrePaintData& data, int time) void GearsEffect::prePaintScreen(ScreenPrePaintData& data, int time)
{ {
if( m_active ) if (m_active) {
{
m_contentRotation += time * 360.0f / 20000.0f; m_contentRotation += time * 360.0f / 20000.0f;
if (m_contentRotation > 360.0f) if (m_contentRotation > 360.0f)
m_contentRotation -= 360.0f; m_contentRotation -= 360.0f;
@ -77,8 +76,7 @@ void GearsEffect::prePaintScreen( ScreenPrePaintData& data, int time )
void GearsEffect::postPaintScreen() void GearsEffect::postPaintScreen()
{ {
if( m_active ) if (m_active) {
{
effects->addRepaintFull(); effects->addRepaintFull();
} }
effects->postPaintScreen(); effects->postPaintScreen();
@ -87,8 +85,7 @@ void GearsEffect::postPaintScreen()
void GearsEffect::paint() void GearsEffect::paint()
{ {
if( m_active ) if (m_active) {
{
paintGears(); paintGears();
} }
} }
@ -123,14 +120,12 @@ void GearsEffect::gear( float inner_radius, float outer_radius, float width, int
/* draw front face */ /* draw front face */
glBegin(GL_QUAD_STRIP); glBegin(GL_QUAD_STRIP);
for( i = 0; i <= teeth; ++i ) for (i = 0; i <= teeth; ++i) {
{
angle = i * 2.0 * M_PI / teeth; angle = i * 2.0 * M_PI / teeth;
glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
if( i < teeth ) if (i < teeth) {
{
glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5); glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5);
} }
@ -141,8 +136,7 @@ void GearsEffect::gear( float inner_radius, float outer_radius, float width, int
/* draw front sides of teeth */ /* draw front sides of teeth */
glBegin(GL_QUADS); glBegin(GL_QUADS);
for( i = 0; i < teeth; ++i ) for (i = 0; i < teeth; ++i) {
{
angle = i * 2.0 * M_PI / teeth; angle = i * 2.0 * M_PI / teeth;
glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
@ -161,14 +155,12 @@ void GearsEffect::gear( float inner_radius, float outer_radius, float width, int
/* draw back face */ /* draw back face */
glBegin(GL_QUAD_STRIP); glBegin(GL_QUAD_STRIP);
for( i = 0; i <= teeth; ++i ) for (i = 0; i <= teeth; ++i) {
{
angle = i * 2.0 * M_PI / teeth; angle = i * 2.0 * M_PI / teeth;
glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
if( i < teeth ) if (i < teeth) {
{
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5); glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5);
glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
} }
@ -180,8 +172,7 @@ void GearsEffect::gear( float inner_radius, float outer_radius, float width, int
glBegin(GL_QUADS); glBegin(GL_QUADS);
da = 2.0 * M_PI / teeth / 4.0; da = 2.0 * M_PI / teeth / 4.0;
for( i = 0; i < teeth; ++i ) for (i = 0; i < teeth; ++i) {
{
angle = i * 2.0 * M_PI / teeth; angle = i * 2.0 * M_PI / teeth;
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5); glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5);
@ -198,8 +189,7 @@ void GearsEffect::gear( float inner_radius, float outer_radius, float width, int
/* draw outward faces of teeth */ /* draw outward faces of teeth */
glBegin(GL_QUAD_STRIP); glBegin(GL_QUAD_STRIP);
for( i = 0; i < teeth; ++i ) for (i = 0; i < teeth; ++i) {
{
angle = i * 2.0 * M_PI / teeth; angle = i * 2.0 * M_PI / teeth;
glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
@ -236,8 +226,7 @@ void GearsEffect::gear( float inner_radius, float outer_radius, float width, int
/* draw inside radius cylinder */ /* draw inside radius cylinder */
glBegin(GL_QUAD_STRIP); glBegin(GL_QUAD_STRIP);
for( i = 0; i <= teeth; ++i ) for (i = 0; i <= teeth; ++i) {
{
angle = i * 2.0 * M_PI / teeth; angle = i * 2.0 * M_PI / teeth;
glNormal3f(-cos(angle), -sin(angle), 0.0); glNormal3f(-cos(angle), -sin(angle), 0.0);
glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);

View File

@ -39,21 +39,17 @@ KWIN_EFFECT( howto, HowtoEffect )
void HowtoEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time) void HowtoEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
{ {
// Is this window the one that is going to be faded out and in again? // Is this window the one that is going to be faded out and in again?
if( w == fade_window ) if (w == fade_window) {
{
// Simply add the time to the total progress. The value of progress will be used // Simply add the time to the total progress. The value of progress will be used
// to determine how far in effect is. // to determine how far in effect is.
progress += time; progress += time;
// If progress is < 1000 (milliseconds), the effect is still in progress. // If progress is < 1000 (milliseconds), the effect is still in progress.
if( progress < 1000 ) // complete change in 1000ms if (progress < 1000) { // complete change in 1000ms
{
// Since the effect will make the window translucent, explicitly change // Since the effect will make the window translucent, explicitly change
// the flags so that the window will be painted only as translucent. // the flags so that the window will be painted only as translucent.
// Use a helper that also takes care of changing the clipping rectangle. // Use a helper that also takes care of changing the clipping rectangle.
data.setTranslucent(); data.setTranslucent();
} } else {
else
{
// If progress has reached 1000 (milliseconds), it means the effect is done // If progress has reached 1000 (milliseconds), it means the effect is done
// and there is no window to fade anymore. // and there is no window to fade anymore.
fade_window = NULL; fade_window = NULL;
@ -77,13 +73,11 @@ void HowtoEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int
void HowtoEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) void HowtoEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{ {
// Is this the window to be faded out and in again? // Is this the window to be faded out and in again?
if( w == fade_window ) if (w == fade_window) {
{
// This effect, after a window has been activated, fades it out to only 50% transparency // This effect, after a window has been activated, fades it out to only 50% transparency
// and then fades it in again to be fully opaque (assuming it's otherwise a fully opaque // and then fades it in again to be fully opaque (assuming it's otherwise a fully opaque
// window, otherwise the transparencies will be added). // window, otherwise the transparencies will be added).
if( progress <= 500 ) if (progress <= 500) {
{
// For the first 500 milliseconds (progress being 0 to 500), the window is faded out. // For the first 500 milliseconds (progress being 0 to 500), the window is faded out.
// progress == 0 -> opacity *= 1 // progress == 0 -> opacity *= 1
// progress == 500 -> opacity *= 0.5 // progress == 500 -> opacity *= 0.5
@ -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, // Note that data.opacity is not set but multiplied - this allows chaining of effects,
// for example if another effect always changes opacity of some window types. // for example if another effect always changes opacity of some window types.
data.opacity *= 1 - 0.5 * (progress / 500.0); data.opacity *= 1 - 0.5 * (progress / 500.0);
} } else {
else
{
// For the second 500 milliseconds (progress being 500 to 1000), the window is // For the second 500 milliseconds (progress being 500 to 1000), the window is
// faded in again. // faded in again.
// progress == 500 -> opacity *= 0.5 // progress == 500 -> opacity *= 0.5
@ -110,8 +102,7 @@ void HowtoEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Window
void HowtoEffect::postPaintWindow(EffectWindow* w) void HowtoEffect::postPaintWindow(EffectWindow* w)
{ {
// Is this the window to be faded out and in again? // Is this the window to be faded out and in again?
if( w == fade_window ) if (w == fade_window) {
{
// Trigger repaint of the whole window, this will cause it to be repainted the next painting pass. // Trigger repaint of the whole window, this will cause it to be repainted the next painting pass.
w->addRepaintFull(); // trigger next animation repaint w->addRepaintFull(); // trigger next animation repaint
} }
@ -124,8 +115,7 @@ void HowtoEffect::windowActivated( EffectWindow* c )
{ {
// Set the window to be faded (or NULL if no window is active). // Set the window to be faded (or NULL if no window is active).
fade_window = c; fade_window = c;
if( fade_window != NULL ) if (fade_window != NULL) {
{
// If there is a window to be faded, reset the progress to zero. // If there is a window to be faded, reset the progress to zero.
progress = 0; progress = 0;
// And add repaint to the window so that it needs to be repainted. // And add repaint to the window so that it needs to be repainted.

View File

@ -58,13 +58,11 @@ KickerEffect::KickerEffect()
KickerEffect::~KickerEffect() KickerEffect::~KickerEffect()
{ {
while( !m_frames.isEmpty() ) while (!m_frames.isEmpty()) {
{
delete m_frames.first(); delete m_frames.first();
m_frames.removeFirst(); m_frames.removeFirst();
} }
while( !m_goalFrames.isEmpty() ) while (!m_goalFrames.isEmpty()) {
{
delete m_goalFrames.first(); delete m_goalFrames.first();
m_goalFrames.removeFirst(); m_goalFrames.removeFirst();
} }
@ -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 // as long as the goal timer has not timed out m_goalActive is true
// after the timeout an animation might still be running, so we continue // after the timeout an animation might still be running, so we continue
// till progress reaches 0.0 again // till progress reaches 0.0 again
if( m_goalActive || m_timeLine.progress() != 0.0 ) if (m_goalActive || m_timeLine.progress() != 0.0) {
{
// the animation might either be ascending (increasing opacity) or // the animation might either be ascending (increasing opacity) or
// descending (decreasing opacity). In case of ascending we add time // descending (decreasing opacity). In case of ascending we add time
// to the timeline till progress reaches 1.0. There we switch direction // to the timeline till progress reaches 1.0. There we switch direction
// to descending. In descending case of course vice versa. // to descending. In descending case of course vice versa.
if( m_ascending ) if (m_ascending) {
{
m_timeLine.addTime(time); m_timeLine.addTime(time);
if( m_timeLine.progress() == 1.0 ) if (m_timeLine.progress() == 1.0) {
{
m_ascending = false; m_ascending = false;
} }
} } else {
else
{
m_timeLine.removeTime(time); m_timeLine.removeTime(time);
// it is possible that this is the last animation. Therefore the // it is possible that this is the last animation. Therefore the
// anding with goalActive. If it has been the last animation we // anding with goalActive. If it has been the last animation we
// do not need to keep the goal EffectFrame around any more, so // do not need to keep the goal EffectFrame around any more, so
// we delete them. // we delete them.
if( m_timeLine.progress() == 0.0 && m_goalActive ) if (m_timeLine.progress() == 0.0 && m_goalActive) {
{
m_ascending = true; m_ascending = true;
} } else if (m_timeLine.progress() == 0.0) {
else if( m_timeLine.progress() == 0.0 )
{
// goal animation finshed, let's delete the EffectFrames // goal animation finshed, let's delete the EffectFrames
while( !m_goalFrames.isEmpty() ) while (!m_goalFrames.isEmpty()) {
{
delete m_goalFrames.first(); delete m_goalFrames.first();
m_goalFrames.removeFirst(); m_goalFrames.removeFirst();
} }
@ -124,16 +113,14 @@ void KickerEffect::paintScreen( int mask, QRegion region, ScreenPaintData &data
{ {
effects->paintScreen(mask, region, data); effects->paintScreen(mask, region, data);
if( m_size.isValid() ) if (m_size.isValid()) {
{
// let's paint the score EffectFrame with unmodified opacity. As it // let's paint the score EffectFrame with unmodified opacity. As it
// uses Plasma styled textures it's still translucent, but the text // uses Plasma styled textures it's still translucent, but the text
// is fully opaque. // is fully opaque.
foreach (EffectFrame * frame, m_frames) foreach (EffectFrame * frame, m_frames)
frame->render(region, 1.0); frame->render(region, 1.0);
} }
if( m_goalActive || m_timeLine.progress() != 0.0 ) if (m_goalActive || m_timeLine.progress() != 0.0) {
{
// the goal animation changes the opacity. Therefore we modify the // the goal animation changes the opacity. Therefore we modify the
// opacity by multiplying with the timeline's progress. // opacity by multiplying with the timeline's progress.
// The text should be fully opaque (1.0), while the background should // The text should be fully opaque (1.0), while the background should
@ -161,8 +148,7 @@ void KickerEffect::slotLoadFinished( bool ok )
// CSS selector for the current score // CSS selector for the current score
QString result = doc.findFirst("td.lttaberg h1").toPlainText(); QString result = doc.findFirst("td.lttaberg h1").toPlainText();
if( m_score != result ) if (m_score != result) {
{
// the score changed, a goal might have been scored // the score changed, a goal might have been scored
bool activate = true; bool activate = true;
// but not if the web page has been loaded for the first time // but not if the web page has been loaded for the first time
@ -181,8 +167,7 @@ void KickerEffect::slotLoadFinished( bool ok )
if (m_score.count('-') > result.count('-')) if (m_score.count('-') > result.count('-'))
activate = false; activate = false;
// yeah it's a goal - generate the EffectFrame and start the animation // yeah it's a goal - generate the EffectFrame and start the animation
if( activate ) if (activate) {
{
generateGoalImage(); generateGoalImage();
m_goalActive = true; m_goalActive = true;
m_ascending = true; m_ascending = true;
@ -199,15 +184,13 @@ void KickerEffect::slotLoadFinished( bool ok )
// we don't want to reposition the EffectFrames, therefore we delete the // we don't want to reposition the EffectFrames, therefore we delete the
// old ones. Normally you wouldn't do that, but as we only update once in // old ones. Normally you wouldn't do that, but as we only update once in
// half a minute and it's easier to code... // half a minute and it's easier to code...
while( !m_frames.isEmpty() ) while (!m_frames.isEmpty()) {
{
delete m_frames.first(); delete m_frames.first();
m_frames.removeFirst(); m_frames.removeFirst();
} }
m_frames.clear(); m_frames.clear();
// and properly position the frame on each screen // and properly position the frame on each screen
for( int i = 0; i < effects->numScreens(); i++ ) for (int i = 0; i < effects->numScreens(); i++) {
{
QRect area = effects->clientArea(ScreenArea, i, effects->currentDesktop()); QRect area = effects->clientArea(ScreenArea, i, effects->currentDesktop());
QRect geometry = QRect(area.x() + area.width() - m_size.width() - 20, area.y() + 20, m_size.width(), m_size.height()); QRect geometry = QRect(area.x() + area.width() - m_size.width() - 20, area.y() + 20, m_size.width(), m_size.height());
EffectFrame *frame = new EffectFrame(EffectFrame::Styled); EffectFrame *frame = new EffectFrame(EffectFrame::Styled);
@ -233,8 +216,7 @@ void KickerEffect::generateGoalImage()
QString goal("GOAL"); QString goal("GOAL");
QFontMetrics fm(font); QFontMetrics fm(font);
QSize size = fm.boundingRect(goal).adjusted(-10, -10, 10, 10).size(); QSize size = fm.boundingRect(goal).adjusted(-10, -10, 10, 10).size();
for( int i = 0; i < effects->numScreens(); i++ ) for (int i = 0; i < effects->numScreens(); i++) {
{
// place one frame on the center of each screen // place one frame on the center of each screen
QRect area = effects->clientArea(ScreenArea, i, effects->currentDesktop()); QRect area = effects->clientArea(ScreenArea, i, effects->currentDesktop());
QRect geometry = QRect(area.x() + (area.width() - size.width()) / 2, QRect geometry = QRect(area.x() + (area.width() - size.width()) / 2,

View File

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

View File

@ -56,8 +56,7 @@ void SwivelTabsEffect::prePaintScreen( ScreenPrePaintData& data, int time )
void SwivelTabsEffect::prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time) void SwivelTabsEffect::prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time)
{ {
if( isActive && ( w == windows.show || w == windows.hide ) ) if (isActive && (w == windows.show || w == windows.hide)) {
{
data.quads = data.quads.makeGrid(40); data.quads = data.quads.makeGrid(40);
data.setTransformed(); data.setTransformed();
w->enablePainting(EffectWindow::PAINT_DISABLED); w->enablePainting(EffectWindow::PAINT_DISABLED);
@ -68,8 +67,7 @@ void SwivelTabsEffect::prePaintWindow( EffectWindow *w, WindowPrePaintData &data
void SwivelTabsEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) void SwivelTabsEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{ {
if( isActive && ( w == windows.show || w == windows.hide ) ) if (isActive && (w == windows.show || w == windows.hide)) {
{
for (int i = 0; i < data.quads.count(); ++i) for (int i = 0; i < data.quads.count(); ++i)
transformQuad(data.quads[i]); transformQuad(data.quads[i]);
} }
@ -90,47 +88,38 @@ void SwivelTabsEffect::transformQuad( WindowQuad &quad )
int height = quad[3].y() - quad[0].y(); int height = quad[3].y() - quad[0].y();
int cx = quad[0].x() + (width / 2); int cx = quad[0].x() + (width / 2);
int cy = quad[0].y() + (height / 2); int cy = quad[0].y() + (height / 2);
if( lastF < 0.5 && F > 0.5 ) if (lastF < 0.5 && F > 0.5) {
{
effects->setElevatedWindow(windows.hide, false); effects->setElevatedWindow(windows.hide, false);
effects->setElevatedWindow(windows.show, true); effects->setElevatedWindow(windows.show, true);
} }
lastF = F; lastF = F;
if( F >= 1.0 ) if (F >= 1.0) {
{
isActive = false; isActive = false;
effects->setElevatedWindow(windows.hide, false); effects->setElevatedWindow(windows.hide, false);
effects->setElevatedWindow(windows.show, false); effects->setElevatedWindow(windows.show, false);
} }
if( F < 0.5 ) if (F < 0.5) {
{ if (horizontal) {
if( horizontal )
{
quad[0].setX(quad[0].x() + (width * F)); quad[0].setX(quad[0].x() + (width * F));
quad[3].setX(quad[3].x() + (width * F)); quad[3].setX(quad[3].x() + (width * F));
quad[1].setX(quad[1].x() - (width * F)); quad[1].setX(quad[1].x() - (width * F));
quad[2].setX(quad[2].x() - (width * F)); quad[2].setX(quad[2].x() - (width * F));
} }
if( vertical ) if (vertical) {
{
quad[0].setY(quad[0].y() + (height * F)); quad[0].setY(quad[0].y() + (height * F));
quad[3].setY(quad[3].y() - (height * F)); quad[3].setY(quad[3].y() - (height * F));
quad[1].setY(quad[1].y() + (height * F)); quad[1].setY(quad[1].y() + (height * F));
quad[2].setY(quad[2].y() - (height * F)); quad[2].setY(quad[2].y() - (height * F));
} }
} } else {
else
{
F -= 0.5; F -= 0.5;
if( horizontal ) if (horizontal) {
{
quad[0].setX(cx - (width * F)); quad[0].setX(cx - (width * F));
quad[3].setX(cx - (width * F)); quad[3].setX(cx - (width * F));
quad[1].setX(cx + (width * F)); quad[1].setX(cx + (width * F));
quad[2].setX(cx + (width * F)); quad[2].setX(cx + (width * F));
} }
if( vertical ) if (vertical) {
{
quad[0].setY(cy - (height * F)); quad[0].setY(cy - (height * F));
quad[3].setY(cy + (height * F)); quad[3].setY(cy + (height * F));
quad[1].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); virtual void clientGroupItemSwitched(EffectWindow* from, EffectWindow* to);
static bool supported(); static bool supported();
private: private:
struct swivel struct swivel {
{
EffectWindow* hide; EffectWindow* hide;
EffectWindow* show; EffectWindow* show;
TimeLine time; TimeLine time;

View File

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

View File

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

View File

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

View File

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

View File

@ -235,8 +235,7 @@ void BlurEffect::drawWindow(EffectWindow *w, int mask, QRegion region, WindowPai
&& hasAlpha && !w->isDesktop() && !transformed) && hasAlpha && !w->isDesktop() && !transformed)
shape = blurRegion(w).translated(w->geometry().topLeft()) & screen; shape = blurRegion(w).translated(w->geometry().topLeft()) & screen;
if (valid && !shape.isEmpty() && region.intersects(shape.boundingRect())) if (valid && !shape.isEmpty() && region.intersects(shape.boundingRect())) {
{
doBlur(shape, screen, data.opacity * data.contents_opacity); doBlur(shape, screen, data.opacity * data.contents_opacity);
} }

View File

@ -380,8 +380,7 @@ void ARBBlurShader::unbind()
#ifndef KWIN_HAVE_OPENGLES #ifndef KWIN_HAVE_OPENGLES
int boundObject; int boundObject;
glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_BINDING_ARB, &boundObject); glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_BINDING_ARB, &boundObject);
if( boundObject == program ) if (boundObject == program) {
{
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 0); glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 0);
glDisable(GL_FRAGMENT_PROGRAM_ARB); glDisable(GL_FRAGMENT_PROGRAM_ARB);
} }

View File

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

View File

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

View File

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

View File

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

View File

@ -79,8 +79,7 @@ class CoverSwitchEffect
Window input; Window input;
float zPosition; float zPosition;
float scaleFactor; float scaleFactor;
enum Direction enum Direction {
{
Left, Left,
Right 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 cylinderShortcutChanged(const QKeySequence& seq);
void sphereShortcutChanged(const QKeySequence& seq); void sphereShortcutChanged(const QKeySequence& seq);
private: private:
enum RotationDirection enum RotationDirection {
{
Left, Left,
Right, Right,
Upwards, Upwards,
Downwards Downwards
}; };
enum VerticalRotationPosition enum VerticalRotationPosition {
{
Up, Up,
Normal, Normal,
Down Down
}; };
enum CubeMode enum CubeMode {
{
Cube, Cube,
Cylinder, Cylinder,
Sphere Sphere

View File

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

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -167,13 +167,10 @@ void DesktopGridEffectConfig::defaults()
void DesktopGridEffectConfig::layoutSelectionChanged() void DesktopGridEffectConfig::layoutSelectionChanged()
{ {
if( m_ui->layoutCombo->currentIndex() == DesktopGridEffect::LayoutCustom ) if (m_ui->layoutCombo->currentIndex() == DesktopGridEffect::LayoutCustom) {
{
m_ui->layoutRowsLabel->setEnabled(true); m_ui->layoutRowsLabel->setEnabled(true);
m_ui->layoutRowsSpin->setEnabled(true); m_ui->layoutRowsSpin->setEnabled(true);
} } else {
else
{
m_ui->layoutRowsLabel->setEnabled(false); m_ui->layoutRowsLabel->setEnabled(false);
m_ui->layoutRowsSpin->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 // Check if this window has a modal dialog and change the window's
// effect's strength accordingly // effect's strength accordingly
bool hasDialog = w->findModal() != NULL; bool hasDialog = w->findModal() != NULL;
if( hasDialog ) if (hasDialog) {
{
// Increase effect strength of this window // Increase effect strength of this window
effectStrength[w] = qMin(1.0, effectStrength[w] + time / changeTime); effectStrength[w] = qMin(1.0, effectStrength[w] + time / changeTime);
} } else {
else
{
effectStrength[w] = qMax(0.0, effectStrength[w] - time / changeTime); effectStrength[w] = qMax(0.0, effectStrength[w] - time / changeTime);
} }
@ -58,8 +55,7 @@ void DialogParentEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& da
void DialogParentEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) void DialogParentEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{ {
double s = effectStrength[w]; double s = effectStrength[w];
if(s > 0.0f) if (s > 0.0f) {
{
// Brightness will be within [1.0; 0.6] // Brightness will be within [1.0; 0.6]
data.brightness *= (1.0 - s * 0.4); data.brightness *= (1.0 - s * 0.4);
// Saturation within [1.0; 0.4] // Saturation within [1.0; 0.4]
@ -88,8 +84,7 @@ void DialogParentEffect::windowActivated( EffectWindow* w )
// If this window is a dialog, we need to repaint it's parent window, so // If this window is a dialog, we need to repaint it's parent window, so
// that the effect could be run for it // that the effect could be run for it
// Set the window to be faded (or NULL if no window is active). // Set the window to be faded (or NULL if no window is active).
if( w && w->isModal() ) if (w && w->isModal()) {
{
// w is a modal dialog // w is a modal dialog
EffectWindowList mainwindows = w->mainWindows(); EffectWindowList mainwindows = w->mainWindows();
foreach (EffectWindow * parent, mainwindows) foreach (EffectWindow * parent, mainwindows)
@ -102,8 +97,7 @@ void DialogParentEffect::windowClosed( EffectWindow* w )
// If this window is a dialog, we need to repaint it's parent window, so // If this window is a dialog, we need to repaint it's parent window, so
// that the effect could be run for it // that the effect could be run for it
// Set the window to be faded (or NULL if no window is active). // Set the window to be faded (or NULL if no window is active).
if ( w && w->isModal() ) if (w && w->isModal()) {
{
// w is a modal dialog // w is a modal dialog
EffectWindowList mainwindows = w->mainWindows(); EffectWindowList mainwindows = w->mainWindows();
foreach (EffectWindow * parent, mainwindows) foreach (EffectWindow * parent, mainwindows)

View File

@ -56,8 +56,8 @@ void DimInactiveEffect::prePaintScreen( ScreenPrePaintData& data, int time )
timeline.addTime(time); timeline.addTime(time);
if (oldValue != timeline.value()) if (oldValue != timeline.value())
effects->addRepaintFull(); effects->addRepaintFull();
if( previousActive ) if (previousActive) {
{ // We are fading out the previous window // We are fading out the previous window
previousActive->addRepaintFull(); previousActive->addRepaintFull();
previousActiveTimeline.addTime(time); previousActiveTimeline.addTime(time);
} }
@ -66,8 +66,7 @@ void DimInactiveEffect::prePaintScreen( ScreenPrePaintData& data, int time )
void DimInactiveEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) void DimInactiveEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{ {
if( dimWindow( w ) || w == previousActive ) if (dimWindow(w) || w == previousActive) {
{
double previous = 1.0; double previous = 1.0;
if (w == previousActive) if (w == previousActive)
previous = previousActiveTimeline.value(); previous = previousActiveTimeline.value();
@ -108,36 +107,30 @@ void DimInactiveEffect::windowDeleted( EffectWindow* w )
void DimInactiveEffect::windowActivated(EffectWindow* w) void DimInactiveEffect::windowActivated(EffectWindow* w)
{ {
if( active != NULL ) if (active != NULL) {
{
previousActive = active; previousActive = active;
previousActiveTimeline.setProgress(0.0); previousActiveTimeline.setProgress(0.0);
if (!dimWindow(previousActive)) if (!dimWindow(previousActive))
previousActive = NULL; previousActive = NULL;
if( dim_by_group ) if (dim_by_group) {
{ if ((w == NULL || w->group() != active->group()) && active->group() != NULL) {
if(( w == NULL || w->group() != active->group()) && active->group() != NULL ) // repaint windows that are no longer in the active group
{ // repaint windows that are no longer in the active group
foreach (EffectWindow * tmp, active->group()->members()) foreach (EffectWindow * tmp, active->group()->members())
tmp->addRepaintFull(); tmp->addRepaintFull();
} }
} } else
else
active->addRepaintFull(); active->addRepaintFull();
} }
active = w; active = w;
if( active != NULL ) if (active != NULL) {
{ if (dim_by_group) {
if( dim_by_group ) if (active->group() != NULL) {
{ // repaint newly active windows
if( active->group() != NULL )
{ // repaint newly active windows
foreach (EffectWindow * tmp, active->group()->members()) foreach (EffectWindow * tmp, active->group()->members())
tmp->addRepaintFull(); tmp->addRepaintFull();
} }
} } else
else
active->addRepaintFull(); active->addRepaintFull();
} }
} }

View File

@ -58,15 +58,12 @@ void DimScreenEffect::prePaintScreen( ScreenPrePaintData& data, int time )
void DimScreenEffect::postPaintScreen() void DimScreenEffect::postPaintScreen()
{ {
if( mActivated ) if (mActivated) {
{ if (activateAnimation && timeline.value() == 1.0) {
if( activateAnimation && timeline.value() == 1.0 )
{
activateAnimation = false; activateAnimation = false;
effects->addRepaintFull(); effects->addRepaintFull();
} }
if( deactivateAnimation && timeline.value() == 0.0 ) if (deactivateAnimation && timeline.value() == 0.0) {
{
deactivateAnimation = false; deactivateAnimation = false;
mActivated = false; mActivated = false;
effects->addRepaintFull(); effects->addRepaintFull();
@ -80,8 +77,7 @@ void DimScreenEffect::postPaintScreen()
void DimScreenEffect::paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data) void DimScreenEffect::paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data)
{ {
if( mActivated && ( w != window ) && w->isManaged() ) if (mActivated && (w != window) && w->isManaged()) {
{
data.brightness *= (1.0 - 0.33 * timeline.value()); data.brightness *= (1.0 - 0.33 * timeline.value());
data.saturation *= (1.0 - 0.33 * timeline.value()); data.saturation *= (1.0 - 0.33 * timeline.value());
} }
@ -97,18 +93,14 @@ void DimScreenEffect::windowActivated( EffectWindow *w )
check << "polkit-kde-manager polkit-kde-manager"; check << "polkit-kde-manager polkit-kde-manager";
check << "polkit-kde-authentication-agent-1 polkit-kde-authentication-agent-1"; check << "polkit-kde-authentication-agent-1 polkit-kde-authentication-agent-1";
check << "pinentry pinentry"; check << "pinentry pinentry";
if( check.contains( w->windowClass() ) ) if (check.contains(w->windowClass())) {
{
mActivated = true; mActivated = true;
activateAnimation = true; activateAnimation = true;
deactivateAnimation = false; deactivateAnimation = false;
window = w; window = w;
effects->addRepaintFull(); effects->addRepaintFull();
} } else {
else if (mActivated) {
{
if( mActivated)
{
activateAnimation = false; activateAnimation = false;
deactivateAnimation = true; deactivateAnimation = true;
effects->addRepaintFull(); effects->addRepaintFull();

View File

@ -67,20 +67,16 @@ bool ExplosionEffect::loadData()
const QString fragmentshader = KGlobal::dirs()->findResource("data", "kwin/explosion.frag"); const QString fragmentshader = KGlobal::dirs()->findResource("data", "kwin/explosion.frag");
QString starttexture = KGlobal::dirs()->findResource("data", "kwin/explosion-start.png"); QString starttexture = KGlobal::dirs()->findResource("data", "kwin/explosion-start.png");
QString endtexture = KGlobal::dirs()->findResource("data", "kwin/explosion-end.png"); QString endtexture = KGlobal::dirs()->findResource("data", "kwin/explosion-end.png");
if(starttexture.isEmpty() || endtexture.isEmpty()) if (starttexture.isEmpty() || endtexture.isEmpty()) {
{
kError(1212) << "Couldn't locate texture files" << endl; kError(1212) << "Couldn't locate texture files" << endl;
return false; return false;
} }
mShader = ShaderManager::instance()->loadFragmentShader(ShaderManager::GenericShader, fragmentshader); mShader = ShaderManager::instance()->loadFragmentShader(ShaderManager::GenericShader, fragmentshader);
if(!mShader->isValid()) if (!mShader->isValid()) {
{
kError(1212) << "The shader failed to load!" << endl; kError(1212) << "The shader failed to load!" << endl;
return false; return false;
} } else {
else
{
ShaderManager::instance()->pushShader(mShader); ShaderManager::instance()->pushShader(mShader);
mShader->setUniform("startOffsetTexture", 4); mShader->setUniform("startOffsetTexture", 4);
mShader->setUniform("endOffsetTexture", 5); mShader->setUniform("endOffsetTexture", 5);
@ -89,13 +85,10 @@ bool ExplosionEffect::loadData()
mStartOffsetTex = new GLTexture(starttexture); mStartOffsetTex = new GLTexture(starttexture);
mEndOffsetTex = new GLTexture(endtexture); mEndOffsetTex = new GLTexture(endtexture);
if(mStartOffsetTex->isNull() || mEndOffsetTex->isNull()) if (mStartOffsetTex->isNull() || mEndOffsetTex->isNull()) {
{
kError(1212) << "The textures failed to load!" << endl; kError(1212) << "The textures failed to load!" << endl;
return false; return false;
} } else {
else
{
mStartOffsetTex->setFilter(GL_LINEAR); mStartOffsetTex->setFilter(GL_LINEAR);
mEndOffsetTex->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) void ExplosionEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
{ {
if( mWindows.contains( w )) if (mWindows.contains(w)) {
{
if (mValid && !mInited) if (mValid && !mInited)
mValid = loadData(); mValid = loadData();
if( mValid ) if (mValid) {
{
mWindows[ w ] += time / animationTime(700.0); // complete change in 700ms mWindows[ w ] += time / animationTime(700.0); // complete change in 700ms
if( mWindows[ w ] < 1 ) if (mWindows[ w ] < 1) {
{
data.setTranslucent(); data.setTranslucent();
data.setTransformed(); data.setTransformed();
w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DELETE); w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DELETE);
} } else {
else
{
mWindows.remove(w); mWindows.remove(w);
w->unrefWindow(); w->unrefWindow();
mActiveAnimations--; mActiveAnimations--;
@ -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 // Make sure we have OpenGL compositing and the window is vidible and not a
// special window // special window
bool useshader = (mValid && mWindows.contains(w)); bool useshader = (mValid && mWindows.contains(w));
if( useshader ) if (useshader) {
{
double maxscaleadd = 1.5f; double maxscaleadd = 1.5f;
double scale = 1 + maxscaleadd * mWindows[w]; double scale = 1 + maxscaleadd * mWindows[w];
data.xScale = scale; data.xScale = scale;
@ -173,8 +160,7 @@ void ExplosionEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Wi
// Call the next effect. // Call the next effect.
effects->paintWindow(w, mask, region, data); effects->paintWindow(w, mask, region, data);
if( useshader ) if (useshader) {
{
ShaderManager::instance()->popShader(); ShaderManager::instance()->popShader();
glActiveTexture(GL_TEXTURE4); glActiveTexture(GL_TEXTURE4);
mStartOffsetTex->unbind(); mStartOffsetTex->unbind();
@ -198,8 +184,7 @@ void ExplosionEffect::windowClosed( EffectWindow* c )
const void* e = c->data(WindowClosedGrabRole).value<void*>(); const void* e = c->data(WindowClosedGrabRole).value<void*>();
if (e && e != this) if (e && e != this)
return; return;
if( c->isOnCurrentDesktop() && !c->isMinimized()) if (c->isOnCurrentDesktop() && !c->isMinimized()) {
{
mWindows[ c ] = 0; // count up to 1 mWindows[ c ] = 0; // count up to 1
c->addRepaintFull(); c->addRepaintFull();
c->refWindow(); c->refWindow();

View File

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

View File

@ -41,20 +41,17 @@ void FadeDesktopEffect::reconfigure( ReconfigureFlags )
void FadeDesktopEffect::prePaintScreen(ScreenPrePaintData &data, int time) void FadeDesktopEffect::prePaintScreen(ScreenPrePaintData &data, int time)
{ {
if( m_fading ) if (m_fading) {
{
m_timeline.addTime(time); m_timeline.addTime(time);
// PAINT_SCREEN_BACKGROUND_FIRST is needed because screen will be actually painted more than once, // 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 // so with normal screen painting second screen paint would erase parts of the first paint
if (m_timeline.value() != 1.0) if (m_timeline.value() != 1.0)
data.mask |= PAINT_SCREEN_TRANSFORMED | PAINT_SCREEN_BACKGROUND_FIRST; data.mask |= PAINT_SCREEN_TRANSFORMED | PAINT_SCREEN_BACKGROUND_FIRST;
else else {
{
m_fading = false; m_fading = false;
m_timeline.setProgress(0.0); m_timeline.setProgress(0.0);
foreach( EffectWindow* w, effects->stackingOrder() ) foreach (EffectWindow * w, effects->stackingOrder()) {
{
w->setData(WindowForceBlurRole, QVariant(false)); w->setData(WindowForceBlurRole, QVariant(false));
} }
effects->setActiveFullScreenEffect(NULL); effects->setActiveFullScreenEffect(NULL);
@ -72,8 +69,7 @@ void FadeDesktopEffect::postPaintScreen()
void FadeDesktopEffect::prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time) void FadeDesktopEffect::prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time)
{ {
if( m_fading ) if (m_fading) {
{
if (w->isOnDesktop(m_oldDesktop)) if (w->isOnDesktop(m_oldDesktop))
w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DESKTOP); w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DESKTOP);
data.setTranslucent(); data.setTranslucent();
@ -83,8 +79,7 @@ void FadeDesktopEffect::prePaintWindow( EffectWindow *w, WindowPrePaintData &dat
void FadeDesktopEffect::paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data) 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)) if (w->isOnDesktop(m_oldDesktop))
data.opacity *= 1 - m_timeline.value(); data.opacity *= 1 - m_timeline.value();
else else
@ -104,8 +99,7 @@ void FadeDesktopEffect::desktopChanged( int old )
m_fading = true; m_fading = true;
m_timeline.setProgress(0); m_timeline.setProgress(0);
m_oldDesktop = old; m_oldDesktop = old;
foreach( EffectWindow* w, effects->stackingOrder() ) foreach (EffectWindow * w, effects->stackingOrder()) {
{
w->setData(WindowForceBlurRole, QVariant(true)); 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) void FallApartEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
{ {
if( windows.contains( w ) && isRealWindow( w )) if (windows.contains(w) && isRealWindow(w)) {
{ if (windows[ w ] < 1) {
if( windows[ w ] < 1 )
{
windows[ w ] += time / animationTime(1000.); windows[ w ] += time / animationTime(1000.);
data.setTransformed(); data.setTransformed();
w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DELETE); w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DELETE);
// Request the window to be divided into cells // Request the window to be divided into cells
data.quads = data.quads.makeGrid(blockSize); data.quads = data.quads.makeGrid(blockSize);
} } else {
else
{
windows.remove(w); windows.remove(w);
w->unrefWindow(); w->unrefWindow();
} }
@ -69,12 +65,10 @@ void FallApartEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data,
void FallApartEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& 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; WindowQuadList new_quads;
int cnt = 0; 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 // make fragments move in various directions, based on where
// they are (left pieces generally move to the left, etc.) // they are (left pieces generally move to the left, etc.)
QPointF p1(quad[ 0 ].x(), quad[ 0 ].y()); 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); ydiff += (rand() % 21 - 10);
for (int j = 0; for (int j = 0;
j < 4; j < 4;
++j ) ++j) {
{
quad[ j ].move(quad[ j ].x() + xdiff * modif, quad[ j ].y() + ydiff * modif); quad[ j ].move(quad[ j ].x() + xdiff * modif, quad[ j ].y() + ydiff * modif);
} }
// also make the fragments rotate around their center // 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 double adiff = (rand() % 720 - 360) / 360. * 2 * M_PI; // spin randomly
for (int j = 0; for (int j = 0;
j < 4; j < 4;
++j ) ++j) {
{
double x = quad[ j ].x() - center.x(); double x = quad[ j ].x() - center.x();
double y = quad[ j ].y() - center.y(); double y = quad[ j ].y() - center.y();
double angle = atan2(y, x); double angle = atan2(y, x);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -78,8 +78,7 @@ bool InvertEffect::loadData()
const QString fragmentshader = KGlobal::dirs()->findResource("data", "kwin/invert.frag"); const QString fragmentshader = KGlobal::dirs()->findResource("data", "kwin/invert.frag");
m_shader = ShaderManager::instance()->loadFragmentShader(ShaderManager::GenericShader, fragmentshader); m_shader = ShaderManager::instance()->loadFragmentShader(ShaderManager::GenericShader, fragmentshader);
if( !m_shader->isValid() ) if (!m_shader->isValid()) {
{
kError(1212) << "The shader failed to load!" << endl; kError(1212) << "The shader failed to load!" << endl;
return false; 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) 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); frame->setShader(m_shader);
ShaderManager::instance()->pushShader(m_shader); ShaderManager::instance()->pushShader(m_shader);
m_shader->setUniform("screenTransformation", QMatrix4x4()); m_shader->setUniform("screenTransformation", QMatrix4x4());
m_shader->setUniform("windowTransformation", QMatrix4x4()); m_shader->setUniform("windowTransformation", QMatrix4x4());
effects->paintEffectFrame(frame, region, opacity, frameOpacity); effects->paintEffectFrame(frame, region, opacity, frameOpacity);
ShaderManager::instance()->popShader(); ShaderManager::instance()->popShader();
} } else {
else
{
effects->paintEffectFrame(frame, region, opacity, frameOpacity); effects->paintEffectFrame(frame, region, opacity, frameOpacity);
} }
} }

View File

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

View File

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

View File

@ -146,21 +146,16 @@ bool LookingGlassEffect::loadData()
void LookingGlassEffect::toggle() void LookingGlassEffect::toggle()
{ {
if( target_zoom == 1.0f ) if (target_zoom == 1.0f) {
{
target_zoom = 2.0f; target_zoom = 2.0f;
if( !polling ) if (!polling) {
{
polling = true; polling = true;
effects->startMousePolling(); effects->startMousePolling();
} }
m_enabled = true; m_enabled = true;
} } else {
else
{
target_zoom = 1.0f; target_zoom = 1.0f;
if( polling ) if (polling) {
{
polling = false; polling = false;
effects->stopMousePolling(); effects->stopMousePolling();
} }
@ -172,8 +167,7 @@ void LookingGlassEffect::zoomIn()
{ {
target_zoom = qMin(7.0, target_zoom + 0.5); target_zoom = qMin(7.0, target_zoom + 0.5);
m_enabled = true; m_enabled = true;
if( !polling ) if (!polling) {
{
polling = true; polling = true;
effects->startMousePolling(); effects->startMousePolling();
} }
@ -183,12 +177,10 @@ void LookingGlassEffect::zoomIn()
void LookingGlassEffect::zoomOut() void LookingGlassEffect::zoomOut()
{ {
target_zoom -= 0.5; target_zoom -= 0.5;
if( target_zoom < 1 ) if (target_zoom < 1) {
{
target_zoom = 1; target_zoom = 1;
m_enabled = false; m_enabled = false;
if( polling ) if (polling) {
{
polling = false; polling = false;
effects->stopMousePolling(); effects->stopMousePolling();
} }
@ -198,8 +190,7 @@ void LookingGlassEffect::zoomOut()
void LookingGlassEffect::prePaintScreen(ScreenPrePaintData& data, int time) void LookingGlassEffect::prePaintScreen(ScreenPrePaintData& data, int time)
{ {
if( zoom != target_zoom ) if (zoom != target_zoom) {
{
double diff = time / animationTime(500.0); double diff = time / animationTime(500.0);
if (target_zoom > zoom) if (target_zoom > zoom)
zoom = qMin(zoom * qMax(1.0 + diff, 1.2), target_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, void LookingGlassEffect::mouseChanged(const QPoint& pos, const QPoint& old, Qt::MouseButtons,
Qt::MouseButtons, Qt::KeyboardModifiers, Qt::KeyboardModifiers) 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(pos.x() - radius, pos.y() - radius, 2 * radius, 2 * radius);
effects->addRepaint(old.x() - radius, old.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(); QHash< EffectWindow*, TimeLine >::iterator entry = mTimeLineWindows.begin();
bool erase = false; bool erase = false;
while( entry != mTimeLineWindows.end() ) while (entry != mTimeLineWindows.end()) {
{
TimeLine &timeline = entry.value(); TimeLine &timeline = entry.value();
if( entry.key()->isMinimized() ) if (entry.key()->isMinimized()) {
{
timeline.addTime(time); timeline.addTime(time);
erase = (timeline.progress() >= 1.0f); erase = (timeline.progress() >= 1.0f);
} } else {
else
{
timeline.removeTime(time); timeline.removeTime(time);
erase = (timeline.progress() <= 0.0f); 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 // Schedule window for transformation if the animation is still in
// progress // progress
if( mTimeLineWindows.contains( w )) if (mTimeLineWindows.contains(w)) {
{
// We'll transform this window // We'll transform this window
data.setTransformed(); data.setTransformed();
data.quads = data.quads.makeGrid(40); 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) 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 // 0 = not minimized, 1 = fully minimized
float progress = mTimeLineWindows[w].value(); 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); QRect area = effects->clientArea(ScreenArea, w);
IconPosition position = Top; IconPosition position = Top;
// If there's no icon geometry, minimize to the center of the screen // 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]); QRect extG = geo.adjusted(mShadowOffset[0], mShadowOffset[1], mShadowOffset[2], mShadowOffset[3]);
QPoint pt = QCursor::pos(); QPoint pt = QCursor::pos();
// focussing inside the window is no good, leads to ugly artefacts, find nearest border // 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()}, 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]; int di = d[1][0];
position = Top; position = Top;
if (d[0][0] < di) if (d[0][0] < di) {
{
di = d[0][0]; di = d[0][0];
position = Left; position = Left;
} }
if (d[1][1] < di) if (d[1][1] < di) {
{
di = d[1][1]; di = d[1][1];
position = Bottom; position = Bottom;
} }
if (d[0][1] < di) if (d[0][1] < di)
position = Right; position = Right;
switch (position) switch(position) {
{
case Top: pt.setY(extG.y()); break; case Top: pt.setY(extG.y()); break;
case Left: pt.setX(extG.x()); break; case Left: pt.setX(extG.x()); break;
case Bottom: pt.setY(extG.bottom()); break; case Bottom: pt.setY(extG.bottom()); break;
case Right: pt.setX(extG.right()); break; case Right: pt.setX(extG.right()); break;
} }
} } else {
else
{
if (pt.y() < geo.y()) if (pt.y() < geo.y())
position = Top; position = Top;
else if (pt.x() < geo.x()) else if (pt.x() < geo.x())
@ -161,47 +149,37 @@ void MagicLampEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Wi
position = Right; position = Right;
} }
icon = QRect(pt, QSize(0, 0)); icon = QRect(pt, QSize(0, 0));
} } else {
else
{
// Assumption: there is a panel containing the icon position // Assumption: there is a panel containing the icon position
EffectWindow* panel = NULL; EffectWindow* panel = NULL;
foreach( EffectWindow* window, effects->stackingOrder() ) foreach (EffectWindow * window, effects->stackingOrder()) {
{
if (!window->isDock()) if (!window->isDock())
continue; continue;
// we have to use intersects as there seems to be a Plasma bug // we have to use intersects as there seems to be a Plasma bug
// the published icon geometry might be bigger than the panel // the published icon geometry might be bigger than the panel
if( window->geometry().intersects( icon ) ) if (window->geometry().intersects(icon)) {
{
panel = window; panel = window;
break; break;
} }
} }
if( panel ) if (panel) {
{
// Assumption: width of horizonal panel is greater than its height and vice versa // 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 // The panel has to border one screen edge, so get it's screen area
QRect panelScreen = effects->clientArea(ScreenArea, panel); QRect panelScreen = effects->clientArea(ScreenArea, panel);
if( panel->width() >= panel->height() ) if (panel->width() >= panel->height()) {
{
// horizontal panel // horizontal panel
if (panel->y() == panelScreen.y()) if (panel->y() == panelScreen.y())
position = Top; position = Top;
else else
position = Bottom; position = Bottom;
} } else {
else
{
// vertical panel // vertical panel
if (panel->x() == panelScreen.x()) if (panel->x() == panelScreen.x())
position = Left; position = Left;
else else
position = Right; position = Right;
} }
} } else {
else
{
// we did not find a panel, so it might be autohidden // we did not find a panel, so it might be autohidden
QRect iconScreen = effects->clientArea(ScreenArea, icon.topLeft(), effects->currentDesktop()); QRect iconScreen = effects->clientArea(ScreenArea, icon.topLeft(), effects->currentDesktop());
// as the icon geometry could be overlap a screen edge we use an intersection // 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 // 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 // in this case the icon borders two screen edges
// there might be a wrong animation, but not distorted // there might be a wrong animation, but not distorted
if( rect.x() == iconScreen.x() ) if (rect.x() == iconScreen.x()) {
{
position = Left; position = Left;
} } else if (rect.x() + rect.width() == iconScreen.x() + iconScreen.width()) {
else if( rect.x() + rect.width() == iconScreen.x() + iconScreen.width() )
{
position = Right; position = Right;
} } else if (rect.y() == iconScreen.y()) {
else if( rect.y() == iconScreen.y() )
{
position = Top; position = Top;
} } else {
else
{
position = Bottom; position = Bottom;
} }
} }
} }
WindowQuadList newQuads; WindowQuadList newQuads;
foreach( WindowQuad quad, data.quads ) // krazy:exclude=foreach foreach (WindowQuad quad, data.quads) { // krazy:exclude=foreach
{ if (position == Top || position == Bottom) {
if( position == Top || position == Bottom )
{
// quadFactor defines how fast a quad is vertically moved: y coordinates near to window top are slowed down // 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 // it is used as quadFactor^3/windowHeight^3
// quadFactor is the y position of the quad but is changed towards becomming the window height // 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 // factor is the current moved y value diveded by the distance between icon and window
float topProgress; float topProgress;
float bottomProgress; float bottomProgress;
if( position == Bottom ) if (position == Bottom) {
{
quadFactor = quad[0].y() + (geo.height() - quad[0].y()) * progress; quadFactor = quad[0].y() + (geo.height() - quad[0].y()) * progress;
yOffsetTop = (icon.y() + quad[0].y() - geo.y()) * progress * yOffsetTop = (icon.y() + quad[0].y() - geo.y()) * progress *
((quadFactor * quadFactor * quadFactor) / (geo.height() * geo.height() * geo.height())); ((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())); ((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); 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); 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; quadFactor = geo.height() - quad[0].y() + (quad[0].y()) * progress;
yOffsetTop = (geo.y() - icon.height() + geo.height() + quad[0].y() - icon.y()) * progress * yOffsetTop = (geo.y() - icon.height() + geo.height() + quad[0].y() - icon.y()) * progress *
((quadFactor * quadFactor * quadFactor) / (geo.height() * geo.height() * geo.height())); ((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() - bottomProgress = qMin(yOffsetBottom / (geo.y() - icon.height() + geo.height() - icon.y() -
(float)((geo.height() - quad[2].y()) / geo.height() * geo.height())), 1.0f); (float)((geo.height() - quad[2].y()) / geo.height() * geo.height())), 1.0f);
} }
if( position == Top ) if (position == Top) {
{
yOffsetTop *= -1; yOffsetTop *= -1;
yOffsetBottom *= -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[1].setY(quad[1].y() + yOffsetTop);
quad[2].setY(quad[2].y() + yOffsetBottom); quad[2].setY(quad[2].y() + yOffsetBottom);
quad[3].setY(quad[3].y() + yOffsetBottom); quad[3].setY(quad[3].y() + yOffsetBottom);
} } else {
else
{
float quadFactor; float quadFactor;
float xOffsetLeft; float xOffsetLeft;
float xOffsetRight; float xOffsetRight;
float leftProgress; float leftProgress;
float rightProgress; float rightProgress;
if( position == Right ) if (position == Right) {
{
quadFactor = quad[0].x() + (geo.width() - quad[0].x()) * progress; quadFactor = quad[0].x() + (geo.width() - quad[0].x()) * progress;
xOffsetLeft = (icon.x() + quad[0].x() - geo.x()) * progress * xOffsetLeft = (icon.x() + quad[0].x() - geo.x()) * progress *
((quadFactor * quadFactor * quadFactor) / (geo.width() * geo.width() * geo.width())); ((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())); ((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); 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); 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; quadFactor = geo.width() - quad[0].x() + (quad[0].x()) * progress;
xOffsetLeft = (geo.x() - icon.width() + geo.width() + quad[0].x() - icon.x()) * progress * xOffsetLeft = (geo.x() - icon.width() + geo.width() + quad[0].x() - icon.x()) * progress *
((quadFactor * quadFactor * quadFactor) / (geo.width() * geo.width() * geo.width())); ((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() - rightProgress = qMin(xOffsetRight / (geo.x() - icon.width() + geo.width() - icon.x() -
(float)((geo.width() - quad[1].x()) / geo.width() * geo.width())), 1.0f); (float)((geo.width() - quad[1].x()) / geo.width() * geo.width())), 1.0f);
} }
if( position == Left ) if (position == Left) {
{
xOffsetLeft *= -1; xOffsetLeft *= -1;
xOffsetRight *= -1; xOffsetRight *= -1;
} }

View File

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

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -67,8 +67,7 @@ class PresentWindowsEffect
Q_OBJECT Q_OBJECT
private: private:
// Structures // Structures
struct WindowData struct WindowData {
{
bool visible; bool visible;
bool deleted; bool deleted;
bool referenced; bool referenced;
@ -80,8 +79,7 @@ class PresentWindowsEffect
EffectFrame* iconFrame; EffectFrame* iconFrame;
}; };
typedef QHash<EffectWindow*, WindowData> DataHash; typedef QHash<EffectWindow*, WindowData> DataHash;
struct GridSize struct GridSize {
{
int columns; int columns;
int rows; int rows;
}; };
@ -121,16 +119,14 @@ class PresentWindowsEffect
virtual void propertyNotify(EffectWindow* w, long atom); virtual void propertyNotify(EffectWindow* w, long atom);
enum { LayoutNatural, LayoutRegularGrid, LayoutFlexibleGrid }; // Layout modes enum { LayoutNatural, LayoutRegularGrid, LayoutFlexibleGrid }; // Layout modes
enum PresentWindowsMode enum PresentWindowsMode {
{
ModeAllDesktops, // Shows windows of all desktops ModeAllDesktops, // Shows windows of all desktops
ModeCurrentDesktop, // Shows windows on current desktop ModeCurrentDesktop, // Shows windows on current desktop
ModeSelectedDesktop, // Shows windows of selected desktop via property (m_desktop) ModeSelectedDesktop, // Shows windows of selected desktop via property (m_desktop)
ModeWindowGroup, // Shows windows selected via property ModeWindowGroup, // Shows windows selected via property
ModeWindowClass // Shows all windows of same class as selected class ModeWindowClass // Shows all windows of same class as selected class
}; };
enum WindowMouseAction enum WindowMouseAction {
{
WindowNoAction = 0, // Nothing WindowNoAction = 0, // Nothing
WindowActivateAction = 1, // Activates the window and deactivates the effect WindowActivateAction = 1, // Activates the window and deactivates the effect
WindowExitAction = 2, // Deactivates the effect without activating new window WindowExitAction = 2, // Deactivates the effect without activating new window
@ -139,8 +135,7 @@ class PresentWindowsEffect
WindowMinimizeAction = 5, // Minimize the window WindowMinimizeAction = 5, // Minimize the window
WindowCloseAction = 6 // Closes the window WindowCloseAction = 6 // Closes the window
}; };
enum DesktopMouseAction enum DesktopMouseAction {
{
DesktopNoAction = 0, // nothing DesktopNoAction = 0, // nothing
DesktopActivateAction = 1, // Activates the window and deactivates the effect DesktopActivateAction = 1, // Activates the window and deactivates the effect
DesktopExitAction = 2, // Deactivates the effect without activating new window DesktopExitAction = 2, // Deactivates the effect without activating new window
@ -149,8 +144,14 @@ class PresentWindowsEffect
public slots: public slots:
void setActive(bool active, bool closingTab = false); // HACK: closingTab shouldn't be needed void setActive(bool active, bool closingTab = false); // HACK: closingTab shouldn't be needed
void toggleActive() { m_mode = ModeCurrentDesktop; setActive( !m_activated ); } void toggleActive() {
void toggleActiveAllDesktops() { m_mode = ModeAllDesktops; setActive( !m_activated ); } m_mode = ModeCurrentDesktop;
setActive(!m_activated);
}
void toggleActiveAllDesktops() {
m_mode = ModeAllDesktops;
setActive(!m_activated);
}
void toggleActiveClass(); void toggleActiveClass();
// slots for global shortcut changed // slots for global shortcut changed
@ -175,12 +176,15 @@ class PresentWindowsEffect
WindowMotionManager& motionManager); WindowMotionManager& motionManager);
// Helper functions for window rearranging // Helper functions for window rearranging
inline double aspectRatio( EffectWindow *w ) inline double aspectRatio(EffectWindow *w) {
{ return w->width() / double( w->height() ); } return w->width() / double(w->height());
inline int widthForHeight( EffectWindow *w, int height ) }
{ return int(( height / double( w->height() )) * w->width() ); } inline int widthForHeight(EffectWindow *w, int height) {
inline int heightForWidth( EffectWindow *w, int width ) return int((height / double(w->height())) * w->width());
{ return int(( width / double( w->width() )) * w->height() ); } }
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 assignSlots(EffectWindowList windowlist, const QRect &area, int columns, int rows);
void getBestAssignments(EffectWindowList windowlist); void getBestAssignments(EffectWindowList windowlist);
bool isOverlappingAny(EffectWindow *w, const QHash<EffectWindow*, QRect> &targets, const QRegion &border); 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) void ResizeEffect::prePaintScreen(ScreenPrePaintData& data, int time)
{ {
if( m_active ) if (m_active) {
{
data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS; data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
} }
effects->prePaintScreen(data, time); 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) void ResizeEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{ {
if( m_active && w == m_resizeWindow ) if (m_active && w == m_resizeWindow) {
{ if (m_features & TextureScale) {
if( m_features & TextureScale )
{
data.xTranslate += m_currentGeometry.x() - m_originalGeometry.x(); data.xTranslate += m_currentGeometry.x() - m_originalGeometry.x();
data.xScale *= m_currentGeometry.width(); data.xScale *= m_currentGeometry.width();
data.xScale /= m_originalGeometry.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); effects->paintWindow(w, mask, region, data);
if( m_features & Outline ) if (m_features & Outline) {
{
QRegion intersection = m_originalGeometry.intersected(m_currentGeometry); QRegion intersection = m_originalGeometry.intersected(m_currentGeometry);
QRegion paintRegion = QRegion(m_originalGeometry).united(m_currentGeometry).subtracted(intersection); QRegion paintRegion = QRegion(m_originalGeometry).united(m_currentGeometry).subtracted(intersection);
float alpha = 0.8f; float alpha = 0.8f;
@ -122,8 +118,7 @@ void ResizeEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Windo
#endif #endif
#ifdef KWIN_HAVE_XRENDER_COMPOSITING #ifdef KWIN_HAVE_XRENDER_COMPOSITING
if( effects->compositingType() == XRenderCompositing) if (effects->compositingType() == XRenderCompositing) {
{
XRenderColor col; XRenderColor col;
col.alpha = int(alpha * 0xffff); col.alpha = int(alpha * 0xffff);
col.red = int(alpha * 0xffff * color.red() / 255); col.red = int(alpha * 0xffff * color.red() / 255);
@ -135,8 +130,7 @@ void ResizeEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Windo
} }
#endif #endif
} }
} } else
else
effects->paintWindow(w, mask, region, data); effects->paintWindow(w, mask, region, data);
} }
@ -152,21 +146,18 @@ void ResizeEffect::reconfigure( ReconfigureFlags )
void ResizeEffect::windowUserMovedResized(EffectWindow* w, bool first, bool last) void ResizeEffect::windowUserMovedResized(EffectWindow* w, bool first, bool last)
{ {
if( first && last ) if (first && last) {
{
// not interested in maximized // not interested in maximized
return; return;
} }
if( first && w->isUserResize() && !w->isUserMove() ) if (first && w->isUserResize() && !w->isUserMove()) {
{
m_active = true; m_active = true;
m_resizeWindow = w; m_resizeWindow = w;
m_originalGeometry = w->geometry(); m_originalGeometry = w->geometry();
m_currentGeometry = w->geometry(); m_currentGeometry = w->geometry();
w->addRepaintFull(); w->addRepaintFull();
} }
if( m_active && w == m_resizeWindow && last ) if (m_active && w == m_resizeWindow && last) {
{
m_active = false; m_active = false;
m_resizeWindow = NULL; m_resizeWindow = NULL;
effects->addRepaintFull(); effects->addRepaintFull();
@ -175,8 +166,7 @@ void ResizeEffect::windowUserMovedResized( EffectWindow* w, bool first, bool las
void ResizeEffect::windowMoveResizeGeometryUpdate(EffectWindow* c, const QRect& geometry) void ResizeEffect::windowMoveResizeGeometryUpdate(EffectWindow* c, const QRect& geometry)
{ {
if( m_active && c == m_resizeWindow ) if (m_active && c == m_resizeWindow) {
{
m_currentGeometry = geometry; m_currentGeometry = geometry;
effects->addRepaintFull(); effects->addRepaintFull();
} }

View File

@ -32,7 +32,9 @@ class ResizeEffect
public: public:
ResizeEffect(); ResizeEffect();
~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 prePaintScreen(ScreenPrePaintData& data, int time);
virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time); virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time);
virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);

View File

@ -34,8 +34,7 @@ void ScaleInEffect::prePaintScreen( ScreenPrePaintData& data, int time )
void ScaleInEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& 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 ].setCurveShape(TimeLine::EaseOutCurve);
mTimeLineWindows[ w ].addTime(time); mTimeLineWindows[ w ].addTime(time);
if (mTimeLineWindows[ w ].value() < 1) 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) 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.opacity *= mTimeLineWindows[ w ].value();
data.xScale *= mTimeLineWindows[ w ].value(); data.xScale *= mTimeLineWindows[ w ].value();
data.yScale *= mTimeLineWindows[ w ].value(); data.yScale *= mTimeLineWindows[ w ].value();
@ -77,8 +75,7 @@ void ScaleInEffect::postPaintWindow( EffectWindow* w )
void ScaleInEffect::windowAdded(EffectWindow* c) void ScaleInEffect::windowAdded(EffectWindow* c)
{ {
if( c->isOnCurrentDesktop()) if (c->isOnCurrentDesktop()) {
{
mTimeLineWindows[ c ].setDuration(animationTime(250)); mTimeLineWindows[ c ].setDuration(animationTime(250));
mTimeLineWindows[ c ].setProgress(0.0); mTimeLineWindows[ c ].setProgress(0.0);
c->addRepaintFull(); c->addRepaintFull();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -42,20 +42,17 @@ static inline bool windowsShareDesktop( EffectWindow *w1, EffectWindow *w2 )
void SlideBackEffect::windowActivated(EffectWindow* w) void SlideBackEffect::windowActivated(EffectWindow* w)
{ {
if( w == NULL || w->keepAbove()) // plasma popups, yakuake etc... if (w == NULL || w->keepAbove()) { // plasma popups, yakuake etc...
{
return; return;
} }
if( disabled || effects->activeFullScreenEffect() ) // TabBox or PresentWindows/Cube in progress if (disabled || effects->activeFullScreenEffect()) { // TabBox or PresentWindows/Cube in progress
{
updateStackingOrder(); updateStackingOrder();
disabled = false; disabled = false;
return; 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(); updateStackingOrder();
return; return;
} }
@ -66,36 +63,27 @@ void SlideBackEffect::windowActivated( EffectWindow* w )
return; return;
} }
if( clientItemShown == w ) if (clientItemShown == w) {
{
clientItemShown = NULL; clientItemShown = NULL;
updateStackingOrder(); updateStackingOrder();
return; return;
} }
if( clientItemHidden == w ) if (clientItemHidden == w) {
{
clientItemHidden = NULL; clientItemHidden = NULL;
updateStackingOrder(); updateStackingOrder();
return; return;
} }
// Determine all windows on top of the activated one // Determine all windows on top of the activated one
bool currentFound = false; bool currentFound = false;
foreach( EffectWindow *tmp, oldStackingOrder ) foreach (EffectWindow * tmp, oldStackingOrder) {
{ if (!currentFound) {
if( !currentFound ) if (tmp == w) {
{
if( tmp == w )
{
currentFound = true; currentFound = true;
} }
} } else {
else if (isWindowUsable(tmp) && windowsShareDesktop(tmp, w)) {
{
if( isWindowUsable( tmp ) && windowsShareDesktop( tmp, w ) )
{
// Do we have to move it? // Do we have to move it?
if( intersects( w, tmp->geometry() ) ) if (intersects(w, tmp->geometry())) {
{
QRect slideRect; QRect slideRect;
slideRect = getSlideDestination(getModalGroupGeometry(w), tmp->geometry()); slideRect = getSlideDestination(getModalGroupGeometry(w), tmp->geometry());
effects->setElevatedWindow(tmp, true); effects->setElevatedWindow(tmp, true);
@ -104,14 +92,10 @@ void SlideBackEffect::windowActivated( EffectWindow* w )
motionManager.moveWindow(tmp, slideRect); motionManager.moveWindow(tmp, slideRect);
destinationList.insert(tmp, slideRect); destinationList.insert(tmp, slideRect);
coveringWindows.append(tmp); coveringWindows.append(tmp);
} } else {
else
{
//Does it intersect with a moved (elevated) window and do we have to elevate it too? //Does it intersect with a moved (elevated) window and do we have to elevate it too?
foreach( EffectWindow *elevatedWindow, elevatedList ) foreach (EffectWindow * elevatedWindow, elevatedList) {
{ if (tmp->geometry().intersects(elevatedWindow->geometry())) {
if( tmp->geometry().intersects( elevatedWindow->geometry() ) )
{
effects->setElevatedWindow(tmp, true); effects->setElevatedWindow(tmp, true);
elevatedList.append(tmp); elevatedList.append(tmp);
break; break;
@ -120,8 +104,7 @@ void SlideBackEffect::windowActivated( EffectWindow* w )
} }
} }
if( tmp->isDock() || tmp->keepAbove() ) if (tmp->isDock() || tmp->keepAbove()) {
{
effects->setElevatedWindow(tmp, true); effects->setElevatedWindow(tmp, true);
elevatedList.append(tmp); 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. // If a window is minimized it could happen that the panels stay elevated without any windows sliding.
// clear all elevation settings // clear all elevation settings
if( !motionManager.managingWindows() ) if (!motionManager.managingWindows()) {
{ foreach (EffectWindow * tmp, elevatedList) {
foreach( EffectWindow* tmp, elevatedList )
{
effects->setElevatedWindow(tmp, false); effects->setElevatedWindow(tmp, false);
} }
} }
@ -148,23 +129,18 @@ QRect SlideBackEffect::getSlideDestination( const QRect &windowUnderGeometry, co
int downSlide = windowUnderGeometry.bottom() - windowOverGeometry.top() + 20; int downSlide = windowUnderGeometry.bottom() - windowOverGeometry.top() + 20;
int horizSlide = leftSlide; int horizSlide = leftSlide;
if( qAbs( horizSlide ) > qAbs( rightSlide ) ) if (qAbs(horizSlide) > qAbs(rightSlide)) {
{
horizSlide = rightSlide; horizSlide = rightSlide;
} }
int vertSlide = upSlide; int vertSlide = upSlide;
if( qAbs( vertSlide ) > qAbs( downSlide ) ) if (qAbs(vertSlide) > qAbs(downSlide)) {
{
vertSlide = downSlide; vertSlide = downSlide;
} }
QRect slideRect = windowOverGeometry; QRect slideRect = windowOverGeometry;
if( qAbs( horizSlide ) < qAbs( vertSlide ) ) if (qAbs(horizSlide) < qAbs(vertSlide)) {
{
slideRect.moveLeft(slideRect.x() + horizSlide); slideRect.moveLeft(slideRect.x() + horizSlide);
} } else {
else
{
slideRect.moveTop(slideRect.y() + vertSlide); slideRect.moveTop(slideRect.y() + vertSlide);
} }
return slideRect; return slideRect;
@ -178,8 +154,7 @@ void SlideBackEffect::updateStackingOrder()
void SlideBackEffect::prePaintScreen(ScreenPrePaintData &data, int time) void SlideBackEffect::prePaintScreen(ScreenPrePaintData &data, int time)
{ {
if( motionManager.managingWindows() ) if (motionManager.managingWindows()) {
{
motionManager.calculate(time); motionManager.calculate(time);
data.mask |= Effect::PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS; data.mask |= Effect::PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
} }
@ -188,8 +163,7 @@ void SlideBackEffect::prePaintScreen( ScreenPrePaintData &data, int time )
void SlideBackEffect::postPaintScreen() void SlideBackEffect::postPaintScreen()
{ {
if( motionManager.areWindowsMoving() ) if (motionManager.areWindowsMoving()) {
{
effects->addRepaintFull(); effects->addRepaintFull();
} }
effects->postPaintScreen(); effects->postPaintScreen();
@ -197,8 +171,7 @@ void SlideBackEffect::postPaintScreen()
void SlideBackEffect::prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time) void SlideBackEffect::prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time)
{ {
if( motionManager.isManaging( w ) ) if (motionManager.isManaging(w)) {
{
data.setTransformed(); data.setTransformed();
} }
@ -207,15 +180,12 @@ void SlideBackEffect::prePaintWindow( EffectWindow *w, WindowPrePaintData &data,
void SlideBackEffect::paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &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: /* This can happen because of two reasons:
- a window has received the focus earlier without being raised and is raised now. -> call windowActivated() now - 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;*/ - paintWindow() is called with a new stackingOrder before activateWindow(). Bug? -> don't draw the overlapping content;*/
foreach( EffectWindow *tmp, oldStackingOrder ) foreach (EffectWindow * tmp, oldStackingOrder) {
{ if (oldStackingOrder.lastIndexOf(tmp) > oldStackingOrder.lastIndexOf(w) && isWindowUsable(tmp) && windowsShareDesktop(tmp, w)) {
if( oldStackingOrder.lastIndexOf( tmp ) > oldStackingOrder.lastIndexOf( w ) && isWindowUsable( tmp ) && windowsShareDesktop( tmp, w ) )
{
kDebug(1212) << "screw detected. region:" << region << "clipping:" << tmp->geometry() ; kDebug(1212) << "screw detected. region:" << region << "clipping:" << tmp->geometry() ;
clippedRegions << region.subtracted(tmp->geometry()); clippedRegions << region.subtracted(tmp->geometry());
PaintClipper::push(clippedRegions.last()); 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. // Finally call windowActivated in case a already active window is raised.
windowActivated(w); windowActivated(w);
} }
if( motionManager.isManaging( w ) ) if (motionManager.isManaging(w)) {
{
motionManager.apply(w, data); motionManager.apply(w, data);
} }
effects->paintWindow(w, mask, region, 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) void SlideBackEffect::postPaintWindow(EffectWindow* w)
{ {
if( motionManager.isManaging( w ) ) if (motionManager.isManaging(w)) {
{ if (destinationList.contains(w)) {
if( destinationList.contains( w ) )
{
// has window reched its destination? // has window reched its destination?
if ((qAbs(motionManager.transformedGeometry(w).x() - destinationList[w].x()) < 1) && 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 // 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 // restore the stacking order of all windows not intersecting any more except panels
if( coveringWindows.contains( w ) ) if (coveringWindows.contains(w)) {
{
EffectWindowList tmpList; EffectWindowList tmpList;
foreach( EffectWindow *tmp, elevatedList ) foreach (EffectWindow * tmp, elevatedList) {
{
QRect elevatedGeometry = tmp->geometry(); QRect elevatedGeometry = tmp->geometry();
if( motionManager.isManaging( tmp ) ) if (motionManager.isManaging(tmp)) {
{
elevatedGeometry = motionManager.transformedGeometry(tmp).toAlignedRect(); 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; QRect newDestination;
newDestination = getSlideDestination(getModalGroupGeometry(effects->activeWindow()), elevatedGeometry); newDestination = getSlideDestination(getModalGroupGeometry(effects->activeWindow()), elevatedGeometry);
if( !motionManager.isManaging( tmp ) ) if (!motionManager.isManaging(tmp)) {
{
motionManager.manage(tmp); motionManager.manage(tmp);
} }
motionManager.moveWindow(tmp, newDestination); motionManager.moveWindow(tmp, newDestination);
destinationList[tmp] = newDestination; destinationList[tmp] = newDestination;
} } else {
else if (!tmp->isDock()) {
{
if( !tmp->isDock() )
{
bool keepElevated = false; bool keepElevated = false;
foreach( EffectWindow *elevatedWindow, tmpList) foreach (EffectWindow * elevatedWindow, tmpList) {
{ if (tmp->geometry().intersects(elevatedWindow->geometry())) {
if( tmp->geometry().intersects( elevatedWindow->geometry() ) )
{
keepElevated = true; keepElevated = true;
} }
} }
if( !keepElevated ) if (!keepElevated) {
{
effects->setElevatedWindow(tmp, false); effects->setElevatedWindow(tmp, false);
elevatedList.removeAll(tmp); elevatedList.removeAll(tmp);
} }
@ -289,37 +244,28 @@ void SlideBackEffect::postPaintWindow( EffectWindow* w )
} }
tmpList.append(tmp); tmpList.append(tmp);
} }
} } else {
else
{
// Move the window back where it belongs // Move the window back where it belongs
motionManager.moveWindow(w, w->geometry()); motionManager.moveWindow(w, w->geometry());
destinationList.remove(w); destinationList.remove(w);
} }
} }
} } else {
else
{
// is window back at its original position? // is window back at its original position?
if ((qAbs(motionManager.transformedGeometry(w).x() - w->geometry().x()) < 1) && 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); motionManager.unmanage(w);
effects->addRepaintFull(); 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. // 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 // 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); coveringWindows.removeAll(w);
if( coveringWindows.isEmpty() ) if (coveringWindows.isEmpty()) {
{
// Restore correct stacking order // Restore correct stacking order
foreach( EffectWindow *tmp, elevatedList ) foreach (EffectWindow * tmp, elevatedList) {
{
effects->setElevatedWindow(tmp, false); effects->setElevatedWindow(tmp, false);
} }
elevatedList.clear(); elevatedList.clear();
@ -336,8 +282,7 @@ void SlideBackEffect::windowDeleted( EffectWindow* w )
oldStackingOrder.removeAll(w); oldStackingOrder.removeAll(w);
coveringWindows.removeAll(w); coveringWindows.removeAll(w);
elevatedList.removeAll(w); elevatedList.removeAll(w);
if( motionManager.isManaging( w ) ) if (motionManager.isManaging(w)) {
{
motionManager.unmanage(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. // 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 // If a window is unminimized but not on top we need to clear the memory because the windowUnminimized() is not
// followed by a windowActivated(). // followed by a windowActivated().
if( isWindowOnTop( w ) ) if (isWindowOnTop(w)) {
{
unminimizedWindow = w; unminimizedWindow = w;
} } else {
else
{
unminimizedWindow = NULL; unminimizedWindow = NULL;
} }
} }
@ -377,8 +319,7 @@ void SlideBackEffect::tabBoxClosed()
bool SlideBackEffect::isWindowOnTop(EffectWindow* w) bool SlideBackEffect::isWindowOnTop(EffectWindow* w)
{ {
EffectWindowList openWindows = usableWindows(effects->stackingOrder()); EffectWindowList openWindows = usableWindows(effects->stackingOrder());
if( !openWindows.isEmpty() && ( openWindows.last() == w ) ) if (!openWindows.isEmpty() && (openWindows.last() == w)) {
{
return true; return true;
} }
return false; return false;
@ -399,10 +340,8 @@ bool SlideBackEffect::intersects( EffectWindow* windowUnder, const QRect &window
EffectWindowList SlideBackEffect::usableWindows(const EffectWindowList & allWindows) EffectWindowList SlideBackEffect::usableWindows(const EffectWindowList & allWindows)
{ {
EffectWindowList retList; EffectWindowList retList;
foreach( EffectWindow *tmp, allWindows ) foreach (EffectWindow * tmp, allWindows) {
{ if (isWindowUsable(tmp)) {
if( isWindowUsable( tmp ) )
{
retList.append(tmp); retList.append(tmp);
} }
} }
@ -423,10 +362,8 @@ EffectWindow* SlideBackEffect::newTopWindow()
QRect SlideBackEffect::getModalGroupGeometry(EffectWindow *w) QRect SlideBackEffect::getModalGroupGeometry(EffectWindow *w)
{ {
QRect modalGroupGeometry = w->geometry(); QRect modalGroupGeometry = w->geometry();
if( w->isModal() ) if (w->isModal()) {
{ foreach (EffectWindow * modalWindow, w->mainWindows()) {
foreach( EffectWindow *modalWindow, w->mainWindows() )
{
modalGroupGeometry = modalGroupGeometry.united(getModalGroupGeometry(modalWindow)); 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) void SlidingPopupsEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
{ {
if( mAppearingWindows.contains( w ) ) if (mAppearingWindows.contains(w)) {
{
mAppearingWindows[ w ].addTime(time); mAppearingWindows[ w ].addTime(time);
if (mAppearingWindows[ w ].value() < 1) if (mAppearingWindows[ w ].value() < 1)
data.setTransformed(); data.setTransformed();
else else
mAppearingWindows.remove(w); mAppearingWindows.remove(w);
} } else if (mDisappearingWindows.contains(w)) {
else if( mDisappearingWindows.contains( w ) )
{
data.setTransformed(); data.setTransformed();
w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DELETE); w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DELETE);
@ -78,24 +75,19 @@ void SlidingPopupsEffect::paintWindow( EffectWindow* w, int mask, QRegion region
bool appearing = false; bool appearing = false;
QRegion clippedRegion = region; QRegion clippedRegion = region;
if( mAppearingWindows.contains( w ) ) if (mAppearingWindows.contains(w)) {
{
appearing = true; appearing = true;
animating = true; animating = true;
} } else if (mDisappearingWindows.contains(w) && w->isDeleted()) {
else if( mDisappearingWindows.contains( w ) && w->isDeleted() )
{
appearing = false; appearing = false;
animating = true; animating = true;
} }
if( animating ) if (animating) {
{
qreal progress; qreal progress;
if (appearing) if (appearing)
progress = 1.0 - mAppearingWindows[ w ].value(); progress = 1.0 - mAppearingWindows[ w ].value();
else else {
{
if (mDisappearingWindows.contains(w)) if (mDisappearingWindows.contains(w))
progress = mDisappearingWindows[ w ].value(); progress = mDisappearingWindows[ w ].value();
else else
@ -103,8 +95,7 @@ void SlidingPopupsEffect::paintWindow( EffectWindow* w, int mask, QRegion region
} }
const int start = mWindowsData[ w ].start; const int start = mWindowsData[ w ].start;
switch (mWindowsData[ w ].from) switch(mWindowsData[ w ].from) {
{
case West: case West:
data.xTranslate += (start - w->width()) * progress; data.xTranslate += (start - w->width()) * progress;
clippedRegion = clippedRegion.subtracted(QRegion(start - w->width(), w->y(), w->width(), w->height())); 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)) if (mAppearingWindows.contains(w) || mDisappearingWindows.contains(w))
w->addRepaintFull(); // trigger next animation repaint w->addRepaintFull(); // trigger next animation repaint
effects->postPaintWindow(w); effects->postPaintWindow(w);
if( mDisappearingWindows.contains( w ) && mDisappearingWindows[ w ].value() >= 1 ) if (mDisappearingWindows.contains(w) && mDisappearingWindows[ w ].value() >= 1) {
{
mDisappearingWindows.remove(w); mDisappearingWindows.remove(w);
w->unrefWindow(); w->unrefWindow();
effects->addRepaint(w->geometry()); effects->addRepaint(w->geometry());
@ -143,8 +133,7 @@ void SlidingPopupsEffect::postPaintWindow( EffectWindow* w )
void SlidingPopupsEffect::windowAdded(EffectWindow* w) void SlidingPopupsEffect::windowAdded(EffectWindow* w)
{ {
propertyNotify(w, mAtom); propertyNotify(w, mAtom);
if( w->isOnCurrentDesktop() && mWindowsData.contains( w ) ) if (w->isOnCurrentDesktop() && mWindowsData.contains(w)) {
{
mAppearingWindows[ w ].setDuration(mWindowsData[ w ].fadeInDuration); mAppearingWindows[ w ].setDuration(mWindowsData[ w ].fadeInDuration);
mAppearingWindows[ w ].setProgress(0.0); mAppearingWindows[ w ].setProgress(0.0);
mAppearingWindows[ w ].setCurveShape(TimeLine::EaseOutCurve); mAppearingWindows[ w ].setCurveShape(TimeLine::EaseOutCurve);
@ -159,8 +148,7 @@ void SlidingPopupsEffect::windowAdded( EffectWindow* w )
void SlidingPopupsEffect::windowClosed(EffectWindow* w) void SlidingPopupsEffect::windowClosed(EffectWindow* w)
{ {
propertyNotify(w, mAtom); propertyNotify(w, mAtom);
if( w->isOnCurrentDesktop() && !w->isMinimized() && mWindowsData.contains( w ) ) if (w->isOnCurrentDesktop() && !w->isMinimized() && mWindowsData.contains(w)) {
{
w->refWindow(); w->refWindow();
mAppearingWindows.remove(w); mAppearingWindows.remove(w);
mDisappearingWindows[ w ].setDuration(mWindowsData[ w ].fadeOutDuration); mDisappearingWindows[ w ].setDuration(mWindowsData[ w ].fadeOutDuration);
@ -189,8 +177,7 @@ void SlidingPopupsEffect::propertyNotify( EffectWindow* w, long a )
QByteArray data = w->readProperty(mAtom, mAtom, 32); 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 // Property was removed, thus also remove the effect for window
mAppearingWindows.remove(w); mAppearingWindows.remove(w);
mDisappearingWindows.remove(w); mDisappearingWindows.remove(w);
@ -202,16 +189,13 @@ void SlidingPopupsEffect::propertyNotify( EffectWindow* w, long a )
Data animData; Data animData;
animData.start = d[ 0 ]; animData.start = d[ 0 ];
animData.from = (Position)d[ 1 ]; animData.from = (Position)d[ 1 ];
if( data.length() >= (int)(sizeof( long ) * 3) ) if (data.length() >= (int)(sizeof(long) * 3)) {
{
animData.fadeInDuration = d[2]; animData.fadeInDuration = d[2];
if (data.length() >= (int)(sizeof(long) * 4)) if (data.length() >= (int)(sizeof(long) * 4))
animData.fadeOutDuration = d[3]; animData.fadeOutDuration = d[3];
else else
animData.fadeOutDuration = d[2]; animData.fadeOutDuration = d[2];
} } else {
else
{
animData.fadeInDuration = animationTime(mFadeInTime); animData.fadeInDuration = animationTime(mFadeInTime);
animData.fadeOutDuration = animationTime(mFadeOutTime); animData.fadeOutDuration = animationTime(mFadeOutTime);
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -113,13 +113,10 @@ void TrackMouseEffectConfig::defaults()
void TrackMouseEffectConfig::enableEditor(bool enabled) 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); m_ui->editor->setEnabled(true);
emit changed(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); m_ui->editor->setEnabled(false);
action->setGlobalShortcut(KShortcut(), KAction::ShortcutTypes(KAction::ActiveShortcut | KAction::DefaultShortcut), KAction::NoAutoloading); action->setGlobalShortcut(KShortcut(), KAction::ShortcutTypes(KAction::ActiveShortcut | KAction::DefaultShortcut), KAction::NoAutoloading);
emit changed(true); emit changed(true);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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