Workaround for xterm not coping well with being maximized to a geometry

that's not exact multiple of its resize increments. Selecting obeying
strict geometry in window-specific settings makes KWin avoid this.
Maximization then doesn't work very well indeed, but one cannot please
everybody, and the bug is in xterm after all.
BUG: 94183

svn path=/trunk/kdebase/kwin/; revision=379401
This commit is contained in:
Luboš Luňák 2005-01-17 13:35:48 +00:00
parent 3e5b28f2e0
commit ded2f457b8
7 changed files with 129 additions and 54 deletions

View file

@ -348,7 +348,7 @@ class Client : public QObject, public KDecorationDefines
bool isNormalState() const;
bool isManaged() const; // returns false if this client is not yet managed
void updateAllowedActions( bool force = false );
QSize sizeForClientSize( const QSize&, Sizemode mode = SizemodeAny ) const;
QSize sizeForClientSize( const QSize&, Sizemode mode = SizemodeAny, bool noframe = false ) const;
void changeMaximize( bool horizontal, bool vertical, bool adjust );
void checkMaximizeGeometry();
bool checkFullScreenHack( const QRect& geom ) const;

View file

@ -1003,7 +1003,7 @@ QSize Client::adjustedSize( const QSize& frame, Sizemode mode ) const
QSize wsize( frame.width() - ( border_left + border_right ),
frame.height() - ( border_top + border_bottom ));
return sizeForClientSize( wsize, mode );
return sizeForClientSize( wsize, mode, false );
}
/*!
@ -1014,7 +1014,7 @@ QSize Client::adjustedSize( const QSize& frame, Sizemode mode ) const
maximum and incremental size changes).
*/
QSize Client::sizeForClientSize( const QSize& wsize, Sizemode mode ) const
QSize Client::sizeForClientSize( const QSize& wsize, Sizemode mode, bool noframe ) const
{
int w = wsize.width();
int h = wsize.height();
@ -1164,17 +1164,23 @@ QSize Client::sizeForClientSize( const QSize& wsize, Sizemode mode ) const
w += xSizeHint.base_width;
h += xSizeHint.base_height;
}
// disobey increments and aspect when maximized
if( maximizeMode() & MaximizeHorizontal )
w = w1;
if( maximizeMode() & MaximizeVertical )
h = h1;
if( !rules()->checkStrictGeometry( false ))
{
// disobey increments and aspect when maximized
if( maximizeMode() & MaximizeHorizontal )
w = w1;
if( maximizeMode() & MaximizeVertical )
h = h1;
}
w += border_left + border_right;
h += border_top + border_bottom;
if( !noframe )
{
w += border_left + border_right;
h += border_top + border_bottom;
}
QSize ret = rules()->checkSize( QSize( w, h ));
if ( mode == SizemodeShaded && wsize.height() == 0 )
ret.setHeight( border_top + border_bottom );
ret.setHeight( noframe ? 0 : border_top + border_bottom );
return ret;
}
@ -1919,14 +1925,23 @@ bool Client::isFullScreenable( bool fullscreen_hack ) const
return false;
if( fullscreen_hack )
return isNormalWindow() || isOverride();
else // don't check size constrains - some apps request fullscreen despite requesting fixed size
return !isSpecialWindow(); // also better disallow only weird types to go fullscreen
if( rules()->checkStrictGeometry( false ))
{
// the app wouldn't fit exactly fullscreen geometry due its strict geometry requirements
QRect fsarea = workspace()->clientArea( FullScreenArea, this );
if( sizeForClientSize( fsarea.size(), SizemodeAny, true ) != fsarea.size())
return false;
}
// don't check size constrains - some apps request fullscreen despite requesting fixed size
return !isSpecialWindow(); // also better disallow only weird types to go fullscreen
}
bool Client::userCanSetFullScreen() const
{
if( fullscreen_mode == FullScreenHack )
return false;
if( !isFullScreenable( false ))
return false;
// isMaximizable() returns false if fullscreen
TemporaryAssign< FullScreenMode > tmp( fullscreen_mode, FullScreenNone );
return isNormalWindow() && isMaximizable();

View file

@ -96,6 +96,7 @@ RulesWidget::RulesWidget( QWidget* parent, const char* name )
SETUP( ignoreposition, force );
SETUP( minsize, force );
SETUP( maxsize, force );
SETUP( strictgeometry, force );
KWinModule module;
int i;
for( i = 1;
@ -141,6 +142,7 @@ UPDATE_ENABLE_SLOT( type )
UPDATE_ENABLE_SLOT( ignoreposition )
UPDATE_ENABLE_SLOT( minsize )
UPDATE_ENABLE_SLOT( maxsize )
UPDATE_ENABLE_SLOT( strictgeometry )
#undef UPDATE_ENABLE_SLOT
@ -395,6 +397,7 @@ void RulesWidget::setRules( Rules* rules )
CHECKBOX_FORCE_RULE( ignoreposition, );
LINEEDIT_FORCE_RULE( minsize, sizeToStr );
LINEEDIT_FORCE_RULE( maxsize, sizeToStr );
CHECKBOX_FORCE_RULE( strictgeometry, );
}
#undef GENERIC_RULE
@ -482,6 +485,7 @@ Rules* RulesWidget::rules() const
CHECKBOX_FORCE_RULE( ignoreposition, );
LINEEDIT_FORCE_RULE( minsize, strToSize );
LINEEDIT_FORCE_RULE( maxsize, strToSize );
CHECKBOX_FORCE_RULE( strictgeometry, );
return rules;
}
@ -596,6 +600,7 @@ void RulesWidget::prefillUnusedValues( const KWin::WindowInfo& info )
//CHECKBOX_PREFILL( ignoreposition, );
LINEEDIT_PREFILL( minsize, sizeToStr, info.frameGeometry().size() );
LINEEDIT_PREFILL( maxsize, sizeToStr, info.frameGeometry().size() );
//CHECKBOX_PREFILL( strictgeometry, );
}
#undef GENERIC_PREFILL

