зеркало из https://github.com/mozilla/gecko-dev.git
Bug#126843
Occasionally unable to get Focues set to URL bar and other widgets fixes a long standing focus issue under the BeOS port r=arougthopher
This commit is contained in:
Родитель
af22bbd97f
Коммит
06abdde379
|
@ -80,6 +80,10 @@ static nsIRollupListener * gRollupListener = nsnull;
|
|||
static nsIWidget * gRollupWidget = nsnull;
|
||||
static PRBool gRollupConsumeRollupEvent = PR_FALSE;
|
||||
////////////////////////////////////////////////////
|
||||
// Focus tracking - static variable defintions
|
||||
////////////////////////////////////////////////////
|
||||
static PRBool gJustGotActivate = PR_FALSE;
|
||||
static PRBool gJustGotDeactivate = PR_FALSE;
|
||||
|
||||
static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
|
||||
|
||||
|
@ -98,7 +102,7 @@ nsWindow::nsWindow() : nsBaseWidget()
|
|||
mForeground = NS_RGB(0x00,0x00,0x00);
|
||||
mIsDestroying = PR_FALSE;
|
||||
mOnDestroyCalled = PR_FALSE;
|
||||
// mTooltip = NULL;
|
||||
// mTooltip = NULL;
|
||||
mPreferredWidth = 0;
|
||||
mPreferredHeight = 0;
|
||||
mFont = nsnull;
|
||||
|
@ -108,7 +112,7 @@ nsWindow::nsWindow() : nsBaseWidget()
|
|||
|
||||
mHitMenu = nsnull;
|
||||
mHitSubMenus = new nsVoidArray();
|
||||
// mVScrollbar = nsnull;
|
||||
// mVScrollbar = nsnull;
|
||||
|
||||
mWindowType = eWindowType_child;
|
||||
mBorderStyle = eBorderStyle_default;
|
||||
|
@ -527,10 +531,10 @@ nsresult nsWindow::StandardWindowCreate(nsIWidget *aParent,
|
|||
SetBorderStyle(aInitData->mBorderStyle);
|
||||
}
|
||||
|
||||
// NEED INPLEMENT
|
||||
// DWORD style = WindowStyle();
|
||||
// NEED INPLEMENT
|
||||
// DWORD extendedStyle = WindowExStyle();
|
||||
// NEED INPLEMENT
|
||||
// DWORD style = WindowStyle();
|
||||
// NEED INPLEMENT
|
||||
// DWORD extendedStyle = WindowExStyle();
|
||||
|
||||
mBorderlessParent = NULL;
|
||||
if (mWindowType == eWindowType_popup)
|
||||
|
@ -544,19 +548,19 @@ nsresult nsWindow::StandardWindowCreate(nsIWidget *aParent,
|
|||
// See if the caller wants to explictly set clip children and clip siblings
|
||||
if (aInitData->clipChildren)
|
||||
{
|
||||
// NEED INPLEMENT
|
||||
// style |= WS_CLIPCHILDREN;
|
||||
// NEED INPLEMENT
|
||||
// style |= WS_CLIPCHILDREN;
|
||||
}
|
||||
else
|
||||
{
|
||||
// NEED INPLEMENT
|
||||
// style &= ~WS_CLIPCHILDREN;
|
||||
// NEED INPLEMENT
|
||||
// style &= ~WS_CLIPCHILDREN;
|
||||
}
|
||||
|
||||
if (aInitData->clipSiblings)
|
||||
{
|
||||
// NEED INPLEMENT
|
||||
// style |= WS_CLIPSIBLINGS;
|
||||
// NEED INPLEMENT
|
||||
// style |= WS_CLIPSIBLINGS;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1190,7 +1194,6 @@ NS_METHOD nsWindow::SetFocus(PRBool aRaise)
|
|||
toolkit->CallMethod(&info);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if(mView && mView->LockLooper())
|
||||
{
|
||||
mView->MakeFocus(true);
|
||||
|
@ -1542,7 +1545,7 @@ void* nsWindow::GetNativeData(PRUint32 aDataType)
|
|||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsWindow::SetColorMap(nsColorMap *aColorMap)
|
||||
{
|
||||
NS_WARNING("nsWindow::SetColorMap - not implemented");
|
||||
NS_WARNING("nsWindow::SetColorMap - not implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1663,21 +1666,23 @@ bool nsWindow::CallMethod(MethodInfo *info)
|
|||
break;
|
||||
|
||||
case nsWindow::GOT_FOCUS:
|
||||
NS_ASSERTION(info->nArgs == 0, "Wrong number of arguments to CallMethod");
|
||||
NS_ASSERTION(info->nArgs == 1, "Wrong number of arguments to CallMethod");
|
||||
DispatchFocus(NS_GOTFOCUS);
|
||||
//if(gJustGotActivate) {
|
||||
// gJustGotActivate = PR_FALSE;
|
||||
if(gJustGotActivate)
|
||||
{
|
||||
gJustGotActivate = PR_FALSE;
|
||||
DispatchFocus(NS_ACTIVATE);
|
||||
//}
|
||||
}
|
||||
break;
|
||||
|
||||
case nsWindow::KILL_FOCUS:
|
||||
NS_ASSERTION(info->nArgs == 0, "Wrong number of arguments to CallMethod");
|
||||
DispatchFocus(NS_LOSTFOCUS);
|
||||
//if(gJustGotDeactivate) {
|
||||
// gJustGotDeactivate = PR_FALSE;
|
||||
NS_ASSERTION(info->nArgs == 1, "Wrong number of arguments to CallMethod");
|
||||
if(gJustGotDeactivate)
|
||||
{
|
||||
gJustGotDeactivate = PR_FALSE;
|
||||
DispatchFocus(NS_DEACTIVATE);
|
||||
//}
|
||||
}
|
||||
DispatchFocus(NS_LOSTFOCUS);
|
||||
break;
|
||||
|
||||
case nsWindow::ONMOUSE :
|
||||
|
@ -1694,6 +1699,8 @@ bool nsWindow::CallMethod(MethodInfo *info)
|
|||
{
|
||||
BPoint p(((int32 *)info->args)[1], ((int32 *)info->args)[2]);
|
||||
mView->ConvertToScreen(&p);
|
||||
//DispatchFocus(NS_GOTFOCUS);//workaround for focus
|
||||
DispatchFocus(NS_ACTIVATE);//in password dialog
|
||||
if (DealWithPopups(nsWindow::ONMOUSE, nsPoint(p.x, p.y)))
|
||||
rollup = true;
|
||||
mView->UnlockLooper();
|
||||
|
@ -1807,6 +1814,24 @@ bool nsWindow::CallMethod(MethodInfo *info)
|
|||
((int32 *)info->args)[4]);
|
||||
break;
|
||||
|
||||
case nsWindow::ONACTIVATE:
|
||||
NS_ASSERTION(info->nArgs == 4, "Wrong number of arguments to CallMethod");
|
||||
if (*mEventCallback)
|
||||
{
|
||||
bool active = (bool)info->args[2];
|
||||
if(!active)
|
||||
{
|
||||
gJustGotDeactivate = PR_TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
gJustGotActivate = PR_TRUE;
|
||||
if(mWindowType == eWindowType_dialog)
|
||||
SetFocus(PR_TRUE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
bRet = FALSE;
|
||||
break;
|
||||
|
@ -1833,11 +1858,11 @@ struct nsKeyConverter {
|
|||
//
|
||||
|
||||
struct nsKeyConverter nsKeycodesBeOS[] = {
|
||||
// { NS_VK_CANCEL, GDK_Cancel },
|
||||
// { NS_VK_CANCEL, GDK_Cancel },
|
||||
{ NS_VK_BACK, 0x1e },
|
||||
{ NS_VK_TAB, 0x26 },
|
||||
// { NS_VK_TAB, GDK_ISO_Left_Tab },
|
||||
// { NS_VK_CLEAR, GDK_Clear },
|
||||
// { NS_VK_TAB, GDK_ISO_Left_Tab },
|
||||
// { NS_VK_CLEAR, GDK_Clear },
|
||||
{ NS_VK_RETURN, 0x47 },
|
||||
{ NS_VK_SHIFT, 0x4b },
|
||||
{ NS_VK_SHIFT, 0x56 },
|
||||
|
@ -1864,7 +1889,7 @@ struct nsKeyConverter nsKeycodesBeOS[] = {
|
|||
// keypad keys (constant keys)
|
||||
{ NS_VK_MULTIPLY, 0x24 },
|
||||
{ NS_VK_ADD, 0x3a },
|
||||
// { NS_VK_SEPARATOR, }, ???
|
||||
// { NS_VK_SEPARATOR, }, ???
|
||||
{ NS_VK_SUBTRACT, 0x25 },
|
||||
{ NS_VK_DIVIDE, 0x23 },
|
||||
{ NS_VK_RETURN, 0x5b },
|
||||
|
@ -1936,7 +1961,7 @@ struct nsKeyConverter nsKeycodesBeOS[] = {
|
|||
{ NS_VK_X, 0x4d },
|
||||
{ NS_VK_Y, 0x2c },
|
||||
{ NS_VK_Z, 0x4c }
|
||||
};
|
||||
};
|
||||
|
||||
// keycode of keypad when num-locked
|
||||
struct nsKeyConverter nsKeycodesBeOSNumLock[] = {
|
||||
|
@ -1951,7 +1976,7 @@ struct nsKeyConverter nsKeycodesBeOSNumLock[] = {
|
|||
{ NS_VK_NUMPAD8, 0x38 },
|
||||
{ NS_VK_NUMPAD9, 0x39 },
|
||||
{ NS_VK_DECIMAL, 0x65 }
|
||||
};
|
||||
};
|
||||
|
||||
// keycode of keypad when not num-locked
|
||||
struct nsKeyConverter nsKeycodesBeOSNoNumLock[] = {
|
||||
|
@ -1965,7 +1990,7 @@ struct nsKeyConverter nsKeycodesBeOSNoNumLock[] = {
|
|||
{ NS_VK_END, 0x58 },
|
||||
{ NS_VK_INSERT, 0x64 },
|
||||
{ NS_VK_DELETE, 0x65 }
|
||||
};
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
|
@ -1976,7 +2001,7 @@ struct nsKeyConverter nsKeycodesBeOSNoNumLock[] = {
|
|||
|
||||
static int TranslateBeOSKeyCode(int32 bekeycode, bool isnumlock)
|
||||
{
|
||||
//printf("bekeycode=%x\n",bekeycode);
|
||||
//printf("bekeycode=%x\n",bekeycode);
|
||||
int i;
|
||||
int length = sizeof(nsKeycodesBeOS) / sizeof(struct nsKeyConverter);
|
||||
int length_numlock = sizeof(nsKeycodesBeOSNumLock) / sizeof(struct nsKeyConverter);
|
||||
|
@ -2027,7 +2052,7 @@ PRBool nsWindow::OnKeyDown(PRUint32 aEventType, const char *bytes,
|
|||
// non ASCII chars
|
||||
}
|
||||
|
||||
// ------------ On Char ------------
|
||||
// ------------ On Char ------------
|
||||
PRUint32 uniChar;
|
||||
|
||||
if ((mIsControlDown || mIsAltDown) && rawcode >= 'a' && rawcode <= 'z') {
|
||||
|
@ -2686,12 +2711,12 @@ NS_METHOD nsWindow::SetMenuBar(nsIMenuBar * aMenuBar)
|
|||
if(mMenuBar)
|
||||
{
|
||||
// Get rid of the old menubar
|
||||
NS_WARNING("nsWindow::SetMenuBar - FIXME: Get rid of the old menubar!");
|
||||
// GtkWidget* oldMenuBar;
|
||||
// mMenuBar->GetNativeData((void*&) oldMenuBar);
|
||||
// if (oldMenuBar) {
|
||||
// gtk_container_remove(GTK_CONTAINER(mVBox), oldMenuBar);
|
||||
// }
|
||||
NS_WARNING("nsWindow::SetMenuBar - FIXME: Get rid of the old menubar!");
|
||||
// GtkWidget* oldMenuBar;
|
||||
// mMenuBar->GetNativeData((void*&) oldMenuBar);
|
||||
// if (oldMenuBar) {
|
||||
// gtk_container_remove(GTK_CONTAINER(mVBox), oldMenuBar);
|
||||
// }
|
||||
NS_RELEASE(mMenuBar);
|
||||
}
|
||||
|
||||
|
@ -2727,21 +2752,21 @@ NS_WARNING("nsWindow::SetMenuBar - FIXME: Get rid of the old menubar!");
|
|||
|
||||
NS_METHOD nsWindow::ShowMenuBar(PRBool aShow)
|
||||
{
|
||||
NS_WARNING("nsWindow::ShowMenuBar - FIXME: not implemented!");
|
||||
// if (!mMenuBar)
|
||||
// // return NS_ERROR_FAILURE;
|
||||
// return NS_OK;
|
||||
//
|
||||
// GtkWidget *menubar;
|
||||
// void *voidData;
|
||||
// mMenuBar->GetNativeData(voidData);
|
||||
// menubar = GTK_WIDGET(voidData);
|
||||
//
|
||||
// if (aShow == PR_TRUE)
|
||||
// gtk_widget_show(menubar);
|
||||
// else
|
||||
// gtk_widget_hide(menubar);
|
||||
//
|
||||
NS_WARNING("nsWindow::ShowMenuBar - FIXME: not implemented!");
|
||||
// if (!mMenuBar)
|
||||
// // return NS_ERROR_FAILURE;
|
||||
// return NS_OK;
|
||||
//
|
||||
// GtkWidget *menubar;
|
||||
// void *voidData;
|
||||
// mMenuBar->GetNativeData(voidData);
|
||||
// menubar = GTK_WIDGET(voidData);
|
||||
//
|
||||
// if (aShow == PR_TRUE)
|
||||
// gtk_widget_show(menubar);
|
||||
// else
|
||||
// gtk_widget_hide(menubar);
|
||||
//
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -2765,17 +2790,17 @@ NS_METHOD nsWindow::SetPreferredSize(PRInt32 aWidth, PRInt32 aHeight)
|
|||
nsIWidgetStore::nsIWidgetStore( nsIWidget *aWidget )
|
||||
: mWidget( aWidget )
|
||||
{
|
||||
// NS_ADDREF/NS_RELEASE is not needed here.
|
||||
// This class is used as internal (BeOS native) object of nsWindow,
|
||||
// so it must not addref/release nsWindow here.
|
||||
// Otherwise, nsWindow object will leak. (Makoto Hamanaka)
|
||||
// NS_ADDREF/NS_RELEASE is not needed here.
|
||||
// This class is used as internal (BeOS native) object of nsWindow,
|
||||
// so it must not addref/release nsWindow here.
|
||||
// Otherwise, nsWindow object will leak. (Makoto Hamanaka)
|
||||
|
||||
// NS_ADDREF(mWidget);
|
||||
// NS_ADDREF(mWidget);
|
||||
}
|
||||
|
||||
nsIWidgetStore::~nsIWidgetStore()
|
||||
{
|
||||
// NS_RELEASE(mWidget);
|
||||
// NS_RELEASE(mWidget);
|
||||
}
|
||||
|
||||
nsIWidget *nsIWidgetStore::GetMozillaWidget(void)
|
||||
|
@ -2931,7 +2956,29 @@ void nsWindowBeOS::DoFrameResized()
|
|||
NS_RELEASE(t);
|
||||
}
|
||||
}
|
||||
|
||||
void nsWindowBeOS::WindowActivated(bool active)
|
||||
{
|
||||
// Calls method ONACTIVATE to handle gJustGotActivated | gJustGotDeactivated
|
||||
uint32 btn, clicks = 0;
|
||||
BPoint point;
|
||||
nsWindow *w = (nsWindow *)GetMozillaWidget();
|
||||
nsToolkit *t;
|
||||
t = w->GetToolkit();
|
||||
if(w && t!= 0)
|
||||
{
|
||||
{
|
||||
uint32 args[4];
|
||||
args[0] = (uint32)point.x;
|
||||
args[1] = (uint32)point.y;
|
||||
args[2] = (uint32)active;
|
||||
args[3] = (uint32)w;
|
||||
MethodInfo *info =
|
||||
new MethodInfo(w, w, nsWindow::ONACTIVATE, 3, args);
|
||||
t->CallMethodAsync(info);
|
||||
}
|
||||
NS_RELEASE(t);
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------
|
||||
// BeOS Sub-Class View
|
||||
//----------------------------------------------------
|
||||
|
@ -3183,17 +3230,16 @@ void nsViewBeOS::KeyUp(const char *bytes, int32 numBytes)
|
|||
|
||||
void nsViewBeOS::MakeFocus(bool focused)
|
||||
{
|
||||
//printf("MakeFocus %s\n",(focused)?"get":"lost");
|
||||
if (IsFocus()) return;
|
||||
|
||||
|
||||
if (!IsFocus() && focused)
|
||||
BView::MakeFocus(focused);
|
||||
|
||||
nsWindow *w = (nsWindow *)GetMozillaWidget();
|
||||
nsToolkit *t;
|
||||
if(w && (t = w->GetToolkit()) != 0)
|
||||
{
|
||||
MethodInfo *info = new MethodInfo(w, w, (focused)? nsWindow::GOT_FOCUS : nsWindow::KILL_FOCUS);
|
||||
uint32 args[1];
|
||||
args[0]=(uint32)Window();
|
||||
MethodInfo *info = new MethodInfo(w, w, (focused)? nsWindow::GOT_FOCUS : nsWindow::KILL_FOCUS,1,args);
|
||||
t->CallMethodAsync(info);
|
||||
NS_RELEASE(t);
|
||||
}
|
||||
|
|
|
@ -262,7 +262,8 @@ public: // public on BeOS to allow BViews to access it
|
|||
CLOSEWINDOW,
|
||||
MENU,
|
||||
ONKEY,
|
||||
BTNCLICK
|
||||
BTNCLICK,
|
||||
ONACTIVATE
|
||||
};
|
||||
nsToolkit *GetToolkit() { return (nsToolkit *)nsBaseWidget::GetToolkit(); }
|
||||
};
|
||||
|
@ -293,6 +294,7 @@ class nsWindowBeOS : public BWindow, public nsIWidgetStore {
|
|||
virtual bool QuitRequested( void );
|
||||
virtual void MessageReceived(BMessage *msg);
|
||||
virtual void DispatchMessage(BMessage *msg, BHandler *handler);
|
||||
virtual void WindowActivated(bool active);
|
||||
virtual void FrameResized(float width, float height);
|
||||
|
||||
void ResizeToWithoutEvent(float width, float height);
|
||||
|
|
Загрузка…
Ссылка в новой задаче