From 6e44fc30b85189cc0a97eab6079a5c566fed13dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Fri, 11 Jun 2004 15:12:29 +0000 Subject: [PATCH] Autosave for window rules. svn path=/trunk/kdebase/kwin/; revision=319665 --- client.cpp | 7 +++++++ client.h | 1 + geometry.cpp | 2 ++ layers.cpp | 2 ++ rules.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++++++ workspace.cpp | 5 +++++ workspace.h | 4 +++- 7 files changed, 67 insertions(+), 1 deletion(-) diff --git a/client.cpp b/client.cpp index 72d7d5f981..5f0ee440d8 100644 --- a/client.cpp +++ b/client.cpp @@ -405,6 +405,7 @@ void Client::setUserNoBorder( bool set ) return; user_noborder = set; updateDecoration( true, false ); + updateWindowRules(); } void Client::updateShape() @@ -535,6 +536,7 @@ void Client::minimize( bool avoid_animation ) rawHide(); updateAllowedActions(); workspace()->updateMinimizedOfTransients( this ); + updateWindowRules(); } void Client::unminimize( bool avoid_animation ) @@ -555,6 +557,7 @@ void Client::unminimize( bool avoid_animation ) } updateAllowedActions(); workspace()->updateMinimizedOfTransients( this ); + updateWindowRules(); } extern bool blockAnimation; @@ -784,6 +787,7 @@ void Client::setShade( ShadeMode mode ) updateAllowedActions(); workspace()->updateMinimizedOfTransients( this ); decoration->shadeChange(); + updateWindowRules(); } void Client::shadeHover() @@ -1065,6 +1069,7 @@ void Client::setSkipTaskbar( bool b, bool from_outside ) return; skip_taskbar = b; info->setState( b?NET::SkipTaskbar:0, NET::SkipTaskbar ); + updateWindowRules(); } void Client::setSkipPager( bool b ) @@ -1074,6 +1079,7 @@ void Client::setSkipPager( bool b ) return; skip_pager = b; info->setState( b?NET::SkipPager:0, NET::SkipPager ); + updateWindowRules(); } void Client::setModal( bool m ) @@ -1106,6 +1112,7 @@ void Client::setDesktop( int desktop ) if( decoration != NULL ) decoration->desktopChange(); virtualDesktopChange(); // hide/show if needed + updateWindowRules(); } void Client::setOnAllDesktops( bool b ) diff --git a/client.h b/client.h index b671d09bac..df86f77ee7 100644 --- a/client.h +++ b/client.h @@ -496,6 +496,7 @@ private slots: QRegion _mask; friend struct FetchNameInternalPredicate; friend struct CheckIgnoreFocusStealingProcedure; + friend struct ResetupRulesProcedure; void show() { assert( false ); } // SELI remove after Client is no longer QWidget void hide() { assert( false ); } }; diff --git a/geometry.cpp b/geometry.cpp index de77a6d9e4..35bfed7472 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -1816,6 +1816,7 @@ void Client::changeMaximize( bool vertical, bool horizontal, bool adjust ) updateAllowedActions(); if( decoration != NULL ) decoration->maximizeChange(); + updateWindowRules(); } void Client::resetMaximize() @@ -1881,6 +1882,7 @@ void Client::setFullScreen( bool set, bool user ) setGeometry( workspace()->clientArea( MaximizeArea, this )); } } + updateWindowRules(); } diff --git a/layers.cpp b/layers.cpp index 67c0e82d2c..de82bb42a1 100644 --- a/layers.cpp +++ b/layers.cpp @@ -658,6 +658,7 @@ void Client::setKeepAbove( bool b ) info->setState( keepAbove() ? NET::KeepAbove : 0, NET::KeepAbove ); // TODO emit a signal about the change to the style plugin workspace()->updateClientLayer( this ); + updateWindowRules(); } void Client::setKeepBelow( bool b ) @@ -675,6 +676,7 @@ void Client::setKeepBelow( bool b ) keep_below = b; info->setState( keepBelow() ? NET::KeepBelow : 0, NET::KeepBelow ); workspace()->updateClientLayer( this ); + updateWindowRules(); } Layer Client::layer() const diff --git a/rules.cpp b/rules.cpp index c1c32596f3..f249fef3f4 100644 --- a/rules.cpp +++ b/rules.cpp @@ -287,32 +287,74 @@ bool WindowRules::match( const Client* c ) const void WindowRules::update( Client* c ) { // TODO check this setting is for this client ? + bool updated = false; if( positionrule == RememberRule ) + { + updated = updated || position != c->pos(); position = c->pos(); + } if( sizerule == RememberRule ) + { + updated = updated || size != c->size(); size = c->size(); + } if( desktoprule == RememberRule ) + { + updated = updated || desktop != c->desktop(); desktop = c->desktop(); + } if( maximizevertrule == RememberRule ) + { + updated = updated || maximizevert != bool( c->maximizeMode() & MaximizeVertical ); maximizevert = c->maximizeMode() & MaximizeVertical; + } if( maximizehorizrule == RememberRule ) + { + updated = updated || maximizehoriz != bool( c->maximizeMode() & MaximizeHorizontal ); maximizehoriz = c->maximizeMode() & MaximizeHorizontal; + } if( minimizerule == RememberRule ) + { + updated = updated || minimize != c->isMinimized(); minimize = c->isMinimized(); + } if( shaderule == RememberRule ) + { + updated = updated || ( shade != ( c->shadeMode() != Client::ShadeNone )); shade = c->shadeMode() != Client::ShadeNone; + } if( skiptaskbarrule == RememberRule ) + { + updated = updated || skiptaskbar != c->skipTaskbar(); skiptaskbar = c->skipTaskbar(); + } if( skippagerrule == RememberRule ) + { + updated = updated || skippager != c->skipPager(); skippager = c->skipPager(); + } if( aboverule == RememberRule ) + { + updated = updated || above != c->keepAbove(); above = c->keepAbove(); + } if( belowrule == RememberRule ) + { + updated = updated || below != c->keepBelow(); below = c->keepBelow(); + } if( fullscreenrule == RememberRule ) + { + updated = updated || fullscreen != c->isFullScreen(); fullscreen = c->isFullScreen(); + } if( noborderrule == RememberRule ) + { + updated = updated || noborder != c->isUserNoBorder(); noborder = c->isUserNoBorder(); + } + if( updated ) + Workspace::self()->rulesUpdated(); } Placement::Policy WindowRules::checkPlacement( Placement::Policy placement ) const @@ -574,4 +616,9 @@ void Workspace::cleanupTemporaryRules() QTimer::singleShot( 60000, this, SLOT( cleanupTemporaryRules())); } +void Workspace::rulesUpdated() + { + rulesUpdatedTimer.start( 1000, true ); + } + } // namespace diff --git a/workspace.cpp b/workspace.cpp index 4e4c15caf9..e271ff93ed 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -112,6 +112,7 @@ Workspace::Workspace( bool restore ) connect( &temporaryRulesMessages, SIGNAL( gotMessage( const QString& )), this, SLOT( gotTemporaryRulesMessage( const QString& ))); + connect( &rulesUpdatedTimer, SIGNAL( timeout()), this, SLOT( writeWindowRules())); updateXTime(); // needed for proper initialization of user_time in Client ctor @@ -753,6 +754,7 @@ void Workspace::slotSettingsChanged(int category) Reread settings */ KWIN_PROCEDURE( CheckBorderSizesProcedure, cl->checkBorderSizes() ); +KWIN_PROCEDURE( ResetupRulesProcedure, cl->setupWindowRules( true ) ); void Workspace::slotReconfigure() { @@ -807,6 +809,9 @@ void Workspace::slotReconfigure() updateTopMenuGeometry(); updateCurrentTopMenu(); } + + loadWindowRules(); + forEachClient( ResetupRulesProcedure()); } void Workspace::loadDesktopSettings() diff --git a/workspace.h b/workspace.h index ec2bd2e6a0..1e9b6db0a4 100644 --- a/workspace.h +++ b/workspace.h @@ -204,6 +204,7 @@ class Workspace : public QObject, public KWinInterface, public KDecorationDefine SessionInfo* takeSessionInfo( Client* ); WindowRules* findWindowRules( const Client*, bool ); + void rulesUpdated(); // dcop interface void cascadeDesktop(); @@ -333,6 +334,7 @@ class Workspace : public QObject, public KWinInterface, public KDecorationDefine void delayFocus(); void gotTemporaryRulesMessage( const QString& ); void cleanupTemporaryRules(); + void writeWindowRules(); protected: bool keyPressMouseEmulation( XKeyEvent& ev ); @@ -429,12 +431,12 @@ class Workspace : public QObject, public KWinInterface, public KDecorationDefine void loadSessionInfo(); void loadWindowRules(); - void writeWindowRules(); void editWindowRules( Client* ); QPtrList session; QValueList windowRules; KXMessages temporaryRulesMessages; + QTimer rulesUpdatedTimer; static const char* windowTypeToTxt( NET::WindowType type ); static NET::WindowType txtToWindowType( const char* txt ); static bool sessionInfoWindowTypeMatch( Client* c, SessionInfo* info );