[uim-commit] r2940 - trunk/xim

ekato at freedesktop.org ekato at freedesktop.org
Wed Jan 18 08:16:19 PST 2006


Author: ekato
Date: 2006-01-18 08:16:15 -0800 (Wed, 18 Jan 2006)
New Revision: 2940

Modified:
   trunk/xim/ximserver.cpp
   trunk/xim/ximserver.h
Log:
* xim/ximserver.cpp : Simplify mod key handling.
(gShiftMask) : Removed.
(gLockMask) : Ditto.
(gControlMask) : Ditto.
(keyState::keyState) : Follow the changes in member variables.
(keyState::check_key) : Simplify.
(keyState::revise_mod) : Removed.
(keyState::reset) : Follow the change in member variables.
(check_modifier) : Don't handle shift and control keys.
(init_modifier_keys) : Ditto.
* xim/ximserver.h (class keyState) : Remove revise_mod(), mAltOn,
  mMetaOn, mHyperOn, mSuperOn members.  Add mModState and
  mPreModState members.


Modified: trunk/xim/ximserver.cpp
===================================================================
--- trunk/xim/ximserver.cpp	2006-01-18 15:42:08 UTC (rev 2939)
+++ trunk/xim/ximserver.cpp	2006-01-18 16:16:15 UTC (rev 2940)
@@ -66,8 +66,7 @@
 InputContext *InputContext::mFocusedContext = NULL;
 
 static int check_modifier(std::list<KeySym> list);
-static int gShiftMask, gLockMask, gControlMask, gMod1Mask,
-	   gMod2Mask, gMod3Mask, gMod4Mask, gMod5Mask;
+static int gMod1Mask, gMod2Mask, gMod3Mask, gMod4Mask, gMod5Mask;
 static int gXNumLockMask;
 
 
@@ -885,10 +884,7 @@
     XimIM *im;
     DefTree *top;
 
-    mAltOn = false;
-    mMetaOn = false;
-    mSuperOn = false;
-    mHyperOn = false;
+    mModState = 0;
     mIc = ic;
 
     im = get_im_by_id(mIc->get_imid());
@@ -908,32 +904,31 @@
     mXKeySym = x->key_sym;
     mXKeyState = x->state;
 
