ardour
visibility_tracker.cc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2013 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 #include <iostream>
20 #include <gtkmm/window.h>
21 
23 
24 using namespace Gtkmm2ext;
25 
27  : _window (win)
28  , _visibility (GdkVisibilityState (0))
29 {
30  _window.add_events (Gdk::VISIBILITY_NOTIFY_MASK);
31  _window.signal_visibility_notify_event().connect (sigc::mem_fun (*this, &VisibilityTracker::handle_visibility_notify_event));
32 }
33 
34 bool
36 {
37  _visibility = ev->state;
38  // std::cerr << "VT: " << _window.get_title() << " vis event, fv = " << fully_visible() << " pv = " << partially_visible() << " nv = " << not_visible() << std::endl;
39  return false;
40 }
41 
42 void
44 {
45  if (fully_visible ()) {
46  _window.hide ();
47  } else {
48  _window.present ();
49  }
50 }
51 
52 bool
54 {
55  return _window.is_mapped() && (_visibility == GDK_VISIBILITY_UNOBSCURED);
56 }
57 
58 bool
60 {
61  return !_window.is_mapped() || (_visibility == GDK_VISIBILITY_FULLY_OBSCURED);
62 }
63 
64 bool
66 {
67  return _window.is_mapped() && ((_visibility == GDK_VISIBILITY_PARTIAL) || (_visibility == GDK_VISIBILITY_UNOBSCURED));
68 }
bool handle_visibility_notify_event(GdkEventVisibility *)