2004-05-28 13:51:11 +00:00
|
|
|
/*****************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2004 Lubos Lunak <l.lunak@kde.org>
|
|
|
|
|
|
|
|
You can Freely distribute this program under the GNU General Public
|
|
|
|
License. See the file "COPYING" for the exact licensing terms.
|
|
|
|
******************************************************************/
|
|
|
|
|
|
|
|
#include "rules.h"
|
|
|
|
|
2004-06-18 08:57:42 +00:00
|
|
|
#include <fixx11h.h>
|
2004-05-28 13:51:11 +00:00
|
|
|
#include <kconfig.h>
|
|
|
|
#include <qregexp.h>
|
2004-06-11 15:10:09 +00:00
|
|
|
#include <ktempfile.h>
|
|
|
|
#include <ksimpleconfig.h>
|
|
|
|
#include <qfile.h>
|
2004-05-28 13:51:11 +00:00
|
|
|
|
|
|
|
#include "client.h"
|
|
|
|
#include "workspace.h"
|
|
|
|
|
|
|
|
namespace KWinInternal
|
|
|
|
{
|
|
|
|
|
2004-06-18 08:57:42 +00:00
|
|
|
Rules::Rules()
|
2004-06-11 15:10:09 +00:00
|
|
|
: temporary_state( 0 )
|
|
|
|
, wmclassregexp( false )
|
2004-05-28 13:54:20 +00:00
|
|
|
, wmclasscomplete( false )
|
2004-05-28 13:51:11 +00:00
|
|
|
, windowroleregexp( false )
|
|
|
|
, titleregexp( false )
|
|
|
|
, extraroleregexp( false )
|
2004-05-28 13:54:20 +00:00
|
|
|
, clientmachineregexp( false )
|
2004-05-31 14:04:49 +00:00
|
|
|
, types( NET::AllTypesMask )
|
2004-06-18 08:57:42 +00:00
|
|
|
, placementrule( UnusedForceRule )
|
|
|
|
, positionrule( UnusedSetRule )
|
|
|
|
, sizerule( UnusedSetRule )
|
|
|
|
, minsizerule( UnusedForceRule )
|
|
|
|
, maxsizerule( UnusedForceRule )
|
2004-06-21 12:38:40 +00:00
|
|
|
, ignorepositionrule( UnusedForceRule )
|
2004-06-18 08:57:42 +00:00
|
|
|
, desktoprule( UnusedSetRule )
|
|
|
|
, typerule( UnusedForceRule )
|
|
|
|
, maximizevertrule( UnusedSetRule )
|
|
|
|
, maximizehorizrule( UnusedSetRule )
|
|
|
|
, minimizerule( UnusedSetRule )
|
|
|
|
, shaderule( UnusedSetRule )
|
|
|
|
, skiptaskbarrule( UnusedSetRule )
|
|
|
|
, skippagerrule( UnusedSetRule )
|
|
|
|
, aboverule( UnusedSetRule )
|
|
|
|
, belowrule( UnusedSetRule )
|
|
|
|
, fullscreenrule( UnusedSetRule )
|
|
|
|
, noborderrule( UnusedSetRule )
|
|
|
|
, fsplevelrule( UnusedForceRule )
|
|
|
|
, acceptfocusrule( UnusedForceRule )
|
|
|
|
, moveresizemoderule( UnusedForceRule )
|
|
|
|
, closeablerule( UnusedForceRule )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Rules::Rules( const QString& str, bool temporary )
|
2004-06-11 15:10:09 +00:00
|
|
|
: temporary_state( temporary ? 2 : 0 )
|
|
|
|
{
|
|
|
|
KTempFile file;
|
|
|
|
QFile* f = file.file();
|
|
|
|
if( f != NULL )
|
|
|
|
{
|
|
|
|
QCString s = str.utf8();
|
|
|
|
f->writeBlock( s.data(), s.length());
|
|
|
|
}
|
|
|
|
file.close();
|
|
|
|
KSimpleConfig cfg( file.name());
|
|
|
|
readFromCfg( cfg );
|
|
|
|
file.unlink();
|
|
|
|
}
|
|
|
|
|
2004-05-31 14:31:52 +00:00
|
|
|
#define READ_MATCH_STRING( var, func ) \
|
|
|
|
var = cfg.readEntry( #var ) func; \
|
|
|
|
var##regexp = cfg.readBoolEntry( #var "regexp" );
|
|
|
|
|
|
|
|
#define READ_SET_RULE( var, type, func ) \
|
|
|
|
var = func ( cfg.read##type##Entry( #var )); \
|
2004-06-18 08:57:42 +00:00
|
|
|
var##rule = readSetRule( cfg, #var "rule" );
|
2004-05-31 14:31:52 +00:00
|
|
|
|
2004-06-11 15:12:43 +00:00
|
|
|
#define READ_SET_RULE_DEF( var, type, func, def ) \
|
|
|
|
var = func ( cfg.read##type##Entry( #var, def )); \
|
2004-06-18 08:57:42 +00:00
|
|
|
var##rule = readSetRule( cfg, #var "rule" );
|
2004-06-11 15:12:43 +00:00
|
|
|
|
2004-05-31 14:31:52 +00:00
|
|
|
#define READ_SET_RULE_2( var, type, func, funcarg ) \
|
|
|
|
var = func ( cfg.read##type##Entry( #var ), funcarg ); \
|
2004-06-18 08:57:42 +00:00
|
|
|
var##rule = readSetRule( cfg, #var "rule" );
|
2004-06-09 08:29:35 +00:00
|
|
|
|
|
|
|
#define READ_FORCE_RULE( var, type, func ) \
|
|
|
|
var = func ( cfg.read##type##Entry( #var )); \
|
|
|
|
var##rule = readForceRule( cfg, #var "rule" );
|
|
|
|
|
2004-06-18 08:57:42 +00:00
|
|
|
#define READ_FORCE_RULE_2( var, type, func, funcarg ) \
|
|
|
|
var = func ( cfg.read##type##Entry( #var ), funcarg ); \
|
|
|
|
var##rule = readForceRule( cfg, #var "rule" );
|
|
|
|
|
|
|
|
|
|
|
|
Rules::Rules( KConfig& cfg )
|
2004-06-11 15:10:09 +00:00
|
|
|
: temporary_state( 0 )
|
|
|
|
{
|
|
|
|
readFromCfg( cfg );
|
|
|
|
}
|
|
|
|
|
2004-06-11 15:12:07 +00:00
|
|
|
static int limit0to4( int i ) { return QMAX( 0, QMIN( 4, i )); }
|
|
|
|
|
2004-06-18 08:57:42 +00:00
|
|
|
void Rules::readFromCfg( KConfig& cfg )
|
2004-05-28 13:51:11 +00:00
|
|
|
{
|
|
|
|
wmclass = cfg.readEntry( "wmclass" ).lower().latin1();
|
|
|
|
wmclassregexp = cfg.readBoolEntry( "wmclassregexp" );
|
2004-05-28 13:54:20 +00:00
|
|
|
wmclasscomplete = cfg.readBoolEntry( "wmclasscomplete" );
|
2004-05-31 14:31:52 +00:00
|
|
|
READ_MATCH_STRING( windowrole, .lower().latin1() );
|
|
|
|
READ_MATCH_STRING( title, );
|
|
|
|
READ_MATCH_STRING( extrarole, .lower().latin1() );
|
|
|
|
READ_MATCH_STRING( clientmachine, .lower().latin1() );
|
2004-05-31 14:04:49 +00:00
|
|
|
types = cfg.readUnsignedLongNumEntry( "types", NET::AllTypesMask );
|
2004-06-18 08:57:42 +00:00
|
|
|
READ_FORCE_RULE_2( placement,, Placement::policyFromString, false );
|
2004-06-11 15:12:43 +00:00
|
|
|
READ_SET_RULE_DEF( position, Point,, &invalidPoint );
|
2004-05-31 14:31:52 +00:00
|
|
|
READ_SET_RULE( size, Size, );
|
2004-06-18 22:06:04 +00:00
|
|
|
if( size.isEmpty() && sizerule != ( SetRule )Remember)
|
2004-06-18 08:57:42 +00:00
|
|
|
sizerule = UnusedSetRule;
|
|
|
|
READ_FORCE_RULE( minsize, Size, );
|
2004-05-31 14:25:25 +00:00
|
|
|
if( !minsize.isValid())
|
2004-06-18 08:57:42 +00:00
|
|
|
minsizerule = UnusedForceRule;
|
|
|
|
READ_FORCE_RULE( maxsize, Size, );
|
2004-05-31 14:25:25 +00:00
|
|
|
if( maxsize.isEmpty())
|
2004-06-18 08:57:42 +00:00
|
|
|
maxsizerule = UnusedForceRule;
|
2004-06-21 12:38:40 +00:00
|
|
|
READ_FORCE_RULE( ignoreposition, Bool, );
|
2004-05-31 14:31:52 +00:00
|
|
|
READ_SET_RULE( desktop, Num, );
|
2004-05-28 15:04:01 +00:00
|
|
|
type = readType( cfg, "type" );
|
2004-06-18 08:57:42 +00:00
|
|
|
typerule = type != NET::Unknown ? readForceRule( cfg, "typerule" ) : UnusedForceRule;
|
2004-06-03 14:09:45 +00:00
|
|
|
READ_SET_RULE( maximizevert, Bool, );
|
|
|
|
READ_SET_RULE( maximizehoriz, Bool, );
|
|
|
|
READ_SET_RULE( minimize, Bool, );
|
|
|
|
READ_SET_RULE( shade, Bool, );
|
|
|
|
READ_SET_RULE( skiptaskbar, Bool, );
|
|
|
|
READ_SET_RULE( skippager, Bool, );
|
2004-05-31 14:31:52 +00:00
|
|
|
READ_SET_RULE( above, Bool, );
|
|
|
|
READ_SET_RULE( below, Bool, );
|
2004-06-03 14:09:45 +00:00
|
|
|
READ_SET_RULE( fullscreen, Bool, );
|
|
|
|
READ_SET_RULE( noborder, Bool, );
|
2004-06-11 15:12:07 +00:00
|
|
|
READ_FORCE_RULE( fsplevel, Num, limit0to4 ); // fsp is 0-4
|
2004-06-09 08:30:06 +00:00
|
|
|
READ_FORCE_RULE( acceptfocus, Bool, );
|
2004-06-09 08:33:53 +00:00
|
|
|
READ_FORCE_RULE( moveresizemode, , Options::stringToMoveResizeMode );
|
|
|
|
READ_FORCE_RULE( closeable, Bool, );
|
2004-06-18 08:57:42 +00:00
|
|
|
kdDebug() << "READ RULE:" << this << endl;
|
2004-05-28 13:51:11 +00:00
|
|
|
}
|
|
|
|
|
2004-05-31 14:31:52 +00:00
|
|
|
#undef READ_MATCH_STRING
|
|
|
|
#undef READ_SET_RULE
|
|
|
|
#undef READ_SET_RULE_2
|
2004-06-09 08:29:35 +00:00
|
|
|
#undef READ_FORCE_RULE
|
2004-06-18 08:57:42 +00:00
|
|
|
#undef READ_FORCE_RULE_2
|
2004-05-31 14:31:52 +00:00
|
|
|
|
2004-05-28 13:51:11 +00:00
|
|
|
#define WRITE_MATCH_STRING( var, cast ) \
|
|
|
|
if( !var.isEmpty()) \
|
|
|
|
{ \
|
|
|
|
cfg.writeEntry( #var, cast var ); \
|
|
|
|
cfg.writeEntry( #var "regexp", var##regexp ); \
|
|
|
|
} \
|
|
|
|
else \
|
|
|
|
{ \
|
|
|
|
cfg.deleteEntry( #var ); \
|
|
|
|
cfg.deleteEntry( #var "regexp" ); \
|
|
|
|
}
|
|
|
|
|
2004-05-31 14:14:10 +00:00
|
|
|
#define WRITE_SET_RULE( var, func ) \
|
2004-06-18 08:57:42 +00:00
|
|
|
if( var##rule != UnusedSetRule ) \
|
|
|
|
{ \
|
|
|
|
cfg.writeEntry( #var, func ( var )); \
|
|
|
|
cfg.writeEntry( #var "rule", var##rule ); \
|
|
|
|
} \
|
|
|
|
else \
|
|
|
|
{ \
|
|
|
|
cfg.deleteEntry( #var ); \
|
|
|
|
cfg.deleteEntry( #var "rule" ); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define WRITE_FORCE_RULE( var, func ) \
|
|
|
|
if( var##rule != UnusedForceRule ) \
|
2004-05-28 13:51:11 +00:00
|
|
|
{ \
|
2004-05-31 14:14:10 +00:00
|
|
|
cfg.writeEntry( #var, func ( var )); \
|
2004-05-28 13:51:11 +00:00
|
|
|
cfg.writeEntry( #var "rule", var##rule ); \
|
|
|
|
} \
|
|
|
|
else \
|
|
|
|
{ \
|
|
|
|
cfg.deleteEntry( #var ); \
|
|
|
|
cfg.deleteEntry( #var "rule" ); \
|
|
|
|
}
|
|
|
|
|
2004-05-31 14:04:49 +00:00
|
|
|
#define WRITE_WITH_DEFAULT( var, default ) \
|
|
|
|
if( var != default ) \
|
|
|
|
cfg.writeEntry( #var, var ); \
|
|
|
|
else \
|
|
|
|
cfg.deleteEntry( #var );
|
|
|
|
|
|
|
|
|
2004-06-18 08:57:42 +00:00
|
|
|
void Rules::write( KConfig& cfg ) const
|
2004-05-28 13:51:11 +00:00
|
|
|
{
|
|
|
|
// always write wmclass
|
|
|
|
cfg.writeEntry( "wmclass", ( const char* )wmclass );
|
|
|
|
cfg.writeEntry( "wmclassregexp", wmclassregexp );
|
2004-05-28 13:54:20 +00:00
|
|
|
cfg.writeEntry( "wmclasscomplete", wmclasscomplete );
|
2004-05-28 13:51:11 +00:00
|
|
|
WRITE_MATCH_STRING( windowrole, (const char*) );
|
|
|
|
WRITE_MATCH_STRING( title, );
|
|
|
|
WRITE_MATCH_STRING( extrarole, (const char*) );
|
2004-05-28 13:54:20 +00:00
|
|
|
WRITE_MATCH_STRING( clientmachine, (const char*) );
|
2004-05-31 14:04:49 +00:00
|
|
|
WRITE_WITH_DEFAULT( types, NET::AllTypesMask );
|
2004-06-18 08:57:42 +00:00
|
|
|
WRITE_FORCE_RULE( placement, Placement::policyToString );
|
2004-05-31 14:25:25 +00:00
|
|
|
WRITE_SET_RULE( position, );
|
|
|
|
WRITE_SET_RULE( size, );
|
2004-06-18 08:57:42 +00:00
|
|
|
WRITE_FORCE_RULE( minsize, );
|
|
|
|
WRITE_FORCE_RULE( maxsize, );
|
2004-06-21 12:38:40 +00:00
|
|
|
WRITE_FORCE_RULE( ignoreposition, );
|
2004-05-31 14:14:10 +00:00
|
|
|
WRITE_SET_RULE( desktop, );
|
2004-06-18 08:57:42 +00:00
|
|
|
WRITE_FORCE_RULE( type, );
|
2004-06-03 14:09:45 +00:00
|
|
|
WRITE_SET_RULE( maximizevert, );
|
|
|
|
WRITE_SET_RULE( maximizehoriz, );
|
|
|
|
WRITE_SET_RULE( minimize, );
|
|
|
|
WRITE_SET_RULE( shade, );
|
|
|
|
WRITE_SET_RULE( skiptaskbar, );
|
|
|
|
WRITE_SET_RULE( skippager, );
|
2004-05-31 14:14:10 +00:00
|
|
|
WRITE_SET_RULE( above, );
|
|
|
|
WRITE_SET_RULE( below, );
|
2004-06-03 14:09:45 +00:00
|
|
|
WRITE_SET_RULE( fullscreen, );
|
|
|
|
WRITE_SET_RULE( noborder, );
|
2004-06-18 08:57:42 +00:00
|
|
|
WRITE_FORCE_RULE( fsplevel, );
|
|
|
|
WRITE_FORCE_RULE( acceptfocus, );
|
|
|
|
WRITE_FORCE_RULE( moveresizemode, Options::moveResizeModeToString );
|
|
|
|
WRITE_FORCE_RULE( closeable, );
|
2004-05-28 13:51:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#undef WRITE_MATCH_STRING
|
|
|
|
#undef WRITE_SET_RULE
|
2004-06-18 08:57:42 +00:00
|
|
|
#undef WRITE_FORCE_RULE
|
2004-05-31 14:04:49 +00:00
|
|
|
#undef WRITE_WITH_DEFAULT
|
2004-05-28 13:51:11 +00:00
|
|
|
|
2004-06-18 08:57:42 +00:00
|
|
|
Rules::SetRule Rules::readSetRule( KConfig& cfg, const QString& key )
|
2004-05-28 13:51:11 +00:00
|
|
|
{
|
|
|
|
int v = cfg.readNumEntry( key );
|
2004-06-18 08:57:42 +00:00
|
|
|
if( v >= DontAffect && v <= Remember )
|
|
|
|
return static_cast< SetRule >( v );
|
|
|
|
return UnusedSetRule;
|
2004-05-28 13:51:11 +00:00
|
|
|
}
|
|
|
|
|
2004-06-18 08:57:42 +00:00
|
|
|
Rules::ForceRule Rules::readForceRule( KConfig& cfg, const QString& key )
|
2004-05-28 13:51:11 +00:00
|
|
|
{
|
2004-05-28 15:04:01 +00:00
|
|
|
int v = cfg.readNumEntry( key );
|
2004-06-18 08:57:42 +00:00
|
|
|
if( v == DontAffect || v == Force )
|
|
|
|
return static_cast< ForceRule >( v );
|
|
|
|
return UnusedForceRule;
|
2004-05-28 15:04:01 +00:00
|
|
|
}
|
|
|
|
|
2004-06-18 08:57:42 +00:00
|
|
|
NET::WindowType Rules::readType( KConfig& cfg, const QString& key )
|
2004-05-28 15:04:01 +00:00
|
|
|
{
|
|
|
|
int v = cfg.readNumEntry( key );
|
|
|
|
if( v >= NET::Normal && v <= NET::Splash )
|
|
|
|
return static_cast< NET::WindowType >( v );
|
|
|
|
return NET::Unknown;
|
2004-05-28 13:51:11 +00:00
|
|
|
}
|
|
|
|
|
2004-06-18 08:57:42 +00:00
|
|
|
bool Rules::match( const Client* c ) const
|
2004-05-28 13:51:11 +00:00
|
|
|
{
|
2004-05-31 14:04:49 +00:00
|
|
|
if( types != NET::AllTypesMask )
|
|
|
|
{
|
2004-06-11 15:10:09 +00:00
|
|
|
NET::WindowType t = c->windowType( true ); // direct type
|
|
|
|
if( t == NET::Unknown )
|
|
|
|
t = NET::Normal; // NET::Unknown->NET::Normal is only here for matching
|
|
|
|
if( !NET::typeMatchesMask( t, types ))
|
2004-05-31 14:04:49 +00:00
|
|
|
return false;
|
|
|
|
}
|
2004-05-28 13:51:11 +00:00
|
|
|
if( !wmclass.isEmpty())
|
|
|
|
{ // TODO optimize?
|
2004-05-28 13:54:20 +00:00
|
|
|
QCString cwmclass = wmclasscomplete
|
2004-06-10 12:34:20 +00:00
|
|
|
? c->resourceName() + ' ' + c->resourceClass() : c->resourceClass();
|
2004-06-11 15:10:09 +00:00
|
|
|
if( wmclassregexp && QRegExp( wmclass ).search( cwmclass ) == -1 )
|
2004-05-28 13:51:11 +00:00
|
|
|
return false;
|
2004-05-28 13:54:20 +00:00
|
|
|
if( !wmclassregexp && wmclass != cwmclass )
|
2004-05-28 13:51:11 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if( !windowrole.isEmpty())
|
|
|
|
{
|
2004-06-11 15:10:09 +00:00
|
|
|
if( windowroleregexp && QRegExp( windowrole ).search( c->windowRole()) == -1 )
|
2004-05-28 13:51:11 +00:00
|
|
|
return false;
|
|
|
|
if( !windowroleregexp && windowrole != c->windowRole())
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if( !title.isEmpty())
|
|
|
|
{
|
2004-06-11 15:10:09 +00:00
|
|
|
if( titleregexp && QRegExp( title ).search( c->caption( false )) == -1 )
|
2004-05-28 13:51:11 +00:00
|
|
|
return false;
|
|
|
|
if( !titleregexp && title != c->caption( false ))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
// TODO extrarole
|
2004-05-28 13:54:20 +00:00
|
|
|
if( !clientmachine.isEmpty())
|
|
|
|
{
|
|
|
|
if( clientmachineregexp
|
2004-06-11 15:10:09 +00:00
|
|
|
&& QRegExp( clientmachine ).search( c->wmClientMachine( true )) == -1
|
|
|
|
&& QRegExp( clientmachine ).search( c->wmClientMachine( false )) == -1 )
|
2004-05-28 13:54:20 +00:00
|
|
|
return false;
|
|
|
|
if( !clientmachineregexp
|
|
|
|
&& clientmachine != c->wmClientMachine( true )
|
|
|
|
&& clientmachine != c->wmClientMachine( false ))
|
|
|
|
return false;
|
|
|
|
}
|
2004-05-28 13:51:11 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2004-06-18 08:57:42 +00:00
|
|
|
bool Rules::update( Client* c )
|
2004-05-28 15:04:01 +00:00
|
|
|
{
|
|
|
|
// TODO check this setting is for this client ?
|
2004-06-11 15:12:29 +00:00
|
|
|
bool updated = false;
|
2004-06-18 22:06:04 +00:00
|
|
|
if( positionrule == ( SetRule )Remember)
|
2004-06-11 15:12:29 +00:00
|
|
|
{
|
|
|
|
updated = updated || position != c->pos();
|
2004-05-31 14:25:25 +00:00
|
|
|
position = c->pos();
|
2004-06-11 15:12:29 +00:00
|
|
|
}
|
2004-06-18 22:06:04 +00:00
|
|
|
if( sizerule == ( SetRule )Remember)
|
2004-06-11 15:12:29 +00:00
|
|
|
{
|
|
|
|
updated = updated || size != c->size();
|
2004-05-31 14:25:25 +00:00
|
|
|
size = c->size();
|
2004-06-11 15:12:29 +00:00
|
|
|
}
|
2004-06-18 22:06:04 +00:00
|
|
|
if( desktoprule == ( SetRule )Remember)
|
2004-06-11 15:12:29 +00:00
|
|
|
{
|
|
|
|
updated = updated || desktop != c->desktop();
|
2004-05-28 15:04:01 +00:00
|
|
|
desktop = c->desktop();
|
2004-06-11 15:12:29 +00:00
|
|
|
}
|
2004-06-18 22:06:04 +00:00
|
|
|
if( maximizevertrule == ( SetRule )Remember)
|
2004-06-11 15:12:29 +00:00
|
|
|
{
|
|
|
|
updated = updated || maximizevert != bool( c->maximizeMode() & MaximizeVertical );
|
2004-06-03 14:09:45 +00:00
|
|
|
maximizevert = c->maximizeMode() & MaximizeVertical;
|
2004-06-11 15:12:29 +00:00
|
|
|
}
|
2004-06-18 22:06:04 +00:00
|
|
|
if( maximizehorizrule == ( SetRule )Remember)
|
2004-06-11 15:12:29 +00:00
|
|
|
{
|
|
|
|
updated = updated || maximizehoriz != bool( c->maximizeMode() & MaximizeHorizontal );
|
2004-06-03 14:09:45 +00:00
|
|
|
maximizehoriz = c->maximizeMode() & MaximizeHorizontal;
|
2004-06-11 15:12:29 +00:00
|
|
|
}
|
2004-06-18 22:06:04 +00:00
|
|
|
if( minimizerule == ( SetRule )Remember)
|
2004-06-11 15:12:29 +00:00
|
|
|
{
|
|
|
|
updated = updated || minimize != c->isMinimized();
|
2004-06-03 14:09:45 +00:00
|
|
|
minimize = c->isMinimized();
|
2004-06-11 15:12:29 +00:00
|
|
|
}
|
2004-06-18 22:06:04 +00:00
|
|
|
if( shaderule == ( SetRule )Remember)
|
2004-06-11 15:12:29 +00:00
|
|
|
{
|
2004-06-18 08:57:42 +00:00
|
|
|
updated = updated || ( shade != ( c->shadeMode() != ShadeNone ));
|
|
|
|
shade = c->shadeMode() != ShadeNone;
|
2004-06-11 15:12:29 +00:00
|
|
|
}
|
2004-06-18 22:06:04 +00:00
|
|
|
if( skiptaskbarrule == ( SetRule )Remember)
|
2004-06-11 15:12:29 +00:00
|
|
|
{
|
|
|
|
updated = updated || skiptaskbar != c->skipTaskbar();
|
2004-06-03 14:09:45 +00:00
|
|
|
skiptaskbar = c->skipTaskbar();
|
2004-06-11 15:12:29 +00:00
|
|
|
}
|
2004-06-18 22:06:04 +00:00
|
|
|
if( skippagerrule == ( SetRule )Remember)
|
2004-06-11 15:12:29 +00:00
|
|
|
{
|
|
|
|
updated = updated || skippager != c->skipPager();
|
2004-06-03 14:09:45 +00:00
|
|
|
skippager = c->skipPager();
|
2004-06-11 15:12:29 +00:00
|
|
|
}
|
2004-06-18 22:06:04 +00:00
|
|
|
if( aboverule == ( SetRule )Remember)
|
2004-06-11 15:12:29 +00:00
|
|
|
{
|
|
|
|
updated = updated || above != c->keepAbove();
|
2004-05-28 15:04:01 +00:00
|
|
|
above = c->keepAbove();
|
2004-06-11 15:12:29 +00:00
|
|
|
}
|
2004-06-18 22:06:04 +00:00
|
|
|
if( belowrule == ( SetRule )Remember)
|
2004-06-11 15:12:29 +00:00
|
|
|
{
|
|
|
|
updated = updated || below != c->keepBelow();
|
2004-05-28 15:04:01 +00:00
|
|
|
below = c->keepBelow();
|
2004-06-11 15:12:29 +00:00
|
|
|
}
|
2004-06-18 22:06:04 +00:00
|
|
|
if( fullscreenrule == ( SetRule )Remember)
|
2004-06-11 15:12:29 +00:00
|
|
|
{
|
|
|
|
updated = updated || fullscreen != c->isFullScreen();
|
2004-06-03 14:09:45 +00:00
|
|
|
fullscreen = c->isFullScreen();
|
2004-06-11 15:12:29 +00:00
|
|
|
}
|
2004-06-18 22:06:04 +00:00
|
|
|
if( noborderrule == ( SetRule )Remember)
|
2004-06-11 15:12:29 +00:00
|
|
|
{
|
|
|
|
updated = updated || noborder != c->isUserNoBorder();
|
2004-06-03 14:09:45 +00:00
|
|
|
noborder = c->isUserNoBorder();
|
2004-06-11 15:12:29 +00:00
|
|
|
}
|
2004-06-18 08:57:42 +00:00
|
|
|
return updated;
|
2004-05-28 15:04:01 +00:00
|
|
|
}
|
|
|
|
|
2004-06-18 08:57:42 +00:00
|
|
|
#define APPLY_RULE( var, name, type ) \
|
|
|
|
bool Rules::apply##name( type& arg, bool init ) const \
|
|
|
|
{ \
|
|
|
|
if( checkSetRule( var##rule, init )) \
|
|
|
|
arg = this->var; \
|
|
|
|
return checkSetStop( var##rule ); \
|
2004-05-31 14:14:10 +00:00
|
|
|
}
|
|
|
|
|
2004-06-18 08:57:42 +00:00
|
|
|
#define APPLY_FORCE_RULE( var, name, type ) \
|
|
|
|
bool Rules::apply##name( type& arg ) const \
|
|
|
|
{ \
|
|
|
|
if( checkForceRule( var##rule )) \
|
|
|
|
arg = this->var; \
|
|
|
|
return checkForceStop( var##rule ); \
|
2004-05-31 14:25:25 +00:00
|
|
|
}
|
|
|
|
|
2004-06-18 08:57:42 +00:00
|
|
|
APPLY_FORCE_RULE( placement, Placement, Placement::Policy )
|
2004-05-31 14:25:25 +00:00
|
|
|
|
2004-06-18 08:57:42 +00:00
|
|
|
bool Rules::applyGeometry( QRect& rect, bool init ) const
|
2004-05-31 14:25:25 +00:00
|
|
|
{
|
2004-06-18 08:57:42 +00:00
|
|
|
QPoint p = rect.topLeft();
|
|
|
|
QSize s = rect.size();
|
|
|
|
bool ret = false; // no short-circuiting
|
|
|
|
if( applyPosition( p, init ))
|
|
|
|
{
|
|
|
|
rect.moveTopLeft( p );
|
|
|
|
ret = true;
|
|
|
|
}
|
|
|
|
if( applySize( s, init ))
|
|
|
|
{
|
|
|
|
rect.setSize( s );
|
|
|
|
ret = true;
|
|
|
|
}
|
|
|
|
return ret;
|
2004-05-31 14:25:25 +00:00
|
|
|
}
|
|
|
|
|
2004-06-18 08:57:42 +00:00
|
|
|
bool Rules::applyPosition( QPoint& pos, bool init ) const
|
2004-05-31 14:15:33 +00:00
|
|
|
{
|
2004-06-18 08:57:42 +00:00
|
|
|
if( pos != invalidPoint && checkSetRule( positionrule, init ))
|
|
|
|
pos = this->position;
|
|
|
|
return checkSetStop( positionrule );
|
2004-05-31 14:15:33 +00:00
|
|
|
}
|
|
|
|
|
2004-06-18 08:57:42 +00:00
|
|
|
bool Rules::applySize( QSize& s, bool init ) const
|
2004-05-31 14:15:33 +00:00
|
|
|
{
|
2004-06-18 08:57:42 +00:00
|
|
|
if( size.isValid() && checkSetRule( sizerule, init ))
|
|
|
|
s = this->size;
|
|
|
|
return checkSetStop( sizerule );
|
2004-05-31 14:15:33 +00:00
|
|
|
}
|
|
|
|
|
2004-06-18 08:57:42 +00:00
|
|
|
APPLY_FORCE_RULE( minsize, MinSize, QSize )
|
|
|
|
APPLY_FORCE_RULE( maxsize, MaxSize, QSize )
|
2004-06-21 12:38:40 +00:00
|
|
|
APPLY_FORCE_RULE( ignoreposition, IgnorePosition, bool )
|
2004-06-18 08:57:42 +00:00
|
|
|
APPLY_RULE( desktop, Desktop, int )
|
|
|
|
APPLY_FORCE_RULE( type, Type, NET::WindowType )
|
2004-05-28 13:51:11 +00:00
|
|
|
|
2004-06-18 08:57:42 +00:00
|
|
|
bool Rules::applyMaximizeHoriz( MaximizeMode& mode, bool init ) const
|
2004-05-28 13:51:11 +00:00
|
|
|
{
|
2004-06-18 08:57:42 +00:00
|
|
|
if( checkSetRule( maximizehorizrule, init ))
|
|
|
|
mode = static_cast< MaximizeMode >(( maximizehoriz ? MaximizeHorizontal : 0 ) | ( mode & MaximizeVertical ));
|
|
|
|
return checkSetStop( maximizehorizrule );
|
2004-05-28 13:51:11 +00:00
|
|
|
}
|
|
|
|
|
2004-06-18 08:57:42 +00:00
|
|
|
bool Rules::applyMaximizeVert( MaximizeMode& mode, bool init ) const
|
2004-05-28 13:51:11 +00:00
|
|
|
{
|
2004-06-18 08:57:42 +00:00
|
|
|
if( checkSetRule( maximizevertrule, init ))
|
|
|
|
mode = static_cast< MaximizeMode >(( maximizevert ? MaximizeVertical : 0 ) | ( mode & MaximizeHorizontal ));
|
|
|
|
return checkSetStop( maximizevertrule );
|
2004-05-28 13:51:11 +00:00
|
|
|
}
|
2004-06-03 14:09:45 +00:00
|
|
|
|
2004-06-18 08:57:42 +00:00
|
|
|
APPLY_RULE( minimize, Minimize, bool )
|
2004-06-03 14:09:45 +00:00
|
|
|
|
2004-06-18 08:57:42 +00:00
|
|
|
bool Rules::applyShade( ShadeMode& sh, bool init ) const
|
2004-06-03 14:09:45 +00:00
|
|
|
{
|
2004-06-18 08:57:42 +00:00
|
|
|
if( checkSetRule( shaderule, init ))
|
2004-06-03 14:09:45 +00:00
|
|
|
{
|
|
|
|
if( !this->shade )
|
2004-06-18 08:57:42 +00:00
|
|
|
sh = ShadeNone;
|
|
|
|
if( this->shade && sh == ShadeNone )
|
|
|
|
sh = ShadeNormal;
|
2004-06-03 14:09:45 +00:00
|
|
|
}
|
2004-06-18 08:57:42 +00:00
|
|
|
return checkSetStop( shaderule );
|
2004-06-03 14:09:45 +00:00
|
|
|
}
|
|
|
|
|
2004-06-18 08:57:42 +00:00
|
|
|
APPLY_RULE( skiptaskbar, SkipTaskbar, bool )
|
|
|
|
APPLY_RULE( skippager, SkipPager, bool )
|
|
|
|
APPLY_RULE( above, KeepAbove, bool )
|
|
|
|
APPLY_RULE( below, KeepBelow, bool )
|
|
|
|
APPLY_RULE( fullscreen, FullScreen, bool )
|
|
|
|
APPLY_RULE( noborder, NoBorder, bool )
|
|
|
|
APPLY_FORCE_RULE( fsplevel, FSP, int )
|
|
|
|
APPLY_FORCE_RULE( acceptfocus, AcceptFocus, bool )
|
|
|
|
APPLY_FORCE_RULE( moveresizemode, MoveResizeMode, Options::MoveResizeMode )
|
|
|
|
APPLY_FORCE_RULE( closeable, Closeable, bool )
|
2004-06-03 14:09:45 +00:00
|
|
|
|
2004-06-18 08:57:42 +00:00
|
|
|
#undef APPLY_RULE
|
|
|
|
#undef APPLY_FORCE_RULE
|
2004-06-03 14:09:45 +00:00
|
|
|
|
2004-06-18 08:57:42 +00:00
|
|
|
bool Rules::isTemporary() const
|
2004-06-03 14:09:45 +00:00
|
|
|
{
|
2004-06-18 08:57:42 +00:00
|
|
|
return temporary_state > 0;
|
2004-06-03 14:09:45 +00:00
|
|
|
}
|
|
|
|
|
2004-06-18 08:57:42 +00:00
|
|
|
bool Rules::discardTemporary( bool force )
|
2004-06-03 14:09:45 +00:00
|
|
|
{
|
2004-06-18 08:57:42 +00:00
|
|
|
if( temporary_state == 0 ) // not temporary
|
|
|
|
return false;
|
|
|
|
if( force || --temporary_state == 0 ) // too old
|
|
|
|
{
|
|
|
|
kdDebug() << "DISCARD:" << this << endl;
|
|
|
|
delete this;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2004-05-28 15:04:01 +00:00
|
|
|
}
|
2004-05-28 13:51:11 +00:00
|
|
|
|
2004-06-18 08:57:42 +00:00
|
|
|
#ifndef NDEBUG
|
|
|
|
kdbgstream& operator<<( kdbgstream& stream, const Rules* r )
|
2004-06-03 14:09:45 +00:00
|
|
|
{
|
2004-06-18 08:57:42 +00:00
|
|
|
return stream << "[" << r->wmclass << "/" << r->windowrole << "/" << r->title << "]";
|
2004-06-03 14:09:45 +00:00
|
|
|
}
|
2004-06-18 08:57:42 +00:00
|
|
|
#endif
|
2004-06-03 14:09:45 +00:00
|
|
|
|
2004-06-18 08:57:42 +00:00
|
|
|
void WindowRules::discardTemporary()
|
2004-06-03 14:09:45 +00:00
|
|
|
{
|
2004-06-18 08:57:42 +00:00
|
|
|
QValueVector< Rules* >::Iterator it2 = rules.begin();
|
|
|
|
for( QValueVector< Rules* >::Iterator it = rules.begin();
|
|
|
|
it != rules.end();
|
|
|
|
)
|
|
|
|
{
|
|
|
|
if( (*it)->discardTemporary( false ))
|
|
|
|
++it;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*it2++ = *it++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rules.erase( it2, rules.end());
|
2004-06-03 14:09:45 +00:00
|
|
|
}
|
|
|
|
|
2004-06-18 08:57:42 +00:00
|
|
|
void WindowRules::update( Client* c )
|
2004-06-09 08:29:35 +00:00
|
|
|
{
|
2004-06-18 08:57:42 +00:00
|
|
|
bool updated = false;
|
|
|
|
for( QValueVector< Rules* >::ConstIterator it = rules.begin();
|
|
|
|
it != rules.end();
|
|
|
|
++it )
|
|
|
|
if( (*it)->update( c )) // no short-circuiting here
|
|
|
|
updated = true;
|
|
|
|
if( updated )
|
|
|
|
Workspace::self()->rulesUpdated();
|
2004-06-09 08:29:35 +00:00
|
|
|
}
|
2004-06-03 14:09:45 +00:00
|
|
|
|
2004-06-18 08:57:42 +00:00
|
|
|
#define CHECK_RULE( rule, type ) \
|
|
|
|
type WindowRules::check##rule( type arg, bool init ) const \
|
|
|
|
{ \
|
|
|
|
if( rules.count() == 0 ) \
|
|
|
|
return arg; \
|
|
|
|
type ret = arg; \
|
|
|
|
for( QValueVector< Rules* >::ConstIterator it = rules.begin(); \
|
|
|
|
it != rules.end(); \
|
|
|
|
++it ) \
|
|
|
|
{ \
|
|
|
|
if( (*it)->apply##rule( ret, init )) \
|
|
|
|
break; \
|
|
|
|
} \
|
|
|
|
return ret; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define CHECK_FORCE_RULE( rule, type ) \
|
|
|
|
type WindowRules::check##rule( type arg ) const \
|
|
|
|
{ \
|
|
|
|
if( rules.count() == 0 ) \
|
|
|
|
return arg; \
|
|
|
|
type ret = arg; \
|
|
|
|
for( QValueVector< Rules* >::ConstIterator it = rules.begin(); \
|
|
|
|
it != rules.end(); \
|
|
|
|
++it ) \
|
|
|
|
{ \
|
|
|
|
if( (*it)->apply##rule( ret )) \
|
|
|
|
break; \
|
|
|
|
} \
|
|
|
|
return ret; \
|
2004-06-09 08:30:06 +00:00
|
|
|
}
|
|
|
|
|
2004-06-18 08:57:42 +00:00
|
|
|
CHECK_FORCE_RULE( Placement, Placement::Policy )
|
2004-06-09 08:33:53 +00:00
|
|
|
|
2004-06-18 08:57:42 +00:00
|
|
|
QRect WindowRules::checkGeometry( QRect rect, bool init ) const
|
2004-06-09 08:33:53 +00:00
|
|
|
{
|
2004-06-18 08:57:42 +00:00
|
|
|
return QRect( checkPosition( rect.topLeft(), init ), checkSize( rect.size(), init ));
|
2004-06-09 08:33:53 +00:00
|
|
|
}
|
|
|
|
|
2004-06-18 08:57:42 +00:00
|
|
|
CHECK_RULE( Position, QPoint )
|
|
|
|
CHECK_RULE( Size, QSize )
|
|
|
|
CHECK_FORCE_RULE( MinSize, QSize )
|
|
|
|
CHECK_FORCE_RULE( MaxSize, QSize )
|
2004-06-21 12:38:40 +00:00
|
|
|
CHECK_FORCE_RULE( IgnorePosition, bool )
|
2004-06-18 08:57:42 +00:00
|
|
|
CHECK_RULE( Desktop, int )
|
|
|
|
CHECK_FORCE_RULE( Type, NET::WindowType )
|
|
|
|
CHECK_RULE( MaximizeVert, KDecorationDefines::MaximizeMode )
|
|
|
|
CHECK_RULE( MaximizeHoriz, KDecorationDefines::MaximizeMode )
|
2004-06-11 15:10:09 +00:00
|
|
|
|
2004-06-18 08:57:42 +00:00
|
|
|
KDecorationDefines::MaximizeMode WindowRules::checkMaximize( MaximizeMode mode, bool init ) const
|
2004-06-11 15:10:09 +00:00
|
|
|
{
|
2004-06-18 08:57:42 +00:00
|
|
|
bool vert = checkMaximizeVert( mode, init ) & MaximizeVertical;
|
|
|
|
bool horiz = checkMaximizeHoriz( mode, init ) & MaximizeHorizontal;
|
|
|
|
return static_cast< MaximizeMode >(( vert ? MaximizeVertical : 0 ) | ( horiz ? MaximizeHorizontal : 0 ));
|
2004-06-11 15:10:09 +00:00
|
|
|
}
|
|
|
|
|
2004-06-18 08:57:42 +00:00
|
|
|
CHECK_RULE( Minimize, bool )
|
|
|
|
CHECK_RULE( Shade, ShadeMode )
|
|
|
|
CHECK_RULE( SkipTaskbar, bool )
|
|
|
|
CHECK_RULE( SkipPager, bool )
|
|
|
|
CHECK_RULE( KeepAbove, bool )
|
|
|
|
CHECK_RULE( KeepBelow, bool )
|
|
|
|
CHECK_RULE( FullScreen, bool )
|
|
|
|
CHECK_RULE( NoBorder, bool )
|
|
|
|
CHECK_FORCE_RULE( FSP, int )
|
|
|
|
CHECK_FORCE_RULE( AcceptFocus, bool )
|
|
|
|
CHECK_FORCE_RULE( MoveResizeMode, Options::MoveResizeMode )
|
|
|
|
CHECK_FORCE_RULE( Closeable, bool )
|
|
|
|
|
|
|
|
#undef CHECK_RULE
|
|
|
|
#undef CHECK_FORCE_RULE
|
|
|
|
|
2004-05-28 13:51:11 +00:00
|
|
|
// Client
|
|
|
|
|
2004-06-11 15:10:09 +00:00
|
|
|
void Client::setupWindowRules( bool ignore_temporary )
|
2004-05-28 13:51:11 +00:00
|
|
|
{
|
2004-06-11 15:10:09 +00:00
|
|
|
client_rules = workspace()->findWindowRules( this, ignore_temporary );
|
2004-05-28 15:04:01 +00:00
|
|
|
// check only after getting the rules, because there may be a rule forcing window type
|
|
|
|
if( isTopMenu()) // TODO cannot have restrictions
|
2004-06-18 08:57:42 +00:00
|
|
|
client_rules = WindowRules();
|
2004-05-28 13:51:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Client::updateWindowRules()
|
|
|
|
{
|
2004-06-18 08:57:42 +00:00
|
|
|
client_rules.update( this );
|
2004-05-28 13:51:11 +00:00
|
|
|
}
|
|
|
|
|
2004-05-31 14:25:25 +00:00
|
|
|
void Client::finishWindowRules()
|
|
|
|
{
|
|
|
|
updateWindowRules();
|
2004-06-18 08:57:42 +00:00
|
|
|
client_rules = WindowRules();
|
2004-05-31 14:25:25 +00:00
|
|
|
}
|
|
|
|
|
2004-05-28 13:51:11 +00:00
|
|
|
// Workspace
|
|
|
|
|
2004-06-18 08:57:42 +00:00
|
|
|
WindowRules Workspace::findWindowRules( const Client* c, bool ignore_temporary )
|
2004-05-28 13:51:11 +00:00
|
|
|
{
|
2004-06-18 08:57:42 +00:00
|
|
|
QValueVector< Rules* > ret;
|
|
|
|
for( QValueList< Rules* >::Iterator it = rules.begin();
|
|
|
|
it != rules.end();
|
|
|
|
)
|
2004-05-28 13:51:11 +00:00
|
|
|
{
|
2004-06-11 15:10:09 +00:00
|
|
|
if( ignore_temporary && (*it)->isTemporary())
|
2004-06-18 08:57:42 +00:00
|
|
|
{
|
|
|
|
++it;
|
2004-06-11 15:10:09 +00:00
|
|
|
continue;
|
2004-06-18 08:57:42 +00:00
|
|
|
}
|
2004-05-28 13:51:11 +00:00
|
|
|
if( (*it)->match( c ))
|
|
|
|
{
|
2004-06-18 08:57:42 +00:00
|
|
|
Rules* rule = *it;
|
|
|
|
kdDebug() << "RULE FOUND:" << rule << ":" << c << endl;
|
|
|
|
if( rule->isTemporary())
|
|
|
|
it = rules.remove( it );
|
|
|
|
else
|
|
|
|
++it;
|
|
|
|
ret.append( rule );
|
|
|
|
continue;
|
2004-05-28 13:51:11 +00:00
|
|
|
}
|
2004-06-18 08:57:42 +00:00
|
|
|
++it;
|
2004-05-28 13:51:11 +00:00
|
|
|
}
|
2004-06-18 08:57:42 +00:00
|
|
|
return WindowRules( ret );
|
2004-05-28 13:51:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::editWindowRules( Client* c )
|
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::loadWindowRules()
|
|
|
|
{
|
2004-06-18 08:57:42 +00:00
|
|
|
while( !rules.isEmpty())
|
2004-05-28 13:51:11 +00:00
|
|
|
{
|
2004-06-18 08:57:42 +00:00
|
|
|
delete rules.front();
|
|
|
|
rules.pop_front();
|
2004-05-28 13:51:11 +00:00
|
|
|
}
|
|
|
|
KConfig cfg( "kwinrulesrc", true );
|
|
|
|
cfg.setGroup( "General" );
|
|
|
|
int count = cfg.readNumEntry( "count" );
|
|
|
|
kdDebug() << "RULES:" << count << endl;
|
|
|
|
for( int i = 1;
|
|
|
|
i <= count;
|
|
|
|
++i )
|
|
|
|
{
|
|
|
|
cfg.setGroup( QString::number( i ));
|
2004-06-18 08:57:42 +00:00
|
|
|
Rules* rule = new Rules( cfg );
|
|
|
|
rules.append( rule );
|
2004-05-28 13:51:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::writeWindowRules()
|
|
|
|
{
|
|
|
|
KConfig cfg( "kwinrulesrc" );
|
|
|
|
cfg.setGroup( "General" );
|
2004-06-18 08:57:42 +00:00
|
|
|
cfg.writeEntry( "count", rules.count());
|
2004-05-28 13:51:11 +00:00
|
|
|
int i = 1;
|
2004-06-18 08:57:42 +00:00
|
|
|
for( QValueList< Rules* >::ConstIterator it = rules.begin();
|
|
|
|
it != rules.end();
|
2004-06-11 15:10:09 +00:00
|
|
|
++it )
|
2004-05-28 13:51:11 +00:00
|
|
|
{
|
2004-06-11 15:10:09 +00:00
|
|
|
if( (*it)->isTemporary())
|
|
|
|
continue;
|
2004-05-28 13:51:11 +00:00
|
|
|
cfg.setGroup( QString::number( i ));
|
|
|
|
(*it)->write( cfg );
|
2004-06-11 15:10:09 +00:00
|
|
|
++i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::gotTemporaryRulesMessage( const QString& message )
|
|
|
|
{
|
|
|
|
bool was_temporary = false;
|
2004-06-18 08:57:42 +00:00
|
|
|
for( QValueList< Rules* >::ConstIterator it = rules.begin();
|
|
|
|
it != rules.end();
|
2004-06-11 15:10:09 +00:00
|
|
|
++it )
|
|
|
|
if( (*it)->isTemporary())
|
|
|
|
was_temporary = true;
|
2004-06-18 08:57:42 +00:00
|
|
|
Rules* rule = new Rules( message, true );
|
|
|
|
rules.prepend( rule ); // highest priority first
|
2004-06-11 15:10:09 +00:00
|
|
|
if( !was_temporary )
|
|
|
|
QTimer::singleShot( 60000, this, SLOT( cleanupTemporaryRules()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::cleanupTemporaryRules()
|
|
|
|
{
|
|
|
|
kdDebug() << "CLEANUP" << endl;
|
|
|
|
bool has_temporary = false;
|
2004-06-18 08:57:42 +00:00
|
|
|
for( QValueList< Rules* >::Iterator it = rules.begin();
|
|
|
|
it != rules.end();
|
2004-06-11 15:10:09 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
if( (*it)->discardTemporary( false ))
|
2004-06-18 08:57:42 +00:00
|
|
|
it = rules.remove( it );
|
2004-06-11 15:10:09 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if( (*it)->isTemporary())
|
|
|
|
has_temporary = true;
|
|
|
|
++it;
|
|
|
|
}
|
2004-05-28 13:51:11 +00:00
|
|
|
}
|
2004-06-11 15:10:09 +00:00
|
|
|
if( has_temporary )
|
|
|
|
QTimer::singleShot( 60000, this, SLOT( cleanupTemporaryRules()));
|
2004-05-28 13:51:11 +00:00
|
|
|
}
|
|
|
|
|
2004-06-11 15:12:29 +00:00
|
|
|
void Workspace::rulesUpdated()
|
|
|
|
{
|
|
|
|
rulesUpdatedTimer.start( 1000, true );
|
|
|
|
}
|
|
|
|
|
2004-05-28 13:51:11 +00:00
|
|
|
} // namespace
|