Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions | Variables
nsWindow.cpp File Reference
#include "nsWindow.h"
#include "nsIAppShell.h"
#include "nsIFontMetrics.h"
#include "nsFont.h"
#include "nsGUIEvent.h"
#include "nsIRenderingContext.h"
#include "nsIRenderingContextOS2.h"
#include "nsIDeviceContext.h"
#include "nsIScreenManager.h"
#include "nsRect.h"
#include "nsTransform2D.h"
#include "nsGfxCIID.h"
#include "prtime.h"
#include "nsISupportsArray.h"
#include "nsIMenuBar.h"
#include "nsHashtable.h"
#include "nsDragService.h"
#include "nsILocalFile.h"
#include "nsNetUtil.h"
#include "nsIRollupListener.h"
#include "nsIMenuRollup.h"
#include "nsIRegion.h"
#include "nsIPref.h"
#include "nsplugindefs.h"
#include "nsITimer.h"
#include "nsIServiceManager.h"
#include "nsAppDirectoryServiceDefs.h"
#include "nsXPIDLString.h"
#include "nsIFile.h"
#include "nsOS2Uni.h"
#include "nsPaletteOS2.h"
#include "imgIContainer.h"
#include "gfxIImageFrame.h"
#include <stdlib.h>
#include <ctype.h>
#include "nsdefs.h"
#include "wdgtos2rc.h"

Go to the source code of this file.

Defines

#define XFROMMP(m)   (SHORT(LOUSHORT(m)))
#define YFROMMP(m)   (SHORT(HIUSHORT(m)))
#define ACTION_PAINT   1
#define ACTION_DRAW   2
#define ACTION_SCROLL   3
#define ACTION_SHOW   4
#define ACTION_PTRPOS   5
#define DND_None   (nsIDragSessionOS2::DND_NONE)
#define DND_NativeDrag   (nsIDragSessionOS2::DND_NATIVEDRAG)
#define DND_MozDrag   (nsIDragSessionOS2::DND_MOZDRAG)
#define DND_InDrop   (nsIDragSessionOS2::DND_INDROP)
#define DND_DragStatus   (nsIDragSessionOS2::DND_DRAGSTATUS)
#define DND_DispatchEnterEvent   (nsIDragSessionOS2::DND_DISPATCHENTEREVENT)
#define DND_DispatchEvent   (nsIDragSessionOS2::DND_DISPATCHEVENT)
#define DND_GetDragoverResult   (nsIDragSessionOS2::DND_GETDRAGOVERRESULT)
#define DND_ExitSession   (nsIDragSessionOS2::DND_EXITSESSION)
#define WM_APPCOMMAND   0x0319
#define APPCOMMAND_BROWSER_BACKWARD   1
#define APPCOMMAND_BROWSER_FORWARD   2
#define APPCOMMAND_BROWSER_REFRESH   3
#define APPCOMMAND_BROWSER_STOP   4
#define FAPPCOMMAND_MASK   0xF000
#define GET_APPCOMMAND_LPARAM(lParam)   ((USHORT)(HIUSHORT(lParam) & ~FAPPCOMMAND_MASK))
#define kWindowPositionSlop   100
#define ALIGNEDBPR(cx, bits)   ( ( ( ((cx)*(bits)) + 31) / 32) * 4)
#define MAX_TITLEBAR_LENGTH   256

Functions

static PCSZ GetNSWindowPropName ()
BOOL bothFromSameWindow (HWND hwnd1, HWND hwnd2)
MRESULT EXPENTRY fnwpNSWindow (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
PRUint32 WMChar2KeyCode (MPARAM mp1, MPARAM mp2)

Variables

static const char * sScreenManagerContractID = "@mozilla.org/gfx/screenmanager;1"
nsIRollupListenergRollupListener = nsnull
nsIWidgetgRollupWidget = nsnull
PRBool gRollupConsumeRollupEvent = PR_FALSE
PRBool gJustGotActivate = PR_FALSE
PRBool gJustGotDeactivate = PR_FALSE
static POINTS gLastButton1Down = {0,0}
static PRBool gGlobalsInitialized = PR_FALSE
static HPOINTER gPtrArray [IDC_COUNT]
static PRBool gIsTrackPoint = PR_FALSE
static PRBool gIsDBCS = PR_FALSE
static PRUint32 gLastInputEventTime = 0
static PRUint32 gDragStatus = 0

Define Documentation

Definition at line 168 of file nsWindow.cpp.

Definition at line 167 of file nsWindow.cpp.

Definition at line 171 of file nsWindow.cpp.

Definition at line 169 of file nsWindow.cpp.

Definition at line 170 of file nsWindow.cpp.

#define ALIGNEDBPR (   cx,
  bits 
)    ( ( ( ((cx)*(bits)) + 31) / 32) * 4)

