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 bool VisibilityTracker::_use_window_manager_visibility = true;
28 VisibilityTracker::VisibilityTracker (Gtk::Window& win)
30 , _visibility (GdkVisibilityState (0))
32 _window.add_events (Gdk::VISIBILITY_NOTIFY_MASK);
33 _window.signal_visibility_notify_event().connect (sigc::mem_fun (*this, &VisibilityTracker::handle_visibility_notify_event));
37 VisibilityTracker::set_use_window_manager_visibility (bool yn)
39 _use_window_manager_visibility = yn;
43 VisibilityTracker::handle_visibility_notify_event (GdkEventVisibility* ev)
45 _visibility = ev->state;
50 VisibilityTracker::cycle_visibility ()
52 if (fully_visible ()) {
60 VisibilityTracker::fully_visible () const
62 if (_use_window_manager_visibility) {
63 return _window.is_mapped() && (_visibility == GDK_VISIBILITY_UNOBSCURED);
65 return _window.is_mapped();
70 VisibilityTracker::not_visible () const
72 if (_use_window_manager_visibility) {
73 return !_window.is_mapped() || (_visibility == GDK_VISIBILITY_FULLY_OBSCURED);
75 return !_window.is_mapped();
80 VisibilityTracker::partially_visible () const
82 if (_use_window_manager_visibility) {
83 return _window.is_mapped() && ((_visibility == GDK_VISIBILITY_PARTIAL) || (_visibility == GDK_VISIBILITY_UNOBSCURED));
85 return _window.is_mapped();