- if (key_editor == 0) {
- key_editor = new KeyEditor;
- key_editor->signal_unmap().connect (sigc::bind (sigc::ptr_fun(&ActionManager::uncheck_toggleaction), X_("<Actions>/Common/ToggleKeyEditor")));
- }
-
- RefPtr<Action> act = ActionManager::get_action (X_("Common"), X_("ToggleKeyEditor"));
- if (act) {
- RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
-
- if (tact->get_active()) {
- key_editor->show_all ();
- key_editor->present ();
+ bool obscuring = false;
+ /* currently, if windows are on different
+ screens then we do nothing; but in the
+ future we may want to bring the window
+ to the front or something, so I'm leaving this
+ variable for future use
+ */
+ bool same_screen = true;
+
+ if (editor && mixer) {
+
+ /* remeber: Screen != Monitor (Screen is a separately rendered
+ * continuous geometry that make include 1 or more monitors.
+ */
+
+ if (editor->get_screen() != mixer->get_screen() && (mixer->get_screen() != 0) && (editor->get_screen() != 0)) {
+ // different screens, so don't do anything
+ same_screen = false;
+ } else {
+ // they are on the same screen, see if they are obscuring each other
+
+ gint ex, ey, ew, eh;
+ gint mx, my, mw, mh;
+
+ editor->get_position (ex, ey);
+ editor->get_size (ew, eh);
+
+ mixer->get_position (mx, my);
+ mixer->get_size (mw, mh);
+
+ GdkRectangle e;
+ GdkRectangle m;
+ GdkRectangle r;
+
+ e.x = ex;
+ e.y = ey;
+ e.width = ew;
+ e.height = eh;
+
+ m.x = mx;
+ m.y = my;
+ m.width = mw;
+ m.height = mh;
+
+ if (gdk_rectangle_intersect (&e, &m, &r)) {
+ obscuring = true;
+ }
+ }
+ }
+
+ if (mixer && !mixer->not_visible() && mixer->property_has_toplevel_focus()) {
+ if (obscuring && same_screen) {
+ goto_editor_window();
+ }
+ } else if (editor && !editor->not_visible() && editor->property_has_toplevel_focus()) {
+ if (obscuring && same_screen) {
+ goto_mixer_window();
+ }
+ } else if (mixer && mixer->not_visible()) {
+ if (obscuring && same_screen) {
+ goto_mixer_window ();
+ }
+ } else if (editor && editor->not_visible()) {
+ if (obscuring && same_screen) {
+ goto_editor_window ();
+ }
+ } else if (obscuring && same_screen) {
+ //it's unclear what to do here, so just do the opposite of what we did last time (old behavior)
+ if (_mixer_on_top) {
+ goto_editor_window ();