Definition at line 1999 of file nsWindow.cpp.

Definition at line 193 of file nsWindow.cpp.

Definition at line 194 of file nsWindow.cpp.

Definition at line 195 of file nsWindow.cpp.

Definition at line 196 of file nsWindow.cpp.

Definition at line 179 of file nsWindow.cpp.

Definition at line 180 of file nsWindow.cpp.

Definition at line 178 of file nsWindow.cpp.

Definition at line 182 of file nsWindow.cpp.

Definition at line 181 of file nsWindow.cpp.

Definition at line 177 of file nsWindow.cpp.

Definition at line 176 of file nsWindow.cpp.

Definition at line 175 of file nsWindow.cpp.

Definition at line 174 of file nsWindow.cpp.

#define FAPPCOMMAND_MASK   0xF000

Definition at line 198 of file nsWindow.cpp.

#define GET_APPCOMMAND_LPARAM (   lParam)    ((USHORT)(HIUSHORT(lParam) & ~FAPPCOMMAND_MASK))

Definition at line 199 of file nsWindow.cpp.

Definition at line 3688 of file nsWindow.cpp.

#define WM_APPCOMMAND   0x0319

Definition at line 191 of file nsWindow.cpp.

#define XFROMMP (   m)    (SHORT(LOUSHORT(m)))

Definition at line 144 of file nsWindow.cpp.

#define YFROMMP (   m)    (SHORT(HIUSHORT(m)))

Definition at line 145 of file nsWindow.cpp.


Function Documentation

BOOL bothFromSameWindow ( HWND  hwnd1,
HWND  hwnd2 
)

Definition at line 714 of file nsWindow.cpp.

{
  HWND hwnd1Chain = WinQueryWindow( hwnd1, QW_OWNER );
  if (!hwnd1Chain)
    hwnd1Chain = WinQueryWindow( hwnd1, QW_PARENT );
  HWND hwnd1GChain = WinQueryWindow( hwnd1Chain, QW_OWNER );
  if (!hwnd1GChain)
    hwnd1GChain = WinQueryWindow( hwnd1Chain, QW_PARENT );
  HWND hwnd2Chain = WinQueryWindow( hwnd2, QW_OWNER );
  if (!hwnd2Chain)
    hwnd2Chain = WinQueryWindow( hwnd2, QW_PARENT );
  HWND hwnd2GChain = WinQueryWindow( hwnd2Chain, QW_OWNER );
  if (!hwnd2GChain)
    hwnd2GChain = WinQueryWindow( hwnd2Chain, QW_PARENT );
  while( hwnd1GChain) {
    hwnd1 = hwnd1Chain;
    hwnd1Chain = hwnd1GChain;
    hwnd1GChain = WinQueryWindow( hwnd1Chain, QW_OWNER );
    if (!hwnd1GChain)
      hwnd1GChain = WinQueryWindow( hwnd1Chain, QW_PARENT );
  }
  while( hwnd2GChain) {
    hwnd2 = hwnd2Chain;
    hwnd2Chain = hwnd2GChain;
    hwnd2GChain = WinQueryWindow( hwnd2Chain, QW_OWNER );
    if (!hwnd2GChain)
      hwnd2GChain = WinQueryWindow( hwnd2Chain, QW_PARENT );
  }
  return (hwnd1 == hwnd2);
}

Here is the caller graph for this function:

MRESULT EXPENTRY fnwpNSWindow ( HWND  hwnd,
ULONG  msg,
MPARAM  mp1,
MPARAM  mp2 
)

Definition at line 750 of file nsWindow.cpp.