View file

@ -78,6 +78,7 @@ class RulesWidget
void updateEnableignoreposition();
void updateEnableminsize();
void updateEnablemaxsize();
void updateEnablestrictgeometry();
// internal
void detected( bool );
private:

View file

@ -1913,43 +1913,6 @@
<string>0123456789-+,xX:</string>
</property>
</widget>
<widget class="QCheckBox" row="3" column="3">
<property name="name">
<cstring>ignoreposition</cstring>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string></string>
</property>
</widget>
<widget class="QCheckBox" row="3" column="0">
<property name="name">
<cstring>enable_ignoreposition</cstring>
</property>
<property name="text">
<string>Ignore requested &amp;position</string>
</property>
</widget>
<widget class="KComboBox" row="3" column="1">
<item>
<property name="text">
<string>Do Not Affect</string>
</property>
</item>
<item>
<property name="text">
<string>Force</string>
</property>
</item>
<property name="name">
<cstring>rule_ignoreposition</cstring>
</property>
<property name="enabled">
<bool>false</bool>
</property>
</widget>
<widget class="QCheckBox" row="4" column="0">
<property name="name">
<cstring>enable_minsize</cstring>
@ -2013,7 +1976,33 @@
<bool>false</bool>
</property>
</widget>
<spacer row="6" column="2">
<widget class="QCheckBox" row="3" column="0">
<property name="name">
<cstring>enable_ignoreposition</cstring>
</property>
<property name="text">
<string>Ignore requested &amp;position</string>
</property>
</widget>
<widget class="KComboBox" row="3" column="1">
<item>
<property name="text">
<string>Do Not Affect</string>
</property>
</item>
<item>
<property name="text">
<string>Force</string>
</property>
</item>
<property name="name">
<cstring>rule_ignoreposition</cstring>
</property>
<property name="enabled">
<bool>false</bool>
</property>
</widget>
<spacer row="7" column="2">
<property name="name">
<cstring>spacer35</cstring>
</property>
@ -2026,10 +2015,61 @@
<property name="sizeHint">
<size>
<width>20</width>
<height>90</height>
<height>190</height>
</size>
</property>
</spacer>
<widget class="QCheckBox" row="3" column="3">
<property name="name">
<cstring>ignoreposition</cstring>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string></string>
</property>
</widget>
<widget class="QCheckBox" row="6" column="0">
<property name="name">
<cstring>enable_strictgeometry</cstring>
</property>
<property name="text">
<string>Strictly obey geometry</string>
</property>
<property name="accel">
<string></string>
</property>
</widget>
<widget class="KComboBox" row="6" column="1">
<item>
<property name="text">
<string>Do Not Affect</string>
</property>
</item>
<item>
<property name="text">
<string>Force</string>
</property>
</item>
<property name="name">
<cstring>rule_strictgeometry</cstring>
</property>
<property name="enabled">
<bool>false</bool>
</property>
</widget>
<widget class="QCheckBox" row="6" column="3">
<property name="name">
<cstring>strictgeometry</cstring>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string></string>
</property>
</widget>
</grid>
</widget>
</widget>
@ -2222,8 +2262,9 @@
<includehint>kcombobox.h</includehint>
<includehint>krestrictedline.h</includehint>
<includehint>kcombobox.h</includehint>
<includehint>kcombobox.h</includehint>
<includehint>krestrictedline.h</includehint>
<includehint>kcombobox.h</includehint>
<includehint>kcombobox.h</includehint>
<includehint>kcombobox.h</includehint>
</includehints>
</UI>

