Beispiel #1
0
//------
// Move
//------
PRBool nsWidget::OnMove( PRInt32 aX, PRInt32 aY ) {
    nsGUIEvent event(PR_TRUE, 0, nsnull);
    InitEvent(event, NS_MOVE);
    event.point.x = aX;
    event.point.y = aY;
    return DispatchWindowEvent(&event);
}
Beispiel #2
0
//-------------------------------------------------------------------------
//
// Send a resize message to the listener
//
//-------------------------------------------------------------------------
PRBool nsWidget::OnResize( nsRect &aRect ) {

    PRBool result = PR_FALSE;

    // call the event callback
    if( mEventCallback ) {
        nsSizeEvent event(PR_TRUE, 0, nsnull);

        InitEvent(event, NS_SIZE);

        nsRect *foo = new nsRect(0, 0, aRect.width, aRect.height);
        event.windowSize = foo;

        event.point.x = 0;
        event.point.y = 0;
        event.mWinWidth = aRect.width;
        event.mWinHeight = aRect.height;

        NS_ADDREF_THIS();
        result = DispatchWindowEvent(&event);
        NS_RELEASE_THIS();
        delete foo;
    }

    return result;
}
Beispiel #3
0
//-------------------------------------------------------------------------
//
// Deal with all sort of mouse event
//
//-------------------------------------------------------------------------
PRBool nsWidget::DispatchMouseEvent( nsMouseEvent& aEvent ) {

    PRBool result = PR_FALSE;
    if (nsnull == mEventCallback && nsnull == mMouseListener) return result;

    //printf("* DispatchMouseEvent %d\n", aEvent.message);
    // call the event callback
    if (nsnull != mEventCallback) {
        result = DispatchWindowEvent(&aEvent);
        return result;
    }

    if (nsnull != mMouseListener) {

        switch (aEvent.message) {
        case NS_MOUSE_LEFT_BUTTON_DOWN:
        case NS_MOUSE_MIDDLE_BUTTON_DOWN:
        case NS_MOUSE_RIGHT_BUTTON_DOWN:
            result = ConvertStatus(mMouseListener->MousePressed(aEvent));
            break;

        case NS_MOUSE_LEFT_BUTTON_UP:
        case NS_MOUSE_MIDDLE_BUTTON_UP:
        case NS_MOUSE_RIGHT_BUTTON_UP:
            result = ConvertStatus(mMouseListener->MouseReleased(aEvent));
            result = ConvertStatus(mMouseListener->MouseClicked(aEvent));
            break;

        case NS_DRAGDROP_DROP:
            break;

        case NS_MOUSE_MOVE:
            break;

        default:
            break;

        } // switch
    }
    return result;
}
// Process messages from the frame
MRESULT nsFrameWindow::FrameMessage( ULONG msg, MPARAM mp1, MPARAM mp2)
{
   MRESULT mresult = 0;
   BOOL    bDone = FALSE;

   switch (msg)
   {
      case WM_WINDOWPOSCHANGED:
      {
         PSWP pSwp = (PSWP) mp1;

         // Note that client windows never get 'move' messages (well, they won't here anyway)
         if( pSwp->fl & SWP_MOVE && !(pSwp->fl & SWP_MINIMIZE))
         {
            // These commented-out `-1's cancel each other out.
            POINTL ptl = { pSwp->x, pSwp->y + pSwp->cy /* - 1 */ };
            ptl.y = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN) - ptl.y /* - 1*/ ;
            mBounds.x = ptl.x;
            mBounds.y = ptl.y;
            OnMove( ptl.x, ptl.y);
         }

         // When the frame is sized, do stuff to recalculate client size.
         if( pSwp->fl & SWP_SIZE && !(pSwp->fl & SWP_MINIMIZE))
         {
            mresult = (*fnwpDefFrame)( mFrameWnd, msg, mp1, mp2);
            bDone = TRUE;

            mBounds.width = pSwp->cx;
            mBounds.height = pSwp->cy;

            UpdateClientSize();
            DispatchResizeEvent( mSizeClient.width, mSizeClient.height);
         }
 
         if (pSwp->fl & (SWP_MAXIMIZE | SWP_MINIMIZE | SWP_RESTORE)) {
           nsSizeModeEvent event(PR_TRUE, NS_SIZEMODE, this);
            if (pSwp->fl & SWP_MAXIMIZE)
              event.mSizeMode = nsSizeMode_Maximized;
            else if (pSwp->fl & SWP_MINIMIZE)
              event.mSizeMode = nsSizeMode_Minimized;
            else
              event.mSizeMode = nsSizeMode_Normal;
            InitEvent(event);
            DispatchWindowEvent(&event);
         }

         break;
      }

      // a frame window in kiosk/fullscreen mode must have its frame
      // controls reattached before it's minimized & detached after it's
      // restored;  if this doesn't happen at the correct times, clicking
      // on the icon won't restore it, the sysmenu will have the wrong
      // items, and/or the minmax button will have the wrong buttons

      case WM_ADJUSTWINDOWPOS:
      {
        if (mChromeHidden && ((PSWP)mp1)->fl & SWP_MINIMIZE) {
          HWND hwndTemp = (HWND)WinQueryProperty(mFrameWnd, "hwndMinMax");
          if (hwndTemp)
            WinSetParent(hwndTemp, mFrameWnd, TRUE);
          hwndTemp = (HWND)WinQueryProperty(mFrameWnd, "hwndTitleBar");
          if (hwndTemp)
            WinSetParent(hwndTemp, mFrameWnd, TRUE);
          hwndTemp = (HWND)WinQueryProperty(mFrameWnd, "hwndSysMenu");
          if (hwndTemp)
            WinSetParent(hwndTemp, mFrameWnd, TRUE);
        }
        break;
      }
      case WM_ADJUSTFRAMEPOS:
      {
        if (mChromeHidden && ((PSWP)mp1)->fl & SWP_RESTORE) {
          HWND hwndTemp = (HWND)WinQueryProperty(mFrameWnd, "hwndSysMenu");
          if (hwndTemp)
            WinSetParent(hwndTemp, HWND_OBJECT, TRUE);
          hwndTemp = (HWND)WinQueryProperty(mFrameWnd, "hwndTitleBar");
          if (hwndTemp)
            WinSetParent(hwndTemp, HWND_OBJECT, TRUE);
          hwndTemp = (HWND)WinQueryProperty(mFrameWnd, "hwndMinMax");
          if (hwndTemp)
            WinSetParent(hwndTemp, HWND_OBJECT, TRUE);
        }
        break;
      }

      case WM_DESTROY:
         DEBUGFOCUS(frame WM_DESTROY);
         WinSubclassWindow( mFrameWnd, fnwpDefFrame);
         WinSetWindowPtr( mFrameWnd, QWL_USER, 0);
         WinRemoveProperty(mFrameWnd, "hwndTitleBar");
         WinRemoveProperty(mFrameWnd, "hwndSysMenu");
         WinRemoveProperty(mFrameWnd, "hwndMinMax");
         WinRemoveProperty(mFrameWnd, "ulStyle");
         break;
      case WM_INITMENU:
         /* If we are in fullscreen/kiosk mode, disable maximize menu item */
         if (mChromeHidden) {
            if (WinQueryWindowULong(mFrameWnd, QWL_STYLE) & WS_MINIMIZED) {
              if (SHORT1FROMMP(mp1) == SC_SYSMENU) {
                MENUITEM menuitem;
                WinSendMsg(WinWindowFromID(mFrameWnd, FID_SYSMENU), MM_QUERYITEM, MPFROM2SHORT(SC_SYSMENU, FALSE), MPARAM(&menuitem));
                mresult = (*fnwpDefFrame)( mFrameWnd, msg, mp1, mp2);
                WinEnableMenuItem(menuitem.hwndSubMenu, SC_MAXIMIZE, FALSE);
                bDone = TRUE;
              }
            }
         }
         break;
      case WM_SYSCOMMAND:
         /* If we are in fullscreen/kiosk mode, don't honor maximize requests */
         if (mChromeHidden) {
            if (WinQueryWindowULong(mFrameWnd, QWL_STYLE) & WS_MINIMIZED) {
              if ((SHORT1FROMMP(mp1) == SC_MAXIMIZE))
              {
                bDone = TRUE;
              }
            }
         }
         break;

      // When the frame is activated, set a flag to be acted on after
      // PM has finished changing focus.  When deactivated, dispatch
      // the event immediately because it doesn't affect the focus.
      case WM_ACTIVATE:
         DEBUGFOCUS(WM_ACTIVATE);
         if (mp1) {
            mNeedActivation = PR_TRUE;
         } else {
            mNeedActivation = PR_FALSE;
            DEBUGFOCUS(NS_DEACTIVATE);
            DispatchFocus(NS_DEACTIVATE);
            // Prevent the frame from automatically focusing any window
            // when it's reactivated.  Let moz set the focus to avoid
            // having non-widget children of plugins focused in error.
            WinSetWindowULong(mFrameWnd, QWL_HWNDFOCUSSAVE, 0);
         }
         break;
   }

   if( !bDone)
      mresult = (*fnwpDefFrame)( mFrameWnd, msg, mp1, mp2);

   return mresult;
}