Exemple #1
0
		private System.Windows.Forms.Keys StringToWFKey(XEvent Event)
		{
			Dummy.Remove(0, Dummy.Length);
			Dummy.Append(" "); // HACK: Somehow necessary

			Event.KeyEvent.state = 16; // Repair any shifting applied by control

			if (Xlib.XLookupString(ref Event, Dummy, 10, IntPtr.Zero, IntPtr.Zero) != 0)
			{
				string Lookup = Dummy.ToString();

				if (Dummy.Length == 1 && char.IsLetterOrDigit(Dummy[0]))
					Lookup = Dummy[0].ToString().ToUpper();

				if (string.IsNullOrEmpty(Lookup.Trim())) return System.Windows.Forms.Keys.None;

				try
				{
					return (System.Windows.Forms.Keys) Enum.Parse(typeof(System.Windows.Forms.Keys), Lookup);
				}
				catch (ArgumentException)
				{
					// TODO
					Console.Error.WriteLine("Warning, could not look up key: " + Lookup);
					return System.Windows.Forms.Keys.None;
				}
			}
			else return System.Windows.Forms.Keys.None;
		}
Exemple #2
0
 public static extern int XLookupString(ref XEvent Key, StringBuilder Buffer, int Count, IntPtr KeySym, IntPtr Useless);
Exemple #3
0
 public static extern void XNextEvent(IntPtr Display, ref XEvent Event);
Exemple #4
0
		private System.Windows.Forms.Keys TranslateKey(XEvent Event)
		{
			if (Mapping.ContainsKey(Event.KeyEvent.keycode))
				return Mapping[Event.KeyEvent.keycode];
			else return StringToWFKey(Event);
		}
Exemple #5
0
#pragma warning disable 612, 618
		private void HandleXEvent(XEvent Event)
		{
			if (Event.type == XEventName.KeyPress || Event.type == XEventName.KeyRelease)
				KeyReceived(TranslateKey(Event), Event.type == XEventName.KeyPress);
		}
Exemple #6
0
        private void FishEvent()
        {
            var Event = new XEvent();
            Xlib.XNextEvent(Display, ref Event);

            if(OnEvent != null)
                OnEvent(Event);

            if (Event.type == XEventName.CreateNotify)
            {
                int Window = Event.CreateWindowEvent.window;
                Success = true;

                Windows.Add(Window);

                SurpressErrors = true;
                if(Success)
                    RecurseTree(Display, Window);

                SurpressErrors = false;
            }
            else if(Event.type == XEventName.DestroyNotify)
            {
                Windows.Remove(Event.DestroyWindowEvent.window);
            }
        }