[BeOS]Bug 315726, avoid mistargeted focus messages, p=sergei_d, r=thesuckiestemail@yahoo.se, BeOS-only, no need for sr

This commit is contained in:
sergei_d%fi.tartu.ee 2005-11-10 19:54:23 +00:00
Родитель b5a5baab8e
Коммит b3dc7f068e
1 изменённых файлов: 29 добавлений и 8 удалений

Просмотреть файл

@ -1308,6 +1308,7 @@ NS_METHOD nsWindow::SetFocus(PRBool aRaise)
mView->MakeFocus(true); mView->MakeFocus(true);
mView->UnlockLooper(); mView->UnlockLooper();
DispatchFocus(NS_GOTFOCUS);
} }
return NS_OK; return NS_OK;
@ -1913,16 +1914,23 @@ bool nsWindow::CallMethod(MethodInfo *info)
SetFocus(((PRBool *)info->args)[0]); SetFocus(((PRBool *)info->args)[0]);
break; break;
#ifdef DEBUG_FOCUS
case nsWindow::GOT_FOCUS: 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");
if (!mEnabled) if (!mEnabled)
return false; return false;
DispatchFocus(NS_GOTFOCUS); if ((uint32)info->args[0] != (uint32)mView)
printf("Wrong view to get focus\n");*/
break; break;
#endif
case nsWindow::KILL_FOCUS: case nsWindow::KILL_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_LOSTFOCUS); if ((uint32)info->args[0] == (uint32)mView)
DispatchFocus(NS_LOSTFOCUS);
#ifdef DEBUG_FOCUS
else
printf("Wrong view to de-focus\n");
#endif
#if defined BeIME #if defined BeIME
nsIMEBeOS::GetIME()->DispatchCancelIME(); nsIMEBeOS::GetIME()->DispatchCancelIME();
if (mView && mView->LockLooper()) if (mView && mView->LockLooper())
@ -3278,18 +3286,31 @@ void nsViewBeOS::MakeFocus(bool focused)
{ {
if (!IsFocus() && focused) if (!IsFocus() && focused)
BView::MakeFocus(focused); BView::MakeFocus(focused);
uint32 args[1];
args[0] = (uint32)this;
nsWindow *w = (nsWindow *)GetMozillaWidget(); nsWindow *w = (nsWindow *)GetMozillaWidget();
nsToolkit *t; nsToolkit *t;
if (w && (t = w->GetToolkit()) != 0) if (w && (t = w->GetToolkit()) != 0)
{ {
MethodInfo *info = nsnull; MethodInfo *info = nsnull;
if (nsnull != (info = new MethodInfo(w, w, (focused)? nsWindow::GOT_FOCUS : nsWindow::KILL_FOCUS))) if (!focused)
t->CallMethodAsync(info); {
if (nsnull != (info = new MethodInfo(w, w, nsWindow::KILL_FOCUS),1,args))
t->CallMethodAsync(info);
}
#ifdef DEBUG_FOCUS
else
{
if (nsnull != (info = new MethodInfo(w, w, nsWindow::GOT_FOCUS),1,args))
t->CallMethodAsync(info);
}
#endif
NS_RELEASE(t); NS_RELEASE(t);
} }
} }
#if defined(BeIME) #if defined(BeIME)
// Inline Input Method implementation
void nsViewBeOS::DoIME(BMessage *msg) void nsViewBeOS::DoIME(BMessage *msg)
{ {
nsWindow *w = (nsWindow *)GetMozillaWidget(); nsWindow *w = (nsWindow *)GetMozillaWidget();