Attachment #474244: Part 1. Make nsWindow::GetBounds return in screen coordinates for popups (checked in) for bug #588403

View | Details | Raw Unified | Return to bug 588403
Collapse All | Expand All

(-)a/widget/public/nsIWidget.h (-1 / +3 lines)
Line     Link Here 
 Lines 549-565   class nsIWidget : public nsISupports { Link Here 
549
     *               the case of popups may not be this widget's toplevel
549
     *               the case of popups may not be this widget's toplevel
550
     *               window) is already active, and this function indicates
550
     *               window) is already active, and this function indicates
551
     *               that keyboard events should be reported through the
551
     *               that keyboard events should be reported through the
552
     *               aHandleEventFunction provided to this->Create().
552
     *               aHandleEventFunction provided to this->Create().
553
     */
553
     */
554
    NS_IMETHOD SetFocus(PRBool aRaise = PR_FALSE) = 0;
554
    NS_IMETHOD SetFocus(PRBool aRaise = PR_FALSE) = 0;
555
555
556
    /**
556
    /**
557
     * Get this widget's outside dimensions relative to its parent widget
557
     * Get this widget's outside dimensions relative to its parent widget. For
558
     * popup widgets the returned rect is in screen coordinates and not
559
     * relative to its parent widget.
558
     *
560
     *
559
     * @param aRect   On return it holds the  x, y, width and height of
561
     * @param aRect   On return it holds the  x, y, width and height of
560
     *                this widget.
562
     *                this widget.
561
     */
563
     */
562
    NS_IMETHOD GetBounds(nsIntRect &aRect) = 0;
564
    NS_IMETHOD GetBounds(nsIntRect &aRect) = 0;
563
565
564
    /**
566
    /**
565
     * Get this widget's outside dimensions in global coordinates. This
567
     * Get this widget's outside dimensions in global coordinates. This
(-)a/widget/src/windows/nsWindow.cpp (+8 lines)
Line     Link Here 
 Lines 1834-1849   NS_METHOD nsWindow::GetBounds(nsIntRect Link Here 
1834
  if (mWnd) {
1834
  if (mWnd) {
1835
    RECT r;
1835
    RECT r;
1836
    VERIFY(::GetWindowRect(mWnd, &r));
1836
    VERIFY(::GetWindowRect(mWnd, &r));
1837
1837
1838
    // assign size
1838
    // assign size
1839
    aRect.width  = r.right - r.left;
1839
    aRect.width  = r.right - r.left;
1840
    aRect.height = r.bottom - r.top;
1840
    aRect.height = r.bottom - r.top;
1841
1841
1842
    // popup window bounds' are in screen coordinates, not relative to parent
1843
    // window
1844
    if (mWindowType == eWindowType_popup) {
1845
      aRect.x = r.left;
1846
      aRect.y = r.top;
1847
      return NS_OK;
1848
    }
1849
1842
    // chrome on parent:
1850
    // chrome on parent:
1843
    //  ___      5,5   (chrome start)
1851
    //  ___      5,5   (chrome start)
1844
    // |  ____   10,10 (client start)
1852
    // |  ____   10,10 (client start)
1845
    // | |  ____ 20,20 (child start)
1853
    // | |  ____ 20,20 (child start)
1846
    // | | |
1854
    // | | |
1847
    // 20,20 - 5,5 = 15,15 (??)
1855
    // 20,20 - 5,5 = 15,15 (??)
1848
    // minus GetClientOffset:
1856
    // minus GetClientOffset:
1849
    // 15,15 - 5,5 = 10,10
1857
    // 15,15 - 5,5 = 10,10

Return to bug 588403