diff options
Diffstat (limited to 'twin/client.cpp')
| -rw-r--r-- | twin/client.cpp | 335 |
1 files changed, 124 insertions, 211 deletions
diff --git a/twin/client.cpp b/twin/client.cpp index b8f00746e..50248bc2c 100644 --- a/twin/client.cpp +++ b/twin/client.cpp @@ -18,9 +18,9 @@ License. See the file "COPYING" for the exact licensing terms. #include <tqdatetime.h> #include <tqimage.h> #include <tqfile.h> -#include <kprocess.h> +#include <tdeprocess.h> #include <unistd.h> -#include <kstandarddirs.h> +#include <tdestandarddirs.h> #include <tqwhatsthis.h> #include <twin.h> #include <kiconloader.h> @@ -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) @@ -144,23 +144,23 @@ Client::Client( Workspace *ws ) desk = 0; // no desktop yet mode = PositionCenter; - buttonDown = FALSE; - moveResizeMode = FALSE; + buttonDown = false; + moveResizeMode = false; info = NULL; shade_mode = ShadeNone; - active = FALSE; + active = false; deleting = false; - keep_above = FALSE; - keep_below = FALSE; - is_shape = FALSE; + keep_above = false; + keep_below = false; + is_shape = false; motif_noborder = false; - motif_may_move = TRUE; - motif_may_resize = TRUE; - motif_may_close = TRUE; + motif_may_move = true; + motif_may_resize = true; + motif_may_close = true; fullscreen_mode = FullScreenNone; - skip_taskbar = FALSE; + skip_taskbar = false; original_skip_taskbar = false; minimized = false; hidden = false; @@ -177,8 +177,8 @@ Client::Client( Workspace *ws ) Ptakeactivity = 0; Pcontexthelp = 0; Pping = 0; - input = FALSE; - skip_pager = FALSE; + input = false; + skip_pager = false; max_mode = MaximizeRestore; maxmode_restore = MaximizeRestore; @@ -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(); @@ -445,7 +439,7 @@ void Client::detectShapable() case NET::Menu : case NET::Dialog : case NET::Utility : - setShapable(FALSE); + setShapable(false); break; default: assert( false ); @@ -522,9 +516,9 @@ bool Client::isModalSystemNotification() const result = XGetWindowProperty(tqt_xdisplay(), window(), atoms->net_wm_system_modal_notification, 0L, 1L, False, XA_CARDINAL, &actual, &format, &n, &left, /*(unsigned char **)*/ &data); if (result == Success && data && format == 32 ) { - return TRUE; + return true; } - return FALSE; + return false; } void Client::updateShape() @@ -541,7 +535,7 @@ void Client::updateShape() XShapeCombineShape(tqt_xdisplay(), frameId(), ShapeBounding, clientPos().x(), clientPos().y(), window(), ShapeBounding, ShapeSet); - setShapable(TRUE); + setShapable(true); } // !shape() mask setting is done in setMask() when the decoration // calls it or when the decoration is created/destroyed @@ -709,7 +703,7 @@ void Client::unminimize( bool avoid_animation ) if( isOnCurrentDesktop() && isShown( true )) { if( mainClients().isEmpty() && !avoid_animation ) - animateMinimizeOrUnminimize( FALSE ); + animateMinimizeOrUnminimize( false ); } updateVisibility(); updateAllowedActions(); @@ -778,7 +772,7 @@ void Client::animateMinimizeOrUnminimize( bool minimize ) float diff; TQPainter p ( workspace()->desktopWidget() ); - bool need_to_clear = FALSE; + bool need_to_clear = false; TQPixmap pm3; do { @@ -790,12 +784,12 @@ void Client::animateMinimizeOrUnminimize( bool minimize ) if ( need_to_clear ) { p.drawPixmap( area2.x(), area2.y(), pm3 ); - need_to_clear = FALSE; + need_to_clear = false; } area2 = area; } XFlush(tqt_xdisplay()); - XSync( tqt_xdisplay(), FALSE ); + XSync( tqt_xdisplay(), False ); diff = t.elapsed(); if (diff > step) diff = step; @@ -810,7 +804,7 @@ void Client::animateMinimizeOrUnminimize( bool minimize ) else { // no overlap, we can clear later to avoid flicker pm3 = pm2; - need_to_clear = TRUE; + need_to_clear = true; } } } while ( t.elapsed() < step); @@ -897,7 +891,7 @@ void Client::setShade( ShadeMode mode ) XSelectInput( tqt_xdisplay(), wrapper, ClientWinMask | SubstructureNotifyMask ); //as we hid the unmap event, xcompmgr didn't recognize the client wid has vanished, so we'll extra inform it //done xcompmgr workaround -// FRAME repaint( FALSE ); +// FRAME repaint( false ); // bool wasStaticContents = testWFlags( WStaticContents ); // setWFlags( WStaticContents ); int step = TQMAX( 4, TQABS( h - s.height() ) / as )+1; @@ -938,7 +932,7 @@ void Client::setShade( ShadeMode mode ) resizeDecoration( TQSize( s.width(), h )); // assume a border // we do not have time to wait for X to send us paint events -// FRAME repaint( 0, h - step-5, width(), step+5, TRUE); +// FRAME repaint( 0, h - step-5, width(), step+5, true); TQApplication::syncX(); } while ( h < s.height() - step ); // if ( !wasStaticContents ) @@ -946,7 +940,7 @@ void Client::setShade( ShadeMode mode ) shade_geometry_change = false; plainResize( s ); if( shade_mode == ShadeHover || shade_mode == ShadeActivated ) - setActive( TRUE ); + setActive( true ); XMapWindow( tqt_xdisplay(), wrapperId()); XMapWindow( tqt_xdisplay(), window()); XDeleteProperty (tqt_xdisplay(), client, atoms->net_wm_window_shade); @@ -1897,7 +1891,7 @@ bool Client::isSuspendable() const tcomm = basename(tbuf); #else /* default */ TQString statString(statRaw); - TQStringList statFields = TQStringList::split(" ", statString, TRUE); + TQStringList statFields = TQStringList::split(" ", statString, true); TQString tcomm = statFields[1]; TQString state = statFields[2]; #endif /* default */ @@ -1967,7 +1961,7 @@ bool Client::isResumeable() const TQString state(TQChar(inf->pr_sname)); #else /* default */ TQString statString(statRaw); - TQStringList statFields = TQStringList::split(" ", statString, TRUE); + TQStringList statFields = TQStringList::split(" ", statString, true); TQString tcomm = statFields[1]; TQString state = statFields[2]; #endif /* default */ @@ -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 ) { @@ -2422,11 +2411,11 @@ void Client::readIcons( Window win, TQPixmap* icon, TQPixmap* miniicon ) { // get the icons, allow scaling if( icon != NULL ) - *icon = KWin::icon( win, 32, 32, TRUE, KWin::NETWM | KWin::WMHints ); + *icon = KWin::icon( win, 32, 32, true, KWin::NETWM | KWin::WMHints ); if( miniicon != NULL ) { if( icon == NULL || !icon->isNull()) - *miniicon = KWin::icon( win, 16, 16, TRUE, KWin::NETWM | KWin::WMHints ); + *miniicon = KWin::icon( win, 16, 16, true, KWin::NETWM | KWin::WMHints ); else *miniicon = TQPixmap(); } @@ -2454,8 +2443,8 @@ void Client::getIcons() } if( icon_pix.isNull()) { // and if nothing else, load icon from classhint or xapp icon - icon_pix = KWin::icon( window(), 32, 32, TRUE, KWin::ClassHint | KWin::XApp ); - miniicon_pix = KWin::icon( window(), 16, 16, TRUE, KWin::ClassHint | KWin::XApp ); + icon_pix = KWin::icon( window(), 32, 32, true, KWin::ClassHint | KWin::XApp ); + miniicon_pix = KWin::icon( window(), 16, 16, true, KWin::ClassHint | KWin::XApp ); } if( isManaged() && decoration != NULL ) decoration->iconChange(); @@ -2532,7 +2521,7 @@ Window Client::staticWmClientLeader(WId w) Window result = w; XErrorHandler oldHandler = XSetErrorHandler(nullErrorHandler); status = XGetWindowProperty( tqt_xdisplay(), w, atoms->wm_client_leader, 0, 10000, - FALSE, XA_WINDOW, &type, &format, + False, XA_WINDOW, &type, &format, &nitems, &extra, &data ); XSetErrorHandler(oldHandler); if (status == Success ) @@ -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,161 +2817,93 @@ 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++; } + 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); - } - } + } + 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); } } @@ -3019,12 +2938,20 @@ 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; + return true; } - return FALSE; + return false; } void Client::setCustomOpacityFlag(bool custom) @@ -3039,37 +2966,23 @@ uint Client::opacity() int Client::opacityPercentage() { - return int(100*((double)opacity_/0xffffffff)); + return opacity_ / ( 0xffffffff / 100 ); } bool Client::touches(const Client* c) // checks if this client borders c, needed to test beep media player window state { if (y() == c->y() + c->height()) // this bottom to c - return TRUE; + return true; if (y() + height() == c->y()) // this top to c - return TRUE; + return true; if (x() == c->x() + c->width()) // this right to c - return TRUE; + return true; if (x() + width() == c->x()) // this left to c - return TRUE; - return FALSE; + return true; + 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 ) { |
