hide minimized window (C++,gtkmm)

Especially if you use a status icon you don’t want to have the window of your program minimized. It will eat space in your taskbar (in gnome3 the bar in the activity view) and needs to be handled.
To remove the icon you can use hide() but this must be triggered.
For this use on_my_window_state_event(GdkEventWindowState* event) and read the next state of the window out of GdkEventWindowState. Have a look for the valid states in

Before I come to the examples a little hint for getting the window back. First use deiconify(), then show() elsewise the window is stucked in the invisibility state.
Now some gkmm,C++ examples:

The initialisation of the trigger to hide:

main_win->signal_window_state_event().connect (sigc::mem_fun(*this,&gui::on_my_window_state_event));

The trigger method:

bool gui::on_my_window_state_event(GdkEventWindowState* event)
    if (event->new_window_state==GDK_WINDOW_STATE_ICONIFIED)
        return false;
        return false;

The restore method:

void gui::show()


The project I used as example:
https://github.com/devkral/asaus  (my project)



Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s