Index: kmail/kwindowpositioner.cpp
===================================================================
--- kmail/kwindowpositioner.cpp	(wersja 817550)
+++ kmail/kwindowpositioner.cpp	(kopia robocza)
@@ -25,37 +25,43 @@
 #include <kdebug.h>
 
 #include <QWidget>
-//Added by qt3to4:
-#include <QEvent>
+#include <QApplication>
+#include <QDesktopWidget>
 
 KWindowPositioner::KWindowPositioner( QWidget *master, QWidget *slave,
   Mode mode )
   : QObject( master ), mMaster( master ), mSlave( slave ), mMode( mode )
 {
-  master->topLevelWidget()->installEventFilter( this );
 }
 
-bool KWindowPositioner::eventFilter( QObject *, QEvent *e )
-{
-  if ( e->type() == QEvent::Move ) {
-    reposition();
-  }
-
-  return false;
-}
-
 void KWindowPositioner::reposition()
 {
   QPoint relativePos;
   if ( mMode == Right ) {
-    relativePos = QPoint( mMaster->width(), -100 );
+    relativePos = QPoint( mMaster->width(), 0 );
   } else if ( mMode == Bottom ) {
-    relativePos = QPoint( 100 - mSlave->width() + mMaster->width(),
+    relativePos = QPoint( mMaster->width() - mSlave->frameGeometry().width(),
       mMaster->height() );
   } else {
     kError() <<"KWindowPositioner: Illegal mode";
   }
   QPoint pos = mMaster->mapToGlobal( relativePos );
+  
+  // fix position to avoid hiding parts of the window (needed especially when not using KWin)
+  const QRect desktopRect( qApp->desktop()->availableGeometry( mMaster ) );
+  if ( ( pos.x() + mSlave->frameGeometry().width() ) > desktopRect.width() )
+    pos.setX( desktopRect.width() - mSlave->frameGeometry().width() );
+  if ( ( pos.y() + mSlave->frameGeometry().height() ) > desktopRect.height() )
+    pos.setY( desktopRect.height() - mSlave->frameGeometry().height() - mMaster->height() );
+  kDebug() << mMaster->pos() << mMaster->mapToGlobal(mMaster->pos()) << pos.y() << (mMaster->pos().y() - pos.y()) << mSlave->frameGeometry().height();
+  if ( mMode == Bottom && mMaster->mapToGlobal(mMaster->pos()).y() > pos.y() && (mMaster->pos().y() - pos.y()) < mSlave->frameGeometry().height() ) {
+    pos.setY( mMaster->mapToGlobal(  QPoint( 0, -mSlave->frameGeometry().height() ) ).y() );
+  }
+  if ( pos.x() < desktopRect.left() )
+    pos.setX( desktopRect.left() );
+  if ( pos.y() < desktopRect.top() )
+    pos.setY( desktopRect.top() );
+
   mSlave->move( pos );
   mSlave->raise();
 }
Index: kmail/kwindowpositioner.h
===================================================================
--- kmail/kwindowpositioner.h	(wersja 817550)
+++ kmail/kwindowpositioner.h	(kopia robocza)
@@ -21,9 +21,7 @@
 #ifndef KWINDOWPOSITIONER_H
 #define KWINDOWPOSITIONER_H
 
-#include <QObject>
-//Added by qt3to4:
-#include <QEvent>
+#include <QWidget>
 
 
 class KWindowPositioner : public QObject
@@ -34,8 +32,6 @@
 
     KWindowPositioner( QWidget *master, QWidget *slave, Mode mode = Bottom );
 
-    bool eventFilter( QObject *watched, QEvent *e );
-
     void reposition();
     
   private:
Index: kmail/recipientseditor.cpp
===================================================================
--- kmail/recipientseditor.cpp	(wersja 817550)
+++ kmail/recipientseditor.cpp	(kopia robocza)
@@ -747,7 +747,7 @@
     mRecipientPicker = new RecipientsPicker( non_const_this );
     connect( mRecipientPicker, SIGNAL( pickedRecipient( const Recipient & ) ),
              non_const_this, SIGNAL( pickedRecipient( const Recipient & ) ) );
-    mPickerPositioner = new KWindowPositioner( non_const_this, mRecipientPicker );
+    mPickerPositioner = new KWindowPositioner( mSelectButton, mRecipientPicker );
   }
   return mRecipientPicker;
 }
@@ -813,9 +813,8 @@
   RecipientsPicker *p = picker();
   p->setDefaultType( mView->activeLine()->recipientType() );
   p->setRecipients( mView->recipients() );
-  p->show();
   mPickerPositioner->reposition();
-  p->raise();
+  p->show();
 }
 
 
