diff --git a/client.cpp b/client.cpp index 436f4bee8c..07ea81ff61 100644 --- a/client.cpp +++ b/client.cpp @@ -151,6 +151,15 @@ QSizePolicy WindowWrapper::sizePolicy() const } +/** + Gives layout the illusion the wrapper was visible + */ +void WindowWrapper::pseudoShow() +{ + clearWState( WState_ForceHide ); +} + + void WindowWrapper::resizeEvent( QResizeEvent * ) { if ( win ) { @@ -349,18 +358,24 @@ void Client::manage( bool isMapped ) updateShape(); } + // find out the initial state. Several possibilities exist + XWMHints * hints = XGetWMHints(qt_xdisplay(), win ); + int state = NormalState; + if (hints && (hints->flags & StateHint)) + state = hints->initial_state; + if (hints) + XFree(hints); // ### TODO check XGetWMHints() for initial mapping state, icon, etc. pp. // assume window wants to be visible on the current desktop desk = KWM::desktop( win ); //workspace()->currentDesktop(); - setMappingState( NormalState ); - if ( isOnDesktop( workspace()->currentDesktop() ) ) { + setMappingState( state ); + if ( state == NormalState && isOnDesktop( workspace()->currentDesktop() ) ) { show(); + if ( options->focusPolicyIsReasonable() ) + workspace()->requestFocus( this ); } - if ( options->focusPolicyIsReasonable() ) - workspace()->requestFocus( this ); - } @@ -506,7 +521,7 @@ bool Client::unmapNotify( XUnmapEvent& e ) // maybe we will be destroyed soon. Check this first. XEvent ev; - if ( XCheckTypedWindowEvent (qt_xdisplay(), win, + if ( XCheckTypedWindowEvent (qt_xdisplay(), windowWrapper()->winId(), DestroyNotify, &ev) ){ workspace()->destroyClient( this ); return TRUE; @@ -691,14 +706,14 @@ QSize Client::sizeForWindowSize( const QSize& wsize, bool ignore_height) const } int ww = wwrap->width(); - int wh = 0; + int wh = 0;; if ( !wwrap->testWState( WState_ForceHide ) ) wh = wwrap->height(); - + return QSize( QMIN( QMAX( width() - ww + w, minimumWidth() ), maximumWidth() ), - ignore_height? height()-wh : QMIN( QMAX( height() - wh + h, minimumHeight() ), - maximumHeight() ) ); + ignore_height? height()-wh : (QMIN( QMAX( height() - wh + h, minimumHeight() ), + maximumHeight() ) ) ); } @@ -740,6 +755,15 @@ void Client::mouseReleaseEvent( QMouseEvent * e) } } + +/*! + */ +void Client::resizeEvent( QResizeEvent * e) +{ + QWidget::resizeEvent( e ); +} + + /*! Reimplemented to provide move/resize */ @@ -1306,9 +1330,10 @@ void Client::setShade( bool s ) resize (s ); } else { QSize s( sizeForWindowSize( windowWrapper()->size() ) ); + resize ( s ); windowWrapper()->show(); layout()->activate(); - resize ( s ); + repaint(); if ( isActive() ) workspace()->requestFocus( this ); } diff --git a/client.h b/client.h index 6a3a38b33b..d21b42430e 100644 --- a/client.h +++ b/client.h @@ -25,6 +25,8 @@ public: void invalidateWindow(); QSize sizeHint() const; QSizePolicy sizePolicy() const; + + void pseudoShow(); protected: void resizeEvent( QResizeEvent * ); @@ -146,6 +148,7 @@ protected: void mousePressEvent( QMouseEvent * ); void mouseReleaseEvent( QMouseEvent * ); void mouseMoveEvent( QMouseEvent * ); + void resizeEvent( QResizeEvent * ); void enterEvent( QEvent * ); void leaveEvent( QEvent * ); void showEvent( QShowEvent* ); diff --git a/stdclient.cpp b/stdclient.cpp index d004d84e5c..7f8c413861 100644 --- a/stdclient.cpp +++ b/stdclient.cpp @@ -45,7 +45,7 @@ static void create_pixmaps() if ( pixmaps_created ) return; pixmaps_created = true; - + QPainter pact, pdis; QBitmap bitmap; QColor actHigh = options->color(Options::ButtonFg, true).light(150); @@ -54,7 +54,7 @@ static void create_pixmaps() QColor disHigh = options->color(Options::ButtonFg, false).light(150); QColor disMed = options->color(Options::ButtonFg, false); QColor disLow = options->color(Options::ButtonFg, false).dark(120); - + close_pix = new QPixmap(16, 16); dis_close_pix = new QPixmap(16, 16); pact.begin(close_pix); pdis.begin(dis_close_pix); @@ -86,7 +86,7 @@ static void create_pixmaps() pact.end(); pdis.end(); bitmap = QBitmap(16, 16, iconify_mask_bits, true); minimize_pix->setMask(bitmap); dis_minimize_pix->setMask(bitmap); - + maximize_pix = new QPixmap(16, 16); dis_maximize_pix = new QPixmap(16, 16); pact.begin(maximize_pix); pdis.begin(dis_maximize_pix); @@ -155,7 +155,7 @@ static void create_pixmaps() pact.end(); pdis.end(); bitmap = QBitmap(16, 16, pinup_mask_bits, true); pinup_pix->setMask(bitmap); dis_pinup_pix->setMask(bitmap); - + pindown_pix = new QPixmap(16, 16); dis_pindown_pix = new QPixmap(16, 16); pact.begin(pindown_pix); pdis.begin(dis_pindown_pix); @@ -176,7 +176,7 @@ static void create_pixmaps() pact.end(); pdis.end(); bitmap = QBitmap(16, 16, pindown_mask_bits, true); pindown_pix->setMask(bitmap); dis_pindown_pix->setMask(bitmap); - + } @@ -265,7 +265,7 @@ void StdClient::resizeEvent( QResizeEvent* e) t.setTop( 0 ); QRegion r = rr.subtract( QRect( t.x()+1, 0, t.width()-2, 1 ) ); setMask( r ); - + if ( isVisibleToTLW() ) { // manual clearing without the titlebar (we selected WResizeNoErase ) QPainter p( this ); @@ -298,7 +298,7 @@ void StdClient::stickyChange( bool s) button[1]->setIconSet( s?*pindown_pix:*pinup_pix ); } -void StdClient::paintEvent( QPaintEvent* ) +void StdClient::paintEvent( QPaintEvent* e) { QPainter p( this ); QRect t = titlebar->geometry(); diff --git a/workspace.cpp b/workspace.cpp index 9a9ce51e2a..e1379361c5 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -263,9 +263,9 @@ bool Workspace::workspaceEvent( XEvent * e ) return TRUE; return destroyClient( findClient( e->xdestroywindow.window ) ); case MapRequest: - if ( e->xmaprequest.parent == root ) { - c = findClient( e->xmaprequest.window ); - if ( !c ) { + c = findClient( e->xmaprequest.window ); + if ( !c ) { + if ( e->xmaprequest.parent == root ) { if ( addDockwin( e->xmaprequest.window ) ) return TRUE; c = clientFactory( this, e->xmaprequest.window ); @@ -274,11 +274,14 @@ bool Workspace::workspaceEvent( XEvent * e ) XReparentWindow( qt_xdisplay(), c->winId(), root, 0, 0 ); } if ( c != desktop_client ) { + focus_chain.prepend( c ); clients.append( c ); stacking_order.append( c ); } propagateClients(); } + } + if ( c ) { bool result = c->windowEvent( e ); if ( c == desktop_client ) setDesktopClient( c ); @@ -410,6 +413,7 @@ bool Workspace::destroyClient( Client* c) { if ( !c ) return FALSE; + qDebug("Workspace:.destroyClient"); clients.remove( c ); stacking_order.remove( c ); focus_chain.remove( c );