GdkWindowState 在GDK2和GDK3的使用区别
写个程序的时候,需要获取程序窗口的状态,之前代码是用GTK2编写的,现在用GTK3编译,结果发现,最大化后,无法还原了,仔细对比状态值,发现了问题,仔细对比API:GDK2:http://gtk.awaysoft.com/apis/lastest/gdk/gdk-Event-Structures.html#GdkWindowState
GDK3:http://gtk.awaysoft.com/apis/lastest/gdk3/gdk3-Event-Structures.html#GdkWindowState
对比,可以发现,在GDK3中添加了一个
GDK_WINDOW_STATE_FOCUSED = 1 << 7
即激活状态,这个状态几乎一直是存在的,(窗口不激活的时候,一般也不会检查状态吧)
所以,之前通过switch判断的代码就不可使用了,必须通过&运算符来判断。
之前代码:
switch(state){
case GDK_WINDOW_STATE_WITHDRAWN: af_window_set_visible(TRUE);
break;
case GDK_WINDOW_STATE_ICONIFIED: gtk_window_deiconify(GTK_WINDOW(window));
break;
case GDK_WINDOW_STATE_MAXIMIZED: gtk_window_unmaximize(GTK_WINDOW(window));
break;
case GDK_WINDOW_STATE_STICKY: gtk_window_unstick(GTK_WINDOW(window));
break;
case GDK_WINDOW_STATE_FULLSCREEN: af_window_set_fullscreen(FALSE);
break;
case GDK_WINDOW_STATE_ABOVE: af_window_set_above(FALSE);
break;
case GDK_WINDOW_STATE_BELOW: af_window_set_below(FALSE);
break;
default:
return FALSE;
}现在代码:
if ((state & GDK_WINDOW_STATE_WITHDRAWN)) af_window_set_visible(TRUE);
if ((state & GDK_WINDOW_STATE_ICONIFIED)) gtk_window_deiconify(GTK_WINDOW(window));
if ((state & GDK_WINDOW_STATE_MAXIMIZED)) gtk_window_unmaximize(GTK_WINDOW(window));
if ((state & GDK_WINDOW_STATE_STICKY)) gtk_window_unstick(GTK_WINDOW(window));
if ((state & GDK_WINDOW_STATE_FULLSCREEN)) af_window_set_fullscreen(FALSE);
if ((state & GDK_WINDOW_STATE_ABOVE)) af_window_set_above(FALSE);
if ((state & GDK_WINDOW_STATE_BELOW)) af_window_set_below(FALSE);
页:
[1]