< prev index next >

src/java.desktop/unix/native/libawt_xawt/awt/awt_InputMethod.c

Print this page




1606 {
1607     X11InputMethodData *pX11IMData;
1608     char * ret = NULL;
1609     XVaNestedList   pr_atrb;
1610 #if defined(__linux__) || defined(MACOSX)
1611     Boolean calledXSetICFocus = False;
1612 #endif
1613 
1614     AWT_LOCK();
1615     pX11IMData = getX11InputMethodData(env, this);
1616 
1617     if ((pX11IMData == NULL) || (pX11IMData->current_ic == NULL)) {
1618         AWT_UNLOCK();
1619         return JNI_FALSE;
1620     }
1621 
1622 #if defined(__linux__) || defined(MACOSX)
1623     if (NULL != pX11IMData->statusWindow) {
1624         Window focus = 0;
1625         int revert_to;
1626 #if defined(_LP64) && !defined(_LITTLE_ENDIAN)
1627         // The Window value which is used for XGetICValues must be 32bit on BigEndian XOrg's xlib
1628         unsigned int w = 0;
1629 #else
1630         Window w = 0;
1631 #endif
1632         XGetInputFocus(awt_display, &focus, &revert_to);
1633         XGetICValues(pX11IMData->current_ic, XNFocusWindow, &w, NULL);





1634         if (RevertToPointerRoot == revert_to
1635                 && pX11IMData->ic_active != pX11IMData->ic_passive) {
1636             if (pX11IMData->current_ic == pX11IMData->ic_active) {
1637                 if (getParentWindow(focus) == getParentWindow(w)) {
1638                     XUnsetICFocus(pX11IMData->ic_active);
1639                     calledXSetICFocus = True;
1640                 }
1641             }
1642         }
1643     }
1644 #endif
1645     pr_atrb = XVaCreateNestedList(0,
1646                   XNPreeditState, (enable ? XIMPreeditEnable : XIMPreeditDisable),
1647                   NULL);
1648     ret = XSetICValues(pX11IMData->current_ic, XNPreeditAttributes, pr_atrb, NULL);
1649     XFree((void *)pr_atrb);
1650 #if defined(__linux__) || defined(MACOSX)
1651     if (calledXSetICFocus) {
1652         XSetICFocus(pX11IMData->ic_active);
1653     }


1662 
1663     return (jboolean)(ret == 0);
1664 }
1665 
1666 /*
1667  * Class:     sun_awt_X11InputMethodBase
1668  * Method:    isCompositionEnabledNative
1669  * Signature: ()Z
1670  *
1671  * This method tries to get the XNPreeditState attribute associated with the current XIC.
1672  *
1673  * Return JNI_TRUE if the XNPreeditState is successfully retrieved. Otherwise, if
1674  * XGetICValues fails to get this attribute, java.lang.UnsupportedOperationException
1675  * will be thrown. JNI_FALSE is returned if this method fails due to other reasons.
1676  */
1677 JNIEXPORT jboolean JNICALL Java_sun_awt_X11InputMethodBase_isCompositionEnabledNative
1678   (JNIEnv *env, jobject this)
1679 {
1680     X11InputMethodData *pX11IMData = NULL;
1681     char * ret = NULL;
1682 #if defined(_LP64) && !defined(_LITTLE_ENDIAN)
1683     // XIMPreeditState value which is used for XGetICValues must be 32bit on BigEndian XOrg's xlib
1684     unsigned int state = XIMPreeditUnKnown;
1685 #else
1686     XIMPreeditState state = XIMPreeditUnKnown;
1687 #endif
1688 
1689     XVaNestedList   pr_atrb;
1690 
1691     AWT_LOCK();
1692     pX11IMData = getX11InputMethodData(env, this);
1693 
1694     if ((pX11IMData == NULL) || (pX11IMData->current_ic == NULL)) {
1695         AWT_UNLOCK();
1696         return JNI_FALSE;
1697     }
1698 
1699     pr_atrb = XVaCreateNestedList(0, XNPreeditState, &state, NULL);
1700     ret = XGetICValues(pX11IMData->current_ic, XNPreeditAttributes, pr_atrb, NULL);
1701     XFree((void *)pr_atrb);
1702     AWT_UNLOCK();





1703 
1704     if ((ret != 0)
1705             && ((strcmp(ret, XNPreeditAttributes) == 0)
1706             || (strcmp(ret, XNPreeditState) == 0))) {
1707         JNU_ThrowByName(env, "java/lang/UnsupportedOperationException", "");
1708         return JNI_FALSE;
1709     }
1710 
1711     return (jboolean)(state == XIMPreeditEnable);
1712 }
1713 
1714 JNIEXPORT void JNICALL Java_sun_awt_X11_XInputMethod_adjustStatusWindow
1715   (JNIEnv *env, jobject this, jlong window)
1716 {
1717 #if defined(__linux__) || defined(MACOSX)
1718     AWT_LOCK();
1719     adjustStatusWindow(window);
1720     AWT_UNLOCK();
1721 #endif
1722 }


1606 {
1607     X11InputMethodData *pX11IMData;
1608     char * ret = NULL;
1609     XVaNestedList   pr_atrb;
1610 #if defined(__linux__) || defined(MACOSX)
1611     Boolean calledXSetICFocus = False;
1612 #endif
1613 
1614     AWT_LOCK();
1615     pX11IMData = getX11InputMethodData(env, this);
1616 
1617     if ((pX11IMData == NULL) || (pX11IMData->current_ic == NULL)) {
1618         AWT_UNLOCK();
1619         return JNI_FALSE;
1620     }
1621 
1622 #if defined(__linux__) || defined(MACOSX)
1623     if (NULL != pX11IMData->statusWindow) {
1624         Window focus = 0;
1625         int revert_to;




1626         Window w = 0;

1627         XGetInputFocus(awt_display, &focus, &revert_to);
1628         XGetICValues(pX11IMData->current_ic, XNFocusWindow, &w, NULL);
1629 #if defined(_LP64) && !defined(_LITTLE_ENDIAN)
1630         // On 64bit BigEndian,
1631         // Window value may be stored on high 32bit by XGetICValues via XIM
1632         if (w > 0xffffffffUL) w = w >> 32;
1633 #endif
1634         if (RevertToPointerRoot == revert_to
1635                 && pX11IMData->ic_active != pX11IMData->ic_passive) {
1636             if (pX11IMData->current_ic == pX11IMData->ic_active) {
1637                 if (getParentWindow(focus) == getParentWindow(w)) {
1638                     XUnsetICFocus(pX11IMData->ic_active);
1639                     calledXSetICFocus = True;
1640                 }
1641             }
1642         }
1643     }
1644 #endif
1645     pr_atrb = XVaCreateNestedList(0,
1646                   XNPreeditState, (enable ? XIMPreeditEnable : XIMPreeditDisable),
1647                   NULL);
1648     ret = XSetICValues(pX11IMData->current_ic, XNPreeditAttributes, pr_atrb, NULL);
1649     XFree((void *)pr_atrb);
1650 #if defined(__linux__) || defined(MACOSX)
1651     if (calledXSetICFocus) {
1652         XSetICFocus(pX11IMData->ic_active);
1653     }


1662 
1663     return (jboolean)(ret == 0);
1664 }
1665 
1666 /*
1667  * Class:     sun_awt_X11InputMethodBase
1668  * Method:    isCompositionEnabledNative
1669  * Signature: ()Z
1670  *
1671  * This method tries to get the XNPreeditState attribute associated with the current XIC.
1672  *
1673  * Return JNI_TRUE if the XNPreeditState is successfully retrieved. Otherwise, if
1674  * XGetICValues fails to get this attribute, java.lang.UnsupportedOperationException
1675  * will be thrown. JNI_FALSE is returned if this method fails due to other reasons.
1676  */
1677 JNIEXPORT jboolean JNICALL Java_sun_awt_X11InputMethodBase_isCompositionEnabledNative
1678   (JNIEnv *env, jobject this)
1679 {
1680     X11InputMethodData *pX11IMData = NULL;
1681     char * ret = NULL;




1682     XIMPreeditState state = XIMPreeditUnKnown;

1683 
1684     XVaNestedList   pr_atrb;
1685 
1686     AWT_LOCK();
1687     pX11IMData = getX11InputMethodData(env, this);
1688 
1689     if ((pX11IMData == NULL) || (pX11IMData->current_ic == NULL)) {
1690         AWT_UNLOCK();
1691         return JNI_FALSE;
1692     }
1693 
1694     pr_atrb = XVaCreateNestedList(0, XNPreeditState, &state, NULL);
1695     ret = XGetICValues(pX11IMData->current_ic, XNPreeditAttributes, pr_atrb, NULL);
1696     XFree((void *)pr_atrb);
1697     AWT_UNLOCK();
1698 #if defined(__linux__) && defined(_LP64) && !defined(_LITTLE_ENDIAN)
1699     // On 64bit BigEndian,
1700     // XIMPreeditState value may be stored on high 32bit by XGetICValues via XIM
1701     if (state > 0xffffffffUL) state = state >> 32;
1702 #endif
1703 
1704     if ((ret != 0)
1705             && ((strcmp(ret, XNPreeditAttributes) == 0)
1706             || (strcmp(ret, XNPreeditState) == 0))) {
1707         JNU_ThrowByName(env, "java/lang/UnsupportedOperationException", "");
1708         return JNI_FALSE;
1709     }
1710 
1711     return (jboolean)(state == XIMPreeditEnable);
1712 }
1713 
1714 JNIEXPORT void JNICALL Java_sun_awt_X11_XInputMethod_adjustStatusWindow
1715   (JNIEnv *env, jobject this, jlong window)
1716 {
1717 #if defined(__linux__) || defined(MACOSX)
1718     AWT_LOCK();
1719     adjustStatusWindow(window);
1720     AWT_UNLOCK();
1721 #endif
1722 }
< prev index next >