| 52 | 52 | 	}
 | 
  | 53 | 53 | }
 | 
  | 54 | 54 | 
 | 
  |  | 55 | #ifndef AltMask
 | 
  |  | 56 | # ifdef NL_OS_MAC
 | 
  |  | 57 | #  define AltMask (8192)
 | 
  |  | 58 | # else
 | 
  |  | 59 | #  define AltMask (Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask)
 | 
  |  | 60 | # endif
 | 
  |  | 61 | #endif
 | 
  |  | 62 | 
 | 
  | 55 | 63 | TMouseButton getMouseButton (uint32 state)
 | 
  | 56 | 64 | {
 | 
  | 57 |  | 	TMouseButton button=noButton;
 | 
  | 58 |  | 	if (state&ControlMask) (int&)button|=ctrlButton;
 | 
  | 59 |  | 	if (state&Button1Mask) (int&)button|=leftButton;
 | 
  | 60 |  | 	if (state&Button3Mask) (int&)button|=rightButton;
 | 
  | 61 |  | 	if (state&Button2Mask) (int&)button|=middleButton;
 | 
  | 62 |  | 	if (state&ShiftMask)   (int&)button|=shiftButton;
 | 
  | 63 |  | 	// TODO manage ALT key
 | 
  | 64 |  | 	//	if (GetAsyncKeyState(VK_MENU)&(1<<15))
 | 
  | 65 |  | 	//	(int&)button|=altButton;
 | 
  | 66 |  | 	return button;
 | 
  |  | 65 | 	uint32 button=noButton;
 | 
  |  | 66 | 	if (state&Button1Mask) button|=leftButton;
 | 
  |  | 67 | 	if (state&Button2Mask) button|=middleButton;
 | 
  |  | 68 | 	if (state&Button3Mask) button|=rightButton;
 | 
  |  | 69 | 	if (state&ControlMask) button|=ctrlButton;
 | 
  |  | 70 | 	if (state&ShiftMask)   button|=shiftButton;
 | 
  |  | 71 | 	if (state&AltMask)     button|=altButton;
 | 
  |  | 72 | 	// TODO: handle meta / windows / apple key if possible
 | 
  |  | 73 | 	return (TMouseButton)button;
 | 
  | 67 | 74 | }
 | 
  | 68 | 75 | 
 | 
  |  | 76 | TKeyButton getKeyButton (uint32 state)
 | 
  |  | 77 | {
 | 
  |  | 78 | 	uint32 button=noKeyButton;
 | 
  |  | 79 | 	if (state&ControlMask) button|=ctrlKeyButton;
 | 
  |  | 80 | 	if (state&ShiftMask)   button|=shiftKeyButton;
 | 
  |  | 81 | 	if (state&AltMask)     button|=altKeyButton;
 | 
  |  | 82 | 	// TODO: handle meta / windows / apple key if possible
 | 
  |  | 83 | 	return (TKeyButton)button;
 | 
  |  | 84 | }	
 | 
  |  | 85 | 
 | 
  | 69 | 86 | TKey getKey (KeySym keysym)
 | 
  | 70 | 87 | {
 | 
  | 71 | 88 | 	switch (keysym)
 | 
  | ... | ... |  | 
  | 125 | 142 | ///	case XK_Caps_Lock: return Key;
 | 
  | 126 | 143 | ///	case XK_Meta_L: return Key;
 | 
  | 127 | 144 | ///	case XK_Meta_R: return Key;
 | 
  | 128 |  | ///	case XK_Alt_L: return Key;
 | 
  | 129 |  | ///	case XK_Alt_R: return Key;
 | 
  |  | 145 | 	case XK_Mode_switch: return KeyMENU;
 | 
  |  | 146 | 	case XK_ISO_Level3_Shift: return KeyMENU;
 | 
  |  | 147 | 	case XK_Alt_L: return KeyMENU;
 | 
  |  | 148 | 	case XK_Alt_R: return KeyMENU;
 | 
  | 130 | 149 | 	case XK_space: return KeySPACE;
 | 
  | 131 | 150 | //	case XK_comma: return Key;
 | 
  | 132 | 151 | //	case XK_minus: return Key;
 | 
  | ... | ... |  | 
  | 199 | 218 | 	case XK_y: return KeyY;
 | 
  | 200 | 219 | 	case XK_Z:
 | 
  | 201 | 220 | 	case XK_z: return KeyZ;
 | 
  | 202 |  | 	default: nldebug ("0x%x %d '%c'", keysym, keysym, keysym);
 | 
  |  | 221 | 	default: //nldebug ("0x%x %d '%c'", keysym, keysym, keysym);
 | 
  |  | 222 | 	break;
 | 
  | 203 | 223 | 	}
 | 
  | 204 |  | 	return KeyNUMLOCK;
 | 
  |  | 224 | 	return KeyNOKEY;
 | 
  | 205 | 225 | }
 | 
  | 206 | 226 | 
 | 
  | 207 | 227 | 
 | 
  | ... | ... |  | 
  | 282 | 302 | 		int c;
 | 
  | 283 | 303 | 		c = XLookupString(&event.xkey, Text, 1024-1, &k, NULL);
 | 
  | 284 | 304 | 
 | 
  | 285 |  | 		TKey key = getKey (k);
 | 
  |  | 305 | 		TKey key = getKey(XKeycodeToKeysym(_dpy, ((XKeyEvent*)&event)->keycode, 0));
 | 
  |  | 306 | 		if(key == KeyNOKEY)
 | 
  |  | 307 | 			key = getKey(XKeycodeToKeysym(_dpy, ((XKeyEvent*)&event)->keycode, 1));
 | 
  | 286 | 308 | 		// TODO manage the bool (first time pressed)
 | 
  | 287 |  | 		server.postEvent (new CEventKeyDown (key, noKeyButton, true, this));
 | 
  |  | 309 | 		server.postEvent (new CEventKeyDown (key, getKeyButton(event.xbutton.state), true, this));
 | 
  | 288 | 310 | 
 | 
  | 289 | 311 | 		Text[c] = '\0';
 | 
  | 290 | 312 | 		if(c>0)
 | 
  | ... | ... |  | 
  | 303 | 325 | 		int c;
 | 
  | 304 | 326 | 		c = XLookupString(&event.xkey, Text, 1024-1, &k, NULL);
 | 
  | 305 | 327 | 
 | 
  | 306 |  | 		TKey key = getKey (k);
 | 
  |  | 328 | 		TKey key = getKey(XKeycodeToKeysym(_dpy, ((XKeyEvent*)&event)->keycode, 0));
 | 
  |  | 329 | 		if(key == KeyNOKEY)
 | 
  |  | 330 | 			key = getKey(XKeycodeToKeysym(_dpy, ((XKeyEvent*)&event)->keycode, 1));
 | 
  | 307 | 331 | 		// TODO manage the bool (first time pressed)
 | 
  | 308 |  | 		server.postEvent (new CEventKeyUp (key, noKeyButton, this));
 | 
  |  | 332 | 		server.postEvent (new CEventKeyUp (key, getKeyButton(event.xbutton.state), this));
 | 
  | 309 | 333 | 		break;
 | 
  | 310 | 334 | 	}
 | 
  | 311 | 335 | 	Case(FocusIn)
 |