[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdebase/kwin
From:       Luboš Luňák <l.lunak () kde ! org>
Date:       2005-08-16 17:46:45
Message-ID: 1124214405.185876.10430.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 449779 by lunakl:

Make it simpler to also edit special window setting affecting
the whole application.



 M  +59 -23    kcmkwin/kwinrules/main.cpp  
 M  +2 -1      lib/kdecoration.h  
 M  +6 -2      rules.cpp  
 M  +5 -1      useractions.cpp  
 M  +1 -1      workspace.h  


--- trunk/KDE/kdebase/kwin/kcmkwin/kwinrules/main.cpp #449778:449779
@@ -66,7 +66,7 @@
         }
     }
 
-static Rules* findRule( const Q3ValueList< Rules* >& rules, Window wid )
+static Rules* findRule( const Q3ValueList< Rules* >& rules, Window wid, bool \
whole_app )  {
     KWin::WindowInfo info = KWin::windowInfo( wid,
         NET::WMName | NET::WMWindowType,
@@ -102,29 +102,37 @@
             quality += 1;
             generic = false;  // this can be considered specific enough (old X apps)
             }
-        if( rule->windowrolematch != Rules::UnimportantMatch )
+        if( !whole_app )
             {
-            quality += rule->windowrolematch == Rules::ExactMatch ? 5 : 1;
-            generic = false;
+            if( rule->windowrolematch != Rules::UnimportantMatch )
+                {
+                quality += rule->windowrolematch == Rules::ExactMatch ? 5 : 1;
+                generic = false;
+                }
+            if( rule->titlematch != Rules::UnimportantMatch )
+                {
+                quality += rule->titlematch == Rules::ExactMatch ? 3 : 1;
+                generic = false;
+                }
+            if( rule->types != NET::AllTypesMask )
+                {
+                int bits = 0;
+                for( int bit = 1;
+                     bit < 1 << 31;
+                     bit <<= 1 )
+                    if( rule->types & bit )
+                        ++bits;
+                if( bits == 1 )
+                    quality += 2;
+                }
+            if( generic ) // ignore generic rules, use only the ones that are for \
this window +                continue;
             }
-        if( rule->titlematch != Rules::UnimportantMatch )
+        else
             {
-            quality += rule->titlematch == Rules::ExactMatch ? 3 : 1;
-            generic = false;
-            }
-        if( rule->types != NET::AllTypesMask )
-            {
-            int bits = 0;
-            for( int bit = 1;
-                 bit < 1 << 31;
-                 bit <<= 1 )
-                if( rule->types & bit )
-                    ++bits;
-            if( bits == 1 )
+            if( rule->types == NET::AllTypesMask )
                 quality += 2;
             }
-        if( generic ) // ignore generic rules, use only the ones that are for this \
                window
-            continue;
         if( !rule->matchType( type )
             || !rule->matchRole( role )
             || !rule->matchTitle( title )
@@ -139,7 +147,33 @@
     if( best_match != NULL )
         return best_match;
     Rules* ret = new Rules;
-    ret->description = i18n( "Settings for %1" ).arg( QString::fromLatin1( \
wmclass_class ) ); +    if( whole_app )
+        {
+        ret->description = i18n( "Application settings for %1" ).arg( \
QString::fromLatin1( wmclass_class )); +        // TODO maybe exclude some types? If \
yes, then also exclude them above +        // when searching.
+        ret->types = NET::AllTypesMask; 
+        ret->titlematch = Rules::UnimportantMatch;
+        ret->clientmachine = machine; // set, but make unimportant
+        ret->clientmachinematch = Rules::UnimportantMatch;
+        ret->extrarolematch = Rules::UnimportantMatch;
+        ret->windowrolematch = Rules::UnimportantMatch;
+        if( wmclass_name == wmclass_class )
+            {
+            ret->wmclasscomplete = false;
+            ret->wmclass = wmclass_class;
+            ret->wmclassmatch = Rules::ExactMatch;
+            }
+        else
+            {
+            // WM_CLASS components differ - perhaps the app got -name argument
+            ret->wmclasscomplete = true;
+            ret->wmclass = wmclass_name + ' ' + wmclass_class;
+            ret->wmclassmatch = Rules::ExactMatch;
+            }
+        return ret;
+        }
+    ret->description = i18n( "Window settings for %1" ).arg( QString::fromLatin1( \
wmclass_class ));  if( type == NET::Unknown )
         ret->types = NET::NormalMask;
     else
@@ -195,11 +229,11 @@
     return ret;
     }
 
-static int edit( Window wid )
+static int edit( Window wid, bool whole_app )
     {
     Q3ValueList< Rules* > rules;
     loadRules( rules );
-    Rules* orig_rule = findRule( rules, wid );
+    Rules* orig_rule = findRule( rules, wid, whole_app );
     RulesDialog dlg;
     // dlg.edit() creates new Rules instance if edited
     Rules* edited_rule = dlg.edit( orig_rule, wid );
@@ -232,6 +266,7 @@
     {
     // no need for I18N_NOOP(), this is not supposed to be used directly
         { "wid <wid>", "WId of the window for special window settings.", 0 },
+        { "whole-app", "Whether the settings should affect all windows of the \
application.", 0 },  KCmdLineLastOption
     };
 
@@ -246,11 +281,12 @@
     KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
     bool id_ok = false;
     Window id = args->getOption( "wid" ).toULongLong( &id_ok );
+    bool whole_app = args->isSet( "whole-app" );
     args->clear();
     if( !id_ok || id == None )
         {
 	KCmdLineArgs::usage( i18n( "This helper utility is not supposed to be called \
directly." ));  return 1;
         }
-    return KWinInternal::edit( id );
+    return KWinInternal::edit( id, whole_app );
     }
--- trunk/KDE/kdebase/kwin/lib/kdecoration.h #449778:449779
@@ -99,7 +99,8 @@
         FullScreenOp,
         NoBorderOp,
         NoOp,
-        SetupWindowShortcutOp
+        SetupWindowShortcutOp,
+        ApplicationRulesOp     ///< @since 3.5
         };
     /**
      * Basic color types that should be recognized by all decoration styles.
--- trunk/KDE/kdebase/kwin/rules.cpp #449778:449779
@@ -940,10 +940,14 @@
     return WindowRules( ret );
     }
 
-void Workspace::editWindowRules( Client* c )
+void Workspace::editWindowRules( Client* c, bool whole_app )
     {
     writeWindowRules();
-    KApplication::kdeinitExec( "kwin_rules_dialog", QStringList() << "--wid" << \
QString::number( c->window())); +    QStringList args;
+    args << "--wid" << QString::number( c->window());
+    if( whole_app )
+        args << "--whole-app";
+    KApplication::kdeinitExec( "kwin_rules_dialog", args );
     }
 
 void Workspace::loadWindowRules()
--- trunk/KDE/kdebase/kwin/useractions.cpp #449778:449779
@@ -68,6 +68,7 @@
         advanced_popup->insertItem( SmallIconSet("key_bindings"),
             i18n("Window &Shortcut...")+'\t'+keys->shortcut("Setup Window \
                Shortcut").seq(0).toString(), Options::SetupWindowShortcutOp );
         advanced_popup->insertItem( SmallIconSet( "wizard" ), i18n("&Special Window \
Settings..."), Options::WindowRulesOp ); +        advanced_popup->insertItem( \
SmallIconSet( "wizard" ), i18n("&Special Application Settings..."), \
Options::ApplicationRulesOp );  
         popup->insertItem(i18n("Ad&vanced"), advanced_popup );
         desk_popup_index = popup->count();
@@ -427,8 +428,11 @@
             c->performMouseCommand( Options::MouseShade, QCursor::pos());
             break;
         case Options::WindowRulesOp:
-            editWindowRules( c );
+            editWindowRules( c, false );
             break;
+        case Options::ApplicationRulesOp:
+            editWindowRules( c, true );
+            break;
         case Options::SetupWindowShortcutOp:
             setupWindowShortcut( c );
             break;
--- trunk/KDE/kdebase/kwin/workspace.h #449778:449779
@@ -482,7 +482,7 @@
 
         void loadSessionInfo();
         void loadWindowRules();
-        void editWindowRules( Client* );
+        void editWindowRules( Client* c, bool whole_app );
 
         QList<SessionInfo*> session;
         QList<Rules*> rules;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic