Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes
MouseTrailer Class Reference

Makes sure exit/enter mouse messages are always dispatched. More...

#include <nsToolkit.h>

Collaboration diagram for MouseTrailer:
Collaboration graph
[legend]

List of all members.

Public Member Functions

nsWindowGetMouseTrailerWindow ()
nsWindowGetCaptureWindow ()
void SetMouseTrailerWindow (nsWindow *aNSWin)
void SetCaptureWindow (nsWindow *aNSWin)
void IgnoreNextCycle ()
void DestroyTimer ()
 ~MouseTrailer ()

Static Public Member Functions

static MouseTrailerGetSingleton ()

Private Member Functions

 MouseTrailer ()
nsresult CreateTimer ()

Static Private Member Functions

static void TimerProc (nsITimer *aTimer, void *aClosure)

Private Attributes

nsWindowmHoldMouseWindow
nsWindowmCaptureWindow
PRBool mIsInCaptureMode
PRBool mIgnoreNextCycle
nsCOMPtr< nsITimermTimer

Static Private Attributes

static MouseTrailer mSingleton

Detailed Description

Makes sure exit/enter mouse messages are always dispatched.

In the case where the mouse has exited the outer most window the only way to tell if it has exited is to set a timer and look at the mouse pointer to see if it is within the outer most window.

Definition at line 159 of file nsToolkit.h.


Constructor & Destructor Documentation

Definition at line 938 of file nsToolkit.cpp.

Here is the call graph for this function:


Member Function Documentation

Definition at line 963 of file nsToolkit.cpp.

{
  if (mTimer) {
    return NS_OK;
  } 

  nsresult rv;
  mTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
  NS_ENSURE_SUCCESS(rv, rv);

  return mTimer->InitWithFuncCallback(TimerProc, nsnull, 200,
                                      nsITimer::TYPE_REPEATING_SLACK);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 982 of file nsToolkit.cpp.

{
  if (mTimer) {
    mTimer->Cancel();
    mTimer = nsnull;
  }
}

Here is the caller graph for this function:

Definition at line 165 of file nsToolkit.h.

{ return mCaptureWindow; }

Definition at line 164 of file nsToolkit.h.

{ return mHoldMouseWindow; }
static MouseTrailer& MouseTrailer::GetSingleton ( ) [inline, static]

Definition at line 162 of file nsToolkit.h.

{ return mSingleton; }

Here is the caller graph for this function:

Definition at line 169 of file nsToolkit.h.

Here is the caller graph for this function:

Definition at line 993 of file nsToolkit.cpp.

Here is the call graph for this function:

Definition at line 948 of file nsToolkit.cpp.

{
  nsWindow *topWin = aNSWin ? aNSWin->GetTopLevelWindow() : nsnull;
  if (mHoldMouseWindow != topWin && mTimer) {
    // Make sure TimerProc is fired at least once for the old window
    TimerProc(nsnull, nsnull);
  }
  NS_IF_RELEASE(mHoldMouseWindow);
  mHoldMouseWindow = topWin;
  CreateTimer();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void MouseTrailer::TimerProc ( nsITimer aTimer,
void aClosure 
) [static, private]

Definition at line 1005 of file nsToolkit.cpp.

{
  // Check to see if we are in mouse capture mode,
  // Once capture ends we could still get back one more timer event 
  // Capture could end outside our window
  // Also, for some reason when the mouse is on the frame it thinks that
  // it is inside the window that is being captured.
  if (nsnull != mSingleton.mCaptureWindow) {
    if (mSingleton.mCaptureWindow != mSingleton.mHoldMouseWindow) {
      return;
    }
  } else {
    if (mSingleton.mIsInCaptureMode) {
      // The mHoldMouse could be bad from rolling over the frame, so clear 
      // it if we were capturing and now this is the first timer call back 
      // since we canceled the capture
      NS_IF_RELEASE(mSingleton.mHoldMouseWindow);
      mSingleton.mIsInCaptureMode = PR_FALSE;
      return;
    }
  }

  if (mSingleton.mHoldMouseWindow && ::IsWindow(mSingleton.mHoldMouseWindow->GetWindowHandle())) {
    if (mSingleton.mIgnoreNextCycle) {
      mSingleton.mIgnoreNextCycle = PR_FALSE;
    }
    else {
      POINT mp;
      DWORD pos = ::GetMessagePos();
      mp.x = GET_X_LPARAM(pos);
      mp.y = GET_Y_LPARAM(pos);

      // Need to get the top level wnd's here. Although mHoldMouseWindow is top level,
      // the actual top level window handle might be something else
      HWND mouseWnd = nsWindow::GetTopLevelHWND(::WindowFromPoint(mp), PR_TRUE);
      HWND holdWnd = nsWindow::GetTopLevelHWND(mSingleton.mHoldMouseWindow->GetWindowHandle(), PR_TRUE);
      if (mouseWnd != holdWnd) {
        //notify someone that a mouse exit happened
        if (nsnull != mSingleton.mHoldMouseWindow) {
          mSingleton.mHoldMouseWindow->DispatchMouseEvent(NS_MOUSE_EXIT, NULL, NULL);
        }

        // we are out of this window and of any window, destroy timer
        mSingleton.DestroyTimer();
        NS_IF_RELEASE(mSingleton.mHoldMouseWindow);
      }
    }
  } else {
    mSingleton.DestroyTimer();
    NS_IF_RELEASE(mSingleton.mHoldMouseWindow);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 186 of file nsToolkit.h.

Definition at line 185 of file nsToolkit.h.

Definition at line 188 of file nsToolkit.h.

Definition at line 187 of file nsToolkit.h.

Definition at line 181 of file nsToolkit.h.

Definition at line 190 of file nsToolkit.h.


The documentation for this class was generated from the following files: