зеркало из https://github.com/mozilla/gecko-dev.git
bug 110411
XIM performance improvement for over-the-spot mode avoid unnecessary calls for over-the-spot r=pavlov, sr=blizzard
This commit is contained in:
Родитель
7fe1a20d15
Коммит
8255228076
|
@ -1021,9 +1021,15 @@ nsIMEGtkIC::SetFocusWindow(nsWindow * aFocusWindow)
|
|||
gdk_im_begin((GdkIC *) mIC, gdkWindow);
|
||||
|
||||
if (mInputStyle & GDK_IM_PREEDIT_POSITION) {
|
||||
SetPreeditArea(0, 0,
|
||||
(int)((GdkWindowPrivate*)gdkWindow)->width,
|
||||
(int)((GdkWindowPrivate*)gdkWindow)->height);
|
||||
static int oldw=0;
|
||||
static int oldh=0;
|
||||
int neww=(int)((GdkWindowPrivate*)gdkWindow)->width;
|
||||
int newh=(int)((GdkWindowPrivate*)gdkWindow)->height;
|
||||
if (oldw != neww || oldh != newh) {
|
||||
SetPreeditArea(0, 0, neww, newh);
|
||||
oldw = neww;
|
||||
oldh = newh;
|
||||
}
|
||||
}
|
||||
|
||||
if (mInputStyle & GDK_IM_STATUS_CALLBACKS) {
|
||||
|
@ -1334,20 +1340,6 @@ nsIMEGtkIC::IsPreeditComposing()
|
|||
return PR_TRUE;
|
||||
}
|
||||
|
||||
GdkFont*
|
||||
nsIMEGtkIC::GetPreeditFont() {
|
||||
mIC->mask = GDK_IC_PREEDIT_FONTSET; // hack
|
||||
GdkFont *fontset = 0;
|
||||
GdkICAttr *attr = gdk_ic_attr_new();
|
||||
if (attr) {
|
||||
GdkICAttributesType attrMask = GDK_IC_PREEDIT_FONTSET;
|
||||
gdk_ic_get_attr((GdkIC*)mIC, attr, attrMask);
|
||||
fontset = attr->preedit_fontset;
|
||||
gdk_ic_attr_destroy(attr);
|
||||
}
|
||||
return fontset;
|
||||
}
|
||||
|
||||
void
|
||||
nsIMEGtkIC::SetPreeditFont(GdkFont *aFontset) {
|
||||
GdkICAttr *attr = gdk_ic_attr_new();
|
||||
|
|
|
@ -156,7 +156,6 @@ class nsIMEGtkIC {
|
|||
static GdkIMStyle GetInputStyle();
|
||||
|
||||
GdkIMStyle mInputStyle;
|
||||
GdkFont *GetPreeditFont();
|
||||
char *mStatusText;
|
||||
void SetStatusText(const char*);
|
||||
void SetPreeditFont(GdkFont*);
|
||||
|
|
|
@ -221,6 +221,7 @@ nsWindow::nsWindow()
|
|||
mIMECallComposeEnd = PR_TRUE;
|
||||
mIMEIsBeingActivate = PR_FALSE;
|
||||
mICSpotTimer = nsnull;
|
||||
mXICFontSize = 16;
|
||||
if (gXICLookupTable.ops == NULL) {
|
||||
PL_DHashTableInit(&gXICLookupTable, PL_DHashGetStubOps(), nsnull,
|
||||
sizeof(nsXICLookupEntry), PL_DHASH_MIN_SIZE);
|
||||
|
@ -3844,30 +3845,14 @@ nsresult nsWindow::UpdateICSpot(nsIMEGtkIC *aXIC)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsWindow::GetXYFromPosition(nsIMEGtkIC* aXIC,
|
||||
unsigned long *aX,
|
||||
unsigned long *aY)
|
||||
{
|
||||
GdkFont *gfontset = aXIC->GetPreeditFont();
|
||||
if (gfontset) {
|
||||
// this is currently not working well
|
||||
// We change from += ascent to -= descent because we change the nsCaret
|
||||
// code to return the nsPoint from the top of the cursor to the bottom
|
||||
// of the cursor
|
||||
*aY -= gfontset->descent;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
nsWindow::SetXICBaseFontSize(nsIMEGtkIC* aXIC, int height)
|
||||
{
|
||||
if (height == mXICFontSize) return;
|
||||
if (height%2) {
|
||||
height-=1;
|
||||
}
|
||||
if (height<2) return;
|
||||
if (height == mXICFontSize) return;
|
||||
if (gPreeditFontset) {
|
||||
gdk_font_unref(gPreeditFontset);
|
||||
}
|
||||
|
@ -3883,10 +3868,12 @@ nsWindow::SetXICBaseFontSize(nsIMEGtkIC* aXIC, int height)
|
|||
void
|
||||
nsWindow::SetXICSpotLocation(nsIMEGtkIC* aXIC, nsPoint aPoint)
|
||||
{
|
||||
unsigned long x, y;
|
||||
x = aPoint.x, y = aPoint.y;
|
||||
GetXYFromPosition(aXIC, &x, &y);
|
||||
aXIC->SetPreeditSpotLocation(x, y);
|
||||
if (gPreeditFontset) {
|
||||
unsigned long x, y;
|
||||
x = aPoint.x, y = aPoint.y;
|
||||
y -= gPreeditFontset->descent;
|
||||
aXIC->SetPreeditSpotLocation(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -3987,7 +3974,6 @@ nsWindow::IMEGetInputContext(PRBool aCreate)
|
|||
if (aCreate) {
|
||||
if (gPreeditFontset == nsnull) {
|
||||
gPreeditFontset = gdk_fontset_load("-*-*-medium-r-*-*-16-*-*-*-*-*-*-*");
|
||||
mXICFontSize = 16; // default
|
||||
}
|
||||
if (gStatusFontset == nsnull) {
|
||||
gStatusFontset = gdk_fontset_load("-*-*-medium-r-*-*-16-*-*-*-*-*-*-*");
|
||||
|
|
|
@ -354,7 +354,6 @@ protected:
|
|||
nsWindow* mIMEShellWindow;
|
||||
void SetXICSpotLocation(nsIMEGtkIC* aXIC, nsPoint aPoint);
|
||||
void SetXICBaseFontSize(nsIMEGtkIC* aXIC, int height);
|
||||
void GetXYFromPosition(nsIMEGtkIC* aXIC, unsigned long *aX, unsigned long *aY);
|
||||
nsCOMPtr<nsITimer> mICSpotTimer;
|
||||
static void ICSpotCallback(nsITimer* aTimer, void* aClosure);
|
||||
nsresult KillICSpotTimer();
|
||||
|
|
Загрузка…
Ссылка в новой задаче