From 6e34bc5e8a462028fb995230b944a91f932b7c1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Wed, 9 Jun 2004 08:33:53 +0000 Subject: [PATCH] KWin rules for making windows noncloseable, and for changing moveresize mode. svn path=/trunk/kdebase/kwin/; revision=318994 --- client.cpp | 2 +- geometry.cpp | 18 ++++++++++-------- options.cpp | 14 ++++++++++++-- options.h | 3 +++ rules.cpp | 16 ++++++++++++++++ rules.h | 7 +++++++ 6 files changed, 49 insertions(+), 11 deletions(-) diff --git a/client.cpp b/client.cpp index 2da1973903..480dda840d 100644 --- a/client.cpp +++ b/client.cpp @@ -915,7 +915,7 @@ void Client::sendClientMessage(Window w, Atom a, Atom protocol, long data1, long */ bool Client::isCloseable() const { - return motif_may_close && ( !isSpecialWindow() || isOverride()); // TODO is NET::Override special? + return rules()->checkCloseable( motif_may_close && ( !isSpecialWindow() || isOverride())); // TODO is NET::Override special? } /*! diff --git a/geometry.cpp b/geometry.cpp index 4e11b370e2..de77a6d9e4 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -1921,8 +1921,8 @@ void Client::positionGeometryTip() { if( !geometryTip ) { // save under is not necessary with opaque, and seem to make things slower - bool save_under = ( isMove() && options->moveMode != Options::Opaque ) - || ( isResize() && options->resizeMode != Options::Opaque ); + bool save_under = ( isMove() && rules()->checkMoveResizeMode( options->moveMode ) != Options::Opaque ) + || ( isResize() && rules()->checkMoveResizeMode( options->resizeMode ) != Options::Opaque ); geometryTip = new GeometryTip( &xSizeHint, save_under ); } QRect wgeom( moveResizeGeom ); // position of the frame, size of the window itself @@ -1983,8 +1983,8 @@ bool Client::startMoveResize() workspace()->setClientIsMoving(this); initialMoveResizeGeom = moveResizeGeom = geometry(); checkUnrestrictedMoveResize(); - if ( ( isMove() && options->moveMode != Options::Opaque ) - || ( isResize() && options->resizeMode != Options::Opaque ) ) + if ( ( isMove() && rules()->checkMoveResizeMode( options->moveMode ) != Options::Opaque ) + || ( isResize() && rules()->checkMoveResizeMode( options->resizeMode ) != Options::Opaque ) ) { grabXServer(); kapp->sendPostedEvents(); @@ -2020,8 +2020,8 @@ void Client::leaveMoveResize() delete geometryTip; geometryTip = NULL; } - if ( ( isMove() && options->moveMode != Options::Opaque ) - || ( isResize() && options->resizeMode != Options::Opaque ) ) + if ( ( isMove() && rules()->checkMoveResizeMode( options->moveMode ) != Options::Opaque ) + || ( isResize() && rules()->checkMoveResizeMode( options->resizeMode ) != Options::Opaque ) ) ungrabXServer(); XUngrabKeyboard( qt_xdisplay(), qt_x_time ); XUngrabPointer( qt_xdisplay(), qt_x_time ); @@ -2256,12 +2256,14 @@ void Client::handleMoveResize( int x, int y, int x_root, int y_root ) if( update ) { - if(( isResize() ? options->resizeMode : options->moveMode ) == Options::Opaque ) + if( rules()->checkMoveResizeMode + ( isResize() ? options->resizeMode : options->moveMode ) == Options::Opaque ) { setGeometry( moveResizeGeom ); positionGeometryTip(); } - else if(( isResize() ? options->resizeMode : options->moveMode ) == Options::Transparent ) + else if( rules()->checkMoveResizeMode + ( isResize() ? options->resizeMode : options->moveMode ) == Options::Transparent ) { clearbound(); // it's necessary to move the geometry tip when there's no outline positionGeometryTip(); // shown, otherwise it would cause repaint problems in case diff --git a/options.cpp b/options.cpp index 12c483166d..47ede1561f 100644 --- a/options.cpp +++ b/options.cpp @@ -45,8 +45,8 @@ unsigned long Options::updateSettings() changed |= d->updateKWinSettings( config ); // read decoration settings config->setGroup( "Windows" ); - moveMode = config->readEntry("MoveMode", "Opaque" ) == "Opaque"?Opaque:Transparent; - resizeMode = config->readEntry("ResizeMode", "Opaque" ) == "Opaque"?Opaque:Transparent; + moveMode = stringToMoveResizeMode( config->readEntry("MoveMode", "Opaque" )); + resizeMode = stringToMoveResizeMode( config->readEntry("ResizeMode", "Opaque" )); show_geometry_tip = config->readBoolEntry("GeometryTip", false); QString val; @@ -250,4 +250,14 @@ bool Options::checkIgnoreFocusStealing( const Client* c ) return ignoreFocusStealingClasses.contains(QString::fromLatin1(c->resourceClass())); } +Options::MoveResizeMode Options::stringToMoveResizeMode( const QString& s ) + { + return s == "Opaque" ? Opaque : Transparent; + } + +const char* Options::moveResizeModeToString( MoveResizeMode mode ) + { + return mode == Opaque ? "Opaque" : "Transparent"; + } + } // namespace diff --git a/options.h b/options.h index abb135d439..0d06f6091e 100644 --- a/options.h +++ b/options.h @@ -141,6 +141,9 @@ class Options : public KDecorationOptions MoveResizeMode resizeMode; MoveResizeMode moveMode; + + static MoveResizeMode stringToMoveResizeMode( const QString& s ); + static const char* moveResizeModeToString( MoveResizeMode mode ); Placement::Policy placement; diff --git a/rules.cpp b/rules.cpp index 388a817dc3..c995000926 100644 --- a/rules.cpp +++ b/rules.cpp @@ -48,6 +48,8 @@ WindowRules::WindowRules() , noborderrule( DontCareRule ) , fspleveladjustrule( DontCareRule ) , acceptfocusrule( DontCareRule ) + , moveresizemoderule( DontCareRule ) + , closeablerule( DontCareRule ) { } @@ -103,6 +105,8 @@ WindowRules::WindowRules( KConfig& cfg ) READ_SET_RULE( noborder, Bool, ); READ_FORCE_RULE( fspleveladjust, Num, ); READ_FORCE_RULE( acceptfocus, Bool, ); + READ_FORCE_RULE( moveresizemode, , Options::stringToMoveResizeMode ); + READ_FORCE_RULE( closeable, Bool, ); kdDebug() << "READ RULE:" << wmclass << endl; } @@ -172,6 +176,8 @@ void WindowRules::write( KConfig& cfg ) const WRITE_SET_RULE( noborder, ); WRITE_SET_RULE( fspleveladjust, ); WRITE_SET_RULE( acceptfocus, ); + WRITE_SET_RULE( moveresizemode, Options::moveResizeModeToString ); + WRITE_SET_RULE( closeable, ); } #undef WRITE_MATCH_STRING @@ -388,6 +394,16 @@ bool WindowRules::checkAcceptFocus( bool focus ) const return checkForceRule( acceptfocusrule ) ? this->acceptfocus : focus; } +Options::MoveResizeMode WindowRules::checkMoveResizeMode( Options::MoveResizeMode mode ) const + { + return checkForceRule( moveresizemoderule ) ? this->moveresizemode : mode; + } + +bool WindowRules::checkCloseable( bool closeable ) const + { + return checkForceRule( closeablerule ) ? this->closeable : closeable; + } + // Client void Client::setupWindowRules() diff --git a/rules.h b/rules.h index 1744e5af00..8194a3c063 100644 --- a/rules.h +++ b/rules.h @@ -18,6 +18,7 @@ License. See the file "COPYING" for the exact licensing terms. #include "placement.h" #include "lib/kdecoration.h" #include "client.h" +#include "options.h" class KConfig; @@ -64,6 +65,8 @@ class WindowRules bool checkNoBorder( bool noborder, bool init = false ) const; int checkFSP( int fsp ) const; bool checkAcceptFocus( bool focus ) const; + Options::MoveResizeMode checkMoveResizeMode( Options::MoveResizeMode mode ) const; + bool checkCloseable( bool closeable ) const; private: static SettingRule readRule( KConfig&, const QString& key ); static SettingRule readForceRule( KConfig&, const QString& key ); @@ -120,6 +123,10 @@ class WindowRules SettingRule fspleveladjustrule; bool acceptfocus; SettingRule acceptfocusrule; + Options::MoveResizeMode moveresizemode; + SettingRule moveresizemoderule; + bool closeable; + SettingRule closeablerule; }; inline