KWin rules - override minsize/maxsize.
svn path=/trunk/kdebase/kwin/; revision=316413
This commit is contained in:
parent
2f7d3203aa
commit
a114e9acc3
5 changed files with 48 additions and 14 deletions
6
client.h
6
client.h
|
@ -72,6 +72,7 @@ class Client : public QObject, public KDecorationDefines
|
||||||
QRect geometry() const;
|
QRect geometry() const;
|
||||||
QSize size() const;
|
QSize size() const;
|
||||||
QSize minSize() const;
|
QSize minSize() const;
|
||||||
|
QSize maxSize() const;
|
||||||
QPoint pos() const;
|
QPoint pos() const;
|
||||||
QRect rect() const;
|
QRect rect() const;
|
||||||
int x() const;
|
int x() const;
|
||||||
|
@ -753,11 +754,6 @@ inline QSize Client::size() const
|
||||||
return frame_geometry.size();
|
return frame_geometry.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline QSize Client::minSize() const
|
|
||||||
{
|
|
||||||
return QSize( xSizeHint.min_width, xSizeHint.min_height );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline QPoint Client::pos() const
|
inline QPoint Client::pos() const
|
||||||
{
|
{
|
||||||
return frame_geometry.topLeft();
|
return frame_geometry.topLeft();
|
||||||
|
|
25
geometry.cpp
25
geometry.cpp
|
@ -27,6 +27,7 @@ License. See the file "COPYING" for the exact licensing terms.
|
||||||
#include "placement.h"
|
#include "placement.h"
|
||||||
#include "notifications.h"
|
#include "notifications.h"
|
||||||
#include "geometrytip.h"
|
#include "geometrytip.h"
|
||||||
|
#include "rules.h"
|
||||||
|
|
||||||
extern Time qt_x_time;
|
extern Time qt_x_time;
|
||||||
|
|
||||||
|
@ -818,8 +819,8 @@ QSize Client::sizeForClientSize( const QSize& wsize, Sizemode mode ) const
|
||||||
|
|
||||||
// basesize, minsize, maxsize, paspect and resizeinc have all values defined,
|
// basesize, minsize, maxsize, paspect and resizeinc have all values defined,
|
||||||
// even if they're not set in flags - see getWmNormalHints()
|
// even if they're not set in flags - see getWmNormalHints()
|
||||||
QSize min_size( xSizeHint.min_width, xSizeHint.min_height );
|
QSize min_size = minSize();
|
||||||
QSize max_size( xSizeHint.max_width, xSizeHint.max_height );
|
QSize max_size = maxSize();
|
||||||
if( decoration != NULL )
|
if( decoration != NULL )
|
||||||
{
|
{
|
||||||
QSize decominsize = decoration->minimumSize();
|
QSize decominsize = decoration->minimumSize();
|
||||||
|
@ -1024,6 +1025,16 @@ void Client::getWmNormalHints()
|
||||||
updateAllowedActions(); // affects isResizeable()
|
updateAllowedActions(); // affects isResizeable()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QSize Client::minSize() const
|
||||||
|
{
|
||||||
|
return rules()->checkMinSize( QSize( xSizeHint.min_width, xSizeHint.min_height ));
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize Client::maxSize() const
|
||||||
|
{
|
||||||
|
return rules()->checkMaxSize( QSize( xSizeHint.max_width, xSizeHint.max_height ));
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Auxiliary function to inform the client about the current window
|
Auxiliary function to inform the client about the current window
|
||||||
configuration.
|
configuration.
|
||||||
|
@ -1287,10 +1298,9 @@ bool Client::isResizable() const
|
||||||
if ( !isMovable() || !motif_may_resize || isSplash())
|
if ( !isMovable() || !motif_may_resize || isSplash())
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if ( ( xSizeHint.flags & PMaxSize) == 0 || (xSizeHint.flags & PMinSize ) == 0 )
|
QSize min = minSize();
|
||||||
return TRUE;
|
QSize max = maxSize();
|
||||||
return ( xSizeHint.min_width < xSizeHint.max_width ) ||
|
return min.width() < max.width() || min.height() < max.height();
|
||||||
( xSizeHint.min_height < xSizeHint.max_height );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1302,7 +1312,8 @@ bool Client::isMaximizable() const
|
||||||
return TRUE;
|
return TRUE;
|
||||||
if( !isResizable() || isToolbar()) // SELI isToolbar() ?
|
if( !isResizable() || isToolbar()) // SELI isToolbar() ?
|
||||||
return false;
|
return false;
|
||||||
if( xSizeHint.max_height < 32767 || xSizeHint.max_width < 32767 ) // sizes are 16bit with X
|
QSize max = maxSize();
|
||||||
|
if( max.width() < 32767 || max.height() < 32767 ) // sizes are 16bit with X
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -252,9 +252,11 @@ bool Client::manage( Window w, bool isMapped )
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xSizeHint.flags & PMaxSize)
|
if (xSizeHint.flags & PMaxSize)
|
||||||
geom.setSize( geom.size().boundedTo( QSize(xSizeHint.max_width, xSizeHint.max_height ) ) );
|
geom.setSize( geom.size().boundedTo(
|
||||||
|
rules()->checkMaxSize( QSize(xSizeHint.max_width, xSizeHint.max_height ) ) ) );
|
||||||
if (xSizeHint.flags & PMinSize)
|
if (xSizeHint.flags & PMinSize)
|
||||||
geom.setSize( geom.size().expandedTo( QSize(xSizeHint.min_width, xSizeHint.min_height ) ) );
|
geom.setSize( geom.size().expandedTo(
|
||||||
|
rules()->checkMinSize( QSize(xSizeHint.min_width, xSizeHint.min_height ) ) ) );
|
||||||
|
|
||||||
if( isMovable())
|
if( isMovable())
|
||||||
{
|
{
|
||||||
|
|
18
rules.cpp
18
rules.cpp
|
@ -30,6 +30,8 @@ WindowRules::WindowRules()
|
||||||
, clientmachineregexp( false )
|
, clientmachineregexp( false )
|
||||||
, types( NET::AllTypesMask )
|
, types( NET::AllTypesMask )
|
||||||
, placementrule( DontCareRule )
|
, placementrule( DontCareRule )
|
||||||
|
, minsizerule( DontCareRule )
|
||||||
|
, maxsizerule( DontCareRule )
|
||||||
, desktoprule( DontCareRule )
|
, desktoprule( DontCareRule )
|
||||||
, typerule( DontCareRule )
|
, typerule( DontCareRule )
|
||||||
, aboverule( DontCareRule )
|
, aboverule( DontCareRule )
|
||||||
|
@ -53,6 +55,10 @@ WindowRules::WindowRules( KConfig& cfg )
|
||||||
types = cfg.readUnsignedLongNumEntry( "types", NET::AllTypesMask );
|
types = cfg.readUnsignedLongNumEntry( "types", NET::AllTypesMask );
|
||||||
placement = Placement::policyFromString( cfg.readEntry( "placement" ), false );
|
placement = Placement::policyFromString( cfg.readEntry( "placement" ), false );
|
||||||
placementrule = readRule( cfg, "placementrule" );
|
placementrule = readRule( cfg, "placementrule" );
|
||||||
|
minsize = cfg.readSizeEntry( "minsize" );
|
||||||
|
minsizerule = readRule( cfg, "minsizerule" );
|
||||||
|
maxsize = cfg.readSizeEntry( "maxsize" );
|
||||||
|
maxsizerule = readRule( cfg, "maxsizerule" );
|
||||||
desktop = cfg.readNumEntry( "desktop" );
|
desktop = cfg.readNumEntry( "desktop" );
|
||||||
desktoprule = readRule( cfg, "desktoprule" );
|
desktoprule = readRule( cfg, "desktoprule" );
|
||||||
type = readType( cfg, "type" );
|
type = readType( cfg, "type" );
|
||||||
|
@ -107,6 +113,8 @@ void WindowRules::write( KConfig& cfg ) const
|
||||||
WRITE_MATCH_STRING( clientmachine, (const char*) );
|
WRITE_MATCH_STRING( clientmachine, (const char*) );
|
||||||
WRITE_WITH_DEFAULT( types, NET::AllTypesMask );
|
WRITE_WITH_DEFAULT( types, NET::AllTypesMask );
|
||||||
WRITE_SET_RULE( placement, Placement::policyToString );
|
WRITE_SET_RULE( placement, Placement::policyToString );
|
||||||
|
WRITE_SET_RULE( minsize, );
|
||||||
|
WRITE_SET_RULE( maxsize, );
|
||||||
WRITE_SET_RULE( desktop, );
|
WRITE_SET_RULE( desktop, );
|
||||||
WRITE_SET_RULE( type, );
|
WRITE_SET_RULE( type, );
|
||||||
WRITE_SET_RULE( above, );
|
WRITE_SET_RULE( above, );
|
||||||
|
@ -203,6 +211,16 @@ Placement::Policy WindowRules::checkPlacement( Placement::Policy placement ) con
|
||||||
return checkForceRule( placementrule ) ? this->placement : placement;
|
return checkForceRule( placementrule ) ? this->placement : placement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QSize WindowRules::checkMinSize( const QSize& s ) const
|
||||||
|
{
|
||||||
|
return checkForceRule( minsizerule ) ? this->minsize : s;
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize WindowRules::checkMaxSize( const QSize& s ) const
|
||||||
|
{
|
||||||
|
return checkForceRule( maxsizerule ) ? this->maxsize : s;
|
||||||
|
}
|
||||||
|
|
||||||
int WindowRules::checkDesktop( int req_desktop, bool init ) const
|
int WindowRules::checkDesktop( int req_desktop, bool init ) const
|
||||||
{
|
{
|
||||||
// TODO chaining?
|
// TODO chaining?
|
||||||
|
|
7
rules.h
7
rules.h
|
@ -13,6 +13,7 @@ License. See the file "COPYING" for the exact licensing terms.
|
||||||
|
|
||||||
#include <qstring.h>
|
#include <qstring.h>
|
||||||
#include <netwm_def.h>
|
#include <netwm_def.h>
|
||||||
|
#include <qrect.h>
|
||||||
|
|
||||||
#include "placement.h"
|
#include "placement.h"
|
||||||
|
|
||||||
|
@ -41,6 +42,8 @@ class WindowRules
|
||||||
void update( Client* );
|
void update( Client* );
|
||||||
bool match( const Client* c ) const;
|
bool match( const Client* c ) const;
|
||||||
Placement::Policy checkPlacement( Placement::Policy placement ) const;
|
Placement::Policy checkPlacement( Placement::Policy placement ) const;
|
||||||
|
QSize checkMinSize( const QSize& s ) const;
|
||||||
|
QSize checkMaxSize( const QSize& s ) const;
|
||||||
int checkDesktop( int desktop, bool init = false ) const;
|
int checkDesktop( int desktop, bool init = false ) const;
|
||||||
NET::WindowType checkType( NET::WindowType type ) const;
|
NET::WindowType checkType( NET::WindowType type ) const;
|
||||||
bool checkKeepAbove( bool above, bool init = false ) const;
|
bool checkKeepAbove( bool above, bool init = false ) const;
|
||||||
|
@ -65,6 +68,10 @@ class WindowRules
|
||||||
unsigned long types; // types for matching
|
unsigned long types; // types for matching
|
||||||
Placement::Policy placement;
|
Placement::Policy placement;
|
||||||
SettingRule placementrule;
|
SettingRule placementrule;
|
||||||
|
QSize minsize;
|
||||||
|
SettingRule minsizerule;
|
||||||
|
QSize maxsize;
|
||||||
|
SettingRule maxsizerule;
|
||||||
int desktop;
|
int desktop;
|
||||||
SettingRule desktoprule;
|
SettingRule desktoprule;
|
||||||
NET::WindowType type; // type for setting
|
NET::WindowType type; // type for setting
|
||||||
|
|
Loading…
Reference in a new issue