Revision: 6347
Author: nogu.dev
Date: Wed Apr 28 15:50:55 2010
Log: * qt4/immodule/candidatewindow.cpp
  - (CandidateWindow::moveEvent, CandidateWindow::resizeEvent):
    Follow change of SubWindow::layoutWindow().
  - (CandidateWindow::slotHookSubwindow): Call SubWindow::layoutWindow().
* qt4/immodule/subwindow.cpp
  - (SubWindow::layoutWindow): Fix position of SubWindow.
  - (SubWindow::forceInside): Remove.
* qt4/immodule/subwindow.h
  - Change SubWindow::layoutWindow().
  - Remove SubWindow::forceInside().
http://code.google.com/p/uim/source/detail?r=6347

Modified:
 /trunk/qt4/immodule/candidatewindow.cpp
 /trunk/qt4/immodule/subwindow.cpp
 /trunk/qt4/immodule/subwindow.h

=======================================
--- /trunk/qt4/immodule/candidatewindow.cpp     Mon Apr 26 15:50:19 2010
+++ /trunk/qt4/immodule/candidatewindow.cpp     Wed Apr 28 15:50:55 2010
@@ -562,6 +562,7 @@
         = cList->item( list[0]->row(), ANNOTATION_COLUMN )->text();
     if ( !annotationString.isEmpty() )
     {
+        subWin->layoutWindow( frameGeometry() );
         subWin->hookPopup( "Annotation", annotationString );
     }
 }
@@ -571,14 +572,14 @@
 {
     // move subwindow
     if ( subWin )
-        subWin->layoutWindow( e->pos().x() + width(), e->pos().y() );
+        subWin->layoutWindow( QRect( e->pos(), size() ) );
 }

 void CandidateWindow::resizeEvent( QResizeEvent *e )
 {
     // move subwindow
     if ( subWin )
-        subWin->layoutWindow( pos().x() + e->size().width(), pos().y() );
+        subWin->layoutWindow( QRect( pos(), e->size() ) );
 }


=======================================
--- /trunk/qt4/immodule/subwindow.cpp   Sun Apr  4 20:35:54 2010
+++ /trunk/qt4/immodule/subwindow.cpp   Wed Apr 28 15:50:55 2010
@@ -109,25 +109,21 @@
     popup();
 }

-void SubWindow::layoutWindow( int x, int y )
-{
-    QRect focusRect = QRect( QPoint( x, y ), frameSize() );
-    QRect screenRect = QRect( 0, 0,
- QApplication::desktop() ->screenGeometry().width(), - QApplication::desktop() ->screenGeometry().height() );
-
-    QPoint p = forceInside( screenRect, focusRect );
-    move( p );
-}
-
-QPoint SubWindow::forceInside( const QRect &enclosure, const QRect &prisoner )
-{
-    int new_x, new_y;
-
- new_x = qMin( enclosure.right(), prisoner.right() ) - prisoner.width() + 1;
-    new_x = qMax( enclosure.left(), new_x );
- new_y = qMin( enclosure.bottom(), prisoner.bottom() ) - prisoner.height() + 1;
-    new_y = qMax( enclosure.top(), new_y );
-
-    return QPoint( new_x, new_y );
-}
+void SubWindow::layoutWindow( const QRect &rect )
+{
+    const QRect screenRect = QApplication::desktop()->screenGeometry();
+
+    const int w = width();
+    const int candX = rect.x();
+    int destX = candX + rect.width();
+    if ( destX + w > screenRect.width() )
+        destX = candX - w;
+
+    const int h = height();
+    const int screenH = screenRect.height();
+    int destY = rect.y();
+    if ( destY + h > screenH )
+        destY = screenH - h;
+
+    move( destX, destY );
+}
=======================================
--- /trunk/qt4/immodule/subwindow.h     Sun Apr  4 20:35:54 2010
+++ /trunk/qt4/immodule/subwindow.h     Wed Apr 28 15:50:55 2010
@@ -47,7 +47,7 @@
     explicit SubWindow( QWidget *parent = 0 );
     ~SubWindow();

-    void layoutWindow( int x, int y );
+    void layoutWindow( const QRect &rect );

     bool isHooked()
     {
@@ -61,8 +61,6 @@
 protected:
     void popup();

-    QPoint forceInside( const QRect &enclosure, const QRect &prisoner );
-
 protected slots:
     void timerDone();

Reply via email to