From bad93649e3f93cab21a49e7a6ffab90f3c037e1c Mon Sep 17 00:00:00 2001 From: Matthias Ettrich Date: Thu, 25 Nov 1999 12:53:17 +0000 Subject: [PATCH] fixed min/max handling, handle palette changes properly svn path=/trunk/kdebase/kwin/; revision=35018 --- client.cpp | 34 ++++++++++++++++++++++------------ main.cpp | 2 +- options.cpp | 5 ++++- options.h | 15 ++++++++++----- stdclient.cpp | 8 ++++---- tabbox.cpp | 2 +- 6 files changed, 42 insertions(+), 24 deletions(-) diff --git a/client.cpp b/client.cpp index f562e601c1..2b4fb3eb80 100644 --- a/client.cpp +++ b/client.cpp @@ -97,7 +97,7 @@ WindowWrapper::WindowWrapper( WId w, Client *parent, const char* name) setMouseTracking( TRUE ); setBackgroundColor( colorGroup().background() ); - + // we don't want the window to be destroyed when we are destroyed XAddToSaveSet(qt_xdisplay(), win ); @@ -341,6 +341,7 @@ void Client::manage( bool isMapped ) // geom.setSize( geom.size().boundedTo( QSize(xSizeHint.max_width, xSizeHint.max_height ) ) ); } + windowWrapper()->resize( geom.size() ); // the clever activate() trick is necessary layout()->activate(); // resize( geom.width() + width() - windowWrapper()->width(), @@ -351,7 +352,7 @@ void Client::manage( bool isMapped ) move( geom.x(), geom.y() ); gravitate( FALSE ); - if ( !placementDone ) { + if ( !placementDone && !transient_for ) { workspace()->doPlacement( this ); placementDone = TRUE; } @@ -707,19 +708,28 @@ QSize Client::sizeForWindowSize( const QSize& wsize, bool ignore_height) const h = bh + sy * xSizeHint.height_inc; } } + + if (xSizeHint.flags & PMinSize) { + w = QMAX( xSizeHint.min_width, w ); + } + if (xSizeHint.flags & PMaxSize) { + w = QMIN( xSizeHint.max_width, w ); + } int ww = wwrap->width(); int wh = 0; if ( !wwrap->testWState( WState_ForceHide ) ) wh = wwrap->height(); - + if ( ignore_height && wsize.height() == 0 ) h = 0; - return QSize( QMIN( QMAX( width() - ww + w, minimumWidth() ), - maximumWidth() ), - ignore_height? height()-wh+h : (QMIN( QMAX( height() - wh + h, minimumHeight() ), - maximumHeight() ) ) ); + return QSize( width() - ww + w, height()-wh+h ); + +// return QSize( QMIN( QMAX( width() - ww + w, minimumWidth() ), +// maximumWidth() ), +// ignore_height? height()-wh+h : (QMIN( QMAX( height() - wh + h, minimumHeight() ), +// maximumHeight() ) ) ); } @@ -1061,7 +1071,7 @@ int Client::minimumHeight() const /*! Returns the maximum size. This function differs from QWidget::maximumSize() and is to be preferred - */ + */ QSize Client::maximumSize() const { return QSize( maximumWidth(), maximumHeight() ); @@ -1121,16 +1131,16 @@ void Client::maximize( MaximizeMode m) { if ( isShade() ) setShade( FALSE ); - + if ( geom_restore.isNull() ) { geom_restore = geometry(); switch ( m ) { case MaximizeVertical: - setGeometry( QRect( QPoint( x(), workspace()->geometry().top() ), + setGeometry( QRect( QPoint( x(), workspace()->geometry().top() ), adjustedSize( QSize( width(), workspace()->geometry().height()) ) ) ); break; case MaximizeHorizontal: - setGeometry( QRect( QPoint( workspace()->geometry().left(), y() ), + setGeometry( QRect( QPoint( workspace()->geometry().left(), y() ), adjustedSize( QSize( workspace()->geometry().width(), height() ) ) ) ); break; default: @@ -1481,7 +1491,7 @@ void Client::setMask( const QRegion & reg) -NoBorderClient::NoBorderClient( Workspace *ws, WId w, QWidget *parent=0, const char *name=0 ) +NoBorderClient::NoBorderClient( Workspace *ws, WId w, QWidget *parent, const char *name ) : Client( ws, w, parent, name ) { QHBoxLayout* h = new QHBoxLayout( this ); diff --git a/main.cpp b/main.cpp index e6966cfd15..8608b61165 100644 --- a/main.cpp +++ b/main.cpp @@ -80,7 +80,7 @@ Application::~Application() for ( WorkspaceList::Iterator it = workspaces.begin(); it != workspaces.end(); ++it) { delete (*it); } - delete options; + delete options; } bool Application::x11EventFilter( XEvent *e ) diff --git a/options.cpp b/options.cpp index 64909f99f2..4d7130f59a 100644 --- a/options.cpp +++ b/options.cpp @@ -1,11 +1,12 @@ #include "options.h" #include #include -#include +#include #include #include Options::Options() + : QObject( 0, 0) { int i; for(i=0; i < KWINCOLORS*2; ++i) @@ -16,6 +17,8 @@ Options::Options() placement = Smart; animate_shade = true; anim_steps = 100; + + connect( kapp, SIGNAL( appearanceChanged() ), this, SLOT(reload() ) ); } Options::~Options(){ diff --git a/options.h b/options.h index cf93419c78..9f9be3c94c 100644 --- a/options.h +++ b/options.h @@ -1,15 +1,21 @@ #ifndef OPTIONS_H #define OPTIONS_H +#include #include #include // increment this when you add a color type (mosfet) #define KWINCOLORS 8 -class Options { +class Options : public QObject { + Q_OBJECT public: + Options(); + ~Options(); + + /*! Different focus policies:
    @@ -36,7 +42,7 @@ public: */ enum FocusPolicy { ClickToFocus, FocusFollowsMouse, FocusUnderMouse, FocusStricklyUnderMouse }; FocusPolicy focusPolicy; - + enum MoveResizeMode { Transparent, Opaque }; /** @@ -84,11 +90,10 @@ public: * Return the number of animation steps (would this be general?) */ const int animSteps() { return anim_steps; }; - // When restarting is implemented this should get called (mosfet). + +public slots: void reload(); - Options(); - ~Options(); protected: QFont activeFont, inactiveFont; QColor colors[KWINCOLORS*2]; diff --git a/stdclient.cpp b/stdclient.cpp index dfcfe64219..1e8d74db85 100644 --- a/stdclient.cpp +++ b/stdclient.cpp @@ -189,7 +189,7 @@ StdClient::StdClient( Workspace *ws, WId w, QWidget *parent, const char *name ) g->setRowStretch( 1, 10 ); g->addWidget( windowWrapper(), 1, 1 ); g->addItem( new QSpacerItem( 0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding ) ); - + g->addColSpacing(0, 2); g->addColSpacing(2, 2); g->addRowSpacing(2, 2); @@ -227,11 +227,11 @@ StdClient::StdClient( Workspace *ws, WId w, QWidget *parent, const char *name ) button[0]->setIconSet(isActive() ? *menu_pix : *dis_menu_pix); else button[0]->setIconSet( miniIcon() ); - + connect( button[0], SIGNAL( pressed() ), this, SLOT( menuButtonPressed() ) ); button[0]->setPopupDelay( 0 ); button[0]->setPopup( workspace()->clientPopup( this ) ); - + button[1]->setIconSet(isSticky() ? isActive() ? *pindown_pix : *dis_pindown_pix : isActive() ? *pinup_pix : *dis_pinup_pix ); connect( button[1], SIGNAL( clicked() ), this, ( SLOT( toggleSticky() ) ) ); @@ -306,7 +306,7 @@ void StdClient::stickyChange( bool s) button[1]->setIconSet( s?*pindown_pix:*pinup_pix ); } -void StdClient::paintEvent( QPaintEvent* e) +void StdClient::paintEvent( QPaintEvent* ) { QPainter p( this ); QRect t = titlebar->geometry(); diff --git a/tabbox.cpp b/tabbox.cpp index 377b163ef1..c602911251 100644 --- a/tabbox.cpp +++ b/tabbox.cpp @@ -5,7 +5,7 @@ const bool options_traverse_all = FALSE; // TODO -TabBox::TabBox( Workspace *ws, const char *name=0 ) +TabBox::TabBox( Workspace *ws, const char *name ) : QWidget( 0, name, WStyle_Customize | WStyle_NoBorder ) { wspace = ws;