summaryrefslogtreecommitdiffstats
path: root/twin/client.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'twin/client.cpp')
-rw-r--r--twin/client.cpp255
1 files changed, 84 insertions, 171 deletions
diff --git a/twin/client.cpp b/twin/client.cpp
index 0f1e7d053..50248bc2c 100644
--- a/twin/client.cpp
+++ b/twin/client.cpp
@@ -120,7 +120,7 @@ Client::Client( Workspace *ws )
border_right( 0 ),
border_top( 0 ),
border_bottom( 0 ),
- opacity_( 0 ),
+ opacity_( Opacity::Opaque ),
demandAttentionKNotifyTimer( NULL ),
activeMaximizing(false),
activeTiled(false)
@@ -224,7 +224,7 @@ void Client::releaseWindow( bool on_shutdown )
deleting = true;
workspace()->discardUsedWindowRules( this, true ); // remove ForceTemporarily rules
StackingUpdatesBlocker blocker( workspace());
- if (!custom_opacity) setOpacity(false);
+ if (!custom_opacity) setOpacity(Opacity::Opaque);
if (moveResizeMode)
leaveMoveResize();
removeShadow();
@@ -328,9 +328,6 @@ void Client::updateDecoration( bool check_workspace_pos, bool force )
XReparentWindow( tqt_xdisplay(), decoration->widget()->winId(), frameId(), 0, 0 );
decoration->widget()->lower();
decoration->borders( border_left, border_right, border_top, border_bottom );
- options->onlyDecoTranslucent ?
- setDecoHashProperty(border_top, border_right, border_bottom, border_left):
- unsetDecoHashProperty();
int save_workarea_diff_x = workarea_diff_x;
int save_workarea_diff_y = workarea_diff_y;
move( calculateGravitation( false ));
@@ -387,9 +384,6 @@ void Client::checkBorderSizes()
border_right != new_right ||
border_top != new_top ||
border_bottom != new_bottom)
- options->onlyDecoTranslucent ?
- setDecoHashProperty(new_top, new_right, new_bottom, new_left):
- unsetDecoHashProperty();
move( calculateGravitation( false ));
plainResize( sizeForClientSize( clientSize()), ForceGeometrySet );
checkWorkspacePosition();
@@ -2241,11 +2235,6 @@ void Client::takeFocus( allowed_t )
if ( rules()->checkAcceptFocus( input ))
{
XSetInputFocus( tqt_xdisplay(), window(), RevertToPointerRoot, get_tqt_x_time() );
- // Work around opacity bug
- bool activePrev = active;
- active = true;
- updateOpacity();
- active = activePrev;
}
if ( Ptakefocus )
{
@@ -2800,26 +2789,24 @@ void Client::cancelAutoRaise()
autoRaiseTimer = 0;
}
-void Client::setOpacity(bool translucent, uint opacity)
+void Client::setOpacity(uint opacity)
{
if (isDesktop())
return; // xcompmgr does not like non solid desktops and the user could set it accidently by mouse scrolling
// tqWarning("setting opacity for %d",tqt_xdisplay());
- //rule out activated translulcency with 100% opacity
- if (!translucent || opacity == 0xFFFFFFFF)
- {
- opacity_ = 0xFFFFFFFF;
+ if (opacity == Opacity::Opaque && !custom_opacity)
+ { // Note: if it is custom_opacity we want to keep the properties in case of WM restart
XDeleteProperty (tqt_xdisplay(), frameId(), atoms->net_wm_window_opacity);
XDeleteProperty (tqt_xdisplay(), window(), atoms->net_wm_window_opacity); // ??? frameId() is necessary for visible changes, window() is the winId() that would be set by apps - we set both to be sure the app knows what's currently displayd
}
else{
if(opacity == opacity_)
return;
- opacity_ = opacity;
long data = opacity; // 32bit XChangeProperty needs long
XChangeProperty(tqt_xdisplay(), frameId(), atoms->net_wm_window_opacity, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &data, 1L);
XChangeProperty(tqt_xdisplay(), window(), atoms->net_wm_window_opacity, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &data, 1L);
}
+ opacity_ = opacity;
}
void Client::setShadowSize(uint shadowSize)
@@ -2830,162 +2817,94 @@ void Client::setShadowSize(uint shadowSize)
XChangeProperty(tqt_xdisplay(), frameId(), atoms->net_wm_window_shadow, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &data, 1L);
}
-void Client::updateOpacity()
-// extra syncscreen flag allows to avoid double syncs when active state changes (as it will usually change for two windows)
+uint Client::defaultOpacity()
{
- if (!(isNormalWindow() || isDialog() || isUtility() )|| custom_opacity)
- return;
- if (isActive())
+ return defaultOpacity(isActive() || (keepAbove() && options->keepAboveAsActive));
+ }
+
+uint Client::defaultOpacity(bool active)
+ {
+ if (active)
{
if( ruleOpacityActive() )
- setOpacity(rule_opacity_active < 0xFFFFFFFF, rule_opacity_active);
+ return rule_opacity_active;
else
- setOpacity(options->translucentActiveWindows, options->activeWindowOpacity);
- if (isBMP())
- // beep-media-player, only undecorated windows (gtk2 xmms, xmms doesn't work with compmgr at all - s.e.p. :P )
- {
- ClientList tmpGroupMembers = group()->members();
- ClientList activeGroupMembers;
- activeGroupMembers.append(this);
- tmpGroupMembers.remove(this);
- ClientList::Iterator it = tmpGroupMembers.begin();
- while (it != tmpGroupMembers.end())
- // search for next attached and not activated client and repeat if found
- {
- if ((*it) != this && (*it)->isBMP())
- // potential "to activate" client found
- {
-// tqWarning("client found");
- if ((*it)->touches(this)) // first test, if the new client touches the just activated one
- {
-// tqWarning("found client touches me");
- if( ruleOpacityActive() )
- (*it)->setOpacity(rule_opacity_active < 0xFFFFFFFF, rule_opacity_active);
- else
- (*it)->setOpacity(options->translucentActiveWindows, options->activeWindowOpacity);
-// tqWarning("activated, search restarted (1)");
- (*it)->setShadowSize(options->activeWindowShadowSize);
- activeGroupMembers.append(*it);
- tmpGroupMembers.remove(it);
- it = tmpGroupMembers.begin(); // restart, search next client
- continue;
- }
- else
- { // pot. client does not touch c, so we have to search if it touches some other activated client
- bool found = false;
- for( ClientList::ConstIterator it2 = activeGroupMembers.begin(); it2 != activeGroupMembers.end(); it2++ )
- {
- if ((*it2) != this && (*it2) != (*it) && (*it)->touches(*it2))
- {
-// tqWarning("found client touches other active client");
- if( ruleOpacityActive() )
- (*it)->setOpacity(rule_opacity_active < 0xFFFFFFFF, rule_opacity_active);
- else
- (*it)->setOpacity(options->translucentActiveWindows, options->activeWindowOpacity);
- (*it)->setShadowSize(options->activeWindowShadowSize);
- activeGroupMembers.append(*it);
- tmpGroupMembers.remove(it);
- it = tmpGroupMembers.begin(); // reset potential client search
- found = true;
-// tqWarning("activated, search restarted (2)");
- break; // skip this loop
- }
- }
- if (found) continue;
- }
- }
- it++;
- }
- }
- else if (isNormalWindow())
- // activate dependend minor windows as well
- {
- for( ClientList::ConstIterator it = group()->members().begin(); it != group()->members().end(); it++ )
- if ((*it)->isDialog() || (*it)->isUtility())
- {
- if( (*it)->ruleOpacityActive() )
- (*it)->setOpacity((*it)->ruleOpacityActive() < 0xFFFFFFFF, (*it)->ruleOpacityActive());
- else
- (*it)->setOpacity(options->translucentActiveWindows, options->activeWindowOpacity);
- }
- }
+ return options->translucentActiveWindows ? options->activeWindowOpacity : Opacity::Opaque;
}
else
{
if( ruleOpacityInactive() )
- setOpacity(rule_opacity_inactive < 0xFFFFFFFF, rule_opacity_inactive);
+ return rule_opacity_inactive;
else
- setOpacity(options->translucentInactiveWindows && !(keepAbove() && options->keepAboveAsActive),
- options->inactiveWindowOpacity);
- // deactivate dependend minor windows as well
- if (isBMP())
- // beep-media-player, only undecorated windows (gtk2 xmms, xmms doesn't work with compmgr at all - s.e.p. :P )
+ return options->translucentInactiveWindows ? options->inactiveWindowOpacity : Opacity::Opaque;
+ }
+ }
+
+void Client::updateOpacity()
+// extra syncscreen flag allows to avoid double syncs when active state changes (as it will usually change for two windows)
+ {
+ if (!(isNormalWindow() || isDialog() || isUtility() )|| custom_opacity)
+ return;
+ uint opacity = defaultOpacity();
+ setOpacity(opacity);
+
+ if (isBMP())
+ // beep-media-player, only undecorated windows (gtk2 xmms, xmms doesn't work with compmgr at all - s.e.p. :P )
+ {
+ ClientList tmpGroupMembers = group()->members();
+ ClientList groupMembers;
+ groupMembers.append(this);
+ tmpGroupMembers.remove(this);
+ ClientList::Iterator it = tmpGroupMembers.begin();
+ while (it != tmpGroupMembers.end())
+ // search for next attached and not activated client and repeat if found
{
- ClientList tmpGroupMembers = group()->members();
- ClientList inactiveGroupMembers;
- inactiveGroupMembers.append(this);
- tmpGroupMembers.remove(this);
- ClientList::Iterator it = tmpGroupMembers.begin();
- while ( it != tmpGroupMembers.end() )
- // search for next attached and not activated client and repeat if found
+ if ((*it) != this && (*it)->isBMP())
+ // potential "to activate" client found
{
- if ((*it) != this && (*it)->isBMP())
- // potential "to activate" client found
- {
// tqWarning("client found");
- if ((*it)->touches(this)) // first test, if the new client touches the just activated one
- {
+ if ((*it)->touches(this)) // first test, if the new client touches the just activated one
+ {
// tqWarning("found client touches me");
- if( (*it)->ruleOpacityInactive() )
- (*it)->setOpacity((*it)->ruleOpacityInactive() < 0xFFFFFFFF, (*it)->ruleOpacityInactive());
- else
- (*it)->setOpacity(options->translucentInactiveWindows && !((*it)->keepAbove() && options->keepAboveAsActive), options->inactiveWindowOpacity);
- (*it)->setShadowSize(options->inactiveWindowShadowSize);
-// tqWarning("deactivated, search restarted (1)");
- inactiveGroupMembers.append(*it);
- tmpGroupMembers.remove(it);
- it = tmpGroupMembers.begin(); // restart, search next client
- continue;
- }
- else // pot. client does not touch c, so we have to search if it touches some other activated client
+ (*it)->setOpacity(opacity);
+// tqWarning("(de)activated, search restarted (1)");
+ (*it)->setShadowSize(options->activeWindowShadowSize);
+ groupMembers.append(*it);
+ tmpGroupMembers.remove(it);
+ it = tmpGroupMembers.begin(); // restart, search next client
+ continue;
+ }
+ else
+ { // pot. client does not touch c, so we have to search if it touches some other activated client
+ bool found = false;
+ for( ClientList::ConstIterator it2 = groupMembers.begin(); it2 != groupMembers.end(); it2++ )
{
- bool found = false;
- for( ClientList::ConstIterator it2 = inactiveGroupMembers.begin(); it2 != inactiveGroupMembers.end(); it2++ )
+ if ((*it2) != this && (*it2) != (*it) && (*it)->touches(*it2))
{
- if ((*it2) != this && (*it2) != (*it) && (*it)->touches(*it2))
- {
-// tqWarning("found client touches other inactive client");
- if( (*it)->ruleOpacityInactive() )
- (*it)->setOpacity((*it)->ruleOpacityInactive() < 0xFFFFFFFF, (*it)->ruleOpacityInactive());
- else
- (*it)->setOpacity(options->translucentInactiveWindows && !((*it)->keepAbove() && options->keepAboveAsActive), options->inactiveWindowOpacity);
- (*it)->setShadowSize(options->inactiveWindowShadowSize);
-// tqWarning("deactivated, search restarted (2)");
- inactiveGroupMembers.append(*it);
- tmpGroupMembers.remove(it);
- it = tmpGroupMembers.begin(); // reset potential client search
- found = true;
- break; // skip this loop
- }
+// tqWarning("found client touches other active client");
+ (*it)->setOpacity(opacity);
+ (*it)->setShadowSize(isActive() ? options->activeWindowShadowSize : options->inactiveWindowShadowSize);
+ groupMembers.append(*it);
+ tmpGroupMembers.remove(it);
+ it = tmpGroupMembers.begin(); // reset potential client search
+ found = true;
+// tqWarning("(de)activated, search restarted (2)");
+ break; // skip this loop
}
- if (found) continue;
}
+ if (found) continue;
}
- it++;
}
- }
- else if (isNormalWindow())
- {
- for( ClientList::ConstIterator it = group()->members().begin(); it != group()->members().end(); it++ )
- if ((*it)->isUtility()) //don't deactivate dialogs...
- {
- if( (*it)->ruleOpacityInactive() )
- (*it)->setOpacity((*it)->ruleOpacityInactive() < 0xFFFFFFFF, (*it)->ruleOpacityInactive());
- else
- (*it)->setOpacity(options->translucentInactiveWindows && !((*it)->keepAbove() && options->keepAboveAsActive), options->inactiveWindowOpacity);
- }
+ it++;
}
}
+ else if (isNormalWindow())
+ // activate/deactivate dependend minor windows as well
+ {
+ for( ClientList::ConstIterator it = group()->members().begin(); it != group()->members().end(); it++ )
+ if ((*it)->isUtility() || ((*it)->isDialog() && isActive() )) // note: don't deactivate dialogs...
+ (*it)->setOpacity(opacity);
+ }
}
void Client::updateShadowSize()
@@ -3019,8 +2938,16 @@ bool Client::getWindowOpacity() //query translucency settings from X, returns tr
if (result == Success && data && format == 32 )
{
opacity_ = *reinterpret_cast< long* >( data );
- custom_opacity = true;
-// setOpacity(opacity_ < 0xFFFFFFFF, opacity_);
+ // Don't set custom_opacity flag during initialization if the opacity looks like what it
+ // supposed to be for the given type of window. As in a such case it is likely set by us
+ // and the WM is just restarting
+ if ( !(Workspace::self()->initializing()
+ && ( opacity_ == defaultOpacity(/*active*/ false)
+ || opacity_ == defaultOpacity(/*active*/ true) ) ) )
+ {
+ custom_opacity = true;
+ }
+// setOpacity(opacity_);
XFree ((char*)data);
return true;
}
@@ -3039,7 +2966,7 @@ uint Client::opacity()
int Client::opacityPercentage()
{
- return int(100*((double)opacity_/0xffffffff));
+ return opacity_ / ( 0xffffffff / 100 );
}
bool Client::touches(const Client* c)
@@ -3056,20 +2983,6 @@ bool Client::touches(const Client* c)
return false;
}
-void Client::setDecoHashProperty(uint topHeight, uint rightWidth, uint bottomHeight, uint leftWidth)
-{
- long data = (topHeight < 255 ? topHeight : 255) << 24 |
- (rightWidth < 255 ? rightWidth : 255) << 16 |
- (bottomHeight < 255 ? bottomHeight : 255) << 8 |
- (leftWidth < 255 ? leftWidth : 255);
- XChangeProperty(tqt_xdisplay(), frameId(), atoms->net_wm_window_decohash, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &data, 1L);
-}
-
-void Client::unsetDecoHashProperty()
-{
- XDeleteProperty( tqt_xdisplay(), frameId(), atoms->net_wm_window_decohash);
-}
-
#ifndef NDEBUG
kdbgstream& operator<<( kdbgstream& stream, const Client* cl )
{