2 Copyright (C) 2013 Paul Davis
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.
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.
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.
20 #include <gtkmm/window.h>
22 #include "gtkmm2ext/visibility_tracker.h"
24 using namespace Gtkmm2ext;
26 VisibilityTracker::VisibilityTracker (Gtk::Window& win)
28 , _visibility (GdkVisibilityState (0))
30 _window.add_events (Gdk::VISIBILITY_NOTIFY_MASK);
31 _window.signal_visibility_notify_event().connect (sigc::mem_fun (*this, &VisibilityTracker::handle_visibility_notify_event));
35 VisibilityTracker::handle_visibility_notify_event (GdkEventVisibility* ev)
37 _visibility = ev->state;
38 // std::cerr << "VT: " << _window.get_title() << " vis event, fv = " << fully_visible() << " pv = " << partially_visible() << " nv = " << not_visible() << std::endl;
43 VisibilityTracker::cycle_visibility ()
45 if (fully_visible ()) {
53 VisibilityTracker::fully_visible () const
55 return _window.is_mapped() && (_visibility == GDK_VISIBILITY_UNOBSCURED);
59 VisibilityTracker::not_visible () const
61 return !_window.is_mapped() || (_visibility == GDK_VISIBILITY_FULLY_OBSCURED);
65 VisibilityTracker::partially_visible () const
67 return _window.is_mapped() && ((_visibility == GDK_VISIBILITY_PARTIAL) || (_visibility == GDK_VISIBILITY_UNOBSCURED));