+    mPreModState = mModState;
+
     if (x->press) {
 	m_bPush = true;
 
-	if (!(g_option_mask & OPT_ON_DEMAND_SYNC)) {
-	    // Only KeyPress is forwarded with full-synchronous
-	    // method.  So reset modifiers here.
-	    if (!(x->state) || x->state == LockMask || x->state == gXNumLockMask)
-		mAltOn = mMetaOn = mSuperOn = mHyperOn = false;
-	}
+	if (!(x->state) || x->state == LockMask || x->state == gXNumLockMask)
+	    mModState = mPreModState = 0;
 
+	mPreModState = mModState;
 	switch (x->key_sym) {
 	case XK_Alt_L:
 	case XK_Alt_R:
-	    mAltOn = true;
+	    mModState |= UMod_Alt;
 	    break;
 	case XK_Meta_L:
 	case XK_Meta_R:
-	    mMetaOn = true;
+	    mModState |= UMod_Meta;
 	    break;
 	case XK_Super_L:
 	case XK_Super_R:
-	    mSuperOn = true;
+	    mModState |= UMod_Super;
 	    break;
 	case XK_Hyper_L:
 	case XK_Hyper_R:
-	    mHyperOn = true;
+	    mModState |= UMod_Hyper;
 	    break;
 	default:
 	    break;
@@ -944,19 +939,19 @@
 	switch (x->key_sym) {
 	case XK_Alt_L:
 	case XK_Alt_R:
-	    mAltOn = false;
+	    mModState &= ~UMod_Alt;
 	    break;
 	case XK_Meta_L:
 	case XK_Meta_R:
-	    mMetaOn = false;
+	    mModState &= ~UMod_Meta;
 	    break;
 	case XK_Super_L:
 	case XK_Super_R:
-	    mSuperOn = false;
+	    mModState &= ~UMod_Super;
 	    break;
 	case XK_Hyper_L:
 	case XK_Hyper_R:
-	    mHyperOn = false;
+	    mModState &= ~UMod_Hyper;
 	    break;
 	default:
 	    break;
@@ -964,21 +959,19 @@
     }
 
     if (x->state & ShiftMask)
-	mModifier |= gShiftMask;
-    if (x->state & LockMask)
-	mModifier |= gLockMask;
+	mModifier |= UMod_Shift;
     if (x->state & ControlMask)
-	mModifier |= gControlMask;
+	mModifier |= UMod_Control;
     if (x->state & Mod1Mask)
-	mModifier |= revise_mod(gMod1Mask);
+	mModifier |= (gMod1Mask & mPreModState);
     if (x->state & Mod2Mask)
-	mModifier |= revise_mod(gMod2Mask);
+	mModifier |= (gMod2Mask & mPreModState);
     if (x->state & Mod3Mask)
-	mModifier |= revise_mod(gMod3Mask);
+	mModifier |= (gMod3Mask & mPreModState);
     if (x->state & Mod4Mask)
-	mModifier |= revise_mod(gMod4Mask);
+	mModifier |= (gMod4Mask & mPreModState);
     if (x->state & Mod5Mask)
-	mModifier |= revise_mod(gMod5Mask);
+	mModifier |= (gMod5Mask & mPreModState);
 
     if (x->key_sym < 128 && x->key_sym >= 32)
 	mKey = x->key_sym;
@@ -1047,20 +1040,6 @@
     return m_bPush;
 }
 
-int keyState::revise_mod(int uim_mod)
-{
-    if ((uim_mod & UMod_Alt) && (mAltOn == false))
-	uim_mod &= ~UMod_Alt;
-    if ((uim_mod & UMod_Meta) && (mMetaOn == false))
-	uim_mod &= ~UMod_Meta;
-    if ((uim_mod & UMod_Super) && (mSuperOn == false))
-	uim_mod &= ~UMod_Super;
-    if ((uim_mod & UMod_Hyper) && (mHyperOn == false))
-	uim_mod &= ~UMod_Hyper;
-
-    return uim_mod;
-}
-
 KeySym keyState::xkeysym()
 {
     return mXKeySym;
@@ -1073,7 +1052,7 @@
 
 void keyState::reset()
 {
-    mAltOn = mMetaOn = mHyperOn = mSuperOn = false;
+    mModState = 0;
     mCompose->reset();
 }
 
@@ -1089,14 +1068,6 @@
     std::list<KeySym>::iterator i;
     for (i = keysym_list.begin(); i != keysym_list.end(); i++) {
 	switch (*i) {
-	case XK_Shift_L:
-	case XK_Shift_R:
-	    ret |= UMod_Shift;
-	    break;
-	case XK_Control_L:
-	case XK_Control_R:
-	    ret |= UMod_Control;
-	    break;
 	case XK_Alt_L:
 	case XK_Alt_R:
 	    ret |= UMod_Alt;
@@ -1124,8 +1095,7 @@
     int i, k = 0;
     int min_keycode, max_keycode, keysyms_per_keycode = 0;
 
-    std::list<KeySym> ShiftMaskSyms, LockMaskSyms, ControlMaskSyms,
-		      Mod1MaskSyms, Mod2MaskSyms, Mod3MaskSyms,
+    std::list<KeySym> Mod1MaskSyms, Mod2MaskSyms, Mod3MaskSyms,
 		      Mod4MaskSyms, Mod5MaskSyms;
 
     gXNumLockMask = 0;
@@ -1146,9 +1116,9 @@
 		} while (!ks && index < keysyms_per_keycode);
 
 		switch (i) {
-		case ShiftMapIndex: ShiftMaskSyms.push_back(ks); break;
-		case LockMapIndex: LockMaskSyms.push_back(ks); break;
-		case ControlMapIndex: ControlMaskSyms.push_back(ks); break;
+		case ShiftMapIndex: break;
+		case LockMapIndex: break;
+		case ControlMapIndex: break;
 		case Mod1MapIndex: Mod1MaskSyms.push_back(ks); break;
 		case Mod2MapIndex: Mod2MaskSyms.push_back(ks); break;
 		case Mod3MapIndex: Mod3MaskSyms.push_back(ks); break;
@@ -1166,9 +1136,6 @@
     XFreeModifiermap(map);
     XFree(sym);
 
-    gShiftMask = check_modifier(ShiftMaskSyms);
-    gLockMask = check_modifier(LockMaskSyms);
-    gControlMask = check_modifier(ControlMaskSyms);
     gMod1Mask = check_modifier(Mod1MaskSyms);
     gMod2Mask = check_modifier(Mod2MaskSyms);
     gMod3Mask = check_modifier(Mod3MaskSyms);

Modified: trunk/xim/ximserver.h
===================================================================
--- trunk/xim/ximserver.h	2006-01-18 15:42:08 UTC (rev 2939)
+++ trunk/xim/ximserver.h	2006-01-18 16:16:15 UTC (rev 2940)
@@ -133,16 +133,13 @@
     bool is_push(); // for distinguish from release
     void print();
 private:
-    int revise_mod(int uim_mod);
     int mKey;
     int mModifier;
     KeySym mXKeySym;
     int mXKeyState;
     bool m_bPush;
-    bool mAltOn;
-    bool mMetaOn;
-    bool mHyperOn;
-    bool mSuperOn;
+    int mModState;
+    int mPreModState;
     Compose *mCompose;
     XimIC *mIc;
 };



More information about the uim-commit mailing list