From 04b43be9b261f36edc4b0300a9784ec5dcbe1c52 Mon Sep 17 00:00:00 2001 From: Alexander Golubev Date: Thu, 8 Jan 2026 16:33:18 +0300 Subject: twin: better rules when to set custom_opacity flag This patch implements next peaces of logic: - If opacity is not completely opaque by default, changing it to opaque won't result it resetting the flag anymore. - Also in such a case the X11 property will be set for completely opaque windows as well. That way we can restore it in case of WM restart. - On WM initialization we check if the X11 opacity property has value we would expectto be left behind by previous WM instance and if it does we won't set the custom_opacity flag. Signed-off-by: Alexander Golubev --- twin/client.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'twin/client.cpp') diff --git a/twin/client.cpp b/twin/client.cpp index e9e74e139..7cdf00a77 100644 --- a/twin/client.cpp +++ b/twin/client.cpp @@ -2801,8 +2801,8 @@ void Client::setOpacity(bool translucent, uint opacity) 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) - { + if ((!translucent || 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 @@ -2827,7 +2827,12 @@ void Client::setShadowSize(uint shadowSize) uint Client::defaultOpacity() { - if (isActive() || (keepAbove() && options->keepAboveAsActive)) + return defaultOpacity(isActive() || (keepAbove() && options->keepAboveAsActive)); + } + +uint Client::defaultOpacity(bool active) + { + if (active) { if( ruleOpacityActive() ) return rule_opacity_active; @@ -2941,7 +2946,15 @@ bool Client::getWindowOpacity() //query translucency settings from X, returns tr if (result == Success && data && format == 32 ) { opacity_ = *reinterpret_cast< long* >( data ); - custom_opacity = true; + // 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_ < 0xFFFFFFFF, opacity_); XFree ((char*)data); return true; -- cgit v1.2.3