Beispiel #1
0
        void SendKeyEvent(Gtk.Widget target, uint keyval, Gdk.ModifierType state, Gdk.EventType eventType, string subWindow)
        {
            Gdk.KeymapKey[] keyms = Gdk.Keymap.Default.GetEntriesForKeyval(keyval);
            if (keyms.Length == 0)
            {
                throw new Exception("Keyval not found");
            }

            Gdk.Window win = target.GdkWindow;

            // FIXME: Do we need subwindow for anything?

            /*
             * if (subWindow == null) {
             *      win = target.GdkWindow;
             * } else {
             *      win = (Gdk.Window)GetValue (target, target.GetType (), subWindow);
             * }
             */

            var nativeEvent = new NativeEventKeyStruct {
                type             = eventType,
                send_event       = 1,
                window           = win.Handle,
                state            = (uint)state,
                keyval           = keyval,
                group            = (byte)keyms [0].Group,
                hardware_keycode = (ushort)keyms [0].Keycode,
                length           = 0,
                time             = Gtk.Global.CurrentEventTime
            };

            IntPtr ptr = GLib.Marshaller.StructureToPtrAlloc(nativeEvent);

            try {
                Gdk.EventHelper.Put(new Gdk.EventKey(ptr));
            } finally {
                Marshal.FreeHGlobal(ptr);
            }
        }
Beispiel #2
0
        void SendKeyEvent(Gtk.Widget target, uint keyval, Gdk.ModifierType state, Gdk.EventType eventType, string subWindow)
        {
            Gdk.KeymapKey[] keyms = Gdk.Keymap.Default.GetEntriesForKeyval(keyval);
            if (keyms.Length == 0)
            {
                throw new Exception("Keyval not found");
            }

            Gdk.Window win;
            if (subWindow == null)
            {
                win = target.GdkWindow;
            }
            else
            {
                win = (Gdk.Window)GetValue(target, target.GetType(), subWindow);
            }

            NativeEventKeyStruct nativeEvent = new NativeEventKeyStruct();

            nativeEvent.type             = eventType;
            nativeEvent.send_event       = 1;
            nativeEvent.window           = win.Handle;
            nativeEvent.state            = (uint)state;
            nativeEvent.keyval           = keyval;
            nativeEvent.group            = (byte)keyms[0].Group;
            nativeEvent.hardware_keycode = (ushort)keyms[0].Keycode;
            nativeEvent.length           = 0;
            nativeEvent.time             = Gtk.Global.CurrentEventTime;

            IntPtr ptr = GLib.Marshaller.StructureToPtrAlloc(nativeEvent);

            try {
                Gdk.EventKey evnt = new Gdk.EventKey(ptr);
                Gdk.EventHelper.Put(evnt);
            } finally {
                Marshal.FreeHGlobal(ptr);
            }
        }
Beispiel #3
0
        static Gdk.EventKey CreateKeyEvent(uint keyval, int keyCode, Gdk.ModifierType state, Gdk.EventType eventType, Gdk.Window win)
        {
            int effectiveGroup, level;

            Gdk.ModifierType cmods;
            if (keyval == 0)
            {
                Gdk.Keymap.Default.TranslateKeyboardState((uint)keyCode, state, 0, out keyval, out effectiveGroup, out level, out cmods);
            }

            Gdk.KeymapKey [] keyms = Gdk.Keymap.Default.GetEntriesForKeyval(keyval);
            if (keyms.Length == 0)
            {
                return(null);
            }

            var nativeEvent = new NativeEventKeyStruct {
                type             = eventType,
                send_event       = 1,
                window           = win != null ? win.Handle : IntPtr.Zero,
                state            = (uint)state,
                keyval           = keyval,
                group            = (byte)keyms [0].Group,
                hardware_keycode = keyCode == -1 ? (ushort)keyms [0].Keycode : (ushort)keyCode,
                length           = 0,
                time             = global::Gtk.Global.CurrentEventTime
            };

            IntPtr ptr = GLib.Marshaller.StructureToPtrAlloc(nativeEvent);

            return(new EventKeyWrapper(ptr));
        }
Beispiel #4
0
 public static Gdk.EventKey CreateKeyEventFromKeyCode(ushort keyCode, Gdk.ModifierType state, Gdk.EventType eventType, Gdk.Window win)
 {
     return(CreateKeyEvent(0, keyCode, state, eventType, win));
 }
Beispiel #5
0
 public static Gdk.EventKey CreateKeyEvent(uint keyval, Gdk.ModifierType state, Gdk.EventType eventType, Gdk.Window win)
 {
     return(CreateKeyEvent(keyval, -1, state, eventType, win));
 }
Beispiel #6
0
        // FIXME: This is seriously LAME. The Gtk# binding does not support mutating
        // Gdk.Event* objects. All the properties are marked read only. Support for
        // these objects is simply incomplete.
        // http://bugzilla.novell.com/show_bug.cgi?id=323373

        private void UpdateEventButton(Gdk.EventButton evnt, Gdk.Window window, Gdk.EventType type)
        {
            Marshal.WriteInt32(evnt.Handle, 0, (int)type);
            UpdateEventButtonWindow(evnt, window);
        }
Beispiel #7
0
 public MarginMouseEventArgs(TextEditor editor, uint button, double x, double y, Gdk.EventType type, Gdk.ModifierType modifierState)
 {
     this.Editor        = editor;
     this.Button        = button;
     this.X             = x;
     this.Y             = y;
     this.Type          = type;
     this.ModifierState = modifierState;
 }