Reset compositing on XRandr changes to react on screen

size or refresh rate changes, patch by Philip Falkner.


svn path=/branches/work/kwin_composite/; revision=610114
This commit is contained in:
Luboš Luňák 2006-12-03 13:29:57 +00:00
parent 6a66250620
commit ab8d845718
3 changed files with 72 additions and 32 deletions

View file

@ -475,6 +475,20 @@ bool Workspace::workspaceEvent( XEvent * e )
addDamage( e->xexpose.x, e->xexpose.y, e->xexpose.width, e->xexpose.height );
break;
default:
if( e->type == Extensions::randrNotifyEvent() && Extensions::randrAvailable() )
{
#ifdef HAVE_XRANDR
XRRUpdateConfiguration( e );
#endif
if( compositing() )
{
// desktopResized() should take care of when the size or
// shape of the desktop has changed, but we also want to
// catch refresh rate changes
finishCompositing();
QTimer::singleShot( 0, this, SLOT( setupCompositing() ) );
}
}
break;
}
return false;

View file

@ -28,6 +28,7 @@ License. See the file "COPYING" for the exact licensing terms.
#include "notifications.h"
#include "geometrytip.h"
#include "rules.h"
#include "effects.h"
#include <QX11Info>
#include <QDesktopWidget>
@ -45,6 +46,11 @@ void Workspace::desktopResized()
{
updateClientArea();
checkElectricBorders( true );
if( compositing() )
{
finishCompositing();
QTimer::singleShot( 0, this, SLOT( setupCompositing() ) );
}
}
/*!
@ -1404,7 +1410,7 @@ void Client::configureRequest( int value_mask, int rx, int ry, int rw, int rh, i
|| ns != size())
{
QRect orig_geometry = geometry();
GeometryUpdatesPostponer blocker( this );
GeometryUpdatesBlocker blocker( this );
move( new_pos );
plainResize( ns );
setGeometry( QRect( calculateGravitation( false, gravity ), size()));
@ -1437,7 +1443,7 @@ void Client::configureRequest( int value_mask, int rx, int ry, int rw, int rh, i
if( ns != size()) // don't restore if some app sets its own size again
{
QRect orig_geometry = geometry();
GeometryUpdatesPostponer blocker( this );
GeometryUpdatesBlocker blocker( this );
int save_gravity = xSizeHint.win_gravity;
xSizeHint.win_gravity = gravity;
resizeWithChecks( ns );
@ -1657,31 +1663,40 @@ void Client::setGeometry( int x, int y, int w, int h, ForceGeometry_t force )
{
client_size = QSize( w - border_left - border_right, h - border_top - border_bottom );
}
if( force == NormalGeometrySet && frame_geometry == QRect( x, y, w, h ))
if( force == NormalGeometrySet && geom == QRect( x, y, w, h ))
return;
frame_geometry = QRect( x, y, w, h );
geom = QRect( x, y, w, h );
updateWorkareaDiffs();
if( postpone_geometry_updates != 0 )
if( block_geometry_updates != 0 )
{
pending_geometry_update = true;
return;
}
resizeDecoration( QSize( w, h ));
XMoveResizeWindow( display(), frameId(), x, y, w, h );
// resizeDecoration( QSize( w, h ));
if( !isShade())
if( geom_before_block.size() != geom.size())
{
QSize cs = clientSize();
XMoveResizeWindow( display(), wrapperId(), clientPos().x(), clientPos().y(),
cs.width(), cs.height());
XMoveResizeWindow( display(), window(), 0, 0, cs.width(), cs.height());
resizeDecoration( QSize( w, h ));
XMoveResizeWindow( display(), frameId(), x, y, w, h );
if( !isShade())
{
QSize cs = clientSize();
XMoveResizeWindow( display(), wrapperId(), clientPos().x(), clientPos().y(),
cs.width(), cs.height());
XMoveResizeWindow( display(), window(), 0, 0, cs.width(), cs.height());
}
if( shape())
updateShape();
}
updateShape();
else
XMoveWindow( display(), frameId(), x, y );
// SELI TODO won't this be too expensive?
updateWorkareaDiffs();
sendSyntheticConfigureNotify();
updateWindowRules();
checkMaximizeGeometry();
if( geom_before_block.size() != geom.size())
addDamageFull(); // damage window only if it actually was a resize
workspace()->addDamage( geom_before_block ); // TODO add damage only if not obscured
geom_before_block = geom;
}
void Client::plainResize( int w, int h, ForceGeometry_t force )
@ -1711,11 +1726,11 @@ void Client::plainResize( int w, int h, ForceGeometry_t force )
kDebug() << "forced size fail:" << QSize( w,h ) << ":" << rules()->checkSize( QSize( w, h )) << endl;
kDebug() << kBacktrace() << endl;
}
if( force == NormalGeometrySet && frame_geometry.size() == QSize( w, h ))
if( force == NormalGeometrySet && geom.size() == QSize( w, h ))
return;
frame_geometry.setSize( QSize( w, h ));
geom.setSize( QSize( w, h ));
updateWorkareaDiffs();
if( postpone_geometry_updates != 0 )
if( block_geometry_updates != 0 )
{
pending_geometry_update = true;
return;
@ -1730,11 +1745,15 @@ void Client::plainResize( int w, int h, ForceGeometry_t force )
cs.width(), cs.height());
XMoveResizeWindow( display(), window(), 0, 0, cs.width(), cs.height());
}
updateShape();
if( shape())
updateShape();
updateWorkareaDiffs();
sendSyntheticConfigureNotify();
updateWindowRules();
checkMaximizeGeometry();
addDamageFull(); // TODO add damage only in added area?
workspace()->addDamage( geom_before_block ); // TODO add damage only if not obscured
geom_before_block = geom;
}
/*!
@ -1742,11 +1761,11 @@ void Client::plainResize( int w, int h, ForceGeometry_t force )
*/
void Client::move( int x, int y, ForceGeometry_t force )
{
if( force == NormalGeometrySet && frame_geometry.topLeft() == QPoint( x, y ))
if( force == NormalGeometrySet && geom.topLeft() == QPoint( x, y ))
return;
frame_geometry.moveTopLeft( QPoint( x, y ));
geom.moveTopLeft( QPoint( x, y ));
updateWorkareaDiffs();
if( postpone_geometry_updates != 0 )
if( block_geometry_updates != 0 )
{
pending_geometry_update = true;
return;
@ -1755,20 +1774,22 @@ void Client::move( int x, int y, ForceGeometry_t force )
sendSyntheticConfigureNotify();
updateWindowRules();
checkMaximizeGeometry();
// client itself is not damaged
workspace()->addDamage( geom_before_block ); // TODO add damage only if not obscured
geom_before_block = geom;
}
void Client::postponeGeometryUpdates( bool postpone )
void Client::blockGeometryUpdates( bool block )
{
if( postpone )
if( block )
{
if( postpone_geometry_updates == 0 )
if( block_geometry_updates == 0 )
pending_geometry_update = false;
++postpone_geometry_updates;
++block_geometry_updates;
}
else
{
if( --postpone_geometry_updates == 0 )
if( --block_geometry_updates == 0 )
{
if( pending_geometry_update )
{
@ -1817,7 +1838,7 @@ void Client::changeMaximize( bool vertical, bool horizontal, bool adjust )
if( !adjust && max_mode == old_mode )
return;
GeometryUpdatesPostponer blocker( this );
GeometryUpdatesBlocker blocker( this );
// maximing one way and unmaximizing the other way shouldn't happen
Q_ASSERT( !( vertical && horizontal )
@ -2069,7 +2090,7 @@ void Client::setFullScreen( bool set, bool user )
if( was_fs == isFullScreen())
return;
StackingUpdatesBlocker blocker1( workspace());
GeometryUpdatesPostponer blocker2( this );
GeometryUpdatesBlocker blocker2( this );
workspace()->updateClientLayer( this ); // active fullscreens get different layer
info->setState( isFullScreen() ? NET::FullScreen : 0, NET::FullScreen );
updateDecoration( false, false );
@ -2225,7 +2246,7 @@ bool Client::startMoveResize()
XMapRaised( display(), move_resize_grab_window );
if( XGrabPointer( display(), move_resize_grab_window, False,
ButtonPressMask | ButtonReleaseMask | PointerMotionMask | EnterWindowMask | LeaveWindowMask,
GrabModeAsync, GrabModeAsync, move_resize_grab_window, cursor.handle(), xTime() ) == Success )
GrabModeAsync, GrabModeAsync, None, cursor.handle(), xTime() ) == Success )
has_grab = true;
if( XGrabKeyboard( display(), frameId(), False, GrabModeAsync, GrabModeAsync, xTime() ) == Success )
has_grab = true;
@ -2255,6 +2276,8 @@ bool Client::startMoveResize()
// not needed anymore? kapp->installEventFilter( eater );
}
Notify::raise( isResize() ? Notify::ResizeStart : Notify::MoveStart );
if( effects )
effects->windowUserMovedResized( this, true, false );
return true;
}
@ -2268,6 +2291,8 @@ void Client::finishMoveResize( bool cancel )
checkMaximizeGeometry();
// FRAME update();
Notify::raise( isResize() ? Notify::ResizeEnd : Notify::MoveEnd );
if( effects )
effects->windowUserMovedResized( this, false, true );
}
void Client::leaveMoveResize()
@ -2531,7 +2556,8 @@ void Client::handleMoveResize( int x, int y, int x_root, int y_root )
}
if ( isMove() )
workspace()->clientMoved(globalPos, xTime());
if( effects )
effects->windowUserMovedResized( this, false, false );
}
} // namespace

View file

@ -426,6 +426,7 @@ class Workspace : public QObject, public KDecorationDefines
void writeWindowRules();
void slotBlockShortcuts(int data);
void setPopupClientOpacity( QAction* action );
void setupCompositing();
void performCompositing();
void lostCMSelection();
@ -519,7 +520,6 @@ class Workspace : public QObject, public KDecorationDefines
void updateClientArea( bool force );
void setupCompositing();
void finishCompositing();
SystemTrayWindowList systemTrayWins;