diff --git a/widget/src/motif/nsTextWidget.cpp b/widget/src/motif/nsTextWidget.cpp index 4f866543e7e7..784d356e4b4b 100644 --- a/widget/src/motif/nsTextWidget.cpp +++ b/widget/src/motif/nsTextWidget.cpp @@ -90,6 +90,16 @@ void nsTextWidget::Create(nsIWidget *aParent, InitCallbacks("nsTextWidget"); + XtAddCallback(mWidget, + XmNfocusCallback, + nsXtWidget_Focus_Callback, + this); + + XtAddCallback(mWidget, + XmNlosingFocusCallback, + nsXtWidget_Focus_Callback, + this); + if (mMakeReadOnly) { SetReadOnly(PR_TRUE); } diff --git a/widget/src/motif/nsWindow.cpp b/widget/src/motif/nsWindow.cpp index ac76ab53fb2b..dafdf20811ea 100644 --- a/widget/src/motif/nsWindow.cpp +++ b/widget/src/motif/nsWindow.cpp @@ -351,7 +351,6 @@ void nsWindow::CreateWindow(nsNativeWidget aNativeParent, this); - /*XtAddCallback(mWidget, XmNexposeCallback, nsXtWidget_Expose_Callback, @@ -435,6 +434,7 @@ void nsWindow::InitCallbacks(char * aName) nsXtWidget_ExposureMask_EventHandler, this); + /*XtAddEventHandler(mWidget, ResizeRedirectMask, PR_FALSE, @@ -706,6 +706,7 @@ nscolor nsWindow::GetBackgroundColor(void) void nsWindow::SetBackgroundColor(const nscolor &aColor) { mBackground = aColor ; + //XtVaSetValues(mWidget, } @@ -781,6 +782,28 @@ void nsWindow::SetCursor(nsCursor aCursor) //------------------------------------------------------------------------- void nsWindow::Invalidate(PRBool aIsSynchronous) { + if (mWidget == nsnull) { + return; + } + + Window win = XtWindow(mWidget); + Display *display = XtDisplay(mWidget); + + + XEvent evt; + evt.xgraphicsexpose.type = GraphicsExpose; + evt.xgraphicsexpose.send_event = False; + evt.xgraphicsexpose.display = display; + evt.xgraphicsexpose.drawable = win; + evt.xgraphicsexpose.x = 0; + evt.xgraphicsexpose.y = 0; + evt.xgraphicsexpose.width = mBounds.width; + evt.xgraphicsexpose.height = mBounds.height; + evt.xgraphicsexpose.count = 0; + XSendEvent(display, win, False, ExposureMask, &evt); + XFlush(display); + + } @@ -1120,8 +1143,12 @@ PRBool nsWindow::OnKey(PRUint32 aEventType, PRUint32 aKeyCode) } -PRBool nsWindow::DispatchFocus(PRUint32 aEventType) +PRBool nsWindow::DispatchFocus(nsGUIEvent &aEvent) { + if (mEventCallback) { + return(DispatchEvent(&aEvent)); + } + return FALSE; } diff --git a/widget/src/motif/nsWindow.h b/widget/src/motif/nsWindow.h index 287fe14667c5..cb589d56cfed 100644 --- a/widget/src/motif/nsWindow.h +++ b/widget/src/motif/nsWindow.h @@ -120,7 +120,7 @@ public: virtual PRBool OnResize(nsSizeEvent &aEvent); virtual PRBool OnKey(PRUint32 aEventType, PRUint32 aKeyCode); - virtual PRBool DispatchFocus(PRUint32 aEventType); + virtual PRBool DispatchFocus(nsGUIEvent &aEvent); virtual PRBool OnScroll(nsScrollbarEvent & aEvent, PRUint32 cPos); virtual void SetIgnoreResize(PRBool aIgnore); @@ -274,7 +274,7 @@ public: \ virtual PRBool OnPaint(nsPaintEvent & event); \ virtual PRBool OnResize(nsSizeEvent &aEvent); \ virtual PRBool OnKey(PRUint32 aEventType, PRUint32 aKeyCode); \ - virtual PRBool DispatchFocus(PRUint32 aEventType); \ + virtual PRBool DispatchFocus(nsGUIEvent &aEvent); \ virtual PRBool OnScroll(nsScrollbarEvent & aEvent, PRUint32 cPos); @@ -495,9 +495,9 @@ public: \ { \ return GET_OUTER()->OnKey(aEventType, aKeyCode); \ } \ - PRBool _classname::_aggname::DispatchFocus(PRUint32 aEventType) \ + PRBool _classname::_aggname::DispatchFocus(nsGUIEvent &aEvent) \ { \ - return GET_OUTER()->DispatchFocus(aEventType); \ + return GET_OUTER()->DispatchFocus(aEvent); \ } \ PRBool _classname::_aggname::OnScroll(nsScrollbarEvent & aEvent, PRUint32 cPos) \ { \ diff --git a/widget/src/motif/nsXtEventHandler.cpp b/widget/src/motif/nsXtEventHandler.cpp index d3908d3c7fc2..21518f1b3cda 100644 --- a/widget/src/motif/nsXtEventHandler.cpp +++ b/widget/src/motif/nsXtEventHandler.cpp @@ -93,7 +93,7 @@ typedef struct COLLAPSE_INFO { //============================================================== static void expandDamageRect(nsRect *drect, XEvent *xev, Boolean debug, char*str) { - int x1 = xev->xexpose.x; +/* int x1 = xev->xexpose.x; int y1 = xev->xexpose.y; int x2 = x1 + xev->xexpose.width; int y2 = y1 + xev->xexpose.height; @@ -112,7 +112,7 @@ static void expandDamageRect(nsRect *drect, XEvent *xev, Boolean debug, char*str if (debug) { printf("(%d,%d %dx%d) %s\n", drect->x, drect->y, drect->width - drect->x, drect->height - drect->y); - } + }*/ } //============================================================== @@ -309,6 +309,20 @@ void nsXtWidget_LeaveMask_EventHandler(Widget w, XtPointer p, XEvent * event, Bo widgetWindow->DispatchMouseEvent(mevent); } +//============================================================== +void nsXtWidget_Focus_Callback(Widget w, XtPointer p, XtPointer call_data) +{ + nsWindow * widgetWindow = (nsWindow *) p ; + + XmAnyCallbackStruct * cbs = (XmAnyCallbackStruct*)call_data; + + nsGUIEvent event; + nsXtWidget_InitNSEvent(cbs->event, p, event, + cbs->reason == XmCR_FOCUS?NS_GOTFOCUS:NS_LOSTFOCUS); + widgetWindow->DispatchFocus(event); + +} + //============================================================== void nsXtWidget_Toggle_Callback(Widget w, XtPointer p, XtPointer call_data) { @@ -595,7 +609,7 @@ void nsXtWidget_Resize_Callback(Widget w, XtPointer p, XtPointer call_data) if (! widgetWindow->GetResized()) { - printf("Adding timeout for %d\n", widgetWindow); + //printf("Adding timeout for %d\n", widgetWindow); XtAppAddTimeOut(gAppContext, 250, (XtTimerCallbackProc)nsXtWidget_Refresh_Callback, widgetWindow); } @@ -620,7 +634,6 @@ void nsXtWidget_Text_Callback(Widget w, XtPointer p, XtPointer call_data) { if (DBG) fprintf(stderr, "In nsXtWidget_Text_Callback\n"); nsWindow * widgetWindow = (nsWindow *) p ; - char * newStr; int len; XmTextVerifyCallbackStruct *cbs = (XmTextVerifyCallbackStruct *) call_data; @@ -636,8 +649,8 @@ void nsXtWidget_Text_Callback(Widget w, XtPointer p, XtPointer call_data) return; } - printf("start %d insert %d len %d end %d ptr [%s]\n", - cbs->startPos, cbs->currInsert, cbs->text->length, cbs->endPos, cbs->text->ptr); + //printf("start %d insert %d len %d end %d ptr [%s]\n", + //cbs->startPos, cbs->currInsert, cbs->text->length, cbs->endPos, cbs->text->ptr); if (cbs->startPos < cbs->currInsert) { /* backspace */ cbs->endPos = data->mPassword.Length(); /* delete from here to end */ @@ -652,7 +665,7 @@ void nsXtWidget_Text_Callback(Widget w, XtPointer p, XtPointer call_data) //} if (cbs->startPos == cbs->currInsert && cbs->currInsert < data->mPassword.Length()) { - printf("Inserting [%s] at %d\n", cbs->text->ptr, cbs->currInsert); + //printf("Inserting [%s] at %d\n", cbs->text->ptr, cbs->currInsert); nsString insStr(cbs->text->ptr); data->mPassword.Insert(insStr, cbs->currInsert, strlen(cbs->text->ptr)); } else if (cbs->startPos == cbs->currInsert && cbs->endPos != cbs->startPos) { @@ -660,7 +673,7 @@ void nsXtWidget_Text_Callback(Widget w, XtPointer p, XtPointer call_data) printf("Setting Length [%s] at %d\n", cbs->text->ptr, cbs->currInsert); } else if (cbs->startPos == cbs->currInsert) { /* backspace */ data->mPassword.Append(cbs->text->ptr); - printf("Appending [%s] at %d\n", cbs->text->ptr, cbs->currInsert); + //printf("Appending [%s] at %d\n", cbs->text->ptr, cbs->currInsert); } else { printf("Shouldn't be here!\n"); } diff --git a/widget/src/motif/nsXtEventHandler.h b/widget/src/motif/nsXtEventHandler.h index 466ac77d9b0f..630823d1e6d7 100644 --- a/widget/src/motif/nsXtEventHandler.h +++ b/widget/src/motif/nsXtEventHandler.h @@ -34,6 +34,7 @@ void nsXtWidget_FSBCancel_Callback(Widget w, XtPointer p, XtPointer call_data); void nsXtWidget_FSBOk_Callback(Widget w, XtPointer p, XtPointer call_data); //---------------------------------------------------- +void nsXtWidget_Focus_Callback(Widget w, XtPointer p, XtPointer call_data); void nsXtWidget_Scrollbar_Callback(Widget w, XtPointer p, XtPointer call_data); void nsXtWidget_Toggle_Callback(Widget w, XtPointer p, XtPointer call_data); void nsXtWidget_Toggle_ArmCallback(Widget w, XtPointer p, XtPointer call_data);