static void pager_propertynotify(pager_priv *p, XEvent *ev) { Atom at = ev->xproperty.atom; Window win = ev->xproperty.window; task *t; ENTER; if ((win == GDK_ROOT_WINDOW()) || !(t = g_hash_table_lookup(p->htable, &win))) RET(); DBG("window=0x%lx\n", t->win); if (at == a_NET_WM_STATE) { DBG("event=NET_WM_STATE\n"); get_net_wm_state(t->win, &t->nws); } else if (at == a_NET_WM_DESKTOP) { DBG("event=NET_WM_DESKTOP\n"); desk_set_dirty_by_win(p, t); // to clean up desks where this task was t->desktop = get_net_wm_desktop(t->win); } else { RET(); } desk_set_dirty_by_win(p, t); RET(); }
/* Handle PropertyNotify event. * http://tronche.com/gui/x/icccm/ * http://standards.freedesktop.org/wm-spec/wm-spec-1.4.html */ static void pager_property_notify_event(PagerPlugin * pg, XEvent * ev) { /* State may be PropertyNewValue, PropertyDeleted. */ if (((XPropertyEvent*) ev)->state == PropertyNewValue) { Atom at = ev->xproperty.atom; Window win = ev->xproperty.window; if (win != GDK_ROOT_WINDOW()) { /* Look up task structure by X window handle. */ PagerTask * tk = task_lookup(pg, win); if (tk != NULL) { /* Install an error handler that ignores BadWindow. * We frequently get a PropertyNotify event on deleted windows. */ XErrorHandler previous_error_handler = XSetErrorHandler(panel_handle_x_error_swallow_BadWindow_BadDrawable); /* Dispatch on atom. */ if (at == a_WM_STATE) { /* Window changed state. */ tk->ws = get_wm_state(tk->win); desk_set_dirty_by_win(pg, tk); } else if (at == a_NET_WM_STATE) { /* Window changed EWMH state. */ get_net_wm_state(tk->win, &tk->nws); desk_set_dirty_by_win(pg, tk); } else if (at == a_NET_WM_DESKTOP) { /* Window changed desktop. * Mark both old and new desktops for redraw. */ desk_set_dirty_by_win(pg, tk); tk->desktop = get_net_wm_desktop(tk->win); desk_set_dirty_by_win(pg, tk); XSetErrorHandler(previous_error_handler); } } } } }
static void do_net_client_list_stacking(FbEv *ev, pager *p) { int i; task *t; ENTER; if (p->wins) XFree(p->wins); p->wins = get_xaproperty (GDK_ROOT_WINDOW(), a_NET_CLIENT_LIST_STACKING, XA_WINDOW, &p->winnum); if (!p->wins || !p->winnum) RET(); /* refresh existing tasks and add new */ for (i = 0; i < p->winnum; i++) { if ((t = g_hash_table_lookup(p->htable, &p->wins[i]))) { t->refcount++; if (t->stacking != i) { t->stacking = i; desk_set_dirty_by_win(p, t); } } else { t = g_new0(task, 1); t->refcount++; t->win = p->wins[i]; t->ws = get_wm_state (t->win); t->desktop = get_net_wm_desktop(t->win); get_net_wm_state(t->win, &t->nws); get_net_wm_window_type(t->win, &t->nwwt); task_get_sizepos(t); if (!FBPANEL_WIN(t->win)) XSelectInput (GDK_DISPLAY(), t->win, PropertyChangeMask | StructureNotifyMask); g_hash_table_insert(p->htable, &t->win, t); DBG("add %x\n", t->win); desk_set_dirty_by_win(p, t); } } /* pass throu hash table and delete stale windows */ g_hash_table_foreach_remove(p->htable, (GHRFunc) task_remove_stale, (gpointer)p); RET(); }