summaryrefslogtreecommitdiff
path: root/gtk2_ardour/keyboard.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2008-12-12 14:43:24 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2008-12-12 14:43:24 +0000
commitbc89fe0147c04b67141936d109c00dfd4d69cc4b (patch)
tree544ff450c40fe1f43853a8420228a26f27f1eafb /gtk2_ardour/keyboard.cc
parent30daaebaa2d90d6b0e8673143ccc3cacd7bd1753 (diff)
most of the 2.X->3.0 commit (up to rev 4299) except for gtk2_ardour/editor_canvas.cc; builds and runs and does a few specific things but expect it to be buggy for a while yet
git-svn-id: svn://localhost/ardour2/branches/3.0@4313 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/keyboard.cc')
-rw-r--r--gtk2_ardour/keyboard.cc74
1 files changed, 51 insertions, 23 deletions
diff --git a/gtk2_ardour/keyboard.cc b/gtk2_ardour/keyboard.cc
index ef8cc34389..d0fcbea5cf 100644
--- a/gtk2_ardour/keyboard.cc
+++ b/gtk2_ardour/keyboard.cc
@@ -64,6 +64,7 @@ guint Keyboard::TertiaryModifier = GDK_SHIFT_MASK; // Shift
guint Keyboard::Level4Modifier = GDK_CONTROL_MASK; // Control
guint Keyboard::CopyModifier = GDK_MOD1_MASK; // Alt/Option
guint Keyboard::RangeSelectModifier = GDK_SHIFT_MASK;
+guint Keyboard::button2_modifiers = Keyboard::SecondaryModifier|Keyboard::Level4Modifier;
#else
guint Keyboard::PrimaryModifier = GDK_CONTROL_MASK; // Control
guint Keyboard::SecondaryModifier = GDK_MOD1_MASK; // Alt/Option
@@ -71,8 +72,10 @@ guint Keyboard::TertiaryModifier = GDK_SHIFT_MASK; // Shift
guint Keyboard::Level4Modifier = GDK_MOD4_MASK; // Mod4/Windows
guint Keyboard::CopyModifier = GDK_CONTROL_MASK;
guint Keyboard::RangeSelectModifier = GDK_SHIFT_MASK;
+guint Keyboard::button2_modifiers = 0; /* not used */
#endif
+
Keyboard* Keyboard::_the_keyboard = 0;
Gtk::Window* Keyboard::current_window = 0;
bool Keyboard::_some_magic_widget_has_focus = false;
@@ -265,10 +268,20 @@ Keyboard::snooper (GtkWidget *widget, GdkEventKey *event)
}
}
- if (event->type == GDK_KEY_RELEASE && event->keyval == GDK_w && modifier_state_equals (event->state, PrimaryModifier)) {
- if (current_window) {
- current_window->hide ();
- current_window = 0;
+ /* Special keys that we want to handle in
+ any dialog, no matter whether it uses
+ the regular set of accelerators or not
+ */
+
+ if (event->type == GDK_KEY_RELEASE && modifier_state_equals (event->state, PrimaryModifier)) {
+ switch (event->keyval) {
+ case GDK_w:
+ if (current_window) {
+ current_window->hide ();
+ current_window = 0;
+ ret = true;
+ }
+ break;
}
}
@@ -291,25 +304,29 @@ Keyboard::enter_window (GdkEventCrossing *ev, Gtk::Window* win)
bool
Keyboard::leave_window (GdkEventCrossing *ev, Gtk::Window* win)
{
- switch (ev->detail) {
- case GDK_NOTIFY_INFERIOR:
- if (debug_keyboard) {
- cerr << "INFERIOR crossing ... out\n";
- }
- break;
-
- case GDK_NOTIFY_VIRTUAL:
- if (debug_keyboard) {
- cerr << "VIRTUAL crossing ... out\n";
- }
- /* fallthru */
-
- default:
- if (debug_keyboard) {
- cerr << "REAL CROSSING ... out\n";
- cerr << "clearing current target\n";
+ if (ev) {
+ switch (ev->detail) {
+ case GDK_NOTIFY_INFERIOR:
+ if (debug_keyboard) {
+ cerr << "INFERIOR crossing ... out\n";
+ }
+ break;
+
+ case GDK_NOTIFY_VIRTUAL:
+ if (debug_keyboard) {
+ cerr << "VIRTUAL crossing ... out\n";
+ }
+ /* fallthru */
+
+ default:
+ if (debug_keyboard) {
+ cerr << "REAL CROSSING ... out\n";
+ cerr << "clearing current target\n";
+ }
+ state.clear ();
+ current_window = 0;
}
- state.clear ();
+ } else {
current_window = 0;
}
@@ -363,13 +380,24 @@ Keyboard::set_snap_modifier (guint mod)
bool
Keyboard::is_edit_event (GdkEventButton *ev)
{
-
return (ev->type == GDK_BUTTON_PRESS || ev->type == GDK_BUTTON_RELEASE) &&
(ev->button == Keyboard::edit_button()) &&
((ev->state & RelevantModifierKeyMask) == Keyboard::edit_modifier());
}
bool
+Keyboard::is_button2_event (GdkEventButton* ev)
+{
+#ifdef GTKOSX
+ return (ev->button == 2) ||
+ ((ev->button == 1) &&
+ ((ev->state & Keyboard::button2_modifiers) == Keyboard::button2_modifiers));
+#else
+ return ev->button == 2;
+#endif
+}
+
+bool
Keyboard::is_delete_event (GdkEventButton *ev)
{
return (ev->type == GDK_BUTTON_PRESS || ev->type == GDK_BUTTON_RELEASE) &&