fix up Meta/Mod2/Command madness for OS X

git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@10796 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2011-11-23 17:21:22 +00:00
parent ad8240f5c1
commit 58a9b0f2de
5 changed files with 20 additions and 105 deletions

View File

@ -621,8 +621,12 @@ Keyboard::load_keybindings (string path)
any Meta entries to Mod2
*/
std::map<string,string> dict;
dict.push_back (pair ("<Meta>", "<Mod2>"));
(void) PBD::file_subst (path, dict);
dict.insert (pair<string,string> ("<Meta>", "<Mod2>"));
if (PBD::file_subst (path, dict)) {
cerr << string_compose (_("Your keybindings will be wrong. The file %1 needs to be editable by Ardour to update it"),
path)
<< endl;
}
#endif
try {

View File

@ -1145,18 +1145,18 @@ static const struct {
#ifdef GTKOSX
/* Command = Meta
/* Command = Mod2
Option/Alt = Mod1
*/
{ "Shift", GDK_SHIFT_MASK },
{ "Command", GDK_META_MASK },
{ "Command", GDK_MOD2_MASK },
{ "Control", GDK_CONTROL_MASK },
{ "Option", GDK_MOD1_MASK },
{ "Command-Shift", GDK_MOD1_MASK|GDK_SHIFT_MASK },
{ "Command-Option", GDK_MOD1_MASK|GDK_MOD5_MASK },
{ "Shift-Option", GDK_SHIFT_MASK|GDK_MOD5_MASK },
{ "Shift-Command-Option", GDK_MOD5_MASK|GDK_SHIFT_MASK|GDK_MOD1_MASK },
{ "Command-Shift", GDK_MOD2_MASK|GDK_SHIFT_MASK },
{ "Command-Option", GDK_MOD2_MASK|GDK_MOD1_MASK },
{ "Shift-Option", GDK_SHIFT_MASK|GDK_MOD1_MASK },
{ "Shift-Command-Option", GDK_MOD1_MASK|GDK_SHIFT_MASK|GDK_MOD2_MASK },
#else
{ "Shift", GDK_SHIFT_MASK },

View File

@ -410,73 +410,6 @@ relay_key_press (GdkEventKey* ev, Gtk::Window* win)
}
}
#ifdef GTKOSX
static guint
osx_keyval_without_alt (guint accent_keyval)
{
switch (accent_keyval) {
case GDK_oe:
return GDK_q;
case GDK_registered:
return GDK_r;
case GDK_dagger:
return GDK_t;
case GDK_yen:
return GDK_y;
case GDK_diaeresis:
return GDK_u;
case GDK_oslash:
return GDK_o;
case GDK_Greek_pi:
return GDK_p;
case GDK_leftdoublequotemark:
return GDK_bracketleft;
case GDK_leftsinglequotemark:
return GDK_bracketright;
case GDK_guillemotleft:
return GDK_backslash;
case GDK_aring:
return GDK_a;
case GDK_ssharp:
return GDK_s;
case GDK_partialderivative:
return GDK_d;
case GDK_function:
return GDK_f;
case GDK_copyright:
return GDK_g;
case GDK_abovedot:
return GDK_h;
case GDK_notsign:
return GDK_l;
case GDK_ellipsis:
return GDK_semicolon;
case GDK_ae:
return GDK_apostrophe;
case GDK_Greek_OMEGA:
return GDK_z;
case GDK_ccedilla:
return GDK_c;
case GDK_radical:
return GDK_v;
case GDK_integral:
return GDK_b;
case GDK_mu:
return GDK_m;
case GDK_lessthanequal:
return GDK_comma;
case GDK_greaterthanequal:
return GDK_period;
case GDK_division:
return GDK_slash;
default:
break;
}
return GDK_VoidSymbol;
}
#endif
bool
key_press_focus_accelerator_handler (Gtk::Window& window, GdkEventKey* ev)
{
@ -485,17 +418,18 @@ key_press_focus_accelerator_handler (Gtk::Window& window, GdkEventKey* ev)
bool special_handling_of_unmodified_accelerators = false;
bool allow_activating = true;
// #define DEBUG_ACCELERATOR_HANDLING
#define DEBUG_ACCELERATOR_HANDLING
#ifdef DEBUG_ACCELERATOR_HANDLING
//bool debug = (getenv ("ARDOUR_DEBUG_ACCELERATOR_HANDLING") != 0);
bool debug=true;
bool debug = (getenv ("ARDOUR_DEBUG_ACCELERATOR_HANDLING") != 0);
#endif
if (focus) {
if (GTK_IS_ENTRY(focus) || Keyboard::some_magic_widget_has_focus()) {
special_handling_of_unmodified_accelerators = true;
}
#ifdef DEBUG_ACCELERATOR_HANDLING
cerr << "Focus widget name " << gtk_widget_get_name(focus) << endl;
if (debug) {
cerr << "Focus widget name " << gtk_widget_get_name(focus) << endl;
}
#endif
}
@ -513,7 +447,7 @@ key_press_focus_accelerator_handler (Gtk::Window& window, GdkEventKey* ev)
<< " alt/mod1 " << ((ev->state & GDK_MOD1_MASK) ? 1 : 0)
<< " mod2 " << ((ev->state & GDK_MOD2_MASK) ? 1 : 0)
<< " shift " << ((ev->state & GDK_SHIFT_MASK) ? 1 : 0)
<< " cmd/meta " << ((ev->state & GDK_META_MASK) ? 1 : 0)
<< " meta " << ((ev->state & GDK_META_MASK) ? 1 : 0)
<< " lock " << ((ev->state & GDK_LOCK_MASK) ? 1 : 0)
<< " special handling ? "
<< special_handling_of_unmodified_accelerators
@ -556,27 +490,6 @@ key_press_focus_accelerator_handler (Gtk::Window& window, GdkEventKey* ev)
all "normal text" accelerators.
*/
#ifdef GTKOSX
if (!special_handling_of_unmodified_accelerators) {
if (ev->state & GDK_MOD1_MASK) {
/* we're not in a text entry or "magic focus" widget so we don't want OS X "special-character"
text-style handling of alt-<key>. change the keyval back to what it would be without
the alt key. this way, we see <alt>-v rather than <alt>-radical and so on.
*/
guint keyval_without_alt = osx_keyval_without_alt (ev->keyval);
if (keyval_without_alt != GDK_VoidSymbol) {
#ifdef DEBUG_ACCELERATOR_HANDLING
cerr << "Remapped " << gdk_keyval_name (ev->keyval) << " to " << gdk_keyval_name (keyval_without_alt) << endl;
#endif
ev->keyval = keyval_without_alt;
ev->group = 0;
}
}
}
#endif
if (!special_handling_of_unmodified_accelerators) {
/* pretend that certain key events that GTK does not allow

View File

@ -870,9 +870,7 @@ cocoa_menu_item_update_accelerator (NSMenuItem *cocoa_item,
modifiers |= NSControlKeyMask;
}
/* gdk/quartz maps Command to Meta (XXX check this - it may move to SUPER at some point) */
if (key->accel_mods & GDK_META_MASK) {
if (key->accel_mods & GDK_MOD2_MASK) {
modifiers |= NSCommandKeyMask;
}
}

View File

@ -28,7 +28,7 @@ using namespace Gdk;
using namespace std;
#ifdef GTKOSX
int PixFader::fine_scale_modifier = GDK_META_MASK;
int PixFader::fine_scale_modifier = GDK_MOD2_MASK;
#else
int PixFader::fine_scale_modifier = GDK_CONTROL_MASK;
#endif