Re: How to get the window deiconify event?



2012-12-23 10:02, Jiergir Ogoerg skrev:
Hi,
There are methods for iconify()ing (minimizing) and deiconify()ing a window, but there are no obvious signals to get these events. I found here[1] how to get the iconify event, but how do I get the deiconify event?

I need 4 events (window hide/show/iconified/deiconified events), to make my app smart enough to not bother repainting if it's not visible.

Hide/show detects when the window goes to/from the system tray or when it initially appears.

Iconify/deiconify (on Ubuntu) happen when the app goes to/from the left vertical bar by clicking the minimize window button and respectively by clicking its icon in the left vertical bar.


[1]
http://cubicarch.wordpress.com/2012/06/11/hide-minimized-window-cgtkmm/


I think Gtk::Widget::signal_hide(), Gtk::Widget::signal_show() and Gtk::Widget::signal_window_state_event() is all you need. A handler of signal_window_state_event() takes a GdkEventWindowState* argument, and that structure contains 'changed_mask' and 'new_window_state' which show what has changed, and how it has changed. I haven't used this signal myself, but the documentation says it's emitted both when the window is iconified and when it's deiconified. See the documentation of Gtk::Window::iconify() and Gtk::Window::deiconify() at
http://developer.gnome.org/gtkmm/stable/classGtk_1_1Window.html

The test
  if (event->new_window_state==GDK_WINDOW_STATE_ICONIFIED)
in the page you link to, seems unsafe. new_window_state contains bit flags, and I suppose more than one flag can be set.
If you want to test one of the flags, this is better:
  if (event->new_window_state & GDK_WINDOW_STATE_ICONIFIED)

Possibly you need only signal_window_state_event(). GdkEventWindowState::new_window_state can also contain the flag GDK_WINDOW_STATE_WITHDRAWN, which means "the window is not shown." Probably that means it's hidden.

Kjell



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