force ArdourWindows to be TYPE_UTILITY so that they float "with" TYPE_DIALOG windows...
[ardour.git] / gtk2_ardour / ardour_window.cc
1 /*
2     Copyright (C) 2002-2011 Paul Davis
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #include <iostream>
21 #include <sigc++/bind.h>
22
23 #include <gtkmm2ext/doi.h>
24
25 #include "ardour_window.h"
26 #include "keyboard.h"
27
28 using namespace std;
29 using namespace Gtk;
30 using namespace Gtkmm2ext;
31
32 ArdourWindow::ArdourWindow (string title)
33         : Window ()
34         , VisibilityTracker (*((Gtk::Window*)this))
35 {
36         set_title (title);
37         init ();
38 }
39
40 ArdourWindow::ArdourWindow (Gtk::Window& parent, string /*title*/)
41         : Window ()
42         , VisibilityTracker (*((Gtk::Window*)this))
43 {
44         init ();
45         set_transient_for (parent);
46         set_position (Gtk::WIN_POS_CENTER_ON_PARENT);
47 }
48
49 ArdourWindow::~ArdourWindow ()
50 {
51 }
52
53 bool
54 ArdourWindow::on_enter_notify_event (GdkEventCrossing *ev)
55 {
56         Keyboard::the_keyboard().enter_window (ev, this);
57         return Window::on_enter_notify_event (ev);
58 }
59
60 bool
61 ArdourWindow::on_leave_notify_event (GdkEventCrossing *ev)
62 {
63         Keyboard::the_keyboard().leave_window (ev, this);
64         return Window::on_leave_notify_event (ev);
65 }
66
67 void
68 ArdourWindow::on_unmap ()
69 {
70         Keyboard::the_keyboard().leave_window (0, this);
71         Window::on_unmap ();
72 }
73
74 void
75 ArdourWindow::init ()
76 {
77         set_border_width (10);
78
79         /* ArdourWindows are not dialogs (they have no "OK" or "Close" button) but
80            they should be considered part of the same "window level" as a dialog. This
81            works on X11 and Quartz, in that:
82            
83            (a) utility & dialog windows are considered to be part of the same level
84            (b) they will float above normal windows without any particular effort
85         */
86
87         set_type_hint (Gdk::WINDOW_TYPE_HINT_UTILITY);
88 }
89