{
   MRESULT popupHandlingResult;
   if( nsWindow::DealWithPopups(msg, &popupHandlingResult) )
      return popupHandlingResult;

   // Get the nsWindow for this hwnd
   nsWindow *wnd = nsWindow::GetNSWindowPtr(hwnd);

   // check to see if we have a rollup listener registered
   if( nsnull != gRollupListener && nsnull != gRollupWidget) {
      if( msg == WM_ACTIVATE || msg == WM_BUTTON1DOWN ||
          msg == WM_BUTTON2DOWN || msg == WM_BUTTON3DOWN) {
      // Rollup if the event is outside the popup.
      PRBool rollup = !nsWindow::EventIsInsideWindow((nsWindow*)gRollupWidget);
      
      // If we're dealing with menus, we probably have submenus and we don't
      // want to rollup if the click is in a parent menu of the current submenu.
      if (rollup) {
        nsCOMPtr<nsIMenuRollup> menuRollup ( do_QueryInterface(gRollupListener) );
        if ( menuRollup ) {
          nsCOMPtr<nsISupportsArray> widgetChain;
          menuRollup->GetSubmenuWidgetChain ( getter_AddRefs(widgetChain) );
          if ( widgetChain ) {
            PRUint32 count = 0;
            widgetChain->Count(&count);
            for ( PRUint32 i = 0; i < count; ++i ) {
              nsCOMPtr<nsISupports> genericWidget;
              widgetChain->GetElementAt ( i, getter_AddRefs(genericWidget) );
              nsCOMPtr<nsIWidget> widget ( do_QueryInterface(genericWidget) );
              if ( widget ) {
                nsIWidget* temp = widget.get();
                if ( nsWindow::EventIsInsideWindow((nsWindow*)temp) ) {
                  rollup = PR_FALSE;
                  break;
                }
              }
            } // foreach parent menu widget
          }
        } // if rollup listener knows about menus
      }
      }
      else if( msg == WM_SETFOCUS) {
         if( !mp2 && 
             !bothFromSameWindow( ((nsWindow*)gRollupWidget)->GetMainWindow(), 
                                  (HWND)mp1) ) {
            gRollupListener->Rollup();
         }
      }
   }

   // Messages which get re-routed if their source was an nsWindow
   // (it's very bad to reroute messages whose source isn't an nsWindow,
   // listboxes with scrollbars for example would break)
   switch( msg)
   {
      case WM_CONTROL:
      case WM_HSCROLL:
      case WM_VSCROLL: // !! potential problems here if canvas children
      {
         // assume parent == owner, true for our creations
         HWND hwndChild = WinWindowFromID( hwnd, SHORT1FROMMP( mp1));
         if( hwndChild)
         {
            nsWindow *w = nsWindow::GetNSWindowPtr(hwndChild);
            if( w)
               wnd = w;
         }
         break;
      }
   }

    // hold on to the window for the life of this method, in case it gets
    // deleted during processing. yes, it's a double hack, since someWindow
    // is not really an interface.
    nsCOMPtr<nsISupports> kungFuDeathGrip;
    if (!wnd->mIsDestroying) // not if we're in the destructor!
      kungFuDeathGrip = do_QueryInterface((nsBaseWidget*)wnd);

   MRESULT mresult = 0;

   if (wnd)
   {
      if( PR_FALSE == wnd->ProcessMessage( msg, mp1, mp2, mresult) &&
          WinIsWindow( (HAB)0, hwnd) && wnd->GetPrevWP())
      {
         mresult = (wnd->GetPrevWP())( hwnd, msg, mp1, mp2);

      }
   }
   else
      /* erm */ mresult = WinDefWindowProc( hwnd, msg, mp1, mp2);

   return mresult;
}

Here is the call graph for this function:

static PCSZ GetNSWindowPropName ( ) [static]

