自动隐藏,只响应父窗体的鼠标离开事件

参考自:

http://blog.csdn.net/maojudong/archive/2008/03/19/2197425.aspx

 

typedef struct _Parent Parent;
struct _Parent
{
  GtkWidget *window;  // top window
  gboolean   hiddened;
};

gboolean leave_event (GtkWidget         *widget,
                      GdkEventCrossing  *event,
                      gpointer           data)
{
    Parent *parent = (Parent *)data;
    if (!parent->hiddened && event->detail != GDK_NOTIFY_INFERIOR)
    {
      gtk_widget_set_size_request (GTK_WIDGET (parent->window), gdk_screen_width(), 1);
      parent->hiddened = TRUE;
    }

    return FALSE;
}

int main(int   argc,
         char *argv[])
{
... //skip
    Parent *parent;
    parent = g_new (Parent, 1);
    parent->window = window;
    parent->hiddened = TRUE;

    g_signal_connect (G_OBJECT (window), "leave_notify_event",
                      G_CALLBACK (leave_event), parent);
... //skip
}

你可能感兴趣的:(GTK,.net,Blog)