KWin rules for making windows noncloseable, and for changing moveresize
mode. svn path=/trunk/kdebase/kwin/; revision=318994
This commit is contained in:
parent
2d336eb6ac
commit
6e34bc5e8a
6 changed files with 49 additions and 11 deletions
|
@ -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?
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
18
geometry.cpp
18
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
|
||||
|
|
14
options.cpp
14
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
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
16
rules.cpp
16
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()
|
||||
|
|
7
rules.h
7
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
|
||||
|
|
Loading…
Reference in a new issue