Definition at line 626 of file nsWindow.cpp.

                                  {
  static ATOM atom = 0;

  // this is threadsafe, even without locking;
  // even if there's a race, GlobalAddAtom("nsWindowPtr")
  // will just return the same value
  if (!atom) {
    atom = WinAddAtom(WinQuerySystemAtomTable(), "nsWindowPtr");
  }
  return (PCSZ)atom;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRUint32 WMChar2KeyCode ( MPARAM  mp1,
MPARAM  mp2 
)

Definition at line 4046 of file nsWindow.cpp.

{
  PRUint32 rc = SHORT1FROMMP(mp2);  // character code
  PRUint32 rcmask = rc & 0x00FF;    // masked character code for key up events
  USHORT sc = CHAR4FROMMP(mp1);     // scan code
  USHORT flags = SHORT1FROMMP(mp1); // flag word

  // First check for characters.
  // This is complicated by keystrokes such as Ctrl+K not having the KC_CHAR
  // bit set, but thankfully they do have the character actually there.
  //
  // Assume that `if not vkey or deadkey or valid number then char'
  if (!(flags & (KC_VIRTUALKEY | KC_DEADKEY)) ||
      (rcmask >= '0' && rcmask <= '9' &&             // handle keys on Numpad, too,
       (isNumPadScanCode(sc) ? isNumlockOn : 1)) ) { // if NumLock is on
    if (flags & KC_KEYUP) { // On OS/2 the scancode is in the upper byte of
                            // usChar when KC_KEYUP is set so mask it off
      rc = rcmask;
    } else { // not KC_KEYUP
      if (! (flags & KC_CHAR)) {
        if ((flags & KC_ALT) || (flags & KC_CTRL))
          rc = rcmask;
        else
          rc = 0;
      }
    }

    if (rc < 0xFF) {
      if (rc >= 'a' && rc <= 'z') { // The DOM_VK are for upper case only so
                                    // if rc is lower case upper case it.
        rc = rc - 'a' + NS_VK_A;
      } else if (rc >= 'A' && rc <= 'Z') { // Upper case
        rc = rc - 'A' + NS_VK_A;
      } else if (rc >= '0' && rc <= '9') {
        // Number keys, including Numpad if NumLock is not set
        rc = rc - '0' + NS_VK_0;
      } else {
        /* For some characters, map the scan code to the NS_VK value */
        /* This only happens in the char case NOT the VK case! */
        switch (sc) {
          case 0x02: rc = NS_VK_1;             break;
          case 0x03: rc = NS_VK_2;             break;
          case 0x04: rc = NS_VK_3;             break;
          case 0x05: rc = NS_VK_4;             break;
          case 0x06: rc = NS_VK_5;             break;
          case 0x07: rc = NS_VK_6;             break;
          case 0x08: rc = NS_VK_7;             break;
          case 0x09: rc = NS_VK_8;             break;
          case 0x0A: rc = NS_VK_9;             break;
          case 0x0B: rc = NS_VK_0;             break;
          case 0x0D: rc = NS_VK_EQUALS;        break;
          case 0x1A: rc = NS_VK_OPEN_BRACKET;  break;
          case 0x1B: rc = NS_VK_CLOSE_BRACKET; break;
          case 0x27: rc = NS_VK_SEMICOLON;     break;
          case 0x28: rc = NS_VK_QUOTE;         break;
          case 0x29: rc = NS_VK_BACK_QUOTE;    break;
          case 0x2B: rc = NS_VK_BACK_SLASH;    break;
          case 0x33: rc = NS_VK_COMMA;         break;
          case 0x34: rc = NS_VK_PERIOD;        break;
          case 0x35: rc = NS_VK_SLASH;         break;
          case 0x37: rc = NS_VK_MULTIPLY;      break;
          case 0x4A: rc = NS_VK_SUBTRACT;      break;
          case 0x4C: rc = NS_VK_CLEAR;         break; // numeric case is handled above
          case 0x4E: rc = NS_VK_ADD;           break;
          case 0x5C: rc = NS_VK_DIVIDE;        break;
          default: break;
        } // switch
      } // else
    } // if (rc < 0xFF)
  } else if (flags & KC_VIRTUALKEY) {
    USHORT vk = SHORT2FROMMP(mp2);
    if (flags & KC_KEYUP) { // On OS/2 there are extraneous bits in the upper byte of
                            // usChar when KC_KEYUP is set so mask them off
      rc = rcmask;
    }
    if (isNumPadScanCode(sc) &&
        (((flags & KC_ALT) && (sc != PMSCAN_PADPERIOD)) ||
          ((flags & (KC_CHAR | KC_SHIFT)) == KC_CHAR)  ||
          ((flags & KC_KEYUP) && rc != 0) )) {
      CHAR numpadMap[] = {NS_VK_NUMPAD7, NS_VK_NUMPAD8, NS_VK_NUMPAD9, 0,
                          NS_VK_NUMPAD4, NS_VK_NUMPAD5, NS_VK_NUMPAD6, 0,
                          NS_VK_NUMPAD1, NS_VK_NUMPAD2, NS_VK_NUMPAD3,
                          NS_VK_NUMPAD0, NS_VK_DECIMAL};
      // If this is the Numpad must not return VK for ALT+Numpad or ALT+NumLock+Numpad
      // NumLock+Numpad is OK
      if (numpadMap[sc - PMSCAN_PAD7] != 0) { // not plus or minus on Numpad
        if (flags & KC_ALT ) // do not react on Alt plus ASCII-code sequences
          rc = 0;
        else
          rc = numpadMap[sc - PMSCAN_PAD7];
      } else {                                // plus or minus of Numpad
        rc = 0; // No virtual key for Alt+Numpad or NumLock+Numpad
      }
    } else if (!(flags & KC_CHAR) || isNumPadScanCode(sc) ||
               (vk == VK_BACKSPACE) || (vk == VK_TAB) || (vk == VK_BACKTAB) ||
               (vk == VK_ENTER) || (vk == VK_NEWLINE) || (vk == VK_SPACE)) {
      if (vk >= VK_F1 && vk <= VK_F24)
        rc = NS_VK_F1 + (vk - VK_F1);
      else switch (vk) {
        case VK_NUMLOCK:   rc = NS_VK_NUM_LOCK;    break;
        case VK_SCRLLOCK:  rc = NS_VK_SCROLL_LOCK; break;
        case VK_ESC:       rc = NS_VK_ESCAPE;      break; // NS_VK_CANCEL
        case VK_BACKSPACE: rc = NS_VK_BACK;        break;
        case VK_TAB:       rc = NS_VK_TAB;         break;
        case VK_BACKTAB:   rc = NS_VK_TAB;         break; // layout tests for isShift
        case VK_CLEAR:     rc = NS_VK_CLEAR;       break;
        case VK_NEWLINE:   rc = NS_VK_RETURN;      break;
        case VK_ENTER:     rc = NS_VK_RETURN;      break;
        case VK_SHIFT:     rc = NS_VK_SHIFT;       break;
        case VK_CTRL:      rc = NS_VK_CONTROL;     break;
        case VK_ALT:       rc = NS_VK_ALT;         break;
        case VK_PAUSE:     rc = NS_VK_PAUSE;       break;
        case VK_CAPSLOCK:  rc = NS_VK_CAPS_LOCK;   break;
        case VK_SPACE:     rc = NS_VK_SPACE;       break;
        case VK_PAGEUP:    rc = NS_VK_PAGE_UP;     break;
        case VK_PAGEDOWN:  rc = NS_VK_PAGE_DOWN;   break;
        case VK_END:       rc = NS_VK_END;         break;
        case VK_HOME:      rc = NS_VK_HOME;        break;
        case VK_LEFT:      rc = NS_VK_LEFT;        break;
        case VK_UP:        rc = NS_VK_UP;          break;
        case VK_RIGHT:     rc = NS_VK_RIGHT;       break;
        case VK_DOWN:      rc = NS_VK_DOWN;        break;
        case VK_PRINTSCRN: rc = NS_VK_PRINTSCREEN; break;
        case VK_INSERT:    rc = NS_VK_INSERT;      break;
        case VK_DELETE:    rc = NS_VK_DELETE;      break;
      } // switch
    }
  }

  return rc;
}

Here is the caller graph for this function:


Variable Documentation

PRUint32 gDragStatus = 0 [static]

Definition at line 185 of file nsWindow.cpp.

Definition at line 148 of file nsWindow.cpp.

PRBool gIsDBCS = PR_FALSE [static]

Definition at line 151 of file nsWindow.cpp.

Definition at line 150 of file nsWindow.cpp.

Definition at line 135 of file nsWindow.cpp.

Definition at line 136 of file nsWindow.cpp.

POINTS gLastButton1Down = {0,0} [static]

Definition at line 142 of file nsWindow.cpp.

Definition at line 156 of file nsWindow.cpp.

HPOINTER gPtrArray[IDC_COUNT] [static]

Definition at line 149 of file nsWindow.cpp.

Definition at line 132 of file nsWindow.cpp.

Definition at line 130 of file nsWindow.cpp.

Definition at line 131 of file nsWindow.cpp.

const char* sScreenManagerContractID = "@mozilla.org/gfx/screenmanager;1" [static]

Definition at line 100 of file nsWindow.cpp.