Re: Find out if a widget or window is actually visible?



On Wednesday 25 October 2006 10:21, Toralf Lund wrote:
> Does Gtkmm/Gdkmm offer a nice and simple way to find out if a widget or
> window is actually visible to the user, i.e. is mapped *and not obscured
> by another window*? I mean, .e.g Gdk::Window::is_viewable () and
> Gdk::Window::is_visible ()/Gtk::Widget::is_visible() will answer only
> first half of that question, I believe, i.e. they will tell me whether
> the window/widget is mapped, but not check if it is covered by something
> else.

I am not entirely sure if I understand you but Gtk::Widget::is_visible() will 
tell you whether the widget is obscured.  (Note however that a minimised 
window still counts as visible so in practice you will need to check for 
both.)

The best thing is to connect to the 
Gtk::Widget::signal_visibility_notify_event() signal of the Gtk::Window 
object concerned.  The GdkEventVisibility argument passed to the slot has an 
enumerated member variable called 'state' of type GdkVisibilityState which 
can tell you whether the widget is wholly or partially obscured (it has state 
values of GDK_VISIBILITY_UNOBSCURED GDK_VISIBILITY_PARTIAL and 
GDK_VISIBILITY_FULLY_OBSCURED).  The callback will be called whenever the 
visibility state changes.

Chris





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]