Esempio n. 1
0
        static string ModifierKeyToString(Gdk.Key key)
        {
            string label = string.Empty;

            if (key.Equals(Gdk.Key.Control_L) || key.Equals(Gdk.Key.Control_R))
            {
                label += "Control+";
            }
            else if (key.Equals(Gdk.Key.Alt_L) || key.Equals(Gdk.Key.Alt_R))
            {
                label += "Alt+";
            }
            else if (key.Equals(Gdk.Key.Shift_L) || key.Equals(Gdk.Key.Shift_R))
            {
                label += "Shift+";
            }
            else if (key.Equals(Gdk.Key.Meta_L) || key.Equals(Gdk.Key.Meta_R))
            {
                label += "Meta+";
            }
            else if (key.Equals(Gdk.Key.Super_L) || key.Equals(Gdk.Key.Super_R))
            {
                label += "Super+";
            }

            return(label);
        }
Esempio n. 2
0
        static bool KeyIsModifier(Gdk.Key key)
        {
            if (key.Equals(Gdk.Key.Control_L) || key.Equals(Gdk.Key.Control_R))
            {
                return(true);
            }
            else if (key.Equals(Gdk.Key.Alt_L) || key.Equals(Gdk.Key.Alt_R))
            {
                return(true);
            }
            else if (key.Equals(Gdk.Key.Shift_L) || key.Equals(Gdk.Key.Shift_R))
            {
                return(true);
            }
            else if (key.Equals(Gdk.Key.Meta_L) || key.Equals(Gdk.Key.Meta_R))
            {
                return(true);
            }
            else if (key.Equals(Gdk.Key.Super_L) || key.Equals(Gdk.Key.Super_R))
            {
                return(true);
            }

            return(false);
        }
Esempio n. 3
0
        static string ModifierToPartialAccel(Gdk.ModifierType mod, Gdk.Key key, out bool keyIsModifier)
        {
            string label = String.Empty;

            if ((mod & Gdk.ModifierType.ControlMask) != 0)
            {
                label += "Control+";
            }
            if ((mod & Gdk.ModifierType.Mod1Mask) != 0)
            {
                label += "Alt+";
            }
            if ((mod & Gdk.ModifierType.ShiftMask) != 0)
            {
                label += "Shift+";
            }
            if ((mod & Gdk.ModifierType.MetaMask) != 0)
            {
                label += "Meta+";
            }
            if ((mod & Gdk.ModifierType.SuperMask) != 0)
            {
                label += "Super+";
            }

            keyIsModifier = true;
            if (key.Equals(Gdk.Key.Control_L) || key.Equals(Gdk.Key.Control_R))
            {
                label += "Control+";
            }
            else if (key.Equals(Gdk.Key.Alt_L) || key.Equals(Gdk.Key.Alt_R))
            {
                label += "Alt+";
            }
            else if (key.Equals(Gdk.Key.Shift_L) || key.Equals(Gdk.Key.Shift_R))
            {
                label += "Shift+";
            }
            else if (key.Equals(Gdk.Key.Meta_L) || key.Equals(Gdk.Key.Meta_R))
            {
                label += "Meta+";
            }
            else if (key.Equals(Gdk.Key.Super_L) || key.Equals(Gdk.Key.Super_L))
            {
                label += "Super+";
            }
            else
            {
                keyIsModifier = false;
            }

            return(label);
        }
		static bool KeyIsModifier (Gdk.Key key)
		{
			if (key.Equals (Gdk.Key.Control_L) || key.Equals (Gdk.Key.Control_R))
				return true;
			else if (key.Equals (Gdk.Key.Alt_L) || key.Equals (Gdk.Key.Alt_R))
				return true;
			else if (key.Equals (Gdk.Key.Shift_L) || key.Equals (Gdk.Key.Shift_R))
				return true;
			else if (key.Equals (Gdk.Key.Meta_L) || key.Equals (Gdk.Key.Meta_R))
				return true;
			else if (key.Equals (Gdk.Key.Super_L) || key.Equals (Gdk.Key.Super_L))
				return true;
			
			return false;
		}
Esempio n. 5
0
        void OnAccelEntryKeyPress(object sender, KeyPressEventArgs e)
        {
            Gdk.Key key = e.Event.Key;
            string  accel;

            e.RetVal = true;

            if (accelComplete)
            {
                CurrentBinding  = String.Empty;
                accelIncomplete = false;
                accelComplete   = false;
                chord           = null;

                if (key.Equals(Gdk.Key.BackSpace))
                {
                    return;
                }
            }

            accelComplete = false;
            bool combinationComplete;

            accel = KeyBindingManager.AccelLabelFromKey(e.Event, out combinationComplete);
            if (combinationComplete)
            {
                CurrentBinding  = KeyBindingManager.Binding(chord, accel);
                accelIncomplete = false;
                if (chord != null)
                {
                    accelComplete = true;
                }
                else
                {
                    chord = accel;
                }
            }
            else
            {
                accel           = (chord != null ? chord + "|" : string.Empty) + accel;
                accelIncomplete = true;
                CurrentBinding  = accel;
            }
        }
