diff --git a/mozilla/widget/src/os2/nsWindow.cpp b/mozilla/widget/src/os2/nsWindow.cpp index 37be4363d51..b85efd12639 100644 --- a/mozilla/widget/src/os2/nsWindow.cpp +++ b/mozilla/widget/src/os2/nsWindow.cpp @@ -21,6 +21,7 @@ * Pierre Phaneuf * IBM Corp. * Rich Walsh + * Dainis Jonitis * */ @@ -168,6 +169,20 @@ static int currentWindowIdentifier = 0; // set when any nsWindow is being dragged over static PRUint32 gDragStatus = 0; + +// +// App Command messages for IntelliMouse and Natural Keyboard Pro +// +#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)) + //------------------------------------------------------------------------- // // nsWindow constructor @@ -502,6 +517,24 @@ PRBool nsWindow::DispatchStandardEvent(PRUint32 aMsg) return result; } +//------------------------------------------------------------------------- +// +// Dispatch app command event +// +//------------------------------------------------------------------------- +PRBool nsWindow::DispatchAppCommandEvent(PRUint32 aEventCommand) +{ + nsAppCommandEvent event(NS_APPCOMMAND_START, this); + + InitEvent(event); + event.appCommand = NS_APPCOMMAND_START + aEventCommand; + + DispatchWindowEvent(&event); + NS_RELEASE(event.widget); + + return NS_OK; +} + //------------------------------------------------------------------------- NS_IMETHODIMP nsWindow::CaptureRollupEvents(nsIRollupListener * aListener, PRBool aDoCapture, @@ -2568,6 +2601,30 @@ PRBool nsWindow::ProcessMessage( ULONG msg, MPARAM mp1, MPARAM mp2, MRESULT &rc) case WM_MOUSELEAVE: result = DispatchMouseEvent( NS_MOUSE_EXIT, mp1, mp2); break; + + case WM_APPCOMMAND: + { + PRUint32 appCommand = GET_APPCOMMAND_LPARAM(mp2); + + switch (appCommand) + { + case APPCOMMAND_BROWSER_BACKWARD: + case APPCOMMAND_BROWSER_FORWARD: + case APPCOMMAND_BROWSER_REFRESH: + case APPCOMMAND_BROWSER_STOP: + DispatchAppCommandEvent(appCommand); + // tell the driver that we handled the event + rc = (MRESULT)1; + result = PR_TRUE; + break; + + default: + rc = (MRESULT)0; + result = PR_FALSE; + break; + } + break; + } case WM_HSCROLL: case WM_VSCROLL: diff --git a/mozilla/widget/src/os2/nsWindow.h b/mozilla/widget/src/os2/nsWindow.h index ff5aabce62d..d45650e7290 100644 --- a/mozilla/widget/src/os2/nsWindow.h +++ b/mozilla/widget/src/os2/nsWindow.h @@ -291,6 +291,7 @@ protected: virtual PRBool DispatchWindowEvent(nsGUIEvent* event); virtual PRBool DispatchWindowEvent(nsGUIEvent*event, nsEventStatus &aStatus); PRBool DispatchStandardEvent( PRUint32 aMsg); + PRBool DispatchAppCommandEvent(PRUint32 aEventCommand); virtual PRBool DispatchMouseEvent( PRUint32 aEventType, MPARAM mp1, MPARAM mp2); virtual PRBool DispatchResizeEvent( PRInt32 aClientX, PRInt32 aClientY); void GetNonClientBounds(nsRect &aRect);