2 * Copyright (C) 2013-2018 Paul Davis <paul@linuxaudiosystems.com>
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 along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #include <gtkmm/window.h>
21 #include "gtkmm2ext/visibility_tracker.h"
23 using namespace Gtkmm2ext;
25 bool VisibilityTracker::_use_window_manager_visibility = true;
27 VisibilityTracker::VisibilityTracker (Gtk::Window& win)
29 , _visibility (GDK_VISIBILITY_FULLY_OBSCURED)
31 _window.add_events (Gdk::VISIBILITY_NOTIFY_MASK);
32 _window.signal_visibility_notify_event().connect (sigc::mem_fun (*this, &VisibilityTracker::handle_visibility_notify_event));
36 VisibilityTracker::set_use_window_manager_visibility (bool yn)
38 _use_window_manager_visibility = yn;
42 VisibilityTracker::handle_visibility_notify_event (GdkEventVisibility* ev)
44 _visibility = ev->state;
49 VisibilityTracker::cycle_visibility ()
51 if (fully_visible ()) {
59 VisibilityTracker::fully_visible () const
61 if (_use_window_manager_visibility) {
62 return _window.is_mapped() && (_visibility == GDK_VISIBILITY_UNOBSCURED);
64 return _window.is_mapped();
69 VisibilityTracker::not_visible () const
71 if (_use_window_manager_visibility) {
72 return !_window.is_mapped() || (_visibility == GDK_VISIBILITY_FULLY_OBSCURED);
74 return !_window.is_mapped();
79 VisibilityTracker::partially_visible () const
81 if (_use_window_manager_visibility) {
82 return _window.is_mapped() && ((_visibility == GDK_VISIBILITY_PARTIAL) || (_visibility == GDK_VISIBILITY_UNOBSCURED));
84 return _window.is_mapped();