Back to index

lightning-sunbird  0.9+nobinonly
Public Types | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Static Protected Attributes
CEmbedEventAttachment Class Reference

#include <EmbedEventHandling.h>

List of all members.

Public Types

enum  { class_ID = FOUR_CHAR_CODE('GAWA') }

Public Member Functions

 CEmbedEventAttachment ()
virtual ~CEmbedEventAttachment ()
virtual void ExecuteSelf (MessageT inMessage, void *ioParam)

Protected Member Functions

Boolean IsAlienGeckoWindow (WindowPtr inMacWindow)

Static Protected Member Functions

static void GetWindowEventSink (WindowPtr aWindow, nsIEventSink **outSink)
static void GetTopWidget (WindowPtr aWindow, nsIWidget **outWidget)

Static Protected Attributes

static WindowPtr mLastAlienWindowClicked

Detailed Description

Definition at line 57 of file EmbedEventHandling.h.


Member Enumeration Documentation

anonymous enum
Enumerator:
class_ID 

Definition at line 61 of file EmbedEventHandling.h.

{ class_ID = FOUR_CHAR_CODE('GAWA') };

Constructor & Destructor Documentation

Definition at line 64 of file EmbedEventHandling.cpp.

{
}

Definition at line 68 of file EmbedEventHandling.cpp.

{
}

Member Function Documentation

void CEmbedEventAttachment::ExecuteSelf ( MessageT  inMessage,
void ioParam 
) [virtual]

Definition at line 112 of file EmbedEventHandling.cpp.

{
       SetExecuteHost(true);

    EventRecord *inMacEvent;
    WindowPtr macWindowP;
       
       // 1. Handle the msg_AdjustCursor message. PowerPlant
       // sends this message to attachments which are attached
       // to views but not those attached to the application.
       // IMPORTANT: For this to be called, the application's
       // AdjustCursor() method must be overridden to send the
       // msg_AdjustCursor to its attachments.
              
    if (inMessage == msg_AdjustCursor) {
        inMacEvent = static_cast<EventRecord*>(ioParam);
        ::MacFindWindow(inMacEvent->where, &macWindowP);
        if (IsAlienGeckoWindow(macWindowP)) {
            nsCOMPtr<nsIEventSink> sink;
            GetWindowEventSink(macWindowP, getter_AddRefs(sink));
            if ( sink ) {
              PRBool handled = PR_FALSE;
              sink->DispatchEvent(inMacEvent, &handled);
              SetExecuteHost(false);
            }
        }
              
       } else if (inMessage == msg_Event) {
        inMacEvent = static_cast<EventRecord*>(ioParam);

#if defined(__MWERKS__) && defined(DEBUG) && !TARGET_CARBON
        // 2. See if the event is for the console window.
        // Limit what types of events we send to it.
        if ((inMacEvent->what == mouseDown ||
            inMacEvent->what == updateEvt ||
            inMacEvent->what == activateEvt ||
            inMacEvent->what == keyDown) &&
            SIOUXHandleOneEvent(inMacEvent))
        {
            SetExecuteHost(false);
            return;
        }
#endif
        
       // 3. Finally, see if we have an event for a Gecko window
       // which is not an LWindow. These get created by widget to
       // show pop-up list boxes - grrr. The following events are
       // sufficient for those.
                
        switch (inMacEvent->what)
           {  
          case mouseDown:
          {
              mLastAlienWindowClicked = nil;
              // If an alien window is frontmost, as they always are when present,
              // Gecko needs to get the event - no matter where the click occured.
              // This is so the pop-up window (what these alien windows are used for)
              // will be rolled up on a click in the menu bar, title bar, etc.
              WindowPtr frontWindow = ::FrontWindow();
              if (IsAlienGeckoWindow(frontWindow)) {
                 nsCOMPtr<nsIEventSink> sink;
                 GetWindowEventSink(frontWindow, getter_AddRefs(sink));
                 if (sink) {
                   PRBool handled = PR_FALSE;
                   sink->DispatchEvent(inMacEvent, &handled);
                   SInt16 thePart = ::MacFindWindow(inMacEvent->where, &macWindowP);
                   if ((thePart == inContent) && (frontWindow == macWindowP)) {
                     // It the click was actually in an alien window - done processing
                     // Otherwise, let PowerPlant continue processing the click.
                     mLastAlienWindowClicked = macWindowP;
                     SetExecuteHost(false);
                  }
               }
            }
         }
         break;

                  case mouseUp:
                  {
                      if (mLastAlienWindowClicked) {
                nsCOMPtr<nsIEventSink> sink;
                GetWindowEventSink(mLastAlienWindowClicked, getter_AddRefs(sink));
                if ( sink ) {
                  PRBool handled = PR_FALSE;
                          sink->DispatchEvent(inMacEvent, &handled);
                          mLastAlienWindowClicked = nil;
                          SetExecuteHost(false);
                        }
                      }
                  }
                     break;
                            
                  case updateEvt:
                  case activateEvt:
                  {
                    macWindowP = (WindowPtr)inMacEvent->message;
                         if (IsAlienGeckoWindow(macWindowP)) {
                nsCOMPtr<nsIEventSink> sink;
                GetWindowEventSink(macWindowP, getter_AddRefs(sink));
                if ( sink ) {
                  PRBool handled = PR_FALSE;
                          sink->DispatchEvent(inMacEvent, &handled);
                          SetExecuteHost(false);
                        }
                         }
                     }
                     break;                      
           }
       }
}

Here is the call graph for this function:

void CEmbedEventAttachment::GetTopWidget ( WindowPtr  aWindow,
nsIWidget **  outWidget 
) [static, protected]

Definition at line 80 of file EmbedEventHandling.cpp.

{
  nsIWidget* topLevelWidget = nsnull;
       ::GetWindowProperty ( aWindow, 'MOSS', 'GEKO', sizeof(nsIWidget*), nsnull, (void*)&topLevelWidget);
  if ( topLevelWidget ) {
    *outWidget = topLevelWidget;
    NS_ADDREF(*outWidget);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void CEmbedEventAttachment::GetWindowEventSink ( WindowPtr  aWindow,
nsIEventSink **  outSink 
) [static, protected]

Definition at line 98 of file EmbedEventHandling.cpp.

{
  *outSink = nsnull;
  
  nsCOMPtr<nsIWidget> topWidget;
  GetTopWidget ( aWindow, getter_AddRefs(topWidget) );
  nsCOMPtr<nsIEventSink> sink ( do_QueryInterface(topWidget) );
  if ( sink ) {
    *outSink = sink;
    NS_ADDREF(*outSink);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Boolean CEmbedEventAttachment::IsAlienGeckoWindow ( WindowPtr  inMacWindow) [protected]

Definition at line 225 of file EmbedEventHandling.cpp.

{
    PRBool isAlien = PR_FALSE;
    
    // it's an 'alien' window if there's no LWindow object and there is
    // an nsIEventSink stashed in the window's root control.
    if (inMacWindow && !LWindow::FetchWindowObject(inMacWindow)) {
      nsCOMPtr<nsIEventSink> sink;
      GetWindowEventSink ( inMacWindow, getter_AddRefs(sink) );
      if ( sink )
        isAlien = PR_TRUE;   
    }
    
    return isAlien;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

WindowPtr CEmbedEventAttachment::mLastAlienWindowClicked [static, protected]

Definition at line 78 of file EmbedEventHandling.h.


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