diff options
| author | Alexander Golubev <fatzer2@gmail.com> | 2026-01-08 05:51:53 +0300 |
|---|---|---|
| committer | Alexander Golubev <fatzer2@gmail.com> | 2026-01-08 19:07:19 +0300 |
| commit | 745b8e5e0297a14e7da1c1742add6cd6010a9813 (patch) | |
| tree | ceda8f530524e91cff3f8668f55cd7507ae219f8 | |
| parent | afdcdb0e333e5dbc3689f6930366b20e16d117fd (diff) | |
| download | tdebase-Fat-Zer/fix/twin-opacity.tar.gz tdebase-Fat-Zer/fix/twin-opacity.zip | |
twin: refactor Client::setOpacity() and associated stuffFat-Zer/fix/twin-opacity
* change setOpacity() prototype to receive only opacity.
* rename { setPopupClientOpacity => setPopupClientTransparancy() } to
better reflect what the function does
Signed-off-by: Alexander Golubev <fatzer2@gmail.com>
| -rw-r--r-- | twin/activation.cpp | 2 | ||||
| -rw-r--r-- | twin/client.cpp | 20 | ||||
| -rw-r--r-- | twin/client.h | 2 | ||||
| -rw-r--r-- | twin/geometry.cpp | 4 | ||||
| -rw-r--r-- | twin/rules.cpp | 10 | ||||
| -rw-r--r-- | twin/useractions.cpp | 14 | ||||
| -rw-r--r-- | twin/workspace.cpp | 4 | ||||
| -rw-r--r-- | twin/workspace.h | 2 |
8 files changed, 30 insertions, 28 deletions
diff --git a/twin/activation.cpp b/twin/activation.cpp index 143756366..4d8193403 100644 --- a/twin/activation.cpp +++ b/twin/activation.cpp @@ -864,7 +864,7 @@ void Client::setActive( bool act, bool updateOpacity_) if (isModal() && transientFor()) { if (!act) transientFor()->updateOpacity(); - else if (!transientFor()->custom_opacity) transientFor()->setOpacity(options->translucentActiveWindows, options->activeWindowOpacity); + else if (!transientFor()->custom_opacity) transientFor()->setOpacity(options->translucentActiveWindows ? options->activeWindowOpacity : Opacity::Opaque); } updateShadowSize(); diff --git a/twin/client.cpp b/twin/client.cpp index 7cdf00a77..22936084f 100644 --- a/twin/client.cpp +++ b/twin/client.cpp @@ -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(); @@ -2795,26 +2795,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 == Opacity::Opaque) && !custom_opacity) + if (opacity == Opacity::Opaque && !custom_opacity) { // Note: if it is custom_opacity we want to keep the properties in case of WM restart - opacity_ = Opacity::Opaque; 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) @@ -2854,7 +2852,7 @@ void Client::updateOpacity() if (!(isNormalWindow() || isDialog() || isUtility() )|| custom_opacity) return; uint opacity = defaultOpacity(); - setOpacity(true, opacity); + setOpacity(opacity); if (isBMP()) // beep-media-player, only undecorated windows (gtk2 xmms, xmms doesn't work with compmgr at all - s.e.p. :P ) @@ -2874,7 +2872,7 @@ void Client::updateOpacity() if ((*it)->touches(this)) // first test, if the new client touches the just activated one { // tqWarning("found client touches me"); - (*it)->setOpacity(true, opacity); + (*it)->setOpacity(opacity); // tqWarning("(de)activated, search restarted (1)"); (*it)->setShadowSize(options->activeWindowShadowSize); groupMembers.append(*it); @@ -2890,7 +2888,7 @@ void Client::updateOpacity() if ((*it2) != this && (*it2) != (*it) && (*it)->touches(*it2)) { // tqWarning("found client touches other active client"); - (*it)->setOpacity(true, opacity); + (*it)->setOpacity(opacity); (*it)->setShadowSize(isActive() ? options->activeWindowShadowSize : options->inactiveWindowShadowSize); groupMembers.append(*it); tmpGroupMembers.remove(it); @@ -2911,7 +2909,7 @@ void Client::updateOpacity() { 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(true, opacity); + (*it)->setOpacity(opacity); } } @@ -2955,7 +2953,7 @@ bool Client::getWindowOpacity() //query translucency settings from X, returns tr { custom_opacity = true; } -// setOpacity(opacity_ < 0xFFFFFFFF, opacity_); +// setOpacity(opacity_); XFree ((char*)data); return true; } diff --git a/twin/client.h b/twin/client.h index 6ed72fcc8..c92bb14ba 100644 --- a/twin/client.h +++ b/twin/client.h @@ -329,7 +329,7 @@ class Client : public TQObject, public KDecorationDefines Opaque = 0xFFFFFFFF //< Fully opaque window }; }; - void setOpacity(bool translucent, uint opacity = 0); + void setOpacity(uint opacity); void setShadowSize(uint shadowSize); uint defaultOpacity(); /// Returns default opacity for an active or inactive window depending on the argument diff --git a/twin/geometry.cpp b/twin/geometry.cpp index 512f705a8..bf8dfeee3 100644 --- a/twin/geometry.cpp +++ b/twin/geometry.cpp @@ -2362,7 +2362,7 @@ bool Client::startMoveResize() if (rules()->checkMoveResizeMode( options->moveMode ) == Options::Opaque) { savedOpacity_ = opacity_; - setOpacity(options->translucentMovingWindows, options->movingWindowOpacity); + setOpacity(options->translucentMovingWindows ? options->movingWindowOpacity : Opacity::Opaque); } if ( ( isMove() && rules()->checkMoveResizeMode( options->moveMode ) != Options::Opaque ) @@ -2429,7 +2429,7 @@ void Client::leaveMoveResize() { // rule out non opaque windows from useless translucency settings, maybe resizes? if (rules()->checkMoveResizeMode( options->moveMode ) == Options::Opaque) - setOpacity(true, savedOpacity_); + setOpacity(savedOpacity_); if ((isResize() && options->removeShadowsOnResize) || (isMove() && options->removeShadowsOnMove)) updateShadowSize(); clearbound(); diff --git a/twin/rules.cpp b/twin/rules.cpp index aa4b7904a..a72c4d195 100644 --- a/twin/rules.cpp +++ b/twin/rules.cpp @@ -902,12 +902,16 @@ void Client::checkAndSetInitialRuledOpacity() rule_opacity_inactive = 0; return; - + if( isDock() ) //workaround for docks, as they don't have active/inactive settings and don't aut, therefore we take only the active one... { - uint tmp = rule_opacity_active ? rule_opacity_active : options->dockOpacity; - setOpacity(tmp < 0xFFFFFFFF && (rule_opacity_active || options->translucentDocks), tmp); + if (rule_opacity_active) + setOpacity(rule_opacity_active); + else if(options->translucentDocks) + setOpacity(options->dockOpacity); + else + setOpacity(Opacity::Opaque); } else updateOpacity(); diff --git a/twin/useractions.cpp b/twin/useractions.cpp index 8051c9574..fddc4cb38 100644 --- a/twin/useractions.cpp +++ b/twin/useractions.cpp @@ -116,7 +116,7 @@ TQPopupMenu* Workspace::clientPopup() connect(transButton, TQ_SIGNAL(clicked()), TQ_SLOT(resetClientOpacity())); connect(transButton, TQ_SIGNAL(clicked()), trans_popup, TQ_SLOT(hide())); connect(transSlider, TQ_SIGNAL(valueChanged(int)), TQ_SLOT(setTransButtonText(int))); - connect(transSlider, TQ_SIGNAL(valueChanged(int)), this, TQ_SLOT(setPopupClientOpacity(int))); + connect(transSlider, TQ_SIGNAL(valueChanged(int)), this, TQ_SLOT(setPopupClientTransparancy(int))); // connect(transSlider, TQ_SIGNAL(sliderReleased()), trans_popup, TQ_SLOT(hide())); trans_popup->insertItem(transBox); popup->insertItem(i18n("&Opacity"), trans_popup ); @@ -143,11 +143,11 @@ TQPopupMenu* Workspace::clientPopup() } //sets the transparency of the client to given value(given by slider) -void Workspace::setPopupClientOpacity(int value) +void Workspace::setPopupClientTransparancy(int value) { active_popup_client->setCustomOpacityFlag(true); int opacityPercent = 100 - value; - active_popup_client->setOpacity(true, percentToUint(opacityPercent)); + active_popup_client->setOpacity(percentToUint(opacityPercent)); } void Workspace::setTransButtonText(int value) @@ -653,21 +653,21 @@ bool Client::performMouseCommand( Options::MouseCommand command, TQPoint globalP if (opacity_ < Opacity::Opaque - Opacity::MouseStep) { custom_opacity = true; - setOpacity(true, opacity_ + Opacity::MouseStep); + setOpacity(opacity_ + Opacity::MouseStep); } else { if (defaultOpacity() == Opacity::Opaque) custom_opacity = false; - setOpacity(true, Opacity::Opaque); + setOpacity(Opacity::Opaque); } } break; case Options::MouseOpacityLess: - if (opacity_ > 0) + if (opacity_ > Opacity::Transparent) { custom_opacity = true; - setOpacity(true, (opacity_ > Opacity::MouseStep) ? opacity_ - Opacity::MouseStep : Opacity::Transparent); + setOpacity((opacity_ > Opacity::MouseStep) ? opacity_ - Opacity::MouseStep : Opacity::Transparent); } break; case Options::MouseNothing: diff --git a/twin/workspace.cpp b/twin/workspace.cpp index 6c7c0cf7f..78ca51563 100644 --- a/twin/workspace.cpp +++ b/twin/workspace.cpp @@ -602,7 +602,7 @@ void Workspace::addClient( Client* c, allowed_t ) if (!c->hasCustomOpacity()) // this xould be done slightly more efficient, but we want to support the topDock in future { c->setShadowSize(options->dockShadowSize); - c->setOpacity(options->translucentDocks, options->dockOpacity); + c->setOpacity(options->translucentDocks ? options->dockOpacity : Client::Opacity::Opaque); } } else @@ -3101,7 +3101,7 @@ void Workspace::setOpacity(unsigned long winId, unsigned int opacityPercent) for( ClientList::ConstIterator it = stackingOrder().begin(); it != stackingOrder().end(); it++ ) if (winId == (*it)->window()) { - (*it)->setOpacity(opacityPercent < 100, percentToUint(opacityPercent)); + (*it)->setOpacity(percentToUint(opacityPercent)); return; } } diff --git a/twin/workspace.h b/twin/workspace.h index 023854398..8b0649cef 100644 --- a/twin/workspace.h +++ b/twin/workspace.h @@ -417,7 +417,7 @@ class Workspace : public TQObject, public KWinInterface, public KDecorationDefin void updateActiveBorders(); void tileCurrentWindowToBorder(int position); // kompmgr - void setPopupClientOpacity(int v); + void setPopupClientTransparancy(int v); void resetClientOpacity(); void setTransButtonText(int value); void unblockKompmgrRestart(); |
