From 9d1977d645ddb476832e615e1c6c8f12dfc10d13 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Sat, 29 Nov 2008 17:45:25 +0000 Subject: [PATCH] Resize accordingly when we are resized from "outside" (eg by the WM). BUG: 173545 svn path=/trunk/KDE/kdegraphics/okular/; revision=890639 --- ui/presentationwidget.cpp | 19 +++++++++++++++++++ ui/presentationwidget.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/ui/presentationwidget.cpp b/ui/presentationwidget.cpp index ddc8f569b..50da24191 100644 --- a/ui/presentationwidget.cpp +++ b/ui/presentationwidget.cpp @@ -620,6 +620,17 @@ void PresentationWidget::paintEvent( QPaintEvent * pe ) } painter.end(); } + +void PresentationWidget::resizeEvent( QResizeEvent *re ) +{ + // kDebug() << re->oldSize() << "=>" << re->size(); + if ( re->oldSize() == QSize( -1, -1 ) ) + return; + + m_screen = QApplication::desktop()->screenNumber( this ); + + applyNewScreenSize( re->oldSize() ); +} // @@ -1307,6 +1318,11 @@ void PresentationWidget::setScreen( int newScreen ) m_screen = newScreen; setGeometry( screenGeom ); + applyNewScreenSize( oldSize ); +} + +void PresentationWidget::applyNewScreenSize( const QSize & oldSize ) +{ repositionContent(); // if by chance the new screen has the same resolution of the previous, @@ -1325,6 +1341,8 @@ void PresentationWidget::setScreen( int newScreen ) (*fIt)->recalcGeometry( m_width, m_height, screenRatio ); } + if ( m_frameIndex != -1 ) + { // ugliness alarm! const_cast< Okular::Page * >( m_frames[ m_frameIndex ]->page )->deletePixmap( PRESENTATION_ID ); // force the regeneration of the pixmap @@ -1332,6 +1350,7 @@ void PresentationWidget::setScreen( int newScreen ) m_blockNotifications = true; requestPixmaps(); m_blockNotifications = false; + } generatePage( true /* no transitions */ ); } diff --git a/ui/presentationwidget.h b/ui/presentationwidget.h index 205af1fef..6a326b2ee 100644 --- a/ui/presentationwidget.h +++ b/ui/presentationwidget.h @@ -64,6 +64,7 @@ class PresentationWidget : public QWidget, public Okular::DocumentObserver void mouseReleaseEvent( QMouseEvent * e ); void mouseMoveEvent( QMouseEvent * e ); void paintEvent( QPaintEvent * e ); + void resizeEvent( QResizeEvent * e ); private: const Okular::Action * getLink( int x, int y, QRect * geometry = 0 ) const; @@ -83,6 +84,7 @@ class PresentationWidget : public QWidget, public Okular::DocumentObserver void repositionContent(); void requestPixmaps(); void setScreen( int ); + void applyNewScreenSize( const QSize & oldSize ); void inhibitScreenSaver(); void allowScreenSaver(); // create actions that interact with this widget