View file

@ -58,6 +58,7 @@ Rules::Rules()
, acceptfocusrule( UnusedForceRule )
, moveresizemoderule( UnusedForceRule )
, closeablerule( UnusedForceRule )
, strictgeometry( UnusedForceRule )
{
}
@ -157,6 +158,7 @@ void Rules::readFromCfg( KConfig& cfg )
READ_FORCE_RULE( acceptfocus, Bool, );
READ_FORCE_RULE( moveresizemode, , Options::stringToMoveResizeMode );
READ_FORCE_RULE( closeable, Bool, );
READ_FORCE_RULE( strictgeometry, Bool, );
}
#undef READ_MATCH_STRING
@ -243,6 +245,7 @@ void Rules::write( KConfig& cfg ) const
WRITE_FORCE_RULE( acceptfocus, );
WRITE_FORCE_RULE( moveresizemode, Options::moveResizeModeToString );
WRITE_FORCE_RULE( closeable, );
WRITE_FORCE_RULE( strictgeometry, );
}
#undef WRITE_MATCH_STRING
@ -276,7 +279,8 @@ bool Rules::isEmpty() const
&& fsplevelrule == UnusedForceRule
&& acceptfocusrule == UnusedForceRule
&& moveresizemoderule == UnusedForceRule
&& closeablerule == UnusedForceRule );
&& closeablerule == UnusedForceRule
&& strictgeometryrule == UnusedForceRule );
}
Rules::SetRule Rules::readSetRule( KConfig& cfg, const QString& key )
@ -593,6 +597,7 @@ 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 )
APPLY_FORCE_RULE( strictgeometry, StrictGeometry, bool )
#undef APPLY_RULE
#undef APPLY_FORCE_RULE
@ -722,6 +727,7 @@ CHECK_FORCE_RULE( FSP, int )
CHECK_FORCE_RULE( AcceptFocus, bool )
CHECK_FORCE_RULE( MoveResizeMode, Options::MoveResizeMode )
CHECK_FORCE_RULE( Closeable, bool )
CHECK_FORCE_RULE( StrictGeometry, bool )
#undef CHECK_RULE
#undef CHECK_FORCE_RULE
@ -773,6 +779,9 @@ void Client::setupWindowRules( bool ignore_temporary )
workspace()->activateNextClient( this );
// MoveResizeMode
// Closeable
QSize s = adjustedSize( size());
if( s != size())
resizeWithChecks( s );
}
}

View file

@ -65,6 +65,7 @@ class WindowRules
bool checkAcceptFocus( bool focus ) const;
Options::MoveResizeMode checkMoveResizeMode( Options::MoveResizeMode mode ) const;
bool checkCloseable( bool closeable ) const;
bool checkStrictGeometry( bool strict ) const;
private:
MaximizeMode checkMaximizeVert( MaximizeMode mode, bool init ) const;
MaximizeMode checkMaximizeHoriz( MaximizeMode mode, bool init ) const;
@ -112,6 +113,7 @@ class Rules
bool applyAcceptFocus( bool& focus ) const;
bool applyMoveResizeMode( Options::MoveResizeMode& mode ) const;
bool applyCloseable( bool& closeable ) const;
bool applyStrictGeometry( bool& strict ) const;
private:
#endif
bool matchType( NET::WindowType match_type ) const;
@ -219,6 +221,8 @@ class Rules
ForceRule moveresizemoderule;
bool closeable;
ForceRule closeablerule;
bool strictgeometry;
ForceRule strictgeometryrule;
friend kdbgstream& operator<<( kdbgstream& stream, const Rules* );
};