Esempio n. 6
0
        static string ModifierToPartialAccel(Gdk.ModifierType mod, Gdk.Key key, out bool keyIsModifier)
        {
            //Console.WriteLine("PRESSED MOD: {0} ; KEY {1}",mod,key);

            string labelMod = String.Empty;
            string labelKey = String.Empty;

            if ((mod & Gdk.ModifierType.ControlMask) != 0)
            {
                labelMod += "Control+";
            }
            if ((mod & Gdk.ModifierType.Mod1Mask) != 0)
            {
                labelMod += "Alt+";
            }
            if ((mod & Gdk.ModifierType.ShiftMask) != 0)
            {
                labelMod += "Shift+";
            }
            if ((mod & Gdk.ModifierType.MetaMask) != 0)
            {
                labelMod += "Command+";                //labelMod += "Meta+";
            }
            if ((mod & Gdk.ModifierType.SuperMask) != 0)
            {
                labelMod += "Super+";
            }

            //Console.WriteLine("labelMod-> {0}",labelMod);

            keyIsModifier = true;
            if (key.Equals(Gdk.Key.Control_L) || key.Equals(Gdk.Key.Control_R))
            {
                labelKey += "Control+";
            }
            else if (key.Equals(Gdk.Key.Alt_L) || key.Equals(Gdk.Key.Alt_R))
            {
                labelKey += "Alt+";
            }
            else if (key.Equals(Gdk.Key.Shift_L) || key.Equals(Gdk.Key.Shift_R))
            {
                labelKey += "Shift+";
            }
            else if (key.Equals(Gdk.Key.Meta_L) || key.Equals(Gdk.Key.Meta_R))
            {
                labelKey += "Command+";                //labelKey += "Meta+";
            }
            else if (key.Equals(Gdk.Key.Super_L) || key.Equals(Gdk.Key.Super_L))
            {
                labelKey += "Super+";
            }
            else
            {
                keyIsModifier = false;
            }


            //Console.WriteLine("labelKey-> {0}",labelKey);

            if (labelMod.Contains(labelKey))
            {
                return(labelMod);
            }
            else
            {
                return(labelMod + labelKey);
            }
        }
Esempio n. 7
0
        public static void MapRawKeys(Gdk.EventKey evt, out Gdk.Key key, out Gdk.ModifierType mod)
        {
            mod = evt.State;
            key = evt.Key;
            uint keyval;
            int  effectiveGroup, level;

            Gdk.ModifierType consumedModifiers;
            keymap.TranslateKeyboardState(evt.HardwareKeycode, evt.State, evt.Group, out keyval, out effectiveGroup,
                                          out level, out consumedModifiers);

            key = (Gdk.Key)keyval;
            mod = evt.State & ~consumedModifiers;

            if (MainClass.Platform.IsX11)
            {
                //this is a workaround for a common X mapping issue
                //where the alt key is mapped to the meta key when the shift modifier is active
                if (key.Equals(Gdk.Key.Meta_L) || key.Equals(Gdk.Key.Meta_R))
                {
                    key = Gdk.Key.Alt_L;
                }
            }

            //HACK: the MAC GTK+ port currently does some horrible, un-GTK-ish key mappings
            // so we work around them by playing some tricks to remap and decompose modifiers.
            // We also decompose keys to the root physical key so that the Mac command
            // combinations appear as expected, e.g. shift-{ is treated as shift-[.
            if (MainClass.Platform.IsMac && !MainClass.Platform.IsX11)
            {
                // Mac GTK+ maps the command key to the Mod1 modifier, which usually means alt/
                // We map this instead to meta, because the Mac GTK+ has mapped the cmd key
                // to the meta key (yay inconsistency!). IMO super would have been saner.
                if ((mod & Gdk.ModifierType.Mod1Mask) != 0)
                {
                    mod ^= Gdk.ModifierType.Mod1Mask;
                    mod |= Gdk.ModifierType.MetaMask;
                }

                // If Mod5 is active it *might* mean that opt/alt is active,
                // so we can unset this and map it back to the normal modifier.
                if ((mod & Gdk.ModifierType.Mod5Mask) != 0)
                {
                    mod ^= Gdk.ModifierType.Mod5Mask;
                    mod |= Gdk.ModifierType.Mod1Mask;
                }

                // When opt modifier is active, we need to decompose this to make the command appear correct for Mac.
                // In addition, we can only inspect whether the opt/alt key is pressed by examining
                // the key's "group", because the Mac GTK+ treats opt as a group modifier and does
                // not expose it as an actual GDK modifier.
                if (evt.Group == (byte)1)
                {
                    mod |= Gdk.ModifierType.Mod1Mask;
                    key  = GetGroupZeroKey(key, evt);
                }
            }

            //fix shift-tab weirdness. There isn't a nice name for untab, so make it shift-tab
            if (key == Gdk.Key.ISO_Left_Tab)
            {
                key  = Gdk.Key.Tab;
                mod |= Gdk.ModifierType.ShiftMask;
            }
        }
Esempio n. 8
0
 public bool Equals(AccelKey other)
 {
     return(true && Key.Equals(other.Key) && AccelMods.Equals(other.AccelMods) && AccelFlags.Equals(other.AccelFlags));
 }